class Setting { constructor(key, type, validations, title, description, value = '') { this.key = key; this.type = type; this.validations = validations; this.title = title; this.description = description; this.params = []; this.value = value; } setParams(params) { if(this.type === 'select' || this.type === 'multiselect') this.params = params; } static create(key, type, validation) { return new self(key, type, validation); } getKey() { return this.key; } getValidationsString() { if(this.validations.length > 0) { var items = '['; $.each(this.validations, (index, value) => { items += '"'+value+'",'; }); items = items.substr(0, items.length -1); items += ']'; return items; } return '[]'; } getParams() { if(this.params.params !== undefined) { var items = '{'; $.each(this.params.params, (index, value) => { items += '"'+value.key+'": "'+value.param+'", '; }); items = items.substr(0, items.length -2); items += '}'; return items; } return '[]'; } render() { return '"'+this.key+'": {"type": "'+this.type+'", "validations": '+this.getValidationsString()+', "title": "'+this.title+'", "description": "'+this.description+'", "params": '+this.getParams()+', "value": "'+this.value+'"}'; } }