mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
committed by
Eugenio Romano
parent
033939615d
commit
2e03ef3548
@@ -17,6 +17,8 @@
|
||||
- [Activiti Content Component](#activiti-content-component)
|
||||
* [Properties](#properties-1)
|
||||
* [Events](#events-1)
|
||||
- [ADF Form List Component](#adf-form-list-component)
|
||||
* [Properties](#properties-2)
|
||||
- [FormService Service](#formservice-service)
|
||||
* [Events](#events-2)
|
||||
* [Methods](#methods)
|
||||
@@ -279,6 +281,24 @@ The recommended set of properties can be found in the following table:
|
||||
| --- | --- |
|
||||
| contentClick | Invoked when the content is clicked. |
|
||||
|
||||
## ADF Form List Component
|
||||
|
||||
The component shows the activiti forms as a list.
|
||||
|
||||
```html
|
||||
<adf-form-list
|
||||
[forms]="[{ name: 'My Name', lastUpdatedByFullName: 'My User Name', lastUpdated: '2017-06-01'}]">
|
||||
</adf-form-list>
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
The recommended set of properties can be found in the following table:
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| forms | any | | The array that contains the information to show inside the list. |
|
||||
|
||||
## FormService Service
|
||||
|
||||
```ts
|
||||
|
@@ -18,8 +18,9 @@
|
||||
import { NgModule, ModuleWithProviders } from '@angular/core';
|
||||
import { MdCheckboxModule, MdTabsModule, MdCardModule, MdButtonModule, MdIconModule, MdSlideToggleModule, MdInputModule } from '@angular/material';
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
|
||||
import { DataTableModule } from 'ng2-alfresco-datatable';
|
||||
import { ActivitiForm } from './src/components/activiti-form.component';
|
||||
import { ADFFormList } from './src/components/adf-form-list.component';
|
||||
import { ActivitiContent } from './src/components/activiti-content.component';
|
||||
import { FormFieldComponent } from './src/components/form-field/form-field.component';
|
||||
import { ActivitiStartForm } from './src/components/activiti-start-form.component';
|
||||
@@ -34,6 +35,7 @@ import { HttpModule } from '@angular/http';
|
||||
import { WIDGET_DIRECTIVES, MASK_DIRECTIVE } from './src/components/widgets/index';
|
||||
|
||||
export * from './src/components/activiti-form.component';
|
||||
export * from './src/components/adf-form-list.component';
|
||||
export * from './src/components/activiti-content.component';
|
||||
export * from './src/components/activiti-start-form.component';
|
||||
export * from './src/services/form.service';
|
||||
@@ -46,6 +48,7 @@ export * from './src/events/index';
|
||||
|
||||
export const ACTIVITI_FORM_DIRECTIVES: any[] = [
|
||||
ActivitiForm,
|
||||
ADFFormList,
|
||||
ActivitiContent,
|
||||
ActivitiStartForm,
|
||||
FormFieldComponent,
|
||||
@@ -65,6 +68,7 @@ export const ACTIVITI_FORM_PROVIDERS: any[] = [
|
||||
@NgModule({
|
||||
imports: [
|
||||
CoreModule,
|
||||
DataTableModule,
|
||||
HttpModule,
|
||||
MdCheckboxModule,
|
||||
MdTabsModule,
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<alfresco-datatable *ngIf="!isEmpty()"
|
||||
[rows]="forms">
|
||||
<data-columns>
|
||||
<data-column key="name" type="text" title="Name" class="ellipsis-cell" [sortable]="true"></data-column>
|
||||
<data-column key="lastUpdatedByFullName" type="text" title="User" class="ellipsis-cell" [sortable]="true"></data-column>
|
||||
<data-column key="lastUpdated" type="date" format="shortDate" title="Date"></data-column>
|
||||
</data-columns>
|
||||
</alfresco-datatable>
|
@@ -0,0 +1,88 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { CoreModule, AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { DataTableModule } from 'ng2-alfresco-datatable';
|
||||
import { FormService } from '../services/form.service';
|
||||
import { EcmModelService } from '../services/ecm-model.service';
|
||||
import { ADFFormList } from './adf-form-list.component';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('TaskAttachmentList', () => {
|
||||
|
||||
let component: ADFFormList;
|
||||
let fixture: ComponentFixture<ADFFormList>;
|
||||
let service: FormService;
|
||||
let componentHandler: any;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot(),
|
||||
DataTableModule
|
||||
],
|
||||
declarations: [
|
||||
ADFFormList
|
||||
],
|
||||
providers: [
|
||||
FormService,
|
||||
EcmModelService
|
||||
]
|
||||
}).compileComponents();
|
||||
|
||||
let translateService = TestBed.get(AlfrescoTranslationService);
|
||||
spyOn(translateService, 'addTranslationFolder').and.stub();
|
||||
spyOn(translateService, 'get').and.callFake((key) => {
|
||||
return Observable.of(key);
|
||||
});
|
||||
|
||||
componentHandler = jasmine.createSpyObj('componentHandler', [
|
||||
'upgradeAllRegistered',
|
||||
'upgradeElement'
|
||||
]);
|
||||
window['componentHandler'] = componentHandler;
|
||||
}));
|
||||
|
||||
beforeEach(async(() => {
|
||||
|
||||
fixture = TestBed.createComponent(ADFFormList);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
service = TestBed.get(FormService);
|
||||
|
||||
}));
|
||||
|
||||
fit('should show the forms as a list', async(() => {
|
||||
spyOn(service, 'getForms').and.returnValue(Observable.of([
|
||||
{ name: 'FakeName-1', lastUpdatedByFullName: 'FakeUser-1', lastUpdated: '2017-01-02' },
|
||||
{ name: 'FakeName-2', lastUpdatedByFullName: 'FakeUser-2', lastUpdated: '2017-01-03' }
|
||||
]));
|
||||
|
||||
component.ngOnChanges({});
|
||||
|
||||
fixture.whenStable()
|
||||
.then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.queryAll(By.css('alfresco-datatable tbody tr')).length).toBe(2);
|
||||
});
|
||||
}));
|
||||
|
||||
});
|
@@ -0,0 +1,50 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnChanges, Input, SimpleChanges } from '@angular/core';
|
||||
import { LogService } from 'ng2-alfresco-core';
|
||||
import { FormService } from './../services/form.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-form-list',
|
||||
templateUrl: './adf-form-list.component.html',
|
||||
styleUrls: ['./adf-form-list.component.css']
|
||||
})
|
||||
export class ADFFormList implements OnChanges {
|
||||
|
||||
@Input()
|
||||
forms: any [] = [];
|
||||
|
||||
constructor(protected formService: FormService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
this.getForms();
|
||||
}
|
||||
|
||||
isEmpty(): boolean {
|
||||
return this.forms && this.forms.length === 0;
|
||||
}
|
||||
|
||||
getForms() {
|
||||
this.formService.getForms().subscribe((forms) => {
|
||||
this.forms.push(...forms);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -138,7 +138,11 @@ export class FormService {
|
||||
'modelType': 2
|
||||
};
|
||||
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.modelsApi.getModels(opts));
|
||||
return Observable.fromPromise(
|
||||
this.apiService.getInstance().activiti.modelsApi.getModels(opts))
|
||||
.map((response: any) => <any[]> response.data || [])
|
||||
.catch(err => this.handleError(err));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user