From 79f0ded47bce64613dec7a8f74d0fbc216d290c9 Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 1 Apr 2024 18:03:07 +0200 Subject: [PATCH] [Angular] Migrate Input to Signal Input (_entityFile_-detail) --- .../_entityFile_-detail.component.html.ejs | 36 +++++++++---------- .../_entityFile_-detail.component.spec.ts.ejs | 2 +- .../_entityFile_-detail.component.ts.ejs | 4 +-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.html.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.html.ejs index 1e5b83b6b3dd..208e6f7e82f1 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.html.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.html.ejs @@ -18,7 +18,7 @@ -%>
- @if (<%= entityInstance %>) { + @if (<%= entityInstance %>()) {

Translate="<%= i18nKeyPrefix %>.detail.title">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.detail.title')

@@ -37,31 +37,31 @@ _%>
<%_ if (field.fieldIsEnum) { _%> <%# TODO: import enum and use its key as label _%> - Translate="{{ '<%= frontendAppName %>.<%= fieldType %>.' + <%= entityInstance %>.<%= fieldName %> }}">{{ <%= entityInstance %>.<%= fieldName %> }} + Translate="{{ '<%= frontendAppName %>.<%= fieldType %>.' + <%= entityInstance %>()!.<%= fieldName %> }}">{{ <%= entityInstance %>()!.<%= fieldName %> }} <%_ } else if (field.fieldTypeBinary && field.blobContentTypeImage) { _%> - @if (<%= entityInstance %>.<%= fieldName %>) { + @if (<%= entityInstance %>()!.<%= fieldName %>) {
- - <%= entityInstance %> + + <%= entityInstance %> - {{ <%= entityInstance %>.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>.<%= fieldName %>) }} + {{ <%= entityInstance %>()!.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>()!.<%= fieldName %> ?? '') }}
} <%_ } else if (field.fieldTypeBinary && field.blobContentTypeAny) { _%> - @if (<%= entityInstance %>.<%= fieldName %>) { + @if (<%= entityInstance %>()!.<%= fieldName %>) {
- Translate="entity.action.open">__jhiTransformTranslate__('entity.action.open') - {{ <%= entityInstance %>.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>.<%= fieldName %>) }} + Translate="entity.action.open">__jhiTransformTranslate__('entity.action.open') + {{ <%= entityInstance %>()!.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>()!.<%= fieldName %> ?? '') }}
} <%_ } else if (field.fieldTypeDuration) { _%> - {{ <%= entityInstance %>.<%= fieldName %> | duration }} ({{<%= entityInstance %>.<%= fieldName %> }}) + {{ <%= entityInstance %>()!.<%= fieldName %> | duration }} ({{<%= entityInstance %>()!.<%= fieldName %> }}) <%_ } else if (field.fieldTypeTimed) { _%> - {{ <%= entityInstance %>.<%= fieldName %> | formatMediumDatetime }} + {{ <%= entityInstance %>()!.<%= fieldName %> | formatMediumDatetime }} <%_ } else if (field.fieldTypeLocalDate) { _%> - {{ <%= entityInstance %>.<%= fieldName %> | formatMediumDate }} + {{ <%= entityInstance %>()!.<%= fieldName %> | formatMediumDate }} <%_ } else { _%> - {{ <%= entityInstance %>.<%= fieldName %> }} + {{ <%= entityInstance %>()!.<%= fieldName %> }} <%_ } _%>
<%_ } _%> @@ -79,17 +79,17 @@ _%>
<%_ if (relationship.otherEntityUser) { _%> <%_ if (relationship.collection) { _%> - @for (<%= relationshipFieldName %> of <%= entityInstance %>.<%= relationshipFieldNamePlural %>; track $index; let last = $last) { + @for (<%= relationshipFieldName %> of <%= entityInstance %>()!.<%= relationshipFieldNamePlural %>; track $index; let last = $last) { {{ <%= relationshipFieldName %>.<%= otherEntityField %> }}{{ last ? '' : ', ' }} } <%_ } else { _%> - {{ <%= entityInstance %>.<%= relationshipFieldName %>?.<%= otherEntityField %> }} + {{ <%= entityInstance %>()!.<%= relationshipFieldName %>?.<%= otherEntityField %> }} <%_ } _%> <%_ } else { _%> <%_ if (relationship.collection) { _%> - @for (<%= relationshipFieldName %> of <%= entityInstance %>.<%= relationshipFieldNamePlural %>; track $index; let last = $last) { + @for (<%= relationshipFieldName %> of <%= entityInstance %>()!.<%= relationshipFieldNamePlural %>; track $index; let last = $last) { {{ <%= relationshipFieldName %>.<%= otherEntityField %> }}{{ last ? '' : ', ' }} @@ -97,7 +97,7 @@ _%> <%_ } else { _%> @if (<%= entityInstance + '.' + relationshipFieldName %>) { } <%_ } _%> @@ -118,7 +118,7 @@ _%> <%_ if (!readOnly && updatableEntity) { _%> diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts.ejs index 92159ea099f4..58c17417955f 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.spec.ts.ejs @@ -73,7 +73,7 @@ describe('<%= entityAngularName %> Management Detail Component', () => { const instance = await harness.navigateByUrl('/', <%= entityAngularName %>DetailComponent); // THEN - expect(instance.<%= entityInstance %>).toEqual(expect.objectContaining(<%- testEntity %>)); + expect(instance.<%= entityInstance %>()).toEqual(expect.objectContaining(<%- testEntity %>)); }); }); diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.ts.ejs index 9a6e06fa3916..f9fbfdb58db4 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/detail/_entityFile_-detail.component.ts.ejs @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. -%> -import { Component, <% if (anyFieldIsBlobDerived) { %>inject, <% } %>Input } from '@angular/core'; +import { Component, <% if (anyFieldIsBlobDerived) { %>inject, <% } %>input } from '@angular/core'; import { RouterModule } from '@angular/router'; import SharedModule from 'app/shared/shared.module'; @@ -33,7 +33,7 @@ import { DataUtils } from 'app/core/util/data-util.service'; imports: [SharedModule, RouterModule, DurationPipe, FormatMediumDatetimePipe, FormatMediumDatePipe], }) export class <%= entityAngularName %>DetailComponent { - @Input() <%= entityInstance %>: I<%= entityAngularName %> | null = null; + <%= entityInstance %> = input | null>(null); <%_ if (anyFieldIsBlobDerived) { _%> protected dataUtils = inject(DataUtils);