mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3946] Add the GroupCloudComponent to the StartTaskCloudComponent (#4202)
* Add GroupComponent to the start task cloud * [ADF-3946] Exported unexported componentes in group module * [ADF-3946] Used group module in start task module * Fix import * Fix build name * Fix build name unit tests * Fix unit test * Add space to rebuild travis
This commit is contained in:
@@ -13,7 +13,7 @@ Searches Groups.
|
||||
|
||||
```html
|
||||
<adf-cloud-group
|
||||
[applicationName]="'simple-app'"
|
||||
[appName]="'simple-app'"
|
||||
[mode]="'multiple'">
|
||||
</adf-cloud-group>
|
||||
```
|
||||
@@ -26,7 +26,7 @@ Searches Groups.
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| ---- | ---- | ------------- | ----------- |
|
||||
| applicationName | `string` | | Name of the application. If specified this shows the users who have access to the app. |
|
||||
| appName | `string` | | Name of the application. If specified this shows the users who have access to the app. |
|
||||
| mode | `string` | | User selection mode (single/multiple). |
|
||||
| preSelectGroups | [`GroupModel`](../../process-services-cloud/src/lib/group/models/group.model.ts)`[]` | \[] | Array of users to be pre-selected. This pre-selects all users in multi selection mode and only the first user of the array in single selection mode. |
|
||||
|
||||
|
@@ -49,7 +49,7 @@ describe('GroupCloudComponent', () => {
|
||||
findGroupsByNameSpy = spyOn(service, 'findGroupsByName').and.returnValue(of(mockGroups));
|
||||
getClientIdByApplicationNameSpy = spyOn(service, 'getClientIdByApplicationName').and.returnValue(of('mock-client-id'));
|
||||
checkGroupHasClientRoleMappingSpy = spyOn(service, 'checkGroupHasClientRoleMapping').and.returnValue(of(true));
|
||||
component.applicationName = 'mock-app-name';
|
||||
component.appName = 'mock-app-name';
|
||||
});
|
||||
|
||||
it('should create GroupCloudComponent', () => {
|
||||
@@ -197,7 +197,7 @@ describe('GroupCloudComponent', () => {
|
||||
}));
|
||||
|
||||
it('should list groups who have access to the app when appName is specified', async(() => {
|
||||
component.applicationName = 'sample-app';
|
||||
component.appName = 'sample-app';
|
||||
fixture.detectChanges();
|
||||
let inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||
inputHTMLElement.focus();
|
||||
@@ -213,7 +213,7 @@ describe('GroupCloudComponent', () => {
|
||||
|
||||
it('should not list groups who do not have access to the app when appName is specified', async(() => {
|
||||
checkGroupHasClientRoleMappingSpy.and.returnValue(of(false));
|
||||
component.applicationName = 'sample-app';
|
||||
component.appName = 'sample-app';
|
||||
|
||||
fixture.detectChanges();
|
||||
let inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('[data-automation-id="adf-cloud-group-search-input"]');
|
||||
|
@@ -48,7 +48,7 @@ export class GroupCloudComponent implements OnInit {
|
||||
|
||||
/** Name of the application. If specified this shows the users who have access to the app. */
|
||||
@Input()
|
||||
applicationName: string;
|
||||
appName: string;
|
||||
|
||||
/** User selection mode (single/multiple). */
|
||||
@Input()
|
||||
@@ -97,14 +97,14 @@ export class GroupCloudComponent implements OnInit {
|
||||
this.loadPreSelectGroups();
|
||||
this.initSearch();
|
||||
|
||||
if (this.applicationName) {
|
||||
if (this.appName) {
|
||||
this.disableSearch();
|
||||
this.loadClientId();
|
||||
}
|
||||
}
|
||||
|
||||
private async loadClientId() {
|
||||
this.clientId = await this.groupService.getClientIdByApplicationName(this.applicationName).toPromise();
|
||||
this.clientId = await this.groupService.getClientIdByApplicationName(this.appName).toPromise();
|
||||
if (this.clientId) {
|
||||
this.enableSearch();
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@ import { TRANSLATION_PROVIDER } from '@alfresco/adf-core';
|
||||
import { AppListCloudModule } from './app/app-list-cloud.module';
|
||||
import { TaskCloudModule } from './task/task-cloud.module';
|
||||
import { ProcessCloudModule } from './process/process-cloud.module';
|
||||
import { GroupCloudModule } from './group/group-cloud.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -41,8 +40,7 @@ import { GroupCloudModule } from './group/group-cloud.module';
|
||||
exports: [
|
||||
AppListCloudModule,
|
||||
ProcessCloudModule,
|
||||
TaskCloudModule,
|
||||
GroupCloudModule
|
||||
TaskCloudModule
|
||||
]
|
||||
})
|
||||
export class ProcessServicesCloudModule { }
|
||||
|
@@ -64,6 +64,10 @@
|
||||
<div fxFlex>
|
||||
<adf-cloud-people #peopleInput *ngIf="currentUser" [appName]="appName" [preSelectUsers]="[currentUser]" (selectUser)="onAssigneeSelect($event)" (removeUser)="onRemoveUser()"></adf-cloud-people>
|
||||
</div>
|
||||
|
||||
<div fxFlex>
|
||||
<adf-cloud-group #groupInput *ngIf="currentUser" [mode]="'multiple'" [appName]="appName" (selectGroup)="onSelectGroup($event)" (removeGroup)="onRemoveGroup($event)"></adf-cloud-group>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
|
||||
|
@@ -125,7 +125,7 @@ describe('StartTaskCloudComponent', () => {
|
||||
createTaskButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const taskRequest = new TaskDetailsCloudModel({ name: 'fakeName', assignee: 'currentUser'});
|
||||
const taskRequest = new TaskDetailsCloudModel({ name: 'fakeName', assignee: 'currentUser', candidateGroups: []});
|
||||
expect(createNewTaskSpy).toHaveBeenCalledWith(taskRequest);
|
||||
});
|
||||
}));
|
||||
@@ -137,7 +137,7 @@ describe('StartTaskCloudComponent', () => {
|
||||
createTaskButton.click();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
const taskRequest = new TaskDetailsCloudModel({ name: 'fakeName', assignee: 'currentUser'});
|
||||
const taskRequest = new TaskDetailsCloudModel({ name: 'fakeName', assignee: 'currentUser', candidateGroups: []});
|
||||
expect(createNewTaskSpy).toHaveBeenCalledWith(taskRequest);
|
||||
});
|
||||
}));
|
||||
|
@@ -84,6 +84,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
||||
submitted = false;
|
||||
|
||||
assigneeName: string;
|
||||
candidateGroups: string [] = [];
|
||||
|
||||
dateError: boolean;
|
||||
|
||||
@@ -145,6 +146,8 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
||||
newTask.appName = this.getAppName();
|
||||
newTask.dueDate = this.getDueDate();
|
||||
newTask.assignee = this.assigneeName;
|
||||
|
||||
newTask.candidateGroups = this.candidateGroups;
|
||||
this.createNewTask(new TaskDetailsCloudModel(newTask));
|
||||
}
|
||||
|
||||
@@ -193,6 +196,16 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
||||
this.assigneeName = null;
|
||||
}
|
||||
|
||||
onSelectGroup(group) {
|
||||
this.candidateGroups.push(group.name);
|
||||
}
|
||||
|
||||
onRemoveGroup(group) {
|
||||
this.candidateGroups = this.candidateGroups.filter( (name) => {
|
||||
return name !== group.name;
|
||||
});
|
||||
}
|
||||
|
||||
public whitespaceValidator(control: FormControl) {
|
||||
const isWhitespace = (control.value || '').trim().length === 0;
|
||||
const isValid = !isWhitespace;
|
||||
|
@@ -19,6 +19,7 @@ export class StartTaskCloudRequestModel {
|
||||
name: string;
|
||||
description: string;
|
||||
assignee: string;
|
||||
candidateGroups: string [];
|
||||
priority: string;
|
||||
dueDate: Date;
|
||||
payloadType: string;
|
||||
@@ -30,6 +31,7 @@ export class StartTaskCloudRequestModel {
|
||||
this.assignee = obj.assignee || null;
|
||||
this.priority = obj.priority || null;
|
||||
this.dueDate = obj.dueDate || null;
|
||||
this.candidateGroups = obj.candidateGroups || null;
|
||||
this.payloadType = 'CreateTaskPayload';
|
||||
}
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ export class TaskDetailsCloudModel {
|
||||
processInstanceId: string;
|
||||
status: string;
|
||||
standAlone: boolean;
|
||||
candidateGroups: string [];
|
||||
managerOfCandidateGroup: boolean;
|
||||
memberOfCandidateGroup: boolean;
|
||||
memberOfCandidateUsers: boolean;
|
||||
@@ -64,6 +65,7 @@ export class TaskDetailsCloudModel {
|
||||
this.processInstanceId = obj.processInstanceId || null;
|
||||
this.status = obj.status || null;
|
||||
this.standAlone = obj.standAlone || null;
|
||||
this.candidateGroups = obj.candidateGroups || null;
|
||||
this.managerOfCandidateGroup = obj.managerOfCandidateGroup || null;
|
||||
this.memberOfCandidateGroup = obj.memberOfCandidateGroup || null;
|
||||
this.memberOfCandidateUsers = obj.memberOfCandidateUsers || null;
|
||||
|
@@ -25,6 +25,7 @@ import { StartTaskCloudComponent } from './components/start-task-cloud.component
|
||||
import { StartTaskCloudService } from './services/start-task-cloud.service';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { PeopleCloudComponent } from './components/people-cloud/people-cloud.component';
|
||||
import { GroupCloudModule } from '../../group/group-cloud.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -41,6 +42,7 @@ import { PeopleCloudComponent } from './components/people-cloud/people-cloud.com
|
||||
MaterialModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
GroupCloudModule,
|
||||
FormModule
|
||||
],
|
||||
declarations: [StartTaskCloudComponent, PeopleCloudComponent],
|
||||
|
@@ -19,3 +19,4 @@ export * from './lib/process-services-cloud.module';
|
||||
export * from './lib/app/public-api';
|
||||
export * from './lib/process/public-api';
|
||||
export * from './lib/task/public-api';
|
||||
export * from './lib/group/public-api';
|
||||
|
Reference in New Issue
Block a user