VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
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-full/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-form__js__layouteditor__LayoutEditorCmd.js
/*** module: node_modules/absol-form/js/layouteditor/LayoutEditorCmd.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LayoutEditorCmdDescriptors = exports.LayoutEditorCmdTree = exports.LayoutEditorCmdNames = exports.default = void 0;

var _R = _interopRequireDefault(require("../R"));

var _FormPreview = _interopRequireDefault(require("../editor/FormPreview"));

var _ClipboardManager = _interopRequireDefault(require("../ClipboardManager"));

var _FCore = _interopRequireWildcard(require("../core/FCore"));

var _FileSaver = require("absol/src/Network/FileSaver");

var _BlockEditor = _interopRequireDefault(require("../ciruiteditor/blockeditor/BlockEditor"));

var _CircuitDiagramEditor = _interopRequireDefault(require("../ciruiteditor/diagrameditor/CircuitDiagramEditor"));

var _safeThrow = _interopRequireDefault(require("absol/src/Code/safeThrow"));

var _CmdDescriptors = _interopRequireDefault(require("../cmds/CmdDescriptors"));

var _SelectComponentTypeDialog = require("./tool/SelectComponentTypeDialog");

var _layoutUtils = require("./layoutUtils");

var _LEDeleteErrorDialog = _interopRequireDefault(require("./dialog/LEDeleteErrorDialog"));

var _LEPageSettingDialog = _interopRequireWildcard(require("./dialog/LEPageSettingDialog"));

var _FNode = require("../core/FNode");

var _Constants = require("../Constants");




function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }

/**
 * @type {import('./LayoutEditor').default}
 */
var LayoutEditorCmd = {};

LayoutEditorCmd.preview = function () {
  this.flexFormEditor.execCmd('preview');
};

LayoutEditorCmd.remotePreview = function () {
  this.flexFormEditor.execCmd('remotePreview');
};

LayoutEditorCmd.save = function () {
  this.flexFormEditor.execCmd('save'); // var tabHolder = this.formEditor.getEditorHolderByEditor(this);
  // if (tabHolder)
  //     PluginManager.exec(this, R.PLUGINS.SAVE_CONTENT_DATA, tabHolder);
  // this.notifySaved();
};

LayoutEditorCmd.saveAs = function () {
  this.flexFormEditor.execCmd('saveAs');
};

LayoutEditorCmd.saveAsSystem = function () {
  this.flexFormEditor.execCmd('saveAsSystem');
};

LayoutEditorCmd.update_from_other = function () {
  var formEditor = this.getContext(_R.default.FORM_EDITOR);

  if (formEditor) {
    var tabHolder = formEditor.getEditorHolderByEditor(this);
    var currentTabIdent = tabHolder.ident;
    var blockEditorTabIdent = currentTabIdent + '_blocks';
    var blockEditor;
    var blockEditorTabHolder = formEditor.getTaskById(blockEditorTabIdent);
    if (blockEditorTabHolder) blockEditor = blockEditorTabHolder.editor;

    if (blockEditor) {
      this.setBlockData(blockEditor.getData());
      blockEditor.notifySaved();
    }

    var lineEditorTabIdent = currentTabIdent + '_lines';
    var lineEditor;
    var lineEditorTabHolder = formEditor.getTaskById(lineEditorTabIdent);
    if (lineEditorTabHolder) lineEditor = lineEditorTabHolder.editor;

    if (lineEditor) {
      this.setLineData(lineEditor.getLineData());
      this.setDiagramData(lineEditor.getDiagramData());
      lineEditor.notifySaved();
    }
  }
};
/***
 * @this LayoutEditor
 */


LayoutEditorCmd.importFromJson = function () {
  this.flexFormEditor.execCmd('importFromJson');
};

LayoutEditorCmd.export2Json = function () {
  this.flexFormEditor.execCmd('export2Json');
};

LayoutEditorCmd.export2sharpEncode = function () {
  this.flexFormEditor.execCmd('export2sharpEncode');
};

LayoutEditorCmd.export2clipboard = function () {
  this.flexFormEditor.execCmd('export2clipboard');
};

LayoutEditorCmd.editBlocks = function () {
  if (!this.rootLayout) return;
  /**
   * @type {import('./FormEditor').default}
   */

  var formEditor = this.getContext(_R.default.FORM_EDITOR);
  if (!formEditor) return;
  var tabHolder = formEditor.getEditorHolderByEditor(this);
  var currentTabIdent = tabHolder.ident;
  var blockEditorTabIdent = currentTabIdent + '_blocks';
  var blockEditor;
  var blockEditorTabHolder = formEditor.getTaskById(blockEditorTabIdent);
  if (blockEditorTabHolder) blockEditor = blockEditorTabHolder.editor;

  if (!blockEditor) {
    blockEditor = new _BlockEditor.default();
    blockEditor.attach(this);
    var name = tabHolder.name + '(blocks)';
    var desc = tabHolder.desc;
    formEditor.openEditorTab(blockEditorTabIdent, name, desc, blockEditor, {
      layoutEditor: this
    });
  } else {
    blockEditorTabHolder.tabframe.requestActive();
  }

  var data = this.getBlockData();
  blockEditor.setData(data);
};

LayoutEditorCmd.editLines = function () {
  if (!this.rootLayout) return;
  var formEditor = this.getContext(_R.default.FORM_EDITOR);
  if (!formEditor) return;
  var tabHolder = formEditor.getEditorHolderByEditor(this);
  var currentTabIdent = tabHolder.ident;
  var lineEditorTabIdent = currentTabIdent + '_lines';
  var lineEditor;
  var lineEditorTabHolder = formEditor.getTaskById(lineEditorTabIdent);
  if (lineEditorTabHolder) lineEditor = lineEditorTabHolder.editor;

  if (!lineEditor) {
    lineEditor = new _CircuitDiagramEditor.default();
    lineEditor.attach(this);
    var name = tabHolder.name + '(lines)';
    var desc = tabHolder.desc;
    formEditor.openEditorTab(lineEditorTabIdent, name, desc, lineEditor, {
      layoutEditor: this
    });
  } else {
    lineEditorTabHolder.tabframe.requestActive();
  }

  var lines = this.getLineData();
  var diagram = this.getDiagramData();
  lineEditor.setData(lines, diagram);
};
/**
 * @this {LayoutEditor}
 */


LayoutEditorCmd.cut = function () {
  this.clipboardCtrl.cut();
  return;
  if (this.anchorEditors.length < 1) return;
  var components = this.anchorEditors.map(function (ed) {
    return ed.component;
  });
  var componentsData = components.map(function (component) {
    var data = component.getData();
    data.bound = component.view.getBoundingClientRect().toJSON();
    return data;
  });

  _ClipboardManager.default.set(_R.default.CLIPBOARD.COMPONENTS, componentsData); //code copy and edit from LayoutEditor.prototype.removeComponent


  var self = this;
  this.anchorEditors.forEach(function (ed) {
    ed.component.remove();
    self.emit('removecomponent', {
      type: 'removecomponent',
      target: this,
      component: ed.component
    }, this);
  });

  function visit(node) {
    if (node.attributes && node.attributes.name) {
      node.attributes.id = undefined;
      delete node.attributes.id;
    }

    if (node.children) node.children.forEach(visit);
  }

  componentsData.forEach(visit); // this.componentPropertiesEditor.edit();

  this.setActiveComponent();
  this.notifyDataChange();
  this.notifyUnsaved();
  this.outlineDelegate.notifyTreeChange();
  this.commitHistory('cut', 'Cut ' + components.map(function (c) {
    return c.getAttribute('name');
  }).join(', '));
};

LayoutEditorCmd.copy = function () {
  this.clipboardCtrl.copy();
  return;
  if (this.anchorEditors.length < 1) return;
  var componentsData = this.anchorEditors.map(function (ed) {
    var data = ed.component.getData();
    data.bound = ed.component.view.getBoundingClientRect().toJSON();
    return data;
  });

  function visit(node) {
    if (node.attributes && node.attributes.name) {
      node.attributes.name = undefined;
      delete node.attributes.name;
      node.attributes.id = undefined;
      delete node.attributes.id;
    }

    if (node.children) node.children.forEach(visit);
  }

  componentsData.forEach(visit);

  _ClipboardManager.default.set(_R.default.CLIPBOARD.COMPONENTS, componentsData);
};

LayoutEditorCmd.paste = function (event) {
  this.clipboardCtrl.paste();
};
/***
 * @this LayoutEditor
 */


LayoutEditorCmd.delete = function () {
  var editors = this.anchorEditors;
  var components = editors.map(function (e) {
    return e.component;
  });
  var diagramEditor = this.getContext(_R.default.DIAGRAM_EDITOR);
  var refCountById = diagramEditor.getLineData().reduce((ac, line) => {
    ac[line.u] = (ac[line.u] || 0) + 1;

    if (line.u !== line.v) {
      ac[line.v] = (ac[line.v] || 0) + 1;
    }

    return ac;
  }, {});
  var reasons = components.reduce((ac, comp) => {
    (0, _layoutUtils.collectDeleteLockReason)(refCountById, comp, ac);
    return ac;
  }, []);

  if (reasons.length === 0) {
    var _this$layoutStructToo;

    (_this$layoutStructToo = this.layoutStructTool).removeComponent.apply(_this$layoutStructToo, _toConsumableArray(components));
  } else {
    new _LEDeleteErrorDialog.default({
      reasons: reasons
    }).start();
  }
};

LayoutEditorCmd.undo = function () {
  this.undoHistory.undo();
};

LayoutEditorCmd.redo = function () {
  this.undoHistory.redo();
};
/**
 * @this {LayoutEditor}
 */


LayoutEditorCmd.toggleHistory = function () {
  var btn, btnBound;

  if (this.$historyCtn.parentElement) {
    this.$historyCtn.remove();
  } else {
    this.$historyCtn.addTo(this.$view);

    if (this.config.historyWindow) {
      this.$historyCtn.addStyle({
        left: this.config.historyWindow.left + 'px',
        top: this.config.historyWindow.top + 'px',
        width: this.config.historyWindow.width + 'px',
        height: this.config.historyWindow.height + 'px'
      });
    } else {
      btn = (0, _FCore.$)('button[data-cmd-name="toggleHistory"]', this.$header);
      btnBound = btn.getBoundingClientRect();
      this.$historyCtn.removeStyle('display');
      this.$historyCtn.addStyle({
        left: btnBound.left + 'px',
        top: btnBound.bottom + 2 + 'px'
      });
    }

    this.$historyCtn.relocation();
  }
};

LayoutEditorCmd.selectAll = function () {
  var now = new Date().getTime();
  var comp;

  if (this.anchorEditors.length == 0) {
    comp = this.rootLayout.children;
  } else {
    comp = (this.findNearestLayoutParent(this.anchorEditors[0].component.parent) || this.rootLayout).children;
  }

  this.setActiveComponent.apply(this, comp);
};

LayoutEditorCmd.editRootLayout = function () {
  this.editLayout(this.rootLayout);
  this.setActiveComponent(this.rootLayout);
};

LayoutEditorCmd.zoomIn = function () {
  this.zoomBy(1 / 0.9);
};

LayoutEditorCmd.zoomOut = function () {
  this.zoomBy(0.9);
};

LayoutEditorCmd.resetZoom = function () {
  this.setSoftScale(1);
};
/***
 * @this {LayoutEditor}
 */


LayoutEditorCmd.setSelectMode = function (mode) {
  this.selectCtrl.setSelectMode(mode);
};
/***
 * @this {LayoutEditor}
 */


LayoutEditorCmd.addComponent = function () {
  (0, _SelectComponentTypeDialog.openSelectComponentTypeDialog)({
    confirmButtonText: 'ADD'
  }).then(function (clazz) {
    if (!clazz) return;
    var focusAE = this.anchorEditorsCtrl.anchorEditors[this.anchorEditorsCtrl.anchorEditors.length - 1];
    var focusC = focusAE && focusAE.component;
    var editingLayout = this.editingLayout;
    if (focusC) editingLayout = focusC.parent; //todo: fix undefined

    editingLayout = editingLayout || this.rootLayout;
    var newComponent = this.buildComponent({
      tag: clazz.prototype.tag
    }, editingLayout.fragment);
    var nameDict = {};
    (0, _FNode.traversal)(editingLayout, function (path) {
      nameDict[path.node.attributes.name] = true;
    });
    var name = newComponent.attributes.name.replace(/[0-9]+$/, '');
    var i = 0;

    if (nameDict) {
      while (nameDict[name + i]) {
        ++i;
      }

      name = name + i;
      newComponent.attributes.name = name;
    }

    if (focusC) {
      editingLayout.addChildAfter(newComponent, focusC);
    } else {
      editingLayout.addChild(newComponent);
    }

    this.anchorEditorsCtrl.setActiveComponent(newComponent);
    this.lcEmitter.emit(_Constants.EV_COMP_TREE_CHANGE);
  }.bind(this));
};

LayoutEditorCmd.transformComponentType = function () {
  alert('In processing!');
};
/***
 * @this {LayoutEditor}
 */


LayoutEditorCmd.pageSetting = function () {
  (0, _LEPageSettingDialog.openPageSettingDialog)().then(result => {
    if (!result || !this.rootLayout) return;
    this.rootLayout.style.width = result[0];
    this.rootLayout.style.height = 'auto';

    if (this.rootLayout.tag === 'LinearLayout') {
      this.rootLayout.style.paddingLeft = result[2];
      this.rootLayout.style.paddingRight = result[2];
      this.rootLayout.style.paddingTop = result[3];
      this.rootLayout.style.paddingBottom = result[3];
    }
  });
};
/***
 * @this {LayoutEditor}
 */


LayoutEditorCmd.editContent = function () {
  var editors = this.anchorEditors;
  var components = editors.map(function (e) {
    return e.component;
  });
  var comp = components.pop();

  if (comp) {
    if (comp.isLayout) this.editLayout(comp);else this.editComponent(comp);
  }
};
/***
 * @this {LayoutEditor}
 */


LayoutEditorCmd.moveOrderToFirst = function () {
  var _this$layoutStructToo2;

  var components = this.anchorEditorsCtrl.getComponents();
  if (components.length === 0) return;

  (_this$layoutStructToo2 = this.layoutStructTool).moveComponentToFirst.apply(_this$layoutStructToo2, _toConsumableArray(components));
};
/***
 * @this {LayoutEditor}
 */


LayoutEditorCmd.moveOrderToPrevious = function () {
  var _this$layoutStructToo3;

  var components = this.anchorEditorsCtrl.getComponents();
  if (components.length === 0) return;

  (_this$layoutStructToo3 = this.layoutStructTool).moveComponentToPrevious.apply(_this$layoutStructToo3, _toConsumableArray(components));
};
/***
 * @this {LayoutEditor}
 */


LayoutEditorCmd.moveOrderToNext = function () {
  var _this$layoutStructToo4;

  var components = this.anchorEditorsCtrl.getComponents();
  if (components.length === 0) return;

  (_this$layoutStructToo4 = this.layoutStructTool).moveComponentToNext.apply(_this$layoutStructToo4, _toConsumableArray(components));
};
/***
 * @this {LayoutEditor}
 */


LayoutEditorCmd.moveOrderToLast = function () {
  var _this$layoutStructToo5;

  var components = this.anchorEditorsCtrl.getComponents();
  if (components.length === 0) return;

  (_this$layoutStructToo5 = this.layoutStructTool).moveComponentToLast.apply(_this$layoutStructToo5, _toConsumableArray(components));
};

var _default = LayoutEditorCmd;
exports.default = _default;
var LayoutEditorCmdNames = []; //
// export var LayoutEditorCmdTree = [
//     [
//         [
//             'preview',
//             'remotePreview'
//         ],
//
//
//     ],
//     [
//         'pageSetting',
//         'editRootLayout',
//         'selectAll',
//         'setSelectMode'
//     ],
//     [
//         'transformComponentType'
//     ],
//     [
//         'moveOrderToFirst',
//         'moveOrderToPrevious',
//         'moveOrderToNext',
//         'moveOrderToLast',
//     ],
//     [
//         'formatFont'
//     ]
// ];

exports.LayoutEditorCmdNames = LayoutEditorCmdNames;
var LayoutEditorCmdTree = {
  type: 'tab_list',
  children: [{
    type: 'tab',
    name: 'Home',
    children: [{
      type: 'group_x2',
      children: ['preview']
    }, {
      type: 'group_x2',
      children: ['save', 'saveAs', 'saveAsSystem']
    }, {
      type: 'group_x2',
      children: ['undo', 'redo', 'toggleHistory']
    }, {
      type: 'group_x2',
      children: ['cut', 'copy', 'paste', 'delete']
    }]
  }, {
    type: 'tab',
    name: 'Edit',
    children: [{
      type: 'group_x2',
      children: ['addComponent']
    }, {
      type: 'group_x2',
      children: ['pageSetting', 'editRootLayout', 'selectAll', 'setSelectMode']
    }, {
      type: 'group_x2',
      children: ['moveOrderToFirst', 'moveOrderToPrevious', 'moveOrderToNext', 'moveOrderToLast']
    }]
  }, {
    type: 'tab',
    name: 'Data',
    children: [{
      type: 'group_x2',
      children: ['importFromJson', 'export2Json', 'export2sharpEncode', 'export2clipboard']
    }]
  }, {
    type: 'tab',
    name: 'Layout & Format'
  }]
};
exports.LayoutEditorCmdTree = LayoutEditorCmdTree;
var LayoutEditorCmdDescriptors = Object.assign({}, _CmdDescriptors.default);
exports.LayoutEditorCmdDescriptors = LayoutEditorCmdDescriptors;

VaKeR 2022