Feature custom image icon fixes after review.
This commit is contained in:
		
							parent
							
								
									20e44ab004
								
							
						
					
					
						commit
						f2e66ca012
					
				@ -303,6 +303,7 @@ export class TbIconComponent extends _TbIconBase
 | 
			
		||||
      this.imagePipe.transform(rawName, { asString: true, ignoreLoadingImage: true }).subscribe(
 | 
			
		||||
        imageUrl => {
 | 
			
		||||
          const imgElement = this.renderer.createElement('img');
 | 
			
		||||
          this.renderer.addClass(imgElement, 'mat-icon');
 | 
			
		||||
          this.renderer.setAttribute(imgElement, 'src', imageUrl as string);
 | 
			
		||||
          const elem: HTMLElement = this._elementRef.nativeElement;
 | 
			
		||||
          this.renderer.insertBefore(elem, imgElement, this._iconNameContent.nativeElement);
 | 
			
		||||
 | 
			
		||||
@ -37,10 +37,6 @@
 | 
			
		||||
          [disabled]="disabled"
 | 
			
		||||
          #matButton
 | 
			
		||||
          (click)="openIconPopup($event, matButton)">
 | 
			
		||||
    @if (!isCustomIcon) {
 | 
			
		||||
      <tb-icon matButtonIcon>{{materialIconFormGroup.get('icon').value}}</tb-icon>
 | 
			
		||||
    } @else {
 | 
			
		||||
      <img class="mat-icon" alt="icon" [src]="materialIconFormGroup.get('icon').value | image | async">
 | 
			
		||||
    }
 | 
			
		||||
    <tb-icon matButtonIcon>{{materialIconFormGroup.get('icon').value}}</tb-icon>
 | 
			
		||||
  </button>
 | 
			
		||||
</ng-template>
 | 
			
		||||
 | 
			
		||||
@ -36,7 +36,6 @@ import { TbPopoverService } from '@shared/components/popover.service';
 | 
			
		||||
import { MaterialIconsComponent } from '@shared/components/material-icons.component';
 | 
			
		||||
import { MatButton } from '@angular/material/button';
 | 
			
		||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
 | 
			
		||||
import { isTbImage } from '@shared/models/resource.models';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'tb-material-icon-select',
 | 
			
		||||
@ -76,8 +75,6 @@ export class MaterialIconSelectComponent extends PageComponent implements OnInit
 | 
			
		||||
  @coerceBoolean()
 | 
			
		||||
  allowedCustomIcon = false;
 | 
			
		||||
 | 
			
		||||
  isCustomIcon = false;
 | 
			
		||||
 | 
			
		||||
  private requiredValue: boolean;
 | 
			
		||||
  get required(): boolean {
 | 
			
		||||
    return this.requiredValue;
 | 
			
		||||
@ -138,13 +135,11 @@ export class MaterialIconSelectComponent extends PageComponent implements OnInit
 | 
			
		||||
    this.materialIconFormGroup.patchValue(
 | 
			
		||||
      { icon: this.modelValue }, {emitEvent: false}
 | 
			
		||||
    );
 | 
			
		||||
    this.defineIconType(value);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private updateModel() {
 | 
			
		||||
    const icon: string = this.materialIconFormGroup.get('icon').value;
 | 
			
		||||
    if (this.modelValue !== icon) {
 | 
			
		||||
      this.defineIconType(icon);
 | 
			
		||||
      this.modelValue = icon;
 | 
			
		||||
      this.propagateChange(this.modelValue);
 | 
			
		||||
    }
 | 
			
		||||
@ -198,10 +193,4 @@ export class MaterialIconSelectComponent extends PageComponent implements OnInit
 | 
			
		||||
    this.materialIconFormGroup.get('icon').patchValue(null, {emitEvent: true});
 | 
			
		||||
    this.cd.markForCheck();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private defineIconType(icon: string) {
 | 
			
		||||
    if (this.allowedCustomIcon) {
 | 
			
		||||
      this.isCustomIcon = isTbImage(icon);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user