@WidgetComponent
    
    
File
    Implements
    
    
    Metadata
    
        
            
                | selector | 
                nm-search-attribute-selection | 
            
            
                | styleUrls | 
                search-attribute-selection.component.scss | 
            
            
                | templateUrl | 
                ./search-attribute-selection.component.html | 
            
        
    
    
    Index
    
        
            
                
                    
                        Widget inputs
                    
                 | 
            
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                     
              
                | 
                 | 
            
             
                
                    
                        Widget outputs
                    
                 | 
            
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                     
              
                | 
                 | 
            
            
            
            
             
            
                
                    
                        Properties
                    
                 | 
            
            
                | 
                    
                 | 
            
               
            
                
                    
                        Methods
                    
                 | 
            
            
                | 
                    
                 | 
            
                  
        
    
    
    Constructor
        
            
                
                    
constructor(dialogRef: MatDialogRef, http: HttpClient, _notificationService: CustomNotificationService, translateService: TranslateService)
                     | 
                
                        
                            | 
                                
                             | 
                        
                
                    | 
                            
                     | 
                
            
        
    
    
        
            Methods
        
        
            
                
                    | 
                        
                        
                            
                            arrayToObj
                            
                            
                        
                     | 
                
                
                    
arrayToObj(selectedFields: )
                     | 
                
                        
                            | 
                                    
                             | 
                        
                
                    
                            
                                    Parameters :
                                    
                                        
                                            
                                                | Name | 
                                                Optional | 
                                             
                                        
                                        
                                                
                                                        | selectedFields | 
                                                    
                                                    
                                                            no
                                                     | 
                                                    
                                                 
                                        
                                     
                             
                            
                             
                            
                                Returns :     { fieldsVisible: {}; attributes: any; }
                             
                                
                                    
                                 
                     | 
                
            
        
        
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            doSaveFavorites
                            
                            
                        
                     | 
                
                
                    
                            
                        doSaveFavorites()
                     | 
                
                        
                            | 
                                    
                             | 
                        
                
                    | 
                            
                     | 
                
            
        
        
        
        
            
                
                    | 
                        
                        
                            
                            selectedItemsChanged
                            
                            
                        
                     | 
                
                
                    
selectedItemsChanged()
                     | 
                
                        
                            | 
                                    
                             | 
                        
                
                    | 
                            
                     | 
                
            
        
    
    
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            activateMultipleAddableMode
                            
                            
                        
                     | 
                
                
                    
                        activateMultipleAddableMode:     boolean
                     | 
                
                    
                        
                            Type :     boolean
                         | 
                    
                    
                        
                            Default value : true
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            additionalProperties
                            
                            
                        
                     | 
                
                
                    
                        additionalProperties:     
                     | 
                
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            attributesVisible
                            
                            
                        
                     | 
                
                
                    
                        attributesVisible:     any[]
                     | 
                
                    
                        
                            Type :     any[]
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            currentLocale
                            
                            
                        
                     | 
                
                
                    
                        currentLocale:     
                     | 
                
                        
                            | 
                                    
                             | 
                        
            
        
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            enableSaveButton
                            
                            
                        
                     | 
                
                
                    
                        enableSaveButton:     boolean
                     | 
                
                    
                        
                            Type :     boolean
                         | 
                    
                    
                        
                            Default value : false
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            fields
                            
                            
                        
                     | 
                
                
                    
                        fields:     any[]
                     | 
                
                    
                        
                            Type :     any[]
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            fieldsVisible
                            
                            
                        
                     | 
                
                
                    
                        fieldsVisible:     
                     | 
                
                        
                            | 
                                    
                             | 
                        
            
        
        
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            initalselectedFields
                            
                            
                        
                     | 
                
                
                    
                        initalselectedFields:     any[]
                     | 
                
                    
                        
                            Type :     any[]
                         | 
                    
                    
                        
                            Default value : []
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            resetDefault
                            
                            
                        
                     | 
                
                
                    
                        resetDefault:     
                     | 
                
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Private
                            saveFavorites
                            
                            
                        
                     | 
                
                
                    
                        saveFavorites:     
                     | 
                
                    
                        
                            Default value : new Subject<any>()
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            saveFavoritesObservable
                            
                            
                        
                     | 
                
                
                    
                        saveFavoritesObservable:     
                     | 
                
                    
                        
                            Default value : this.saveFavorites.asObservable()
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            selectedFields
                            
                            
                        
                     | 
                
                
                    
                        selectedFields:     any[]
                     | 
                
                    
                        
                            Type :     any[]
                         | 
                    
                    
                        
                            Default value : []
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
        
        
            
                
                    | 
                        
                        
                            
                                Public
                            withDefaultMenuAction
                            
                            
                        
                     | 
                
                
                    
                        withDefaultMenuAction:     boolean
                     | 
                
                    
                        
                            Type :     boolean
                         | 
                    
                    
                        
                            Default value : true
                         | 
                    
                        
                            | 
                                    
                             | 
                        
            
        
 
    
        import { Component, OnInit } from "@angular/core";
import { MatDialogRef } from "@angular/material/dialog";
import { HttpClient } from "@angular/common/http";
import { Subject } from "rxjs";
import { deepCopy, flatCopy } from "../../../components/util/util.service";
import { CustomNotificationService } from "../../../components/notification/customnotification.service";
import { TranslateService } from "@ngx-translate/core";
import { SelectFilterParams } from "../../interfaces/list.interfaces";
import * as uriTemplates_ from "uri-templates";
const uriTemplates = uriTemplates_;
@Component({
  selector: "nm-search-attribute-selection",
  templateUrl: "./search-attribute-selection.component.html",
  styleUrls: ["./search-attribute-selection.component.scss"],
})
export class SearchAttributeSelectionDialog implements OnInit {
  // The default fields of the dialog
  public fields: any[];
  public attributesVisible: any[];
  public fieldsVisible;
  public resetDefault;
  public selectedFields: any[] = [];
  public initalselectedFields: any[] = [];
  public enableSaveButton: boolean = false;
  public infoText: string;
  public infoTitle: string;
  public currentLocale;
  public additionalProperties;
  public withDefaultMenuAction: boolean = true;
  public selectFilterParams: SelectFilterParams;
  private saveFavorites = new Subject<any>();
  public saveFavoritesObservable = this.saveFavorites.asObservable();
  public activateMultipleAddableMode: boolean = true;
  constructor(
    public dialogRef: MatDialogRef<SearchAttributeSelectionDialog>,
    private http: HttpClient,
    private _notificationService: CustomNotificationService,
    private translateService: TranslateService
  ) {}
  ngOnInit() {
    if (!this.selectFilterParams) {
      this.selectFilterParams = {
        filterAttribute: ["scope", "mandatory"],
        placeholder: "placeholder.attributescope",
        href:
          "/api/core/configuration-types/attributescopes?locale=" +
          this.currentLocale,
        dataType: "types",
      };
    }
    this.selectFilterParams = flatCopy(this.selectFilterParams);
    this.selectFilterParams.href = uriTemplates(
      this.selectFilterParams.href
    ).fill({
      locale: this.currentLocale,
    });
    this.additionalProperties = ["parentDescription", "group", "dataLevels"];
    this.fields.forEach((field) => {
      if (
        field.scope === "SYSTEM" &&
        (this.fieldsVisible[field.identifier] ||
          this.fieldsVisible[field.identifier] === undefined)
      ) {
        this.selectedFields.push(field);
      }
    });
    if (this.attributesVisible) {
      this.selectedFields = this.selectedFields.concat(this.attributesVisible);
    }
    this.initalselectedFields = deepCopy(this.selectedFields);
  }
  close() {
    this.dialogRef.close();
  }
  confirm() {
    const mappedValue = this.arrayToObj(this.selectedFields);
    this.dialogRef.close(mappedValue);
  }
  public doSaveFavorites() {
    const favorites = deepCopy(this.selectedFields);
    this.resetDefault = favorites;
    this.saveFavorites.next(favorites);
    this._notificationService.success(
      this.translateService.instant("message.success.action.title"),
      this.translateService.instant("message.success.save.visible.fields.body")
    );
  }
  selectedItemsChanged() {
    this.enableSaveButton = true;
  }
  reset() {
    if (this.resetDefault) {
      this.initalselectedFields = deepCopy(this.resetDefault);
    }
  }
  arrayToObj(selectedFields) {
    const fieldsVisible = {};
    const attributes = selectedFields.filter(
      (entry) => entry.scope !== "SYSTEM"
    );
    /* TODO: This seems wrong in search app?
    Object.keys(this.fields.filter(entry => entry.scope === 'FAKE')).forEach(key => {
      let field = this.fields[key].identifier;
      const isVisible = selectedFields.find(entry => entry.identifier === field) !== undefined;
      fieldsVisible[field] = isVisible;
    });
     */
    Object.keys(this.fieldsVisible).forEach((field) => {
      const isVisible =
        selectedFields.find((entry) => entry.identifier === field) !==
        undefined;
      fieldsVisible[field] = isVisible;
    });
    return { fieldsVisible, attributes };
  }
}
     
    
        <nm-dialog
  [dialogRef]="dialogRef"
  class="nm-dialog nm-select-attributes-dialog"
>
  <ng-container slot="title">
    {{ "edit.visible.fields" | translate }}
  </ng-container>
  <ng-container slot="content">
    <div class="duallist-table">
      <nm-ngx-material-duallistbox
        [items]="fields"
        [(selectedItems)]="selectedFields"
        [initalselectedItems]="initalselectedFields"
        [additionalProperties]="additionalProperties"
        [selectFilterParams]="selectFilterParams"
        [descProperty]="'description'"
        [filterPlaceholder]="'placeholder.available.attributes' | translate"
        [filterPlaceholderTo]="'placeholder.visible.attributes' | translate"
        [removeAllTooltip]="'button.removeAll' | translate"
        [addAllTooltip]="'button.addAll' | translate"
        [idProperty]="'identifier'"
        [activateMultipleAddableMode]="activateMultipleAddableMode"
        removeIcon="remove"
        (selectedItemsChange)="selectedItemsChanged()"
        [dynamicHeightContainer]="'.mat-dialog-container'"
        [dynamicHeightAdditionalHeight]="'190px'"
        [autofocus]="true"
      >
      </nm-ngx-material-duallistbox>
    </div>
  </ng-container>
  <ng-container slot="actions">
    <button *ngIf="withDefaultMenuAction" mat-button [matMenuTriggerFor]="menu">
      <mat-icon>more_vert</mat-icon>
      {{ "placeholder.default" | translate }}
    </button>
    <mat-menu #menu="matMenu">
      <button mat-menu-item (click)="reset()">
        <mat-icon>replay</mat-icon>
        {{ "button.reset.to.default" | translate }}
      </button>
      <button mat-menu-item (click)="doSaveFavorites()">
        <mat-icon>save</mat-icon>
        {{ "button.save.as.default" | translate }}
      </button>
    </mat-menu>
    <div class="u-flex-1"></div>
    <button mat-button (click)="close()">
      {{ "button.cancel" | translate }}
    </button>
    <button
      mat-raised-button
      type="button"
      color="primary"
      (click)="confirm()"
      [disabled]="!enableSaveButton"
    >
      {{ "button.accept" | translate }}
    </button>
  </ng-container>
</nm-dialog>
     
    
        
        
            
                Legend
            
            
            
            
                Html element with directive