MOBILE-4292 base-profilefield: Translate fields to display

main
Alfonso Salces 2023-04-18 09:28:01 +02:00
parent e87408418b
commit e0edc76b28
7 changed files with 60 additions and 16 deletions

View File

@ -1,7 +1,11 @@
<!-- Render (no edit). -->
<ion-item *ngIf="!edit && field && field.name">
<ion-label>
<p class="item-heading">{{ field.name }}</p>
<p class="item-heading">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</p>
<p *ngIf="value != '0'">
{{ 'core.yes' | translate }}
</p>
@ -14,7 +18,11 @@
<!-- Edit. -->
<ion-item *ngIf="edit && field && field.shortname && form" [formGroup]="form">
<ion-label>
<span class="label-text" [core-mark-required]="required">{{ field.name }}</span>
<span class="label-text" [core-mark-required]="required">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</span>
<core-input-errors [control]="form.controls[modelName]"></core-input-errors>
</ion-label>
<ion-checkbox item-end [formControlName]="modelName">

View File

@ -1,7 +1,11 @@
<!-- Render (no edit). -->
<ion-item *ngIf="!edit && field && field.name">
<ion-label>
<p class="item-heading">{{ field.name }}</p>
<p class="item-heading">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</p>
<p *ngIf="valueNumber">{{ valueNumber * 1000 | coreFormatDate }}</p>
<p *ngIf="displayValue">{{ displayValue }}</p>
</ion-label>
@ -10,7 +14,11 @@
<!-- Edit. -->
<ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form">
<ion-label position="stacked">
<span [core-mark-required]="required">{{ field.name }}</span>
<span [core-mark-required]="required">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</span>
</ion-label>
<ion-datetime [formControlName]="modelName" [placeholder]="'core.choosedots' | translate" [displayFormat]="format" [max]="max"
[min]="min" [monthNames]="monthNames" [displayTimezone]="displayTimezone">

View File

@ -1,9 +1,14 @@
<!-- Render (no edit). -->
<ion-item *ngIf="!edit && field && field.name">
<ion-label>
<p class="item-heading">{{ field.name }}</p>
<p class="item-heading">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</p>
<p>
<core-format-text [text]="value" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" [courseId]="courseId">
<core-format-text [text]="value" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" [courseId]="courseId"
[wsNotFiltered]="valueNotFiltered">
</core-format-text>
</p>
</ion-label>
@ -12,7 +17,11 @@
<!-- Edit. -->
<ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form">
<ion-label position="stacked">
<span [core-mark-required]="required">{{ field.name }}</span>
<span [core-mark-required]="required">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</span>
</ion-label>
<ion-select [formControlName]="modelName" [placeholder]="'core.choosedots' | translate" interface="action-sheet"
[interfaceOptions]="{header: field.name}">

View File

@ -1,9 +1,14 @@
<!-- Render (no edit). -->
<ion-item *ngIf="!edit && field && field.name">
<ion-label>
<p class="item-heading">{{ field.name }}</p>
<p class="item-heading">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</p>
<p>
<core-format-text [text]="value" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" [courseId]="courseId">
<core-format-text [text]="value" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" [courseId]="courseId"
[wsNotFiltered]="valueNotFiltered">
</core-format-text>
</p>
</ion-label>
@ -12,7 +17,11 @@
<!-- Edit. -->
<ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form">
<ion-label position="stacked">
<span [core-mark-required]="required">{{ field.name }}</span>
<span [core-mark-required]="required">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</span>
</ion-label>
<ion-input [type]="inputType" [formControlName]="modelName" [placeholder]="field.name" maxlength="{{maxLength}}"></ion-input>
<core-input-errors [control]="form.controls[modelName]"></core-input-errors>

View File

@ -1,9 +1,14 @@
<!-- Render (no edit). -->
<ion-item *ngIf="!edit && field && field.name">
<ion-label>
<p class="item-heading">{{ field.name }}</p>
<p class="item-heading">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</p>
<p>
<core-format-text [text]="value" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" [courseId]="courseId">
<core-format-text [text]="value" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId" [courseId]="courseId"
[wsNotFiltered]="valueNotFiltered">
</core-format-text>
</p>
</ion-label>
@ -12,7 +17,11 @@
<!-- Edit. -->
<ion-item *ngIf="edit && field && field.shortname" class="ion-text-wrap" [formGroup]="form">
<ion-label position="stacked">
<span [core-mark-required]="required">{{ field.name }}</span>
<span [core-mark-required]="required">
<core-format-text [text]="field.name" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"
[courseId]="courseId" [wsNotFiltered]="true">
</core-format-text>
</span>
<core-input-errors [control]="control"></core-input-errors>
</ion-label>
<core-rich-text-editor [control]="control" [placeholder]="field.name" [autoSave]="true" [contextLevel]="contextLevel"

View File

@ -40,11 +40,12 @@ export abstract class CoreUserProfileFieldBaseComponent implements OnInit {
modelName = '';
value?: string;
required?: boolean;
valueNotFiltered?: boolean;
/**
* @inheritdoc
*/
ngOnInit(): void {
async ngOnInit(): Promise<void> {
if (!this.field) {
return;
}
@ -60,7 +61,6 @@ export abstract class CoreUserProfileFieldBaseComponent implements OnInit {
return;
}
}
/**
@ -70,6 +70,7 @@ export abstract class CoreUserProfileFieldBaseComponent implements OnInit {
*/
protected initForNonEdit(field: CoreUserProfileField): void {
this.value = field.displayvalue ?? field.value;
this.valueNotFiltered = field.displayvalue === undefined || field.displayvalue === null;
}
/**

View File

@ -892,7 +892,7 @@ export type CoreUserPreference = {
export type CoreUserProfileField = {
type: string; // The type of the custom field - text field, checkbox...
value: string; // The value of the custom field.
displayvalue: string; // @since 4.2. Formatted value of the custom field.
displayvalue?: string; // @since 4.2. Formatted value of the custom field.
name: string; // The name of the custom field.
shortname: string; // The shortname of the custom field - to be able to build the field class in the code.
};