forked from EVOgeek/Vmeda.Online
		
	Merge pull request #3611 from alfonso-salces/MOBILE-4292
MOBILE-4292 base-profilefield: Translate fields to display
This commit is contained in:
		
						commit
						5646dd14e0
					
				| @ -1,7 +1,11 @@ | |||||||
| <!-- Render (no edit). --> | <!-- Render (no edit). --> | ||||||
| <ion-item *ngIf="!edit && field && field.name"> | <ion-item *ngIf="!edit && field && field.name"> | ||||||
|     <ion-label> |     <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'"> |         <p *ngIf="value != '0'"> | ||||||
|             {{ 'core.yes' | translate }} |             {{ 'core.yes' | translate }} | ||||||
|         </p> |         </p> | ||||||
| @ -14,7 +18,11 @@ | |||||||
| <!-- Edit. --> | <!-- Edit. --> | ||||||
| <ion-item *ngIf="edit && field && field.shortname && form" [formGroup]="form"> | <ion-item *ngIf="edit && field && field.shortname && form" [formGroup]="form"> | ||||||
|     <ion-label> |     <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> |         <core-input-errors [control]="form.controls[modelName]"></core-input-errors> | ||||||
|     </ion-label> |     </ion-label> | ||||||
|     <ion-checkbox item-end [formControlName]="modelName"> |     <ion-checkbox item-end [formControlName]="modelName"> | ||||||
|  | |||||||
| @ -1,7 +1,11 @@ | |||||||
| <!-- Render (no edit). --> | <!-- Render (no edit). --> | ||||||
| <ion-item *ngIf="!edit && field && field.name"> | <ion-item *ngIf="!edit && field && field.name"> | ||||||
|     <ion-label> |     <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="valueNumber">{{ valueNumber * 1000 | coreFormatDate }}</p> | ||||||
|         <p *ngIf="displayValue">{{ displayValue }}</p> |         <p *ngIf="displayValue">{{ displayValue }}</p> | ||||||
|     </ion-label> |     </ion-label> | ||||||
| @ -10,7 +14,11 @@ | |||||||
| <!-- Edit. --> | <!-- Edit. --> | ||||||
| <ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form"> | <ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form"> | ||||||
|     <ion-label position="stacked"> |     <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-label> | ||||||
|     <ion-datetime [formControlName]="modelName" [placeholder]="'core.choosedots' | translate" [displayFormat]="format" [max]="max" |     <ion-datetime [formControlName]="modelName" [placeholder]="'core.choosedots' | translate" [displayFormat]="format" [max]="max" | ||||||
|         [min]="min" [monthNames]="monthNames" [displayTimezone]="displayTimezone"> |         [min]="min" [monthNames]="monthNames" [displayTimezone]="displayTimezone"> | ||||||
|  | |||||||
| @ -1,9 +1,14 @@ | |||||||
| <!-- Render (no edit). --> | <!-- Render (no edit). --> | ||||||
| <ion-item *ngIf="!edit && field && field.name"> | <ion-item *ngIf="!edit && field && field.name"> | ||||||
|     <ion-label> |     <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> |         <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> |             </core-format-text> | ||||||
|         </p> |         </p> | ||||||
|     </ion-label> |     </ion-label> | ||||||
| @ -12,7 +17,11 @@ | |||||||
| <!-- Edit. --> | <!-- Edit. --> | ||||||
| <ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form"> | <ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form"> | ||||||
|     <ion-label position="stacked"> |     <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-label> | ||||||
|     <ion-select [formControlName]="modelName" [placeholder]="'core.choosedots' | translate" interface="action-sheet" |     <ion-select [formControlName]="modelName" [placeholder]="'core.choosedots' | translate" interface="action-sheet" | ||||||
|         [interfaceOptions]="{header: field.name}"> |         [interfaceOptions]="{header: field.name}"> | ||||||
|  | |||||||
| @ -1,9 +1,14 @@ | |||||||
| <!-- Render (no edit). --> | <!-- Render (no edit). --> | ||||||
| <ion-item *ngIf="!edit && field && field.name"> | <ion-item *ngIf="!edit && field && field.name"> | ||||||
|     <ion-label> |     <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> |         <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> |             </core-format-text> | ||||||
|         </p> |         </p> | ||||||
|     </ion-label> |     </ion-label> | ||||||
| @ -12,7 +17,11 @@ | |||||||
| <!-- Edit. --> | <!-- Edit. --> | ||||||
| <ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form"> | <ion-item *ngIf="edit && field && field.shortname && form" class="ion-text-wrap" [formGroup]="form"> | ||||||
|     <ion-label position="stacked"> |     <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-label> | ||||||
|     <ion-input [type]="inputType" [formControlName]="modelName" [placeholder]="field.name" maxlength="{{maxLength}}"></ion-input> |     <ion-input [type]="inputType" [formControlName]="modelName" [placeholder]="field.name" maxlength="{{maxLength}}"></ion-input> | ||||||
|     <core-input-errors [control]="form.controls[modelName]"></core-input-errors> |     <core-input-errors [control]="form.controls[modelName]"></core-input-errors> | ||||||
|  | |||||||
| @ -1,9 +1,14 @@ | |||||||
| <!-- Render (no edit). --> | <!-- Render (no edit). --> | ||||||
| <ion-item *ngIf="!edit && field && field.name"> | <ion-item *ngIf="!edit && field && field.name"> | ||||||
|     <ion-label> |     <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> |         <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> |             </core-format-text> | ||||||
|         </p> |         </p> | ||||||
|     </ion-label> |     </ion-label> | ||||||
| @ -12,7 +17,11 @@ | |||||||
| <!-- Edit. --> | <!-- Edit. --> | ||||||
| <ion-item *ngIf="edit && field && field.shortname" class="ion-text-wrap" [formGroup]="form"> | <ion-item *ngIf="edit && field && field.shortname" class="ion-text-wrap" [formGroup]="form"> | ||||||
|     <ion-label position="stacked"> |     <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> |         <core-input-errors [control]="control"></core-input-errors> | ||||||
|     </ion-label> |     </ion-label> | ||||||
|     <core-rich-text-editor [control]="control" [placeholder]="field.name" [autoSave]="true" [contextLevel]="contextLevel" |     <core-rich-text-editor [control]="control" [placeholder]="field.name" [autoSave]="true" [contextLevel]="contextLevel" | ||||||
|  | |||||||
| @ -40,11 +40,12 @@ export abstract class CoreUserProfileFieldBaseComponent implements OnInit { | |||||||
|     modelName = ''; |     modelName = ''; | ||||||
|     value?: string; |     value?: string; | ||||||
|     required?: boolean; |     required?: boolean; | ||||||
|  |     valueNotFiltered?: boolean; | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @inheritdoc |      * @inheritdoc | ||||||
|      */ |      */ | ||||||
|     ngOnInit(): void { |     async ngOnInit(): Promise<void> { | ||||||
|         if (!this.field) { |         if (!this.field) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| @ -60,7 +61,6 @@ export abstract class CoreUserProfileFieldBaseComponent implements OnInit { | |||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
| @ -70,6 +70,7 @@ export abstract class CoreUserProfileFieldBaseComponent implements OnInit { | |||||||
|      */ |      */ | ||||||
|     protected initForNonEdit(field: CoreUserProfileField): void { |     protected initForNonEdit(field: CoreUserProfileField): void { | ||||||
|         this.value = field.displayvalue ?? field.value; |         this.value = field.displayvalue ?? field.value; | ||||||
|  |         this.valueNotFiltered = field.displayvalue === undefined || field.displayvalue === null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -60,14 +60,15 @@ export class CoreUserProfileFieldComponent implements OnInit { | |||||||
| 
 | 
 | ||||||
|         this.data.field = this.field; |         this.data.field = this.field; | ||||||
|         this.data.edit = CoreUtils.isTrueOrOne(this.edit); |         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) { |         if (this.edit) { | ||||||
|             this.data.signup = CoreUtils.isTrueOrOne(this.signup); |             this.data.signup = CoreUtils.isTrueOrOne(this.signup); | ||||||
|             this.data.disabled = 'locked' in this.field && CoreUtils.isTrueOrOne(this.field.locked); |             this.data.disabled = 'locked' in this.field && CoreUtils.isTrueOrOne(this.field.locked); | ||||||
|             this.data.form = this.form; |             this.data.form = this.form; | ||||||
|             this.data.registerAuth = this.registerAuth; |             this.data.registerAuth = this.registerAuth; | ||||||
|             this.data.contextLevel = this.contextLevel; |  | ||||||
|             this.data.contextInstanceId = this.contextInstanceId; |  | ||||||
|             this.data.courseId = this.courseId; |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -892,7 +892,7 @@ export type CoreUserPreference = { | |||||||
| export type CoreUserProfileField = { | export type CoreUserProfileField = { | ||||||
|     type: string; // The type of the custom field - text field, checkbox...
 |     type: string; // The type of the custom field - text field, checkbox...
 | ||||||
|     value: string; // The value of the custom field.
 |     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.
 |     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.
 |     shortname: string; // The shortname of the custom field - to be able to build the field class in the code.
 | ||||||
| }; | }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user