/** * Created by hubert on 23/06/17. */ import './ozone-edit-set-entry.html' import {customElement, property} from 'taktik-polymer-typescript' import {OzoneEditEntry} from '../ozone-edit-entry/ozone-edit-entry' /** * is an element to edit ozone items fields as set. * */ @customElement('ozone-edit-set-entry') export class OzoneEditSetEntry extends OzoneEditEntry { @property({type: String}) textValue?:string; static get observers() { return [ 'valueChange(value)', 'textChange(textValue)' ] } registerChangeListener (){ // NOP prevent default behavior that listen on change event } textToSet(textValue?:string):Array{ textValue = textValue|| ''; return textValue.replace(/ /g, '').split(','); } setTotext(arrayValue:Array):string{ return arrayValue.join(', ') } isValueAndTextEqual():boolean{ let textValue = this.textValue || ''; let value = this.value || []; return this.textToSet(textValue).join() == value.join(); } valueChange () { if(! this.isValueAndTextEqual()){ this.set('textValue', this.setTotext(this.value)); } } textChange () { if(! this.isValueAndTextEqual()){ this.set('value', this.textToSet(this.textValue)); this.set('isModify', true); } } }