in src/ui/editor/basic/AKvSet.tsx [38:87]
element() {
let data = super.getValue();
if(!_.isPlainObject(data)) {
data = {};
}
let checkboxs = this._enumFields.map((m, index)=>{
const select = _.has(data, m.value.toString());
const itemKey = m.value?.toString();
return <div key={itemKey} className={`kvSet_${this.props.schema.layoutHint}`}>
<Checkbox disabled={this.props.disable} checked={select} onChange={(e)=>{
let c = e.target.checked;
let update = false;
if(c) {
data[itemKey] = this._inputBoxValue?.[index];
const keys = Object.keys(data);
for(let k of keys) {
if(Object.keys(data).length > this.props.schema.max) {
if( k != itemKey ) {
delete data[k];
update = true;
}
} else {
break;
}
}
} else {
delete data[m.value?.toString()]
}
super.changeValueEx(data, update, true);
}}/>
<div style={{display: "inline-block", marginLeft:5, marginRight:10, marginBottom:3}}>
{m.label ?? m.value}
<div style={{display:"inline-block", paddingLeft: 10}}>
<MFieldViewer
morph={this.props.morph}
schema={this.props.schema.openOption ?? defaultBoxSchema}
database={this}
parent={this.props.schema} forceValid={false}
disable={this.props.disable || !select}
path={"_inputBoxValue[" + index + "]"} afterChange={(path:string, str:any, final:boolean) => {
data[m.value?.toString()] = this._inputBoxValue[index];
super.changeValueEx(data, false, final);
}} />
</div>
</div>
{this._createBr()}
</div>
});