Skip to content

Commit

Permalink
Remove semantic explanation from table cells for plain fields (eclips…
Browse files Browse the repository at this point in the history
…e-esmf#127)

Signed-off-by: Pavel Shalamkov <[email protected]>
  • Loading branch information
pavel-s-epam authored Mar 10, 2025
1 parent 2f30c5a commit b2373ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,7 @@
* SPDX-License-Identifier: MPL-2.0
*/

import {
apply,
applyTemplates,
MergeStrategy,
mergeWith,
move,
Rule,
SchematicContext,
Tree,
url
} from '@angular-devkit/schematics';
import {apply, applyTemplates, MergeStrategy, mergeWith, move, Rule, SchematicContext, Tree, url} from '@angular-devkit/schematics';
import {strings} from '@angular-devkit/core';
import {Values} from '../../../schema';
import {getTableColumValues} from '../../../utils';
Expand All @@ -33,15 +23,15 @@ export function generateSemanticExplanation(options: Values): Rule {
applyTemplates({
classify: strings.classify,
dasherize: strings.dasherize,
options: {...options,
tableColumns: getTableColumValues(options.listAllProperties, options)
options: {
...options,
tableColumns: getTableColumValues(options.listAllProperties, options),
},
name: options.name
name: options.name,
}),
move('src/app/shared/constants')
move('src/app/shared/constants'),
]),
options.overwrite ? MergeStrategy.Overwrite : MergeStrategy.Error,
options.overwrite ? MergeStrategy.Overwrite : MergeStrategy.Error
);
};

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
<% } else { %>
<esmf-table-cell
[value]="<%= cellContent %>"
[description]="'<%= propertyLocaleKeyPath %>.description' | transloco"
<% if(value.isEnumeration) { %>
[description]="'<%= propertyLocaleKeyPath %>.description' | transloco"
<% } %>
<% if(options.hasSearchBar) { %>
[configs]="configs"
[highlightString]="highlightString"
Expand Down
21 changes: 14 additions & 7 deletions src/ng-generate/components/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,28 @@ function generateKey(name: string): string {
*/
export function getTableColumValues(
allProps: Array<Property>,
options: Schema,
options: Schema
): Array<{
property: Property;
index: number;
complexPrefix: string;
isEnumeration: boolean;
}> {
return allProps.flatMap((property: Property, index: number) => {
const isEnumeration = property.characteristic && property.characteristic instanceof DefaultEnumeration;
if (property.effectiveDataType?.isComplex && property.characteristic instanceof DefaultSingleEntity) {
const complexPropObj = options.templateHelper.getComplexProperties(property, options);
return complexPropObj.properties.map((complexProp: Property, index: number) => {
return {property: complexProp, index: index, complexPrefix: `${complexPropObj.complexProp}.`};
return {
property: complexProp,
index: index,
complexPrefix: `${complexPropObj.complexProp}.`,
isEnumeration,
};
});
}

return [{property: property, index: index, complexPrefix: ''}];
return [{property: property, index: index, complexPrefix: '', isEnumeration}];
});
}

Expand Down Expand Up @@ -168,11 +175,11 @@ export function getCustomRowActions(options: any): string {
const formattedAction = action.replace(/\.[^/.]+$/, '');
const formattedActionKebab = formattedAction.replace(/\s+/g, '-').toLowerCase();
const commonParts = `data-test="custom-action-icon" *ngIf="is${classify(
formattedActionKebab,
formattedActionKebab
)}Visible" (click)="executeCustomAction($event, '${formattedActionKebab}', row)" style="cursor: pointer;" matTooltip="{{ '${options.templateHelper.getVersionedAccessPrefix(
options,
options
)}${formattedActionKebab}.customRowAction' | transloco }}" aria-hidden="false" attr.aria-label="{{ '${options.templateHelper.getVersionedAccessPrefix(
options,
options
)}${formattedActionKebab}.customRowAction' | transloco }}"`;
return `${action.lastIndexOf('.') > -1 ? `<mat-icon svgIcon="${formattedAction}" ${commonParts}></mat-icon>` : ''}${
action.lastIndexOf('.') === -1 ? `<mat-icon ${commonParts} class="material-icons">${action}</mat-icon>` : ''
Expand Down Expand Up @@ -246,7 +253,7 @@ export function resolveJsPropertyType(property: Property): string {
if (property.characteristic.elementCharacteristic) {
return resolveJsCharacteristicType(
property.characteristic.elementCharacteristic,
property.characteristic.elementCharacteristic.dataType,
property.characteristic.elementCharacteristic.dataType
);
}

Expand Down

0 comments on commit b2373ed

Please sign in to comment.