@alfresco/adf-process-services 9.2.0-37898766965 → 9.2.0-37910004176

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.
@@ -111,6 +111,12 @@
111
111
  "FILTERS": {
112
112
  "MESSAGES": {
113
113
  "NONE": "No task filter selected"
114
+ },
115
+ "DEFAULT": {
116
+ "MY_TASKS": "My Tasks",
117
+ "OVERDUE_TASKS": "Overdue Tasks",
118
+ "UNASSIGNED_TASKS": "Unassigned Tasks",
119
+ "COMPLETED_TASKS": "Completed Tasks"
114
120
  }
115
121
  },
116
122
  "START_TASK": {
@@ -182,6 +188,11 @@
182
188
  "FILTERS": {
183
189
  "MESSAGES": {
184
190
  "NONE": "No process instance filter selected."
191
+ },
192
+ "DEFAULT": {
193
+ "RUNNING": "Running",
194
+ "COMPLETED": "Completed",
195
+ "ALL": "All"
185
196
  }
186
197
  },
187
198
  "PROPERTIES": {
@@ -4,7 +4,7 @@ import { inject, Injectable, EventEmitter, Output, Input, ContentChild, Componen
4
4
  import { LazyApi, TasksApi, ProcessDefinitionsApi, ProcessInstancesApi, ProcessInstanceVariablesApi, UserFiltersApi, RuntimeAppDefinitionsApi, TaskQueryRepresentation, ResultListDataRepresentationTaskRepresentation, ModelsApi, TaskActionsApi, ChecklistsApi, UsersApi, ActivitiGroupsApi, UserProfileApi, CustomModelApi, FormModelsApi, TaskFormsApi, FormSaveRepresentation, ActivitiContentApi, AlfrescoApi, ContentApi, IntegrationAlfrescoOnPremiseApi, TaskRepresentation, UserTaskFilterRepresentation, ActivitiCommentsApi } from '@alfresco/js-api';
5
5
  import { AlfrescoApiService, NodesApiService, AlfrescoViewerComponent, ContentNodeSelectorPanelComponent, DocumentListService, SitesService, SearchService, ContentService, ContentNodeDialogService, AlfrescoIconComponent, UploadService } from '@alfresco/adf-content-services';
6
6
  import { from, BehaviorSubject, Observable, forkJoin, of, throwError, merge, Subject, zip, EMPTY } from 'rxjs';
7
- import { map, finalize, filter, flatMap, catchError, tap, switchMap, mergeMap, debounceTime, distinctUntilChanged, share, defaultIfEmpty } from 'rxjs/operators';
7
+ import { map, finalize, filter, switchMap, flatMap, catchError, tap, mergeMap, debounceTime, distinctUntilChanged, share, defaultIfEmpty } from 'rxjs/operators';
8
8
  import * as i1 from '@angular/common';
9
9
  import { DatePipe, CommonModule, Location } from '@angular/common';
10
10
  import * as i2 from '@angular/material/progress-spinner';
@@ -703,7 +703,7 @@ class ProcessFilterService {
703
703
  */
704
704
  getRunningFilterInstance(appId, index) {
705
705
  return {
706
- name: 'Running',
706
+ name: 'ADF_PROCESS_LIST.FILTERS.DEFAULT.RUNNING',
707
707
  appId,
708
708
  recent: true,
709
709
  icon: 'glyphicon-random',
@@ -720,6 +720,16 @@ class ProcessFilterService {
720
720
  addProcessFilter(filter) {
721
721
  return from(this.userFiltersApi.createUserProcessInstanceFilter(filter));
722
722
  }
723
+ /**
724
+ * Updates a process filter.
725
+ *
726
+ * @param filterId existing filter id
727
+ * @param updatedFilter updated filter body
728
+ * @returns The updated filter
729
+ */
730
+ updateProcessFilter(filterId, updatedFilter) {
731
+ return from(this.userFiltersApi.updateUserProcessInstanceFilter(filterId, updatedFilter));
732
+ }
723
733
  /**
724
734
  * Calls `getUserProcessInstanceFilters` from the Alfresco JS API.
725
735
  *
@@ -736,7 +746,7 @@ class ProcessFilterService {
736
746
  }
737
747
  getCompletedFilterInstance(appId, index) {
738
748
  return {
739
- name: 'Completed',
749
+ name: 'ADF_PROCESS_LIST.FILTERS.DEFAULT.COMPLETED',
740
750
  appId,
741
751
  recent: false,
742
752
  icon: 'glyphicon-ok-sign',
@@ -746,7 +756,7 @@ class ProcessFilterService {
746
756
  }
747
757
  getAllFilterInstance(appId, index) {
748
758
  return {
749
- name: 'All',
759
+ name: 'ADF_PROCESS_LIST.FILTERS.DEFAULT.ALL',
750
760
  appId,
751
761
  recent: true,
752
762
  icon: 'glyphicon-th',
@@ -989,6 +999,11 @@ class IconModel {
989
999
  * See the License for the specific language governing permissions and
990
1000
  * limitations under the License.
991
1001
  */
1002
+ const LEGACY_DEFAULT_PROCESS_FILTER_TRANSLATION_KEYS = {
1003
+ Running: 'ADF_PROCESS_LIST.FILTERS.DEFAULT.RUNNING',
1004
+ Completed: 'ADF_PROCESS_LIST.FILTERS.DEFAULT.COMPLETED',
1005
+ All: 'ADF_PROCESS_LIST.FILTERS.DEFAULT.ALL'
1006
+ };
992
1007
  class ProcessFiltersComponent {
993
1008
  constructor() {
994
1009
  this.processFilterService = inject(ProcessFilterService);
@@ -1043,25 +1058,18 @@ class ProcessFiltersComponent {
1043
1058
  * @param appId - optional
1044
1059
  */
1045
1060
  getFiltersByAppId(appId) {
1046
- this.processFilterService.getProcessFilters(appId).subscribe((res) => {
1061
+ this.processFilterService
1062
+ .getProcessFilters(appId)
1063
+ .pipe(switchMap((res) => {
1047
1064
  if (res.length === 0 && this.isFilterListEmpty()) {
1048
- this.processFilterService.createDefaultFilters(appId).subscribe((resDefault) => {
1049
- this.resetFilter();
1050
- this.filters = resDefault;
1051
- this.selectProcessFilter(this.filterParam);
1052
- this.success.emit(resDefault);
1053
- }, (errDefault) => {
1054
- this.error.emit(errDefault);
1055
- });
1056
- }
1057
- else {
1058
- this.resetFilter();
1059
- this.filters = res;
1060
- this.selectProcessFilter(this.filterParam);
1061
- this.success.emit(res);
1065
+ return this.processFilterService.createDefaultFilters(appId);
1062
1066
  }
1063
- }, (err) => {
1064
- this.error.emit(err);
1067
+ const migratedFilters = this.migrateDefaultFilters(res);
1068
+ return migratedFilters.length > 0 ? forkJoin(migratedFilters).pipe(map(() => res)) : of(res);
1069
+ }), takeUntilDestroyed(this.destroyRef))
1070
+ .subscribe({
1071
+ next: (filters) => this.setProcessFilters(filters),
1072
+ error: (err) => this.error.emit(err)
1065
1073
  });
1066
1074
  }
1067
1075
  /**
@@ -1143,6 +1151,33 @@ class ProcessFiltersComponent {
1143
1151
  this.filters = [];
1144
1152
  this.currentFilter = undefined;
1145
1153
  }
1154
+ /**
1155
+ * Reset the current selection and display the given filters, selecting the one matching filterParam.
1156
+ *
1157
+ * @param filters - list of filters to display
1158
+ */
1159
+ setProcessFilters(filters) {
1160
+ this.resetFilter();
1161
+ this.filters = filters;
1162
+ this.selectProcessFilter(this.filterParam);
1163
+ this.success.emit(filters);
1164
+ }
1165
+ /**
1166
+ * Rename default filters still stored with their legacy plain-string name to the matching translation key.
1167
+ *
1168
+ * @param filters - list of filters to migrate
1169
+ * @returns list of observables for each migrated filter
1170
+ */
1171
+ migrateDefaultFilters(filters) {
1172
+ const migratedFilters = [];
1173
+ filters.forEach((filterToMigrate) => {
1174
+ const translationKey = LEGACY_DEFAULT_PROCESS_FILTER_TRANSLATION_KEYS[filterToMigrate.name];
1175
+ if (translationKey) {
1176
+ migratedFilters.push(this.processFilterService.updateProcessFilter(filterToMigrate.id, { ...filterToMigrate, name: translationKey }));
1177
+ }
1178
+ });
1179
+ return migratedFilters;
1180
+ }
1146
1181
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ProcessFiltersComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1147
1182
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.22", type: ProcessFiltersComponent, isStandalone: true, selector: "adf-process-instance-filters", inputs: { filterParam: "filterParam", appId: "appId", appName: "appName", showIcon: "showIcon" }, outputs: { filterClicked: "filterClicked", success: "success", error: "error", filterSelected: "filterSelected" }, usesOnChanges: true, ngImport: i0, template: "<div *ngFor=\"let filter of filters\" class=\"adf-filters__entry\" [class.adf-active]=\"isActiveRoute(filter)\">\n <button\n (click)=\"selectFilter(filter)\"\n [attr.aria-label]=\"filter.name | translate\"\n [id]=\"filter.id\"\n [attr.data-automation-id]=\"filter.name + '_filter'\"\n mat-button\n class=\"adf-filter-action-button adf-full-width\"\n >\n <mat-icon data-automation-id=\"adf-filter-icon\" *ngIf=\"showIcon\" aria-hidden=\"true\">{{ getFilterIcon(filter.icon) }}</mat-icon>\n <span data-automation-id=\"adf-filter-label\" class=\"adf-filter-action-button__label\">{{ filter.name | translate }}</span>\n </button>\n</div>\n", styles: ["adf-process-instance-filters .adf-filters__entry:has(.adf-filter-action-button){padding:0;width:100%}adf-process-instance-filters .adf-filters__entry:has(.adf-filter-action-button) .adf-full-width{display:flex;width:100%}adf-process-instance-filters .adf-filters__entry:has(.adf-filter-action-button) .adf-filter-action-button{align-items:center;height:32px;justify-content:flex-start}adf-process-instance-filters .adf-filters__entry:has(.adf-filter-action-button) .adf-filter-action-button .adf-filter-action-button__label{padding-left:20px;margin:0 8px;font:var(--mat-sys-body-large)}adf-process-instance-filters .adf-filters__entry:has(.adf-filter-action-button).adf-active .adf-filter-action-button__label{color:var(--mat-sys-primary)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i3.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], encapsulation: i0.ViewEncapsulation.None }); }
1148
1183
  }
@@ -6750,7 +6785,7 @@ class TaskFilterService {
6750
6785
  */
6751
6786
  getMyTasksFilterInstance(appId, index) {
6752
6787
  return new UserTaskFilterRepresentation({
6753
- name: 'My Tasks',
6788
+ name: 'ADF_TASK_LIST.FILTERS.DEFAULT.MY_TASKS',
6754
6789
  appId,
6755
6790
  recent: false,
6756
6791
  icon: 'glyphicon-inbox',
@@ -6772,7 +6807,7 @@ class TaskFilterService {
6772
6807
  */
6773
6808
  getOverdueTasksFilterInstance(appId, index) {
6774
6809
  return new UserTaskFilterRepresentation({
6775
- name: 'Overdue Tasks',
6810
+ name: 'ADF_TASK_LIST.FILTERS.DEFAULT.OVERDUE_TASKS',
6776
6811
  appId,
6777
6812
  recent: false,
6778
6813
  icon: 'glyphicon-align-left',
@@ -6789,7 +6824,7 @@ class TaskFilterService {
6789
6824
  */
6790
6825
  getUnassignedTasksFilterInstance(appId, index) {
6791
6826
  return new UserTaskFilterRepresentation({
6792
- name: 'Unassigned Tasks',
6827
+ name: 'ADF_TASK_LIST.FILTERS.DEFAULT.UNASSIGNED_TASKS',
6793
6828
  appId,
6794
6829
  recent: false,
6795
6830
  icon: 'glyphicon-record',
@@ -6806,7 +6841,7 @@ class TaskFilterService {
6806
6841
  */
6807
6842
  getCompletedTasksFilterInstance(appId, index) {
6808
6843
  return new UserTaskFilterRepresentation({
6809
- name: 'Completed Tasks',
6844
+ name: 'ADF_TASK_LIST.FILTERS.DEFAULT.COMPLETED_TASKS',
6810
6845
  appId,
6811
6846
  recent: true,
6812
6847
  icon: 'glyphicon-ok-sign',
@@ -6843,6 +6878,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImpo
6843
6878
  * See the License for the specific language governing permissions and
6844
6879
  * limitations under the License.
6845
6880
  */
6881
+ const LEGACY_DEFAULT_TASK_FILTER_TRANSLATION_KEYS = {
6882
+ 'My Tasks': 'ADF_TASK_LIST.FILTERS.DEFAULT.MY_TASKS',
6883
+ 'Overdue Tasks': 'ADF_TASK_LIST.FILTERS.DEFAULT.OVERDUE_TASKS',
6884
+ 'Unassigned Tasks': 'ADF_TASK_LIST.FILTERS.DEFAULT.UNASSIGNED_TASKS',
6885
+ 'Completed Tasks': 'ADF_TASK_LIST.FILTERS.DEFAULT.COMPLETED_TASKS'
6886
+ };
6846
6887
  class TaskFiltersComponent {
6847
6888
  constructor() {
6848
6889
  this.taskFilterService = inject(TaskFilterService);
@@ -6897,23 +6938,18 @@ class TaskFiltersComponent {
6897
6938
  * @param appId - optional
6898
6939
  */
6899
6940
  getFiltersByAppId(appId) {
6900
- this.taskFilterService.getTaskListFilters(appId).subscribe((res) => {
6941
+ this.taskFilterService
6942
+ .getTaskListFilters(appId)
6943
+ .pipe(switchMap((res) => {
6901
6944
  if (res.length === 0 && this.isFilterListEmpty()) {
6902
- this.createFiltersByAppId(appId);
6945
+ return this.taskFilterService.createDefaultFilters(appId);
6903
6946
  }
6904
- else {
6905
- const migratedFilters = this.migrateObsoleteFilters(res);
6906
- if (migratedFilters.length > 0) {
6907
- forkJoin(migratedFilters).subscribe(() => {
6908
- this.setTaskFilters(res);
6909
- });
6910
- }
6911
- else {
6912
- this.setTaskFilters(res);
6913
- }
6914
- }
6915
- }, (err) => {
6916
- this.error.emit(err);
6947
+ const migratedFilters = this.migrateObsoleteFilters(res);
6948
+ return migratedFilters.length > 0 ? forkJoin(migratedFilters).pipe(map(() => res)) : of(res);
6949
+ }), takeUntilDestroyed(this.destroyRef))
6950
+ .subscribe({
6951
+ next: (filters) => this.setTaskFilters(filters),
6952
+ error: (err) => this.error.emit(err)
6917
6953
  });
6918
6954
  }
6919
6955
  /**
@@ -6928,18 +6964,6 @@ class TaskFiltersComponent {
6928
6964
  this.error.emit(err);
6929
6965
  });
6930
6966
  }
6931
- /**
6932
- * Create default filters by appId
6933
- *
6934
- * @param appId application id
6935
- */
6936
- createFiltersByAppId(appId) {
6937
- this.taskFilterService.createDefaultFilters(appId).subscribe((resDefault) => {
6938
- this.setTaskFilters(resDefault);
6939
- }, (errDefault) => {
6940
- this.error.emit(errDefault);
6941
- });
6942
- }
6943
6967
  /**
6944
6968
  * Pass the selected filter as next
6945
6969
  *
@@ -7016,7 +7040,9 @@ class TaskFiltersComponent {
7016
7040
  this.currentFilter = undefined;
7017
7041
  }
7018
7042
  /**
7019
- * Migrate "Involved" and "Queued" filters to "Overdue" and "Unassigned" filters
7043
+ * Migrate obsolete and legacy default filters:
7044
+ * - "Involved" and "Queued" filters become "Overdue" and "Unassigned" filters
7045
+ * - default filters still stored with their legacy plain-string name are renamed to the matching translation key
7020
7046
  *
7021
7047
  * @param filters - list of filters to migrate
7022
7048
  * @returns list of observables for each migrated filter
@@ -7031,8 +7057,13 @@ class TaskFiltersComponent {
7031
7057
  case 'Queued Tasks':
7032
7058
  migratedFilters.push(this.taskFilterService.updateTaskFilter(filterToMigrate.id, this.taskFilterService.getUnassignedTasksFilterInstance(this.appId)));
7033
7059
  break;
7034
- default:
7060
+ default: {
7061
+ const translationKey = LEGACY_DEFAULT_TASK_FILTER_TRANSLATION_KEYS[filterToMigrate.name];
7062
+ if (translationKey) {
7063
+ migratedFilters.push(this.taskFilterService.updateTaskFilter(filterToMigrate.id, new UserTaskFilterRepresentation({ ...filterToMigrate, name: translationKey })));
7064
+ }
7035
7065
  break;
7066
+ }
7036
7067
  }
7037
7068
  });
7038
7069
  return migratedFilters;