tfp
Version:
A Web UI framework for TaskBuilder
70 lines (57 loc) • 2.22 kB
JavaScript
import TFPComponentRender from '../render.js'
export default class SelectRender extends TFPComponentRender {
constructor(__tfp, _dataModel, _level) {
super(__tfp, _dataModel, _level);
}
getAttrHtml(retainStyleAttr, otherOptions) {
var attrHtml = super.getAttrHtml(retainStyleAttr);
if (!this._tfp.isDesigning) {
attrHtml += " mode=\"selector\"";
if (otherOptions && otherOptions.gridContainer) {
attrHtml += " name=\"" + this.dataModel.id + "_{{index}}\"";
attrHtml += " value=\"{{item." + this.dataModel.id + "}}\"";
}
else {
attrHtml += " name=\"" + this.dataModel.id + "\"";
attrHtml += " value=\"{{" + this.dataModel.id + "}}\"";
}
attrHtml += " range=\"{{" + this.dataModel.id + "_array}}\"";
attrHtml += " range-key=\"{{'text'}}\" bindchange=\"bindchange_controller\"";
}
return attrHtml;
}
getBodyHtml(getComponentsHtml, retainStyleAttr) {
let html = "\r\n";
let indent = this.getHtmlIndent();
let val = "";
if (this.dataModel.value) {
val = this.dataModel.value;
}
html += indent + "\t<div class=\"wx-select-picker\">" + val + "</div>\r\n";
return html + indent;
}
getBodyWX(getComponentsHtml, retainStyleAttr, otherOptions) {
var cpt_wx = {
"wxjson": "",
"wxjs": "",
"wxml": "",
"wxss": ""
}
let bodyHtml = "\r\n";
let indent = this.getHtmlIndent();
bodyHtml += indent + "\t<view class=\"wx-select-picker\">";
if (otherOptions && otherOptions.gridContainer)
bodyHtml += "{{" + this.dataModel.id + "_array[item." + this.dataModel.id + "].text}}";
else
bodyHtml += "{{" + this.dataModel.id + "_array[" + this.dataModel.id + "].text}}";
bodyHtml += "</view>\r\n";
cpt_wx.wxml = bodyHtml + indent;
return cpt_wx;
}
getHtml(getComponentsHtml, parentIndent, retainStyleAttr) {
return super.getHtml("div", false, parentIndent, retainStyleAttr);
}
getWX(getComponentsHtml, parentIndent, retainStyleAttr, otherOptions) {
return super.getWX("picker", false, parentIndent, retainStyleAttr, otherOptions);
}
}