File

packages/data/src/lib/files/tag-select/tag-select.component.ts

Extends

ResourceSelectComponent

Implements

OnInit OnChanges

Metadata

selector ec-tag-select
templateUrl ../../resource-select/resource-select.component.html

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(resourceConfig: ResourceConfig, auth: AuthService, elementRef: ElementRef, symbol: SymbolService, cdr: ChangeDetectorRef, sdk: SdkService)
Parameters :
Name Type Optional
resourceConfig ResourceConfig No
auth AuthService No
elementRef ElementRef No
symbol SymbolService No
cdr ChangeDetectorRef No
sdk SdkService No

Inputs

api
Type : Core
Inherited from ResourceSelectComponent

The api to use

config
Type : CrudConfig<Resource>
Inherited from ResourceSelectComponent

The config that should be merged into the generated config

focusEvent
Type : EventEmitter<boolean>
Default value : new EventEmitter()
Inherited from ResourceSelectComponent

The event that focuses the input

formControl
Type : FormControl
Inherited from ResourceSelectComponent

The formControl that is used.

relation
Type : string
Inherited from ResourceSelectComponent

The relation of the resource.

solo
Type : boolean
Inherited from ResourceSelectComponent

Wether or not the selection should be solo

value
Type : Array<Resource>
Inherited from ResourceSelectComponent

The value that should be prefilled

config
Type : ListConfig<T>
Inherited from ResourceSelectComponent

Configuration Object for List

disabled
Type : ListConfig<T>
Inherited from ResourceSelectComponent

If true, the input will be disabled

focusEvent
Type : EventEmitter<boolean>
Default value : new EventEmitter()
Inherited from ResourceSelectComponent

Event emitter to focus input

formControl
Type : FormControl
Inherited from ResourceSelectComponent

The formControl that is used.

list
Type : List<T>
Inherited from ResourceSelectComponent

The Instance of the List

placeholder
Type : string
Inherited from ResourceSelectComponent

Input placeholder

selection
Type : Selection<T>
Inherited from ResourceSelectComponent

The used selection

solo
Type : boolean
Inherited from ResourceSelectComponent

Wether or not the selection should be solo

value
Type : Array<T> | T
Inherited from ResourceSelectComponent

The visible items

values
Type : Array<T>
Inherited from ResourceSelectComponent

Available Items

config
Type : ListConfig<T>
Inherited from SelectComponent
Defined in SelectComponent:48

Configuration Object for List

disabled
Type : ListConfig<T>
Inherited from SelectComponent
Defined in SelectComponent:50

If true, the input will be disabled

focusEvent
Type : EventEmitter<boolean>
Default value : new EventEmitter()
Inherited from SelectComponent
Defined in SelectComponent:76

Event emitter to focus input

formControl
Type : FormControl
Inherited from SelectComponent
Defined in SelectComponent:88

The formControl that is used.

list
Type : List<T>
Inherited from SelectComponent
Defined in SelectComponent:70

The Instance of the List

placeholder
Type : string
Inherited from SelectComponent
Defined in SelectComponent:56

Input placeholder

selection
Type : Selection<T>
Inherited from SelectComponent
Defined in SelectComponent:54

The used selection

solo
Type : boolean
Inherited from SelectComponent
Defined in SelectComponent:74

Wether or not the selection should be solo

value
Type : Array<T> | T
Inherited from SelectComponent
Defined in SelectComponent:52

The visible items

values
Type : Array<T>
Inherited from SelectComponent
Defined in SelectComponent:72

Available Items

Outputs

add
Type : EventEmitter<Item<T>>
Inherited from ResourceSelectComponent

Emits when an item is being added

changed
Type : EventEmitter<Selection<T>>
Inherited from ResourceSelectComponent

Event emitter on item selection

enter
Type : EventEmitter<SelectComponent<T>>
Inherited from ResourceSelectComponent

Emits the query when enter is pressed

enterPressed
Type : Subject<string>
Inherited from ResourceSelectComponent

Subject that is nexted when enter is pressed

itemClick
Type : EventEmitter<Item<T>>
Inherited from ResourceSelectComponent

Event emitter on selected item click

remove
Type : EventEmitter<Item<T>>
Inherited from ResourceSelectComponent

Emits when an item is being removed

add
Type : EventEmitter<Item<T>>
Inherited from SelectComponent
Defined in SelectComponent:64

Emits when an item is being added

changed
Type : EventEmitter<Selection<T>>
Inherited from SelectComponent
Defined in SelectComponent:58

Event emitter on item selection

enter
Type : EventEmitter<SelectComponent<T>>
Inherited from SelectComponent
Defined in SelectComponent:66

Emits the query when enter is pressed

enterPressed
Type : Subject<string>
Inherited from SelectComponent
Defined in SelectComponent:68

Subject that is nexted when enter is pressed

itemClick
Type : EventEmitter<Item<T>>
Inherited from SelectComponent
Defined in SelectComponent:60

Event emitter on selected item click

remove
Type : EventEmitter<Item<T>>
Inherited from SelectComponent
Defined in SelectComponent:62

Emits when an item is being removed

Methods

init
init()
Returns : void
useConfig
useConfig(config: object)
Parameters :
Name Type Optional Default value
config object No {}
Returns : void
clickItem
clickItem(item, e)
Inherited from ResourceSelectComponent

Is called when a selected item is clicked. Either outputs itemClick (if subscribed) or opens the edit pop if puttable.

Parameters :
Name Optional
item No
e No
Returns : any
defaultPlaceholder
defaultPlaceholder()
Inherited from ResourceSelectComponent
Returns : any
editItem
editItem(item: Item, e)
Inherited from ResourceSelectComponent

Is called when a selected item has been clicked.

Parameters :
Name Type Optional
item Item<Resource> No
e No
Returns : void
focusSearchbar
focusSearchbar()
Inherited from ResourceSelectComponent
Returns : void
formSubmitted
formSubmitted(form: Form)
Inherited from ResourceSelectComponent

Is called when the nested resource-form has been saved. Selects the fresh resource and clears the form

Parameters :
Name Type Optional
form Form<EntryResource> No
Returns : void
Public hasMethod
hasMethod(method: string)
Inherited from ResourceSelectComponent

Returns true if the given method is part of the methods array (or if there is no methods array)

Parameters :
Name Type Optional
method string No
Returns : boolean
init
init()
Inherited from ResourceSelectComponent

Inits the select with api, relation and config setup

Returns : void
ngOnChanges
ngOnChanges()
Inherited from ResourceSelectComponent
Returns : void
ngOnInit
ngOnInit()
Inherited from ResourceSelectComponent
Returns : void
onChange
onChange()
Inherited from ResourceSelectComponent
Returns : void
pasteValue
pasteValue(e)
Inherited from ResourceSelectComponent
Parameters :
Name Optional
e No
Returns : void
togglePop
togglePop(e?, noFocus)
Inherited from ResourceSelectComponent
Parameters :
Name Optional Default value
e Yes
noFocus No false
Returns : void
useConfig
useConfig(config: CrudConfig)
Inherited from ResourceSelectComponent

Calls super.useConfig and then creates special dropdownConfig with just entryTitle as field

Parameters :
Name Type Optional Default value
config CrudConfig<Resource> No {}
Returns : void
useMethods
useMethods(methods)
Inherited from ResourceSelectComponent
Parameters :
Name Optional
methods No
Returns : void
activate
activate(e)
Inherited from ResourceSelectComponent
Parameters :
Name Optional
e No
Returns : void
addItem
addItem(item: Item)
Inherited from ResourceSelectComponent

Adds the given ite, emits add output if observed

Parameters :
Name Type Optional
item Item<any> No
Returns : void
cancelDrag
cancelDrag(item, e, target)
Inherited from ResourceSelectComponent

is called when the drag stops in any kind of way.

Parameters :
Name Optional Default value
item No
e No
target No e.target
Returns : void
canRemove
canRemove()
Inherited from ResourceSelectComponent
Returns : boolean
Public clickItem
clickItem(item, e?)
Inherited from ResourceSelectComponent

Is called when a selected item is clicked

Parameters :
Name Optional
item No
e Yes
Returns : void
filterDropdownList
filterDropdownList(listComponent: ListComponent, query)
Inherited from ResourceSelectComponent
Parameters :
Name Type Optional
listComponent ListComponent<any> No
query No
Returns : void
focus
focus(e)
Inherited from ResourceSelectComponent
Parameters :
Name Optional
e No
Returns : void
focusSearchbar
focusSearchbar()
Inherited from ResourceSelectComponent
Returns : void
getArray
getArray(value)
Inherited from ResourceSelectComponent
Parameters :
Name Optional
value No
Returns : any
getParentTree
getParentTree(el, tree: [])
Inherited from ResourceSelectComponent
Parameters :
Name Type Optional Default value
el No
tree [] No []
Returns : any
handleKey
handleKey(e, list)
Inherited from ResourceSelectComponent
Parameters :
Name Optional
e No
list No
Returns : void
hasSoloSelection
hasSoloSelection()
Inherited from ResourceSelectComponent
Returns : boolean
initSelection
initSelection()
Inherited from ResourceSelectComponent

creates the collection from the config

Returns : void
Public listItemClicked
listItemClicked(item, list?)
Inherited from ResourceSelectComponent

Select handler. Toggles selection.

Parameters :
Name Optional
item No
list Yes
Returns : void
ngOnChanges
ngOnChanges()
Inherited from ResourceSelectComponent
Returns : void
ngOnInit
ngOnInit()
Inherited from ResourceSelectComponent
Returns : void
onChange
onChange()
Inherited from ResourceSelectComponent

Fires on selection change. Hides dropdown if solo

Returns : void
onDragStart
onDragStart(item, e, target)
Inherited from ResourceSelectComponent

is called when an element is dragged by the user. hides element in selection

Parameters :
Name Optional Default value
item No
e No
target No e.target
Returns : void
onDrop
onDrop(e)
Inherited from ResourceSelectComponent

called when the element is dropped. moves item in selection.

Parameters :
Name Optional
e No
Returns : void
preventDefault
preventDefault(e)
Inherited from ResourceSelectComponent
Parameters :
Name Optional
e No
Returns : void
registerOnChange
registerOnChange(fn)
Inherited from ResourceSelectComponent

registers change method. (handled by angular)

Parameters :
Name Optional
fn No
Returns : void
registerOnTouched
registerOnTouched()
Inherited from ResourceSelectComponent
Returns : void
removeItem
removeItem(item: Item, e?)
Inherited from ResourceSelectComponent

Removes the given item from selection

Parameters :
Name Type Optional
item Item<any> No
e Yes
Returns : void
setDisabledState
setDisabledState(isDisabled)
Inherited from ResourceSelectComponent
Parameters :
Name Optional
isDisabled No
Returns : void
use
use(value, event)
Inherited from ResourceSelectComponent

Uses the given value as selection items

Parameters :
Name Optional Default value
value No
event No true
Returns : void
useConfig
useConfig(config: ListConfig)
Inherited from ResourceSelectComponent

Initializes either with values, collection or list. Creates Selection with config.

Parameters :
Name Type Optional Default value
config ListConfig<T> No {}
Returns : void
writeValue
writeValue(value: any)
Inherited from ResourceSelectComponent

Called when the model changes

Parameters :
Name Type Optional
value any No
Returns : void
activate
activate(e)
Inherited from SelectComponent
Parameters :
Name Optional
e No
Returns : void
addItem
addItem(item: Item)
Inherited from SelectComponent

Adds the given ite, emits add output if observed

Parameters :
Name Type Optional
item Item<any> No
Returns : void
cancelDrag
cancelDrag(item, e, target)
Inherited from SelectComponent

is called when the drag stops in any kind of way.

Parameters :
Name Optional Default value
item No
e No
target No e.target
Returns : void
canRemove
canRemove()
Inherited from SelectComponent
Returns : boolean
Public clickItem
clickItem(item, e?)
Inherited from SelectComponent

Is called when a selected item is clicked

Parameters :
Name Optional
item No
e Yes
Returns : void
filterDropdownList
filterDropdownList(listComponent: ListComponent, query)
Inherited from SelectComponent
Parameters :
Name Type Optional
listComponent ListComponent<any> No
query No
Returns : void
focus
focus(e)
Inherited from SelectComponent
Parameters :
Name Optional
e No
Returns : void
focusSearchbar
focusSearchbar()
Inherited from SelectComponent
Returns : void
getArray
getArray(value)
Inherited from SelectComponent
Parameters :
Name Optional
value No
Returns : any
getParentTree
getParentTree(el, tree: [])
Inherited from SelectComponent
Parameters :
Name Type Optional Default value
el No
tree [] No []
Returns : any
handleKey
handleKey(e, list)
Inherited from SelectComponent
Parameters :
Name Optional
e No
list No
Returns : void
hasSoloSelection
hasSoloSelection()
Inherited from SelectComponent
Returns : boolean
initSelection
initSelection()
Inherited from SelectComponent

creates the collection from the config

Returns : void
Public listItemClicked
listItemClicked(item, list?)
Inherited from SelectComponent

Select handler. Toggles selection.

Parameters :
Name Optional
item No
list Yes
Returns : void
ngOnChanges
ngOnChanges()
Inherited from SelectComponent
Returns : void
ngOnInit
ngOnInit()
Inherited from SelectComponent
Returns : void
onChange
onChange()
Inherited from SelectComponent

Fires on selection change. Hides dropdown if solo

Returns : void
onDragStart
onDragStart(item, e, target)
Inherited from SelectComponent

is called when an element is dragged by the user. hides element in selection

Parameters :
Name Optional Default value
item No
e No
target No e.target
Returns : void
onDrop
onDrop(e)
Inherited from SelectComponent

called when the element is dropped. moves item in selection.

Parameters :
Name Optional
e No
Returns : void
preventDefault
preventDefault(e)
Inherited from SelectComponent
Parameters :
Name Optional
e No
Returns : void
registerOnChange
registerOnChange(fn)
Inherited from SelectComponent

registers change method. (handled by angular)

Parameters :
Name Optional
fn No
Returns : void
registerOnTouched
registerOnTouched()
Inherited from SelectComponent
Returns : void
removeItem
removeItem(item: Item, e?)
Inherited from SelectComponent

Removes the given item from selection

Parameters :
Name Type Optional
item Item<any> No
e Yes
Returns : void
setDisabledState
setDisabledState(isDisabled)
Inherited from SelectComponent
Parameters :
Name Optional
isDisabled No
Returns : void
use
use(value, event)
Inherited from SelectComponent

Uses the given value as selection items

Parameters :
Name Optional Default value
value No
event No true
Returns : void
useConfig
useConfig(config: ListConfig)
Inherited from SelectComponent

Initializes either with values, collection or list. Creates Selection with config.

Parameters :
Name Type Optional Default value
config ListConfig<T> No {}
Returns : void
writeValue
writeValue(value: any)
Inherited from SelectComponent

Called when the model changes

Parameters :
Name Type Optional
value any No
Returns : void

Properties

Public cdr
Type : ChangeDetectorRef
config
Type : CrudConfig<any>
Public elementRef
Type : ElementRef
placeholder
Default value : this.symbol.resolve('tag-select.placeholder')
relation
Type : string
Default value : 'tags'
Public sdk
Type : SdkService
Public symbol
Type : SymbolService
Public cdr
Type : ChangeDetectorRef
Inherited from ResourceSelectComponent
Public config
Type : CrudConfig<Resource>
Inherited from ResourceSelectComponent

The config that is being generated.

Protected control
Type : FormControl
Inherited from ResourceSelectComponent

The form control that is used

dropdown
Type : PopComponent
Decorators :
@ViewChild('dropdown', {static: true})
Inherited from ResourceSelectComponent

The crud pop with the list to select from

dropdownConfig
Type : CrudConfig<Resource>
Inherited from ResourceSelectComponent

The config of the dropdown pop

dropdownList
Type : ResourceListComponent
Decorators :
@ViewChild('dropdownList')
Inherited from ResourceSelectComponent

The nested resource list in the dropdown

Public elementRef
Type : ElementRef
Inherited from ResourceSelectComponent
Protected group
Type : FormGroup
Inherited from ResourceSelectComponent

The form group that is used

Protected item
Type : Item<any>
Inherited from ResourceSelectComponent

The item that is targeted by the input

resourceListPop
Type : ResourceListPopComponent
Decorators :
@ViewChild(ResourceListPopComponent, {static: true})
Inherited from ResourceSelectComponent

The nested resource list pop

resourcePop
Type : ResourcePopComponent
Decorators :
@ViewChild(ResourcePopComponent)
Inherited from ResourceSelectComponent

The nested resource pop for editing and creating

Public symbol
Type : SymbolService
Inherited from ResourceSelectComponent
Public cdr
Type : ChangeDetectorRef
Inherited from ResourceSelectComponent
dragged
Type : Item<T>
Inherited from ResourceSelectComponent

the current dragged element

dropdown
Type : PopComponent
Decorators :
@ViewChild('dropdown', {static: true})
Inherited from ResourceSelectComponent

The selection dropdown

dropdownList
Type : ListComponent<any>
Decorators :
@ViewChild(ListComponent, {static: true})
Inherited from ResourceSelectComponent

The list in the dropdown

dropdownLoader
Type : LoaderComponent
Decorators :
@ViewChild('dropdownLoader', {static: true})
Inherited from ResourceSelectComponent

The loader inside the dropdown

Public elementRef
Type : ElementRef
Inherited from ResourceSelectComponent
propagateChange
Default value : () => {...}
Inherited from ResourceSelectComponent

Propagates formControl/ngModel changes

searchbar
Type : SearchbarComponent
Decorators :
@ViewChild(SearchbarComponent)
Inherited from ResourceSelectComponent

The nested searchbar

toggleItem
Type : Subject<Item<T>>
Default value : new Subject()
Inherited from ResourceSelectComponent

Subject that is nexted when an item is being selected (clicked or entered on)

Public cdr
Type : ChangeDetectorRef
Inherited from SelectComponent
Defined in SelectComponent:90
dragged
Type : Item<T>
Inherited from SelectComponent
Defined in SelectComponent:46

the current dragged element

dropdown
Type : PopComponent
Decorators :
@ViewChild('dropdown', {static: true})
Inherited from SelectComponent
Defined in SelectComponent:78

The selection dropdown

dropdownList
Type : ListComponent<any>
Decorators :
@ViewChild(ListComponent, {static: true})
Inherited from SelectComponent
Defined in SelectComponent:82

The list in the dropdown

dropdownLoader
Type : LoaderComponent
Decorators :
@ViewChild('dropdownLoader', {static: true})
Inherited from SelectComponent
Defined in SelectComponent:80

The loader inside the dropdown

Public elementRef
Type : ElementRef
Inherited from SelectComponent
Defined in SelectComponent:90
propagateChange
Default value : () => {...}
Inherited from SelectComponent

Propagates formControl/ngModel changes

searchbar
Type : SearchbarComponent
Decorators :
@ViewChild(SearchbarComponent)
Inherited from SelectComponent
Defined in SelectComponent:84

The nested searchbar

toggleItem
Type : Subject<Item<T>>
Default value : new Subject()
Inherited from SelectComponent
Defined in SelectComponent:86

Subject that is nexted when an item is being selected (clicked or entered on)

import { Component, OnInit, ChangeDetectorRef, ElementRef, OnChanges } from '@angular/core';
import { ResourceSelectComponent } from '../../resource-select/resource-select.component';
import { SymbolService } from '@ec.components/ui';
import { ResourceConfig } from '../../resource-config/resource-config.service';
import { SdkService } from '../../sdk/sdk.service';
import { Item } from '@ec.components/core';
import { AuthService } from '../../auth/auth.service';
import { CrudConfig } from '../../crud/crud-config.interface';

@Component({
  selector: 'ec-tag-select',
  templateUrl: '../../resource-select/resource-select.component.html',
})
export class TagSelectComponent extends ResourceSelectComponent implements OnInit, OnChanges {
  relation = 'tags';
  placeholder = this.symbol.resolve('tag-select.placeholder');
  config: CrudConfig<any>;

  constructor(
    protected resourceConfig: ResourceConfig,
    protected auth: AuthService,
    public elementRef: ElementRef,
    public symbol: SymbolService,
    public cdr: ChangeDetectorRef,
    public sdk: SdkService,
  ) {
    super(resourceConfig, auth, elementRef, symbol, cdr);
    this.enterPressed.asObservable().subscribe((s) => {
      this.selection.add(new Item({ tag: this.searchbar.query }, this.config));
      this.searchbar.clear();
      this.dropdownList.list.clearFilter();
    });
  }

  useConfig(config = {}) {
    super.useConfig(config);
    this.config = {
      label: 'tag',
      identifier: 'tag',
      methods: ['get'],
      defaultFilter: false,
      disableHeader: true,
      disableListPop: true,
      disableCreatePop: true,
      fields: {
        tag: {
          view: 'string',
        },
      },
      dropdownFields: {
        tag: {
          view: 'string',
        },
      },
    };
    this.dropdownConfig = {
      disableHeader: true,
      label: 'tag',
      identifier: 'tag',
      fields: {
        tag: {
          view: 'string',
        },
      },
    };
  }

  init() {
    this.sdk.ready.then(() => {
      this.api = this.sdk.api;
      super.init();
    });
  }
}
<div class="ec-resource-select">
  <div class="ec-select" [class.ec-select_solo]="solo" [class.is-empty]="selection?.isEmpty()"
    (click)="togglePop($event)" [class.has-searchbar]="!config?.disableSearchbar">
    <ul class="ec-select-selection">
      <li *ngIf="config?.disableSearchbar&&selection.isEmpty()">
        <span class="ec-select__placeholder">
          {{placeholder||defaultPlaceholder()}}
        </span>
      </li>
      <li *ngFor="let selected of selection?.items">
        <span [class.ec-select-selected]="!solo" [class.ec-select-selected_solo]="solo"
          (click)="clickItem(selected, $event)">
          {{selected.display()}}
          <a (click)="removeItem(selected,$event);" *ngIf="!config?.disableRemove&&!disabled">&times;</a>
        </span>
      </li>
      <li *ngIf="!config?.disableSearchbar" class="ec-select__searchbar">
        <ec-searchbar [disabled]="disabled" [focusEvent]="focusEvent" [autofocus]="false" [property]="config?.label||dropdownConfig?.label"
          [placeholder]="placeholder||defaultPlaceholder()" (pasted)="pasteValue($event)"
          (keypressed)="handleKey($event,dropdownList)" (focus)="focus($event)"
          (queryChanged)="filterDropdownList(dropdownList,$event)"></ec-searchbar>
      </li>
    </ul>
    <ec-pop class="ec-select-options" #dropdown [hideOnClickOutside]="true">
      <ec-loader class="ec-loader loader is-local" #dropdownLoader></ec-loader>
      <ec-resource-list (changed)="searchbar.updatedList($event)" #dropdownList *ngIf="dropdown.activated"
        [relation]="relation" [api]="api" [config]="dropdownConfig" [selection]="selection" [loader]="dropdownLoader"
        (columnClicked)="listItemClicked($event,dropdownList)"></ec-resource-list>
    </ec-pop>
  </div>
  <ec-resource-list-pop (pasted)="pasteValue($event)" (columnClicked)="listItemClicked($event)" #resourceListPop
    [api]="api" [relation]="relation" [config]="config" [selection]="selection"></ec-resource-list-pop>
  <ec-resource-pop #resourcePop [api]="api" [relation]="relation" [config]="config" (submitted)="formSubmitted($event)"
    (deleted)="removeItem($event)" *ngIf="config"></ec-resource-pop>
  <nav class="ec-resource-select__controls">
    <a (click)="editItem(selection?.items[0],$event)" class="btn btn_clear btn_square"
      *ngIf="solo&&hasMethod('put')&&!selection?.isEmpty()">
      <ec-icon name="edit"></ec-icon>
    </a>
    <a (click)="resourcePop.create()" class="btn btn_clear btn_square" *ngIf="!disabled&&!config?.disableCreatePop&&hasMethod('post')">
      <ec-icon name="add"></ec-icon>
    </a>
    <a (click)="resourceListPop.show($event)" class="btn btn_clear btn_square" *ngIf="!config?.disableListPop&&hasMethod('get')&&!disabled">
      <ec-icon name="search"></ec-icon>
    </a>
  </nav>
</div>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""