import KinisiteBind from "../kinisite-bind"; /** * Toggle class */ let KWidget: any = { block: true, priority: 4000, // Populate with inner html routine: function (el: any, value: any) { if (value) { // Update html with latest let html = value.html; if (html && !el.innerHTML.trim()) { el.innerHTML = html; let parentModel = this.view.models; let myModel = value.propertyData; KWidget.findProperties(parentModel, myModel); // Ensure template delimiters are passed correctly but assume parent config let config = {...KinisiteBind.Kinibind.config, templateDelimiters: ['{', '}']}; this.kinisiteBind = new KinisiteBind(el, myModel, config); } } }, unbind: function () { KinisiteBind.unregister(this.kinisiteBind); }, findProperties(sourceModel: any, targetModel: any) { Object.keys(sourceModel).forEach(key => { if (key !== "$parent" && !targetModel[key]) { targetModel[key] = sourceModel[key]; } }); if (sourceModel["$parent"]) { KWidget.findProperties(sourceModel["$parent"], targetModel); } } }; export default KWidget;