bx-rest 0.2.11 → 0.2.13

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.
Files changed (47) hide show
  1. package/esm2022/map/disk/base.mjs +1 -1
  2. package/esm2022/map/disk/file.mjs +1 -1
  3. package/esm2022/map/disk/folder.mjs +1 -1
  4. package/esm2022/map/disk/storage.mjs +1 -1
  5. package/esm2022/map/task/planner.mjs +17 -0
  6. package/esm2022/request/disk/attachedObject.mjs +1 -1
  7. package/esm2022/request/disk/file.mjs +1 -1
  8. package/esm2022/request/disk/folder.mjs +1 -1
  9. package/esm2022/request/disk/storage.mjs +1 -1
  10. package/esm2022/request/task/planner.mjs +21 -0
  11. package/esm2022/request/task.mjs +6 -4
  12. package/esm2022/request/tasks/task.mjs +2 -9
  13. package/esm2022/request-navvy/task/elapseditem.mjs +17 -73
  14. package/esm2022/request-navvy/task/operation/elapseditem.mjs +101 -4
  15. package/esm2022/request-navvy/task/planner.mjs +24 -0
  16. package/esm2022/request-navvy/task.mjs +6 -4
  17. package/esm2022/services/http/HttpBX.mjs +4 -7
  18. package/esm2022/typification/rest/disk/file.mjs +1 -1
  19. package/esm2022/typification/rest/disk/map.mjs +1 -1
  20. package/esm2022/typification/rest/user/get.mjs +1 -1
  21. package/fesm2022/bx-rest.mjs +619 -534
  22. package/fesm2022/bx-rest.mjs.map +1 -1
  23. package/map/disk/base.d.ts +4 -4
  24. package/map/disk/file.d.ts +3 -7
  25. package/map/disk/folder.d.ts +2 -2
  26. package/map/disk/storage.d.ts +2 -2
  27. package/map/task/planner.d.ts +7 -0
  28. package/package.json +1 -1
  29. package/request/disk/file.d.ts +3 -3
  30. package/request/disk/folder.d.ts +2 -2
  31. package/request/disk/storage.d.ts +3 -3
  32. package/request/task/planner.d.ts +9 -0
  33. package/request/task.d.ts +3 -1
  34. package/request/tasks/task.d.ts +0 -3
  35. package/request-navvy/disk/file.d.ts +2 -6
  36. package/request-navvy/disk/folder.d.ts +1 -1
  37. package/request-navvy/disk/interlayer/storage.d.ts +2 -2
  38. package/request-navvy/disk/operation.d.ts +3 -3
  39. package/request-navvy/disk/storage.d.ts +2 -2
  40. package/request-navvy/task/elapseditem.d.ts +7 -10
  41. package/request-navvy/task/operation/elapseditem.d.ts +13 -2
  42. package/request-navvy/task/planner.d.ts +12 -0
  43. package/request-navvy/task.d.ts +3 -1
  44. package/services/http/HttpBX.d.ts +4 -0
  45. package/typification/rest/disk/file.d.ts +4 -5
  46. package/typification/rest/disk/map.d.ts +3 -3
  47. package/typification/rest/user/get.d.ts +34 -1
@@ -12,7 +12,7 @@ import { DateTime } from 'luxon';
12
12
  import * as i1$2 from '@angular/common/http';
13
13
  import { HttpParams, HttpHeaders } from '@angular/common/http';
14
14
  import flatten from 'just-flatten-it';
15
- import { map, catchError, mergeMap as mergeMap$1 } from 'rxjs/operators';
15
+ import { map, catchError, take, mergeMap as mergeMap$1 } from 'rxjs/operators';
16
16
 
17
17
  const BX_REST_SETTINGS = {
18
18
  auth: {
@@ -1152,12 +1152,9 @@ class HttpBXServices extends HttpServices {
1152
1152
  }
1153
1153
  return res;
1154
1154
  }
1155
- // override mapBranchResult<T>(res: iBatchRequestAnswer<T>[]) {
1156
- // return Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined)) as {
1157
- // [key: keyBatch]: T
1158
- // }
1159
- // }
1160
- //
1155
+ mapBranchResult(res) {
1156
+ return Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined));
1157
+ }
1161
1158
  mapBranchResultWithoutKey(res) {
1162
1159
  return flatten(Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined)));
1163
1160
  }
@@ -1483,12 +1480,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImpor
1483
1480
  }]
1484
1481
  }], ctorParameters: function () { return [{ type: HttpBXServices }]; } });
1485
1482
 
1483
+ class BXRestTaskPlanner {
1484
+ constructor(http) {
1485
+ this.http = http;
1486
+ }
1487
+ getList() {
1488
+ return this.http.post([$task, $planner, $getlist]);
1489
+ }
1490
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestTaskPlanner, deps: [{ token: HttpBXServices }], target: i0.ɵɵFactoryTarget.Injectable }); }
1491
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestTaskPlanner, providedIn: 'root' }); }
1492
+ }
1493
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestTaskPlanner, decorators: [{
1494
+ type: Injectable,
1495
+ args: [{
1496
+ providedIn: 'root'
1497
+ }]
1498
+ }], ctorParameters: function () { return [{ type: HttpBXServices }]; } });
1499
+
1486
1500
  class BXRestTask {
1487
- constructor(elapseditem, commentitem) {
1501
+ constructor(elapseditem, commentitem, planner) {
1488
1502
  this.elapseditem = elapseditem;
1489
1503
  this.commentitem = commentitem;
1504
+ this.planner = planner;
1490
1505
  }
1491
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestTask, deps: [{ token: BXRestTaskElapseditem }, { token: BXRestTaskCommentItem }], target: i0.ɵɵFactoryTarget.Injectable }); }
1506
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestTask, deps: [{ token: BXRestTaskElapseditem }, { token: BXRestTaskCommentItem }, { token: BXRestTaskPlanner }], target: i0.ɵɵFactoryTarget.Injectable }); }
1492
1507
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestTask, providedIn: 'root' }); }
1493
1508
  }
1494
1509
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestTask, decorators: [{
@@ -1496,7 +1511,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImpor
1496
1511
  args: [{
1497
1512
  providedIn: 'root'
1498
1513
  }]
1499
- }], ctorParameters: function () { return [{ type: BXRestTaskElapseditem }, { type: BXRestTaskCommentItem }]; } });
1514
+ }], ctorParameters: function () { return [{ type: BXRestTaskElapseditem }, { type: BXRestTaskCommentItem }, { type: BXRestTaskPlanner }]; } });
1500
1515
 
1501
1516
  class BXRestTasksTask {
1502
1517
  constructor(http) {
@@ -1536,9 +1551,6 @@ class BXRestTasksTask {
1536
1551
  list: [$tasks, $task, $result, $list],
1537
1552
  addFromComment: [$tasks, $task, $result, 'addFromComment'],
1538
1553
  deleteFromComment: [$tasks, $task, $result, 'deleteFromComment'], // Удаление результата задачи по комментарию из которого он был создан
1539
- },
1540
- planner: {
1541
- getlist: [$task, $planner, $getlist], // Возвращает массив, содержащий идентификаторы задач в плане на день
1542
1554
  }
1543
1555
  };
1544
1556
  }
@@ -1701,10 +1713,6 @@ class BXRestTasksTask {
1701
1713
  return undefined
1702
1714
  }))
1703
1715
  }
1704
-
1705
- getPlannerList() {s
1706
- return this.http.post<iHttpAnswerBX<(string | number)[]>>(this.url.planner.getlist)
1707
- }
1708
1716
  */
1709
1717
  getaccess(param) {
1710
1718
  return this.http.post(this.url.getaccess, param);
@@ -3019,11 +3027,43 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImpor
3019
3027
  }]
3020
3028
  }] });
3021
3029
 
3030
+ class BXRestMapTaskElapseditem extends BaseMapServices {
3031
+ update(p) {
3032
+ return (p == null);
3033
+ }
3034
+ getList(v) {
3035
+ return (v) ? v.map(i => this.ElapsedItemHttpToElapsedItem(i)) : undefined;
3036
+ }
3037
+ ElapsedItemHttpToElapsedItem(item) {
3038
+ return Object.assign(item, {
3039
+ ID: this.toNum(item.ID),
3040
+ MINUTES: this.toNum(item.MINUTES),
3041
+ SECONDS: this.toNum(item.SECONDS),
3042
+ TASK_ID: this.toNum(item.TASK_ID),
3043
+ USER_ID: this.toNum(item.USER_ID),
3044
+ SOURCE: this.toNum(item.SOURCE),
3045
+ CREATED_DATE: this.toDate(item.CREATED_DATE),
3046
+ DATE_START: this.toDate(item.DATE_START),
3047
+ DATE_STOP: this.toDate(item.DATE_STOP),
3048
+ });
3049
+ }
3050
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskElapseditem, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
3051
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskElapseditem, providedIn: 'root' }); }
3052
+ }
3053
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskElapseditem, decorators: [{
3054
+ type: Injectable,
3055
+ args: [{
3056
+ providedIn: 'root'
3057
+ }]
3058
+ }] });
3059
+
3022
3060
  class BXRestNavvyOperationElapseditem {
3023
- constructor(http, BXRestNavvyElapseditem, BXRestMapElapseditem) {
3061
+ constructor(http, BXRestNavvyElapseditem, BXRestMapElapseditem, BXRestNavvyUser, BXRestNavvyTasks) {
3024
3062
  this.http = http;
3025
3063
  this.BXRestNavvyElapseditem = BXRestNavvyElapseditem;
3026
3064
  this.BXRestMapElapseditem = BXRestMapElapseditem;
3065
+ this.BXRestNavvyUser = BXRestNavvyUser;
3066
+ this.BXRestNavvyTasks = BXRestNavvyTasks;
3027
3067
  }
3028
3068
  getByInterval(idsUsers, dateStart, dateEnd) {
3029
3069
  const param = {
@@ -3053,428 +3093,136 @@ class BXRestNavvyOperationElapseditem {
3053
3093
  return undefined;
3054
3094
  }));
3055
3095
  }
3056
- }
3057
-
3058
- class BXRestMapTasksTask extends BaseMapServices {
3059
- getaccess(v) {
3060
- return (v && v.allowedActions) ? v.allowedActions : undefined;
3096
+ checkPermissionAddElapsedtimeToTaskArr(tasks) {
3097
+ let request = Object.assign({}, ...tasks.map(i => {
3098
+ return { [i]: this.checkPermissionAddElapsedtimeToTask(i) };
3099
+ }));
3100
+ return forkJoin(request)
3101
+ .pipe(take(1), mergeMap(v => {
3102
+ let forForeach = Object.entries(v).map(([key, value]) => {
3103
+ return { id: Number(key), value: value };
3104
+ });
3105
+ if (forForeach.find(i => i.value === undefined) !== undefined) {
3106
+ let forForeachHave = forForeach.filter(i => i.value !== undefined);
3107
+ let forForeachNotHave = forForeach.filter(i => i.value === undefined); // тут получаем все id не сохраненных у нас прав
3108
+ return this.http.branch(Object.assign({}, ...forForeachNotHave
3109
+ .map(i => i.id)
3110
+ .map(i => {
3111
+ return {
3112
+ [i]: {
3113
+ name: this.http.getNameMethod([$tasks, $task, $getaccess]),
3114
+ param: {
3115
+ TASKID: i,
3116
+ ITEMID: 1,
3117
+ ACTIONID: 1
3118
+ }
3119
+ }
3120
+ };
3121
+ }))).pipe(map(v => {
3122
+ if (v && v.length) {
3123
+ const res = this.http.mapBranchResult(v);
3124
+ forForeachNotHave = Object.entries(res).map(([key, value]) => {
3125
+ return { id: Number(key), value: value };
3126
+ });
3127
+ return Object.assign(forForeachHave, forForeachNotHave);
3128
+ }
3129
+ return undefined;
3130
+ }));
3131
+ }
3132
+ return of(forForeach);
3133
+ }));
3061
3134
  }
3062
- add(item) {
3063
- return (item) ? this.TaskBXHttpToTaskBX(item.task) : undefined;
3135
+ checkPermissionAddElapsedtimeToTask(idTask) {
3136
+ let permission = Permission.get();
3137
+ if (permission?.tasks?.length) {
3138
+ let findTask = permission.tasks.find(i => i.id === idTask);
3139
+ if (findTask?.permission) {
3140
+ return of(findTask.permission['ELAPSEDTIME.ADD']);
3141
+ }
3142
+ return this.BXRestNavvyUser.current().result().pipe(mergeMap(self => {
3143
+ if (self) {
3144
+ return this.BXRestNavvyTasks.task.getaccess({
3145
+ id: idTask,
3146
+ users: [self.ID]
3147
+ }).result().pipe(tap(v => {
3148
+ if (v && v[self.ID]) {
3149
+ Permission.set({
3150
+ tasks: [{ id: idTask, permission: v[self.ID], elapsedItem: [] }]
3151
+ });
3152
+ }
3153
+ }), map(v => {
3154
+ return (v && v[self.ID]) ? v[self.ID]['ELAPSEDTIME.ADD'] : false;
3155
+ }));
3156
+ }
3157
+ return of(undefined);
3158
+ }));
3159
+ }
3160
+ return of(undefined);
3064
3161
  }
3065
- get(item) {
3066
- return (item && item.task) ? this.TaskBXHttpToTaskBX(item.task) : undefined;
3162
+ checkPermissionReadTask(idTask) {
3163
+ let permission = Permission.get();
3164
+ if (permission?.tasks?.length) {
3165
+ let findTask = permission.tasks.find(i => i.id === idTask);
3166
+ if (findTask?.permission) {
3167
+ return of(findTask.permission.ACCEPT);
3168
+ }
3169
+ return this.BXRestNavvyUser.current().result().pipe(mergeMap(self => {
3170
+ if (self) {
3171
+ return this.BXRestNavvyTasks.task.getaccess({
3172
+ id: idTask,
3173
+ users: [self.ID]
3174
+ }).result().pipe(tap(v => {
3175
+ if (v && v[self.ID]) {
3176
+ Permission.set({
3177
+ tasks: [{ id: idTask, permission: v[self.ID], elapsedItem: [] }]
3178
+ });
3179
+ }
3180
+ }), map(v => {
3181
+ return (v && v[self.ID]) ? v[self.ID].ACCEPT : false;
3182
+ }));
3183
+ }
3184
+ return of(undefined);
3185
+ }));
3186
+ }
3187
+ return of(undefined);
3067
3188
  }
3068
- list(item) {
3069
- return (item && item.tasks) ? item.tasks.map(i => this.TaskBXHttpToTaskBX(i)) : undefined;
3189
+ }
3190
+
3191
+ class BXRestNavvyElapseditem {
3192
+ constructor(BXRestElapseditem, BXRestMapElapseditem, operation) {
3193
+ this.BXRestElapseditem = BXRestElapseditem;
3194
+ this.BXRestMapElapseditem = BXRestMapElapseditem;
3195
+ this.operation = operation;
3196
+ this.Navvy = new Navvy(this.BXRestElapseditem, this.BXRestMapElapseditem);
3070
3197
  }
3071
- TaskBXHttpToTaskBX(item) {
3072
- let result = {};
3073
- if (item.id) {
3074
- result.id = this.toNum(item.id);
3075
- }
3076
- if (item.parentId) {
3077
- result.parentId = this.toNum(item.parentId);
3078
- }
3079
- if (item.priority) {
3080
- result.priority = this.toNum(item.priority);
3081
- }
3082
- if (item.status) {
3083
- result.status = this.toNum(item.status);
3084
- }
3085
- if (item.multitask) {
3086
- result.multitask = item.multitask === 'Y';
3087
- }
3088
- if (item.groupId) {
3089
- result.groupId = this.toNum(item.groupId);
3090
- }
3091
- if (item.stageId) {
3092
- result.stageId = this.toNum(item.stageId);
3093
- }
3094
- if (item.createdBy) {
3095
- result.createdBy = this.toNum(item.createdBy);
3096
- }
3097
- if (item.createdDate) {
3098
- result.createdDate = this.toDate(item.createdDate);
3099
- }
3100
- if (item.responsibleId) {
3101
- result.responsibleId = this.toNum(item.responsibleId);
3102
- }
3103
- if (item.changedBy) {
3104
- result.changedBy = this.toNum(item.changedBy);
3105
- }
3106
- if (item.changedDate) {
3107
- result.changedDate = this.toDate(item.changedDate);
3108
- }
3109
- if (item.statusChangedBy) {
3110
- result.statusChangedBy = this.toNum(item.statusChangedBy);
3111
- }
3112
- if (item.statusChangedDate) {
3113
- result.statusChangedDate = this.toDate(item.statusChangedDate);
3114
- }
3115
- if (item.closedBy) {
3116
- result.closedBy = this.toNum(item.closedBy);
3117
- }
3118
- if (item.closedDate) {
3119
- result.closedDate = this.toDate(item.closedDate);
3120
- }
3121
- if (item.dateStart) {
3122
- result.dateStart = this.toDate(item.dateStart);
3123
- }
3124
- if (item.deadline) {
3125
- result.deadline = this.toDate(item.deadline);
3126
- }
3127
- if (item.startDatePlan) {
3128
- result.startDatePlan = this.toDate(item.startDatePlan);
3129
- }
3130
- if (item.endDatePlan) {
3131
- result.endDatePlan = this.toDate(item.endDatePlan);
3132
- }
3133
- if (item.forumTopicId) {
3134
- result.forumTopicId = this.toNum(item.forumTopicId);
3135
- }
3136
- if (item.forumId) {
3137
- result.forumId = this.toNum(item.forumId);
3138
- }
3139
- if (item.viewedDate) {
3140
- result.viewedDate = this.toDate(item.viewedDate);
3141
- }
3142
- if (item.sorting) {
3143
- result.sorting = this.toNum(item.sorting);
3144
- }
3145
- if (item.durationPlan) {
3146
- result.durationPlan = this.toNum(item.durationPlan);
3147
- }
3148
- if (item.descriptionInBbcode) {
3149
- result.descriptionInBbcode = item.descriptionInBbcode === 'Y';
3150
- }
3151
- if (item.accomplices) {
3152
- result.accomplices = item.accomplices.map(i => this.toNum(i));
3153
- }
3154
- if (item.subStatus) {
3155
- result.subStatus = this.toNum(item.subStatus);
3156
- }
3157
- if (item.creator) {
3158
- result.creator = Object.assign(item.creator, { id: this.toNum(item.creator.id) });
3159
- }
3160
- if (item.responsible) {
3161
- result.responsible = Object.assign(item.responsible, { id: this.toNum(item.responsible.id) });
3162
- }
3163
- if (item.accomplicesData) {
3164
- result.accomplicesData =
3165
- Object.values(item.accomplicesData).map(i => Object.assign(i, { id: this.toNum(i.id) }));
3166
- }
3167
- if (item.allowTimeTracking) {
3168
- result.allowTimeTracking = item.allowTimeTracking === 'Y';
3198
+ /*
3199
+ call(methodName: string, ...args: any[]){
3200
+ if (typeof this[methodName] === 'function') {
3201
+ return this[methodName](...args);
3202
+ }
3203
+ return this[methodName](...args);
3204
+ }
3205
+ */
3206
+ getList(param = {}) {
3207
+ if (param) {
3208
+ if (!param.TASKID && !param.SELECT) {
3209
+ param.SELECT = ['*'];
3210
+ }
3211
+ if (!param.TASKID && !param.PARAMS) {
3212
+ param.PARAMS = {
3213
+ NAV_PARAMS: {
3214
+ nPageSize: 50,
3215
+ iNumPage: 1
3216
+ }
3217
+ };
3218
+ }
3169
3219
  }
3170
- return Object.assign(item, result);
3171
- }
3172
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTasksTask, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
3173
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTasksTask, providedIn: 'root' }); }
3174
- }
3175
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTasksTask, decorators: [{
3176
- type: Injectable,
3177
- args: [{
3178
- providedIn: 'root'
3179
- }]
3180
- }] });
3181
-
3182
- // export interface TimeProcess {
3183
- // total: number,
3184
- // next: number
3185
- // }
3186
- class BXRestNavvyTasksTask {
3187
- constructor(BXRestTasksTask,
3188
- // private snackBar: SnackBarService,
3189
- // private store: Store<{ tasks: IStoreTask }>,
3190
- BXRestMapTasksTask) {
3191
- this.BXRestTasksTask = BXRestTasksTask;
3192
- this.BXRestMapTasksTask = BXRestMapTasksTask;
3193
- // pageSize = 50
3194
- // nowLoad$ = new ReplaySubject<TimeProcess>(1)
3195
- this.def = {
3196
- select: ['ID', 'PARENT_ID', 'TITLE', 'DESCRIPTION', 'MARK', 'PRIORITY', 'STATUS', 'MULTITASK',
3197
- 'GROUP_ID', 'STAGE_ID', 'CREATED_BY', 'CREATED_DATE', 'RESPONSIBLE_ID', 'ACCOMPLICES', 'AUDITORS',
3198
- 'CHANGED_BY', 'CHANGED_DATE', 'STATUS_CHANGED_DATE', 'CLOSED_BY', 'CLOSED_DATE', 'DATE_START', 'VIEWED_DATE',
3199
- 'DEADLINE', 'START_DATE_PLAN', 'END_DATE_PLAN', 'FORKED_BY_TEMPLATE_ID', 'TIME_ESTIMATE', 'TIME_SPENT_IN_LOGS',
3200
- 'TAGS', 'ALLOW_TIME_TRACKING'
3201
- ]
3202
- };
3203
- this.Navvy = new Navvy(this.BXRestTasksTask, this.BXRestMapTasksTask);
3204
- // this.storeTask$ = this.store.select('tasks')
3205
- // this.nowLoad$.next({
3206
- // total: 0,
3207
- // next: 0
3208
- // })
3209
- }
3210
- add(param) {
3211
- return this.Navvy.simpleWithArg(this.BXRestTasksTask.add, param, 'Не удалось добавить задачу', this.BXRestMapTasksTask.add);
3212
- // return this.http.post<{ task: TaskBXHttp }>(this.url.add, {fields: param}).pipe(
3213
- // map(v => {
3214
- // if (v && v.result && v.result.task) {
3215
- // return Object.assign(
3216
- // v,
3217
- // {
3218
- // result: this.taskBXMap.TaskBXHttpToTaskBX(v.result.task)
3219
- // })
3220
- // }
3221
- // return undefined
3222
- // }
3223
- // ))
3224
- }
3225
- /*
3226
- update(taskId: number, updateFields: iBXRestTaskFieldsName[], task: iBXRestTask) {
3227
- let sendTask: Record<string, any> = {}
3228
- let taskTS: Record<string, any> = task
3229
- if (updateFields.length) {
3230
- for (let updateField of updateFields) {
3231
- if (taskTS[camelCase(updateField)]) {
3232
- sendTask[updateField] = taskTS[camelCase(updateField)]
3233
- }
3234
- }
3235
- if (Object.values(sendTask).length) {
3236
- return this.http.post(
3237
- this.url.update,
3238
- {taskId: taskId, fields: sendTask},
3239
- 'error to update task')
3240
- } else {
3241
- this.snackBar.error('not valid send data task')
3242
- console.error('not valid send data task', sendTask, task)
3243
- return of(undefined)
3244
- }
3245
- }
3246
-
3247
- this.snackBar.warning('not have field for update')
3248
- return of(undefined)
3249
- }
3250
- */
3251
- get(param) {
3252
- if (!param.select) {
3253
- param.select = this.def.select;
3254
- }
3255
- return this.Navvy.simpleWithArg(this.BXRestTasksTask.get, param, 'Не удалось получить задачу', this.BXRestMapTasksTask.get);
3256
- }
3257
- list(param = {}) {
3258
- if (!param.select) {
3259
- param.select = this.def.select;
3260
- }
3261
- return this.Navvy.PagNavTasks(this.BXRestTasksTask.list, param, 'Не удалось получить список задач', this.BXRestMapTasksTask.list);
3262
- }
3263
- /*
3264
- listArray(requestArray: RequestApiTaskListBX = {}) {
3265
- return this.list(requestArray).pipe(
3266
- map(v => this.http.mapResult(v)),
3267
- map(v => (v && v.tasks) ? v.tasks : [])
3268
- )
3269
- }
3270
-
3271
- listAll(requestArray: RequestApiTaskListBX = {}, cache = false): Observable<TaskBX[]> {
3272
- if (!requestArray.select) {
3273
- requestArray.select = this.def.select
3274
- if (cache) {
3275
- return this.storeTask$.pipe(
3276
- take(1),
3277
- mergeMap(tasks => {
3278
- if (tasks && tasks.data.http.list && requestArray.filter && requestArray.filter.ID) {
3279
- const ids = (typeof requestArray.filter.ID === 'number') ? [requestArray.filter.ID] : requestArray.filter.ID
3280
- let filter = tasks.data.http.list.filter(i => (i.id) ? ids.includes(i.id) : false)
3281
- if (filter.length === ids.length) {
3282
- return of(filter)
3283
- }
3284
- }
3285
- return this.getEndListArray(requestArray)
3286
- })
3287
- )
3288
- }
3289
- return this.getEndListArray(requestArray)
3290
- }
3291
- return this.getEndListArray(requestArray)
3292
- }
3293
-
3294
- getEndListArray(requestArray: RequestApiTaskListBX): Observable<TaskBX[]> {
3295
- return this.list(requestArray).pipe(
3296
- mergeMap((items: AnswerApiTaskBX | undefined): ObservableInput<any> | Observable<AnswerApiTaskBX[]> => {
3297
- if (items && items.result && typeof items.result.tasks === 'object') {
3298
- const items$ = of(items.result.tasks)
3299
- if (items.next) {
3300
- this.nowLoad$.next({
3301
- total: (items.total) ? items.total : 0,
3302
- next: items.next
3303
- })
3304
- requestArray.start = items.next
3305
- return this.getEndListArray(requestArray).pipe(
3306
- map(vEnd => {
3307
- if (vEnd && items.result.tasks) {
3308
- return [...items.result.tasks, ...vEnd]
3309
- }
3310
- return (items.result.tasks) ? items.result.tasks : []
3311
- }))
3312
- }
3313
- this.nowLoad$.next({
3314
- total: 0,
3315
- next: 0
3316
- })
3317
- return items$
3318
- } else {
3319
- return of([])
3320
- }
3321
- })
3322
- )
3323
- }
3324
-
3325
- getFields() {
3326
- return this.storeTask$.pipe(
3327
- mergeMap(v => {
3328
- if (v && !v.data.fields) {
3329
- return this.http.post<iHttpAnswerBX<{ fields: iGetFieldsDescription }>>(this.url.getFields).pipe(
3330
- tap(v => {
3331
- if (v && v.result) {
3332
- this.store.dispatch(saveFields(v.result))
3333
- }
3334
- }),
3335
- map(v => {
3336
- if (v && v.result && v.result.fields) {
3337
- return {result: v.result.fields}
3338
- }
3339
-
3340
- return undefined
3341
- })
3342
- )
3343
- }
3344
- if (v.data.fields) {
3345
- return of({result: clone<iGetFieldsDescription>(v.data.fields)})
3346
- } else {
3347
- return of(undefined)
3348
- }
3349
- })
3350
- )
3351
- }
3352
-
3353
- deleteResultFromComment(commentID: number) {
3354
- return this.http.post<iHttpAnswerBX<any>>(this.url.result.deleteFromComment, {commentId: commentID})
3355
- }
3356
-
3357
- addResultFromComment(commentID: number) {
3358
- return this.http.post<iHttpAnswerBX<iTaskResultHttp>>(this.url.result.addFromComment, {commentId: commentID})
3359
- .pipe(
3360
- map(v => {
3361
- if (v && v.result) {
3362
- this.taskResultMap.iTaskResultHttpToiTaskResult(v.result)
3363
- }
3364
- return undefined
3365
- }))
3366
- }
3367
-
3368
- getResulList(taskId: number): Observable<iTaskResult[] | undefined> {
3369
- return this.http.post<iHttpAnswerBX<iTaskResultHttp[]>>(this.url.result.list, {taskId: taskId})
3370
- .pipe(
3371
- map(v => {
3372
- if (v && v.result) {
3373
- return v.result.map(i => this.taskResultMap.iTaskResultHttpToiTaskResult(i))
3374
- }
3375
- return undefined
3376
- }))
3377
- }
3378
-
3379
- getPlannerList() {
3380
- return this.http.post<iHttpAnswerBX<(string | number)[]>>(this.url.planner.getlist)
3381
- }
3382
- */
3383
- getaccess(param) {
3384
- return this.Navvy.simpleWithArg(this.BXRestTasksTask.getaccess, param, 'Не удалось получить права на указанных пользователей', this.BXRestMapTasksTask.getaccess);
3385
- }
3386
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasksTask, deps: [{ token: BXRestTasksTask }, { token: BXRestMapTasksTask }], target: i0.ɵɵFactoryTarget.Injectable }); }
3387
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasksTask, providedIn: 'root' }); }
3388
- }
3389
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasksTask, decorators: [{
3390
- type: Injectable,
3391
- args: [{
3392
- providedIn: 'root'
3393
- }]
3394
- }], ctorParameters: function () { return [{ type: BXRestTasksTask }, { type: BXRestMapTasksTask }]; } });
3395
-
3396
- class BXRestNavvyTasks {
3397
- constructor(task) {
3398
- this.task = task;
3399
- }
3400
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasks, deps: [{ token: BXRestNavvyTasksTask }], target: i0.ɵɵFactoryTarget.Injectable }); }
3401
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasks, providedIn: 'root' }); }
3402
- }
3403
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasks, decorators: [{
3404
- type: Injectable,
3405
- args: [{
3406
- providedIn: 'root'
3407
- }]
3408
- }], ctorParameters: function () { return [{ type: BXRestNavvyTasksTask }]; } });
3409
-
3410
- class BXRestMapTaskElapseditem extends BaseMapServices {
3411
- update(p) {
3412
- return (p == null);
3413
- }
3414
- getList(v) {
3415
- return (v) ? v.map(i => this.ElapsedItemHttpToElapsedItem(i)) : undefined;
3416
- }
3417
- ElapsedItemHttpToElapsedItem(item) {
3418
- return Object.assign(item, {
3419
- ID: this.toNum(item.ID),
3420
- MINUTES: this.toNum(item.MINUTES),
3421
- SECONDS: this.toNum(item.SECONDS),
3422
- TASK_ID: this.toNum(item.TASK_ID),
3423
- USER_ID: this.toNum(item.USER_ID),
3424
- SOURCE: this.toNum(item.SOURCE),
3425
- CREATED_DATE: this.toDate(item.CREATED_DATE),
3426
- DATE_START: this.toDate(item.DATE_START),
3427
- DATE_STOP: this.toDate(item.DATE_STOP),
3428
- });
3429
- }
3430
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskElapseditem, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
3431
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskElapseditem, providedIn: 'root' }); }
3432
- }
3433
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskElapseditem, decorators: [{
3434
- type: Injectable,
3435
- args: [{
3436
- providedIn: 'root'
3437
- }]
3438
- }] });
3439
-
3440
- class BXRestNavvyElapseditem {
3441
- constructor(BXRestElapseditem, BXRestNavvyUser, BXRestNavvyTasks, BXRestMapElapseditem, http) {
3442
- this.BXRestElapseditem = BXRestElapseditem;
3443
- this.BXRestNavvyUser = BXRestNavvyUser;
3444
- this.BXRestNavvyTasks = BXRestNavvyTasks;
3445
- this.BXRestMapElapseditem = BXRestMapElapseditem;
3446
- this.http = http;
3447
- this.Navvy = new Navvy(this.BXRestElapseditem, this.BXRestMapElapseditem);
3448
- this.operation = new BXRestNavvyOperationElapseditem(this.http, this, this.BXRestMapElapseditem);
3449
- }
3450
- /*
3451
- call(methodName: string, ...args: any[]){
3452
- if (typeof this[methodName] === 'function') {
3453
- return this[methodName](...args);
3454
- }
3455
- return this[methodName](...args);
3456
- }
3457
- */
3458
- getList(param = {}) {
3459
- if (param) {
3460
- if (!param.TASKID && !param.SELECT) {
3461
- param.SELECT = ['*'];
3462
- }
3463
- if (!param.TASKID && !param.PARAMS) {
3464
- param.PARAMS = {
3465
- NAV_PARAMS: {
3466
- nPageSize: 50,
3467
- iNumPage: 1
3468
- }
3469
- };
3470
- }
3471
- }
3472
- return this.Navvy.alterPagNav(this.BXRestElapseditem.getList, param, 'Не удалось получить список затраченного на задачу(-и) времени', this.BXRestMapElapseditem.getList);
3220
+ return this.Navvy.alterPagNav(this.BXRestElapseditem.getList, param, 'Не удалось получить список затраченного на задачу(-и) времени', this.BXRestMapElapseditem.getList);
3473
3221
  }
3474
3222
  add(param) {
3475
- return this.checkPermissionReadTask(param.TASKID).pipe(mergeMap(allowedReadTask => {
3223
+ return this.operation.checkPermissionReadTask(param.TASKID).pipe(mergeMap(allowedReadTask => {
3476
3224
  if (allowedReadTask) {
3477
- return this.checkPermissionAddTask(param.TASKID).pipe(mergeMap(allowed => {
3225
+ return this.operation.checkPermissionAddElapsedtimeToTask(param.TASKID).pipe(mergeMap(allowed => {
3478
3226
  if (allowed) {
3479
3227
  return this.BXRestElapseditem.add(param);
3480
3228
  }
@@ -3488,8 +3236,13 @@ class BXRestNavvyElapseditem {
3488
3236
  }
3489
3237
  }));
3490
3238
  }
3239
+ /**
3240
+ * Обновление записи рабочего времени
3241
+ *
3242
+ * @param param
3243
+ */
3491
3244
  update(param) {
3492
- return this.Navvy.simple(() => this.checkPermissionReadTask(param.TASKID).pipe(mergeMap(allowedReadTask => {
3245
+ return this.Navvy.simple(() => this.operation.checkPermissionReadTask(param.TASKID).pipe(mergeMap(allowedReadTask => {
3493
3246
  if (allowedReadTask) {
3494
3247
  return this.isAllowedModify(param.TASKID, param.ITEMID).pipe(mergeMap(allowed => {
3495
3248
  if (allowed) {
@@ -3609,69 +3362,15 @@ class BXRestNavvyElapseditem {
3609
3362
  * @param param
3610
3363
  */
3611
3364
  isActionAllowed(param) {
3612
- return this.Navvy.simple(() => this.checkPermissionReadTask(param.TASKID).pipe(mergeMap(canRead => {
3365
+ return this.Navvy.simple(() => this.operation.checkPermissionReadTask(param.TASKID).pipe(mergeMap(canRead => {
3613
3366
  if (canRead) {
3614
3367
  return this.BXRestElapseditem.isActionAllowed(param);
3615
3368
  }
3616
3369
  return throwError(() => new Error('Отсутствуют права на чтение задачи'));
3617
3370
  })));
3618
3371
  }
3619
- checkPermissionAddTask(idTask) {
3620
- let permission = Permission.get();
3621
- if (permission?.tasks?.length) {
3622
- let findTask = permission.tasks.find(i => i.id === idTask);
3623
- if (findTask?.permission) {
3624
- return of(findTask.permission['ELAPSEDTIME.ADD']);
3625
- }
3626
- return this.BXRestNavvyUser.current().result().pipe(mergeMap(self => {
3627
- if (self) {
3628
- return this.BXRestNavvyTasks.task.getaccess({
3629
- id: idTask,
3630
- users: [self.ID]
3631
- }).result().pipe(tap(v => {
3632
- if (v && v[self.ID]) {
3633
- Permission.set({
3634
- tasks: [{ id: idTask, permission: v[self.ID], elapsedItem: [] }]
3635
- });
3636
- }
3637
- }), map(v => {
3638
- return (v && v[self.ID]) ? v[self.ID]['ELAPSEDTIME.ADD'] : false;
3639
- }));
3640
- }
3641
- return of(undefined);
3642
- }));
3643
- }
3644
- return of(undefined);
3645
- }
3646
- checkPermissionReadTask(idTask) {
3647
- let permission = Permission.get();
3648
- if (permission?.tasks?.length) {
3649
- let findTask = permission.tasks.find(i => i.id === idTask);
3650
- if (findTask?.permission) {
3651
- return of(findTask.permission.ACCEPT);
3652
- }
3653
- return this.BXRestNavvyUser.current().result().pipe(mergeMap(self => {
3654
- if (self) {
3655
- return this.BXRestNavvyTasks.task.getaccess({
3656
- id: idTask,
3657
- users: [self.ID]
3658
- }).result().pipe(tap(v => {
3659
- if (v && v[self.ID]) {
3660
- Permission.set({
3661
- tasks: [{ id: idTask, permission: v[self.ID], elapsedItem: [] }]
3662
- });
3663
- }
3664
- }), map(v => {
3665
- return (v && v[self.ID]) ? v[self.ID].ACCEPT : false;
3666
- }));
3667
- }
3668
- return of(undefined);
3669
- }));
3670
- }
3671
- return of(undefined);
3672
- }
3673
3372
  del(param) {
3674
- return this.Navvy.simple(() => this.checkPermissionReadTask(param.TASKID).pipe(mergeMap(allowedReadTask => {
3373
+ return this.Navvy.simple(() => this.operation.checkPermissionReadTask(param.TASKID).pipe(mergeMap(allowedReadTask => {
3675
3374
  if (allowedReadTask) {
3676
3375
  return this.isAllowedRemove(param.TASKID, param.ITEMID).pipe(mergeMap(allowed => {
3677
3376
  if (allowed) {
@@ -3687,7 +3386,7 @@ class BXRestNavvyElapseditem {
3687
3386
  }
3688
3387
  })), 'Не удалось удалить элемент списка', v => (v === null));
3689
3388
  }
3690
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyElapseditem, deps: [{ token: BXRestTaskElapseditem }, { token: BXRestNavvyUser }, { token: BXRestNavvyTasks }, { token: BXRestMapTaskElapseditem }, { token: HttpBXServices }], target: i0.ɵɵFactoryTarget.Injectable }); }
3389
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyElapseditem, deps: [{ token: BXRestTaskElapseditem }, { token: BXRestMapTaskElapseditem }, { token: BXRestNavvyOperationElapseditem }], target: i0.ɵɵFactoryTarget.Injectable }); }
3691
3390
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyElapseditem, providedIn: 'root' }); }
3692
3391
  }
3693
3392
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyElapseditem, decorators: [{
@@ -3695,7 +3394,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImpor
3695
3394
  args: [{
3696
3395
  providedIn: 'root'
3697
3396
  }]
3698
- }], ctorParameters: function () { return [{ type: BXRestTaskElapseditem }, { type: BXRestNavvyUser }, { type: BXRestNavvyTasks }, { type: BXRestMapTaskElapseditem }, { type: HttpBXServices }]; } });
3397
+ }], ctorParameters: function () { return [{ type: BXRestTaskElapseditem }, { type: BXRestMapTaskElapseditem }, { type: BXRestNavvyOperationElapseditem }]; } });
3699
3398
 
3700
3399
  class BXRestMapTaskCommentItem extends BaseMapServices {
3701
3400
  getlist(value) {
@@ -3738,79 +3437,465 @@ class BXRestMapTaskCommentItem extends BaseMapServices {
3738
3437
  };
3739
3438
  }
3740
3439
  }
3741
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskCommentItem, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
3742
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskCommentItem, providedIn: 'root' }); }
3440
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskCommentItem, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
3441
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskCommentItem, providedIn: 'root' }); }
3442
+ }
3443
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskCommentItem, decorators: [{
3444
+ type: Injectable,
3445
+ args: [{
3446
+ providedIn: 'root'
3447
+ }]
3448
+ }] });
3449
+
3450
+ class BXRestNavvyTaskCommentItem {
3451
+ constructor(BXRestTaskCommentItem, mapTaskCommentItem, snackBar) {
3452
+ this.BXRestTaskCommentItem = BXRestTaskCommentItem;
3453
+ this.mapTaskCommentItem = mapTaskCommentItem;
3454
+ this.snackBar = snackBar;
3455
+ this.Navvy = new Navvy(this.BXRestTaskCommentItem, this.mapTaskCommentItem);
3456
+ }
3457
+ add(param) {
3458
+ return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.add, param, 'Не удалось добавить комментарий к задаче');
3459
+ }
3460
+ update(param) {
3461
+ return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.update, param, 'Не удалось обновить комментарий к задаче');
3462
+ }
3463
+ get(param) {
3464
+ return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.get, param, 'Не удалось получить комментарий к задаче', this.mapTaskCommentItem.get);
3465
+ }
3466
+ getlist(param = {
3467
+ FILTER: {},
3468
+ ORDER: {
3469
+ POST_DATE: 'asc'
3470
+ }
3471
+ }) {
3472
+ return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.getlist, param, 'Не удалось получить комментарии к задаче', this.mapTaskCommentItem.getlist);
3473
+ }
3474
+ del(param) {
3475
+ if (param.ITEMID > 0) {
3476
+ return this.get(param).result().pipe(mergeMap(v => {
3477
+ if (v) {
3478
+ return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.del, param, 'Не удалось удалить комментарий').result();
3479
+ }
3480
+ this.snackBar.warning('comment not exist');
3481
+ return of(false);
3482
+ }));
3483
+ }
3484
+ else {
3485
+ this.snackBar.warning('comment not exist');
3486
+ return of(false);
3487
+ }
3488
+ }
3489
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskCommentItem, deps: [{ token: BXRestTaskCommentItem }, { token: BXRestMapTaskCommentItem }, { token: SnackBarService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3490
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskCommentItem, providedIn: 'root' }); }
3491
+ }
3492
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskCommentItem, decorators: [{
3493
+ type: Injectable,
3494
+ args: [{
3495
+ providedIn: 'root'
3496
+ }]
3497
+ }], ctorParameters: function () { return [{ type: BXRestTaskCommentItem }, { type: BXRestMapTaskCommentItem }, { type: SnackBarService }]; } });
3498
+
3499
+ class BXRestMapTaskPlaner extends BaseMapServices {
3500
+ getList(v) {
3501
+ return (v) ? v.map(i => this.toNum(i)) : undefined;
3502
+ }
3503
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskPlaner, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
3504
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskPlaner, providedIn: 'root' }); }
3505
+ }
3506
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskPlaner, decorators: [{
3507
+ type: Injectable,
3508
+ args: [{
3509
+ providedIn: 'root'
3510
+ }]
3511
+ }] });
3512
+
3513
+ class BXRestNavvyTaskPlanner {
3514
+ constructor(BXRestTaskPlanner, BXRestMapTaskPlaner) {
3515
+ this.BXRestTaskPlanner = BXRestTaskPlanner;
3516
+ this.BXRestMapTaskPlaner = BXRestMapTaskPlaner;
3517
+ this.Navvy = new Navvy(this.BXRestTaskPlanner, this.BXRestMapTaskPlaner);
3518
+ }
3519
+ getList() {
3520
+ return this.Navvy.simple(this.BXRestTaskPlanner.getList, 'Не удалось получить текущий клан на день', this.BXRestMapTaskPlaner.getList);
3521
+ }
3522
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskPlanner, deps: [{ token: BXRestTaskPlanner }, { token: BXRestMapTaskPlaner }], target: i0.ɵɵFactoryTarget.Injectable }); }
3523
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskPlanner, providedIn: 'root' }); }
3524
+ }
3525
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskPlanner, decorators: [{
3526
+ type: Injectable,
3527
+ args: [{
3528
+ providedIn: 'root'
3529
+ }]
3530
+ }], ctorParameters: function () { return [{ type: BXRestTaskPlanner }, { type: BXRestMapTaskPlaner }]; } });
3531
+
3532
+ class BXRestNavvyTask {
3533
+ constructor(elapseditem, commentitem, planner) {
3534
+ this.elapseditem = elapseditem;
3535
+ this.commentitem = commentitem;
3536
+ this.planner = planner;
3537
+ }
3538
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTask, deps: [{ token: BXRestNavvyElapseditem }, { token: BXRestNavvyTaskCommentItem }, { token: BXRestNavvyTaskPlanner }], target: i0.ɵɵFactoryTarget.Injectable }); }
3539
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTask, providedIn: 'root' }); }
3540
+ }
3541
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTask, decorators: [{
3542
+ type: Injectable,
3543
+ args: [{
3544
+ providedIn: 'root'
3545
+ }]
3546
+ }], ctorParameters: function () { return [{ type: BXRestNavvyElapseditem }, { type: BXRestNavvyTaskCommentItem }, { type: BXRestNavvyTaskPlanner }]; } });
3547
+
3548
+ class BXRestMapTasksTask extends BaseMapServices {
3549
+ getaccess(v) {
3550
+ return (v && v.allowedActions) ? v.allowedActions : undefined;
3551
+ }
3552
+ add(item) {
3553
+ return (item) ? this.TaskBXHttpToTaskBX(item.task) : undefined;
3554
+ }
3555
+ get(item) {
3556
+ return (item && item.task) ? this.TaskBXHttpToTaskBX(item.task) : undefined;
3557
+ }
3558
+ list(item) {
3559
+ return (item && item.tasks) ? item.tasks.map(i => this.TaskBXHttpToTaskBX(i)) : undefined;
3560
+ }
3561
+ TaskBXHttpToTaskBX(item) {
3562
+ let result = {};
3563
+ if (item.id) {
3564
+ result.id = this.toNum(item.id);
3565
+ }
3566
+ if (item.parentId) {
3567
+ result.parentId = this.toNum(item.parentId);
3568
+ }
3569
+ if (item.priority) {
3570
+ result.priority = this.toNum(item.priority);
3571
+ }
3572
+ if (item.status) {
3573
+ result.status = this.toNum(item.status);
3574
+ }
3575
+ if (item.multitask) {
3576
+ result.multitask = item.multitask === 'Y';
3577
+ }
3578
+ if (item.groupId) {
3579
+ result.groupId = this.toNum(item.groupId);
3580
+ }
3581
+ if (item.stageId) {
3582
+ result.stageId = this.toNum(item.stageId);
3583
+ }
3584
+ if (item.createdBy) {
3585
+ result.createdBy = this.toNum(item.createdBy);
3586
+ }
3587
+ if (item.createdDate) {
3588
+ result.createdDate = this.toDate(item.createdDate);
3589
+ }
3590
+ if (item.responsibleId) {
3591
+ result.responsibleId = this.toNum(item.responsibleId);
3592
+ }
3593
+ if (item.changedBy) {
3594
+ result.changedBy = this.toNum(item.changedBy);
3595
+ }
3596
+ if (item.changedDate) {
3597
+ result.changedDate = this.toDate(item.changedDate);
3598
+ }
3599
+ if (item.statusChangedBy) {
3600
+ result.statusChangedBy = this.toNum(item.statusChangedBy);
3601
+ }
3602
+ if (item.statusChangedDate) {
3603
+ result.statusChangedDate = this.toDate(item.statusChangedDate);
3604
+ }
3605
+ if (item.closedBy) {
3606
+ result.closedBy = this.toNum(item.closedBy);
3607
+ }
3608
+ if (item.closedDate) {
3609
+ result.closedDate = this.toDate(item.closedDate);
3610
+ }
3611
+ if (item.dateStart) {
3612
+ result.dateStart = this.toDate(item.dateStart);
3613
+ }
3614
+ if (item.deadline) {
3615
+ result.deadline = this.toDate(item.deadline);
3616
+ }
3617
+ if (item.startDatePlan) {
3618
+ result.startDatePlan = this.toDate(item.startDatePlan);
3619
+ }
3620
+ if (item.endDatePlan) {
3621
+ result.endDatePlan = this.toDate(item.endDatePlan);
3622
+ }
3623
+ if (item.forumTopicId) {
3624
+ result.forumTopicId = this.toNum(item.forumTopicId);
3625
+ }
3626
+ if (item.forumId) {
3627
+ result.forumId = this.toNum(item.forumId);
3628
+ }
3629
+ if (item.viewedDate) {
3630
+ result.viewedDate = this.toDate(item.viewedDate);
3631
+ }
3632
+ if (item.sorting) {
3633
+ result.sorting = this.toNum(item.sorting);
3634
+ }
3635
+ if (item.durationPlan) {
3636
+ result.durationPlan = this.toNum(item.durationPlan);
3637
+ }
3638
+ if (item.descriptionInBbcode) {
3639
+ result.descriptionInBbcode = item.descriptionInBbcode === 'Y';
3640
+ }
3641
+ if (item.accomplices) {
3642
+ result.accomplices = item.accomplices.map(i => this.toNum(i));
3643
+ }
3644
+ if (item.subStatus) {
3645
+ result.subStatus = this.toNum(item.subStatus);
3646
+ }
3647
+ if (item.creator) {
3648
+ result.creator = Object.assign(item.creator, { id: this.toNum(item.creator.id) });
3649
+ }
3650
+ if (item.responsible) {
3651
+ result.responsible = Object.assign(item.responsible, { id: this.toNum(item.responsible.id) });
3652
+ }
3653
+ if (item.accomplicesData) {
3654
+ result.accomplicesData =
3655
+ Object.values(item.accomplicesData).map(i => Object.assign(i, { id: this.toNum(i.id) }));
3656
+ }
3657
+ if (item.allowTimeTracking) {
3658
+ result.allowTimeTracking = item.allowTimeTracking === 'Y';
3659
+ }
3660
+ return Object.assign(item, result);
3661
+ }
3662
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTasksTask, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
3663
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTasksTask, providedIn: 'root' }); }
3743
3664
  }
3744
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTaskCommentItem, decorators: [{
3665
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestMapTasksTask, decorators: [{
3745
3666
  type: Injectable,
3746
3667
  args: [{
3747
3668
  providedIn: 'root'
3748
3669
  }]
3749
3670
  }] });
3750
3671
 
3751
- class BXRestNavvyTaskCommentItem {
3752
- constructor(BXRestTaskCommentItem, mapTaskCommentItem, snackBar) {
3753
- this.BXRestTaskCommentItem = BXRestTaskCommentItem;
3754
- this.mapTaskCommentItem = mapTaskCommentItem;
3755
- this.snackBar = snackBar;
3756
- this.Navvy = new Navvy(this.BXRestTaskCommentItem, this.mapTaskCommentItem);
3672
+ // export interface TimeProcess {
3673
+ // total: number,
3674
+ // next: number
3675
+ // }
3676
+ class BXRestNavvyTasksTask {
3677
+ constructor(BXRestTasksTask,
3678
+ // private snackBar: SnackBarService,
3679
+ // private store: Store<{ tasks: IStoreTask }>,
3680
+ BXRestMapTasksTask) {
3681
+ this.BXRestTasksTask = BXRestTasksTask;
3682
+ this.BXRestMapTasksTask = BXRestMapTasksTask;
3683
+ // pageSize = 50
3684
+ // nowLoad$ = new ReplaySubject<TimeProcess>(1)
3685
+ this.def = {
3686
+ select: ['ID', 'PARENT_ID', 'TITLE', 'DESCRIPTION', 'MARK', 'PRIORITY', 'STATUS', 'MULTITASK',
3687
+ 'GROUP_ID', 'STAGE_ID', 'CREATED_BY', 'CREATED_DATE', 'RESPONSIBLE_ID', 'ACCOMPLICES', 'AUDITORS',
3688
+ 'CHANGED_BY', 'CHANGED_DATE', 'STATUS_CHANGED_DATE', 'CLOSED_BY', 'CLOSED_DATE', 'DATE_START', 'VIEWED_DATE',
3689
+ 'DEADLINE', 'START_DATE_PLAN', 'END_DATE_PLAN', 'FORKED_BY_TEMPLATE_ID', 'TIME_ESTIMATE', 'TIME_SPENT_IN_LOGS',
3690
+ 'TAGS', 'ALLOW_TIME_TRACKING'
3691
+ ]
3692
+ };
3693
+ this.Navvy = new Navvy(this.BXRestTasksTask, this.BXRestMapTasksTask);
3694
+ // this.storeTask$ = this.store.select('tasks')
3695
+ // this.nowLoad$.next({
3696
+ // total: 0,
3697
+ // next: 0
3698
+ // })
3757
3699
  }
3758
3700
  add(param) {
3759
- return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.add, param, 'Не удалось добавить комментарий к задаче');
3701
+ return this.Navvy.simpleWithArg(this.BXRestTasksTask.add, param, 'Не удалось добавить задачу', this.BXRestMapTasksTask.add);
3702
+ // return this.http.post<{ task: TaskBXHttp }>(this.url.add, {fields: param}).pipe(
3703
+ // map(v => {
3704
+ // if (v && v.result && v.result.task) {
3705
+ // return Object.assign(
3706
+ // v,
3707
+ // {
3708
+ // result: this.taskBXMap.TaskBXHttpToTaskBX(v.result.task)
3709
+ // })
3710
+ // }
3711
+ // return undefined
3712
+ // }
3713
+ // ))
3760
3714
  }
3761
- update(param) {
3762
- return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.update, param, 'Не удалось обновить комментарий к задаче');
3715
+ /*
3716
+ update(taskId: number, updateFields: iBXRestTaskFieldsName[], task: iBXRestTask) {
3717
+ let sendTask: Record<string, any> = {}
3718
+ let taskTS: Record<string, any> = task
3719
+ if (updateFields.length) {
3720
+ for (let updateField of updateFields) {
3721
+ if (taskTS[camelCase(updateField)]) {
3722
+ sendTask[updateField] = taskTS[camelCase(updateField)]
3723
+ }
3724
+ }
3725
+ if (Object.values(sendTask).length) {
3726
+ return this.http.post(
3727
+ this.url.update,
3728
+ {taskId: taskId, fields: sendTask},
3729
+ 'error to update task')
3730
+ } else {
3731
+ this.snackBar.error('not valid send data task')
3732
+ console.error('not valid send data task', sendTask, task)
3733
+ return of(undefined)
3734
+ }
3735
+ }
3736
+
3737
+ this.snackBar.warning('not have field for update')
3738
+ return of(undefined)
3763
3739
  }
3740
+ */
3764
3741
  get(param) {
3765
- return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.get, param, 'Не удалось получить комментарий к задаче', this.mapTaskCommentItem.get);
3742
+ if (!param.select) {
3743
+ param.select = this.def.select;
3744
+ }
3745
+ return this.Navvy.simpleWithArg(this.BXRestTasksTask.get, param, 'Не удалось получить задачу', this.BXRestMapTasksTask.get);
3766
3746
  }
3767
- getlist(param = {
3768
- FILTER: {},
3769
- ORDER: {
3770
- POST_DATE: 'asc'
3747
+ list(param = {}) {
3748
+ if (!param.select) {
3749
+ param.select = this.def.select;
3771
3750
  }
3772
- }) {
3773
- return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.getlist, param, 'Не удалось получить комментарии к задаче', this.mapTaskCommentItem.getlist);
3751
+ return this.Navvy.PagNavTasks(this.BXRestTasksTask.list, param, 'Не удалось получить список задач', this.BXRestMapTasksTask.list);
3774
3752
  }
3775
- del(param) {
3776
- if (param.ITEMID > 0) {
3777
- return this.get(param).result().pipe(mergeMap(v => {
3778
- if (v) {
3779
- return this.Navvy.simpleWithArg(this.BXRestTaskCommentItem.del, param, 'Не удалось удалить комментарий').result();
3753
+ /*
3754
+ listArray(requestArray: RequestApiTaskListBX = {}) {
3755
+ return this.list(requestArray).pipe(
3756
+ map(v => this.http.mapResult(v)),
3757
+ map(v => (v && v.tasks) ? v.tasks : [])
3758
+ )
3759
+ }
3760
+
3761
+ listAll(requestArray: RequestApiTaskListBX = {}, cache = false): Observable<TaskBX[]> {
3762
+ if (!requestArray.select) {
3763
+ requestArray.select = this.def.select
3764
+ if (cache) {
3765
+ return this.storeTask$.pipe(
3766
+ take(1),
3767
+ mergeMap(tasks => {
3768
+ if (tasks && tasks.data.http.list && requestArray.filter && requestArray.filter.ID) {
3769
+ const ids = (typeof requestArray.filter.ID === 'number') ? [requestArray.filter.ID] : requestArray.filter.ID
3770
+ let filter = tasks.data.http.list.filter(i => (i.id) ? ids.includes(i.id) : false)
3771
+ if (filter.length === ids.length) {
3772
+ return of(filter)
3780
3773
  }
3781
- this.snackBar.warning('comment not exist');
3782
- return of(false);
3783
- }));
3784
- }
3785
- else {
3786
- this.snackBar.warning('comment not exist');
3787
- return of(false);
3774
+ }
3775
+ return this.getEndListArray(requestArray)
3776
+ })
3777
+ )
3788
3778
  }
3779
+ return this.getEndListArray(requestArray)
3780
+ }
3781
+ return this.getEndListArray(requestArray)
3789
3782
  }
3790
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskCommentItem, deps: [{ token: BXRestTaskCommentItem }, { token: BXRestMapTaskCommentItem }, { token: SnackBarService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3791
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskCommentItem, providedIn: 'root' }); }
3783
+
3784
+ getEndListArray(requestArray: RequestApiTaskListBX): Observable<TaskBX[]> {
3785
+ return this.list(requestArray).pipe(
3786
+ mergeMap((items: AnswerApiTaskBX | undefined): ObservableInput<any> | Observable<AnswerApiTaskBX[]> => {
3787
+ if (items && items.result && typeof items.result.tasks === 'object') {
3788
+ const items$ = of(items.result.tasks)
3789
+ if (items.next) {
3790
+ this.nowLoad$.next({
3791
+ total: (items.total) ? items.total : 0,
3792
+ next: items.next
3793
+ })
3794
+ requestArray.start = items.next
3795
+ return this.getEndListArray(requestArray).pipe(
3796
+ map(vEnd => {
3797
+ if (vEnd && items.result.tasks) {
3798
+ return [...items.result.tasks, ...vEnd]
3799
+ }
3800
+ return (items.result.tasks) ? items.result.tasks : []
3801
+ }))
3802
+ }
3803
+ this.nowLoad$.next({
3804
+ total: 0,
3805
+ next: 0
3806
+ })
3807
+ return items$
3808
+ } else {
3809
+ return of([])
3810
+ }
3811
+ })
3812
+ )
3813
+ }
3814
+
3815
+ getFields() {
3816
+ return this.storeTask$.pipe(
3817
+ mergeMap(v => {
3818
+ if (v && !v.data.fields) {
3819
+ return this.http.post<iHttpAnswerBX<{ fields: iGetFieldsDescription }>>(this.url.getFields).pipe(
3820
+ tap(v => {
3821
+ if (v && v.result) {
3822
+ this.store.dispatch(saveFields(v.result))
3823
+ }
3824
+ }),
3825
+ map(v => {
3826
+ if (v && v.result && v.result.fields) {
3827
+ return {result: v.result.fields}
3828
+ }
3829
+
3830
+ return undefined
3831
+ })
3832
+ )
3833
+ }
3834
+ if (v.data.fields) {
3835
+ return of({result: clone<iGetFieldsDescription>(v.data.fields)})
3836
+ } else {
3837
+ return of(undefined)
3838
+ }
3839
+ })
3840
+ )
3841
+ }
3842
+
3843
+ deleteResultFromComment(commentID: number) {
3844
+ return this.http.post<iHttpAnswerBX<any>>(this.url.result.deleteFromComment, {commentId: commentID})
3845
+ }
3846
+
3847
+ addResultFromComment(commentID: number) {
3848
+ return this.http.post<iHttpAnswerBX<iTaskResultHttp>>(this.url.result.addFromComment, {commentId: commentID})
3849
+ .pipe(
3850
+ map(v => {
3851
+ if (v && v.result) {
3852
+ this.taskResultMap.iTaskResultHttpToiTaskResult(v.result)
3853
+ }
3854
+ return undefined
3855
+ }))
3856
+ }
3857
+
3858
+ getResulList(taskId: number): Observable<iTaskResult[] | undefined> {
3859
+ return this.http.post<iHttpAnswerBX<iTaskResultHttp[]>>(this.url.result.list, {taskId: taskId})
3860
+ .pipe(
3861
+ map(v => {
3862
+ if (v && v.result) {
3863
+ return v.result.map(i => this.taskResultMap.iTaskResultHttpToiTaskResult(i))
3864
+ }
3865
+ return undefined
3866
+ }))
3867
+ }
3868
+
3869
+ getPlannerList() {
3870
+ return this.http.post<iHttpAnswerBX<(string | number)[]>>(this.url.planner.getlist)
3871
+ }
3872
+ */
3873
+ getaccess(param) {
3874
+ return this.Navvy.simpleWithArg(this.BXRestTasksTask.getaccess, param, 'Не удалось получить права на указанных пользователей', this.BXRestMapTasksTask.getaccess);
3875
+ }
3876
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasksTask, deps: [{ token: BXRestTasksTask }, { token: BXRestMapTasksTask }], target: i0.ɵɵFactoryTarget.Injectable }); }
3877
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasksTask, providedIn: 'root' }); }
3792
3878
  }
3793
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTaskCommentItem, decorators: [{
3879
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasksTask, decorators: [{
3794
3880
  type: Injectable,
3795
3881
  args: [{
3796
3882
  providedIn: 'root'
3797
3883
  }]
3798
- }], ctorParameters: function () { return [{ type: BXRestTaskCommentItem }, { type: BXRestMapTaskCommentItem }, { type: SnackBarService }]; } });
3884
+ }], ctorParameters: function () { return [{ type: BXRestTasksTask }, { type: BXRestMapTasksTask }]; } });
3799
3885
 
3800
- class BXRestNavvyTask {
3801
- constructor(elapseditem, commentitem) {
3802
- this.elapseditem = elapseditem;
3803
- this.commentitem = commentitem;
3886
+ class BXRestNavvyTasks {
3887
+ constructor(task) {
3888
+ this.task = task;
3804
3889
  }
3805
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTask, deps: [{ token: BXRestNavvyElapseditem }, { token: BXRestNavvyTaskCommentItem }], target: i0.ɵɵFactoryTarget.Injectable }); }
3806
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTask, providedIn: 'root' }); }
3890
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasks, deps: [{ token: BXRestNavvyTasksTask }], target: i0.ɵɵFactoryTarget.Injectable }); }
3891
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasks, providedIn: 'root' }); }
3807
3892
  }
3808
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTask, decorators: [{
3893
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.6", ngImport: i0, type: BXRestNavvyTasks, decorators: [{
3809
3894
  type: Injectable,
3810
3895
  args: [{
3811
3896
  providedIn: 'root'
3812
3897
  }]
3813
- }], ctorParameters: function () { return [{ type: BXRestNavvyElapseditem }, { type: BXRestNavvyTaskCommentItem }]; } });
3898
+ }], ctorParameters: function () { return [{ type: BXRestNavvyTasksTask }]; } });
3814
3899
 
3815
3900
  class BXRestMapDiskBase extends BaseMapServices {
3816
3901
  separationFoldersAndFiles(arr) {