@momsfriendlydevco/angular-ui-query-builder
Advanced tools
Comparing version 1.3.16 to 1.3.18
@@ -516,3 +516,3 @@ "use strict"; | ||
}, | ||
template: "\n\t\t<nav>\n\t\t\t<ul class=\"pager\">\n\t\t\t\t<li ng-class=\"canPrev ? '' : 'disabled'\" class=\"previous\"><a ng-click=\"navPageRelative(-1)\"><i ng-class=\"qbTableSettings.icons.paginationPrev\"></i></a></li>\n\t\t\t\t<ng-transclude class=\"text-center\">\n\t\t\t\t\t<span ng-if=\"qbTableSettings.pagination.showXOfY && showRange.end\" class=\"display-xofy\">\n\t\t\t\t\t\tShowing documents {{showRange.start | number}} - {{showRange.end | number}}\n\t\t\t\t\t\t<span ng-if=\"showRange.total\">\n\t\t\t\t\t\t\tof {{showRange.total | number}}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<ul ng-if=\"qbTableSettings.pagination.showPages && showRange.end && pages.max > 1\" class=\"display-pages pagination\">\n\t\t\t\t\t\t<li ng-repeat=\"page in pages.range track by page.number\" ng-class=\"page.mode == 'current' ? 'active' : ''\">\n\t\t\t\t\t\t\t<a ng-click=\"navPageNumber(page.number)\">\n\t\t\t\t\t\t\t\t{{page.number + 1 | number}}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</ng-transclude>\n\t\t\t\t<li ng-class=\"canNext ? '' : 'disabled'\" class=\"next\"><a ng-click=\"navPageRelative(1)\"><i ng-class=\"qbTableSettings.icons.paginationNext\"></i></a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t" | ||
template: "\n\t\t<nav>\n\t\t\t<ul class=\"pager\">\n\t\t\t\t<li ng-class=\"canPrev ? '' : 'disabled'\" class=\"previous\"><a ng-click=\"canPrev && navPageRelative(-1)\"><i ng-class=\"qbTableSettings.icons.paginationPrev\"></i></a></li>\n\t\t\t\t<ng-transclude class=\"text-center\">\n\t\t\t\t\t<span ng-if=\"qbTableSettings.pagination.showXOfY && showRange.end\" class=\"display-xofy\">\n\t\t\t\t\t\tShowing documents {{showRange.start | number}} - {{showRange.end | number}}\n\t\t\t\t\t\t<span ng-if=\"showRange.total\">\n\t\t\t\t\t\t\tof {{showRange.total | number}}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<ul ng-if=\"qbTableSettings.pagination.showPages && showRange.end && pages.max > 1\" class=\"display-pages pagination\">\n\t\t\t\t\t\t<li ng-repeat=\"page in pages.range track by page.number\" ng-class=\"page.mode == 'current' ? 'active' : ''\">\n\t\t\t\t\t\t\t<a ng-click=\"navPageNumber(page.number)\">\n\t\t\t\t\t\t\t\t{{page.number + 1 | number}}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</ng-transclude>\n\t\t\t\t<li ng-class=\"canNext ? '' : 'disabled'\" class=\"next\"><a ng-click=\"canNext && navPageRelative(1)\"><i ng-class=\"qbTableSettings.icons.paginationNext\"></i></a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t" | ||
}; | ||
@@ -519,0 +519,0 @@ }) // }}} |
@@ -1,1 +0,1 @@ | ||
"use strict";function _defineProperty(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}angular.module("angular-ui-query-builder").provider("qbTableSettings",function(){var t=this;return t.debug=!1,t.debugPrefix="[angular-ui-query-builder]",t.icons={sortNone:"fa fa-fw fa-sort text-muted",sortAsc:"fa fa-fw fa-sort-alpha-asc text-primary",sortDesc:"fa fa-fw fa-sort-alpha-desc text-primary",checkMetaChecked:"fa fa-lg fa-fw fa-check-square-o text-primary",checkMetaSome:"fa fa-lg fa-fw fa-minus-square-o",checkMetaUnchecked:"fa fa-lg fa-fw fa-square-o",checkMetaCaret:"fa fa-caret-down",checkItemChecked:"fa fa-lg fa-fw fa-check-square-o",checkItemUnchecked:"fa fa-lg fa-fw fa-square-o",paginationPrev:"fa fa-arrow-left",paginationNext:"fa fa-arrow-right",modalClose:"fa fa-times",modalCollapseClosed:"fa fa-caret-right pull-right",search:"fa fa-search",searchClear:"fa fa-times"},t.pagination={showXOfY:!0,showPages:!0,pageRangeBack:5,pageRangeFore:5},t.export={defaults:{format:"xlsx"},formats:[{id:"xlsx",title:"Excel (XLSX)"},{id:"csv",title:"CSV"},{id:"json",title:"JSON"},{id:"html",title:"HTML (display in browser)"}],questions:[]},t.$get=function(){return t},t}).service("qbTableUtilities",function(){return{getSynopsis:function(t){var e=_.keys(t).filter(function(t){return!["sort","skip","limit","select"].includes(t)});return[e.length?1==e.length?"1 filter":"".concat(e.length," filters"):"All documents",t.sort?t.sort.startsWith("-")?"sorted by ".concat(t.sort.substr(1)," (reverse order)"):"sorted by ".concat(t.sort):null,t.limit?"limited to ".concat(t.limit," rows"):null,t.offset?"starting at record ".concat(t.skip):null,t.select?"selecting only ".concat(t.select.length," columns"):null].filter(function(t){return t}).join(", ")},find:function(t,e){var i,s=_.isFunction(e)?e:_.matches(e);return!!function n(t,a){return s(t,a.slice(a.length-1))?(i=a,!0):_.isArray(t)?t.some(function(t,e){return n(t,a.concat(e))}):_.isObject(t)?_.some(t,function(t,e){return n(t,a.concat(e))}):void 0}(t,[])&&i},escapeRegExp:function(t){return String(t).replace(/(\W)/g,"\\$1")},unescapeRegExp:function(t){return String(t).replace(/\\(\W)/g,"$1")}}}).directive("qbTable",function(){return{scope:{qbTable:"=?",count:"<?",stickyThead:"<?",stickyTfoot:"<?"},restrict:"AC",controller:["$attrs","$element","$rootScope","$scope","$timeout","qbTableSettings",function(t,e,n,i,a,s){var l=this;l.query=i.qbTable,l.count=i.count,i.$watch("count",function(){return l.count=i.count}),l.$broadcast=function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),a=1;a<e;a++)n[a-1]=arguments[a];return i.$broadcast.apply(i,[t].concat(n))},l.$on=function(t,e){return i.$on(t,e)},l.setDirty=function(){s.debug&&console.log(s.debugPrefix,"Declare query dirty",i.qbTable),n.$broadcast("queryBuilder.change",i.qbTable)},l.setField=function(t,e){if(null!=e){switch(t){case"sort":l.query.sort===e?l.query.sort="-".concat(e):(l.query.sort,"-".concat(e),l.query.sort=e);break;default:l.query[t]=i.qbTable[t]=e}return l}delete l.query[t]},e.addClass("qb-table"),i.$watch("stickyThead",function(){return e.toggleClass("qb-sticky-thead",i.stickyThead||""===t.stickyThead)}),i.$watch("stickyTfoot",function(){return e.toggleClass("qb-sticky-tfoot",i.stickyTfoot||""===t.stickyTfoot)}),i.$watch("count",function(){return e.toggleClass("qb-noresults",0===i.count)}),i.$on("queryBuilder.change.replace",function(t,e){e.skip=0,l.query=i.qbTable=e,a(function(){return l.setDirty()})})}]}}).directive("qbCol",function(){return{scope:{qbCol:"@",sortable:"@"},require:"^qbTable",restrict:"A",transclude:!0,controller:["$attrs","$element","$scope","$timeout","qbTableSettings",function(t,e,n,a,i){n.qbTableSettings=i;var s=n.$watchGroup(["qbTable","sortable"],function(){""===t.sortable&&!n.qbTable&&i.debug&&console.warn(i.debugPrefix,"Added qb-col + sortable onto element",e,"but no qb-table query has been assigned on the table element!"),s()});n.canSort=!1,n.isSorted=!1,this.$onInit=function(){n.canSort=n.sortable||""===t.sortable,e.toggleClass("sortable",n.canSort),n.canSort&&e.on("click",function(){return a(n.toggleSort)})},n.$watch("qbTable.query.sort",function(t){var e=n.sortable||n.qbCol;t?angular.isArray(t)&&t.some(function(t){return t==e})||t==e?n.isSorted="asc":angular.isArray(t)&&t.some(function(t){return t=="-"+e})||t=="-"+e?n.isSorted="desc":n.isSorted=!1:n.isSorted=!1}),n.toggleSort=function(){n.sortable?n.qbTable.setField("sort",n.sortable).setDirty():n.qbCol&&""===t.sortable&&n.qbTable.setField("sort",n.qbCol).setDirty()}}],link:function(t,e,n,a){t.qbTable=a},template:'\n\t\t<div class="qb-col-wrapper">\n\t\t\t<ng-transclude></ng-transclude>\n\t\t\t<a ng-if="canSort" ng-click="toggleSort()" class="qb-col-right">\n\t\t\t\t<i class="{{\n\t\t\t\t\tisSorted == \'asc\' ? qbTableSettings.icons.sortAsc\n\t\t\t\t\t: isSorted == \'desc\' ? qbTableSettings.icons.sortDesc\n\t\t\t\t\t: qbTableSettings.icons.sortNone\n\t\t\t\t}}"></i>\n\t\t\t</a>\n\t\t</div>\n\t'}}).directive("qbCell",function(){return{scope:{selector:"=?",onPreSelect:"&?",onSelect:"&?"},require:"^qbTable",restrict:"A",transclude:!0,controller:["$attrs","$element","$scope","$timeout","qbTableSettings",function(t,e,n,a,i){n.qbTableSettings=i,n.isMeta=0<e.parents("thead").length,n.isMeta&&a(function(){return n.qbTable.$on("qbTableCellSelect",function(){var t=[];n.qbTable.$broadcast("qbTableCellSelectStatus",t),n.metaStatus=t.every(function(t){return t})?"all":t.some(function(t){return t})?"some":"none"})}),n.isSelector="selector"in t,n.$watch("selector",function(){n.isSelector&&e.toggleClass("selector",n.isSelector),n.isSelector&&!n.isMeta&&e.parents("tr").toggleClass("selected",!!n.selector)}),n.isSelector&&!n.isMeta&&e.on("click",function(t){return n.$apply(function(){n.onPreSelect&&n.onPreSelect({value:n.selector}),n.selector=!n.selector,n.qbTable.$broadcast("qbTableCellSelect"),n.onSelect&&a(function(){return n.onSelect({value:n.selector})})})}),n.metaSelect=function(t){return n.qbTable.$broadcast("qbTableCellSelectMeta",t)},n.isSelector&&!n.isMeta&&a(function(){n.qbTable.$on("qbTableCellSelectMeta",function(t,e){switch(e){case"all":n.selector=!0;break;case"invert":n.selector=!n.selector;break;case"none":n.selector=!1;break;default:throw new Error("Unknown selection type: ".concat(e))}n.qbTable.$broadcast("qbTableCellSelect")}),n.qbTable.$on("qbTableCellSelectStatus",function(t,e){return e.push(n.selector)})}),e.addClass("qb-cell")}],link:function(t,e,n,a){t.qbTable=a},template:'\n\t\t<ng-transclude></ng-transclude>\n\t\t<div ng-if="isSelector && isMeta" class="btn-group">\n\t\t\t<a class="btn btn-default dropdown-toggle" data-toggle="dropdown">\n\t\t\t\t<i ng-class="metaStatus == \'all\' ? qbTableSettings.icons.checkMetaChecked : metaStatus == \'some\' ? qbTableSettings.icons.checkMetaUnchecked : qbTableSettings.icons.checkMetaUnchecked"></i>\n\t\t\t\t<i ng-class="qbTableSettings.icons.checkMetaCaret"></i>\n\t\t\t</a>\n\t\t\t<ul class="dropdown-menu">\n\t\t\t\t<li><a ng-click="metaSelect(\'all\')">All</a></li>\n\t\t\t\t<li><a ng-click="metaSelect(\'invert\')">Invert</a></li>\n\t\t\t\t<li><a ng-click="metaSelect(\'none\')">None</a></li>\n\t\t\t</ul>\n\t\t</div>\n\t\t<div ng-if="isSelector && !isMeta">\n\t\t\t<i ng-class="selector ? qbTableSettings.icons.checkItemChecked : qbTableSettings.icons.checkItemUnchecked"></i>\n\t\t</div>\n\t'}}).directive("qbPagination",function(){return{scope:{},require:"^qbTable",restrict:"EA",transclude:!0,controller:["$attrs","$scope","qbTableSettings",function(t,e,n){e.qbTableSettings=n,e.canPrev=!0,e.canNext=!0,e.showRange={},e.$watchGroup(["qbTable.query.limit","qbTable.query.skip","qbTable.count"],function(t){e.qbTable.query.limit&&"number"!=typeof e.qbTable.query.limit&&e.qbTable.setField("limit",parseInt(e.qbTable.query.limit,10)),e.qbTable.query.skip&&"number"!=typeof e.qbTable.query.skip&&e.qbTable.setField("skip",parseInt(e.qbTable.query.skip,10)),e.qbTable.query.count&&"number"!=typeof e.qbTable.query.count&&e.qbTable.setField("count",parseInt(e.qbTable.query.count,10)),e.canPrev=0<e.qbTable.query.skip,e.canNext=!e.qbTable.count||e.qbTable.query.skip+e.qbTable.query.limit<e.qbTable.count,n.pagination.showXOfY&&(e.showRange={start:(e.qbTable.query.skip||0)+1,end:Math.min((e.qbTable.query.skip||0)+e.qbTable.query.limit,e.qbTable.count),total:e.qbTable.count}),n.pagination.showPages&&(e.pages={current:!!e.qbTable.query.limit&&Math.floor((e.qbTable.query.skip||0)/e.qbTable.query.limit)},e.pages.min=Math.max(e.pages.current-n.pagination.pageRangeBack,0),e.pages.total=e.qbTable.query.limit?Math.ceil(e.qbTable.count/e.qbTable.query.limit):1,e.pages.max=Math.min(e.pages.total,e.pages.current+n.pagination.pageRangeFore+1),e.pages.range=_.range(e.pages.min,e.pages.max).map(function(t){return{number:t,mode:t==e.pages.current?"current":t==e.pages.current-1?"prev":t==e.pages.current+1?"next":"normal"}}))}),e.navPageRelative=function(t){if(-1==t)e.qbTable.setField("skip",Math.max((e.qbTable.query.skip||0)-(e.qbTable.query.limit||10),0)).setDirty();else{if(1!=t)throw new Error("Unsupported page move: "+t);e.qbTable.setField("skip",(e.qbTable.query.skip||0)+(e.qbTable.query.limit||10)).setDirty()}},e.navPageNumber=function(t){return e.qbTable.setField("skip",(t||0)*(e.qbTable.query.limit||10)).setDirty()}}],link:function(t,e,n,a){t.qbTable=a},template:'\n\t\t<nav>\n\t\t\t<ul class="pager">\n\t\t\t\t<li ng-class="canPrev ? \'\' : \'disabled\'" class="previous"><a ng-click="navPageRelative(-1)"><i ng-class="qbTableSettings.icons.paginationPrev"></i></a></li>\n\t\t\t\t<ng-transclude class="text-center">\n\t\t\t\t\t<span ng-if="qbTableSettings.pagination.showXOfY && showRange.end" class="display-xofy">\n\t\t\t\t\t\tShowing documents {{showRange.start | number}} - {{showRange.end | number}}\n\t\t\t\t\t\t<span ng-if="showRange.total">\n\t\t\t\t\t\t\tof {{showRange.total | number}}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<ul ng-if="qbTableSettings.pagination.showPages && showRange.end && pages.max > 1" class="display-pages pagination">\n\t\t\t\t\t\t<li ng-repeat="page in pages.range track by page.number" ng-class="page.mode == \'current\' ? \'active\' : \'\'">\n\t\t\t\t\t\t\t<a ng-click="navPageNumber(page.number)">\n\t\t\t\t\t\t\t\t{{page.number + 1 | number}}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</ng-transclude>\n\t\t\t\t<li ng-class="canNext ? \'\' : \'disabled\'" class="next"><a ng-click="navPageRelative(1)"><i ng-class="qbTableSettings.icons.paginationNext"></i></a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t'}}).directive("qbExport",function(){return{scope:{query:"<",spec:"<",url:"@"},transclude:!0,restrict:"EA",controller:["$element","$httpParamSerializerJQLike","$scope","$timeout","$window","qbTableSettings","qbTableUtilities",function(t,e,n,a,i,s,l){n.qbTableSettings=s,n.settings={},n.isShowing=!1,n.exportPrompt=function(){n.settings=angular.extend(angular.copy(s.export.defaults),{query:_(n.query).omitBy(function(t,e){return["skip","limit"].includes(e)}).value(),columns:_(n.spec).pickBy(function(t){return t&&t.type&&["string","number","data","boolean","objectid"].includes(t.type)}).map(function(t,e){return t.id=e,t.title=_.startCase(e),t.selected=!0,t}).value(),questions:_(s.export.questions).mapKeys(function(t){return t.id}).mapValues(function(t){return t.default}).value()}),t.find(".modal").on("show.bs.modal",function(){return a(function(){return n.isShowing=!0})}).on("hidden.bs.modal",function(){return a(function(){return n.isShowing=!1})}).modal("show")},n.exportExecute=function(){var t=angular.extend(n.settings.query,{select:n.settings.columns.filter(function(t){return t.selected}).map(function(t){return t.id}),format:n.settings.format},n.settings.questions);i.open(n.url+"?"+e(t))},n.querySynopsis,n.$watchGroup(["isShowing","settings.query"],function(){n.isShowing&&(n.querySynopsis=l.getSynopsis(n.settings.query))}),n.columnSynopsis,n.$watchGroup(["isShowing",function(){return _.get(n.settings,"columns",[]).map(function(t){return t.id+"="+t.selected}).join("&")}],function(){n.isShowing&&(n.columnSynopsis=n.settings.columns.filter(function(t){return t.selected}).length+" columns")})}],link:function(t,e){e.find("ng-transclude").on("click",function(){return t.$applyAsync(function(){return t.exportPrompt()})})},template:'\n\t\t<div class="modal fade">\n\t\t\t<div class="modal-dialog modal-lg">\n\t\t\t\t<div ng-if="isShowing" class="modal-content">\n\t\t\t\t\t<div class="modal-header">\n\t\t\t\t\t\t<a class="close" data-dismiss="modal"><i ng-class="qbTableSettings.icons.modalClose"></i></a>\n\t\t\t\t\t\t<h4 class="modal-title">Export</h4>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-body form-horizontal">\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Output format</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<select ng-model="settings.format" class="form-control">\n\t\t\t\t\t\t\t\t\t<option ng-repeat="format in qbTableSettings.export.formats track by format.id" value="{{format.id}}">{{format.title}}</option>\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Criteria</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<div class="panel-group" id="qb-export-criteria-{{$id}}">\n\t\t\t\t\t\t\t\t\t<div class="panel panel-default">\n\t\t\t\t\t\t\t\t\t\t<div class="panel-heading">\n\t\t\t\t\t\t\t\t\t\t\t<h4 class="panel-title">\n\t\t\t\t\t\t\t\t\t\t\t\t<a data-toggle="collapse" data-target="#qb-export-criteria-{{$id}}-query" data-parent="#qb-export-criteria-{{$id}}" class="btn-block collapsed">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{querySynopsis}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i ng-class="qbTableSettings.icons.modalCollapseClosed"></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<div id="qb-export-criteria-{{$id}}-query" class="panel-collapse collapse container">\n\t\t\t\t\t\t\t\t\t\t\t<ui-query-builder\n\t\t\t\t\t\t\t\t\t\t\t\tquery="settings.query"\n\t\t\t\t\t\t\t\t\t\t\t\tspec="spec"\n\t\t\t\t\t\t\t\t\t\t\t></ui-query-builder>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Columns</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<div class="panel-group" id="qb-export-columns-{{$id}}">\n\t\t\t\t\t\t\t\t\t<div class="panel panel-default">\n\t\t\t\t\t\t\t\t\t\t<div class="panel-heading">\n\t\t\t\t\t\t\t\t\t\t\t<h4 class="panel-title">\n\t\t\t\t\t\t\t\t\t\t\t\t<a data-toggle="collapse" data-target="#qb-export-columns-{{$id}}-columns" data-parent="#qb-export-columns-{{$id}}" class="btn-block collapsed">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{columnSynopsis}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i ng-class="qbTableSettings.icons.modalCollapseClosed"></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<div id="qb-export-columns-{{$id}}-columns" class="panel-collapse collapse row">\n\t\t\t\t\t\t\t\t\t\t\t<div class="col-xs-12">\n\t\t\t\t\t\t\t\t\t\t\t\t<table qb-table class="table table-hover">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<th qb-cell selector></th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<th>Column</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr ng-repeat="col in settings.columns track by col.id">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td qb-cell selector="col.selected"></td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>{{col.title}}</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div ng-repeat="question in qbTableSettings.export.questions track by question.id" class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">{{question.title}}</label>\n\t\t\t\t\t\t\t<div ng-switch="question.type" class="col-sm-9">\n\t\t\t\t\t\t\t\t<div ng-switch-when="text">\n\t\t\t\t\t\t\t\t\t<input type="text" ng-model="settings.questions[question.id]" class="form-control"/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div ng-switch-default>\n\t\t\t\t\t\t\t\t\t<div class="alert alert-danger">\n\t\t\t\t\t\t\t\t\t\tUnknown question type: "{{question.type}}"\n\t\t\t\t\t\t\t\t\t\t<pre>{{question | json}}</pre>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div ng-if="question.help" class="help-block">{{question.help}}</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-footer">\n\t\t\t\t\t\t<div class="pull-left">\n\t\t\t\t\t\t\t<a class="btn btn-danger" data-dismiss="modal">Cancel</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pull-right">\n\t\t\t\t\t\t\t<a ng-click="exportExecute()" class="btn btn-primary" data-dismiss="modal">Export</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<ng-transclude>\n\t\t\t<a ng-click="exportPrompt()" class="btn btn-default">Export...</a>\n\t\t</ng-transclude>\n\t'}}).directive("qbModal",function(){return{scope:{query:"=",spec:"<",title:"@?",onRefresh:"&?",binding:"@?"},transclude:!0,restrict:"A",controller:["$element","$scope","$rootScope","qbTableSettings",function(t,e,n,a){var i=this;e.qbTableSettings=a,i.isShown=!1,i.rebind=function(){t.one("click",function(){t.find(".qb-modal").one("hide.bs.modal",function(){i.isShown=!1}).one("hidden.bs.modal",function(){i.rebind()}).modal("show")})},e.submit=function(){angular.isFunction(i.onRefresh)&&i.onRefresh({query:e.queryCopy,spec:e.spec}),e.binding&&"complete"!=e.binding||(e.query=e.queryCopy),t.find(".qb-modal").modal("hide"),n.$broadcast("queryBuilder.change.replace",e.query)},i.$onInit=function(){e.queryCopy="live"==e.binding?e.query:angular.copy(e.query)},i.rebind()}],template:'\n\t\t<ng-transclude></ng-transclude>\n\t\t<div class="qb-modal modal fade">\n\t\t\t<div class="modal-dialog modal-lg">\n\t\t\t\t<div class="modal-content">\n\t\t\t\t\t<div class="modal-header">\n\t\t\t\t\t\t<a class="close" data-dismiss="modal"><i ng-class="qbTableSettings.icons.modalClose"></i></a>\n\t\t\t\t\t\t<h4 class="modal-title">{{title || \'Edit Filter\'}}</h4>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-body">\n\t\t\t\t\t\t<ui-query-builder\n\t\t\t\t\t\t\tquery="queryCopy"\n\t\t\t\t\t\t\tspec="spec"\n\t\t\t\t\t\t></ui-query-builder>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-footer">\n\t\t\t\t\t\t<div class="pull-left">\n\t\t\t\t\t\t\t<a class="btn btn-danger" data-dismiss="modal">Cancel</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pull-right">\n\t\t\t\t\t\t\t<a ng-click="submit()" class="btn btn-success">Refresh</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t'}}).directive("qbSearch",function(){return{scope:{query:"=",spec:"<",onRefresh:"&?",fields:"<?",useIndexes:"@?"},restrict:"AE",transclude:!0,controller:["$element","$scope","$rootScope","$timeout","qbTableSettings","qbTableUtilities",function(a,l,r,t,o,c){var u=this;l.qbTableSettings=o,l.search="",l.isSearching=!1,l.submit=function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(!l.search&&t)return l.clear(!1);var n=c.escapeRegExp(_.trim(l.search)),e={$comment:"search",$or:_(l.spec).pickBy(function(t){return"string"==t.type}).mapValues(function(t,e){return[{$regex:n,$options:"i"}]}).value()},a=c.find(l.query,{$comment:"search"}),i=angular.copy(l.query);if(a&&_.isEqual(a,["$comment"]))i=e;else if(a&&"$and"==a[0])_.set(i,a,e);else if(_.isEqual(_.keys(i),["$and"]))i.$and.push(e);else if(_.isObject(i)){var s=u.useIndexes||"auto";"auto"==s&&(s=_.keys(l.spec).some(function(t){return"_id"!=t&&l.spec[t].index})?"stringIndexed":"string"),l.fields?i.$or=_(l.fields).map(function(t){return _defineProperty({},t,{$regex:c.escapeRegExp(l.search),$options:"i"})}).value():i.$or=_(l.spec).pickBy(function(t,e){if("_id"==e)return!1;if(l.fields&&l.fields.length)return l.fields.includes(e);switch(s){case"all":return!0;case"string":return"string"==t.type;case"stringIndexed":return"string"==t.type&&t.index;default:throw new Error('Unknown field selection method: "'+s+'"')}}).map(function(t,e){return _defineProperty({},e,{$regex:c.escapeRegExp(l.search),$options:"i"})}).value()}else console.warn(o.debugPrefix,"Unable to inject search term",e,"within complex query object",i);l.isSearching=!0,r.$broadcast("queryBuilder.change.replace",i),angular.isFunction(u.onRefresh)&&u.onRefresh({query:i}),"complete"!=u.binding&&!angular.isUndefined(u.binding)||(l.query=i)},l.clear=function(){var t,e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],n=c.find(l.query,{$comment:"search"});if(l.isSearching=!1,l.search="",e&&angular.element(a).find("input").focus(),n&&_.isEqual(n,["$comment"]))t={};else if(n&&"$and"==n[0])(t=angular.copy(l.query)).$and.find(function(t,e){return"search"!=t.$comment});else if(n)t=angular.copy(l.query),_.unset(t,n);else{if(!l.query.$or||!l.query.$or.every(function(t){return 1==_.size(t)&&_.chain(t).first().keys().find(function(t){return"$regEx"==t})}))return o.debug?void console.warn(o.debugPrefix,"Unable to clear search query within complex query - or query doesnt contain a search anyway",l.query):void 0;delete(t=angular.copy(l.query)).$or}r.$broadcast("queryBuilder.change.replace",t),angular.isFunction(u.onRefresh)&&u.onRefresh({query:t}),"complete"!=u.binding&&!angular.isUndefined(u.binding)||(l.query=t)},l.check=function(){try{l.search=_.chain(l.query).get("$or").first().values().first().get("$regex").thru(function(t){return c.unescapeRegExp(t||"")}).value()}catch(t){l.search=""}},u.$onInit=function(){return l.check()}}],template:'\n\t\t<ng-transclude>\n\t\t\t<form ng-submit="submit()" class="form-inline">\n\t\t\t\t<div class="form-group">\n\t\t\t\t\t<div class="input-group">\n\t\t\t\t\t\t<input type="text" ng-model="search" class="form-control"/>\n\t\t\t\t\t\t<a ng-click="isSearching ? clear() : submit(false)" class="btn btn-default input-group-addon">\n\t\t\t\t\t\t\t<i ng-class="isSearching ? qbTableSettings.icons.searchClear : qbTableSettings.icons.search"/>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</ng-transclude>\n\t'}}); | ||
"use strict";function _defineProperty(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}angular.module("angular-ui-query-builder").provider("qbTableSettings",function(){var t=this;return t.debug=!1,t.debugPrefix="[angular-ui-query-builder]",t.icons={sortNone:"fa fa-fw fa-sort text-muted",sortAsc:"fa fa-fw fa-sort-alpha-asc text-primary",sortDesc:"fa fa-fw fa-sort-alpha-desc text-primary",checkMetaChecked:"fa fa-lg fa-fw fa-check-square-o text-primary",checkMetaSome:"fa fa-lg fa-fw fa-minus-square-o",checkMetaUnchecked:"fa fa-lg fa-fw fa-square-o",checkMetaCaret:"fa fa-caret-down",checkItemChecked:"fa fa-lg fa-fw fa-check-square-o",checkItemUnchecked:"fa fa-lg fa-fw fa-square-o",paginationPrev:"fa fa-arrow-left",paginationNext:"fa fa-arrow-right",modalClose:"fa fa-times",modalCollapseClosed:"fa fa-caret-right pull-right",search:"fa fa-search",searchClear:"fa fa-times"},t.pagination={showXOfY:!0,showPages:!0,pageRangeBack:5,pageRangeFore:5},t.export={defaults:{format:"xlsx"},formats:[{id:"xlsx",title:"Excel (XLSX)"},{id:"csv",title:"CSV"},{id:"json",title:"JSON"},{id:"html",title:"HTML (display in browser)"}],questions:[]},t.$get=function(){return t},t}).service("qbTableUtilities",function(){return{getSynopsis:function(t){var e=_.keys(t).filter(function(t){return!["sort","skip","limit","select"].includes(t)});return[e.length?1==e.length?"1 filter":"".concat(e.length," filters"):"All documents",t.sort?t.sort.startsWith("-")?"sorted by ".concat(t.sort.substr(1)," (reverse order)"):"sorted by ".concat(t.sort):null,t.limit?"limited to ".concat(t.limit," rows"):null,t.offset?"starting at record ".concat(t.skip):null,t.select?"selecting only ".concat(t.select.length," columns"):null].filter(function(t){return t}).join(", ")},find:function(t,e){var i,s=_.isFunction(e)?e:_.matches(e);return!!function n(t,a){return s(t,a.slice(a.length-1))?(i=a,!0):_.isArray(t)?t.some(function(t,e){return n(t,a.concat(e))}):_.isObject(t)?_.some(t,function(t,e){return n(t,a.concat(e))}):void 0}(t,[])&&i},escapeRegExp:function(t){return String(t).replace(/(\W)/g,"\\$1")},unescapeRegExp:function(t){return String(t).replace(/\\(\W)/g,"$1")}}}).directive("qbTable",function(){return{scope:{qbTable:"=?",count:"<?",stickyThead:"<?",stickyTfoot:"<?"},restrict:"AC",controller:["$attrs","$element","$rootScope","$scope","$timeout","qbTableSettings",function(t,e,n,i,a,s){var l=this;l.query=i.qbTable,l.count=i.count,i.$watch("count",function(){return l.count=i.count}),l.$broadcast=function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),a=1;a<e;a++)n[a-1]=arguments[a];return i.$broadcast.apply(i,[t].concat(n))},l.$on=function(t,e){return i.$on(t,e)},l.setDirty=function(){s.debug&&console.log(s.debugPrefix,"Declare query dirty",i.qbTable),n.$broadcast("queryBuilder.change",i.qbTable)},l.setField=function(t,e){if(null!=e){switch(t){case"sort":l.query.sort===e?l.query.sort="-".concat(e):(l.query.sort,"-".concat(e),l.query.sort=e);break;default:l.query[t]=i.qbTable[t]=e}return l}delete l.query[t]},e.addClass("qb-table"),i.$watch("stickyThead",function(){return e.toggleClass("qb-sticky-thead",i.stickyThead||""===t.stickyThead)}),i.$watch("stickyTfoot",function(){return e.toggleClass("qb-sticky-tfoot",i.stickyTfoot||""===t.stickyTfoot)}),i.$watch("count",function(){return e.toggleClass("qb-noresults",0===i.count)}),i.$on("queryBuilder.change.replace",function(t,e){e.skip=0,l.query=i.qbTable=e,a(function(){return l.setDirty()})})}]}}).directive("qbCol",function(){return{scope:{qbCol:"@",sortable:"@"},require:"^qbTable",restrict:"A",transclude:!0,controller:["$attrs","$element","$scope","$timeout","qbTableSettings",function(t,e,n,a,i){n.qbTableSettings=i;var s=n.$watchGroup(["qbTable","sortable"],function(){""===t.sortable&&!n.qbTable&&i.debug&&console.warn(i.debugPrefix,"Added qb-col + sortable onto element",e,"but no qb-table query has been assigned on the table element!"),s()});n.canSort=!1,n.isSorted=!1,this.$onInit=function(){n.canSort=n.sortable||""===t.sortable,e.toggleClass("sortable",n.canSort),n.canSort&&e.on("click",function(){return a(n.toggleSort)})},n.$watch("qbTable.query.sort",function(t){var e=n.sortable||n.qbCol;t?angular.isArray(t)&&t.some(function(t){return t==e})||t==e?n.isSorted="asc":angular.isArray(t)&&t.some(function(t){return t=="-"+e})||t=="-"+e?n.isSorted="desc":n.isSorted=!1:n.isSorted=!1}),n.toggleSort=function(){n.sortable?n.qbTable.setField("sort",n.sortable).setDirty():n.qbCol&&""===t.sortable&&n.qbTable.setField("sort",n.qbCol).setDirty()}}],link:function(t,e,n,a){t.qbTable=a},template:'\n\t\t<div class="qb-col-wrapper">\n\t\t\t<ng-transclude></ng-transclude>\n\t\t\t<a ng-if="canSort" ng-click="toggleSort()" class="qb-col-right">\n\t\t\t\t<i class="{{\n\t\t\t\t\tisSorted == \'asc\' ? qbTableSettings.icons.sortAsc\n\t\t\t\t\t: isSorted == \'desc\' ? qbTableSettings.icons.sortDesc\n\t\t\t\t\t: qbTableSettings.icons.sortNone\n\t\t\t\t}}"></i>\n\t\t\t</a>\n\t\t</div>\n\t'}}).directive("qbCell",function(){return{scope:{selector:"=?",onPreSelect:"&?",onSelect:"&?"},require:"^qbTable",restrict:"A",transclude:!0,controller:["$attrs","$element","$scope","$timeout","qbTableSettings",function(t,e,n,a,i){n.qbTableSettings=i,n.isMeta=0<e.parents("thead").length,n.isMeta&&a(function(){return n.qbTable.$on("qbTableCellSelect",function(){var t=[];n.qbTable.$broadcast("qbTableCellSelectStatus",t),n.metaStatus=t.every(function(t){return t})?"all":t.some(function(t){return t})?"some":"none"})}),n.isSelector="selector"in t,n.$watch("selector",function(){n.isSelector&&e.toggleClass("selector",n.isSelector),n.isSelector&&!n.isMeta&&e.parents("tr").toggleClass("selected",!!n.selector)}),n.isSelector&&!n.isMeta&&e.on("click",function(t){return n.$apply(function(){n.onPreSelect&&n.onPreSelect({value:n.selector}),n.selector=!n.selector,n.qbTable.$broadcast("qbTableCellSelect"),n.onSelect&&a(function(){return n.onSelect({value:n.selector})})})}),n.metaSelect=function(t){return n.qbTable.$broadcast("qbTableCellSelectMeta",t)},n.isSelector&&!n.isMeta&&a(function(){n.qbTable.$on("qbTableCellSelectMeta",function(t,e){switch(e){case"all":n.selector=!0;break;case"invert":n.selector=!n.selector;break;case"none":n.selector=!1;break;default:throw new Error("Unknown selection type: ".concat(e))}n.qbTable.$broadcast("qbTableCellSelect")}),n.qbTable.$on("qbTableCellSelectStatus",function(t,e){return e.push(n.selector)})}),e.addClass("qb-cell")}],link:function(t,e,n,a){t.qbTable=a},template:'\n\t\t<ng-transclude></ng-transclude>\n\t\t<div ng-if="isSelector && isMeta" class="btn-group">\n\t\t\t<a class="btn btn-default dropdown-toggle" data-toggle="dropdown">\n\t\t\t\t<i ng-class="metaStatus == \'all\' ? qbTableSettings.icons.checkMetaChecked : metaStatus == \'some\' ? qbTableSettings.icons.checkMetaUnchecked : qbTableSettings.icons.checkMetaUnchecked"></i>\n\t\t\t\t<i ng-class="qbTableSettings.icons.checkMetaCaret"></i>\n\t\t\t</a>\n\t\t\t<ul class="dropdown-menu">\n\t\t\t\t<li><a ng-click="metaSelect(\'all\')">All</a></li>\n\t\t\t\t<li><a ng-click="metaSelect(\'invert\')">Invert</a></li>\n\t\t\t\t<li><a ng-click="metaSelect(\'none\')">None</a></li>\n\t\t\t</ul>\n\t\t</div>\n\t\t<div ng-if="isSelector && !isMeta">\n\t\t\t<i ng-class="selector ? qbTableSettings.icons.checkItemChecked : qbTableSettings.icons.checkItemUnchecked"></i>\n\t\t</div>\n\t'}}).directive("qbPagination",function(){return{scope:{},require:"^qbTable",restrict:"EA",transclude:!0,controller:["$attrs","$scope","qbTableSettings",function(t,e,n){e.qbTableSettings=n,e.canPrev=!0,e.canNext=!0,e.showRange={},e.$watchGroup(["qbTable.query.limit","qbTable.query.skip","qbTable.count"],function(t){e.qbTable.query.limit&&"number"!=typeof e.qbTable.query.limit&&e.qbTable.setField("limit",parseInt(e.qbTable.query.limit,10)),e.qbTable.query.skip&&"number"!=typeof e.qbTable.query.skip&&e.qbTable.setField("skip",parseInt(e.qbTable.query.skip,10)),e.qbTable.query.count&&"number"!=typeof e.qbTable.query.count&&e.qbTable.setField("count",parseInt(e.qbTable.query.count,10)),e.canPrev=0<e.qbTable.query.skip,e.canNext=!e.qbTable.count||e.qbTable.query.skip+e.qbTable.query.limit<e.qbTable.count,n.pagination.showXOfY&&(e.showRange={start:(e.qbTable.query.skip||0)+1,end:Math.min((e.qbTable.query.skip||0)+e.qbTable.query.limit,e.qbTable.count),total:e.qbTable.count}),n.pagination.showPages&&(e.pages={current:!!e.qbTable.query.limit&&Math.floor((e.qbTable.query.skip||0)/e.qbTable.query.limit)},e.pages.min=Math.max(e.pages.current-n.pagination.pageRangeBack,0),e.pages.total=e.qbTable.query.limit?Math.ceil(e.qbTable.count/e.qbTable.query.limit):1,e.pages.max=Math.min(e.pages.total,e.pages.current+n.pagination.pageRangeFore+1),e.pages.range=_.range(e.pages.min,e.pages.max).map(function(t){return{number:t,mode:t==e.pages.current?"current":t==e.pages.current-1?"prev":t==e.pages.current+1?"next":"normal"}}))}),e.navPageRelative=function(t){if(-1==t)e.qbTable.setField("skip",Math.max((e.qbTable.query.skip||0)-(e.qbTable.query.limit||10),0)).setDirty();else{if(1!=t)throw new Error("Unsupported page move: "+t);e.qbTable.setField("skip",(e.qbTable.query.skip||0)+(e.qbTable.query.limit||10)).setDirty()}},e.navPageNumber=function(t){return e.qbTable.setField("skip",(t||0)*(e.qbTable.query.limit||10)).setDirty()}}],link:function(t,e,n,a){t.qbTable=a},template:'\n\t\t<nav>\n\t\t\t<ul class="pager">\n\t\t\t\t<li ng-class="canPrev ? \'\' : \'disabled\'" class="previous"><a ng-click="canPrev && navPageRelative(-1)"><i ng-class="qbTableSettings.icons.paginationPrev"></i></a></li>\n\t\t\t\t<ng-transclude class="text-center">\n\t\t\t\t\t<span ng-if="qbTableSettings.pagination.showXOfY && showRange.end" class="display-xofy">\n\t\t\t\t\t\tShowing documents {{showRange.start | number}} - {{showRange.end | number}}\n\t\t\t\t\t\t<span ng-if="showRange.total">\n\t\t\t\t\t\t\tof {{showRange.total | number}}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<ul ng-if="qbTableSettings.pagination.showPages && showRange.end && pages.max > 1" class="display-pages pagination">\n\t\t\t\t\t\t<li ng-repeat="page in pages.range track by page.number" ng-class="page.mode == \'current\' ? \'active\' : \'\'">\n\t\t\t\t\t\t\t<a ng-click="navPageNumber(page.number)">\n\t\t\t\t\t\t\t\t{{page.number + 1 | number}}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</ng-transclude>\n\t\t\t\t<li ng-class="canNext ? \'\' : \'disabled\'" class="next"><a ng-click="canNext && navPageRelative(1)"><i ng-class="qbTableSettings.icons.paginationNext"></i></a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t'}}).directive("qbExport",function(){return{scope:{query:"<",spec:"<",url:"@"},transclude:!0,restrict:"EA",controller:["$element","$httpParamSerializerJQLike","$scope","$timeout","$window","qbTableSettings","qbTableUtilities",function(t,e,n,a,i,s,l){n.qbTableSettings=s,n.settings={},n.isShowing=!1,n.exportPrompt=function(){n.settings=angular.extend(angular.copy(s.export.defaults),{query:_(n.query).omitBy(function(t,e){return["skip","limit"].includes(e)}).value(),columns:_(n.spec).pickBy(function(t){return t&&t.type&&["string","number","data","boolean","objectid"].includes(t.type)}).map(function(t,e){return t.id=e,t.title=_.startCase(e),t.selected=!0,t}).value(),questions:_(s.export.questions).mapKeys(function(t){return t.id}).mapValues(function(t){return t.default}).value()}),t.find(".modal").on("show.bs.modal",function(){return a(function(){return n.isShowing=!0})}).on("hidden.bs.modal",function(){return a(function(){return n.isShowing=!1})}).modal("show")},n.exportExecute=function(){var t=angular.extend(n.settings.query,{select:n.settings.columns.filter(function(t){return t.selected}).map(function(t){return t.id}),format:n.settings.format},n.settings.questions);i.open(n.url+"?"+e(t))},n.querySynopsis,n.$watchGroup(["isShowing","settings.query"],function(){n.isShowing&&(n.querySynopsis=l.getSynopsis(n.settings.query))}),n.columnSynopsis,n.$watchGroup(["isShowing",function(){return _.get(n.settings,"columns",[]).map(function(t){return t.id+"="+t.selected}).join("&")}],function(){n.isShowing&&(n.columnSynopsis=n.settings.columns.filter(function(t){return t.selected}).length+" columns")})}],link:function(t,e){e.find("ng-transclude").on("click",function(){return t.$applyAsync(function(){return t.exportPrompt()})})},template:'\n\t\t<div class="modal fade">\n\t\t\t<div class="modal-dialog modal-lg">\n\t\t\t\t<div ng-if="isShowing" class="modal-content">\n\t\t\t\t\t<div class="modal-header">\n\t\t\t\t\t\t<a class="close" data-dismiss="modal"><i ng-class="qbTableSettings.icons.modalClose"></i></a>\n\t\t\t\t\t\t<h4 class="modal-title">Export</h4>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-body form-horizontal">\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Output format</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<select ng-model="settings.format" class="form-control">\n\t\t\t\t\t\t\t\t\t<option ng-repeat="format in qbTableSettings.export.formats track by format.id" value="{{format.id}}">{{format.title}}</option>\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Criteria</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<div class="panel-group" id="qb-export-criteria-{{$id}}">\n\t\t\t\t\t\t\t\t\t<div class="panel panel-default">\n\t\t\t\t\t\t\t\t\t\t<div class="panel-heading">\n\t\t\t\t\t\t\t\t\t\t\t<h4 class="panel-title">\n\t\t\t\t\t\t\t\t\t\t\t\t<a data-toggle="collapse" data-target="#qb-export-criteria-{{$id}}-query" data-parent="#qb-export-criteria-{{$id}}" class="btn-block collapsed">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{querySynopsis}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i ng-class="qbTableSettings.icons.modalCollapseClosed"></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<div id="qb-export-criteria-{{$id}}-query" class="panel-collapse collapse container">\n\t\t\t\t\t\t\t\t\t\t\t<ui-query-builder\n\t\t\t\t\t\t\t\t\t\t\t\tquery="settings.query"\n\t\t\t\t\t\t\t\t\t\t\t\tspec="spec"\n\t\t\t\t\t\t\t\t\t\t\t></ui-query-builder>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Columns</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<div class="panel-group" id="qb-export-columns-{{$id}}">\n\t\t\t\t\t\t\t\t\t<div class="panel panel-default">\n\t\t\t\t\t\t\t\t\t\t<div class="panel-heading">\n\t\t\t\t\t\t\t\t\t\t\t<h4 class="panel-title">\n\t\t\t\t\t\t\t\t\t\t\t\t<a data-toggle="collapse" data-target="#qb-export-columns-{{$id}}-columns" data-parent="#qb-export-columns-{{$id}}" class="btn-block collapsed">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{columnSynopsis}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i ng-class="qbTableSettings.icons.modalCollapseClosed"></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<div id="qb-export-columns-{{$id}}-columns" class="panel-collapse collapse row">\n\t\t\t\t\t\t\t\t\t\t\t<div class="col-xs-12">\n\t\t\t\t\t\t\t\t\t\t\t\t<table qb-table class="table table-hover">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<th qb-cell selector></th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<th>Column</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr ng-repeat="col in settings.columns track by col.id">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td qb-cell selector="col.selected"></td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>{{col.title}}</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div ng-repeat="question in qbTableSettings.export.questions track by question.id" class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">{{question.title}}</label>\n\t\t\t\t\t\t\t<div ng-switch="question.type" class="col-sm-9">\n\t\t\t\t\t\t\t\t<div ng-switch-when="text">\n\t\t\t\t\t\t\t\t\t<input type="text" ng-model="settings.questions[question.id]" class="form-control"/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div ng-switch-default>\n\t\t\t\t\t\t\t\t\t<div class="alert alert-danger">\n\t\t\t\t\t\t\t\t\t\tUnknown question type: "{{question.type}}"\n\t\t\t\t\t\t\t\t\t\t<pre>{{question | json}}</pre>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div ng-if="question.help" class="help-block">{{question.help}}</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-footer">\n\t\t\t\t\t\t<div class="pull-left">\n\t\t\t\t\t\t\t<a class="btn btn-danger" data-dismiss="modal">Cancel</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pull-right">\n\t\t\t\t\t\t\t<a ng-click="exportExecute()" class="btn btn-primary" data-dismiss="modal">Export</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<ng-transclude>\n\t\t\t<a ng-click="exportPrompt()" class="btn btn-default">Export...</a>\n\t\t</ng-transclude>\n\t'}}).directive("qbModal",function(){return{scope:{query:"=",spec:"<",title:"@?",onRefresh:"&?",binding:"@?"},transclude:!0,restrict:"A",controller:["$element","$scope","$rootScope","qbTableSettings",function(t,e,n,a){var i=this;e.qbTableSettings=a,i.isShown=!1,i.rebind=function(){t.one("click",function(){t.find(".qb-modal").one("hide.bs.modal",function(){i.isShown=!1}).one("hidden.bs.modal",function(){i.rebind()}).modal("show")})},e.submit=function(){angular.isFunction(i.onRefresh)&&i.onRefresh({query:e.queryCopy,spec:e.spec}),e.binding&&"complete"!=e.binding||(e.query=e.queryCopy),t.find(".qb-modal").modal("hide"),n.$broadcast("queryBuilder.change.replace",e.query)},i.$onInit=function(){e.queryCopy="live"==e.binding?e.query:angular.copy(e.query)},i.rebind()}],template:'\n\t\t<ng-transclude></ng-transclude>\n\t\t<div class="qb-modal modal fade">\n\t\t\t<div class="modal-dialog modal-lg">\n\t\t\t\t<div class="modal-content">\n\t\t\t\t\t<div class="modal-header">\n\t\t\t\t\t\t<a class="close" data-dismiss="modal"><i ng-class="qbTableSettings.icons.modalClose"></i></a>\n\t\t\t\t\t\t<h4 class="modal-title">{{title || \'Edit Filter\'}}</h4>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-body">\n\t\t\t\t\t\t<ui-query-builder\n\t\t\t\t\t\t\tquery="queryCopy"\n\t\t\t\t\t\t\tspec="spec"\n\t\t\t\t\t\t></ui-query-builder>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-footer">\n\t\t\t\t\t\t<div class="pull-left">\n\t\t\t\t\t\t\t<a class="btn btn-danger" data-dismiss="modal">Cancel</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pull-right">\n\t\t\t\t\t\t\t<a ng-click="submit()" class="btn btn-success">Refresh</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t'}}).directive("qbSearch",function(){return{scope:{query:"=",spec:"<",onRefresh:"&?",fields:"<?",useIndexes:"@?"},restrict:"AE",transclude:!0,controller:["$element","$scope","$rootScope","$timeout","qbTableSettings","qbTableUtilities",function(a,l,r,t,o,c){var u=this;l.qbTableSettings=o,l.search="",l.isSearching=!1,l.submit=function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(!l.search&&t)return l.clear(!1);var n=c.escapeRegExp(_.trim(l.search)),e={$comment:"search",$or:_(l.spec).pickBy(function(t){return"string"==t.type}).mapValues(function(t,e){return[{$regex:n,$options:"i"}]}).value()},a=c.find(l.query,{$comment:"search"}),i=angular.copy(l.query);if(a&&_.isEqual(a,["$comment"]))i=e;else if(a&&"$and"==a[0])_.set(i,a,e);else if(_.isEqual(_.keys(i),["$and"]))i.$and.push(e);else if(_.isObject(i)){var s=u.useIndexes||"auto";"auto"==s&&(s=_.keys(l.spec).some(function(t){return"_id"!=t&&l.spec[t].index})?"stringIndexed":"string"),l.fields?i.$or=_(l.fields).map(function(t){return _defineProperty({},t,{$regex:c.escapeRegExp(l.search),$options:"i"})}).value():i.$or=_(l.spec).pickBy(function(t,e){if("_id"==e)return!1;if(l.fields&&l.fields.length)return l.fields.includes(e);switch(s){case"all":return!0;case"string":return"string"==t.type;case"stringIndexed":return"string"==t.type&&t.index;default:throw new Error('Unknown field selection method: "'+s+'"')}}).map(function(t,e){return _defineProperty({},e,{$regex:c.escapeRegExp(l.search),$options:"i"})}).value()}else console.warn(o.debugPrefix,"Unable to inject search term",e,"within complex query object",i);l.isSearching=!0,r.$broadcast("queryBuilder.change.replace",i),angular.isFunction(u.onRefresh)&&u.onRefresh({query:i}),"complete"!=u.binding&&!angular.isUndefined(u.binding)||(l.query=i)},l.clear=function(){var t,e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],n=c.find(l.query,{$comment:"search"});if(l.isSearching=!1,l.search="",e&&angular.element(a).find("input").focus(),n&&_.isEqual(n,["$comment"]))t={};else if(n&&"$and"==n[0])(t=angular.copy(l.query)).$and.find(function(t,e){return"search"!=t.$comment});else if(n)t=angular.copy(l.query),_.unset(t,n);else{if(!l.query.$or||!l.query.$or.every(function(t){return 1==_.size(t)&&_.chain(t).first().keys().find(function(t){return"$regEx"==t})}))return o.debug?void console.warn(o.debugPrefix,"Unable to clear search query within complex query - or query doesnt contain a search anyway",l.query):void 0;delete(t=angular.copy(l.query)).$or}r.$broadcast("queryBuilder.change.replace",t),angular.isFunction(u.onRefresh)&&u.onRefresh({query:t}),"complete"!=u.binding&&!angular.isUndefined(u.binding)||(l.query=t)},l.check=function(){try{l.search=_.chain(l.query).get("$or").first().values().first().get("$regex").thru(function(t){return c.unescapeRegExp(t||"")}).value()}catch(t){l.search=""}},u.$onInit=function(){return l.check()}}],template:'\n\t\t<ng-transclude>\n\t\t\t<form ng-submit="submit()" class="form-inline">\n\t\t\t\t<div class="form-group">\n\t\t\t\t\t<div class="input-group">\n\t\t\t\t\t\t<input type="text" ng-model="search" class="form-control"/>\n\t\t\t\t\t\t<a ng-click="isSearching ? clear() : submit(false)" class="btn btn-default input-group-addon">\n\t\t\t\t\t\t\t<i ng-class="isSearching ? qbTableSettings.icons.searchClear : qbTableSettings.icons.search"/>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</ng-transclude>\n\t'}}); |
@@ -1,1 +0,1 @@ | ||
"use strict";function _defineProperty(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}angular.module("angular-ui-query-builder",[]).service("QueryBuilder",function(){var a=this;a.cleanSpec=function(t){return _(t).mapValues(function(t,e){return{type:t.type,enum:_(t.enum).map(function(t){return _.isString(t)?{id:t,title:_.startCase(t)}:t}).sortBy("title").value()}}).value()},a.metaProperties={limit:{type:"keyVal",actions:[{id:"$eq",title:"Equals"}],action:"$eq",canDelete:!0},populate:{type:"hidden"},skip:{type:"keyVal",actions:[{id:"$eq",title:"Equals"}],action:"$eq",canDelete:!0},sort:{type:"keyVal",actions:[{id:"$eq",title:"Equals"}],action:"$eq",canDelete:!1}},a.queryPathPrototypeActions=[{id:"$eq",title:"Equals"},{id:"$neq",title:"Doesnt equal"},{id:"$lt",title:"Is less than"},{id:"$lte",title:"Is equal to or less than"},{id:"$gt",title:"Is greater than"},{id:"$gte",title:"Is equal or greater than"},{id:"$in",title:"Is one of"},{id:"$nin",title:"Is not one of"},{id:"$exists",title:"Has a value"},{id:"$nexists",title:"Does not have a value"}],a.queryPathPrototype=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length?arguments[2]:void 0,i=n[t],l=_.isObject(e)&&_(e).keys().first(),r=_.isObject(e)?_(e).values().first():e;return"$or"==t&&e.every(function(t){return _.isObject(t)&&1==_.keys(t).length})&&e.map(function(t){return _.chain(t).first().values().first().keys().find(function(t){return"$regexp"==t}).value()}).length==e.length?{path:t,type:"search",title:"Search",value:_.chain(e).first().values().first().get("$regexp").value(),fields:_(e).map(function(t){return _.keys(t)}).flatten().value(),actions:a.queryPathPrototypeActions}:"$and"==t||"$or"==t?(_.isArray(e)||(console.warn("query-builder","Query path",t,"is a meta key",e,"but is not an array!","Given",_typeof(e)),e=[]),{path:t,type:"binaryGroup",title:"$and"==t?"AND":"$or"==t?"OR":"UNKNOWN",condition:t.replace(/\$/,""),children:e.map(function(t){return a.queryToArray(t,n)}),actions:a.queryPathPrototypeActions}):a.metaProperties[t]?Object.assign({path:t,title:_.startCase(t),value:e,type:"hidden",action:"$hidden",actions:a.queryPathPrototypeActions},a.metaProperties[t]):"$exists"==l?{path:t,title:e.title||_.startCase(t),value:!!e,type:"exists",action:"$exists",actions:a.queryPathPrototypeActions}:"string"==i.type&&_.isArray(i.enum)&&i.enum.length?{path:t,title:e.title||_.startCase(t),type:"enum",action:e.$in?"$in":e.$nin?"$nin":i.enum.length?"$in":"$eq",enum:i.enum,value:e.$in?e.$in:e.$nin?e.$nin:i.enum.length&&!_.isArray(e)?[e]:e,actions:a.queryPathPrototypeActions}:{path:t,title:e.title||_.startCase(t),type:"string"==i.type?"string":"number"==i.type?"number":"date"==i.type?"date":"string",action:"$eq",value:"date"==i.type?moment(r).toDate():r,actions:a.queryPathPrototypeActions}},a.queryToArray=function(t,i){return _(t).pickBy(function(t,e){var n=i[e]||"$and"==e||"$or"==e||a.metaProperties[e];return n||console.warn("query-builder","Incomming query path",e,"Does not map to anything in spec",i),!!n}).map(function(t,e){return a.queryPathPrototype(e,t,i)}).value()},a.arrayToQuery=function(t){return _(t).mapKeys(function(t){return t.path}).mapValues(function(e){switch(e.type){case"string":case"number":case"date":return"$eq"==e.action?e.value:_defineProperty({},e.action,e.value);case"enum":return _defineProperty({},e.action,e.value);case"exists":return{$exists:"$exists"==e.action};case"search":return e.fields.map(function(t){return _defineProperty({},t,{$regexp:e.value,options:"i"})});case"keyVal":case"hidden":return e.value;default:console.warn("Unknown type to convert:",e.type)}}).value()}}).component("uiQueryBuilder",{bindings:{query:"=",spec:"<"},template:'\n\t\t<div class="ui-query-builder">\n\t\t\t<div ng-if="$ctrl.isEmpty">\n\t\t\t\t<ui-query-builder-group\n\t\t\t\t\tqb-group="$ctrl.emptyQueryLayout"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-group>\n\t\t\t</div>\n\t\t\t<div ng-if="!$ctrl.isEmpty" class="query-container">\n\t\t\t\t<ui-query-builder-group\n\t\t\t\t\tqb-group="$ctrl.qbQuery"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-group>\n\t\t\t</div>\n\t\t</div>\n\t',controller:["$scope","$timeout","QueryBuilder",function(l,r,a){var c=this;c.qbSpec,c.qbQuery;var t=l.$watchGroup(["$ctrl.query","$ctrl.spec"],function(){c.spec&&c.query&&(c.qbSpec=a.cleanSpec(c.spec),c.qbQuery=a.queryToArray(c.query,c.qbSpec),t())});l.$on("queryBuilder.change",function(t,e){return r(function(){e?(c.query=e,c.qbQuery=a.queryToArray(c.query,c.qbSpec)):c.query=a.arrayToQuery(c.qbQuery)})}),l.$on("queryBuilder.pathAction.drop",function(t,e){c.qbQuery=c.qbQuery.filter(function(t){return t.path!=e}),c.query=a.arrayToQuery(c.qbQuery)}),l.$on("queryBuilder.pathAction.swapPath",function(t,e,n){var i=c.qbQuery.findIndex(function(t){return t.path==e});if(i<0)throw new Error('Cannot find path "'.concat(e,'" to swap with new path "').concat(n,'"'));c.qbQuery[i]=a.queryPathPrototype(n,void 0,c.qbSpec),r(function(){return l.$broadcast("queryBuilder.focusOperand",n)})}),l.$on("queryBuilder.pathAction.swapAction",function(t,e,n){console.log("SWAPACTION",e,n)}),l.$on("queryBuilder.pathAction.add",function(t,e){e?console.warn("Adding a path to a sub-node is not yet supported"):(c.qbQuery.findIndex(function(t){return!t.path})&&c.qbQuery.push({path:"",type:"blank",value:null,fields:[]}),r(function(){return l.$broadcast("queryBuilder.focusPath","")}))}),c.emptyQueryLayout=[{type:"alert",title:"No query specified"}],c.isEmpty,l.$watchCollection("$ctrl.qbQuery",function(){return c.isEmpty=_.isEmpty(c.qbQuery)})}]}).component("uiQueryBuilderGroup",{bindings:{qbGroup:"=",qbSpec:"<"},template:'\n\t\t<div ng-repeat="row in $ctrl.qbGroup | filter:$ctrl.qbGroupFilter" meta-key="{{row.path}}">\n\t\t\t<ui-query-builder-row\n\t\t\t\tqb-item="row"\n\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t></ui-query-builder-row>\n\t\t</div>\n\t\t<button ng-click="$ctrl.add()" type="button" class="btn-add"></button>\n\t',controller:["$scope","QueryBuilder",function(t,e){this.add=function(){return t.$emit("queryBuilder.pathAction.add")},this.qbGroupFilter=function(t){return"hidden"!=t.type}}]}).component("uiQueryBuilderRow",{bindings:{qbItem:"=",qbSpec:"<"},controller:["$element","$scope","QueryBuilder",function(i,e,t){var l=this;l.delete=function(t){return e.$emit("queryBuilder.pathAction.drop",t)},l.setChanged=function(){return e.$emit("queryBuilder.change")},l.setAction=function(t){return e.$emit("queryBuilder.pathAction.swapAction",l.qbItem,t)},e.$on("queryBuilder.focusPath",function(t,e){l.qbItem.path==e&&i.find("ui-query-builder-path .dropdown-toggle").dropdown("toggle")}),e.$on("queryBuilder.focusOperand",function(t,e){if(l.qbItem.path==e){var n=i.find("input.form-control");if(1==n.length)return n.focus();console.warn("Unable to focus any element within DOM",i[0],"for type",l.type,"on line item",l.qbItem)}})}],template:'\n\t\t<div ng-switch="$ctrl.qbItem.type">\n\t\t\t\x3c!-- $and / $or condition {{{ --\x3e\n\t\t\t<div ng-switch-when="binaryGroup" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-1 btn-block">\n\t\t\t\t\t\t{{$ctrl.qbItem.title}}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div ng-repeat="conditional in $ctrl.qbItem.children" class="query-container clearfix">\n\t\t\t\t\t<ui-query-builder-group\n\t\t\t\t\t\tqb-group="conditional"\n\t\t\t\t\t\tqb-spec="$ctrl.spec"\n\t\t\t\t\t></ui-query-builder-group>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- String {{{ --\x3e\n\t\t\t<div ng-switch-when="string" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-3 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-model="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-change="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="text"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Enum {{{ --\x3e\n\t\t\t<div ng-switch-when="enum" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t\t<ui-query-builder-block-menu-multiple\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="3"\n\t\t\t\t\tselected="$ctrl.qbItem.value"\n\t\t\t\t\toptions="$ctrl.qbItem.enum"\n\t\t\t\t></ui-query-builder-block-menu-multiple>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Date {{{ --\x3e\n\t\t\t<div ng-switch-when="date" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-3 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-model="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-change="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="date"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Number {{{ --\x3e\n\t\t\t<div ng-switch-when="number" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-3 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-value="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-changed="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="number"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Exists {{{ --\x3e\n\t\t\t<div ng-switch-when="exists" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Search {{{ --\x3e\n\t\t\t<div ng-switch-when="search" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-2 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-model="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-change="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="text"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- keyVal (Only title + value) {{{ --\x3e\n\t\t\t<div ng-switch-when="keyVal" class="query-row">\n\t\t\t\t<a ng-if="$ctrl.qbItem.canDelete === undefined || $ctrl.qbItem.canDelete" ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-block\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\ttitle="$ctrl.qbItem.title"\n\t\t\t\t></ui-query-builder-block>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-2 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-model="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-change="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="text"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Blank (i.e. field not set yet) {{{ --\x3e\n\t\t\t<div ng-switch-when="blank" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Alert {{{ --\x3e\n\t\t\t<div ng-switch-when="alert" class="query-row">\n\t\t\t\t<div class="query-block query-block-2">\n\t\t\t\t\t<div class="btn btn-block btn-noclick" ng-bind="$ctrl.qbItem.title"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Unknown {{{ --\x3e\n\t\t\t<div ng-switch-default class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-warning btn-block">\n\t\t\t\t\t\tUnknown handler: {{$ctrl.qbItem.type}}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t</div>\n\t'}).component("uiQueryBuilderPath",{bindings:{level:"<",selected:"<",qbSpec:"<"},controller:["$scope",function(e){var n=this;n.setSelected=function(t){return e.$emit("queryBuilder.pathAction.swapPath",n.selected,t)},n.options,n.$onInit=function(){n.options=_.map(n.qbSpec,function(t,e){return Object.assign({},{path:e,title:_.startCase(e)},t)}),n.selectedOption=n.options.find(function(t){return t.path==n.selected})}}],template:'\n\t\t<a class="btn btn-block btn-{{$ctrl.level}} dropdown-toggle" data-toggle="dropdown" ng-bind="$ctrl.selectedOption.title"></a>\n\t\t<ul class="dropdown-menu">\n\t\t\t<li ng-repeat="path in $ctrl.options track by path.path"><a ng-click="$ctrl.setSelected(path.path)">{{path.title}}</a></li>\n\t\t</ul>\n\t'}).component("uiQueryBuilderBlock",{bindings:{level:"<",title:"<"},controller:["$scope",function(t){}],template:'\n\t\t<a class="btn btn-block btn-{{$ctrl.level}}">\n\t\t\t{{$ctrl.title}}\n\t\t</a>\n\t'}).component("uiQueryBuilderBlockMenu",{bindings:{level:"<",options:"<",selected:"=",onChange:"&?"},controller:["$scope",function(t){var e=this;e.setSelected=function(t){e.selected=t.id,angular.isFunction(e.onChange)&&e.onChange({selected:e.selected})},e.selectedOption,t.$watchGroup(["$ctrl.options","$ctrl.selected"],function(){e.selectedOption=e.options.find(function(t){return t.id==e.selected})})}],template:'\n\t\t<a class="btn btn-block btn-{{$ctrl.level}} dropdown-toggle" data-toggle="dropdown" ng-bind="$ctrl.selectedOption.title"></a>\n\t\t<ul class="dropdown-menu pull-right">\n\t\t\t<li ng-repeat="option in $ctrl.options track by option.id"><a ng-click="$ctrl.setSelected(option)">{{option.title}}</a></li>\n\t\t</ul>\n\t'}).component("uiQueryBuilderBlockMenuMultiple",{bindings:{level:"<",options:"<",selected:"="},controller:["$scope",function(t){var n=this;n.toggle=function(e){n.selected=n.selected.filter(function(t){return"string"==typeof t}),n.selected||(n.selected=[]),n.selected.includes(e.id)?n.selected=n.selected.filter(function(t){return t!=e.id}):n.selected.push(e.id),t.$emit("queryBuilder.change")},n.selectedOptions,t.$watch("$ctrl.selected",function(){n.selectedOptions=n.options.filter(function(t){return(n.selected||[]).includes(t.id)}),n.options.forEach(function(e){return e.selected=n.selectedOptions.some(function(t){return t.id==e.id})})},!0)}],template:'\n\t\t<a class="btn btn-block btn-{{$ctrl.level}} dropdown-toggle" data-toggle="dropdown">\n\t\t\t<span ng-repeat="item in $ctrl.selectedOptions track by item.id" class="pill">\n\t\t\t\t{{item.title}}\n\t\t\t</span>\n\t\t</a>\n\t\t<ul class="dropdown-menu">\n\t\t\t<li ng-repeat="option in $ctrl.options track by option.id">\n\t\t\t\t<a ng-click="$ctrl.toggle(option)">\n\t\t\t\t\t<i class="fa fa-fw" ng-class="option.selected ? \'fa-check-square-o\' : \'fa-square-o\'"></i>\n\t\t\t\t\t{{option.title}}\n\t\t\t\t</a>\n\t\t\t</li>\n\t\t</ul>\n\t'}),angular.module("angular-ui-query-builder").provider("qbTableSettings",function(){var t=this;return t.debug=!1,t.debugPrefix="[angular-ui-query-builder]",t.icons={sortNone:"fa fa-fw fa-sort text-muted",sortAsc:"fa fa-fw fa-sort-alpha-asc text-primary",sortDesc:"fa fa-fw fa-sort-alpha-desc text-primary",checkMetaChecked:"fa fa-lg fa-fw fa-check-square-o text-primary",checkMetaSome:"fa fa-lg fa-fw fa-minus-square-o",checkMetaUnchecked:"fa fa-lg fa-fw fa-square-o",checkMetaCaret:"fa fa-caret-down",checkItemChecked:"fa fa-lg fa-fw fa-check-square-o",checkItemUnchecked:"fa fa-lg fa-fw fa-square-o",paginationPrev:"fa fa-arrow-left",paginationNext:"fa fa-arrow-right",modalClose:"fa fa-times",modalCollapseClosed:"fa fa-caret-right pull-right",search:"fa fa-search",searchClear:"fa fa-times"},t.pagination={showXOfY:!0,showPages:!0,pageRangeBack:5,pageRangeFore:5},t.export={defaults:{format:"xlsx"},formats:[{id:"xlsx",title:"Excel (XLSX)"},{id:"csv",title:"CSV"},{id:"json",title:"JSON"},{id:"html",title:"HTML (display in browser)"}],questions:[]},t.$get=function(){return t},t}).service("qbTableUtilities",function(){return{getSynopsis:function(t){var e=_.keys(t).filter(function(t){return!["sort","skip","limit","select"].includes(t)});return[e.length?1==e.length?"1 filter":"".concat(e.length," filters"):"All documents",t.sort?t.sort.startsWith("-")?"sorted by ".concat(t.sort.substr(1)," (reverse order)"):"sorted by ".concat(t.sort):null,t.limit?"limited to ".concat(t.limit," rows"):null,t.offset?"starting at record ".concat(t.skip):null,t.select?"selecting only ".concat(t.select.length," columns"):null].filter(function(t){return t}).join(", ")},find:function(t,e){var l,r=_.isFunction(e)?e:_.matches(e);return!!function n(t,i){return r(t,i.slice(i.length-1))?(l=i,!0):_.isArray(t)?t.some(function(t,e){return n(t,i.concat(e))}):_.isObject(t)?_.some(t,function(t,e){return n(t,i.concat(e))}):void 0}(t,[])&&l},escapeRegExp:function(t){return String(t).replace(/(\W)/g,"\\$1")},unescapeRegExp:function(t){return String(t).replace(/\\(\W)/g,"$1")}}}).directive("qbTable",function(){return{scope:{qbTable:"=?",count:"<?",stickyThead:"<?",stickyTfoot:"<?"},restrict:"AC",controller:["$attrs","$element","$rootScope","$scope","$timeout","qbTableSettings",function(t,e,n,l,i,r){var a=this;a.query=l.qbTable,a.count=l.count,l.$watch("count",function(){return a.count=l.count}),a.$broadcast=function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return l.$broadcast.apply(l,[t].concat(n))},a.$on=function(t,e){return l.$on(t,e)},a.setDirty=function(){r.debug&&console.log(r.debugPrefix,"Declare query dirty",l.qbTable),n.$broadcast("queryBuilder.change",l.qbTable)},a.setField=function(t,e){if(null!=e){switch(t){case"sort":a.query.sort===e?a.query.sort="-".concat(e):(a.query.sort,"-".concat(e),a.query.sort=e);break;default:a.query[t]=l.qbTable[t]=e}return a}delete a.query[t]},e.addClass("qb-table"),l.$watch("stickyThead",function(){return e.toggleClass("qb-sticky-thead",l.stickyThead||""===t.stickyThead)}),l.$watch("stickyTfoot",function(){return e.toggleClass("qb-sticky-tfoot",l.stickyTfoot||""===t.stickyTfoot)}),l.$watch("count",function(){return e.toggleClass("qb-noresults",0===l.count)}),l.$on("queryBuilder.change.replace",function(t,e){e.skip=0,a.query=l.qbTable=e,i(function(){return a.setDirty()})})}]}}).directive("qbCol",function(){return{scope:{qbCol:"@",sortable:"@"},require:"^qbTable",restrict:"A",transclude:!0,controller:["$attrs","$element","$scope","$timeout","qbTableSettings",function(t,e,n,i,l){n.qbTableSettings=l;var r=n.$watchGroup(["qbTable","sortable"],function(){""===t.sortable&&!n.qbTable&&l.debug&&console.warn(l.debugPrefix,"Added qb-col + sortable onto element",e,"but no qb-table query has been assigned on the table element!"),r()});n.canSort=!1,n.isSorted=!1,this.$onInit=function(){n.canSort=n.sortable||""===t.sortable,e.toggleClass("sortable",n.canSort),n.canSort&&e.on("click",function(){return i(n.toggleSort)})},n.$watch("qbTable.query.sort",function(t){var e=n.sortable||n.qbCol;t?angular.isArray(t)&&t.some(function(t){return t==e})||t==e?n.isSorted="asc":angular.isArray(t)&&t.some(function(t){return t=="-"+e})||t=="-"+e?n.isSorted="desc":n.isSorted=!1:n.isSorted=!1}),n.toggleSort=function(){n.sortable?n.qbTable.setField("sort",n.sortable).setDirty():n.qbCol&&""===t.sortable&&n.qbTable.setField("sort",n.qbCol).setDirty()}}],link:function(t,e,n,i){t.qbTable=i},template:'\n\t\t<div class="qb-col-wrapper">\n\t\t\t<ng-transclude></ng-transclude>\n\t\t\t<a ng-if="canSort" ng-click="toggleSort()" class="qb-col-right">\n\t\t\t\t<i class="{{\n\t\t\t\t\tisSorted == \'asc\' ? qbTableSettings.icons.sortAsc\n\t\t\t\t\t: isSorted == \'desc\' ? qbTableSettings.icons.sortDesc\n\t\t\t\t\t: qbTableSettings.icons.sortNone\n\t\t\t\t}}"></i>\n\t\t\t</a>\n\t\t</div>\n\t'}}).directive("qbCell",function(){return{scope:{selector:"=?",onPreSelect:"&?",onSelect:"&?"},require:"^qbTable",restrict:"A",transclude:!0,controller:["$attrs","$element","$scope","$timeout","qbTableSettings",function(t,e,n,i,l){n.qbTableSettings=l,n.isMeta=0<e.parents("thead").length,n.isMeta&&i(function(){return n.qbTable.$on("qbTableCellSelect",function(){var t=[];n.qbTable.$broadcast("qbTableCellSelectStatus",t),n.metaStatus=t.every(function(t){return t})?"all":t.some(function(t){return t})?"some":"none"})}),n.isSelector="selector"in t,n.$watch("selector",function(){n.isSelector&&e.toggleClass("selector",n.isSelector),n.isSelector&&!n.isMeta&&e.parents("tr").toggleClass("selected",!!n.selector)}),n.isSelector&&!n.isMeta&&e.on("click",function(t){return n.$apply(function(){n.onPreSelect&&n.onPreSelect({value:n.selector}),n.selector=!n.selector,n.qbTable.$broadcast("qbTableCellSelect"),n.onSelect&&i(function(){return n.onSelect({value:n.selector})})})}),n.metaSelect=function(t){return n.qbTable.$broadcast("qbTableCellSelectMeta",t)},n.isSelector&&!n.isMeta&&i(function(){n.qbTable.$on("qbTableCellSelectMeta",function(t,e){switch(e){case"all":n.selector=!0;break;case"invert":n.selector=!n.selector;break;case"none":n.selector=!1;break;default:throw new Error("Unknown selection type: ".concat(e))}n.qbTable.$broadcast("qbTableCellSelect")}),n.qbTable.$on("qbTableCellSelectStatus",function(t,e){return e.push(n.selector)})}),e.addClass("qb-cell")}],link:function(t,e,n,i){t.qbTable=i},template:'\n\t\t<ng-transclude></ng-transclude>\n\t\t<div ng-if="isSelector && isMeta" class="btn-group">\n\t\t\t<a class="btn btn-default dropdown-toggle" data-toggle="dropdown">\n\t\t\t\t<i ng-class="metaStatus == \'all\' ? qbTableSettings.icons.checkMetaChecked : metaStatus == \'some\' ? qbTableSettings.icons.checkMetaUnchecked : qbTableSettings.icons.checkMetaUnchecked"></i>\n\t\t\t\t<i ng-class="qbTableSettings.icons.checkMetaCaret"></i>\n\t\t\t</a>\n\t\t\t<ul class="dropdown-menu">\n\t\t\t\t<li><a ng-click="metaSelect(\'all\')">All</a></li>\n\t\t\t\t<li><a ng-click="metaSelect(\'invert\')">Invert</a></li>\n\t\t\t\t<li><a ng-click="metaSelect(\'none\')">None</a></li>\n\t\t\t</ul>\n\t\t</div>\n\t\t<div ng-if="isSelector && !isMeta">\n\t\t\t<i ng-class="selector ? qbTableSettings.icons.checkItemChecked : qbTableSettings.icons.checkItemUnchecked"></i>\n\t\t</div>\n\t'}}).directive("qbPagination",function(){return{scope:{},require:"^qbTable",restrict:"EA",transclude:!0,controller:["$attrs","$scope","qbTableSettings",function(t,e,n){e.qbTableSettings=n,e.canPrev=!0,e.canNext=!0,e.showRange={},e.$watchGroup(["qbTable.query.limit","qbTable.query.skip","qbTable.count"],function(t){e.qbTable.query.limit&&"number"!=typeof e.qbTable.query.limit&&e.qbTable.setField("limit",parseInt(e.qbTable.query.limit,10)),e.qbTable.query.skip&&"number"!=typeof e.qbTable.query.skip&&e.qbTable.setField("skip",parseInt(e.qbTable.query.skip,10)),e.qbTable.query.count&&"number"!=typeof e.qbTable.query.count&&e.qbTable.setField("count",parseInt(e.qbTable.query.count,10)),e.canPrev=0<e.qbTable.query.skip,e.canNext=!e.qbTable.count||e.qbTable.query.skip+e.qbTable.query.limit<e.qbTable.count,n.pagination.showXOfY&&(e.showRange={start:(e.qbTable.query.skip||0)+1,end:Math.min((e.qbTable.query.skip||0)+e.qbTable.query.limit,e.qbTable.count),total:e.qbTable.count}),n.pagination.showPages&&(e.pages={current:!!e.qbTable.query.limit&&Math.floor((e.qbTable.query.skip||0)/e.qbTable.query.limit)},e.pages.min=Math.max(e.pages.current-n.pagination.pageRangeBack,0),e.pages.total=e.qbTable.query.limit?Math.ceil(e.qbTable.count/e.qbTable.query.limit):1,e.pages.max=Math.min(e.pages.total,e.pages.current+n.pagination.pageRangeFore+1),e.pages.range=_.range(e.pages.min,e.pages.max).map(function(t){return{number:t,mode:t==e.pages.current?"current":t==e.pages.current-1?"prev":t==e.pages.current+1?"next":"normal"}}))}),e.navPageRelative=function(t){if(-1==t)e.qbTable.setField("skip",Math.max((e.qbTable.query.skip||0)-(e.qbTable.query.limit||10),0)).setDirty();else{if(1!=t)throw new Error("Unsupported page move: "+t);e.qbTable.setField("skip",(e.qbTable.query.skip||0)+(e.qbTable.query.limit||10)).setDirty()}},e.navPageNumber=function(t){return e.qbTable.setField("skip",(t||0)*(e.qbTable.query.limit||10)).setDirty()}}],link:function(t,e,n,i){t.qbTable=i},template:'\n\t\t<nav>\n\t\t\t<ul class="pager">\n\t\t\t\t<li ng-class="canPrev ? \'\' : \'disabled\'" class="previous"><a ng-click="navPageRelative(-1)"><i ng-class="qbTableSettings.icons.paginationPrev"></i></a></li>\n\t\t\t\t<ng-transclude class="text-center">\n\t\t\t\t\t<span ng-if="qbTableSettings.pagination.showXOfY && showRange.end" class="display-xofy">\n\t\t\t\t\t\tShowing documents {{showRange.start | number}} - {{showRange.end | number}}\n\t\t\t\t\t\t<span ng-if="showRange.total">\n\t\t\t\t\t\t\tof {{showRange.total | number}}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<ul ng-if="qbTableSettings.pagination.showPages && showRange.end && pages.max > 1" class="display-pages pagination">\n\t\t\t\t\t\t<li ng-repeat="page in pages.range track by page.number" ng-class="page.mode == \'current\' ? \'active\' : \'\'">\n\t\t\t\t\t\t\t<a ng-click="navPageNumber(page.number)">\n\t\t\t\t\t\t\t\t{{page.number + 1 | number}}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</ng-transclude>\n\t\t\t\t<li ng-class="canNext ? \'\' : \'disabled\'" class="next"><a ng-click="navPageRelative(1)"><i ng-class="qbTableSettings.icons.paginationNext"></i></a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t'}}).directive("qbExport",function(){return{scope:{query:"<",spec:"<",url:"@"},transclude:!0,restrict:"EA",controller:["$element","$httpParamSerializerJQLike","$scope","$timeout","$window","qbTableSettings","qbTableUtilities",function(t,e,n,i,l,r,a){n.qbTableSettings=r,n.settings={},n.isShowing=!1,n.exportPrompt=function(){n.settings=angular.extend(angular.copy(r.export.defaults),{query:_(n.query).omitBy(function(t,e){return["skip","limit"].includes(e)}).value(),columns:_(n.spec).pickBy(function(t){return t&&t.type&&["string","number","data","boolean","objectid"].includes(t.type)}).map(function(t,e){return t.id=e,t.title=_.startCase(e),t.selected=!0,t}).value(),questions:_(r.export.questions).mapKeys(function(t){return t.id}).mapValues(function(t){return t.default}).value()}),t.find(".modal").on("show.bs.modal",function(){return i(function(){return n.isShowing=!0})}).on("hidden.bs.modal",function(){return i(function(){return n.isShowing=!1})}).modal("show")},n.exportExecute=function(){var t=angular.extend(n.settings.query,{select:n.settings.columns.filter(function(t){return t.selected}).map(function(t){return t.id}),format:n.settings.format},n.settings.questions);l.open(n.url+"?"+e(t))},n.querySynopsis,n.$watchGroup(["isShowing","settings.query"],function(){n.isShowing&&(n.querySynopsis=a.getSynopsis(n.settings.query))}),n.columnSynopsis,n.$watchGroup(["isShowing",function(){return _.get(n.settings,"columns",[]).map(function(t){return t.id+"="+t.selected}).join("&")}],function(){n.isShowing&&(n.columnSynopsis=n.settings.columns.filter(function(t){return t.selected}).length+" columns")})}],link:function(t,e){e.find("ng-transclude").on("click",function(){return t.$applyAsync(function(){return t.exportPrompt()})})},template:'\n\t\t<div class="modal fade">\n\t\t\t<div class="modal-dialog modal-lg">\n\t\t\t\t<div ng-if="isShowing" class="modal-content">\n\t\t\t\t\t<div class="modal-header">\n\t\t\t\t\t\t<a class="close" data-dismiss="modal"><i ng-class="qbTableSettings.icons.modalClose"></i></a>\n\t\t\t\t\t\t<h4 class="modal-title">Export</h4>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-body form-horizontal">\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Output format</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<select ng-model="settings.format" class="form-control">\n\t\t\t\t\t\t\t\t\t<option ng-repeat="format in qbTableSettings.export.formats track by format.id" value="{{format.id}}">{{format.title}}</option>\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Criteria</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<div class="panel-group" id="qb-export-criteria-{{$id}}">\n\t\t\t\t\t\t\t\t\t<div class="panel panel-default">\n\t\t\t\t\t\t\t\t\t\t<div class="panel-heading">\n\t\t\t\t\t\t\t\t\t\t\t<h4 class="panel-title">\n\t\t\t\t\t\t\t\t\t\t\t\t<a data-toggle="collapse" data-target="#qb-export-criteria-{{$id}}-query" data-parent="#qb-export-criteria-{{$id}}" class="btn-block collapsed">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{querySynopsis}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i ng-class="qbTableSettings.icons.modalCollapseClosed"></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<div id="qb-export-criteria-{{$id}}-query" class="panel-collapse collapse container">\n\t\t\t\t\t\t\t\t\t\t\t<ui-query-builder\n\t\t\t\t\t\t\t\t\t\t\t\tquery="settings.query"\n\t\t\t\t\t\t\t\t\t\t\t\tspec="spec"\n\t\t\t\t\t\t\t\t\t\t\t></ui-query-builder>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Columns</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<div class="panel-group" id="qb-export-columns-{{$id}}">\n\t\t\t\t\t\t\t\t\t<div class="panel panel-default">\n\t\t\t\t\t\t\t\t\t\t<div class="panel-heading">\n\t\t\t\t\t\t\t\t\t\t\t<h4 class="panel-title">\n\t\t\t\t\t\t\t\t\t\t\t\t<a data-toggle="collapse" data-target="#qb-export-columns-{{$id}}-columns" data-parent="#qb-export-columns-{{$id}}" class="btn-block collapsed">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{columnSynopsis}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i ng-class="qbTableSettings.icons.modalCollapseClosed"></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<div id="qb-export-columns-{{$id}}-columns" class="panel-collapse collapse row">\n\t\t\t\t\t\t\t\t\t\t\t<div class="col-xs-12">\n\t\t\t\t\t\t\t\t\t\t\t\t<table qb-table class="table table-hover">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<th qb-cell selector></th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<th>Column</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr ng-repeat="col in settings.columns track by col.id">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td qb-cell selector="col.selected"></td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>{{col.title}}</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div ng-repeat="question in qbTableSettings.export.questions track by question.id" class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">{{question.title}}</label>\n\t\t\t\t\t\t\t<div ng-switch="question.type" class="col-sm-9">\n\t\t\t\t\t\t\t\t<div ng-switch-when="text">\n\t\t\t\t\t\t\t\t\t<input type="text" ng-model="settings.questions[question.id]" class="form-control"/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div ng-switch-default>\n\t\t\t\t\t\t\t\t\t<div class="alert alert-danger">\n\t\t\t\t\t\t\t\t\t\tUnknown question type: "{{question.type}}"\n\t\t\t\t\t\t\t\t\t\t<pre>{{question | json}}</pre>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div ng-if="question.help" class="help-block">{{question.help}}</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-footer">\n\t\t\t\t\t\t<div class="pull-left">\n\t\t\t\t\t\t\t<a class="btn btn-danger" data-dismiss="modal">Cancel</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pull-right">\n\t\t\t\t\t\t\t<a ng-click="exportExecute()" class="btn btn-primary" data-dismiss="modal">Export</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<ng-transclude>\n\t\t\t<a ng-click="exportPrompt()" class="btn btn-default">Export...</a>\n\t\t</ng-transclude>\n\t'}}).directive("qbModal",function(){return{scope:{query:"=",spec:"<",title:"@?",onRefresh:"&?",binding:"@?"},transclude:!0,restrict:"A",controller:["$element","$scope","$rootScope","qbTableSettings",function(t,e,n,i){var l=this;e.qbTableSettings=i,l.isShown=!1,l.rebind=function(){t.one("click",function(){t.find(".qb-modal").one("hide.bs.modal",function(){l.isShown=!1}).one("hidden.bs.modal",function(){l.rebind()}).modal("show")})},e.submit=function(){angular.isFunction(l.onRefresh)&&l.onRefresh({query:e.queryCopy,spec:e.spec}),e.binding&&"complete"!=e.binding||(e.query=e.queryCopy),t.find(".qb-modal").modal("hide"),n.$broadcast("queryBuilder.change.replace",e.query)},l.$onInit=function(){e.queryCopy="live"==e.binding?e.query:angular.copy(e.query)},l.rebind()}],template:'\n\t\t<ng-transclude></ng-transclude>\n\t\t<div class="qb-modal modal fade">\n\t\t\t<div class="modal-dialog modal-lg">\n\t\t\t\t<div class="modal-content">\n\t\t\t\t\t<div class="modal-header">\n\t\t\t\t\t\t<a class="close" data-dismiss="modal"><i ng-class="qbTableSettings.icons.modalClose"></i></a>\n\t\t\t\t\t\t<h4 class="modal-title">{{title || \'Edit Filter\'}}</h4>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-body">\n\t\t\t\t\t\t<ui-query-builder\n\t\t\t\t\t\t\tquery="queryCopy"\n\t\t\t\t\t\t\tspec="spec"\n\t\t\t\t\t\t></ui-query-builder>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-footer">\n\t\t\t\t\t\t<div class="pull-left">\n\t\t\t\t\t\t\t<a class="btn btn-danger" data-dismiss="modal">Cancel</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pull-right">\n\t\t\t\t\t\t\t<a ng-click="submit()" class="btn btn-success">Refresh</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t'}}).directive("qbSearch",function(){return{scope:{query:"=",spec:"<",onRefresh:"&?",fields:"<?",useIndexes:"@?"},restrict:"AE",transclude:!0,controller:["$element","$scope","$rootScope","$timeout","qbTableSettings","qbTableUtilities",function(i,a,c,t,s,o){var u=this;a.qbTableSettings=s,a.search="",a.isSearching=!1,a.submit=function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(!a.search&&t)return a.clear(!1);var n=o.escapeRegExp(_.trim(a.search)),e={$comment:"search",$or:_(a.spec).pickBy(function(t){return"string"==t.type}).mapValues(function(t,e){return[{$regex:n,$options:"i"}]}).value()},i=o.find(a.query,{$comment:"search"}),l=angular.copy(a.query);if(i&&_.isEqual(i,["$comment"]))l=e;else if(i&&"$and"==i[0])_.set(l,i,e);else if(_.isEqual(_.keys(l),["$and"]))l.$and.push(e);else if(_.isObject(l)){var r=u.useIndexes||"auto";"auto"==r&&(r=_.keys(a.spec).some(function(t){return"_id"!=t&&a.spec[t].index})?"stringIndexed":"string"),a.fields?l.$or=_(a.fields).map(function(t){return _defineProperty({},t,{$regex:o.escapeRegExp(a.search),$options:"i"})}).value():l.$or=_(a.spec).pickBy(function(t,e){if("_id"==e)return!1;if(a.fields&&a.fields.length)return a.fields.includes(e);switch(r){case"all":return!0;case"string":return"string"==t.type;case"stringIndexed":return"string"==t.type&&t.index;default:throw new Error('Unknown field selection method: "'+r+'"')}}).map(function(t,e){return _defineProperty({},e,{$regex:o.escapeRegExp(a.search),$options:"i"})}).value()}else console.warn(s.debugPrefix,"Unable to inject search term",e,"within complex query object",l);a.isSearching=!0,c.$broadcast("queryBuilder.change.replace",l),angular.isFunction(u.onRefresh)&&u.onRefresh({query:l}),"complete"!=u.binding&&!angular.isUndefined(u.binding)||(a.query=l)},a.clear=function(){var t,e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],n=o.find(a.query,{$comment:"search"});if(a.isSearching=!1,a.search="",e&&angular.element(i).find("input").focus(),n&&_.isEqual(n,["$comment"]))t={};else if(n&&"$and"==n[0])(t=angular.copy(a.query)).$and.find(function(t,e){return"search"!=t.$comment});else if(n)t=angular.copy(a.query),_.unset(t,n);else{if(!a.query.$or||!a.query.$or.every(function(t){return 1==_.size(t)&&_.chain(t).first().keys().find(function(t){return"$regEx"==t})}))return s.debug?void console.warn(s.debugPrefix,"Unable to clear search query within complex query - or query doesnt contain a search anyway",a.query):void 0;delete(t=angular.copy(a.query)).$or}c.$broadcast("queryBuilder.change.replace",t),angular.isFunction(u.onRefresh)&&u.onRefresh({query:t}),"complete"!=u.binding&&!angular.isUndefined(u.binding)||(a.query=t)},a.check=function(){try{a.search=_.chain(a.query).get("$or").first().values().first().get("$regex").thru(function(t){return o.unescapeRegExp(t||"")}).value()}catch(t){a.search=""}},u.$onInit=function(){return a.check()}}],template:'\n\t\t<ng-transclude>\n\t\t\t<form ng-submit="submit()" class="form-inline">\n\t\t\t\t<div class="form-group">\n\t\t\t\t\t<div class="input-group">\n\t\t\t\t\t\t<input type="text" ng-model="search" class="form-control"/>\n\t\t\t\t\t\t<a ng-click="isSearching ? clear() : submit(false)" class="btn btn-default input-group-addon">\n\t\t\t\t\t\t\t<i ng-class="isSearching ? qbTableSettings.icons.searchClear : qbTableSettings.icons.search"/>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</ng-transclude>\n\t'}}); | ||
"use strict";function _defineProperty(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}angular.module("angular-ui-query-builder",[]).service("QueryBuilder",function(){var a=this;a.cleanSpec=function(t){return _(t).mapValues(function(t,e){return{type:t.type,enum:_(t.enum).map(function(t){return _.isString(t)?{id:t,title:_.startCase(t)}:t}).sortBy("title").value()}}).value()},a.metaProperties={limit:{type:"keyVal",actions:[{id:"$eq",title:"Equals"}],action:"$eq",canDelete:!0},populate:{type:"hidden"},skip:{type:"keyVal",actions:[{id:"$eq",title:"Equals"}],action:"$eq",canDelete:!0},sort:{type:"keyVal",actions:[{id:"$eq",title:"Equals"}],action:"$eq",canDelete:!1}},a.queryPathPrototypeActions=[{id:"$eq",title:"Equals"},{id:"$neq",title:"Doesnt equal"},{id:"$lt",title:"Is less than"},{id:"$lte",title:"Is equal to or less than"},{id:"$gt",title:"Is greater than"},{id:"$gte",title:"Is equal or greater than"},{id:"$in",title:"Is one of"},{id:"$nin",title:"Is not one of"},{id:"$exists",title:"Has a value"},{id:"$nexists",title:"Does not have a value"}],a.queryPathPrototype=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length?arguments[2]:void 0,i=n[t],l=_.isObject(e)&&_(e).keys().first(),r=_.isObject(e)?_(e).values().first():e;return"$or"==t&&e.every(function(t){return _.isObject(t)&&1==_.keys(t).length})&&e.map(function(t){return _.chain(t).first().values().first().keys().find(function(t){return"$regexp"==t}).value()}).length==e.length?{path:t,type:"search",title:"Search",value:_.chain(e).first().values().first().get("$regexp").value(),fields:_(e).map(function(t){return _.keys(t)}).flatten().value(),actions:a.queryPathPrototypeActions}:"$and"==t||"$or"==t?(_.isArray(e)||(console.warn("query-builder","Query path",t,"is a meta key",e,"but is not an array!","Given",_typeof(e)),e=[]),{path:t,type:"binaryGroup",title:"$and"==t?"AND":"$or"==t?"OR":"UNKNOWN",condition:t.replace(/\$/,""),children:e.map(function(t){return a.queryToArray(t,n)}),actions:a.queryPathPrototypeActions}):a.metaProperties[t]?Object.assign({path:t,title:_.startCase(t),value:e,type:"hidden",action:"$hidden",actions:a.queryPathPrototypeActions},a.metaProperties[t]):"$exists"==l?{path:t,title:e.title||_.startCase(t),value:!!e,type:"exists",action:"$exists",actions:a.queryPathPrototypeActions}:"string"==i.type&&_.isArray(i.enum)&&i.enum.length?{path:t,title:e.title||_.startCase(t),type:"enum",action:e.$in?"$in":e.$nin?"$nin":i.enum.length?"$in":"$eq",enum:i.enum,value:e.$in?e.$in:e.$nin?e.$nin:i.enum.length&&!_.isArray(e)?[e]:e,actions:a.queryPathPrototypeActions}:{path:t,title:e.title||_.startCase(t),type:"string"==i.type?"string":"number"==i.type?"number":"date"==i.type?"date":"string",action:"$eq",value:"date"==i.type?moment(r).toDate():r,actions:a.queryPathPrototypeActions}},a.queryToArray=function(t,i){return _(t).pickBy(function(t,e){var n=i[e]||"$and"==e||"$or"==e||a.metaProperties[e];return n||console.warn("query-builder","Incomming query path",e,"Does not map to anything in spec",i),!!n}).map(function(t,e){return a.queryPathPrototype(e,t,i)}).value()},a.arrayToQuery=function(t){return _(t).mapKeys(function(t){return t.path}).mapValues(function(e){switch(e.type){case"string":case"number":case"date":return"$eq"==e.action?e.value:_defineProperty({},e.action,e.value);case"enum":return _defineProperty({},e.action,e.value);case"exists":return{$exists:"$exists"==e.action};case"search":return e.fields.map(function(t){return _defineProperty({},t,{$regexp:e.value,options:"i"})});case"keyVal":case"hidden":return e.value;default:console.warn("Unknown type to convert:",e.type)}}).value()}}).component("uiQueryBuilder",{bindings:{query:"=",spec:"<"},template:'\n\t\t<div class="ui-query-builder">\n\t\t\t<div ng-if="$ctrl.isEmpty">\n\t\t\t\t<ui-query-builder-group\n\t\t\t\t\tqb-group="$ctrl.emptyQueryLayout"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-group>\n\t\t\t</div>\n\t\t\t<div ng-if="!$ctrl.isEmpty" class="query-container">\n\t\t\t\t<ui-query-builder-group\n\t\t\t\t\tqb-group="$ctrl.qbQuery"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-group>\n\t\t\t</div>\n\t\t</div>\n\t',controller:["$scope","$timeout","QueryBuilder",function(l,r,a){var c=this;c.qbSpec,c.qbQuery;var t=l.$watchGroup(["$ctrl.query","$ctrl.spec"],function(){c.spec&&c.query&&(c.qbSpec=a.cleanSpec(c.spec),c.qbQuery=a.queryToArray(c.query,c.qbSpec),t())});l.$on("queryBuilder.change",function(t,e){return r(function(){e?(c.query=e,c.qbQuery=a.queryToArray(c.query,c.qbSpec)):c.query=a.arrayToQuery(c.qbQuery)})}),l.$on("queryBuilder.pathAction.drop",function(t,e){c.qbQuery=c.qbQuery.filter(function(t){return t.path!=e}),c.query=a.arrayToQuery(c.qbQuery)}),l.$on("queryBuilder.pathAction.swapPath",function(t,e,n){var i=c.qbQuery.findIndex(function(t){return t.path==e});if(i<0)throw new Error('Cannot find path "'.concat(e,'" to swap with new path "').concat(n,'"'));c.qbQuery[i]=a.queryPathPrototype(n,void 0,c.qbSpec),r(function(){return l.$broadcast("queryBuilder.focusOperand",n)})}),l.$on("queryBuilder.pathAction.swapAction",function(t,e,n){console.log("SWAPACTION",e,n)}),l.$on("queryBuilder.pathAction.add",function(t,e){e?console.warn("Adding a path to a sub-node is not yet supported"):(c.qbQuery.findIndex(function(t){return!t.path})&&c.qbQuery.push({path:"",type:"blank",value:null,fields:[]}),r(function(){return l.$broadcast("queryBuilder.focusPath","")}))}),c.emptyQueryLayout=[{type:"alert",title:"No query specified"}],c.isEmpty,l.$watchCollection("$ctrl.qbQuery",function(){return c.isEmpty=_.isEmpty(c.qbQuery)})}]}).component("uiQueryBuilderGroup",{bindings:{qbGroup:"=",qbSpec:"<"},template:'\n\t\t<div ng-repeat="row in $ctrl.qbGroup | filter:$ctrl.qbGroupFilter" meta-key="{{row.path}}">\n\t\t\t<ui-query-builder-row\n\t\t\t\tqb-item="row"\n\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t></ui-query-builder-row>\n\t\t</div>\n\t\t<button ng-click="$ctrl.add()" type="button" class="btn-add"></button>\n\t',controller:["$scope","QueryBuilder",function(t,e){this.add=function(){return t.$emit("queryBuilder.pathAction.add")},this.qbGroupFilter=function(t){return"hidden"!=t.type}}]}).component("uiQueryBuilderRow",{bindings:{qbItem:"=",qbSpec:"<"},controller:["$element","$scope","QueryBuilder",function(i,e,t){var l=this;l.delete=function(t){return e.$emit("queryBuilder.pathAction.drop",t)},l.setChanged=function(){return e.$emit("queryBuilder.change")},l.setAction=function(t){return e.$emit("queryBuilder.pathAction.swapAction",l.qbItem,t)},e.$on("queryBuilder.focusPath",function(t,e){l.qbItem.path==e&&i.find("ui-query-builder-path .dropdown-toggle").dropdown("toggle")}),e.$on("queryBuilder.focusOperand",function(t,e){if(l.qbItem.path==e){var n=i.find("input.form-control");if(1==n.length)return n.focus();console.warn("Unable to focus any element within DOM",i[0],"for type",l.type,"on line item",l.qbItem)}})}],template:'\n\t\t<div ng-switch="$ctrl.qbItem.type">\n\t\t\t\x3c!-- $and / $or condition {{{ --\x3e\n\t\t\t<div ng-switch-when="binaryGroup" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-1 btn-block">\n\t\t\t\t\t\t{{$ctrl.qbItem.title}}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div ng-repeat="conditional in $ctrl.qbItem.children" class="query-container clearfix">\n\t\t\t\t\t<ui-query-builder-group\n\t\t\t\t\t\tqb-group="conditional"\n\t\t\t\t\t\tqb-spec="$ctrl.spec"\n\t\t\t\t\t></ui-query-builder-group>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- String {{{ --\x3e\n\t\t\t<div ng-switch-when="string" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-3 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-model="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-change="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="text"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Enum {{{ --\x3e\n\t\t\t<div ng-switch-when="enum" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t\t<ui-query-builder-block-menu-multiple\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="3"\n\t\t\t\t\tselected="$ctrl.qbItem.value"\n\t\t\t\t\toptions="$ctrl.qbItem.enum"\n\t\t\t\t></ui-query-builder-block-menu-multiple>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Date {{{ --\x3e\n\t\t\t<div ng-switch-when="date" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-3 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-model="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-change="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="date"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Number {{{ --\x3e\n\t\t\t<div ng-switch-when="number" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-3 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-value="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-changed="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="number"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Exists {{{ --\x3e\n\t\t\t<div ng-switch-when="exists" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<ui-query-builder-block-menu\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="2"\n\t\t\t\t\tselected="$ctrl.qbItem.action"\n\t\t\t\t\toptions="$ctrl.qbItem.actions"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-block-menu>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Search {{{ --\x3e\n\t\t\t<div ng-switch-when="search" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t\ton-change="$ctrl.setAction(selected)"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-2 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-model="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-change="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="text"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- keyVal (Only title + value) {{{ --\x3e\n\t\t\t<div ng-switch-when="keyVal" class="query-row">\n\t\t\t\t<a ng-if="$ctrl.qbItem.canDelete === undefined || $ctrl.qbItem.canDelete" ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-block\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\ttitle="$ctrl.qbItem.title"\n\t\t\t\t></ui-query-builder-block>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-2 btn-block">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tng-model="$ctrl.qbItem.value"\n\t\t\t\t\t\t\tng-change="$ctrl.setChanged()"\n\t\t\t\t\t\t\ttype="text"\n\t\t\t\t\t\t\tclass="form-control"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Blank (i.e. field not set yet) {{{ --\x3e\n\t\t\t<div ng-switch-when="blank" class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Alert {{{ --\x3e\n\t\t\t<div ng-switch-when="alert" class="query-row">\n\t\t\t\t<div class="query-block query-block-2">\n\t\t\t\t\t<div class="btn btn-block btn-noclick" ng-bind="$ctrl.qbItem.title"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t\t\x3c!-- Unknown {{{ --\x3e\n\t\t\t<div ng-switch-default class="query-row">\n\t\t\t\t<a ng-click="$ctrl.delete($ctrl.qbItem.path)" class="btn-trash"></a>\n\t\t\t\t<ui-query-builder-path\n\t\t\t\t\tclass="query-block"\n\t\t\t\t\tlevel="1"\n\t\t\t\t\tselected="$ctrl.qbItem.path"\n\t\t\t\t\tqb-spec="$ctrl.qbSpec"\n\t\t\t\t></ui-query-builder-path>\n\t\t\t\t<div class="query-block">\n\t\t\t\t\t<div class="btn btn-warning btn-block">\n\t\t\t\t\t\tUnknown handler: {{$ctrl.qbItem.type}}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\x3c!-- }}} --\x3e\n\t\t</div>\n\t'}).component("uiQueryBuilderPath",{bindings:{level:"<",selected:"<",qbSpec:"<"},controller:["$scope",function(e){var n=this;n.setSelected=function(t){return e.$emit("queryBuilder.pathAction.swapPath",n.selected,t)},n.options,n.$onInit=function(){n.options=_.map(n.qbSpec,function(t,e){return Object.assign({},{path:e,title:_.startCase(e)},t)}),n.selectedOption=n.options.find(function(t){return t.path==n.selected})}}],template:'\n\t\t<a class="btn btn-block btn-{{$ctrl.level}} dropdown-toggle" data-toggle="dropdown" ng-bind="$ctrl.selectedOption.title"></a>\n\t\t<ul class="dropdown-menu">\n\t\t\t<li ng-repeat="path in $ctrl.options track by path.path"><a ng-click="$ctrl.setSelected(path.path)">{{path.title}}</a></li>\n\t\t</ul>\n\t'}).component("uiQueryBuilderBlock",{bindings:{level:"<",title:"<"},controller:["$scope",function(t){}],template:'\n\t\t<a class="btn btn-block btn-{{$ctrl.level}}">\n\t\t\t{{$ctrl.title}}\n\t\t</a>\n\t'}).component("uiQueryBuilderBlockMenu",{bindings:{level:"<",options:"<",selected:"=",onChange:"&?"},controller:["$scope",function(t){var e=this;e.setSelected=function(t){e.selected=t.id,angular.isFunction(e.onChange)&&e.onChange({selected:e.selected})},e.selectedOption,t.$watchGroup(["$ctrl.options","$ctrl.selected"],function(){e.selectedOption=e.options.find(function(t){return t.id==e.selected})})}],template:'\n\t\t<a class="btn btn-block btn-{{$ctrl.level}} dropdown-toggle" data-toggle="dropdown" ng-bind="$ctrl.selectedOption.title"></a>\n\t\t<ul class="dropdown-menu pull-right">\n\t\t\t<li ng-repeat="option in $ctrl.options track by option.id"><a ng-click="$ctrl.setSelected(option)">{{option.title}}</a></li>\n\t\t</ul>\n\t'}).component("uiQueryBuilderBlockMenuMultiple",{bindings:{level:"<",options:"<",selected:"="},controller:["$scope",function(t){var n=this;n.toggle=function(e){n.selected=n.selected.filter(function(t){return"string"==typeof t}),n.selected||(n.selected=[]),n.selected.includes(e.id)?n.selected=n.selected.filter(function(t){return t!=e.id}):n.selected.push(e.id),t.$emit("queryBuilder.change")},n.selectedOptions,t.$watch("$ctrl.selected",function(){n.selectedOptions=n.options.filter(function(t){return(n.selected||[]).includes(t.id)}),n.options.forEach(function(e){return e.selected=n.selectedOptions.some(function(t){return t.id==e.id})})},!0)}],template:'\n\t\t<a class="btn btn-block btn-{{$ctrl.level}} dropdown-toggle" data-toggle="dropdown">\n\t\t\t<span ng-repeat="item in $ctrl.selectedOptions track by item.id" class="pill">\n\t\t\t\t{{item.title}}\n\t\t\t</span>\n\t\t</a>\n\t\t<ul class="dropdown-menu">\n\t\t\t<li ng-repeat="option in $ctrl.options track by option.id">\n\t\t\t\t<a ng-click="$ctrl.toggle(option)">\n\t\t\t\t\t<i class="fa fa-fw" ng-class="option.selected ? \'fa-check-square-o\' : \'fa-square-o\'"></i>\n\t\t\t\t\t{{option.title}}\n\t\t\t\t</a>\n\t\t\t</li>\n\t\t</ul>\n\t'}),angular.module("angular-ui-query-builder").provider("qbTableSettings",function(){var t=this;return t.debug=!1,t.debugPrefix="[angular-ui-query-builder]",t.icons={sortNone:"fa fa-fw fa-sort text-muted",sortAsc:"fa fa-fw fa-sort-alpha-asc text-primary",sortDesc:"fa fa-fw fa-sort-alpha-desc text-primary",checkMetaChecked:"fa fa-lg fa-fw fa-check-square-o text-primary",checkMetaSome:"fa fa-lg fa-fw fa-minus-square-o",checkMetaUnchecked:"fa fa-lg fa-fw fa-square-o",checkMetaCaret:"fa fa-caret-down",checkItemChecked:"fa fa-lg fa-fw fa-check-square-o",checkItemUnchecked:"fa fa-lg fa-fw fa-square-o",paginationPrev:"fa fa-arrow-left",paginationNext:"fa fa-arrow-right",modalClose:"fa fa-times",modalCollapseClosed:"fa fa-caret-right pull-right",search:"fa fa-search",searchClear:"fa fa-times"},t.pagination={showXOfY:!0,showPages:!0,pageRangeBack:5,pageRangeFore:5},t.export={defaults:{format:"xlsx"},formats:[{id:"xlsx",title:"Excel (XLSX)"},{id:"csv",title:"CSV"},{id:"json",title:"JSON"},{id:"html",title:"HTML (display in browser)"}],questions:[]},t.$get=function(){return t},t}).service("qbTableUtilities",function(){return{getSynopsis:function(t){var e=_.keys(t).filter(function(t){return!["sort","skip","limit","select"].includes(t)});return[e.length?1==e.length?"1 filter":"".concat(e.length," filters"):"All documents",t.sort?t.sort.startsWith("-")?"sorted by ".concat(t.sort.substr(1)," (reverse order)"):"sorted by ".concat(t.sort):null,t.limit?"limited to ".concat(t.limit," rows"):null,t.offset?"starting at record ".concat(t.skip):null,t.select?"selecting only ".concat(t.select.length," columns"):null].filter(function(t){return t}).join(", ")},find:function(t,e){var l,r=_.isFunction(e)?e:_.matches(e);return!!function n(t,i){return r(t,i.slice(i.length-1))?(l=i,!0):_.isArray(t)?t.some(function(t,e){return n(t,i.concat(e))}):_.isObject(t)?_.some(t,function(t,e){return n(t,i.concat(e))}):void 0}(t,[])&&l},escapeRegExp:function(t){return String(t).replace(/(\W)/g,"\\$1")},unescapeRegExp:function(t){return String(t).replace(/\\(\W)/g,"$1")}}}).directive("qbTable",function(){return{scope:{qbTable:"=?",count:"<?",stickyThead:"<?",stickyTfoot:"<?"},restrict:"AC",controller:["$attrs","$element","$rootScope","$scope","$timeout","qbTableSettings",function(t,e,n,l,i,r){var a=this;a.query=l.qbTable,a.count=l.count,l.$watch("count",function(){return a.count=l.count}),a.$broadcast=function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return l.$broadcast.apply(l,[t].concat(n))},a.$on=function(t,e){return l.$on(t,e)},a.setDirty=function(){r.debug&&console.log(r.debugPrefix,"Declare query dirty",l.qbTable),n.$broadcast("queryBuilder.change",l.qbTable)},a.setField=function(t,e){if(null!=e){switch(t){case"sort":a.query.sort===e?a.query.sort="-".concat(e):(a.query.sort,"-".concat(e),a.query.sort=e);break;default:a.query[t]=l.qbTable[t]=e}return a}delete a.query[t]},e.addClass("qb-table"),l.$watch("stickyThead",function(){return e.toggleClass("qb-sticky-thead",l.stickyThead||""===t.stickyThead)}),l.$watch("stickyTfoot",function(){return e.toggleClass("qb-sticky-tfoot",l.stickyTfoot||""===t.stickyTfoot)}),l.$watch("count",function(){return e.toggleClass("qb-noresults",0===l.count)}),l.$on("queryBuilder.change.replace",function(t,e){e.skip=0,a.query=l.qbTable=e,i(function(){return a.setDirty()})})}]}}).directive("qbCol",function(){return{scope:{qbCol:"@",sortable:"@"},require:"^qbTable",restrict:"A",transclude:!0,controller:["$attrs","$element","$scope","$timeout","qbTableSettings",function(t,e,n,i,l){n.qbTableSettings=l;var r=n.$watchGroup(["qbTable","sortable"],function(){""===t.sortable&&!n.qbTable&&l.debug&&console.warn(l.debugPrefix,"Added qb-col + sortable onto element",e,"but no qb-table query has been assigned on the table element!"),r()});n.canSort=!1,n.isSorted=!1,this.$onInit=function(){n.canSort=n.sortable||""===t.sortable,e.toggleClass("sortable",n.canSort),n.canSort&&e.on("click",function(){return i(n.toggleSort)})},n.$watch("qbTable.query.sort",function(t){var e=n.sortable||n.qbCol;t?angular.isArray(t)&&t.some(function(t){return t==e})||t==e?n.isSorted="asc":angular.isArray(t)&&t.some(function(t){return t=="-"+e})||t=="-"+e?n.isSorted="desc":n.isSorted=!1:n.isSorted=!1}),n.toggleSort=function(){n.sortable?n.qbTable.setField("sort",n.sortable).setDirty():n.qbCol&&""===t.sortable&&n.qbTable.setField("sort",n.qbCol).setDirty()}}],link:function(t,e,n,i){t.qbTable=i},template:'\n\t\t<div class="qb-col-wrapper">\n\t\t\t<ng-transclude></ng-transclude>\n\t\t\t<a ng-if="canSort" ng-click="toggleSort()" class="qb-col-right">\n\t\t\t\t<i class="{{\n\t\t\t\t\tisSorted == \'asc\' ? qbTableSettings.icons.sortAsc\n\t\t\t\t\t: isSorted == \'desc\' ? qbTableSettings.icons.sortDesc\n\t\t\t\t\t: qbTableSettings.icons.sortNone\n\t\t\t\t}}"></i>\n\t\t\t</a>\n\t\t</div>\n\t'}}).directive("qbCell",function(){return{scope:{selector:"=?",onPreSelect:"&?",onSelect:"&?"},require:"^qbTable",restrict:"A",transclude:!0,controller:["$attrs","$element","$scope","$timeout","qbTableSettings",function(t,e,n,i,l){n.qbTableSettings=l,n.isMeta=0<e.parents("thead").length,n.isMeta&&i(function(){return n.qbTable.$on("qbTableCellSelect",function(){var t=[];n.qbTable.$broadcast("qbTableCellSelectStatus",t),n.metaStatus=t.every(function(t){return t})?"all":t.some(function(t){return t})?"some":"none"})}),n.isSelector="selector"in t,n.$watch("selector",function(){n.isSelector&&e.toggleClass("selector",n.isSelector),n.isSelector&&!n.isMeta&&e.parents("tr").toggleClass("selected",!!n.selector)}),n.isSelector&&!n.isMeta&&e.on("click",function(t){return n.$apply(function(){n.onPreSelect&&n.onPreSelect({value:n.selector}),n.selector=!n.selector,n.qbTable.$broadcast("qbTableCellSelect"),n.onSelect&&i(function(){return n.onSelect({value:n.selector})})})}),n.metaSelect=function(t){return n.qbTable.$broadcast("qbTableCellSelectMeta",t)},n.isSelector&&!n.isMeta&&i(function(){n.qbTable.$on("qbTableCellSelectMeta",function(t,e){switch(e){case"all":n.selector=!0;break;case"invert":n.selector=!n.selector;break;case"none":n.selector=!1;break;default:throw new Error("Unknown selection type: ".concat(e))}n.qbTable.$broadcast("qbTableCellSelect")}),n.qbTable.$on("qbTableCellSelectStatus",function(t,e){return e.push(n.selector)})}),e.addClass("qb-cell")}],link:function(t,e,n,i){t.qbTable=i},template:'\n\t\t<ng-transclude></ng-transclude>\n\t\t<div ng-if="isSelector && isMeta" class="btn-group">\n\t\t\t<a class="btn btn-default dropdown-toggle" data-toggle="dropdown">\n\t\t\t\t<i ng-class="metaStatus == \'all\' ? qbTableSettings.icons.checkMetaChecked : metaStatus == \'some\' ? qbTableSettings.icons.checkMetaUnchecked : qbTableSettings.icons.checkMetaUnchecked"></i>\n\t\t\t\t<i ng-class="qbTableSettings.icons.checkMetaCaret"></i>\n\t\t\t</a>\n\t\t\t<ul class="dropdown-menu">\n\t\t\t\t<li><a ng-click="metaSelect(\'all\')">All</a></li>\n\t\t\t\t<li><a ng-click="metaSelect(\'invert\')">Invert</a></li>\n\t\t\t\t<li><a ng-click="metaSelect(\'none\')">None</a></li>\n\t\t\t</ul>\n\t\t</div>\n\t\t<div ng-if="isSelector && !isMeta">\n\t\t\t<i ng-class="selector ? qbTableSettings.icons.checkItemChecked : qbTableSettings.icons.checkItemUnchecked"></i>\n\t\t</div>\n\t'}}).directive("qbPagination",function(){return{scope:{},require:"^qbTable",restrict:"EA",transclude:!0,controller:["$attrs","$scope","qbTableSettings",function(t,e,n){e.qbTableSettings=n,e.canPrev=!0,e.canNext=!0,e.showRange={},e.$watchGroup(["qbTable.query.limit","qbTable.query.skip","qbTable.count"],function(t){e.qbTable.query.limit&&"number"!=typeof e.qbTable.query.limit&&e.qbTable.setField("limit",parseInt(e.qbTable.query.limit,10)),e.qbTable.query.skip&&"number"!=typeof e.qbTable.query.skip&&e.qbTable.setField("skip",parseInt(e.qbTable.query.skip,10)),e.qbTable.query.count&&"number"!=typeof e.qbTable.query.count&&e.qbTable.setField("count",parseInt(e.qbTable.query.count,10)),e.canPrev=0<e.qbTable.query.skip,e.canNext=!e.qbTable.count||e.qbTable.query.skip+e.qbTable.query.limit<e.qbTable.count,n.pagination.showXOfY&&(e.showRange={start:(e.qbTable.query.skip||0)+1,end:Math.min((e.qbTable.query.skip||0)+e.qbTable.query.limit,e.qbTable.count),total:e.qbTable.count}),n.pagination.showPages&&(e.pages={current:!!e.qbTable.query.limit&&Math.floor((e.qbTable.query.skip||0)/e.qbTable.query.limit)},e.pages.min=Math.max(e.pages.current-n.pagination.pageRangeBack,0),e.pages.total=e.qbTable.query.limit?Math.ceil(e.qbTable.count/e.qbTable.query.limit):1,e.pages.max=Math.min(e.pages.total,e.pages.current+n.pagination.pageRangeFore+1),e.pages.range=_.range(e.pages.min,e.pages.max).map(function(t){return{number:t,mode:t==e.pages.current?"current":t==e.pages.current-1?"prev":t==e.pages.current+1?"next":"normal"}}))}),e.navPageRelative=function(t){if(-1==t)e.qbTable.setField("skip",Math.max((e.qbTable.query.skip||0)-(e.qbTable.query.limit||10),0)).setDirty();else{if(1!=t)throw new Error("Unsupported page move: "+t);e.qbTable.setField("skip",(e.qbTable.query.skip||0)+(e.qbTable.query.limit||10)).setDirty()}},e.navPageNumber=function(t){return e.qbTable.setField("skip",(t||0)*(e.qbTable.query.limit||10)).setDirty()}}],link:function(t,e,n,i){t.qbTable=i},template:'\n\t\t<nav>\n\t\t\t<ul class="pager">\n\t\t\t\t<li ng-class="canPrev ? \'\' : \'disabled\'" class="previous"><a ng-click="canPrev && navPageRelative(-1)"><i ng-class="qbTableSettings.icons.paginationPrev"></i></a></li>\n\t\t\t\t<ng-transclude class="text-center">\n\t\t\t\t\t<span ng-if="qbTableSettings.pagination.showXOfY && showRange.end" class="display-xofy">\n\t\t\t\t\t\tShowing documents {{showRange.start | number}} - {{showRange.end | number}}\n\t\t\t\t\t\t<span ng-if="showRange.total">\n\t\t\t\t\t\t\tof {{showRange.total | number}}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t\t<ul ng-if="qbTableSettings.pagination.showPages && showRange.end && pages.max > 1" class="display-pages pagination">\n\t\t\t\t\t\t<li ng-repeat="page in pages.range track by page.number" ng-class="page.mode == \'current\' ? \'active\' : \'\'">\n\t\t\t\t\t\t\t<a ng-click="navPageNumber(page.number)">\n\t\t\t\t\t\t\t\t{{page.number + 1 | number}}\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</ng-transclude>\n\t\t\t\t<li ng-class="canNext ? \'\' : \'disabled\'" class="next"><a ng-click="canNext && navPageRelative(1)"><i ng-class="qbTableSettings.icons.paginationNext"></i></a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t'}}).directive("qbExport",function(){return{scope:{query:"<",spec:"<",url:"@"},transclude:!0,restrict:"EA",controller:["$element","$httpParamSerializerJQLike","$scope","$timeout","$window","qbTableSettings","qbTableUtilities",function(t,e,n,i,l,r,a){n.qbTableSettings=r,n.settings={},n.isShowing=!1,n.exportPrompt=function(){n.settings=angular.extend(angular.copy(r.export.defaults),{query:_(n.query).omitBy(function(t,e){return["skip","limit"].includes(e)}).value(),columns:_(n.spec).pickBy(function(t){return t&&t.type&&["string","number","data","boolean","objectid"].includes(t.type)}).map(function(t,e){return t.id=e,t.title=_.startCase(e),t.selected=!0,t}).value(),questions:_(r.export.questions).mapKeys(function(t){return t.id}).mapValues(function(t){return t.default}).value()}),t.find(".modal").on("show.bs.modal",function(){return i(function(){return n.isShowing=!0})}).on("hidden.bs.modal",function(){return i(function(){return n.isShowing=!1})}).modal("show")},n.exportExecute=function(){var t=angular.extend(n.settings.query,{select:n.settings.columns.filter(function(t){return t.selected}).map(function(t){return t.id}),format:n.settings.format},n.settings.questions);l.open(n.url+"?"+e(t))},n.querySynopsis,n.$watchGroup(["isShowing","settings.query"],function(){n.isShowing&&(n.querySynopsis=a.getSynopsis(n.settings.query))}),n.columnSynopsis,n.$watchGroup(["isShowing",function(){return _.get(n.settings,"columns",[]).map(function(t){return t.id+"="+t.selected}).join("&")}],function(){n.isShowing&&(n.columnSynopsis=n.settings.columns.filter(function(t){return t.selected}).length+" columns")})}],link:function(t,e){e.find("ng-transclude").on("click",function(){return t.$applyAsync(function(){return t.exportPrompt()})})},template:'\n\t\t<div class="modal fade">\n\t\t\t<div class="modal-dialog modal-lg">\n\t\t\t\t<div ng-if="isShowing" class="modal-content">\n\t\t\t\t\t<div class="modal-header">\n\t\t\t\t\t\t<a class="close" data-dismiss="modal"><i ng-class="qbTableSettings.icons.modalClose"></i></a>\n\t\t\t\t\t\t<h4 class="modal-title">Export</h4>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-body form-horizontal">\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Output format</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<select ng-model="settings.format" class="form-control">\n\t\t\t\t\t\t\t\t\t<option ng-repeat="format in qbTableSettings.export.formats track by format.id" value="{{format.id}}">{{format.title}}</option>\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Criteria</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<div class="panel-group" id="qb-export-criteria-{{$id}}">\n\t\t\t\t\t\t\t\t\t<div class="panel panel-default">\n\t\t\t\t\t\t\t\t\t\t<div class="panel-heading">\n\t\t\t\t\t\t\t\t\t\t\t<h4 class="panel-title">\n\t\t\t\t\t\t\t\t\t\t\t\t<a data-toggle="collapse" data-target="#qb-export-criteria-{{$id}}-query" data-parent="#qb-export-criteria-{{$id}}" class="btn-block collapsed">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{querySynopsis}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i ng-class="qbTableSettings.icons.modalCollapseClosed"></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<div id="qb-export-criteria-{{$id}}-query" class="panel-collapse collapse container">\n\t\t\t\t\t\t\t\t\t\t\t<ui-query-builder\n\t\t\t\t\t\t\t\t\t\t\t\tquery="settings.query"\n\t\t\t\t\t\t\t\t\t\t\t\tspec="spec"\n\t\t\t\t\t\t\t\t\t\t\t></ui-query-builder>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">Columns</label>\n\t\t\t\t\t\t\t<div class="col-sm-9">\n\t\t\t\t\t\t\t\t<div class="panel-group" id="qb-export-columns-{{$id}}">\n\t\t\t\t\t\t\t\t\t<div class="panel panel-default">\n\t\t\t\t\t\t\t\t\t\t<div class="panel-heading">\n\t\t\t\t\t\t\t\t\t\t\t<h4 class="panel-title">\n\t\t\t\t\t\t\t\t\t\t\t\t<a data-toggle="collapse" data-target="#qb-export-columns-{{$id}}-columns" data-parent="#qb-export-columns-{{$id}}" class="btn-block collapsed">\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{columnSynopsis}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i ng-class="qbTableSettings.icons.modalCollapseClosed"></i>\n\t\t\t\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<div id="qb-export-columns-{{$id}}-columns" class="panel-collapse collapse row">\n\t\t\t\t\t\t\t\t\t\t\t<div class="col-xs-12">\n\t\t\t\t\t\t\t\t\t\t\t\t<table qb-table class="table table-hover">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<th qb-cell selector></th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<th>Column</th>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr ng-repeat="col in settings.columns track by col.id">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td qb-cell selector="col.selected"></td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>{{col.title}}</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div ng-repeat="question in qbTableSettings.export.questions track by question.id" class="form-group">\n\t\t\t\t\t\t\t<label class="col-sm-3 control-label">{{question.title}}</label>\n\t\t\t\t\t\t\t<div ng-switch="question.type" class="col-sm-9">\n\t\t\t\t\t\t\t\t<div ng-switch-when="text">\n\t\t\t\t\t\t\t\t\t<input type="text" ng-model="settings.questions[question.id]" class="form-control"/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div ng-switch-default>\n\t\t\t\t\t\t\t\t\t<div class="alert alert-danger">\n\t\t\t\t\t\t\t\t\t\tUnknown question type: "{{question.type}}"\n\t\t\t\t\t\t\t\t\t\t<pre>{{question | json}}</pre>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div ng-if="question.help" class="help-block">{{question.help}}</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-footer">\n\t\t\t\t\t\t<div class="pull-left">\n\t\t\t\t\t\t\t<a class="btn btn-danger" data-dismiss="modal">Cancel</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pull-right">\n\t\t\t\t\t\t\t<a ng-click="exportExecute()" class="btn btn-primary" data-dismiss="modal">Export</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<ng-transclude>\n\t\t\t<a ng-click="exportPrompt()" class="btn btn-default">Export...</a>\n\t\t</ng-transclude>\n\t'}}).directive("qbModal",function(){return{scope:{query:"=",spec:"<",title:"@?",onRefresh:"&?",binding:"@?"},transclude:!0,restrict:"A",controller:["$element","$scope","$rootScope","qbTableSettings",function(t,e,n,i){var l=this;e.qbTableSettings=i,l.isShown=!1,l.rebind=function(){t.one("click",function(){t.find(".qb-modal").one("hide.bs.modal",function(){l.isShown=!1}).one("hidden.bs.modal",function(){l.rebind()}).modal("show")})},e.submit=function(){angular.isFunction(l.onRefresh)&&l.onRefresh({query:e.queryCopy,spec:e.spec}),e.binding&&"complete"!=e.binding||(e.query=e.queryCopy),t.find(".qb-modal").modal("hide"),n.$broadcast("queryBuilder.change.replace",e.query)},l.$onInit=function(){e.queryCopy="live"==e.binding?e.query:angular.copy(e.query)},l.rebind()}],template:'\n\t\t<ng-transclude></ng-transclude>\n\t\t<div class="qb-modal modal fade">\n\t\t\t<div class="modal-dialog modal-lg">\n\t\t\t\t<div class="modal-content">\n\t\t\t\t\t<div class="modal-header">\n\t\t\t\t\t\t<a class="close" data-dismiss="modal"><i ng-class="qbTableSettings.icons.modalClose"></i></a>\n\t\t\t\t\t\t<h4 class="modal-title">{{title || \'Edit Filter\'}}</h4>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-body">\n\t\t\t\t\t\t<ui-query-builder\n\t\t\t\t\t\t\tquery="queryCopy"\n\t\t\t\t\t\t\tspec="spec"\n\t\t\t\t\t\t></ui-query-builder>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="modal-footer">\n\t\t\t\t\t\t<div class="pull-left">\n\t\t\t\t\t\t\t<a class="btn btn-danger" data-dismiss="modal">Cancel</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pull-right">\n\t\t\t\t\t\t\t<a ng-click="submit()" class="btn btn-success">Refresh</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t'}}).directive("qbSearch",function(){return{scope:{query:"=",spec:"<",onRefresh:"&?",fields:"<?",useIndexes:"@?"},restrict:"AE",transclude:!0,controller:["$element","$scope","$rootScope","$timeout","qbTableSettings","qbTableUtilities",function(i,a,c,t,s,o){var u=this;a.qbTableSettings=s,a.search="",a.isSearching=!1,a.submit=function(){var t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];if(!a.search&&t)return a.clear(!1);var n=o.escapeRegExp(_.trim(a.search)),e={$comment:"search",$or:_(a.spec).pickBy(function(t){return"string"==t.type}).mapValues(function(t,e){return[{$regex:n,$options:"i"}]}).value()},i=o.find(a.query,{$comment:"search"}),l=angular.copy(a.query);if(i&&_.isEqual(i,["$comment"]))l=e;else if(i&&"$and"==i[0])_.set(l,i,e);else if(_.isEqual(_.keys(l),["$and"]))l.$and.push(e);else if(_.isObject(l)){var r=u.useIndexes||"auto";"auto"==r&&(r=_.keys(a.spec).some(function(t){return"_id"!=t&&a.spec[t].index})?"stringIndexed":"string"),a.fields?l.$or=_(a.fields).map(function(t){return _defineProperty({},t,{$regex:o.escapeRegExp(a.search),$options:"i"})}).value():l.$or=_(a.spec).pickBy(function(t,e){if("_id"==e)return!1;if(a.fields&&a.fields.length)return a.fields.includes(e);switch(r){case"all":return!0;case"string":return"string"==t.type;case"stringIndexed":return"string"==t.type&&t.index;default:throw new Error('Unknown field selection method: "'+r+'"')}}).map(function(t,e){return _defineProperty({},e,{$regex:o.escapeRegExp(a.search),$options:"i"})}).value()}else console.warn(s.debugPrefix,"Unable to inject search term",e,"within complex query object",l);a.isSearching=!0,c.$broadcast("queryBuilder.change.replace",l),angular.isFunction(u.onRefresh)&&u.onRefresh({query:l}),"complete"!=u.binding&&!angular.isUndefined(u.binding)||(a.query=l)},a.clear=function(){var t,e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],n=o.find(a.query,{$comment:"search"});if(a.isSearching=!1,a.search="",e&&angular.element(i).find("input").focus(),n&&_.isEqual(n,["$comment"]))t={};else if(n&&"$and"==n[0])(t=angular.copy(a.query)).$and.find(function(t,e){return"search"!=t.$comment});else if(n)t=angular.copy(a.query),_.unset(t,n);else{if(!a.query.$or||!a.query.$or.every(function(t){return 1==_.size(t)&&_.chain(t).first().keys().find(function(t){return"$regEx"==t})}))return s.debug?void console.warn(s.debugPrefix,"Unable to clear search query within complex query - or query doesnt contain a search anyway",a.query):void 0;delete(t=angular.copy(a.query)).$or}c.$broadcast("queryBuilder.change.replace",t),angular.isFunction(u.onRefresh)&&u.onRefresh({query:t}),"complete"!=u.binding&&!angular.isUndefined(u.binding)||(a.query=t)},a.check=function(){try{a.search=_.chain(a.query).get("$or").first().values().first().get("$regex").thru(function(t){return o.unescapeRegExp(t||"")}).value()}catch(t){a.search=""}},u.$onInit=function(){return a.check()}}],template:'\n\t\t<ng-transclude>\n\t\t\t<form ng-submit="submit()" class="form-inline">\n\t\t\t\t<div class="form-group">\n\t\t\t\t\t<div class="input-group">\n\t\t\t\t\t\t<input type="text" ng-model="search" class="form-control"/>\n\t\t\t\t\t\t<a ng-click="isSearching ? clear() : submit(false)" class="btn btn-default input-group-addon">\n\t\t\t\t\t\t\t<i ng-class="isSearching ? qbTableSettings.icons.searchClear : qbTableSettings.icons.search"/>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</ng-transclude>\n\t'}}); |
{ | ||
"name": "@momsfriendlydevco/angular-ui-query-builder", | ||
"version": "1.3.16", | ||
"version": "1.3.18", | ||
"description": "MongoDB format query-builder UI component for Angular", | ||
@@ -5,0 +5,0 @@ "main": "src/utilities.js", |
@@ -384,4 +384,4 @@ angular.module('angular-ui-query-builder') | ||
if ($scope.qbTable.query.limit && typeof $scope.qbTable.query.limit !== 'number') $scope.qbTable.setField('limit', parseInt($scope.qbTable.query.limit, 10)); | ||
if ($scope.qbTable.query.skip && typeof $scope.qbTable.query.skip !== 'number') $scope.qbTable.setField('skip', parseInt($scope.qbTable.query.skip, 10)); | ||
if ($scope.qbTable.query.count && typeof $scope.qbTable.query.count !== 'number') $scope.qbTable.setField('count', parseInt($scope.qbTable.query.count, 10)); | ||
if ($scope.qbTable.query.skip && typeof $scope.qbTable.query.skip !== 'number') $scope.qbTable.setField('skip', parseInt($scope.qbTable.query.skip, 10)); | ||
if ($scope.qbTable.query.count && typeof $scope.qbTable.query.count !== 'number') $scope.qbTable.setField('count', parseInt($scope.qbTable.query.count, 10)); | ||
@@ -448,3 +448,3 @@ $scope.canPrev = $scope.qbTable.query.skip > 0; | ||
<ul class="pager"> | ||
<li ng-class="canPrev ? '' : 'disabled'" class="previous"><a ng-click="navPageRelative(-1)"><i ng-class="qbTableSettings.icons.paginationPrev"></i></a></li> | ||
<li ng-class="canPrev ? '' : 'disabled'" class="previous"><a ng-click="canPrev && navPageRelative(-1)"><i ng-class="qbTableSettings.icons.paginationPrev"></i></a></li> | ||
<ng-transclude class="text-center"> | ||
@@ -465,3 +465,3 @@ <span ng-if="qbTableSettings.pagination.showXOfY && showRange.end" class="display-xofy"> | ||
</ng-transclude> | ||
<li ng-class="canNext ? '' : 'disabled'" class="next"><a ng-click="navPageRelative(1)"><i ng-class="qbTableSettings.icons.paginationNext"></i></a></li> | ||
<li ng-class="canNext ? '' : 'disabled'" class="next"><a ng-click="canNext && navPageRelative(1)"><i ng-class="qbTableSettings.icons.paginationNext"></i></a></li> | ||
</ul> | ||
@@ -468,0 +468,0 @@ </nav> |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
357540