Merge pull request #3611 from alfonso-salces/MOBILE-4292

MOBILE-4292 base-profilefield: Translate fields to display
main
Dani Palou 2023-04-19 15:41:11 +02:00 committed by GitHub
commit 5646dd14e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 64 additions and 19 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

@ -60,14 +60,15 @@ export class CoreUserProfileFieldComponent implements OnInit {
this.data.field = this.field;
this.data.edit = CoreUtils.isTrueOrOne(this.edit);
this.data.contextLevel = this.contextLevel;
this.data.contextInstanceId = this.contextInstanceId;
this.data.courseId = this.courseId;
if (this.edit) {
this.data.signup = CoreUtils.isTrueOrOne(this.signup);
this.data.disabled = 'locked' in this.field && CoreUtils.isTrueOrOne(this.field.locked);
this.data.form = this.form;
this.data.registerAuth = this.registerAuth;
this.data.contextLevel = this.contextLevel;
this.data.contextInstanceId = this.contextInstanceId;
this.data.courseId = this.courseId;
}
}

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.
};