![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-form/js/ciruiteditor/lineeditor/ |
Upload File : |
import {$, _} from '../../core/FCore'; import Board from "absol-acomp/js/Board"; import BoardTable from "absol-acomp/js/BoardTable"; import EventEmitter from "absol/src/HTML5/EventEmitter"; import OOP from "absol/src/HTML5/OOP"; /*** * * @param {LineEditor} editor * @constructor */ function LELine(editor) { EventEmitter.call(this); this.editor = editor; this.pointList = []; this.pointById = {}; } OOP.mixClass(LELine, EventEmitter); LELine.prototype.createView = function () { this.$view = _({ tag: Board.tag, class: 'as-le-line', child: [ { class: ['as-le-line-header', BoardTable.DRAG_ZONE_CLASS_NAME], child: [ 'span.mdi.mdi-relation-one-to-one' ] }, { class: 'as-le-line-attribute', child: [ '<label class="as-le-line-attribute-name">u</label>', { tag: 'selectmenu', class: ['as-le-line-attribute-value', 'as-le-line-attribute-u'], props: { enableSearch: true } } ] }, { class: 'as-le-line-attribute', child: [ '<label class="as-le-line-attribute-name">uPin</label>', { tag: 'selectmenu', class: ['as-le-line-attribute-value', 'as-le-line-attribute-u-pin'] } ] }, { class: 'as-le-line-attribute', child: [ '<label class="as-le-line-attribute-name">v</label>', { tag: 'selectmenu', class: ['as-le-line-attribute-value', 'as-le-line-attribute-v'], props: { enableSearch: true } } ] }, { class: 'as-le-line-attribute', child: [ '<label class="as-le-line-attribute-name">vPin</label>', { tag: 'selectmenu', class: ['as-le-line-attribute-value', 'as-le-line-attribute-v-pin'] } ] }, { class: 'as-le-line-attribute', child: [ '<label class="as-le-line-attribute-name">twoWay</label>', { tag: 'checkboxbutton', class: ['as-le-line-attribute-value', 'as-le-line-attribute-two-way'] } ] } ] }); this.$header = $('.as-le-line-header', this.$view) .on('click', this.notifySelect.bind(this)); this.$u = $('.as-le-line-attribute-u', this.$view) .on('change', this.handleU.bind(this)) .on('change', this.notifyChange.bind(this)); this.$uPin = $('.as-le-line-attribute-u-pin', this.$view) .on('change', this.notifyChange.bind(this)); this.$v = $('.as-le-line-attribute-v', this.$view) .on('change', this.handleV.bind(this)) .on('change', this.notifyChange.bind(this)); this.$vPin = $('.as-le-line-attribute-v-pin', this.$view) .on('change', this.notifyChange.bind(this)); this.$twoWay = $('.as-le-line-attribute-two-way', this.$view) .on('change', this.notifyChange.bind(this)); }; LELine.prototype.getView = function () { if (!this.$view) { this.createView(); } return this.$view; }; LELine.prototype.setData = function (data) { this.getView(); this._data = data; var u = this.pointById[data.u]; this.$u.value = data.u; this.$uPin.value = data.uPin; this.handleU(); var v = this.pointById[data.v]; this.$v.value = data.v; this.$vPin.value = data.vPin; this.handleV(); }; LELine.prototype.getData = function () { var res = { u: this.$u.value, uPin: this.$uPin.value, v: this.$v.value, vPin: this.$vPin.value, twoWay: this.$twoWay.checked }; if (this._data.attributes) res.attributes = this._data.attributes; return res; }; LELine.prototype.loadPoints = function (list, dict) { this.getView(); this.pointList = list || this.editor.getPointList(); this.pointById = dict || this.editor.getPointDict(); this.$u.items = list; this.$v.items = list; }; LELine.prototype.handleU = function () { var u = this.$u.value; var uPin = this.$uPin.value; var uPoint = this.pointById[u]; var pinItem; if (uPoint) { this.$uPin.items = uPoint.pinList; pinItem = uPoint.pinList.find(function (it) { return it.value === uPin; }); if (!pinItem) uPin = uPoint.pinList[0].value; this.$uPin.value = uPin; } else { this.$uPin.items = [{ text: 'Not found block id!', value: '__none__' }]; this.$uPin.value = '__none__'; } }; LELine.prototype.handleV = function () { var v = this.$v.value; var vPin = this.$vPin.value; var vPoint = this.pointById[v]; var pinItem; if (vPoint) { this.$vPin.items = vPoint.pinList; pinItem = vPoint.pinList.find(function (it) { return it.value === vPin; }); if (!pinItem) vPin = vPoint.pinList[0].value; this.$vPin.value = vPin; } else { this.$vPin.items = [{ text: 'Not found block id!', value: '__none__' }]; this.$vPin.value = '__none__'; } }; LELine.prototype.notifySelect = function (originEvent) { this.emit('select', originEvent, this); }; LELine.prototype.notifyChange = function () { this.editor.notifyUnsaved(); }; export default LELine;