Skip to content

Commit

Permalink
[Angular] Loop for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert committed Sep 28, 2021
1 parent 6109bed commit 1f85b8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ _%>
<%_ const enumPrefix = frontendAppName + '.'+ fieldType; _%>
<option [ngValue]="null"><% if (enableTranslation) { %>{{ '<%= enumPrefix %>.null' | translate }}<% } %></option>
<%_ const values = field.enumValues;
for (key in values) {
const enumValue = values[key]; _%>
<option value="<%= enumValue.name %>"><% if (enableTranslation) { %>{{ '<%= enumPrefix %>.<%= enumValue.name %>' | translate }}<% } else { %><%= enumValue.value %><% } %></option>
<%_ } _%>
const enumImports = generateEntityClientEnumImports(fields); _%>
<option *ngFor="let <%= fieldType %> of <%= fieldType %>s" [ngValue]="<%= fieldType %>"><% if (enableTranslation) { %>{{ '<%= enumPrefix %>.' + <%= fieldType %> | translate }}<% } else { %><%= fieldType %><% } %></option>
</select>
<%_ } else { _%>
<%_ if (field.fieldTypeBinary && !field.blobContentTypeText) { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,20 @@ import { <%= uniqueRel.otherEntityAngularName %>Service } from 'app/entities/<%=
}
});
_%>
<%_ const enumImports = generateEntityClientEnumImports(fields); _%>
<%_ enumImports.forEach( (importedPath, importedType) => { _%>
import { <%- importedType %> } from '<%- importedPath %>';
<%_ }); _%>

@Component({
selector: '<%= jhiPrefixDashed %>-<%= entityFileName %>-update',
templateUrl: './<%= entityFileName %>-update.component.html'
})
export class <%= entityAngularName %>UpdateComponent implements OnInit {
isSaving = false;
<%_ enumImports.forEach( (importedPath, importedType) => { _%>
<%- importedType %>s = Object.keys(<%- importedType %>);
<%_ }); _%>

<%_ for (const relationshipsByEntityNeedingOptions of Object.values(differentRelationships).map(relationships => relationships.filter(rel => rel.ownerSide)).filter(relationships => relationships.length > 0)) { _%>
<%_ const relationshipsWithCustomUniqueOptions = relationshipsByEntityNeedingOptions.filter(rel => rel.relationshipOneToOne && !rel.otherEntityUser); _%>
Expand Down

0 comments on commit 1f85b8e

Please sign in to comment.