Skip to content

Commit

Permalink
[Angular] Migrate Input to Signal Input (_entityFile_-detail)
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert committed Apr 1, 2024
1 parent e931651 commit 79f0ded
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-%>
<div class="d-flex justify-content-center">
<div class="col-8">
@if (<%= entityInstance %>) {
@if (<%= entityInstance %>()) {
<div>
<h2 data-cy="<%= entityInstance %>DetailsHeading"><span <%= jhiPrefix %>Translate="<%= i18nKeyPrefix %>.detail.title">__jhiTransformTranslate__('<%- i18nKeyPrefix %>.detail.title')</span></h2>

Expand All @@ -37,31 +37,31 @@ _%>
<dd>
<%_ if (field.fieldIsEnum) { _%>
<%# TODO: import enum and use its key as label _%>
<span <%= jhiPrefix %>Translate="{{ '<%= frontendAppName %>.<%= fieldType %>.' + <%= entityInstance %>.<%= fieldName %> }}">{{ <%= entityInstance %>.<%= fieldName %> }}</span>
<span <%= jhiPrefix %>Translate="{{ '<%= frontendAppName %>.<%= fieldType %>.' + <%= entityInstance %>()!.<%= fieldName %> }}">{{ <%= entityInstance %>()!.<%= fieldName %> }}</span>
<%_ } else if (field.fieldTypeBinary && field.blobContentTypeImage) { _%>
@if (<%= entityInstance %>.<%= fieldName %>) {
@if (<%= entityInstance %>()!.<%= fieldName %>) {
<div>
<a (click)="openFile(<%= entityInstance %>.<%= fieldName %>, <%= entityInstance %>.<%= fieldName %>ContentType)">
<img [src]="'data:' + <%= entityInstance %>.<%= fieldName %>ContentType + ';base64,' + <%= entityInstance %>.<%= fieldName %>" style="max-width: 100%;" alt="<%= entityInstance %>"/>
<a (click)="openFile(<%= entityInstance %>()!.<%= fieldName %> ?? '', <%= entityInstance %>()!.<%= fieldName %>ContentType)">
<img [src]="'data:' + <%= entityInstance %>()!.<%= fieldName %>ContentType + ';base64,' + <%= entityInstance %>()!.<%= fieldName %>" style="max-width: 100%;" alt="<%= entityInstance %>"/>
</a>
{{ <%= entityInstance %>.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>.<%= fieldName %>) }}
{{ <%= entityInstance %>()!.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>()!.<%= fieldName %> ?? '') }}
</div>
}
<%_ } else if (field.fieldTypeBinary && field.blobContentTypeAny) { _%>
@if (<%= entityInstance %>.<%= fieldName %>) {
@if (<%= entityInstance %>()!.<%= fieldName %>) {
<div>
<a (click)="openFile(<%= entityInstance %>.<%= fieldName %>, <%= entityInstance %>.<%= fieldName %>ContentType)" <%= jhiPrefix %>Translate="entity.action.open">__jhiTransformTranslate__('entity.action.open')</a>
{{ <%= entityInstance %>.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>.<%= fieldName %>) }}
<a (click)="openFile(<%= entityInstance %>()!.<%= fieldName %> ?? '', <%= entityInstance %>()!.<%= fieldName %>ContentType)" <%= jhiPrefix %>Translate="entity.action.open">__jhiTransformTranslate__('entity.action.open')</a>
{{ <%= entityInstance %>()!.<%= fieldName %>ContentType }}, {{ byteSize(<%= entityInstance %>()!.<%= fieldName %> ?? '') }}
</div>
}
<%_ } else if (field.fieldTypeDuration) { _%>
<span>{{ <%= entityInstance %>.<%= fieldName %> | duration }} ({{<%= entityInstance %>.<%= fieldName %> }})</span>
<span>{{ <%= entityInstance %>()!.<%= fieldName %> | duration }} ({{<%= entityInstance %>()!.<%= fieldName %> }})</span>
<%_ } else if (field.fieldTypeTimed) { _%>
<span>{{ <%= entityInstance %>.<%= fieldName %> | formatMediumDatetime }}</span>
<span>{{ <%= entityInstance %>()!.<%= fieldName %> | formatMediumDatetime }}</span>
<%_ } else if (field.fieldTypeLocalDate) { _%>
<span>{{ <%= entityInstance %>.<%= fieldName %> | formatMediumDate }}</span>
<span>{{ <%= entityInstance %>()!.<%= fieldName %> | formatMediumDate }}</span>
<%_ } else { _%>
<span>{{ <%= entityInstance %>.<%= fieldName %> }}</span>
<span>{{ <%= entityInstance %>()!.<%= fieldName %> }}</span>
<%_ } _%>
</dd>
<%_ } _%>
Expand All @@ -79,25 +79,25 @@ _%>
<dd>
<%_ 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) {
<span>
{{ <%= relationshipFieldName %>.<%= otherEntityField %> }}{{ last ? '' : ', ' }}
</span>
}
<%_ } else { _%>
<span>{{ <%= entityInstance %>.<%= relationshipFieldName %>?.<%= otherEntityField %> }}</span>
<span>{{ <%= entityInstance %>()!.<%= relationshipFieldName %>?.<%= otherEntityField %> }}</span>
<%_ } _%>
<%_ } else { _%>
<%_ if (relationship.collection) { _%>
@for (<%= relationshipFieldName %> of <%= entityInstance %>.<%= relationshipFieldNamePlural %>; track $index; let last = $last) {
@for (<%= relationshipFieldName %> of <%= entityInstance %>()!.<%= relationshipFieldNamePlural %>; track $index; let last = $last) {
<span>
<a [routerLink]="['/<%= relationship.otherEntity.entityPage %>', <%= relationshipFieldName %>.<%= relationship.otherEntity.primaryKey.name %>, 'view']">{{ <%= relationshipFieldName %>.<%= otherEntityField %> }}</a>{{ last ? '' : ', ' }}
</span>
}
<%_ } else { _%>
@if (<%= entityInstance + '.' + relationshipFieldName %>) {
<div>
<a [routerLink]="['/<%= relationship.otherEntity.entityPage %>', <%= entityInstance + '.' + relationshipFieldName + '.' + relationship.otherEntity.primaryKey.name %>, 'view']">{{ <%= entityInstance %>.<%= relationshipFieldName %>.<%= otherEntityField %> }}</a>
<a [routerLink]="['/<%= relationship.otherEntity.entityPage %>', <%= entityInstance + '.' + relationshipFieldName + '.' + relationship.otherEntity.primaryKey.name %>, 'view']">{{ <%= entityInstance %>()!.<%= relationshipFieldName %>.<%= otherEntityField %> }}</a>
</div>
}
<%_ } _%>
Expand All @@ -118,7 +118,7 @@ _%>
<%_ if (!readOnly && updatableEntity) { _%>
<button type="button"
[routerLink]="['/<%= entityPage %>', <%= entityInstance %>.<%= primaryKey.name %>, 'edit']"
[routerLink]="['/<%= entityPage %>', <%= entityInstance %>()!.<%= primaryKey.name %>, 'edit']"
class="btn btn-primary">
<fa-icon icon="pencil-alt"></fa-icon>&nbsp;<span <%= jhiPrefix %>Translate="entity.action.edit">__jhiTransformTranslate__('entity.action.edit')</span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<I<%= entityAngularName %> | null>(null);

<%_ if (anyFieldIsBlobDerived) { _%>
protected dataUtils = inject(DataUtils);
Expand Down

0 comments on commit 79f0ded

Please sign in to comment.