From 84f428fb4bac6df84afab22d34392df2053c39b1 Mon Sep 17 00:00:00 2001 From: Andrei Onita Date: Thu, 22 Jun 2023 14:34:38 +0300 Subject: [PATCH] updated selector --- public/js/app.js | 2 +- src/App/assets/js/components/_bootstrap-table.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 7b41bcc..26b1402 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,4 +1,4 @@ -(()=>{var t={663:()=>{$(document).ready((function(){$("#adminEditButton").prop("disabled",!0),$("#adminDeleteButton").prop("disabled",!0),$("#adminAddButton").click((function(){$.get("/admin/add").done((function(t){$("#formModalTitle").html("Add Admin"),$("#formPlaceholder").html(t),$("#formMessages").empty(),$("#formModal").modal("show")})).fail((function(t){showFailDialog(t)}))})),$("#adminEditButton").click((function(){var t=$("#bsTable").bootstrapTable("getSelections");1!=t.length?showAlertDialog("Selection error","Multiple or no Admin selected. Only one Admin can be edited a time","error"):$.get("/admin/edit/"+t[0].uuid).done((function(t){$("#formModalTitle").html("Edit Admin"),$("#formPlaceholder").html(t),$("#formMessages").empty(),$("#formModal").modal("show")})).fail((function(t){showFailDialog(t)}))})),$("#adminDeleteButton").click((function(){var t=$("#bsTable").bootstrapTable("getSelections");0!==t.length&&($("#deleteFormPlaceholder").text("Are you sure you want to delete "+t[0].identity+"?"),$("#deleteFormMessages").empty(),$("#deleteFormModal").modal("show"))})),$("#deleteAdminFormModalSubmit").click((function(){var t=$("#bsTable").bootstrapTable("getSelections");$("#deleteFormModal").modal("handleUpdate"),$.post("/admin/delete",t[0]).done((function(t){"success"==t.success?($("#deleteFormMessages").html('"),$("#bsTable").bootstrapTable("refresh"),setTimeout((function(){$("#deleteFormModal").modal("hide")}),1500)):($("#deleteFormMessages").html('"),e.push("")}}}catch(t){n=!0,s=t}finally{try{i||null==r.return||r.return()}finally{if(n)throw s}}this.options.height||this.$tableFooter.length||(this.$el.append(""),this.$tableFooter=this.$el.find("tfoot")),this.$tableFooter.find("tr").html(e.join("")),this.trigger("post-footer",this.$tableFooter)}}},{key:"fitFooter",value:function(){var e=this;if(this.$el.is(":hidden"))setTimeout((function(){return e.fitFooter()}),100);else{var i=this.$tableBody.get(0),n=i.scrollWidth>i.clientWidth&&i.scrollHeight>i.clientHeight+this.$header.outerHeight()?or.getScrollBarWidth():0;this.$tableFooter.css("margin-right",n).find("table").css("width",this.$el.outerWidth()).attr("class",this.$el.attr("class")),this.getVisibleFields();for(var s=this.$tableFooter.find("th"),o=this.$body.find(">tr:first-child:not(.no-records-found)");o.length&&o.find('>td[colspan]:not([colspan="1"])').length;)o=o.next();o.find("> *").each((function(i,n){var o=t(n),r=i;if(e.options.detailView&&!e.options.cardView){if(0===i){var a=s.filter(".detail"),l=a.innerWidth()-a.find(".fht-cell").width();a.find(".fht-cell").width(o.innerWidth()-l)}r=i-1}if(-1!==r){var h=s.eq(i),c=h.innerWidth()-h.find(".fht-cell").width();h.find(".fht-cell").width(o.innerWidth()-c)}})),this.horizontalScroll()}}},{key:"horizontalScroll",value:function(){var t=this;this.$tableBody.off("scroll").on("scroll",(function(){var e=t.$tableBody.scrollLeft();t.options.showHeader&&t.options.height&&t.$tableHeader.scrollLeft(e),t.options.showFooter&&!t.options.cardView&&t.$tableFooter.scrollLeft(e),t.trigger("scroll-body",t.$tableBody)}))}},{key:"getVisibleFields",value:function(){var t=[],e=!0,i=!1,n=void 0;try{for(var s,o=this.header.fields[Symbol.iterator]();!(e=(s=o.next()).done);e=!0){var r=s.value,a=this.columns[this.fieldsColumnsIndex[r]];a&&a.visible&&t.push(r)}}catch(t){i=!0,n=t}finally{try{e||null==o.return||o.return()}finally{if(i)throw n}}return t}},{key:"initHiddenRows",value:function(){this.hiddenRows=[]}},{key:"getOptions",value:function(){var e=t.extend({},this.options);return delete e.data,t.extend(!0,{},e)}},{key:"refreshOptions",value:function(e){or.compareObjects(this.options,e,!0)||(this.options=t.extend(this.options,e),this.trigger("refresh-options",this.options),this.destroy(),this.init())}},{key:"getData",value:function(t){var e=this.options.data;if(!(this.searchText||this.options.customSearch||this.options.sortName)&&or.isEmptyObject(this.filterColumns)&&or.isEmptyObject(this.filterColumnsPartial)||t&&t.unfiltered||(e=this.data),t&&t.useCurrentPage&&(e=e.slice(this.pageFrom-1,this.pageTo)),t&&!t.includeHiddenRows){var i=this.getHiddenRows();e=e.filter((function(t){return-1===or.findIndex(i,t)}))}return e}},{key:"getSelections",value:function(){var t=this;return this.data.filter((function(e){return!0===e[t.header.stateField]}))}},{key:"getAllSelections",value:function(){var t=this;return this.options.data.filter((function(e){return!0===e[t.header.stateField]}))}},{key:"load",value:function(t){var e=!1,i=t;this.options.pagination&&"server"===this.options.sidePagination&&(this.options.totalRows=i[this.options.totalField]),this.options.pagination&&"server"===this.options.sidePagination&&(this.options.totalNotFiltered=i[this.options.totalNotFilteredField]),e=i.fixedScroll,i=Array.isArray(i)?i:i[this.options.dataField],this.initData(i),this.initSearch(),this.initPagination(),this.initBody(e)}},{key:"append",value:function(t){this.initData(t,"append"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)}},{key:"prepend",value:function(t){this.initData(t,"prepend"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)}},{key:"remove",value:function(t){var e,i,n=this.options.data.length;if(t.hasOwnProperty("field")&&t.hasOwnProperty("values")){for(e=n-1;e>=0;e--)(i=this.options.data[e]).hasOwnProperty(t.field)&&t.values.includes(i[t.field])&&(this.options.data.splice(e,1),"server"===this.options.sidePagination&&(this.options.totalRows-=1));n!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))}}},{key:"removeAll",value:function(){this.options.data.length>0&&(this.options.data.splice(0,this.options.data.length),this.initSearch(),this.initPagination(),this.initBody(!0))}},{key:"insertRow",value:function(t){t.hasOwnProperty("index")&&t.hasOwnProperty("row")&&(this.options.data.splice(t.index,0,t.row),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))}},{key:"updateRow",value:function(e){var i=Array.isArray(e)?e:[e],n=!0,s=!1,o=void 0;try{for(var r,a=i[Symbol.iterator]();!(n=(r=a.next()).done);n=!0){var l=r.value;l.hasOwnProperty("index")&&l.hasOwnProperty("row")&&(t.extend(this.options.data[l.index],l.row),l.hasOwnProperty("replace")&&l.replace?this.options.data[l.index]=l.row:t.extend(this.options.data[l.index],l.row))}}catch(t){s=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(s)throw o}}this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)}},{key:"getRowByUniqueId",value:function(t){var e,i,n,s=this.options.uniqueId,o=t,r=null;for(e=this.options.data.length-1;e>=0;e--){if((i=this.options.data[e]).hasOwnProperty(s))n=i[s];else{if(!i._data||!i._data.hasOwnProperty(s))continue;n=i._data[s]}if("string"==typeof n?o=o.toString():"number"==typeof n&&(Number(n)===n&&n%1==0?o=parseInt(o):n===Number(n)&&0!==n&&(o=parseFloat(o))),n===o){r=i;break}}return r}},{key:"updateByUniqueId",value:function(e){var i=Array.isArray(e)?e:[e],n=!0,s=!1,o=void 0;try{for(var r,a=i[Symbol.iterator]();!(n=(r=a.next()).done);n=!0){var l=r.value;if(l.hasOwnProperty("id")&&l.hasOwnProperty("row")){var h=this.options.data.indexOf(this.getRowByUniqueId(l.id));-1!==h&&(l.hasOwnProperty("replace")&&l.replace?this.options.data[h]=l.row:t.extend(this.options.data[h],l.row))}}}catch(t){s=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(s)throw o}}this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)}},{key:"removeByUniqueId",value:function(t){var e=this.options.data.length,i=this.getRowByUniqueId(t);i&&this.options.data.splice(this.options.data.indexOf(i),1),e!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initBody(!0))}},{key:"updateCell",value:function(t){t.hasOwnProperty("index")&&t.hasOwnProperty("field")&&t.hasOwnProperty("value")&&(this.data[t.index][t.field]=t.value,!1!==t.reinit&&(this.initSort(),this.initBody(!0)))}},{key:"updateCellByUniqueId",value:function(t){var e=this;t.hasOwnProperty("id")&&t.hasOwnProperty("field")&&t.hasOwnProperty("value")&&((Array.isArray(t)?t:[t]).forEach((function(t){var i=t.id,n=t.field,s=t.value,o=e.options.data.indexOf(e.getRowByUniqueId(i));-1!==o&&(e.options.data[o][n]=s)})),!1!==t.reinit&&(this.initSort(),this.initBody(!0)))}},{key:"showRow",value:function(t){this._toggleRow(t,!0)}},{key:"hideRow",value:function(t){this._toggleRow(t,!1)}},{key:"_toggleRow",value:function(t,e){var i;if(t.hasOwnProperty("index")?i=this.getData()[t.index]:t.hasOwnProperty("uniqueId")&&(i=this.getRowByUniqueId(t.uniqueId)),i){var n=or.findIndex(this.hiddenRows,i);e||-1!==n?e&&n>-1&&this.hiddenRows.splice(n,1):this.hiddenRows.push(i),e?this.updatePagination():(this.initBody(!0),this.initPagination())}}},{key:"getHiddenRows",value:function(t){if(t)return this.initHiddenRows(),void this.initBody(!0);var e=this.getData(),i=[],n=!0,s=!1,o=void 0;try{for(var r,a=e[Symbol.iterator]();!(n=(r=a.next()).done);n=!0){var l=r.value;this.hiddenRows.includes(l)&&i.push(l)}}catch(t){s=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(s)throw o}}return this.hiddenRows=i,i}},{key:"showColumn",value:function(t){var e=this;(Array.isArray(t)?t:[t]).forEach((function(t){e._toggleColumn(e.fieldsColumnsIndex[t],!0,!0)}))}},{key:"hideColumn",value:function(t){var e=this;(Array.isArray(t)?t:[t]).forEach((function(t){e._toggleColumn(e.fieldsColumnsIndex[t],!1,!0)}))}},{key:"_toggleColumn",value:function(t,e,i){if(-1!==t&&this.columns[t].visible!==e&&(this.columns[t].visible=e,this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns)){var n=this.$toolbar.find('.keep-open input:not(".toggle-all")').prop("disabled",!1);i&&n.filter(or.sprintf('[value="%s"]',t)).prop("checked",e),n.filter(":checked").length<=this.options.minimumCountColumns&&n.filter(":checked").prop("disabled",!0)}}},{key:"getVisibleColumns",value:function(){var t=this;return this.columns.filter((function(e){return e.visible&&!t.isSelectionColumn(e)}))}},{key:"getHiddenColumns",value:function(){return this.columns.filter((function(t){return!t.visible}))}},{key:"isSelectionColumn",value:function(t){return t.radio||t.checkbox}},{key:"showAllColumns",value:function(){this._toggleAllColumns(!0)}},{key:"hideAllColumns",value:function(){this._toggleAllColumns(!1)}},{key:"_toggleAllColumns",value:function(e){var i=this,n=!0,s=!1,o=void 0;try{for(var r,a=this.columns.slice().reverse()[Symbol.iterator]();!(n=(r=a.next()).done);n=!0){var l=r.value;if(l.switchable){if(!e&&this.options.showColumns&&this.getVisibleColumns().length===this.options.minimumCountColumns)continue;l.visible=e}}}catch(t){s=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(s)throw o}}if(this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns){var h=this.$toolbar.find('.keep-open input[type="checkbox"]:not(".toggle-all")').prop("disabled",!1);e?h.prop("checked",e):h.get().reverse().forEach((function(n){h.filter(":checked").length>i.options.minimumCountColumns&&t(n).prop("checked",e)})),h.filter(":checked").length<=this.options.minimumCountColumns&&h.filter(":checked").prop("disabled",!0)}}},{key:"mergeCells",value:function(t){var e,i,n=t.index,s=this.getVisibleFields().indexOf(t.field),o=t.rowspan||1,r=t.colspan||1,a=this.$body.find(">tr");this.options.detailView&&!this.options.cardView&&(s+=1);var l=a.eq(n).find(">td").eq(s);if(!(n<0||s<0||n>=this.data.length)){for(e=n;etd").eq(i).hide();l.attr("rowspan",o).attr("colspan",r).show()}}},{key:"checkAll",value:function(){this._toggleCheckAll(!0)}},{key:"uncheckAll",value:function(){this._toggleCheckAll(!1)}},{key:"_toggleCheckAll",value:function(t){var e=this.getSelections();this.$selectAll.add(this.$selectAll_).prop("checked",t),this.$selectItem.filter(":enabled").prop("checked",t),this.updateRows();var i=this.getSelections();t?this.trigger("check-all",i,e):this.trigger("uncheck-all",i,e)}},{key:"checkInvert",value:function(){var e=this.$selectItem.filter(":enabled"),i=e.filter(":checked");e.each((function(e,i){t(i).prop("checked",!t(i).prop("checked"))})),this.updateRows(),this.updateSelected(),this.trigger("uncheck-some",i),i=this.getSelections(),this.trigger("check-some",i)}},{key:"check",value:function(t){this._toggleCheck(!0,t)}},{key:"uncheck",value:function(t){this._toggleCheck(!1,t)}},{key:"_toggleCheck",value:function(t,e){var i=this.$selectItem.filter('[data-index="'.concat(e,'"]')),n=this.data[e];if(i.is(":radio")||this.options.singleSelect||this.options.multipleSelectRow&&!this.multipleSelectRowCtrlKey&&!this.multipleSelectRowShiftKey){var s=!0,o=!1,r=void 0;try{for(var a,l=this.options.data[Symbol.iterator]();!(s=(a=l.next()).done);s=!0)a.value[this.header.stateField]=!1}catch(t){o=!0,r=t}finally{try{s||null==l.return||l.return()}finally{if(o)throw r}}this.$selectItem.filter(":checked").not(i).prop("checked",!1)}if(n[this.header.stateField]=t,this.options.multipleSelectRow){if(this.multipleSelectRowShiftKey&&this.multipleSelectRowLastSelectedIndex>=0)for(var h=[this.multipleSelectRowLastSelectedIndex,e].sort(),c=h[0]+1;c0&&this.$selectItem.length===this.$selectItem.filter(":checked").length),this.$tableContainer.toggleClass("has-card-view",this.options.cardView),!this.options.cardView&&this.options.showHeader&&this.options.height?(this.$tableHeader.show(),this.resetHeader(),e+=this.$header.outerHeight(!0)+1):(this.$tableHeader.hide(),this.trigger("post-header")),!this.options.cardView&&this.options.showFooter&&(this.$tableFooter.show(),this.fitFooter(),this.options.height&&(e+=this.$tableFooter.outerHeight(!0))),this.$container.hasClass("fullscreen"))this.$tableContainer.css("height",""),this.$tableContainer.css("width","");else if(this.options.height){var i=this.$toolbar.outerHeight(!0),n=this.$pagination.outerHeight(!0),s=this.options.height-i-n,o=this.$tableBody.find(">table"),r=o.outerHeight();if(this.$tableContainer.css("height","".concat(s,"px")),this.$tableBorder){var a=s-r-2;this.$tableBody[0].scrollWidth-this.$tableBody.innerWidth()&&(a-=or.getScrollBarWidth()),this.$tableBorder.css("width","".concat(o.outerWidth(),"px")),this.$tableBorder.css("height","".concat(a,"px"))}}this.options.cardView?(this.$el.css("margin-top","0"),this.$tableContainer.css("padding-bottom","0"),this.$tableFooter.hide()):(this.getCaret(),this.$tableContainer.css("padding-bottom","".concat(e,"px"))),this.trigger("reset-view")}},{key:"showLoading",value:function(){this.$tableLoading.css("display","flex")}},{key:"hideLoading",value:function(){this.$tableLoading.css("display","none")}},{key:"togglePagination",value:function(){this.options.pagination=!this.options.pagination;var t=this.options.showButtonIcons?this.options.pagination?this.options.icons.paginationSwitchDown:this.options.icons.paginationSwitchUp:"",e=this.options.showButtonText?this.options.pagination?this.options.formatPaginationSwitchUp():this.options.formatPaginationSwitchDown():"";this.$toolbar.find('button[name="paginationSwitch"]').html(or.sprintf(this.constants.html.icon,this.options.iconsPrefix,t)+" "+e),this.updatePagination()}},{key:"toggleFullscreen",value:function(){this.$el.closest(".bootstrap-table").toggleClass("fullscreen"),this.resetView()}},{key:"toggleView",value:function(){this.options.cardView=!this.options.cardView,this.initHeader();var t=this.options.showButtonIcons?this.options.cardView?this.options.icons.toggleOn:this.options.icons.toggleOff:"",e=this.options.showButtonText?this.options.cardView?this.options.formatToggleOff():this.options.formatToggleOn():"";this.$toolbar.find('button[name="toggle"]').html(or.sprintf(this.constants.html.icon,this.options.iconsPrefix,t)+" "+e),this.initBody(),this.trigger("toggle",this.options.cardView)}},{key:"resetSearch",value:function(t){var e=this.$toolbar.find(".search input");e.val(t||""),this.onSearch({currentTarget:e})}},{key:"filterBy",value:function(e,i){this.filterOptions=or.isEmptyObject(i)?this.options.filterOptions:t.extend(this.options.filterOptions,i),this.filterColumns=or.isEmptyObject(e)?{}:e,this.options.pageNumber=1,this.initSearch(),this.updatePagination()}},{key:"scrollTo",value:function(e){if(void 0===e)return this.$tableBody.scrollTop();var i={unit:"px",value:0};"object"===Fo(e)?i=Object.assign(i,e):"string"==typeof e&&"bottom"===e?i.value=this.$tableBody[0].scrollHeight:"string"==typeof e&&(i.value=e);var n=i.value;"rows"===i.unit&&(n=0,this.$body.find("> tr:lt(".concat(i.value,")")).each((function(e,i){n+=t(i).outerHeight(!0)}))),this.$tableBody.scrollTop(n)}},{key:"getScrollPosition",value:function(){return this.scrollTo()}},{key:"selectPage",value:function(t){t>0&&t<=this.options.totalPages&&(this.options.pageNumber=t,this.updatePagination())}},{key:"prevPage",value:function(){this.options.pageNumber>1&&(this.options.pageNumber--,this.updatePagination())}},{key:"nextPage",value:function(){this.options.pageNumber tr[data-index="%s"]',t)).next().is("tr.detail-view")?this.collapseRow(t):this.expandRow(t,e),this.resetView()}},{key:"expandRow",value:function(t,e){var i=this.data[t],n=this.$body.find(or.sprintf('> tr[data-index="%s"][data-has-detail-view]',t));if(!n.next().is("tr.detail-view")){this.options.detailViewIcon&&n.find("a.detail-icon").html(or.sprintf(this.constants.html.icon,this.options.iconsPrefix,this.options.icons.detailClose)),n.after(or.sprintf('',n.children("td").length));var s=n.next().find("td"),o=e||this.options.detailFormatter,r=or.calculateObjectValue(this.options,o,[t,i,s],"");1===s.length&&s.append(r),this.trigger("expand-row",t,i,s)}}},{key:"collapseRow",value:function(t){var e=this.data[t],i=this.$body.find(or.sprintf('> tr[data-index="%s"][data-has-detail-view]',t));i.next().is("tr.detail-view")&&(this.options.detailViewIcon&&i.find("a.detail-icon").html(or.sprintf(this.constants.html.icon,this.options.iconsPrefix,this.options.icons.detailOpen)),this.trigger("collapse-row",t,e,i.next()),i.next().remove())}},{key:"expandAllRows",value:function(){for(var e=this.$body.find("> tr[data-index][data-has-detail-view]"),i=0;i tr[data-index][data-has-detail-view]"),i=0;i1?i-1:0),s=1;s{$(document).ready((function(){var t=function(t){var e=t.length;0==e?($("#adminEditButton").prop("disabled",!0),$("#adminDeleteButton").prop("disabled",!0)):1==e?($("#adminEditButton").prop("disabled",!1),$("#adminDeleteButton").prop("disabled",!1)):($("#adminEditButton").prop("disabled",!0),$("#adminDeleteButton").prop("disabled",!1))};$("#formModalSubmit").click((function(){$("#formModal").modal("handleUpdate"),$("#loading").modal({backdrop:!1,show:!0});let t=$("#ajaxForm"),e=new FormData(document.querySelector("#ajaxForm"));$.ajax({url:t.attr("action"),data:e,processData:!1,contentType:!1,type:t.attr("method")}).done((function(t){"success"===t.success?($("#loading").modal("hide"),$("#formMessages").html('"),$("#bsTable").bootstrapTable("refresh"),setTimeout((function(){$("#formModal").modal("hide")}),1500)):($("#loading").modal("hide"),$("#formMessages").html('