forked from EVOgeek/Vmeda.Online
		
	MOBILE-3390 database: Support URL force name and autolink
This commit is contained in:
		
							parent
							
								
									333f3f7188
								
							
						
					
					
						commit
						5395ef18f1
					
				| @ -4,4 +4,7 @@ | ||||
|     <core-input-errors *ngIf="error && mode == 'edit'" [control]="form.controls['f_'+field.id]" [errorText]="error"></core-input-errors> | ||||
| </span> | ||||
| 
 | ||||
| <a *ngIf="isShowOrListMode() && value && value.content" [href]="value.content" core-link capture="true">{{value.content}}</a> | ||||
| <ng-container *ngIf="isShowOrListMode() && value && value.content"> | ||||
|     <a *ngIf="autoLink" [href]="value.content" core-link capture="true">{{ displayValue }}</a> | ||||
|     <span *ngIf="!autoLink">{{ displayValue }}</span> | ||||
| </ng-container> | ||||
| @ -24,6 +24,9 @@ import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin- | ||||
| }) | ||||
| export class AddonModDataFieldUrlComponent extends AddonModDataFieldPluginComponent { | ||||
| 
 | ||||
|     protected autoLink = false; | ||||
|     protected displayValue = ''; | ||||
| 
 | ||||
|     constructor(protected fb: FormBuilder) { | ||||
|         super(fb); | ||||
|     } | ||||
| @ -43,4 +46,36 @@ export class AddonModDataFieldUrlComponent extends AddonModDataFieldPluginCompon | ||||
| 
 | ||||
|         this.addControl('f_' + this.field.id, value); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Calculate data for show or list mode. | ||||
|      */ | ||||
|     protected calculateShowListData(): void { | ||||
|         if (!this.value || !this.value.content) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         const url = this.value.content; | ||||
|         const text = this.field.param2 || this.value.content1; // Param2 forces the text to display.
 | ||||
| 
 | ||||
|         this.autoLink = parseInt(this.field.param1, 10) === 1; | ||||
| 
 | ||||
|         if (this.autoLink) { | ||||
|             this.displayValue = text || url; | ||||
|         } else { | ||||
|             // No auto link, always display the URL.
 | ||||
|             this.displayValue = url; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Update value being shown. | ||||
|      */ | ||||
|     protected updateValue(value: any): void { | ||||
|         super.updateValue(value); | ||||
| 
 | ||||
|         if (this.isShowOrListMode()) { | ||||
|             this.calculateShowListData(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user