%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/projetos/suporte.iigd.com.br.old/js/modules/Search/
Upload File :
Create Path :
Current File : /var/www/projetos/suporte.iigd.com.br.old/js/modules/Search/Table.min.js

/**
 * ---------------------------------------------------------------------
 *
 * GLPI - Gestionnaire Libre de Parc Informatique
 *
 * http://glpi-project.org
 *
 * @copyright 2015-2022 Teclib' and contributors.
 * @copyright 2003-2014 by the INDEPNET Development Team.
 * @licence   https://www.gnu.org/licenses/gpl-3.0.html
 *
 * ---------------------------------------------------------------------
 *
 * LICENSE
 *
 * This file is part of GLPI.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * ---------------------------------------------------------------------
 */
import GenericView from"./GenericView.js";window.GLPI=window.GLPI||{};window.GLPI.Search=window.GLPI.Search||{};window.GLPI.Search.Table=class t extends GenericView{constructor(t){const e=$("#"+t).find("table.search-results").attr("id");super(e);this.shiftSelectAllCheckbox()}getElement(){return $("#"+this.element_id)}onColumnSortClick(t,e=false){const s=$(t);const r=this.getElement().find("thead th");const a=s.attr("data-sort-order");const n=$("[data-sort-num]").length;if(!e&&(a===null||a==="nosort")){r.each(((t,e)=>{const s=$(e);s.attr("data-sort-num",null);s.attr("data-sort-order",null)}))}const o=a==="ASC"?"DESC":a==="DESC"?n>1?"nosort":"ASC":"ASC";s.attr("data-sort-order",o);let i=s.attr("data-sort-num");const c=()=>{let t=[];r.each(((e,s)=>{const r=$(s);if(r.attr("data-sort-num")!==undefined){t[r.attr("data-sort-num")]=r.attr("data-searchopt-id")}}));t=t.filter((t=>t));r.each(((e,s)=>{const r=$(s);r.attr("data-sort-num",undefined);const a=t.indexOf(r.attr("data-searchopt-id"));if(a!==-1){r.attr("data-sort-num",a)}}))};c();if(i===undefined&&o!=="nosort"){s.attr("data-sort-num",r.filter((function(){return $(this).attr("data-sort-num")!==undefined})).length)}else if(o==="nosort"){s.attr("data-sort-num",undefined)}this.refreshResults()}onLimitChange(t){const e=t.value;$(t).closest("form").find("select.search-limit-dropdown").each((function(){$(this).val(e)}));this.refreshResults({start:0})}onPageChange(t){const e=$(t);e.closest(".pagination").find(".page-item").removeClass("selected");e.closest(".page-item").addClass("selected");this.refreshResults()}refreshResults(t={}){this.showLoadingSpinner();const e=this.getElement();const s=e.closest("form");const r=e.closest(".ajax-container");let a={};const n=()=>{window.location.reload()};try{const e=this.getSortState();const o=$(s).find("select.search-limit-dropdown").first().val();const i=$(r).closest(".search-container").find(".search-form-container").serializeArray();let c={};i.forEach((t=>{c[t["name"]]=t["value"]}));const l=$(r).find(".pagination .page-item.selected .page-link").attr("data-start");c["start"]=l||0;if(t["reset"]){a={action:"display_results",searchform_id:this.element_id,itemtype:this.getItemtype(),reset:"reset"}}else{a={action:"display_results",searchform_id:this.element_id,itemtype:this.getItemtype(),glpilist_limit:o};if(e!==null){a["sort"]=e["sort"];a["order"]=e["order"]}a=Object.assign(a,c,t)}history.pushState("","","?"+$.param(Object.assign(c,e,t)));$.ajax({url:CFG_GLPI.root_doc+"/ajax/search.php",method:"GET",data:a}).then((t=>{if(!(typeof t==="string"&&t.includes("search-card"))){n();return}r.html(t);this.getElement().trigger("search_refresh",[this.getElement()]);this.hideLoadingSpinner();this.shiftSelectAllCheckbox()}),(()=>{n()}))}catch(t){n()}}shiftSelectAllCheckbox(){$("#"+this.element_id+' input[type="checkbox"]').shiftSelectable()}registerListeners(){super.registerListeners();const t=this.getResultsView().getAJAXContainer();const e=t.closest(".search-container");$(t).on("click","table.search-results th[data-searchopt-id]",(t=>{t.stopPropagation();const e=$(t.target).closest("th").get(0);if($(e).data("nosort")){return}if(t.ctrlKey||t.metaKey){this.onColumnSortClick(e,true)}else{this.onColumnSortClick(e,false)}}));$(t).on("change","select.search-limit-dropdown",(t=>{this.onLimitChange(t.target)}));$(t).on("click",".pagination .page-link",(t=>{t.preventDefault();this.onPageChange(t.target)}));$(e).on("click",'.search-form-container button[name="search"]',(t=>{t.preventDefault();this.onSearch()}))}getItemtype(){return this.getElement().closest("form").attr("data-search-itemtype")}getSortState(){const t=this.getElement().find('thead th[data-searchopt-id]:not([data-searchopt-id=""])[data-sort-order]:not([data-sort-order=""])');if(t.length===0){return null}const e={sort:[],order:[]};t.each(((t,s)=>{const r=$(s);const a=r.attr("data-sort-order");if(a!=="nosort"){e["sort"][r.attr("data-sort-num")||0]=r.attr("data-searchopt-id");e["order"][r.attr("data-sort-num")||0]=a}}));return e}};

Zerion Mini Shell 1.0