MOBILE-4292 base-profilefield: Use displayvalue instead of value

main
Alfonso Salces 2023-04-12 09:10:55 +02:00
parent 772864245e
commit 98d6733541
5 changed files with 13 additions and 3 deletions

View File

@ -1559,6 +1559,7 @@ export type AddonModAssignParticipant = {
customfields?: { // User custom fields (also known as user profile fields).
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.
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.
}[];

View File

@ -2,7 +2,8 @@
<ion-item *ngIf="!edit && field && field.name">
<ion-label>
<p class="item-heading">{{ field.name }}</p>
<p>{{ valueNumber * 1000 | coreFormatDate }}</p>
<p *ngIf="valueNumber">{{ valueNumber * 1000 | coreFormatDate }}</p>
<p *ngIf="displayValue">{{ displayValue }}</p>
</ion-label>
</ion-item>

View File

@ -36,7 +36,8 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField
format?: string;
min?: string;
max?: string;
valueNumber = 0;
valueNumber?: number;
displayValue?: string;
monthNames?: string[];
displayTimezone?: string;
@ -46,6 +47,12 @@ export class AddonUserProfileFieldDatetimeComponent extends CoreUserProfileField
* @param field Field to render.
*/
protected initForNonEdit(field: CoreUserProfileField): void {
if (field.displayvalue) {
this.displayValue = field.displayvalue;
return;
}
this.valueNumber = Number(field.value);
}

View File

@ -69,7 +69,7 @@ export abstract class CoreUserProfileFieldBaseComponent implements OnInit {
* @param field Field to render.
*/
protected initForNonEdit(field: CoreUserProfileField): void {
this.value = field.value;
this.value = field.displayvalue ?? field.value;
}
/**

View File

@ -892,6 +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.
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.
};