/*
* © 2017 Stratio Big Data Inc., Sucursal en España.
*
* This software is licensed under the Apache License, Version 2.0.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the terms of the License for more details.
*
* SPDX-License-Identifier: Apache-2.0.
*/
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
EventEmitter,
Input,
OnChanges,
OnInit,
Output,
SimpleChanges
} from '@angular/core';
import * as _ from 'lodash';
import { StDropDownMenuItem } from '../st-dropdown-menu/st-dropdown-menu.interface';
import { StEgeo, StRequired } from '../decorators/require-decorators';
import { StTwoListSelection } from './st-two-list-selection';
import { StTwoListSelectionConfig, StTwoListSelectionElement, StTwoListSelectExtraLabelAction, StTwoListSelectionAction } from './st-two-list-selection.model';
@Component({
selector: 'st-two-list-selection',
template: `
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
@StEgeo()
export class StTwoListSelectionComponent extends StTwoListSelection implements OnInit, OnChanges {
@Input() @StRequired('editable') allElements: StTwoListSelectionElement[];
@Input() config: StTwoListSelectionConfig;
@Input() editable: boolean = false;
@Input() hasAllListAll?: boolean = false;
@Input() hasAllListSelected?: boolean = false;
@Input() hasSearch: boolean = true;
@Input() isLoading?: boolean = false;
@Input() itemAll?: StTwoListSelectionElement;
@Input() mode: 'compact' | 'normal' = 'normal';
@Input() moveAllToSelectedButton: boolean = true;
@Input() moveAllToAllButton: boolean = true;
@Input() moveToSelectedButton: boolean = true;
@Input() moveToAllButton: boolean = true;
@Input() orderAllOptions: StDropDownMenuItem[] = [];
@Input() orderSelectedOptions: StDropDownMenuItem[] = [];
@Input() @StRequired() qaTag: string;
@Input() @StRequired() selectedElements: StTwoListSelectionElement[];
@Input() showSearchNumber: number;
@Input() sortBy: 'id' | 'name' | 'notOrder' = 'id';
@Output() change: EventEmitter = new EventEmitter();
@Output() changeOrderAll: EventEmitter = new EventEmitter();
@Output() changeOrderSelected: EventEmitter = new EventEmitter();
@Output() numItemsSelectedAll: EventEmitter = new EventEmitter();
@Output() numItemsSelectedSelected: EventEmitter = new EventEmitter();
@Output() scrollBottomAll: EventEmitter = new EventEmitter();
@Output() searchOverAll: EventEmitter = new EventEmitter();
@Output() searchOverSelected: EventEmitter = new EventEmitter();
@Output() selectedElementsChange: EventEmitter = new EventEmitter();
@Output() selectExtraLabelAll: EventEmitter = new EventEmitter();
@Output() selectExtraLabelSelected: EventEmitter = new EventEmitter();
@Output() selectItemNonEditable: EventEmitter = new EventEmitter();
constructor(private cd: ChangeDetectorRef) {
super(cd);
}
ngOnInit(): void {
this.init(
this.allElements,
this.selectedElements,
this.selectedElementsChange,
this.sortBy,
this.hasAllListAll,
this.hasAllListSelected,
this.itemAll
);
}
ngOnChanges(changes: SimpleChanges): void {
this.checkChanges(changes, 'allElements', 'selectedElements');
this.change.emit();
}
get allList(): StTwoListSelectionElement[] {
return this.copyAllElement;
}
get selectedList(): StTwoListSelectionElement[] {
return this.copySelectedElements;
}
}