diff --git a/ng2-components/ng2-activiti-tasklist/README.md b/ng2-components/ng2-activiti-tasklist/README.md index c36398bb05..122423d04a 100644 --- a/ng2-components/ng2-activiti-tasklist/README.md +++ b/ng2-components/ng2-activiti-tasklist/README.md @@ -40,6 +40,7 @@ * [Properties](#properties-8) + [Events](#events-7) - [ADF Comments Component](#adf-comments-component) +- [Start Task Component](#start-task-component) * [Properties](#properties-9) + [Events](#events-8) - [Build from sources](#build-from-sources) @@ -489,12 +490,38 @@ This component displays comments entered by involved users to a specified task. | --- | --- | | error | Raised when an error occurs while displaying/adding a comment | +## Start Task Component + +This component Creates/Starts new task for the specified app + +```html + + +``` + +![adf-start-task](docs/assets/adf-start-task.png) + +### Properties + +| Name | Type | Description | +| --- | --- | --- | +| appId | string | (**required**): The id of the app. | + +#### Events + +| Name | Description | +| --- | --- | +| onSuccess | Raised when the task is successfully created | +| cancel | Raised when the cancel button is pressed by the user | +| error | Raised if there is an error during task creation | + ## Build from sources You can build component from sources with the following commands: - ```sh npm install + npm run build ``` diff --git a/ng2-components/ng2-activiti-tasklist/docs/assets/adf-start-task.png b/ng2-components/ng2-activiti-tasklist/docs/assets/adf-start-task.png new file mode 100644 index 0000000000..e9ccecce86 Binary files /dev/null and b/ng2-components/ng2-activiti-tasklist/docs/assets/adf-start-task.png differ diff --git a/ng2-components/ng2-activiti-tasklist/index.ts b/ng2-components/ng2-activiti-tasklist/index.ts index 3ee2627887..04cfd0add0 100644 --- a/ng2-components/ng2-activiti-tasklist/index.ts +++ b/ng2-components/ng2-activiti-tasklist/index.ts @@ -17,7 +17,17 @@ import { DatePipe } from '@angular/common'; import { ModuleWithProviders, NgModule } from '@angular/core'; -import { MdButtonModule, MdIconModule, MdInputModule, MdProgressSpinnerModule } from '@angular/material'; +import { + MdButtonModule, + MdIconModule, + MdInputModule, + MdProgressSpinnerModule, + MdDatepickerModule, + MdGridListModule, + MdAutocompleteModule, + MdNativeDateModule, + MdSelectModule +} from '@angular/material'; import { ActivitiFormModule } from 'ng2-activiti-form'; import { CoreModule } from 'ng2-alfresco-core'; import { DataTableModule } from 'ng2-alfresco-datatable'; @@ -32,12 +42,12 @@ import { ActivitiCreateTaskAttachmentComponent, ActivitiFilters, ActivitiPeople, - ActivitiPeopleSearch, - ActivitiStartTaskButton, - ActivitiTaskDetails, ActivitiTaskHeader, - ActivitiTaskList, AdfCommentListComponent, + ActivitiPeopleSearch, + ActivitiStartTaskComponent, + ActivitiTaskDetails, + ActivitiTaskList, NoTaskDetailsTemplateComponent, PeopleList, TaskAttachmentListComponent @@ -59,7 +69,7 @@ export const ACTIVITI_TASKLIST_DIRECTIVES: any[] = [ ActivitiComments, ActivitiPeople, ActivitiTaskHeader, - ActivitiStartTaskButton, + ActivitiStartTaskComponent, ActivitiPeopleSearch, TaskAttachmentListComponent, ActivitiCreateTaskAttachmentComponent, @@ -81,7 +91,12 @@ export const ACTIVITI_TASKLIST_PROVIDERS: any[] = [ MdIconModule, MdButtonModule, MdInputModule, - MdProgressSpinnerModule + MdProgressSpinnerModule, + MdDatepickerModule, + MdNativeDateModule, + MdSelectModule, + MdAutocompleteModule, + MdGridListModule ], declarations: [ ...ACTIVITI_TASKLIST_DIRECTIVES diff --git a/ng2-components/ng2-activiti-tasklist/src/assets/start-task.mock.ts b/ng2-components/ng2-activiti-tasklist/src/assets/start-task.mock.ts new file mode 100644 index 0000000000..eb1f153c13 --- /dev/null +++ b/ng2-components/ng2-activiti-tasklist/src/assets/start-task.mock.ts @@ -0,0 +1,34 @@ +/*! + * @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. + */ + +export let startTaskMock = { + 'name': 'fakeName', + 'description': 'fakeDescription', + 'assignee': {'id': 2001, 'firstName': 'Jhon', 'lastName': 'Adams', 'email': 'jhon@app.activiti.com'}, + 'dueDate': '2017-11-03T15:25:42.749+0000', + 'formKey': '11201', + 'category': 'fakeAppId' +}; + +export let noDataMock = { + 'name': '', + 'description': '', + 'assignee': {}, + 'dueDate': '', + 'formKey': '', + 'category': ';' +}; diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.css b/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.css index ff0f8dd865..253809829b 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.css +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.css @@ -1,7 +1,37 @@ -:host { - width: 100%; +.adf-new-task-heading { + padding: 12px 20px; + font-family: Muli; + font-weight: bold; + border-bottom: 1px solid #eee; + font-size: 18px; + float: left; + text-align: left; + width: calc(100% - 40px); } -.activiti-label { - font-weight: bolder; +.adf-new-task-layout-card { + width: 66.6667%; + margin-right:calc(33.3333%/2 - 24px); + margin-left: calc(33.3333%/2 - 24px); + margin-top: 10px; + margin-bottom: 10px; + padding: 0px +} + +.adf-new-task-footer { + padding: 4px; + font-family: Muli; + font-size: 18px; + border-top: 1px solid #eee; + float: left; + width: calc(100% - 40px); + text-align: right; +} + +.adf-start-task-input-container { + width: 80%; +} + +.adf-new-task-text-width { + width: 90%; } diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.html b/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.html index 1bcae17ba6..cf6be4eabe 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.html +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.html @@ -1,39 +1,63 @@ - - - -

{{'START_TASK.DIALOG.TITLE'|translate}}

-
-
- - -
-
- - -
-
- -
-
- -
-
-
- - -
-
+ + + +
{{'START_TASK.FORM.TITLE'|translate}}
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + {{'START_TASK.FORM.LABEL.NONE'|translate}} + {{ user.firstName +' '+ user.lastName }} + + + + + + + {{'START_TASK.FORM.LABEL.NONE'|translate}} + {{ form.name }} + + + + + + + + + + + + +
diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.spec.ts index ae70df803d..8c48a9f298 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.spec.ts @@ -16,94 +16,199 @@ */ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { MdButtonModule, MdDatepickerModule, MdGridListModule, MdIconModule, MdInputModule, MdNativeDateModule, MdSelectModule } from '@angular/material'; import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; import { Observable } from 'rxjs/Rx'; +import { StartTaskModel } from '../models/index'; +import { ActivitiPeopleService } from '../services/activiti-people.service'; import { ActivitiTaskListService } from '../services/activiti-tasklist.service'; -import { ActivitiStartTaskButton } from './activiti-start-task.component'; +import { startTaskMock } from './../assets/start-task.mock'; +import { ActivitiStartTaskComponent } from './activiti-start-task.component'; declare let jasmine: any; -describe('ActivitiStartTaskButton', () => { +describe('ActivitiStartTaskComponent', () => { - let activitiStartTaskButton: ActivitiStartTaskButton; - let fixture: ComponentFixture; + let activitiStartTaskComponent: ActivitiStartTaskComponent; + let fixture: ComponentFixture; let service: ActivitiTaskListService; + let peopleService: ActivitiPeopleService; let element: HTMLElement; - let startTaskButton: HTMLElement; - + let getformlistSpy: jasmine.Spy; + let getWorkflowUsersSpy: jasmine.Spy; + let getcreateNewTaskSpy: jasmine.Spy; + let fakeForms = [ + { + id: 123, + name: 'Display Data' + }, + { + id: 1111, + name: 'Employee Info' + } + ]; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ - CoreModule.forRoot() + CoreModule.forRoot(), + MdInputModule, + MdIconModule, + MdButtonModule, + MdDatepickerModule, + MdGridListModule, + MdNativeDateModule, + MdSelectModule ], declarations: [ - ActivitiStartTaskButton + ActivitiStartTaskComponent ], providers: [ - ActivitiTaskListService + ActivitiTaskListService, + ActivitiPeopleService ] }).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(ActivitiStartTaskButton); - activitiStartTaskButton = fixture.componentInstance; + fixture = TestBed.createComponent(ActivitiStartTaskComponent); + activitiStartTaskComponent = fixture.componentInstance; element = fixture.nativeElement; fixture.detectChanges(); - startTaskButton = element.querySelector('#start-task-button'); }); })); beforeEach(() => { - jasmine.Ajax.install(); service = fixture.debugElement.injector.get(ActivitiTaskListService); + peopleService = fixture.debugElement.injector.get(ActivitiPeopleService); + getformlistSpy = spyOn(service, 'getFormList').and.returnValue(Observable.of(fakeForms)); + getWorkflowUsersSpy = spyOn(peopleService, 'getWorkflowUsers').and.returnValue(Observable.of([ + { + id: 1, + firstName: 'fakeName', + lastName: 'fakeName', + email: 'fake@app.activiti.com', + company: 'Alfresco.com', + pictureId: 3003 + }, + { + id: 1001, + firstName: 'fake-name', + lastName: 'fake-name', + email: 'fake-@app.com', + company: 'app' + } + ])); }); - afterEach(() => { - jasmine.Ajax.uninstall(); + it('should create instance of ActivitiStartTaskComponent', () => { + expect(fixture.componentInstance instanceof ActivitiStartTaskComponent).toBe(true, 'should create ActivitiStartTaskComponent'); }); - it('should show start task button', () => { - expect(element.querySelector('#start-task-button')).toBeDefined(); - expect(element.querySelector('#start-task-button')).not.toBeNull(); - expect(element.querySelector('#start-task-button').textContent).toContain('START_TASK.BUTTON'); + it('should fetch fakeform on ngonint', () => { + activitiStartTaskComponent.ngOnInit(); + expect(activitiStartTaskComponent.forms).toEqual(fakeForms); + expect(activitiStartTaskComponent.forms[0].name).toEqual('Display Data'); + expect(activitiStartTaskComponent.forms[1].name).toEqual('Employee Info'); + expect(activitiStartTaskComponent.forms[1].id).toEqual(1111); + expect(getformlistSpy).toHaveBeenCalled(); }); - it('should show start dialog on press button', () => { - startTaskButton.click(); - expect(element.querySelector('#start-task-dialog')).not.toBeNull(); - expect(element.querySelector('#start-task-dialog').getAttribute('open')).not.toBeNull(); - expect(element.querySelector('#start-task-dialog-title')).not.toBeNull(); - expect(element.querySelector('#start-task-dialog-title').textContent).toContain('START_TASK.DIALOG.TITLE'); - }); + describe('create task', () => { - it('should close start dialog on cancel button', () => { - startTaskButton.click(); - expect(element.querySelector('#start-task-dialog')).not.toBeNull(); - expect(element.querySelector('#start-task-dialog').getAttribute('open')).not.toBeNull(); - let cancelButton = element.querySelector('#button-cancel'); - cancelButton.click(); - expect(element.querySelector('#start-task-dialog').getAttribute('open')).toBeNull(); - }); + beforeEach(() => { + jasmine.Ajax.install(); + getcreateNewTaskSpy = spyOn(service, 'createNewTask').and.returnValue(Observable.of( + { + id: 91, + name: 'fakeName', + formKey: '4', + assignee: {id: 1001, firstName: 'fakeName', email: 'fake@app.activiti.com'} + } + )); + }); - it('should attach a task when a form id slected', () => { - let attachFormToATask = spyOn(service, 'attachFormToATask').and.returnValue(Observable.of()); - spyOn(service, 'createNewTask').and.callFake( - function() { - return Observable.create(observer => { - observer.next({ id: 'task-id'}); - observer.complete(); - }); + afterEach(() => { + jasmine.Ajax.uninstall(); + }); + + it('should create new task when start is clicked', async(() => { + activitiStartTaskComponent.onSuccess.subscribe((res) => { + expect(res).toBeDefined(); }); + activitiStartTaskComponent.appId = 'fakeAppId'; + activitiStartTaskComponent.startTaskmodel = new StartTaskModel(startTaskMock); + activitiStartTaskComponent.start(); + jasmine.Ajax.requests.mostRecent().respondWith({ + 'status': 200 + }); + })); - let createTaskButton = element.querySelector('#button-start'); + it('should send on onSuccess event when the task is started', async(() => { + activitiStartTaskComponent.onSuccess.subscribe((res) => { + expect(res).toBeDefined(); + expect(res.id).toBe(91); + expect(res.name).toBe('fakeName'); + expect(res.formKey).toBe('4'); + expect(res.assignee.id).toBe(1001); + }); + activitiStartTaskComponent.appId = 'fakeAppId'; + activitiStartTaskComponent.startTaskmodel = new StartTaskModel(startTaskMock); + activitiStartTaskComponent.start(); + jasmine.Ajax.requests.mostRecent().respondWith({ + 'status': 200, + contentType: 'json', + responseText: + { + id: '91', + name: 'fakeName', + description: 'fakeDescription', + formKey: '4', + assignee: {id: 1001, firstName: 'fakeName', email: 'fake@app.activiti.com'}, + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null + } + }); + })); - activitiStartTaskButton.name = 'fake-name'; - activitiStartTaskButton.formId = '123'; - startTaskButton.click(); - createTaskButton.click(); - expect(attachFormToATask).toHaveBeenCalled(); + it('should send on onSuccess event when only name is given', async(() => { + activitiStartTaskComponent.onSuccess.subscribe((res) => { + expect(res).toBeDefined(); + }); + activitiStartTaskComponent.appId = 'fakeAppId'; + activitiStartTaskComponent.startTaskmodel.name = 'fakeName'; + activitiStartTaskComponent.startTaskmodel = new StartTaskModel(startTaskMock); + activitiStartTaskComponent.start(); + jasmine.Ajax.requests.mostRecent().respondWith({ + 'status': 200, + contentType: 'json', + responseText: {} + }); + })); + + it('should attach a task when a form id selected', () => { + activitiStartTaskComponent.onSuccess.subscribe((res) => { + expect(res).toBeDefined(); + expect(res.formKey).toBe('4'); + }); + activitiStartTaskComponent.appId = 'fakeAppId'; + activitiStartTaskComponent.startTaskmodel = new StartTaskModel(startTaskMock); + activitiStartTaskComponent.start(); + expect(getcreateNewTaskSpy).toHaveBeenCalled(); + }); + + it('should not emit onSuccess event when data not present', async(() => { + let onSuccessSpy: jasmine.Spy = spyOn(activitiStartTaskComponent.onSuccess, 'emit'); + activitiStartTaskComponent.startTaskmodel = new StartTaskModel(null); + activitiStartTaskComponent.start(); + fixture.detectChanges(); + expect(getcreateNewTaskSpy).not.toHaveBeenCalled(); + expect(onSuccessSpy).not.toHaveBeenCalled(); + })); }); it('should not attach a task when a form id is not slected', () => { @@ -115,60 +220,56 @@ describe('ActivitiStartTaskButton', () => { observer.complete(); }); }); - let createTaskButton = element.querySelector('#button-start'); - - activitiStartTaskButton.name = 'fake-name'; - startTaskButton.click(); + activitiStartTaskComponent.startTaskmodel.name = 'fake-name'; createTaskButton.click(); expect(attachFormToATask).not.toHaveBeenCalled(); }); - it('should load form when dialogs open', () => { - let loadForms = spyOn(service, 'getFormList').and.returnValue(Observable.of()); - startTaskButton.click(); - expect(loadForms).toHaveBeenCalled(); + it('should show start task button', () => { + expect(element.querySelector('#button-start')).toBeDefined(); + expect(element.querySelector('#button-start')).not.toBeNull(); + expect(element.querySelector('#button-start').textContent).toContain('START_TASK.FORM.ACTION.START'); }); - it('should create new task when start is clicked', () => { - activitiStartTaskButton.onSuccess.subscribe(() => { - expect(element.querySelector('#start-task-dialog').getAttribute('open')).toBeNull(); - }); - let createTaskButton = element.querySelector('#button-start'); - startTaskButton.click(); - activitiStartTaskButton.name = 'fake-name'; - createTaskButton.click(); - jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200 - }); + it('should fetch all users on ngonint', async(() => { + activitiStartTaskComponent.ngOnInit(); + expect(activitiStartTaskComponent.people).toBeDefined(); + expect(activitiStartTaskComponent.people[0].firstName).toEqual('fakeName'); + expect(activitiStartTaskComponent.people[1].firstName).toEqual('fake-name'); + expect(activitiStartTaskComponent.people[0].id).toEqual(1); + expect(activitiStartTaskComponent.people[1].id).toEqual(1001); + expect(getWorkflowUsersSpy).toHaveBeenCalled(); + })); + + it('should not emit TaskDetails OnCancle', () => { + let emitSpy = spyOn(activitiStartTaskComponent.cancel, 'emit'); + activitiStartTaskComponent.onCancel(); + expect(emitSpy).not.toBeNull(); + expect(emitSpy).toHaveBeenCalled(); }); - it('alert message is showed on start error', () => { - spyOn(window, 'alert'); - activitiStartTaskButton.onSuccess.subscribe(() => { - expect(window.alert).toHaveBeenCalledWith('An error occurred while trying to add the task'); - }); - let createTaskButton = element.querySelector('#button-start'); - startTaskButton.click(); - activitiStartTaskButton.name = 'fake-name'; - createTaskButton.click(); - jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 403 - }); + it('should start button disable if name is empty', () => { + let createTaskButton = fixture.nativeElement.querySelector('#button-start'); + activitiStartTaskComponent.startTaskmodel.name = ''; + fixture.detectChanges(); + expect(createTaskButton.disabled).toBeTruthy(); }); - it('should send on success event when the task is started', () => { - activitiStartTaskButton.onSuccess.subscribe((res) => { - expect(res).toBeDefined(); - }); - let createTaskButton = element.querySelector('#button-start'); - startTaskButton.click(); - activitiStartTaskButton.name = 'fake-name'; - createTaskButton.click(); - jasmine.Ajax.requests.mostRecent().respondWith({ - 'status': 200, - contentType: 'json', - responseText: {} - }); + it('should cancle start task on cancle button clicked', () => { + let emitSpy = spyOn(activitiStartTaskComponent.cancel, 'emit'); + let cancleTaskButton = fixture.nativeElement.querySelector('#button-cancle'); + activitiStartTaskComponent.startTaskmodel.name = ''; + fixture.detectChanges(); + cancleTaskButton.click(); + expect(emitSpy).not.toBeNull(); + expect(emitSpy).toHaveBeenCalled(); + }); + + it('should enable button if name is not empty', () => { + let createTaskButton = fixture.nativeElement.querySelector('#button-start'); + activitiStartTaskComponent.startTaskmodel.name = 'fakeName'; + fixture.detectChanges(); + expect(createTaskButton.enable).toBeFalsy(); }); }); diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.ts index f894c3fe30..db1de77781 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-start-task.component.ts @@ -15,20 +15,20 @@ * limitations under the License. */ -import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { AlfrescoTranslationService, LogService } from 'ng2-alfresco-core'; import { Form } from '../models/form.model'; +import { StartTaskModel, User } from '../models/index'; import { TaskDetailsModel } from '../models/task-details.model'; +import { ActivitiPeopleService } from '../services/activiti-people.service'; import { ActivitiTaskListService } from './../services/activiti-tasklist.service'; -declare let dialogPolyfill: any; - @Component({ selector: 'adf-start-task, activiti-start-task', templateUrl: './activiti-start-task.component.html', styleUrls: ['./activiti-start-task.component.css'] }) -export class ActivitiStartTaskButton { +export class ActivitiStartTaskComponent implements OnInit { @Input() appId: string; @@ -36,19 +36,18 @@ export class ActivitiStartTaskButton { @Output() onSuccess: EventEmitter = new EventEmitter(); + @Output() + cancel: EventEmitter = new EventEmitter(); + @Output() error: EventEmitter = new EventEmitter(); - @ViewChild('dialog') - dialog: any; + people: User [] = []; + + startTaskmodel: StartTaskModel = new StartTaskModel(); forms: Form []; - formId: string = null; - - name: string; - description: string; - /** * Constructor * @param auth @@ -57,6 +56,7 @@ export class ActivitiStartTaskButton { */ constructor(private translateService: AlfrescoTranslationService, private taskService: ActivitiTaskListService, + private peopleService: ActivitiPeopleService, private logService: LogService) { if (translateService) { @@ -64,20 +64,22 @@ export class ActivitiStartTaskButton { } } + ngOnInit() { + this.loadFormsTask(); + this.getUsers(); + } + public start() { - if (this.name) { - this.taskService.createNewTask(new TaskDetailsModel({ - name: this.name, - description: this.description, - category: this.appId ? '' + this.appId : null - })).subscribe( + if (this.startTaskmodel.name) { + this.startTaskmodel.category = this.appId; + this.taskService.createNewTask(new TaskDetailsModel(this.startTaskmodel)).subscribe( (res: any) => { this.onSuccess.emit(res); - this.closeDialog(); - this.resetForm(); this.attachForm(res.id); + this.resetForm(); }, (err) => { + this.error.emit(err); this.logService.error('An error occurred while trying to add the task'); } ); @@ -85,46 +87,35 @@ export class ActivitiStartTaskButton { } private attachForm(taskId: string) { - if (this.formId && taskId) { - this.taskService.attachFormToATask(taskId, Number(this.formId)); - this.formId = null; + if (this.startTaskmodel.formKey && taskId) { + this.taskService.attachFormToATask(taskId, Number(this.startTaskmodel.formKey)); } } - public cancel() { - this.closeDialog(); - } - - public showDialog() { - if (!this.dialog.nativeElement.showModal) { - dialogPolyfill.registerDialog(this.dialog.nativeElement); - } - - this.loadFormsTask(); - - if (this.dialog) { - this.dialog.nativeElement.showModal(); - } + public onCancel() { + this.cancel.emit(); } private loadFormsTask() { this.taskService.getFormList().subscribe((res: Form[]) => { this.forms = res; }, - (err) => { + (err) => { this.error.emit(err); this.logService.error('An error occurred while trying to get the forms'); }); } - private closeDialog() { - if (this.dialog) { - this.dialog.nativeElement.close(); - } + private resetForm() { + this.startTaskmodel = null; } - private resetForm() { - this.name = ''; - this.description = ''; + private getUsers() { + this.peopleService.getWorkflowUsers().subscribe((users) => { + this.people = users; + }, (err) => { + this.error.emit(err); + this.logService.error('Could not load users'); + }); } } diff --git a/ng2-components/ng2-activiti-tasklist/src/i18n/en.json b/ng2-components/ng2-activiti-tasklist/src/i18n/en.json index 5a8f83c021..b0fb9049f6 100644 --- a/ng2-components/ng2-activiti-tasklist/src/i18n/en.json +++ b/ng2-components/ng2-activiti-tasklist/src/i18n/en.json @@ -71,13 +71,16 @@ }, "START_TASK": { "BUTTON": "CREATE TASK", - "DIALOG": { + "FORM": { "TITLE": "Start Task", "LABEL": { "NONE": "None", "NAME": "Name", "DESCRIPTION": "Description", - "ATTACHFORM" : "Attach a Form" + "ATTACHFORM" : "Attach a Form", + "ASSIGNEE" : "Assignee", + "FORM" : "Form", + "DATE" : "Choose a Date" }, "ACTION": { "START": "Start", diff --git a/ng2-components/ng2-activiti-tasklist/src/models/index.ts b/ng2-components/ng2-activiti-tasklist/src/models/index.ts index 45b713f383..890d8f4c5e 100644 --- a/ng2-components/ng2-activiti-tasklist/src/models/index.ts +++ b/ng2-components/ng2-activiti-tasklist/src/models/index.ts @@ -22,3 +22,4 @@ export * from './user.model'; export * from './task-details.model'; export * from './task-details.event'; export * from './user-event.model'; +export * from './start-task.model'; diff --git a/ng2-components/ng2-activiti-tasklist/src/models/start-task.model.ts b/ng2-components/ng2-activiti-tasklist/src/models/start-task.model.ts new file mode 100644 index 0000000000..b4f808e872 --- /dev/null +++ b/ng2-components/ng2-activiti-tasklist/src/models/start-task.model.ts @@ -0,0 +1,44 @@ +/*! + * @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. + */ + +/** + * + * This object represent of the StartTaskModel. + * + * + * @returns {StartTaskModel} . + */ +import { User } from './user.model'; + +export class StartTaskModel { + + name: string; + description: string; + assignee: User; + dueDate: any; + formKey: any; + category: string; + + constructor(obj?: any) { + this.name = obj && obj.name || null; + this.description = obj && obj.description || null; + this.assignee = obj && obj.assignee ? new User(obj.assignee) : null; + this.dueDate = obj && obj.dueDate || null; + this.formKey = obj && obj.formKey || null; + this.category = obj && obj.category || null; + } +} diff --git a/ng2-components/ng2-activiti-tasklist/src/services/activiti-people.service.ts b/ng2-components/ng2-activiti-tasklist/src/services/activiti-people.service.ts index 4d02be6806..4efbdbfa7e 100644 --- a/ng2-components/ng2-activiti-tasklist/src/services/activiti-people.service.ts +++ b/ng2-components/ng2-activiti-tasklist/src/services/activiti-people.service.ts @@ -28,7 +28,7 @@ export class ActivitiPeopleService { private logService: LogService) { } - getWorkflowUsers(taskId: string, searchWord: string): Observable { + getWorkflowUsers(taskId?: string, searchWord?: string): Observable { let option = {excludeTaskId: taskId, filter: searchWord}; return Observable.fromPromise(this.getWorkflowUserApi(option)) .map((response: any) => response.data || [])