@acorex/platform 20.6.0-next.16 → 20.6.0-next.18

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.
@@ -1398,7 +1398,7 @@ class AXPEntityCreateViewSectionViewModel {
1398
1398
  const { interfaces, properties } = this.entity;
1399
1399
  const createProps = interfaces?.master?.create?.properties ?? [];
1400
1400
  const createPropNames = new Set(createProps.map(({ name }) => name));
1401
- const filteredProperties = properties.filter(({ groupId, schema, name }) => groupId === this.group.id && !schema.hidden && createPropNames.has(name));
1401
+ const filteredProperties = properties.filter(({ groupId, schema, name }) => groupId === this.group.id && createPropNames.has(name));
1402
1402
  return filteredProperties.map((property) => {
1403
1403
  const createProp = createProps.find(({ name }) => name === property.name);
1404
1404
  return new AXPEntityCreateViewElementViewModel(this.entity, this, property, createProp);
@@ -1418,6 +1418,9 @@ class AXPEntityCreateViewElementViewModel {
1418
1418
  this.editable = computed(() => {
1419
1419
  return !(this.property.schema.readonly ?? false);
1420
1420
  }, ...(ngDevMode ? [{ debugName: "editable" }] : []));
1421
+ this.isHidden = computed(() => {
1422
+ return this.property.schema.hidden ?? false;
1423
+ }, ...(ngDevMode ? [{ debugName: "isHidden" }] : []));
1421
1424
  this.isRequired = computed(() => {
1422
1425
  return this.property.validations?.some((c) => c.rule == 'required') || false;
1423
1426
  }, ...(ngDevMode ? [{ debugName: "isRequired" }] : []));
@@ -1463,7 +1466,7 @@ class AXPEntityMasterCreateViewModel {
1463
1466
  this.sections = computed(() => {
1464
1467
  const { interfaces, properties } = this.entityDef;
1465
1468
  const createProps = interfaces?.master?.create?.properties?.map(({ name }) => name) ?? [];
1466
- const visibleProperties = properties.filter(({ groupId, schema, name }) => groupId && !schema.hidden && createProps.includes(name));
1469
+ const visibleProperties = properties.filter(({ groupId, schema, name }) => groupId && createProps.includes(name));
1467
1470
  const sections = interfaces?.master?.create?.sections?.filter(({ id }) => visibleProperties.some(({ groupId }) => groupId === id)) ?? [];
1468
1471
  console.log({ sections, visibleProperties });
1469
1472
  return sections.map((section) => new AXPEntityCreateViewSectionViewModel(this.entityDef, section));
@@ -3248,6 +3251,8 @@ class AXPPageDetailsConverter extends AXPBaseRelatedEntityConverter {
3248
3251
  const factory = new AXPRelatedEntityConverterFactory();
3249
3252
  const tabDetailTabs = await this.buildTabDetails(factory, tabDetailEntities ?? [], context);
3250
3253
  const tabListTabs = await this.buildTabLists(factory, tabListEntities ?? [], context);
3254
+ // Build actions from single interface
3255
+ const actions = this.buildActions(entityDef, helpers.singleInterface);
3251
3256
  return {
3252
3257
  id: entityDef?.name ?? '',
3253
3258
  title: `${context.rootTitle}`,
@@ -3255,12 +3260,73 @@ class AXPPageDetailsConverter extends AXPBaseRelatedEntityConverter {
3255
3260
  icon: relatedEntity.icon || entityDef.icon,
3256
3261
  settings: this.createPageSettings(),
3257
3262
  load: this.createLoadFunction(entityDef, relatedEntity, evaluateExpressions),
3258
- execute: this.createExecuteFunction(entityDef),
3263
+ execute: this.createExecuteFunction(entityDef, actions, evaluateExpressions, context),
3264
+ actions: await this.buildEvaluatedActions(actions, evaluateExpressions),
3259
3265
  // tabs: [...tabDetailTabs, ...tabListTabs],
3260
3266
  content: [await this.createGridLayoutStructure(helpers.singleInterface, helpers, evaluateExpressions)],
3261
3267
  };
3262
3268
  }
3263
3269
  //#region ---- Utility Methods ----
3270
+ buildActions(entityDef, singleInterface) {
3271
+ const actions = singleInterface?.actions ?? [];
3272
+ return actions.map((action) => new AXPEntityCommandTriggerViewModel(entityDef, action));
3273
+ }
3274
+ async buildEvaluatedActions(actions, evaluateExpressions) {
3275
+ const evaluatedActions = [];
3276
+ for (const action of actions) {
3277
+ // Evaluate disabled condition
3278
+ let disabled = action.disabled;
3279
+ if (disabled && typeof disabled === 'string' && evaluateExpressions) {
3280
+ try {
3281
+ const result = await evaluateExpressions({ disabled: disabled });
3282
+ disabled = result.disabled;
3283
+ }
3284
+ catch {
3285
+ disabled = false;
3286
+ }
3287
+ }
3288
+ // Evaluate hidden condition
3289
+ let hidden = action.hidden;
3290
+ if (hidden && typeof hidden === 'string' && evaluateExpressions) {
3291
+ try {
3292
+ const result = await evaluateExpressions({ hidden: hidden });
3293
+ hidden = result.hidden;
3294
+ }
3295
+ catch {
3296
+ hidden = false;
3297
+ }
3298
+ }
3299
+ // Skip if hidden
3300
+ if (hidden)
3301
+ continue;
3302
+ // Evaluate options
3303
+ let options = action.options;
3304
+ if (options && evaluateExpressions) {
3305
+ try {
3306
+ options = await evaluateExpressions(options);
3307
+ }
3308
+ catch {
3309
+ // Keep original options if evaluation fails
3310
+ }
3311
+ }
3312
+ evaluatedActions.push({
3313
+ name: action.name,
3314
+ title: action.title,
3315
+ icon: action.icon,
3316
+ color: action.color,
3317
+ disabled: disabled || false,
3318
+ zone: 'header',
3319
+ priority: action.priority,
3320
+ scope: action.scope === AXPEntityCommandScope.Individual ? AXPEntityCommandScope.TypeLevel : action.scope,
3321
+ command: {
3322
+ name: action.name,
3323
+ options: options,
3324
+ metadata: action.metadata,
3325
+ },
3326
+ });
3327
+ }
3328
+ return evaluatedActions;
3329
+ }
3264
3330
  createPageSettings() {
3265
3331
  return {
3266
3332
  commands: {
@@ -3289,20 +3355,70 @@ class AXPPageDetailsConverter extends AXPBaseRelatedEntityConverter {
3289
3355
  return { success: true, data: result };
3290
3356
  };
3291
3357
  }
3292
- createExecuteFunction(entityDef) {
3358
+ createExecuteFunction(entityDef, actions, evaluateExpressions, converterContext) {
3293
3359
  return async (e, context) => {
3294
- if (e.name === 'update-entity') {
3295
- const fn = entityDef?.commands?.update?.execute;
3296
- const result = await fn(context);
3297
- return { success: true, data: result };
3360
+ try {
3361
+ if (e.name === 'update-entity') {
3362
+ const fn = entityDef?.commands?.update?.execute;
3363
+ const result = await fn(context);
3364
+ return {
3365
+ success: true,
3366
+ data: result,
3367
+ };
3368
+ }
3369
+ else {
3370
+ // Find action in single interface actions
3371
+ const action = actions.find((a) => a.name === e.name);
3372
+ if (action && converterContext.workflowService) {
3373
+ // Evaluate action options with current context
3374
+ let evaluatedOptions = action.options;
3375
+ if (evaluateExpressions && action.options) {
3376
+ try {
3377
+ evaluatedOptions = await evaluateExpressions(action.options);
3378
+ }
3379
+ catch {
3380
+ // Keep original options if evaluation fails
3381
+ }
3382
+ }
3383
+ const commandName = e.name.split('&')[0];
3384
+ if (converterContext.workflowService.exists(commandName)) {
3385
+ await converterContext.workflowService.execute(commandName, {
3386
+ entity: getEntityInfo(entityDef).source,
3387
+ data: context,
3388
+ entityInfo: {
3389
+ name: entityDef.name,
3390
+ module: entityDef.module,
3391
+ title: entityDef.title,
3392
+ parentKey: entityDef.parentKey,
3393
+ source: `${entityDef.module}.${entityDef.name}`,
3394
+ },
3395
+ options: evaluatedOptions,
3396
+ metadata: action.metadata,
3397
+ });
3398
+ return {
3399
+ success: true,
3400
+ };
3401
+ }
3402
+ if (converterContext.commandService?.exists(commandName)) {
3403
+ // check options for evaluation
3404
+ await converterContext.commandService.execute(commandName, e.options);
3405
+ }
3406
+ }
3407
+ return {
3408
+ success: false,
3409
+ message: {
3410
+ code: 'invalid_command',
3411
+ text: 'Invalid command',
3412
+ },
3413
+ };
3414
+ }
3298
3415
  }
3299
- else {
3416
+ catch (error) {
3300
3417
  return {
3301
3418
  success: false,
3302
3419
  message: {
3303
- code: 'invalid_command',
3304
- text: 'Invalid command'
3305
- }
3420
+ text: error,
3421
+ },
3306
3422
  };
3307
3423
  }
3308
3424
  };
@@ -4169,7 +4285,7 @@ class AXPMainEntityContentBuilder {
4169
4285
  disabled: disabled || false,
4170
4286
  zone: 'header',
4171
4287
  priority: action.priority,
4172
- scope: action.scope,
4288
+ scope: action.scope === AXPEntityCommandScope.Individual ? AXPEntityCommandScope.TypeLevel : action.scope,
4173
4289
  command: {
4174
4290
  name: action.name,
4175
4291
  options: options,
@@ -4362,7 +4478,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
4362
4478
  }]
4363
4479
  }], ctorParameters: () => [{ type: AXPRelatedEntityConverterFactory }, { type: AXPMainEntityContentBuilder }, { type: AXPLayoutAdapterBuilder }, { type: i4$1.AXPFilterOperatorMiddlewareService }] });
4364
4480
 
4365
- const AXPLayoutDetailsViewRouteResolver = async (route, state, entityResolver = inject(AXPEntityDefinitionRegistryService), expressionEvaluator = inject(AXPExpressionEvaluatorService), session = inject(AXPSessionService), formatService = inject(AXFormatService), workflowService = inject(AXPWorkflowService), layoutAdapterFactory = inject(AXPLayoutAdapterFactory)) => {
4481
+ const AXPLayoutDetailsViewRouteResolver = async (route, state, entityResolver = inject(AXPEntityDefinitionRegistryService), expressionEvaluator = inject(AXPExpressionEvaluatorService), session = inject(AXPSessionService), formatService = inject(AXFormatService), workflowService = inject(AXPWorkflowService), commandService = inject(AXPCommandService), layoutAdapterFactory = inject(AXPLayoutAdapterFactory)) => {
4366
4482
  const moduleName = route.parent?.paramMap.get('module');
4367
4483
  const entityName = route.paramMap.get('entity');
4368
4484
  const id = route.paramMap.get('id');
@@ -4372,6 +4488,7 @@ const AXPLayoutDetailsViewRouteResolver = async (route, state, entityResolver =
4372
4488
  session,
4373
4489
  formatService,
4374
4490
  workflowService,
4491
+ commandService,
4375
4492
  };
4376
4493
  return await layoutAdapterFactory.createDetailsViewAdapter(entityResolver, moduleName, entityName, id, dependencies);
4377
4494
  };
@@ -4467,12 +4584,12 @@ const DEFAULT_SECTION_ORDER = {
4467
4584
  */
4468
4585
  const DEFAULT_PROPERTY_ORDER = {
4469
4586
  // Basic Info section
4470
- 'basic-info.code': 1,
4471
- 'basic-info.title': 2,
4472
- 'basic-info.name': 3,
4473
- 'basic-info.description': 10,
4474
- 'basic-info.note': 11,
4475
- 'basic-info.notes': 12,
4587
+ 'basic-info.code': -10,
4588
+ 'basic-info.title': -9,
4589
+ 'basic-info.name': -8,
4590
+ 'basic-info.description': -7,
4591
+ 'basic-info.note': -6,
4592
+ 'basic-info.notes': -5,
4476
4593
  // Classification section
4477
4594
  'classification.categoryIds': 1,
4478
4595
  'classification.tags': 2,