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
|
```html
|
||||||
<adf-cloud-group
|
<adf-cloud-group
|
||||||
[applicationName]="'simple-app'"
|
[appName]="'simple-app'"
|
||||||
[mode]="'multiple'">
|
[mode]="'multiple'">
|
||||||
</adf-cloud-group>
|
</adf-cloud-group>
|
||||||
```
|
```
|
||||||
@@ -26,7 +26,7 @@ Searches Groups.
|
|||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| 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). |
|
| 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. |
|
| 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));
|
findGroupsByNameSpy = spyOn(service, 'findGroupsByName').and.returnValue(of(mockGroups));
|
||||||
getClientIdByApplicationNameSpy = spyOn(service, 'getClientIdByApplicationName').and.returnValue(of('mock-client-id'));
|
getClientIdByApplicationNameSpy = spyOn(service, 'getClientIdByApplicationName').and.returnValue(of('mock-client-id'));
|
||||||
checkGroupHasClientRoleMappingSpy = spyOn(service, 'checkGroupHasClientRoleMapping').and.returnValue(of(true));
|
checkGroupHasClientRoleMappingSpy = spyOn(service, 'checkGroupHasClientRoleMapping').and.returnValue(of(true));
|
||||||
component.applicationName = 'mock-app-name';
|
component.appName = 'mock-app-name';
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create GroupCloudComponent', () => {
|
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(() => {
|
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();
|
fixture.detectChanges();
|
||||||
let inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
let inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||||
inputHTMLElement.focus();
|
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(() => {
|
it('should not list groups who do not have access to the app when appName is specified', async(() => {
|
||||||
checkGroupHasClientRoleMappingSpy.and.returnValue(of(false));
|
checkGroupHasClientRoleMappingSpy.and.returnValue(of(false));
|
||||||
component.applicationName = 'sample-app';
|
component.appName = 'sample-app';
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
let inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('[data-automation-id="adf-cloud-group-search-input"]');
|
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. */
|
/** Name of the application. If specified this shows the users who have access to the app. */
|
||||||
@Input()
|
@Input()
|
||||||
applicationName: string;
|
appName: string;
|
||||||
|
|
||||||
/** User selection mode (single/multiple). */
|
/** User selection mode (single/multiple). */
|
||||||
@Input()
|
@Input()
|
||||||
@@ -97,14 +97,14 @@ export class GroupCloudComponent implements OnInit {
|
|||||||
this.loadPreSelectGroups();
|
this.loadPreSelectGroups();
|
||||||
this.initSearch();
|
this.initSearch();
|
||||||
|
|
||||||
if (this.applicationName) {
|
if (this.appName) {
|
||||||
this.disableSearch();
|
this.disableSearch();
|
||||||
this.loadClientId();
|
this.loadClientId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async 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) {
|
if (this.clientId) {
|
||||||
this.enableSearch();
|
this.enableSearch();
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,6 @@ import { TRANSLATION_PROVIDER } from '@alfresco/adf-core';
|
|||||||
import { AppListCloudModule } from './app/app-list-cloud.module';
|
import { AppListCloudModule } from './app/app-list-cloud.module';
|
||||||
import { TaskCloudModule } from './task/task-cloud.module';
|
import { TaskCloudModule } from './task/task-cloud.module';
|
||||||
import { ProcessCloudModule } from './process/process-cloud.module';
|
import { ProcessCloudModule } from './process/process-cloud.module';
|
||||||
import { GroupCloudModule } from './group/group-cloud.module';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -41,8 +40,7 @@ import { GroupCloudModule } from './group/group-cloud.module';
|
|||||||
exports: [
|
exports: [
|
||||||
AppListCloudModule,
|
AppListCloudModule,
|
||||||
ProcessCloudModule,
|
ProcessCloudModule,
|
||||||
TaskCloudModule,
|
TaskCloudModule
|
||||||
GroupCloudModule
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class ProcessServicesCloudModule { }
|
export class ProcessServicesCloudModule { }
|
||||||
|
@@ -64,6 +64,10 @@
|
|||||||
<div fxFlex>
|
<div fxFlex>
|
||||||
<adf-cloud-people #peopleInput *ngIf="currentUser" [appName]="appName" [preSelectUsers]="[currentUser]" (selectUser)="onAssigneeSelect($event)" (removeUser)="onRemoveUser()"></adf-cloud-people>
|
<adf-cloud-people #peopleInput *ngIf="currentUser" [appName]="appName" [preSelectUsers]="[currentUser]" (selectUser)="onAssigneeSelect($event)" (removeUser)="onRemoveUser()"></adf-cloud-people>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div fxFlex>
|
||||||
|
<adf-cloud-group #groupInput *ngIf="currentUser" [mode]="'multiple'" [appName]="appName" (selectGroup)="onSelectGroup($event)" (removeGroup)="onRemoveGroup($event)"></adf-cloud-group>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
|
|
||||||
|
@@ -125,7 +125,7 @@ describe('StartTaskCloudComponent', () => {
|
|||||||
createTaskButton.click();
|
createTaskButton.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
const taskRequest = new TaskDetailsCloudModel({ name: 'fakeName', assignee: 'currentUser'});
|
const taskRequest = new TaskDetailsCloudModel({ name: 'fakeName', assignee: 'currentUser', candidateGroups: []});
|
||||||
expect(createNewTaskSpy).toHaveBeenCalledWith(taskRequest);
|
expect(createNewTaskSpy).toHaveBeenCalledWith(taskRequest);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@@ -137,7 +137,7 @@ describe('StartTaskCloudComponent', () => {
|
|||||||
createTaskButton.click();
|
createTaskButton.click();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
const taskRequest = new TaskDetailsCloudModel({ name: 'fakeName', assignee: 'currentUser'});
|
const taskRequest = new TaskDetailsCloudModel({ name: 'fakeName', assignee: 'currentUser', candidateGroups: []});
|
||||||
expect(createNewTaskSpy).toHaveBeenCalledWith(taskRequest);
|
expect(createNewTaskSpy).toHaveBeenCalledWith(taskRequest);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
@@ -84,6 +84,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
|||||||
submitted = false;
|
submitted = false;
|
||||||
|
|
||||||
assigneeName: string;
|
assigneeName: string;
|
||||||
|
candidateGroups: string [] = [];
|
||||||
|
|
||||||
dateError: boolean;
|
dateError: boolean;
|
||||||
|
|
||||||
@@ -145,6 +146,8 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
|||||||
newTask.appName = this.getAppName();
|
newTask.appName = this.getAppName();
|
||||||
newTask.dueDate = this.getDueDate();
|
newTask.dueDate = this.getDueDate();
|
||||||
newTask.assignee = this.assigneeName;
|
newTask.assignee = this.assigneeName;
|
||||||
|
|
||||||
|
newTask.candidateGroups = this.candidateGroups;
|
||||||
this.createNewTask(new TaskDetailsCloudModel(newTask));
|
this.createNewTask(new TaskDetailsCloudModel(newTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +196,16 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
|||||||
this.assigneeName = null;
|
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) {
|
public whitespaceValidator(control: FormControl) {
|
||||||
const isWhitespace = (control.value || '').trim().length === 0;
|
const isWhitespace = (control.value || '').trim().length === 0;
|
||||||
const isValid = !isWhitespace;
|
const isValid = !isWhitespace;
|
||||||
|
@@ -19,6 +19,7 @@ export class StartTaskCloudRequestModel {
|
|||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
assignee: string;
|
assignee: string;
|
||||||
|
candidateGroups: string [];
|
||||||
priority: string;
|
priority: string;
|
||||||
dueDate: Date;
|
dueDate: Date;
|
||||||
payloadType: string;
|
payloadType: string;
|
||||||
@@ -30,6 +31,7 @@ export class StartTaskCloudRequestModel {
|
|||||||
this.assignee = obj.assignee || null;
|
this.assignee = obj.assignee || null;
|
||||||
this.priority = obj.priority || null;
|
this.priority = obj.priority || null;
|
||||||
this.dueDate = obj.dueDate || null;
|
this.dueDate = obj.dueDate || null;
|
||||||
|
this.candidateGroups = obj.candidateGroups || null;
|
||||||
this.payloadType = 'CreateTaskPayload';
|
this.payloadType = 'CreateTaskPayload';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,7 @@ export class TaskDetailsCloudModel {
|
|||||||
processInstanceId: string;
|
processInstanceId: string;
|
||||||
status: string;
|
status: string;
|
||||||
standAlone: boolean;
|
standAlone: boolean;
|
||||||
|
candidateGroups: string [];
|
||||||
managerOfCandidateGroup: boolean;
|
managerOfCandidateGroup: boolean;
|
||||||
memberOfCandidateGroup: boolean;
|
memberOfCandidateGroup: boolean;
|
||||||
memberOfCandidateUsers: boolean;
|
memberOfCandidateUsers: boolean;
|
||||||
@@ -64,6 +65,7 @@ export class TaskDetailsCloudModel {
|
|||||||
this.processInstanceId = obj.processInstanceId || null;
|
this.processInstanceId = obj.processInstanceId || null;
|
||||||
this.status = obj.status || null;
|
this.status = obj.status || null;
|
||||||
this.standAlone = obj.standAlone || null;
|
this.standAlone = obj.standAlone || null;
|
||||||
|
this.candidateGroups = obj.candidateGroups || null;
|
||||||
this.managerOfCandidateGroup = obj.managerOfCandidateGroup || null;
|
this.managerOfCandidateGroup = obj.managerOfCandidateGroup || null;
|
||||||
this.memberOfCandidateGroup = obj.memberOfCandidateGroup || null;
|
this.memberOfCandidateGroup = obj.memberOfCandidateGroup || null;
|
||||||
this.memberOfCandidateUsers = obj.memberOfCandidateUsers || 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 { StartTaskCloudService } from './services/start-task-cloud.service';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { PeopleCloudComponent } from './components/people-cloud/people-cloud.component';
|
import { PeopleCloudComponent } from './components/people-cloud/people-cloud.component';
|
||||||
|
import { GroupCloudModule } from '../../group/group-cloud.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -41,6 +42,7 @@ import { PeopleCloudComponent } from './components/people-cloud/people-cloud.com
|
|||||||
MaterialModule,
|
MaterialModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
|
GroupCloudModule,
|
||||||
FormModule
|
FormModule
|
||||||
],
|
],
|
||||||
declarations: [StartTaskCloudComponent, PeopleCloudComponent],
|
declarations: [StartTaskCloudComponent, PeopleCloudComponent],
|
||||||
|
@@ -19,3 +19,4 @@ export * from './lib/process-services-cloud.module';
|
|||||||
export * from './lib/app/public-api';
|
export * from './lib/app/public-api';
|
||||||
export * from './lib/process/public-api';
|
export * from './lib/process/public-api';
|
||||||
export * from './lib/task/public-api';
|
export * from './lib/task/public-api';
|
||||||
|
export * from './lib/group/public-api';
|
||||||
|
Reference in New Issue
Block a user