@valtimo/task 4.15.2-next-main.15 → 4.15.3-next-main.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,547 +9,566 @@ import { TranslateService, TranslateModule, TranslateLoader } from '@ngx-transla
9
9
  import { ListModule, PageHeaderModule, WidgetModule, SpinnerModule, SearchableDropdownSelectModule, CamundaFormModule, FormIoModule, ModalModule } from '@valtimo/components';
10
10
  import { FormioOptionsImpl, TaskList, ROLE_USER, HttpLoaderFactory } from '@valtimo/contract';
11
11
  import { ToastrService, ToastrModule } from 'ngx-toastr';
12
- import { Router, RouterModule } from '@angular/router';
12
+ import { Router, ActivatedRoute, RouterModule } from '@angular/router';
13
13
  import { FormLinkService } from '@valtimo/form-link';
14
14
  import * as momentImported from 'moment';
15
15
  import { NGXLogger } from 'ngx-logger';
16
+ import { take, tap } from 'rxjs/operators';
16
17
  import { combineLatest, BehaviorSubject } from 'rxjs';
17
18
  import { AuthGuardService } from '@valtimo/security';
18
- import { take, tap } from 'rxjs/operators';
19
19
 
20
- /*
21
- * Copyright 2015-2020 Ritense BV, the Netherlands.
22
- *
23
- * Licensed under EUPL, Version 1.2 (the "License");
24
- * you may not use this file except in compliance with the License.
25
- * You may obtain a copy of the License at
26
- *
27
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
28
- *
29
- * Unless required by applicable law or agreed to in writing, software
30
- * distributed under the License is distributed on an "AS IS" basis,
31
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32
- * See the License for the specific language governing permissions and
33
- * limitations under the License.
34
- */
35
- class TaskService {
36
- constructor(http, configService) {
37
- this.http = http;
38
- this.valtimoEndpointUri = configService.config.valtimoApi.endpointUri;
39
- }
40
- queryTasks(params) {
41
- return this.http.get(`${this.valtimoEndpointUri}task`, { observe: 'response', params: params });
42
- }
43
- getTasks() {
44
- return this.http.get(`${this.valtimoEndpointUri}task?filter=all`);
45
- }
46
- getTask(id) {
47
- return this.http.get(this.valtimoEndpointUri + 'task/' + id);
48
- }
49
- getCandidateUsers(id) {
50
- return this.http.get(this.valtimoEndpointUri + 'task/' + id + '/candidate-user');
51
- }
52
- assignTask(id, assigneeRequest) {
53
- return this.http.post(this.valtimoEndpointUri + 'task/' + id + '/assign', assigneeRequest);
54
- }
55
- unassignTask(id) {
56
- return this.http.post(this.valtimoEndpointUri + 'task/' + id + '/unassign', null);
57
- }
58
- completeTask(id, variables) {
59
- return this.http.post(this.valtimoEndpointUri + 'task/' + id + '/complete', {
60
- variables: variables,
61
- filesToDelete: []
62
- });
63
- }
64
- }
65
- TaskService.ɵprov = ɵɵdefineInjectable({ factory: function TaskService_Factory() { return new TaskService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: TaskService, providedIn: "root" });
66
- TaskService.decorators = [
67
- { type: Injectable, args: [{ providedIn: 'root' },] }
68
- ];
69
- TaskService.ctorParameters = () => [
70
- { type: HttpClient },
71
- { type: ConfigService }
20
+ /*
21
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
22
+ *
23
+ * Licensed under EUPL, Version 1.2 (the "License");
24
+ * you may not use this file except in compliance with the License.
25
+ * You may obtain a copy of the License at
26
+ *
27
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
28
+ *
29
+ * Unless required by applicable law or agreed to in writing, software
30
+ * distributed under the License is distributed on an "AS IS" basis,
31
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32
+ * See the License for the specific language governing permissions and
33
+ * limitations under the License.
34
+ */
35
+ class TaskService {
36
+ constructor(http, configService) {
37
+ this.http = http;
38
+ this.valtimoEndpointUri = configService.config.valtimoApi.endpointUri;
39
+ }
40
+ queryTasks(params) {
41
+ return this.http.get(`${this.valtimoEndpointUri}task`, { observe: 'response', params: params });
42
+ }
43
+ getTasks() {
44
+ return this.http.get(`${this.valtimoEndpointUri}task?filter=all`);
45
+ }
46
+ getTask(id) {
47
+ return this.http.get(this.valtimoEndpointUri + 'task/' + id);
48
+ }
49
+ getCandidateUsers(id) {
50
+ return this.http.get(this.valtimoEndpointUri + 'task/' + id + '/candidate-user');
51
+ }
52
+ assignTask(id, assigneeRequest) {
53
+ return this.http.post(this.valtimoEndpointUri + 'task/' + id + '/assign', assigneeRequest);
54
+ }
55
+ unassignTask(id) {
56
+ return this.http.post(this.valtimoEndpointUri + 'task/' + id + '/unassign', null);
57
+ }
58
+ completeTask(id, variables) {
59
+ return this.http.post(this.valtimoEndpointUri + 'task/' + id + '/complete', {
60
+ variables: variables,
61
+ filesToDelete: [],
62
+ });
63
+ }
64
+ }
65
+ TaskService.ɵprov = ɵɵdefineInjectable({ factory: function TaskService_Factory() { return new TaskService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: TaskService, providedIn: "root" });
66
+ TaskService.decorators = [
67
+ { type: Injectable, args: [{ providedIn: 'root' },] }
68
+ ];
69
+ TaskService.ctorParameters = () => [
70
+ { type: HttpClient },
71
+ { type: ConfigService }
72
72
  ];
73
73
 
74
- /*
75
- * Copyright 2015-2020 Ritense BV, the Netherlands.
76
- *
77
- * Licensed under EUPL, Version 1.2 (the "License");
78
- * you may not use this file except in compliance with the License.
79
- * You may obtain a copy of the License at
80
- *
81
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
82
- *
83
- * Unless required by applicable law or agreed to in writing, software
84
- * distributed under the License is distributed on an "AS IS" basis,
85
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
86
- * See the License for the specific language governing permissions and
87
- * limitations under the License.
88
- */
89
- const moment = momentImported;
90
- moment.locale(localStorage.getItem('langKey') || '');
91
- class TaskDetailModalComponent {
92
- constructor(toastr, formLinkService, router, logger) {
93
- this.toastr = toastr;
94
- this.formLinkService = formLinkService;
95
- this.router = router;
96
- this.logger = logger;
97
- this.task = null;
98
- this.page = null;
99
- this.formSubmit = new EventEmitter();
100
- this.assignmentOfTaskChanged = new EventEmitter();
101
- this.errorMessage = null;
102
- this.formioOptions = new FormioOptionsImpl();
103
- this.formioOptions.disableAlerts = true;
104
- }
105
- resetFormDefinition() {
106
- // reset formDefinition in order to reload form-io component
107
- this.formDefinition = null;
108
- }
109
- openTaskDetails(task) {
110
- this.resetFormDefinition();
111
- this.task = task;
112
- this.page = {
113
- title: task.name,
114
- subtitle: `Created ${moment(task.created).fromNow()}`
115
- };
116
- this.formLinkService
117
- .getPreFilledFormDefinitionByFormLinkId(task.processDefinitionKey, task.businessKey, task.taskDefinitionKey, task.id // taskInstanceId
118
- )
119
- .subscribe((formDefinition) => {
120
- this.formAssociation = formDefinition.formAssociation;
121
- const className = this.formAssociation.formLink.className.split('.');
122
- const linkType = className[className.length - 1];
123
- switch (linkType) {
124
- case 'BpmnElementFormIdLink':
125
- this.formDefinition = formDefinition;
126
- this.modal.show();
127
- break;
128
- case 'BpmnElementUrlLink':
129
- const url = this.router.serializeUrl(this.router.createUrlTree([formDefinition.formAssociation.formLink.url]));
130
- window.open(url, '_blank');
131
- break;
132
- case 'BpmnElementAngularStateUrlLink':
133
- this.router.navigate([formDefinition.formAssociation.formLink.url]);
134
- break;
135
- default:
136
- this.logger.fatal('Unsupported class name');
137
- }
138
- }, (errors) => {
139
- var _a;
140
- if ((_a = errors === null || errors === void 0 ? void 0 : errors.error) === null || _a === void 0 ? void 0 : _a.detail) {
141
- this.errorMessage = errors.error.detail;
142
- }
143
- this.modal.show();
144
- });
145
- }
146
- gotoFormLinkScreen() {
147
- this.modal.hide();
148
- this.router.navigate(['form-links']);
149
- }
150
- onSubmit(submission) {
151
- this.formLinkService
152
- .onSubmit(this.task.processDefinitionKey, this.formAssociation.formLink.id, submission.data, this.task.businessKey, this.task.id)
153
- .subscribe((formSubmissionResult) => {
154
- this.toastr.success(this.task.name + ' has successfully been completed');
155
- this.modal.hide();
156
- this.task = null;
157
- this.formSubmit.emit();
158
- }, (errors) => {
159
- this.form.showErrors(errors);
160
- });
161
- }
162
- }
163
- TaskDetailModalComponent.decorators = [
164
- { type: Component, args: [{
165
- selector: 'valtimo-task-detail-modal',
166
- template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<valtimo-modal\n #taskDetailModal\n elementId=\"taskDetailModal\"\n [title]=\"page?.title\"\n [subtitle]=\"page?.subtitle\"\n [templateBelowSubtitle]=\"assignUserToTask\"\n>\n <div body *ngIf=\"formDefinition\">\n <valtimo-form-io\n #form\n [form]=\"formDefinition\"\n (submit)=\"onSubmit($event)\"\n [options]=\"formioOptions\"\n ></valtimo-form-io>\n </div>\n <div body *ngIf=\"!formDefinition && !errorMessage\">\n <div class=\"bg-warning text-black mb-0 p-3 text-center\" [translate]=\"'formManagement.noFormDefinitionFound'\"></div>\n </div>\n <div body *ngIf=\"errorMessage\">\n <div class=\"bg-danger text-black mb-0 p-3 text-center\">\n {{ errorMessage }}\n </div>\n </div>\n <div footer>\n <div class=\"mb-0 p-3 text-center\" *ngIf=\"!formDefinition\">\n <button class=\"btn btn-secondary btn-space\" type=\"button\" (click)=\"gotoFormLinkScreen()\" id=\"form-link-button\">\n {{ 'formManagement.gotoFormLinksButton' | translate }}\n </button>\n </div>\n </div>\n</valtimo-modal>\n\n<ng-template #assignUserToTask>\n <valtimo-assign-user-to-task\n *ngIf=\"task && assignmentOfTaskChanged\"\n [taskId]=\"task.id\"\n [assigneeEmail]=\"task.assignee\"\n (assignmentOfTaskChanged)=\"assignmentOfTaskChanged.emit()\"\n ></valtimo-assign-user-to-task>\n</ng-template>\n",
167
- encapsulation: ViewEncapsulation.None,
168
- styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */#taskDetailModal .formio-component-submit{text-align:right}"]
169
- },] }
170
- ];
171
- TaskDetailModalComponent.ctorParameters = () => [
172
- { type: ToastrService },
173
- { type: FormLinkService },
174
- { type: Router },
175
- { type: NGXLogger }
176
- ];
177
- TaskDetailModalComponent.propDecorators = {
178
- form: [{ type: ViewChild, args: ['form',] }],
179
- modal: [{ type: ViewChild, args: ['taskDetailModal',] }],
180
- formSubmit: [{ type: Output }],
181
- assignmentOfTaskChanged: [{ type: Output }]
74
+ /*
75
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
76
+ *
77
+ * Licensed under EUPL, Version 1.2 (the "License");
78
+ * you may not use this file except in compliance with the License.
79
+ * You may obtain a copy of the License at
80
+ *
81
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
82
+ *
83
+ * Unless required by applicable law or agreed to in writing, software
84
+ * distributed under the License is distributed on an "AS IS" basis,
85
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
86
+ * See the License for the specific language governing permissions and
87
+ * limitations under the License.
88
+ */
89
+ const moment = momentImported;
90
+ moment.locale(localStorage.getItem('langKey') || '');
91
+ class TaskDetailModalComponent {
92
+ constructor(toastr, formLinkService, router, logger, route) {
93
+ this.toastr = toastr;
94
+ this.formLinkService = formLinkService;
95
+ this.router = router;
96
+ this.logger = logger;
97
+ this.route = route;
98
+ this.task = null;
99
+ this.page = null;
100
+ this.formSubmit = new EventEmitter();
101
+ this.assignmentOfTaskChanged = new EventEmitter();
102
+ this.errorMessage = null;
103
+ this.formioOptions = new FormioOptionsImpl();
104
+ this.formioOptions.disableAlerts = true;
105
+ }
106
+ resetFormDefinition() {
107
+ // reset formDefinition in order to reload form-io component
108
+ this.formDefinition = null;
109
+ }
110
+ openTaskDetails(task) {
111
+ this.resetFormDefinition();
112
+ this.task = task;
113
+ this.page = {
114
+ title: task.name,
115
+ subtitle: `Created ${moment(task.created).fromNow()}`,
116
+ };
117
+ this.formLinkService
118
+ .getPreFilledFormDefinitionByFormLinkId(task.processDefinitionKey, task.businessKey, task.taskDefinitionKey, task.id // taskInstanceId
119
+ )
120
+ .subscribe(formDefinition => {
121
+ this.formAssociation = formDefinition.formAssociation;
122
+ const className = this.formAssociation.formLink.className.split('.');
123
+ const linkType = className[className.length - 1];
124
+ switch (linkType) {
125
+ case 'BpmnElementFormIdLink':
126
+ this.formDefinition = formDefinition;
127
+ this.modal.show();
128
+ break;
129
+ case 'BpmnElementUrlLink':
130
+ const url = this.router.serializeUrl(this.router.createUrlTree([formDefinition.formAssociation.formLink.url]));
131
+ window.open(url, '_blank');
132
+ break;
133
+ case 'BpmnElementAngularStateUrlLink':
134
+ this.route.params.pipe(take(1)).subscribe(params => {
135
+ const taskId = task === null || task === void 0 ? void 0 : task.id;
136
+ const documentId = params === null || params === void 0 ? void 0 : params.documentId;
137
+ this.router.navigate([formDefinition.formAssociation.formLink.url], {
138
+ state: Object.assign(Object.assign({}, (taskId && { taskId })), (documentId && { documentId })),
139
+ });
140
+ });
141
+ break;
142
+ default:
143
+ this.logger.fatal('Unsupported class name');
144
+ }
145
+ }, errors => {
146
+ var _a;
147
+ if ((_a = errors === null || errors === void 0 ? void 0 : errors.error) === null || _a === void 0 ? void 0 : _a.detail) {
148
+ this.errorMessage = errors.error.detail;
149
+ }
150
+ this.modal.show();
151
+ });
152
+ }
153
+ gotoFormLinkScreen() {
154
+ this.modal.hide();
155
+ this.router.navigate(['form-links']);
156
+ }
157
+ onSubmit(submission) {
158
+ this.formLinkService
159
+ .onSubmit(this.task.processDefinitionKey, this.formAssociation.formLink.id, submission.data, this.task.businessKey, this.task.id)
160
+ .subscribe((formSubmissionResult) => {
161
+ this.toastr.success(this.task.name + ' has successfully been completed');
162
+ this.modal.hide();
163
+ this.task = null;
164
+ this.formSubmit.emit();
165
+ }, errors => {
166
+ this.form.showErrors(errors);
167
+ });
168
+ }
169
+ }
170
+ TaskDetailModalComponent.decorators = [
171
+ { type: Component, args: [{
172
+ selector: 'valtimo-task-detail-modal',
173
+ template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<valtimo-modal\n #taskDetailModal\n elementId=\"taskDetailModal\"\n [title]=\"page?.title\"\n [subtitle]=\"page?.subtitle\"\n [templateBelowSubtitle]=\"assignUserToTask\"\n>\n <div body *ngIf=\"formDefinition\">\n <valtimo-form-io\n #form\n [form]=\"formDefinition\"\n (submit)=\"onSubmit($event)\"\n [options]=\"formioOptions\"\n ></valtimo-form-io>\n </div>\n <div body *ngIf=\"!formDefinition && !errorMessage\">\n <div\n class=\"bg-warning text-black mb-0 p-3 text-center\"\n [translate]=\"'formManagement.noFormDefinitionFound'\"\n ></div>\n </div>\n <div body *ngIf=\"errorMessage\">\n <div class=\"bg-danger text-black mb-0 p-3 text-center\">\n {{ errorMessage }}\n </div>\n </div>\n <div footer>\n <div class=\"mb-0 p-3 text-center\" *ngIf=\"!formDefinition\">\n <button\n class=\"btn btn-secondary btn-space\"\n type=\"button\"\n (click)=\"gotoFormLinkScreen()\"\n id=\"form-link-button\"\n >\n {{ 'formManagement.gotoFormLinksButton' | translate }}\n </button>\n </div>\n </div>\n</valtimo-modal>\n\n<ng-template #assignUserToTask>\n <valtimo-assign-user-to-task\n *ngIf=\"task && assignmentOfTaskChanged\"\n [taskId]=\"task.id\"\n [assigneeEmail]=\"task.assignee\"\n (assignmentOfTaskChanged)=\"assignmentOfTaskChanged.emit()\"\n ></valtimo-assign-user-to-task>\n</ng-template>\n",
174
+ encapsulation: ViewEncapsulation.None,
175
+ styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */#taskDetailModal .formio-component-submit{text-align:right}"]
176
+ },] }
177
+ ];
178
+ TaskDetailModalComponent.ctorParameters = () => [
179
+ { type: ToastrService },
180
+ { type: FormLinkService },
181
+ { type: Router },
182
+ { type: NGXLogger },
183
+ { type: ActivatedRoute }
184
+ ];
185
+ TaskDetailModalComponent.propDecorators = {
186
+ form: [{ type: ViewChild, args: ['form',] }],
187
+ modal: [{ type: ViewChild, args: ['taskDetailModal',] }],
188
+ formSubmit: [{ type: Output }],
189
+ assignmentOfTaskChanged: [{ type: Output }]
182
190
  };
183
191
 
184
- /*
185
- * Copyright 2015-2020 Ritense BV, the Netherlands.
186
- *
187
- * Licensed under EUPL, Version 1.2 (the "License");
188
- * you may not use this file except in compliance with the License.
189
- * You may obtain a copy of the License at
190
- *
191
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
192
- *
193
- * Unless required by applicable law or agreed to in writing, software
194
- * distributed under the License is distributed on an "AS IS" basis,
195
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
196
- * See the License for the specific language governing permissions and
197
- * limitations under the License.
198
- */
199
- const moment$1 = momentImported;
200
- moment$1.locale(localStorage.getItem('langKey') || '');
201
- class TaskListComponent {
202
- constructor(taskService, router, logger, translateService) {
203
- this.taskService = taskService;
204
- this.router = router;
205
- this.logger = logger;
206
- this.translateService = translateService;
207
- this.tasks = {
208
- mine: new TaskList(),
209
- open: new TaskList(),
210
- all: new TaskList()
211
- };
212
- this.currentTaskType = 'mine';
213
- this.listTitle = null;
214
- this.listDescription = null;
215
- }
216
- paginationClicked(page, type) {
217
- this.tasks[type].page = page - 1;
218
- this.getTasks(type);
219
- }
220
- paginationSet() {
221
- this.tasks.mine.pagination.size = this.tasks.all.pagination.size = this.tasks.open.pagination.size = this.tasks[this.currentTaskType].pagination.size;
222
- this.getTasks(this.currentTaskType);
223
- }
224
- clearPagination(type) {
225
- this.tasks[type].page = 0;
226
- }
227
- tabChange(tab) {
228
- this.clearPagination(this.currentTaskType);
229
- switch (tab.nextId) {
230
- case 'ngb-tab-0':
231
- this.getTasks('mine');
232
- break;
233
- case 'ngb-tab-1':
234
- this.getTasks('open');
235
- break;
236
- case 'ngb-tab-2':
237
- this.getTasks('all');
238
- break;
239
- default:
240
- this.logger.fatal('Unreachable case');
241
- }
242
- }
243
- showTask(task) {
244
- this.router.navigate(['tasks', task.id]);
245
- }
246
- getTasks(type) {
247
- let params;
248
- this.translationSubscription = combineLatest([
249
- this.translateService.stream(`task-list.${type}.title`),
250
- this.translateService.stream(`task-list.${type}.description`)
251
- ]).subscribe(([title, description]) => {
252
- this.listTitle = title;
253
- this.listDescription = description;
254
- });
255
- switch (type) {
256
- case 'mine':
257
- params = { page: this.tasks.mine.page, size: this.tasks.mine.pagination.size, filter: 'mine' };
258
- this.currentTaskType = 'mine';
259
- break;
260
- case 'open':
261
- params = { page: this.tasks.open.page, size: this.tasks.open.pagination.size, filter: 'open' };
262
- this.currentTaskType = 'open';
263
- break;
264
- case 'all':
265
- params = { page: this.tasks.all.page, size: this.tasks.open.pagination.size, filter: 'all' };
266
- this.currentTaskType = 'all';
267
- break;
268
- default:
269
- this.logger.fatal('Unreachable case');
270
- }
271
- this.taskService.queryTasks(params).subscribe((results) => {
272
- this.tasks[type].pagination.collectionSize = results.headers.get('x-total-count');
273
- this.tasks[type].tasks = results.body;
274
- this.tasks[type].tasks.map((task) => {
275
- task.created = moment$1(task.created).format('DD MMM YYYY HH:mm');
276
- if (task.due) {
277
- task.due = moment$1(task.due).format('DD MMM YYYY HH:mm');
278
- }
279
- });
280
- this.tasks[type].fields = [
281
- {
282
- key: 'created',
283
- label: 'Created on'
284
- },
285
- {
286
- key: 'name',
287
- label: 'Name'
288
- },
289
- {
290
- key: 'valtimoAssignee.fullName',
291
- label: 'Assignee'
292
- },
293
- {
294
- key: 'due',
295
- label: 'Due date'
296
- }
297
- ];
298
- });
299
- }
300
- rowOpenTaskClick(task) {
301
- if (!task.endTime) {
302
- this.taskDetail.openTaskDetails(task);
303
- }
304
- else {
305
- return false;
306
- }
307
- }
308
- ngOnDestroy() {
309
- this.translationSubscription.unsubscribe();
310
- }
311
- }
312
- TaskListComponent.decorators = [
313
- { type: Component, args: [{
314
- selector: 'valtimo-task-list',
315
- template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content\">\n <div class=\"container-fluid\">\n <valtimo-widget>\n <valtimo-list\n [items]=\"tasks[currentTaskType].tasks\"\n [fields]=\"tasks[currentTaskType].fields\"\n [pagination]=\"tasks[currentTaskType].pagination\"\n [viewMode]=\"true\"\n (paginationClicked)=\"paginationClicked($event, currentTaskType)\"\n (paginationSet)=\"paginationSet()\"\n paginationIdentifier=\"taskList\"\n [isSearchable]=\"true\"\n [header]=\"true\"\n (rowClicked)=\"rowOpenTaskClick($event)\"\n >\n <div header>\n <h3 class=\"list-header-title\">{{ listTitle }}</h3>\n <h5 class=\"list-header-description\">{{ listDescription }}</h5>\n </div>\n <div tabs>\n <ngb-tabset [destroyOnHide]=\"false\" (tabChange)=\"tabChange($event)\">\n <ngb-tab id=\"ngb-tab-0\" [title]=\"'task-list.mine.title' | translate\"> </ngb-tab>\n <ngb-tab id=\"ngb-tab-1\" [title]=\"'task-list.open.title' | translate\"> </ngb-tab>\n <ngb-tab id=\"ngb-tab-2\" [title]=\"'task-list.all.title' | translate\"> </ngb-tab>\n </ngb-tabset>\n </div>\n </valtimo-list>\n </valtimo-widget>\n <valtimo-task-detail-modal\n #taskDetail\n (formSubmit)=\"getTasks(currentTaskType)\"\n (assignmentOfTaskChanged)=\"getTasks(currentTaskType)\"\n ></valtimo-task-detail-modal>\n </div>\n</div>\n",
316
- encapsulation: ViewEncapsulation.None,
317
- styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.tab-content{margin:0;padding:0}.nav.nav-tabs{background-color:#f5f5f5}"]
318
- },] }
319
- ];
320
- TaskListComponent.ctorParameters = () => [
321
- { type: TaskService },
322
- { type: Router },
323
- { type: NGXLogger },
324
- { type: TranslateService }
325
- ];
326
- TaskListComponent.propDecorators = {
327
- taskDetail: [{ type: ViewChild, args: ['taskDetail',] }]
192
+ /*
193
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
194
+ *
195
+ * Licensed under EUPL, Version 1.2 (the "License");
196
+ * you may not use this file except in compliance with the License.
197
+ * You may obtain a copy of the License at
198
+ *
199
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
200
+ *
201
+ * Unless required by applicable law or agreed to in writing, software
202
+ * distributed under the License is distributed on an "AS IS" basis,
203
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
204
+ * See the License for the specific language governing permissions and
205
+ * limitations under the License.
206
+ */
207
+ const moment$1 = momentImported;
208
+ moment$1.locale(localStorage.getItem('langKey') || '');
209
+ class TaskListComponent {
210
+ constructor(taskService, router, logger, translateService) {
211
+ this.taskService = taskService;
212
+ this.router = router;
213
+ this.logger = logger;
214
+ this.translateService = translateService;
215
+ this.tasks = {
216
+ mine: new TaskList(),
217
+ open: new TaskList(),
218
+ all: new TaskList(),
219
+ };
220
+ this.currentTaskType = 'mine';
221
+ this.listTitle = null;
222
+ this.listDescription = null;
223
+ }
224
+ paginationClicked(page, type) {
225
+ this.tasks[type].page = page - 1;
226
+ this.getTasks(type);
227
+ }
228
+ paginationSet() {
229
+ this.tasks.mine.pagination.size =
230
+ this.tasks.all.pagination.size =
231
+ this.tasks.open.pagination.size =
232
+ this.tasks[this.currentTaskType].pagination.size;
233
+ this.getTasks(this.currentTaskType);
234
+ }
235
+ clearPagination(type) {
236
+ this.tasks[type].page = 0;
237
+ }
238
+ tabChange(tab) {
239
+ this.clearPagination(this.currentTaskType);
240
+ switch (tab.nextId) {
241
+ case 'ngb-tab-0':
242
+ this.getTasks('mine');
243
+ break;
244
+ case 'ngb-tab-1':
245
+ this.getTasks('open');
246
+ break;
247
+ case 'ngb-tab-2':
248
+ this.getTasks('all');
249
+ break;
250
+ default:
251
+ this.logger.fatal('Unreachable case');
252
+ }
253
+ }
254
+ showTask(task) {
255
+ this.router.navigate(['tasks', task.id]);
256
+ }
257
+ getTasks(type) {
258
+ let params;
259
+ this.translationSubscription = combineLatest([
260
+ this.translateService.stream(`task-list.${type}.title`),
261
+ this.translateService.stream(`task-list.${type}.description`),
262
+ ]).subscribe(([title, description]) => {
263
+ this.listTitle = title;
264
+ this.listDescription = description;
265
+ });
266
+ switch (type) {
267
+ case 'mine':
268
+ params = {
269
+ page: this.tasks.mine.page,
270
+ size: this.tasks.mine.pagination.size,
271
+ filter: 'mine',
272
+ };
273
+ this.currentTaskType = 'mine';
274
+ break;
275
+ case 'open':
276
+ params = {
277
+ page: this.tasks.open.page,
278
+ size: this.tasks.open.pagination.size,
279
+ filter: 'open',
280
+ };
281
+ this.currentTaskType = 'open';
282
+ break;
283
+ case 'all':
284
+ params = { page: this.tasks.all.page, size: this.tasks.open.pagination.size, filter: 'all' };
285
+ this.currentTaskType = 'all';
286
+ break;
287
+ default:
288
+ this.logger.fatal('Unreachable case');
289
+ }
290
+ this.taskService.queryTasks(params).subscribe((results) => {
291
+ this.tasks[type].pagination.collectionSize = results.headers.get('x-total-count');
292
+ this.tasks[type].tasks = results.body;
293
+ this.tasks[type].tasks.map((task) => {
294
+ task.created = moment$1(task.created).format('DD MMM YYYY HH:mm');
295
+ if (task.due) {
296
+ task.due = moment$1(task.due).format('DD MMM YYYY HH:mm');
297
+ }
298
+ });
299
+ this.tasks[type].fields = [
300
+ {
301
+ key: 'created',
302
+ label: 'Created on',
303
+ },
304
+ {
305
+ key: 'name',
306
+ label: 'Name',
307
+ },
308
+ {
309
+ key: 'valtimoAssignee.fullName',
310
+ label: 'Assignee',
311
+ },
312
+ {
313
+ key: 'due',
314
+ label: 'Due date',
315
+ },
316
+ ];
317
+ });
318
+ }
319
+ rowOpenTaskClick(task) {
320
+ if (!task.endTime) {
321
+ this.taskDetail.openTaskDetails(task);
322
+ }
323
+ else {
324
+ return false;
325
+ }
326
+ }
327
+ ngOnDestroy() {
328
+ this.translationSubscription.unsubscribe();
329
+ }
330
+ }
331
+ TaskListComponent.decorators = [
332
+ { type: Component, args: [{
333
+ selector: 'valtimo-task-list',
334
+ template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div class=\"main-content\">\n <div class=\"container-fluid\">\n <valtimo-widget>\n <valtimo-list\n [items]=\"tasks[currentTaskType].tasks\"\n [fields]=\"tasks[currentTaskType].fields\"\n [pagination]=\"tasks[currentTaskType].pagination\"\n [viewMode]=\"true\"\n (paginationClicked)=\"paginationClicked($event, currentTaskType)\"\n (paginationSet)=\"paginationSet()\"\n paginationIdentifier=\"taskList\"\n [isSearchable]=\"true\"\n [header]=\"true\"\n (rowClicked)=\"rowOpenTaskClick($event)\"\n >\n <div header>\n <h3 class=\"list-header-title\">{{ listTitle }}</h3>\n <h5 class=\"list-header-description\">{{ listDescription }}</h5>\n </div>\n <div tabs>\n <ngb-tabset [destroyOnHide]=\"false\" (tabChange)=\"tabChange($event)\">\n <ngb-tab id=\"ngb-tab-0\" [title]=\"'task-list.mine.title' | translate\"> </ngb-tab>\n <ngb-tab id=\"ngb-tab-1\" [title]=\"'task-list.open.title' | translate\"> </ngb-tab>\n <ngb-tab id=\"ngb-tab-2\" [title]=\"'task-list.all.title' | translate\"> </ngb-tab>\n </ngb-tabset>\n </div>\n </valtimo-list>\n </valtimo-widget>\n <valtimo-task-detail-modal\n #taskDetail\n (formSubmit)=\"getTasks(currentTaskType)\"\n (assignmentOfTaskChanged)=\"getTasks(currentTaskType)\"\n ></valtimo-task-detail-modal>\n </div>\n</div>\n",
335
+ encapsulation: ViewEncapsulation.None,
336
+ styles: ["/*!\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.tab-content{margin:0;padding:0}.nav.nav-tabs{background-color:#f5f5f5}"]
337
+ },] }
338
+ ];
339
+ TaskListComponent.ctorParameters = () => [
340
+ { type: TaskService },
341
+ { type: Router },
342
+ { type: NGXLogger },
343
+ { type: TranslateService }
344
+ ];
345
+ TaskListComponent.propDecorators = {
346
+ taskDetail: [{ type: ViewChild, args: ['taskDetail',] }]
328
347
  };
329
348
 
330
- /*
331
- * Copyright 2015-2020 Ritense BV, the Netherlands.
332
- *
333
- * Licensed under EUPL, Version 1.2 (the "License");
334
- * you may not use this file except in compliance with the License.
335
- * You may obtain a copy of the License at
336
- *
337
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
338
- *
339
- * Unless required by applicable law or agreed to in writing, software
340
- * distributed under the License is distributed on an "AS IS" basis,
341
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
342
- * See the License for the specific language governing permissions and
343
- * limitations under the License.
344
- */
345
- const ɵ0 = { title: 'Tasks', roles: [ROLE_USER] };
346
- const routes = [
347
- {
348
- path: 'tasks',
349
- component: TaskListComponent,
350
- canActivate: [AuthGuardService],
351
- data: ɵ0
352
- }
353
- ];
354
- class TaskRoutingModule {
355
- }
356
- TaskRoutingModule.decorators = [
357
- { type: NgModule, args: [{
358
- declarations: [],
359
- imports: [
360
- CommonModule,
361
- RouterModule.forChild(routes),
362
- ],
363
- exports: [RouterModule]
364
- },] }
349
+ /*
350
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
351
+ *
352
+ * Licensed under EUPL, Version 1.2 (the "License");
353
+ * you may not use this file except in compliance with the License.
354
+ * You may obtain a copy of the License at
355
+ *
356
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
357
+ *
358
+ * Unless required by applicable law or agreed to in writing, software
359
+ * distributed under the License is distributed on an "AS IS" basis,
360
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
361
+ * See the License for the specific language governing permissions and
362
+ * limitations under the License.
363
+ */
364
+ const ɵ0 = { title: 'Tasks', roles: [ROLE_USER] };
365
+ const routes = [
366
+ {
367
+ path: 'tasks',
368
+ component: TaskListComponent,
369
+ canActivate: [AuthGuardService],
370
+ data: ɵ0,
371
+ },
372
+ ];
373
+ class TaskRoutingModule {
374
+ }
375
+ TaskRoutingModule.decorators = [
376
+ { type: NgModule, args: [{
377
+ declarations: [],
378
+ imports: [CommonModule, RouterModule.forChild(routes)],
379
+ exports: [RouterModule],
380
+ },] }
365
381
  ];
366
382
 
367
- /*
368
- * Copyright 2015-2020 Ritense BV, the Netherlands.
369
- *
370
- * Licensed under EUPL, Version 1.2 (the "License");
371
- * you may not use this file except in compliance with the License.
372
- * You may obtain a copy of the License at
373
- *
374
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
375
- *
376
- * Unless required by applicable law or agreed to in writing, software
377
- * distributed under the License is distributed on an "AS IS" basis,
378
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
379
- * See the License for the specific language governing permissions and
380
- * limitations under the License.
381
- */
382
- class AssignUserToTaskComponent {
383
- constructor(taskService) {
384
- this.taskService = taskService;
385
- this.assignmentOfTaskChanged = new EventEmitter();
386
- this.candidateUsersForTask$ = new BehaviorSubject(undefined);
387
- this.disabled$ = new BehaviorSubject(true);
388
- this.assignedEmailOnServer$ = new BehaviorSubject(null);
389
- this.userEmailToAssign = null;
390
- this.assignedUserFullName$ = new BehaviorSubject(null);
391
- }
392
- ngOnInit() {
393
- this.taskService.getCandidateUsers(this.taskId).subscribe(candidateUsers => {
394
- this.candidateUsersForTask$.next(candidateUsers);
395
- if (this.assigneeEmail) {
396
- this.assignedEmailOnServer$.next(this.assigneeEmail);
397
- this.userEmailToAssign = this.assigneeEmail;
398
- this.assignedUserFullName$.next(this.getAssignedUserName(candidateUsers, this.assigneeEmail));
399
- }
400
- this.enable();
401
- });
402
- }
403
- ngOnChanges(changes) {
404
- const assigneeEmail = changes.assigneeEmail;
405
- if (assigneeEmail) {
406
- this.candidateUsersForTask$.pipe(take(1)).subscribe(candidateUsers => {
407
- const currentUserEmail = assigneeEmail.currentValue;
408
- this.assignedEmailOnServer$.next(currentUserEmail || null);
409
- this.userEmailToAssign = currentUserEmail || null;
410
- this.assignedUserFullName$.next(this.getAssignedUserName(candidateUsers, currentUserEmail));
411
- });
412
- }
413
- else {
414
- this.clear();
415
- }
416
- }
417
- assignTask(userEmail) {
418
- this.disable();
419
- combineLatest([this.candidateUsersForTask$, this.taskService.assignTask(this.taskId, { assignee: userEmail })])
420
- .pipe(take(1), tap(([candidateUsers]) => {
421
- this.userEmailToAssign = userEmail;
422
- this.assignedEmailOnServer$.next(userEmail);
423
- this.assignedUserFullName$.next(this.getAssignedUserName(candidateUsers, userEmail));
424
- this.emitChange();
425
- this.enable();
426
- }))
427
- .subscribe();
428
- }
429
- unassignTask() {
430
- this.disable();
431
- this.taskService
432
- .unassignTask(this.taskId)
433
- .pipe(tap(() => {
434
- this.clear();
435
- this.emitChange();
436
- this.enable();
437
- }))
438
- .subscribe();
439
- }
440
- getAssignedUserName(users, userEmail) {
441
- if (users && userEmail) {
442
- const findUser = users.find(user => user.email === userEmail);
443
- return findUser ? findUser.fullName : '';
444
- }
445
- return '';
446
- }
447
- mapUsersForDropdown(users) {
448
- return (users &&
449
- users
450
- .map(user => { var _a; return (Object.assign(Object.assign({}, user), { lastName: ((_a = user.lastName) === null || _a === void 0 ? void 0 : _a.split(' ').splice(-1)[0]) || '' })); })
451
- .sort((a, b) => a.lastName.localeCompare(b.lastName))
452
- .map(user => ({ text: user.fullName, id: user.email })));
453
- }
454
- clear() {
455
- this.assignedEmailOnServer$.next(null);
456
- this.userEmailToAssign = null;
457
- }
458
- emitChange() {
459
- this.assignmentOfTaskChanged.emit();
460
- }
461
- enable() {
462
- this.disabled$.next(false);
463
- }
464
- disable() {
465
- this.disabled$.next(true);
466
- }
467
- }
468
- AssignUserToTaskComponent.decorators = [
469
- { type: Component, args: [{
470
- selector: 'valtimo-assign-user-to-task',
471
- template: "<ng-container\n *ngIf=\"{\n candidateUsers: candidateUsersForTask$ | async,\n disabled: disabled$ | async,\n emailOnServer: assignedEmailOnServer$ | async\n } as obs\"\n>\n <div class=\"container-fluid\">\n <div class=\"row mt-2 mb-2\">\n <div class=\"col-12 pl-0 d-flex flex-row align-items-center\">\n <ng-container *ngIf=\"obs.candidateUsers; else loading\">\n <valtimo-searchable-dropdown-select\n [style]=\"'underlinedText'\"\n [items]=\"mapUsersForDropdown(obs.candidateUsers)\"\n [buttonText]=\"'assignTask.header' | translate\"\n [searchText]=\"'interface.typeToSearch' | translate\"\n [noResultsText]=\"'interface.noSearchResults' | translate\"\n [disabled]=\"obs.disabled\"\n [selectedText]=\"'assignTask.assignedTo' | translate\"\n [selectedTextValue]=\"assignedUserFullName$ | async\"\n [clearSelectionButtonTitle]=\"'assignTask.remove' | translate\"\n [hasSelection]=\"userEmailToAssign === obs.emailOnServer && obs.emailOnServer !== null\"\n [width]=\"250\"\n (itemSelected)=\"assignTask($event)\"\n (clearSelection)=\"unassignTask()\"\n >\n </valtimo-searchable-dropdown-select>\n </ng-container>\n </div>\n </div>\n </div>\n</ng-container>\n\n<ng-template #loading>\n <h5><b>{{'assignTask.fetchingUsers' | translate}}</b></h5>\n</ng-template>\n\n",
472
- styles: [".container-fluid{color:#959595}i{font-size:13px}"]
473
- },] }
474
- ];
475
- AssignUserToTaskComponent.ctorParameters = () => [
476
- { type: TaskService }
477
- ];
478
- AssignUserToTaskComponent.propDecorators = {
479
- taskId: [{ type: Input }],
480
- assigneeEmail: [{ type: Input }],
481
- assignmentOfTaskChanged: [{ type: Output }]
383
+ /*
384
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
385
+ *
386
+ * Licensed under EUPL, Version 1.2 (the "License");
387
+ * you may not use this file except in compliance with the License.
388
+ * You may obtain a copy of the License at
389
+ *
390
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
391
+ *
392
+ * Unless required by applicable law or agreed to in writing, software
393
+ * distributed under the License is distributed on an "AS IS" basis,
394
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
395
+ * See the License for the specific language governing permissions and
396
+ * limitations under the License.
397
+ */
398
+ class AssignUserToTaskComponent {
399
+ constructor(taskService) {
400
+ this.taskService = taskService;
401
+ this.assignmentOfTaskChanged = new EventEmitter();
402
+ this.candidateUsersForTask$ = new BehaviorSubject(undefined);
403
+ this.disabled$ = new BehaviorSubject(true);
404
+ this.assignedEmailOnServer$ = new BehaviorSubject(null);
405
+ this.userEmailToAssign = null;
406
+ this.assignedUserFullName$ = new BehaviorSubject(null);
407
+ }
408
+ ngOnInit() {
409
+ this.taskService.getCandidateUsers(this.taskId).subscribe(candidateUsers => {
410
+ this.candidateUsersForTask$.next(candidateUsers);
411
+ if (this.assigneeEmail) {
412
+ this.assignedEmailOnServer$.next(this.assigneeEmail);
413
+ this.userEmailToAssign = this.assigneeEmail;
414
+ this.assignedUserFullName$.next(this.getAssignedUserName(candidateUsers, this.assigneeEmail));
415
+ }
416
+ this.enable();
417
+ });
418
+ }
419
+ ngOnChanges(changes) {
420
+ const assigneeEmail = changes.assigneeEmail;
421
+ if (assigneeEmail) {
422
+ this.candidateUsersForTask$.pipe(take(1)).subscribe(candidateUsers => {
423
+ const currentUserEmail = assigneeEmail.currentValue;
424
+ this.assignedEmailOnServer$.next(currentUserEmail || null);
425
+ this.userEmailToAssign = currentUserEmail || null;
426
+ this.assignedUserFullName$.next(this.getAssignedUserName(candidateUsers, currentUserEmail));
427
+ });
428
+ }
429
+ else {
430
+ this.clear();
431
+ }
432
+ }
433
+ assignTask(userEmail) {
434
+ this.disable();
435
+ combineLatest([
436
+ this.candidateUsersForTask$,
437
+ this.taskService.assignTask(this.taskId, { assignee: userEmail }),
438
+ ])
439
+ .pipe(take(1), tap(([candidateUsers]) => {
440
+ this.userEmailToAssign = userEmail;
441
+ this.assignedEmailOnServer$.next(userEmail);
442
+ this.assignedUserFullName$.next(this.getAssignedUserName(candidateUsers, userEmail));
443
+ this.emitChange();
444
+ this.enable();
445
+ }))
446
+ .subscribe();
447
+ }
448
+ unassignTask() {
449
+ this.disable();
450
+ this.taskService
451
+ .unassignTask(this.taskId)
452
+ .pipe(tap(() => {
453
+ this.clear();
454
+ this.emitChange();
455
+ this.enable();
456
+ }))
457
+ .subscribe();
458
+ }
459
+ getAssignedUserName(users, userEmail) {
460
+ if (users && userEmail) {
461
+ const findUser = users.find(user => user.email === userEmail);
462
+ return findUser ? findUser.fullName : '';
463
+ }
464
+ return '';
465
+ }
466
+ mapUsersForDropdown(users) {
467
+ return (users &&
468
+ users
469
+ .map(user => { var _a; return (Object.assign(Object.assign({}, user), { lastName: ((_a = user.lastName) === null || _a === void 0 ? void 0 : _a.split(' ').splice(-1)[0]) || '' })); })
470
+ .sort((a, b) => a.lastName.localeCompare(b.lastName))
471
+ .map(user => ({ text: user.fullName, id: user.email })));
472
+ }
473
+ clear() {
474
+ this.assignedEmailOnServer$.next(null);
475
+ this.userEmailToAssign = null;
476
+ }
477
+ emitChange() {
478
+ this.assignmentOfTaskChanged.emit();
479
+ }
480
+ enable() {
481
+ this.disabled$.next(false);
482
+ }
483
+ disable() {
484
+ this.disabled$.next(true);
485
+ }
486
+ }
487
+ AssignUserToTaskComponent.decorators = [
488
+ { type: Component, args: [{
489
+ selector: 'valtimo-assign-user-to-task',
490
+ template: "<ng-container\n *ngIf=\"{\n candidateUsers: candidateUsersForTask$ | async,\n disabled: disabled$ | async,\n emailOnServer: assignedEmailOnServer$ | async\n } as obs\"\n>\n <div class=\"container-fluid\">\n <div class=\"row mt-2 mb-2\">\n <div class=\"col-12 pl-0 d-flex flex-row align-items-center\">\n <ng-container *ngIf=\"obs.candidateUsers; else loading\">\n <valtimo-searchable-dropdown-select\n [style]=\"'underlinedText'\"\n [items]=\"mapUsersForDropdown(obs.candidateUsers)\"\n [buttonText]=\"'assignTask.header' | translate\"\n [searchText]=\"'interface.typeToSearch' | translate\"\n [noResultsText]=\"'interface.noSearchResults' | translate\"\n [disabled]=\"obs.disabled\"\n [selectedText]=\"'assignTask.assignedTo' | translate\"\n [selectedTextValue]=\"assignedUserFullName$ | async\"\n [clearSelectionButtonTitle]=\"'assignTask.remove' | translate\"\n [hasSelection]=\"userEmailToAssign === obs.emailOnServer && obs.emailOnServer !== null\"\n [width]=\"250\"\n (itemSelected)=\"assignTask($event)\"\n (clearSelection)=\"unassignTask()\"\n >\n </valtimo-searchable-dropdown-select>\n </ng-container>\n </div>\n </div>\n </div>\n</ng-container>\n\n<ng-template #loading>\n <h5>\n <b>{{ 'assignTask.fetchingUsers' | translate }}</b>\n </h5>\n</ng-template>\n",
491
+ styles: [".container-fluid{color:#959595}i{font-size:13px}"]
492
+ },] }
493
+ ];
494
+ AssignUserToTaskComponent.ctorParameters = () => [
495
+ { type: TaskService }
496
+ ];
497
+ AssignUserToTaskComponent.propDecorators = {
498
+ taskId: [{ type: Input }],
499
+ assigneeEmail: [{ type: Input }],
500
+ assignmentOfTaskChanged: [{ type: Output }]
482
501
  };
483
502
 
484
- /*
485
- * Copyright 2015-2020 Ritense BV, the Netherlands.
486
- *
487
- * Licensed under EUPL, Version 1.2 (the "License");
488
- * you may not use this file except in compliance with the License.
489
- * You may obtain a copy of the License at
490
- *
491
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
492
- *
493
- * Unless required by applicable law or agreed to in writing, software
494
- * distributed under the License is distributed on an "AS IS" basis,
495
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
496
- * See the License for the specific language governing permissions and
497
- * limitations under the License.
498
- */
499
- const ɵ0$1 = HttpLoaderFactory;
500
- class TaskModule {
501
- }
502
- TaskModule.decorators = [
503
- { type: NgModule, args: [{
504
- declarations: [TaskListComponent, TaskDetailModalComponent, AssignUserToTaskComponent],
505
- imports: [
506
- CommonModule,
507
- TaskRoutingModule,
508
- ListModule,
509
- PageHeaderModule,
510
- WidgetModule,
511
- SpinnerModule,
512
- SearchableDropdownSelectModule,
513
- CamundaFormModule,
514
- BrowserAnimationsModule,
515
- FormsModule,
516
- ToastrModule.forRoot({
517
- positionClass: 'toast-bottom-full-width',
518
- preventDuplicates: true
519
- }),
520
- TranslateModule.forRoot({
521
- loader: {
522
- provide: TranslateLoader,
523
- useFactory: ɵ0$1,
524
- deps: [HttpClient]
525
- }
526
- }),
527
- NgbModule,
528
- FormIoModule,
529
- ModalModule
530
- ],
531
- exports: [TaskListComponent, TaskDetailModalComponent, AssignUserToTaskComponent]
532
- },] }
503
+ /*
504
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
505
+ *
506
+ * Licensed under EUPL, Version 1.2 (the "License");
507
+ * you may not use this file except in compliance with the License.
508
+ * You may obtain a copy of the License at
509
+ *
510
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
511
+ *
512
+ * Unless required by applicable law or agreed to in writing, software
513
+ * distributed under the License is distributed on an "AS IS" basis,
514
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
515
+ * See the License for the specific language governing permissions and
516
+ * limitations under the License.
517
+ */
518
+ const ɵ0$1 = HttpLoaderFactory;
519
+ class TaskModule {
520
+ }
521
+ TaskModule.decorators = [
522
+ { type: NgModule, args: [{
523
+ declarations: [TaskListComponent, TaskDetailModalComponent, AssignUserToTaskComponent],
524
+ imports: [
525
+ CommonModule,
526
+ TaskRoutingModule,
527
+ ListModule,
528
+ PageHeaderModule,
529
+ WidgetModule,
530
+ SpinnerModule,
531
+ SearchableDropdownSelectModule,
532
+ CamundaFormModule,
533
+ BrowserAnimationsModule,
534
+ FormsModule,
535
+ ToastrModule.forRoot({
536
+ positionClass: 'toast-bottom-full-width',
537
+ preventDuplicates: true,
538
+ }),
539
+ TranslateModule.forRoot({
540
+ loader: {
541
+ provide: TranslateLoader,
542
+ useFactory: ɵ0$1,
543
+ deps: [HttpClient],
544
+ },
545
+ }),
546
+ NgbModule,
547
+ FormIoModule,
548
+ ModalModule,
549
+ ],
550
+ exports: [TaskListComponent, TaskDetailModalComponent, AssignUserToTaskComponent],
551
+ },] }
533
552
  ];
534
553
 
535
- /*
536
- * Copyright 2015-2020 Ritense BV, the Netherlands.
537
- *
538
- * Licensed under EUPL, Version 1.2 (the "License");
539
- * you may not use this file except in compliance with the License.
540
- * You may obtain a copy of the License at
541
- *
542
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
543
- *
544
- * Unless required by applicable law or agreed to in writing, software
545
- * distributed under the License is distributed on an "AS IS" basis,
546
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
547
- * See the License for the specific language governing permissions and
548
- * limitations under the License.
554
+ /*
555
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
556
+ *
557
+ * Licensed under EUPL, Version 1.2 (the "License");
558
+ * you may not use this file except in compliance with the License.
559
+ * You may obtain a copy of the License at
560
+ *
561
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
562
+ *
563
+ * Unless required by applicable law or agreed to in writing, software
564
+ * distributed under the License is distributed on an "AS IS" basis,
565
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
566
+ * See the License for the specific language governing permissions and
567
+ * limitations under the License.
549
568
  */
550
569
 
551
- /**
552
- * Generated bundle index. Do not edit.
570
+ /**
571
+ * Generated bundle index. Do not edit.
553
572
  */
554
573
 
555
574
  export { TaskDetailModalComponent, TaskListComponent, TaskModule, TaskService, ɵ0$1 as ɵ0, AssignUserToTaskComponent as ɵa, TaskRoutingModule as ɵb };