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-acomp__js__treetable__TTQueryController.js
/*** module: node_modules/absol-acomp/js/treetable/TTQueryController.js ***/
"use strict";

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

var _ACore = require("../../ACore");

var _ListSearchMaster = _interopRequireDefault(require("../list/ListSearchMaster"));


/***
 *
 * @param {TreeTable} elt
 * @constructor
 */
function TTQueryController(elt) {
  this.searchMaster = new _ListSearchMaster.default();
  this.elt = elt;
  this.$filterInputs = [];
  this.$searchInput = null;
  this['request'] = this['request'].bind(this);

  this._waitDestroy();

  this._rtsiIdx = -1;
}

TTQueryController.prototype._waitDestroy = function () {
  setTimeout(() => {
    if (this.elt.isDescendantOf(document.body)) {
      this._waitDestroy();
    } else {
      this.searchMaster.destroy();
    }
  }, 10000);
};

TTQueryController.prototype.attachFilterInput = function (input) {
  if (this.$filterInputs.indexOf(input) >= 0) return;
  if (input.detachTreeTable) input.detachTreeTable();
  input.$treeTable = this;

  if ((0, _ACore.$)(input).isSupportedEvent('stoptyping')) {
    input.on('stoptyping', this.request);
  } else {
    input.on('change', this.request);
  }

  input.detachTreeTable = this.detachFilterInput.bind(this, input);
  this.$filterInputs.push(input);
};

TTQueryController.prototype.detachFilterInput = function (input) {
  var idx = this.$filterInputs.indexOf(input);
  if (idx < 0) return;
  this.$filterInputs.splice(idx, 1);
  input.off(this.$searchInput.isSupportedEvent('stoptyping') ? 'stoptyping' : 'change', this.request);
  input.detachTreeTable = null;
};

TTQueryController.prototype.attachSearchInput = function (input) {
  if (this.$searchInput === input) return;
  if (input.detachTreeTable) input.detachTreeTable();
  this.$searchInput = input;

  if ((0, _ACore.$)(input).isSupportedEvent('stoptyping')) {
    input.on('stoptyping', this.request);
  } else {
    input.on('change', this.request);
  }

  input.detachTreeTable = this.detachSearchInput.bind(this, input);
};

TTQueryController.prototype.detachSearchInput = function (input) {
  input = input || this.$searchInput;
  if (input !== this.$searchInput) return;
  input.off(this.$searchInput.isSupportedEvent('stoptyping') ? 'stoptyping' : 'change', this.request);
  input.detachTreeTable = null;
  this.$searchInput = null;
};

TTQueryController.prototype.makeQuery = function () {
  var res = {};

  if (this.$searchInput && this.$searchInput.value.trim().length > 0) {
    res.text = this.$searchInput.value.trim();
  }

  for (var key in res) {
    return res;
  }

  return null;
};

TTQueryController.prototype.request = function () {
  var query = this.makeQuery();
  if (query) this.searchMaster.query(query).then(searchResult => {
    this.elt.table.body.applyQueryResult(searchResult);
  });else this.elt.table.body.applyQueryResult(null);
};

TTQueryController.prototype.getSearchItems = function () {
  var getSearchItemOf = row => {
    var res = {};
    res.text = row.innerText;
    res.value = row.id;

    if (row.subRows && row.subRows.length > 0) {
      res.items = row.subRows.map(getSearchItemOf);
    }

    return res;
  };

  return this.elt.table.body.rows.map(getSearchItemOf);
};

TTQueryController.prototype.transferSearchItems = function () {
  this.searchMaster.transfer(this.getSearchItems());
};

TTQueryController.prototype.requestTransferSearchItems = function () {
  if (this._rtsiIdx > 0) return;
  this._rtsiIdx = setTimeout(() => {
    this._rtsiIdx = -1;
    this.transferSearchItems();
  }, 0);
};

var _default = TTQueryController;
exports.default = _default;

VaKeR 2022