@alfresco/aca-content 7.5.0-26580764564 → 7.5.0-26635454327

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.
@@ -1,4 +1,4 @@
1
- import { NotificationService, CardViewUpdateService, CardViewSelectItemModel, CardViewTextItemModel, CardViewBoolItemModel, CardViewComponent, EmptyContentComponent, ConfirmDialogComponent, provideTranslations } from '@alfresco/adf-core';
1
+ import { NotificationService, CardViewUpdateService, CardViewBoolItemModel, CardViewTextItemModel, CardViewSelectItemModel, CardViewComponent, EmptyContentComponent, ConfirmDialogComponent, provideTranslations } from '@alfresco/adf-core';
2
2
  import { provideExtensionConfig, provideExtensions } from '@alfresco/adf-extensions';
3
3
  import * as i0 from '@angular/core';
4
4
  import { inject, Injectable, forwardRef, Input, ViewEncapsulation, Component, DestroyRef, ElementRef, ViewChildren, HostBinding, EventEmitter, Output, ChangeDetectionStrategy, NgModule } from '@angular/core';
@@ -1092,71 +1092,76 @@ class RuleActionUiComponent {
1092
1092
  const disabledTags = !this.tagService.areTagsEnabled();
1093
1093
  const disabledCategories = !this.categoryService.areCategoriesEnabled();
1094
1094
  this.cardViewItems = (this.selectedActionDefinition?.parameterDefinitions ?? []).map((paramDef) => {
1095
- const constraintsForDropdownBox = paramDef.name === 'securityMarkId'
1096
- ? { name: paramDef.name, constraints: securityMarkOptions || [] }
1097
- : this._parameterConstraints.find((obj) => obj.name === paramDef.name);
1098
- const cardViewPropertiesModel = {
1099
- label: paramDef.displayLabel + (paramDef.mandatory ? ' *' : ''),
1100
- key: paramDef.name,
1101
- editable: true,
1102
- multivalued: paramDef.multiValued,
1103
- ...(paramDef.mandatory
1104
- ? {
1105
- validators: [
1106
- {
1107
- message: 'ACA_FOLDER_RULES.RULE_DETAILS.ERROR.REQUIRED',
1108
- isValid: (value) => !!value
1109
- }
1110
- ]
1111
- }
1112
- : {})
1113
- };
1114
- switch (paramDef.type) {
1115
- case 'd:boolean':
1116
- return new CardViewBoolItemModel({
1117
- ...cardViewPropertiesModel,
1118
- value: this.parameters[paramDef.name] ?? false
1119
- });
1120
- case 'd:noderef':
1121
- if (!constraintsForDropdownBox && !this.readOnly && paramDef.name !== 'category-value') {
1122
- return new CardViewTextItemModel({
1123
- ...cardViewPropertiesModel,
1124
- icon: 'folder',
1125
- default: '',
1126
- clickable: true,
1127
- clickCallBack: this.openSelectorDialog.bind(this, paramDef.name),
1128
- value: this.parameters[paramDef.name]
1129
- });
1130
- }
1131
- else if (paramDef.name === 'category-value' && !this.readOnly) {
1132
- return new CardViewTextItemModel({
1133
- ...cardViewPropertiesModel,
1134
- icon: 'library_add',
1135
- default: '',
1136
- clickable: true,
1137
- clickCallBack: this.openCatDialog.bind(this, paramDef.name),
1138
- value: this.parameters[paramDef.name]
1139
- });
1140
- }
1141
- // falls through
1142
- default:
1143
- if (constraintsForDropdownBox) {
1144
- return new CardViewSelectItemModel({
1145
- ...cardViewPropertiesModel,
1146
- value: this.parameters[paramDef.name] ?? '',
1147
- options$: of(constraintsForDropdownBox.constraints).pipe(map((options) => {
1148
- return options.filter((option) => !((disabledTags && this.tagsRelatedPropertiesAndAspects.includes(option.key)) ||
1149
- (disabledCategories && this.categoriesRelatedPropertiesAndAspects.includes(option.key))));
1150
- }))
1151
- });
1152
- }
1153
- return new CardViewTextItemModel({
1154
- ...cardViewPropertiesModel,
1155
- value: constraintsForDropdownBox && this.readOnly && this.paramsToFormatDisplayedValue.includes(paramDef.name)
1156
- ? (constraintsForDropdownBox.constraints.find((constraint) => constraint.key === this.parameters[paramDef.name])?.label ?? '')
1157
- : (this.parameters[paramDef.name] ?? '')
1158
- });
1159
- }
1095
+ const constraintsForDropdownBox = this.getConstraintsForParameter(paramDef, securityMarkOptions);
1096
+ const cardViewPropertiesModel = this.buildBaseCardViewModel(paramDef);
1097
+ return this.createCardViewItemByType(paramDef, cardViewPropertiesModel, constraintsForDropdownBox, disabledTags, disabledCategories);
1098
+ });
1099
+ }
1100
+ getConstraintsForParameter(paramDef, securityMarkOptions) {
1101
+ return paramDef.name === 'securityMarkId'
1102
+ ? { name: paramDef.name, constraints: securityMarkOptions || [] }
1103
+ : this._parameterConstraints.find((obj) => obj.name === paramDef.name);
1104
+ }
1105
+ buildBaseCardViewModel(paramDef) {
1106
+ return {
1107
+ label: paramDef.displayLabel + (paramDef.mandatory ? ' *' : ''),
1108
+ key: paramDef.name,
1109
+ editable: true,
1110
+ multivalued: paramDef.multiValued,
1111
+ ...(paramDef.mandatory
1112
+ ? {
1113
+ validators: [
1114
+ {
1115
+ message: 'ACA_FOLDER_RULES.RULE_DETAILS.ERROR.REQUIRED',
1116
+ isValid: (value) => !!value
1117
+ }
1118
+ ]
1119
+ }
1120
+ : {})
1121
+ };
1122
+ }
1123
+ createCardViewItemByType(paramDef, cardViewPropertiesModel, constraintsForDropdownBox, disabledTags, disabledCategories) {
1124
+ if (paramDef.type === 'd:boolean') {
1125
+ return new CardViewBoolItemModel({
1126
+ ...cardViewPropertiesModel,
1127
+ value: this.parameters[paramDef.name] ?? false
1128
+ });
1129
+ }
1130
+ if (paramDef.type === 'd:noderef' && !constraintsForDropdownBox && !this.readOnly && paramDef.name !== 'category-value') {
1131
+ return new CardViewTextItemModel({
1132
+ ...cardViewPropertiesModel,
1133
+ icon: 'folder',
1134
+ default: '',
1135
+ clickable: true,
1136
+ clickCallBack: this.openSelectorDialog.bind(this, paramDef.name),
1137
+ value: this.parameters[paramDef.name]
1138
+ });
1139
+ }
1140
+ if (paramDef.type === 'd:noderef' && paramDef.name === 'category-value' && !this.readOnly) {
1141
+ return new CardViewTextItemModel({
1142
+ ...cardViewPropertiesModel,
1143
+ icon: 'library_add',
1144
+ default: '',
1145
+ clickable: true,
1146
+ clickCallBack: this.openCatDialog.bind(this, paramDef.name),
1147
+ value: this.parameters[paramDef.name]
1148
+ });
1149
+ }
1150
+ if (constraintsForDropdownBox) {
1151
+ return new CardViewSelectItemModel({
1152
+ ...cardViewPropertiesModel,
1153
+ value: this.parameters[paramDef.name] ?? (paramDef.multiValued ? [''] : ''),
1154
+ options$: of(constraintsForDropdownBox.constraints).pipe(map((options) => options.filter((option) => !((disabledTags && this.tagsRelatedPropertiesAndAspects.includes(option.key)) ||
1155
+ (disabledCategories && this.categoriesRelatedPropertiesAndAspects.includes(option.key))))))
1156
+ });
1157
+ }
1158
+ const shouldFormatValue = constraintsForDropdownBox && this.readOnly && this.paramsToFormatDisplayedValue.includes(paramDef.name);
1159
+ const formattedValue = shouldFormatValue
1160
+ ? (constraintsForDropdownBox.constraints.find((constraint) => constraint.key === this.parameters[paramDef.name])?.label ?? '')
1161
+ : (this.parameters[paramDef.name] ?? '');
1162
+ return new CardViewTextItemModel({
1163
+ ...cardViewPropertiesModel,
1164
+ value: formattedValue
1160
1165
  });
1161
1166
  }
1162
1167
  openSelectorDialog(paramDefName) {