import { model, Model } from '../../../core/core'; import { ParameterModel } from '../parameter.model'; import { inputTypes } from '../parameter.typings'; @model() export class ParameterInputModel extends Model<{ types: { selectedId: ParameterModel['TYPE']['selectedId']; parameters: ParameterModel['TYPE']['parameters']; }, context: ParameterInputModel['context']; }> { static xtype = 'plugin.model.report.json.components.parameter_input'; context = ['selectedId', 'parameters']; actions = { setSelectedId: (id: string) => { this.model.selectedId = id; }, setParameterName: (id: string, name: string) => { const thisParameter = this.getParameter(id); if (thisParameter) { thisParameter.name = name; } }, setParameterValue: (id: string, value: string, type: inputTypes) => { const thisParameter = this.getParameter(id); if (thisParameter) { thisParameter.value = value; thisParameter.type = type; } }, } private getParameter(id: string) { return this.model.parameters.find(item => item.id === id); } }