|
@@ -1,24 +1,15 @@
|
|
-import { Component, OnInit, Input, forwardRef } from '@angular/core';
|
|
|
|
-import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
|
|
|
|
+import { Component } from '@angular/core';
|
|
|
|
+import { CustomInputComponent } from './../../_abstract/custom-input.component';
|
|
import { ValueTransformer } from './../../../interfaces';
|
|
import { ValueTransformer } from './../../../interfaces';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-dropdown-modified-input',
|
|
selector: 'app-dropdown-modified-input',
|
|
templateUrl: 'dropdown-modified-input.component.html',
|
|
templateUrl: 'dropdown-modified-input.component.html',
|
|
- styles: [],
|
|
|
|
- providers: [
|
|
|
|
- {
|
|
|
|
- provide: NG_VALUE_ACCESSOR,
|
|
|
|
- useExisting: forwardRef(() => DropdownModifiedInputComponent),
|
|
|
|
- multi: true
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
|
|
+ styles: []
|
|
})
|
|
})
|
|
-export class DropdownModifiedInputComponent implements OnInit, ControlValueAccessor {
|
|
|
|
|
|
+export class DropdownModifiedInputComponent extends CustomInputComponent {
|
|
|
|
|
|
-
|
|
|
|
- @Input()
|
|
|
|
- meta: StringMap = {};
|
|
|
|
|
|
+ exposeMetaInTemplate: string[] = ['modifiers', 'transform', 'placeholder'];
|
|
|
|
|
|
modifiers: Array<string>;
|
|
modifiers: Array<string>;
|
|
transform: ValueTransformer = {
|
|
transform: ValueTransformer = {
|
|
@@ -29,18 +20,8 @@ export class DropdownModifiedInputComponent implements OnInit, ControlValueAcces
|
|
private displayedValue: string;
|
|
private displayedValue: string;
|
|
private _controlValue: string;
|
|
private _controlValue: string;
|
|
|
|
|
|
- private extraClass: string = '';
|
|
|
|
-
|
|
|
|
- propagateChange = (_: any) => {};
|
|
|
|
-
|
|
|
|
- ngOnInit() {
|
|
|
|
- // Move meta variables up a level, for direct access in templates
|
|
|
|
- ['modifiers', 'transform', 'placeholder'].map(p => this[p] = this.meta[p] || this[p]);
|
|
|
|
- this.controlValue = this.meta.value;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
get controlValue(): string {
|
|
get controlValue(): string {
|
|
- return this._controlValue;;
|
|
|
|
|
|
+ return this._controlValue;
|
|
}
|
|
}
|
|
|
|
|
|
set controlValue(inputValue) {
|
|
set controlValue(inputValue) {
|
|
@@ -54,13 +35,6 @@ export class DropdownModifiedInputComponent implements OnInit, ControlValueAcces
|
|
this.controlValue = value;
|
|
this.controlValue = value;
|
|
}
|
|
}
|
|
|
|
|
|
- registerOnChange(fn: any): void {
|
|
|
|
- this.propagateChange = fn;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- registerOnTouched(fn: any): void {
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
modifierChange(modifier) {
|
|
modifierChange(modifier) {
|
|
this.selectedModifier = modifier;
|
|
this.selectedModifier = modifier;
|
|
this._controlValue = this.transform.outputFn(this.selectedModifier, this.displayedValue);
|
|
this._controlValue = this.transform.outputFn(this.selectedModifier, this.displayedValue);
|