mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[ADF-897] - ActivitiPeopleList - use the adf prefix (#2001)
* Use the adf as prexif instead of activiti * Fix typo * Fix wrong import
This commit is contained in:
parent
e7dfe2d9a7
commit
908e27a3ae
@ -1,7 +0,0 @@
|
|||||||
<alfresco-datatable
|
|
||||||
[rows]="users"
|
|
||||||
[actions]="hasActions()"
|
|
||||||
(rowClick)="selectUser($event)"
|
|
||||||
(showRowActionsMenu)="onShowRowActionsMenu($event)"
|
|
||||||
(executeRowAction)="onExecuteRowAction($event)">
|
|
||||||
</alfresco-datatable>
|
|
@ -1,100 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @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 { Observable } from 'rxjs/Observable';
|
|
||||||
import { CoreModule, AlfrescoTranslationService } from 'ng2-alfresco-core';
|
|
||||||
import { ActivitiPeopleList } from './activiti-people-list.component';
|
|
||||||
import { User, UserEventModel } from '../models/index';
|
|
||||||
import { DataTableModule, ObjectDataRow, DataRowEvent, DataRowActionEvent } from 'ng2-alfresco-datatable';
|
|
||||||
|
|
||||||
declare let jasmine: any;
|
|
||||||
|
|
||||||
const fakeUser: User = new User({
|
|
||||||
id: '1',
|
|
||||||
firstName: 'fake-name',
|
|
||||||
lastName: 'fake-last',
|
|
||||||
email: 'fake@mail.com'
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('ActivitiPeopleList', () => {
|
|
||||||
|
|
||||||
let activitiPeopleListComponent: ActivitiPeopleList;
|
|
||||||
let fixture: ComponentFixture<ActivitiPeopleList>;
|
|
||||||
let element: HTMLElement;
|
|
||||||
let componentHandler;
|
|
||||||
|
|
||||||
beforeEach(async(() => {
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [
|
|
||||||
CoreModule.forRoot(),
|
|
||||||
DataTableModule
|
|
||||||
],
|
|
||||||
declarations: [
|
|
||||||
ActivitiPeopleList
|
|
||||||
]
|
|
||||||
}).compileComponents().then(() => {
|
|
||||||
|
|
||||||
let translateService = TestBed.get(AlfrescoTranslationService);
|
|
||||||
spyOn(translateService, 'addTranslationFolder').and.stub();
|
|
||||||
spyOn(translateService.translate, 'get').and.callFake((key) => { return Observable.of(key); });
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(ActivitiPeopleList);
|
|
||||||
activitiPeopleListComponent = fixture.componentInstance;
|
|
||||||
element = fixture.nativeElement;
|
|
||||||
componentHandler = jasmine.createSpyObj('componentHandler', [
|
|
||||||
'upgradeAllRegistered'
|
|
||||||
]);
|
|
||||||
|
|
||||||
window['componentHandler'] = componentHandler;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should emit row click event', (done) => {
|
|
||||||
let row = new ObjectDataRow(fakeUser);
|
|
||||||
let rowEvent = new DataRowEvent(row, null);
|
|
||||||
|
|
||||||
activitiPeopleListComponent.clickRow.subscribe(selectedUser => {
|
|
||||||
expect(selectedUser.id).toEqual('1');
|
|
||||||
expect(selectedUser.email).toEqual('fake@mail.com');
|
|
||||||
expect(activitiPeopleListComponent.user.id).toEqual('1');
|
|
||||||
expect(activitiPeopleListComponent.user.email).toEqual('fake@mail.com');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
activitiPeopleListComponent.selectUser(rowEvent);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should emit row action event', (done) => {
|
|
||||||
let row = new ObjectDataRow(fakeUser);
|
|
||||||
let removeObj = {
|
|
||||||
name: 'remove',
|
|
||||||
title: 'Remove'
|
|
||||||
};
|
|
||||||
let rowActionEvent = new DataRowActionEvent(row, removeObj);
|
|
||||||
|
|
||||||
activitiPeopleListComponent.clickAction.subscribe((selectedAction: UserEventModel) => {
|
|
||||||
expect(selectedAction.type).toEqual('remove');
|
|
||||||
expect(selectedAction.value.id).toEqual('1');
|
|
||||||
expect(selectedAction.value.email).toEqual('fake@mail.com');
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
activitiPeopleListComponent.onExecuteRowAction(rowActionEvent);
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,99 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @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, Input, Output, EventEmitter, ViewChild, ContentChild } from '@angular/core';
|
|
||||||
import { User, UserEventModel } from '../models/index';
|
|
||||||
import { DataColumnListComponent } from 'ng2-alfresco-core';
|
|
||||||
import { DataTableComponent } from 'ng2-alfresco-datatable';
|
|
||||||
|
|
||||||
declare let componentHandler: any;
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'activiti-people-list',
|
|
||||||
templateUrl: './activiti-people-list.component.html',
|
|
||||||
styleUrls: ['./activiti-people-list.component.css']
|
|
||||||
})
|
|
||||||
|
|
||||||
export class ActivitiPeopleList {
|
|
||||||
|
|
||||||
@ContentChild(DataColumnListComponent) columnList: DataColumnListComponent;
|
|
||||||
|
|
||||||
@ViewChild(DataTableComponent)
|
|
||||||
peopleDataTable: DataTableComponent;
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
users: User[];
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
actions: boolean = false;
|
|
||||||
|
|
||||||
@Output()
|
|
||||||
clickRow: EventEmitter<User> = new EventEmitter<User>();
|
|
||||||
|
|
||||||
@Output()
|
|
||||||
clickAction: EventEmitter<UserEventModel> = new EventEmitter<UserEventModel>();
|
|
||||||
|
|
||||||
user: User;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterContentInit() {
|
|
||||||
this.peopleDataTable.columnList = this.columnList;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterViewInit() {
|
|
||||||
this.setupMaterialComponents(componentHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
setupMaterialComponents(handler?: any): boolean {
|
|
||||||
// workaround for MDL issues with dynamic components
|
|
||||||
let isUpgraded: boolean = false;
|
|
||||||
if (handler) {
|
|
||||||
handler.upgradeAllRegistered();
|
|
||||||
isUpgraded = true;
|
|
||||||
}
|
|
||||||
return isUpgraded;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectUser(event: any) {
|
|
||||||
this.user = event.value.obj;
|
|
||||||
this.clickRow.emit(this.user);
|
|
||||||
}
|
|
||||||
|
|
||||||
hasActions(): boolean {
|
|
||||||
return this.actions;
|
|
||||||
}
|
|
||||||
|
|
||||||
onShowRowActionsMenu(event: any) {
|
|
||||||
|
|
||||||
let removeAction = {
|
|
||||||
title: 'Remove',
|
|
||||||
name: 'remove'
|
|
||||||
};
|
|
||||||
|
|
||||||
event.value.actions = [
|
|
||||||
removeAction
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
onExecuteRowAction(event: any) {
|
|
||||||
let args = event.value;
|
|
||||||
let action = args.action;
|
|
||||||
this.clickAction.emit(new UserEventModel({type: action.name, value: args.row.obj}));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user