Skip to content

Commit b2373ed

Browse files
authored
Remove semantic explanation from table cells for plain fields (eclipse-esmf#127)
Signed-off-by: Pavel Shalamkov <[email protected]>
1 parent 2f30c5a commit b2373ed

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

Diff for: src/ng-generate/components/shared/generators/constants/semantic-explanation/index.ts

+8-18
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,7 @@
1111
* SPDX-License-Identifier: MPL-2.0
1212
*/
1313

14-
import {
15-
apply,
16-
applyTemplates,
17-
MergeStrategy,
18-
mergeWith,
19-
move,
20-
Rule,
21-
SchematicContext,
22-
Tree,
23-
url
24-
} from '@angular-devkit/schematics';
14+
import {apply, applyTemplates, MergeStrategy, mergeWith, move, Rule, SchematicContext, Tree, url} from '@angular-devkit/schematics';
2515
import {strings} from '@angular-devkit/core';
2616
import {Values} from '../../../schema';
2717
import {getTableColumValues} from '../../../utils';
@@ -33,15 +23,15 @@ export function generateSemanticExplanation(options: Values): Rule {
3323
applyTemplates({
3424
classify: strings.classify,
3525
dasherize: strings.dasherize,
36-
options: {...options,
37-
tableColumns: getTableColumValues(options.listAllProperties, options)
26+
options: {
27+
...options,
28+
tableColumns: getTableColumValues(options.listAllProperties, options),
3829
},
39-
name: options.name
30+
name: options.name,
4031
}),
41-
move('src/app/shared/constants')
32+
move('src/app/shared/constants'),
4233
]),
43-
options.overwrite ? MergeStrategy.Overwrite : MergeStrategy.Error,
34+
options.overwrite ? MergeStrategy.Overwrite : MergeStrategy.Error
4435
);
4536
};
46-
47-
}
37+
}

Diff for: src/ng-generate/components/shared/methods/generation/extended-table.html.template

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@
8080
<% } else { %>
8181
<esmf-table-cell
8282
[value]="<%= cellContent %>"
83-
[description]="'<%= propertyLocaleKeyPath %>.description' | transloco"
83+
<% if(value.isEnumeration) { %>
84+
[description]="'<%= propertyLocaleKeyPath %>.description' | transloco"
85+
<% } %>
8486
<% if(options.hasSearchBar) { %>
8587
[configs]="configs"
8688
[highlightString]="highlightString"

Diff for: src/ng-generate/components/shared/utils.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,28 @@ function generateKey(name: string): string {
107107
*/
108108
export function getTableColumValues(
109109
allProps: Array<Property>,
110-
options: Schema,
110+
options: Schema
111111
): Array<{
112112
property: Property;
113113
index: number;
114114
complexPrefix: string;
115+
isEnumeration: boolean;
115116
}> {
116117
return allProps.flatMap((property: Property, index: number) => {
118+
const isEnumeration = property.characteristic && property.characteristic instanceof DefaultEnumeration;
117119
if (property.effectiveDataType?.isComplex && property.characteristic instanceof DefaultSingleEntity) {
118120
const complexPropObj = options.templateHelper.getComplexProperties(property, options);
119121
return complexPropObj.properties.map((complexProp: Property, index: number) => {
120-
return {property: complexProp, index: index, complexPrefix: `${complexPropObj.complexProp}.`};
122+
return {
123+
property: complexProp,
124+
index: index,
125+
complexPrefix: `${complexPropObj.complexProp}.`,
126+
isEnumeration,
127+
};
121128
});
122129
}
123130

124-
return [{property: property, index: index, complexPrefix: ''}];
131+
return [{property: property, index: index, complexPrefix: '', isEnumeration}];
125132
});
126133
}
127134

@@ -168,11 +175,11 @@ export function getCustomRowActions(options: any): string {
168175
const formattedAction = action.replace(/\.[^/.]+$/, '');
169176
const formattedActionKebab = formattedAction.replace(/\s+/g, '-').toLowerCase();
170177
const commonParts = `data-test="custom-action-icon" *ngIf="is${classify(
171-
formattedActionKebab,
178+
formattedActionKebab
172179
)}Visible" (click)="executeCustomAction($event, '${formattedActionKebab}', row)" style="cursor: pointer;" matTooltip="{{ '${options.templateHelper.getVersionedAccessPrefix(
173-
options,
180+
options
174181
)}${formattedActionKebab}.customRowAction' | transloco }}" aria-hidden="false" attr.aria-label="{{ '${options.templateHelper.getVersionedAccessPrefix(
175-
options,
182+
options
176183
)}${formattedActionKebab}.customRowAction' | transloco }}"`;
177184
return `${action.lastIndexOf('.') > -1 ? `<mat-icon svgIcon="${formattedAction}" ${commonParts}></mat-icon>` : ''}${
178185
action.lastIndexOf('.') === -1 ? `<mat-icon ${commonParts} class="material-icons">${action}</mat-icon>` : ''
@@ -246,7 +253,7 @@ export function resolveJsPropertyType(property: Property): string {
246253
if (property.characteristic.elementCharacteristic) {
247254
return resolveJsCharacteristicType(
248255
property.characteristic.elementCharacteristic,
249-
property.characteristic.elementCharacteristic.dataType,
256+
property.characteristic.elementCharacteristic.dataType
250257
);
251258
}
252259

0 commit comments

Comments
 (0)