diff --git a/build/npm/Plugins.js b/build/npm/Plugins.js index c3a51d4b0..be017d54b 100644 --- a/build/npm/Plugins.js +++ b/build/npm/Plugins.js @@ -245,6 +245,18 @@ const Plugins = [ from: 'node_modules/datatables.net-scroller-bs4/css', to: 'plugins/datatables-scroller/css' }, + { + from: 'node_modules/datatables.net-searchpanes/js', + to: 'plugins/datatables-searchpanes/js' + }, + { + from: 'node_modules/datatables.net-searchpanes-bs4/js', + to: 'plugins/datatables-searchpanes/js' + }, + { + from: 'node_modules/datatables.net-searchpanes-bs4/css', + to: 'plugins/datatables-searchpanes/css' + }, { from: 'node_modules/datatables.net-select/js', to: 'plugins/datatables-select/js' diff --git a/package-lock.json b/package-lock.json index 33b4b077d..8626cf5fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3463,6 +3463,25 @@ "jquery": ">=1.7" } }, + "datatables.net-searchpanes": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/datatables.net-searchpanes/-/datatables.net-searchpanes-1.2.1.tgz", + "integrity": "sha512-SnyWsuM86dZPCMgu0Bz7BeZwbQd4yUsGeKll54sRfYLU/zmTt+1wKzrlTsaNVmFCN2xIlnur8uFj2FBNaQmNlQ==", + "requires": { + "datatables.net": "^1.10.15", + "jquery": ">=1.7" + } + }, + "datatables.net-searchpanes-bs4": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/datatables.net-searchpanes-bs4/-/datatables.net-searchpanes-bs4-1.2.1.tgz", + "integrity": "sha512-SOpMGerNomrar4s+23LDZQRBYrFF+m4flGjigLRTDPEaKFzRR28WXEUR5WJ6ZZlxnE7rSg5YS1qH6pIRMdDdKg==", + "requires": { + "datatables.net-bs4": "^1.10.15", + "datatables.net-searchpanes": "1.2.1", + "jquery": ">=1.7" + } + }, "datatables.net-select": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/datatables.net-select/-/datatables.net-select-1.3.1.tgz", diff --git a/package.json b/package.json index 18d277c47..e153e9764 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "datatables.net-rowgroup-bs4": "^1.1.2", "datatables.net-rowreorder-bs4": "^1.2.7", "datatables.net-scroller-bs4": "^2.0.3", + "datatables.net-searchpanes-bs4": "^1.2.1", "datatables.net-select-bs4": "^1.3.1", "daterangepicker": "^3.1.0", "dropzone": "^5.7.2", diff --git a/plugins/datatables-searchpanes/css/searchPanes.bootstrap4.css b/plugins/datatables-searchpanes/css/searchPanes.bootstrap4.css new file mode 100644 index 000000000..dde29ab82 --- /dev/null +++ b/plugins/datatables-searchpanes/css/searchPanes.bootstrap4.css @@ -0,0 +1,339 @@ +div.dtsp-topRow { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: space-around; + align-content: flex-start; + align-items: flex-start; +} +div.dtsp-topRow input.dtsp-search { + text-overflow: ellipsis; +} +div.dtsp-topRow div.dtsp-subRow1 { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + flex-grow: 1; + flex-shrink: 0; + flex-basis: 0; +} +div.dtsp-topRow div.dtsp-searchCont { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + flex-grow: 1; + flex-shrink: 0; + flex-basis: 0; +} +div.dtsp-topRow button.dtsp-nameButton { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAK2SURBVFgJ7ZY9j41BFICvryCExrJBQ6HyEYVEIREaUZDQIRoR2ViJKCioxV+gkVXYTVZEQiEUhG2EQnxUCh0FKolY4ut5XnM2cyfva3Pt5m7EPcmzZ2bemTNnzjkzd1utnvQi0IvAfxiBy5z5FoxO89kPY+8mbMjtzs47RXs5/WVpbAG6bWExt5PuIibvhVkwmC+ck3eK9ln6/fAddFojYzBVuYSBpcnIEvRaqOw2RcaN18FPuJH0JvRUxbT3wWf4ltiKPgfVidWlbGZgPozDFfgAC+EA/K2EI4cwcAJ+gPaeQ+VQU2SOMMGcPgPl/m/V2p50rrbRsRgt9Iv5h6xtpP22Bz7Ce1C+gFFxfKzOmShcU+Qmyh2w3w8rIJfddHTck66EukL/xPhj+JM8rHNmFys0Pg4v0up3aFNlwR9NYyodd3OL/C64zpsymcTFcf6ElM4YzjAWKYrJkaq8kE/yUYNP4BoYvS1QRo+hNtF5xfkTUjoTheukSFFMjlTFm6PjceOca/SMpKfeCR1L6Uzk/y2WIkVhNFJlJAZhP+hYns7b9D3IPuhY5mYrIv8OrQJvR5NYyNaW4jsU8pSGNySiVx4o5tXq3JkoXE/mg5R/M8dGJCJpKhaDcjBRdbI/Rm8g69c122om33BHmj2CHoV5qa9jUXBraJ+G1fAVjIBO1klc87ro1K4JZ/K35SWW3TwcyDd6TecqnAEd8cGq2+w84xvBm1n3vS0izKkkwh5XNC/GmFPqqAtPF89AOScKuemaNzoTV1SD5dtSbmLf1/RV+tC0WTgcj6R7HEtrVGWaqu/lYDZ/2pvxQ/kIyw/gFByHC9AHw910hv1aUUumyd8yy0QfhmEkfiNod0Xusct68J1qc8Tdux0Z97Q+hsDb+AYGYEbF/4Guw2Q/qDPqZG/zXgT+3Qj8AtKnfWhFwmuAAAAAAElFTkSuQmCC"); + background-repeat: no-repeat; + background-position: center; + background-size: 23px; + vertical-align: bottom; +} +div.dtsp-topRow button.dtsp-countButton { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAG5SURBVEgN3VU9LwVBFF0fiYhofUSlEQkKhU7z/oBCQkIiGr9BgUbhVzy9BAnhFyjV/AYFiU5ICM7ZN+c5Zud5dm3lJmfmzrkz9+7cu3c3y/6jjOBSF8CxXS7FmTkbwqIJjDpJvTcmsJ4K3KPZUpyZsx0sxoB9J6mnAkyC7wGuuCFIipNtEcpcWExgXpOBc78vgj6N+QO4NVsjwdFM59tUIDxDrHMBOeIQ34C5ZDregXuAQm4YcI68nN9B3wr2PcwPAIPkN2EqtJH6b+QZm1ajjTx7BqwAr26Lb+C2Kvpbt0Mb2HAJ7NrGFGfmXO3DeA4UshDfQAVmH0gaUFg852TTTDvlxwBlCtxy9zXyBhQFaq0wMmIdRebrfgosA3zb2hKnqG0oqchp4QbuR8X0TjzABhbdOT8jnQ/atcgqpnfwOA7yqZyTU587ZkIGdesLTt2EkynOnbreMUUKMI/dA4B/QVOcO13CQh+5wWCgDwo/75u59odB/wjmfhbgvACcAOyZPHihMWAoIwxyCLgf1oxfgjzVbgBXSTzIN+f0pg6s5DkcesLMRpsBrgE2XO3CN64JFP7JtUeKHX4CKtRRXFZ+7dEAAAAASUVORK5CYII="); + background-repeat: no-repeat; + background-position: center; + background-size: 18px; + vertical-align: bottom; +} +div.dtsp-topRow button.dtsp-searchIcon { + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAEnSURBVCgVpdG7SgNBFIDh1RhJsBBEsDIgIhaWFjZa2GtpKb6AnU0MprKOWEjK2IuFFxCxS2lhZyOWXh5AQVER/X+zuwwywoIHvp3dM3Nm55Ik/4i+P2or5FewiBIe0cEt8ogVz9LbhEVf+cgkcew1tvAZ5PPXGm9HOMEanMAYQhunaCAazuqA1UjvILl9HGPc/n4fabjPGbzjMM2FjfkDuPw5O8JilzgA9/OKWDynyWnbsPiF7yc4SRWxmEyTN7ZhsSd7gTLW8TuGSSzBcZd2hsV+n+MNC9jGCNzjPDwsz8XCO/x02Bqeptcxhg+4gjD8YxetLOkBGRbuwcIr+NdRLMPl3uMM2YHx2gsLd+D97qKEQuGe65jCAzbgVRWOCUZuovAfs5m/AdVxL0R1AIsLAAAAAElFTkSuQmCC"); + background-repeat: no-repeat; + background-position: center; + background-size: 12px; +} + +div.dt-button-collection { + z-index: 2002; +} + +div.dataTables_scrollBody { + background: white !important; +} + +div.dtsp-columns-1 { + min-width: 98%; + max-width: 98%; + padding-left: 1%; + padding-right: 1%; + margin: 0px !important; +} + +div.dtsp-columns-2 { + min-width: 48%; + max-width: 48%; + padding-left: 1%; + padding-right: 1%; + margin: 0px !important; +} + +div.dtsp-columns-3 { + min-width: 30.333%; + max-width: 30.333%; + padding-left: 1%; + padding-right: 1%; + margin: 0px !important; +} + +div.dtsp-columns-4 { + min-width: 23%; + max-width: 23%; + padding-left: 1%; + padding-right: 1%; + margin: 0px !important; +} + +div.dtsp-columns-5 { + min-width: 18%; + max-width: 18%; + padding-left: 1%; + padding-right: 1%; + margin: 0px !important; +} + +div.dtsp-columns-6 { + min-width: 15.666%; + max-width: 15.666%; + padding-left: 0.5%; + padding-right: 0.5%; + margin: 0px !important; +} + +div.dtsp-columns-7 { + min-width: 13.28%; + max-width: 13.28%; + padding-left: 0.5%; + padding-right: 0.5%; + margin: 0px !important; +} + +div.dtsp-columns-8 { + min-width: 11.5%; + max-width: 11.5%; + padding-left: 0.5%; + padding-right: 0.5%; + margin: 0px !important; +} + +div.dtsp-columns-9 { + min-width: 11.111%; + max-width: 11.111%; + padding-left: 0.5%; + padding-right: 0.5%; + margin: 0px !important; +} + +div.dt-button-collection { + float: none; +} + +div.dtsp-panesContainer { + width: 100%; +} + +div.dtsp-searchPanes { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-evenly; + align-content: flex-start; + align-items: stretch; + clear: both; +} +div.dtsp-searchPanes button.btn { + margin: 0; +} +div.dtsp-searchPanes button.dtsp-clearAll { + max-width: 50px; +} + +div.dtsp-columns-1, +div.dtsp-columns-2, +div.dtsp-columns-3, +div.dtsp-columns-4, +div.dtsp-columns-5, +div.dtsp-columns-6, +div.dtsp-columns-7, +div.dtsp-columns-8, +div.dtsp-columns-9 { + padding-left: 0px; + padding-right: 0px; +} + +div.dtsp-searchPane { + flex-direction: row; + flex-wrap: nowrap; + flex-grow: 1; + flex-shrink: 0; + flex-basis: 280px; + justify-content: space-around; + align-content: flex-start; + align-items: stretch; + padding-top: 0px; + padding-bottom: 5px; + margin: 5px 0; + margin-top: 0px; + margin-bottom: 0px; + font-size: 0.9em; + margin: 5px; +} +div.dtsp-searchPane div.dataTables_wrapper { + flex: 1; +} +div.dtsp-searchPane div.dataTables_wrapper div.dataTables_filter { + display: none; +} +div.dtsp-searchPane div.dataTables_wrapper div.row div.col-sm-12:empty { + display: none; +} +div.dtsp-searchPane div.dataTables_wrapper div.row div.dataTables_filter { + display: none; +} +div.dtsp-searchPane div.btn-group { + padding: 0px; +} +div.dtsp-searchPane div.dtsp-topRow { + padding: 0px !important; + margin: 0px; + margin-bottom: 0.5rem; +} +div.dtsp-searchPane div.dtsp-topRow div.dtsp-subRows { + padding: 0px !important; + text-align: right; +} +div.dtsp-searchPane div.dtsp-topRow div.row { + width: 100%; +} +div.dtsp-searchPane div.dtsp-topRow button { + min-width: 35px; + max-width: 35px; + border: 1px solid #ced4da; +} +div.dtsp-searchPane div.dtsp-topRow div.dtsp-subRow2 { + margin-left: 5px; +} +div.dtsp-searchPane div.dtsp-topRow button.clearButton { + padding-left: 10px; +} +div.dtsp-searchPane thead { + display: none; +} +div.dtsp-searchPane .mb-3 { + margin-bottom: none !important; +} +div.dtsp-searchPane .col-sm-12 { + padding: 5px; +} +div.dtsp-searchPane .input-group { + padding: 0px !important; +} +div.dtsp-searchPane .input-group .input-group-append { + display: inline-block; +} +div.dtsp-searchPane div.dataTables_scrollHead { + display: none; +} +div.dtsp-searchPane div.dataTables_scrollBody { + padding: 2px; + border: 2px #f0f0f0 solid; + border-radius: 4px; +} +div.dtsp-searchPane div.dataTables_scrollBody:hover { + border: 2px solid #cfcfcf !important; +} +div.dtsp-searchPane div.dataTables_scrollBody table { + table-layout: fixed; +} +div.dtsp-searchPane div.dataTables_scrollBody table tbody tr td.dtsp-nameColumn { + width: 100% !important; +} +div.dtsp-searchPane div.dataTables_scrollBody table tbody tr div.dtsp-nameCont { + width: 100%; + display: flex; + flex-direction: row; + justify-content: flex-start; + align-content: flex-start; + align-items: flex-start; +} +div.dtsp-searchPane div.dataTables_scrollBody table tbody tr div.dtsp-nameCont span.dtsp-name { + text-overflow: ellipsis; + overflow: hidden; + display: inline-block; + vertical-align: middle; + white-space: nowrap; + flex-grow: 1; +} +div.dtsp-searchPane div.dataTables_scrollBody table tbody tr div.dtsp-nameCont span.badge { + min-width: 30px; + display: inline-block; + line-height: 1; + margin-top: 3.5px; +} +div.dtsp-searchPane div.dataTables_scrollBody table tbody tr td.dtsp-countColumn { + text-align: right; +} +div.dtsp-searchPane .dtsp-searchIcon { + display: block; + position: relative; + padding: 18px 13px; + border: 1px solid #ced4da; +} +div.dtsp-searchPane div.dataTables_wrapper div.dataTables_filter { + display: none; +} +div.dtsp-searchPane div.dataTables_wrapper div.row { + margin-left: -7px; + margin-right: -7px; +} +div.dtsp-searchPane div.badge { + min-width: 30px; +} + +div.dtsp-panes { + padding: 5px; + border: 2px solid #f0f0f0; + border-radius: 10px; + margin: 5px; + clear: both; +} +div.dtsp-panes div.dtsp-titleRow { + padding-bottom: 10px; + padding-left: 20px; + padding-right: 20px; +} +div.dtsp-panes div.dtsp-title { + float: left; + margin-bottom: 0px; + margin-top: 10px; + padding-left: 0; + padding-right: 0; +} +div.dtsp-panes button.dtsp-clearAll { + float: right; +} + +div.dtsp-hidden { + display: none !important; +} + +@media screen and (max-width: 767px) { + div.dtsp-columns-4, + div.dtsp-columns-5, + div.dtsp-columns-6 { + max-width: 31% !important; + min-width: 31% !important; + } +} +@media screen and (max-width: 640px) { + div.dtsp-searchPanes { + flex-direction: column !important; + } + + div.dtsp-searchPane { + max-width: 98% !important; + min-width: 98% !important; + } +} diff --git a/plugins/datatables-searchpanes/css/searchPanes.bootstrap4.min.css b/plugins/datatables-searchpanes/css/searchPanes.bootstrap4.min.css new file mode 100644 index 000000000..3f1a14384 --- /dev/null +++ b/plugins/datatables-searchpanes/css/searchPanes.bootstrap4.min.css @@ -0,0 +1 @@ +div.dtsp-topRow{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-around;align-content:flex-start;align-items:flex-start}div.dtsp-topRow input.dtsp-search{text-overflow:ellipsis}div.dtsp-topRow div.dtsp-subRow1{display:flex;flex-direction:row;flex-wrap:nowrap;flex-grow:1;flex-shrink:0;flex-basis:0}div.dtsp-topRow div.dtsp-searchCont{display:flex;flex-direction:row;flex-wrap:nowrap;flex-grow:1;flex-shrink:0;flex-basis:0}div.dtsp-topRow button.dtsp-nameButton{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAK2SURBVFgJ7ZY9j41BFICvryCExrJBQ6HyEYVEIREaUZDQIRoR2ViJKCioxV+gkVXYTVZEQiEUhG2EQnxUCh0FKolY4ut5XnM2cyfva3Pt5m7EPcmzZ2bemTNnzjkzd1utnvQi0IvAfxiBy5z5FoxO89kPY+8mbMjtzs47RXs5/WVpbAG6bWExt5PuIibvhVkwmC+ck3eK9ln6/fAddFojYzBVuYSBpcnIEvRaqOw2RcaN18FPuJH0JvRUxbT3wWf4ltiKPgfVidWlbGZgPozDFfgAC+EA/K2EI4cwcAJ+gPaeQ+VQU2SOMMGcPgPl/m/V2p50rrbRsRgt9Iv5h6xtpP22Bz7Ce1C+gFFxfKzOmShcU+Qmyh2w3w8rIJfddHTck66EukL/xPhj+JM8rHNmFys0Pg4v0up3aFNlwR9NYyodd3OL/C64zpsymcTFcf6ElM4YzjAWKYrJkaq8kE/yUYNP4BoYvS1QRo+hNtF5xfkTUjoTheukSFFMjlTFm6PjceOca/SMpKfeCR1L6Uzk/y2WIkVhNFJlJAZhP+hYns7b9D3IPuhY5mYrIv8OrQJvR5NYyNaW4jsU8pSGNySiVx4o5tXq3JkoXE/mg5R/M8dGJCJpKhaDcjBRdbI/Rm8g69c122om33BHmj2CHoV5qa9jUXBraJ+G1fAVjIBO1klc87ro1K4JZ/K35SWW3TwcyDd6TecqnAEd8cGq2+w84xvBm1n3vS0izKkkwh5XNC/GmFPqqAtPF89AOScKuemaNzoTV1SD5dtSbmLf1/RV+tC0WTgcj6R7HEtrVGWaqu/lYDZ/2pvxQ/kIyw/gFByHC9AHw910hv1aUUumyd8yy0QfhmEkfiNod0Xusct68J1qc8Tdux0Z97Q+hsDb+AYGYEbF/4Guw2Q/qDPqZG/zXgT+3Qj8AtKnfWhFwmuAAAAAAElFTkSuQmCC");background-repeat:no-repeat;background-position:center;background-size:23px;vertical-align:bottom}div.dtsp-topRow button.dtsp-countButton{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAG5SURBVEgN3VU9LwVBFF0fiYhofUSlEQkKhU7z/oBCQkIiGr9BgUbhVzy9BAnhFyjV/AYFiU5ICM7ZN+c5Zud5dm3lJmfmzrkz9+7cu3c3y/6jjOBSF8CxXS7FmTkbwqIJjDpJvTcmsJ4K3KPZUpyZsx0sxoB9J6mnAkyC7wGuuCFIipNtEcpcWExgXpOBc78vgj6N+QO4NVsjwdFM59tUIDxDrHMBOeIQ34C5ZDregXuAQm4YcI68nN9B3wr2PcwPAIPkN2EqtJH6b+QZm1ajjTx7BqwAr26Lb+C2Kvpbt0Mb2HAJ7NrGFGfmXO3DeA4UshDfQAVmH0gaUFg852TTTDvlxwBlCtxy9zXyBhQFaq0wMmIdRebrfgosA3zb2hKnqG0oqchp4QbuR8X0TjzABhbdOT8jnQ/atcgqpnfwOA7yqZyTU587ZkIGdesLTt2EkynOnbreMUUKMI/dA4B/QVOcO13CQh+5wWCgDwo/75u59odB/wjmfhbgvACcAOyZPHihMWAoIwxyCLgf1oxfgjzVbgBXSTzIN+f0pg6s5DkcesLMRpsBrgE2XO3CN64JFP7JtUeKHX4CKtRRXFZ+7dEAAAAASUVORK5CYII=");background-repeat:no-repeat;background-position:center;background-size:18px;vertical-align:bottom}div.dtsp-topRow button.dtsp-searchIcon{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAEnSURBVCgVpdG7SgNBFIDh1RhJsBBEsDIgIhaWFjZa2GtpKb6AnU0MprKOWEjK2IuFFxCxS2lhZyOWXh5AQVER/X+zuwwywoIHvp3dM3Nm55Ik/4i+P2or5FewiBIe0cEt8ogVz9LbhEVf+cgkcew1tvAZ5PPXGm9HOMEanMAYQhunaCAazuqA1UjvILl9HGPc/n4fabjPGbzjMM2FjfkDuPw5O8JilzgA9/OKWDynyWnbsPiF7yc4SRWxmEyTN7ZhsSd7gTLW8TuGSSzBcZd2hsV+n+MNC9jGCNzjPDwsz8XCO/x02Bqeptcxhg+4gjD8YxetLOkBGRbuwcIr+NdRLMPl3uMM2YHx2gsLd+D97qKEQuGe65jCAzbgVRWOCUZuovAfs5m/AdVxL0R1AIsLAAAAAElFTkSuQmCC");background-repeat:no-repeat;background-position:center;background-size:12px}div.dt-button-collection{z-index:2002}div.dataTables_scrollBody{background:white !important}div.dtsp-columns-1{min-width:98%;max-width:98%;padding-left:1%;padding-right:1%;margin:0px !important}div.dtsp-columns-2{min-width:48%;max-width:48%;padding-left:1%;padding-right:1%;margin:0px !important}div.dtsp-columns-3{min-width:30.333%;max-width:30.333%;padding-left:1%;padding-right:1%;margin:0px !important}div.dtsp-columns-4{min-width:23%;max-width:23%;padding-left:1%;padding-right:1%;margin:0px !important}div.dtsp-columns-5{min-width:18%;max-width:18%;padding-left:1%;padding-right:1%;margin:0px !important}div.dtsp-columns-6{min-width:15.666%;max-width:15.666%;padding-left:0.5%;padding-right:0.5%;margin:0px !important}div.dtsp-columns-7{min-width:13.28%;max-width:13.28%;padding-left:0.5%;padding-right:0.5%;margin:0px !important}div.dtsp-columns-8{min-width:11.5%;max-width:11.5%;padding-left:0.5%;padding-right:0.5%;margin:0px !important}div.dtsp-columns-9{min-width:11.111%;max-width:11.111%;padding-left:0.5%;padding-right:0.5%;margin:0px !important}div.dt-button-collection{float:none}div.dtsp-panesContainer{width:100%}div.dtsp-searchPanes{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-evenly;align-content:flex-start;align-items:stretch;clear:both}div.dtsp-searchPanes button.btn{margin:0}div.dtsp-searchPanes button.dtsp-clearAll{max-width:50px}div.dtsp-columns-1,div.dtsp-columns-2,div.dtsp-columns-3,div.dtsp-columns-4,div.dtsp-columns-5,div.dtsp-columns-6,div.dtsp-columns-7,div.dtsp-columns-8,div.dtsp-columns-9{padding-left:0px;padding-right:0px}div.dtsp-searchPane{flex-direction:row;flex-wrap:nowrap;flex-grow:1;flex-shrink:0;flex-basis:280px;justify-content:space-around;align-content:flex-start;align-items:stretch;padding-top:0px;padding-bottom:5px;margin:5px 0;margin-top:0px;margin-bottom:0px;font-size:0.9em;margin:5px}div.dtsp-searchPane div.dataTables_wrapper{flex:1}div.dtsp-searchPane div.dataTables_wrapper div.dataTables_filter{display:none}div.dtsp-searchPane div.dataTables_wrapper div.row div.col-sm-12:empty{display:none}div.dtsp-searchPane div.dataTables_wrapper div.row div.dataTables_filter{display:none}div.dtsp-searchPane div.btn-group{padding:0px}div.dtsp-searchPane div.dtsp-topRow{padding:0px !important;margin:0px;margin-bottom:0.5rem}div.dtsp-searchPane div.dtsp-topRow div.dtsp-subRows{padding:0px !important;text-align:right}div.dtsp-searchPane div.dtsp-topRow div.row{width:100%}div.dtsp-searchPane div.dtsp-topRow button{min-width:35px;max-width:35px;border:1px solid #ced4da}div.dtsp-searchPane div.dtsp-topRow div.dtsp-subRow2{margin-left:5px}div.dtsp-searchPane div.dtsp-topRow button.clearButton{padding-left:10px}div.dtsp-searchPane thead{display:none}div.dtsp-searchPane .mb-3{margin-bottom:none !important}div.dtsp-searchPane .col-sm-12{padding:5px}div.dtsp-searchPane .input-group{padding:0px !important}div.dtsp-searchPane .input-group .input-group-append{display:inline-block}div.dtsp-searchPane div.dataTables_scrollHead{display:none}div.dtsp-searchPane div.dataTables_scrollBody{padding:2px;border:2px #f0f0f0 solid;border-radius:4px}div.dtsp-searchPane div.dataTables_scrollBody:hover{border:2px solid #cfcfcf !important}div.dtsp-searchPane div.dataTables_scrollBody table{table-layout:fixed}div.dtsp-searchPane div.dataTables_scrollBody table tbody tr td.dtsp-nameColumn{width:100% !important}div.dtsp-searchPane div.dataTables_scrollBody table tbody tr div.dtsp-nameCont{width:100%;display:flex;flex-direction:row;justify-content:flex-start;align-content:flex-start;align-items:flex-start}div.dtsp-searchPane div.dataTables_scrollBody table tbody tr div.dtsp-nameCont span.dtsp-name{text-overflow:ellipsis;overflow:hidden;display:inline-block;vertical-align:middle;white-space:nowrap;flex-grow:1}div.dtsp-searchPane div.dataTables_scrollBody table tbody tr div.dtsp-nameCont span.badge{min-width:30px;display:inline-block;line-height:1;margin-top:3.5px}div.dtsp-searchPane div.dataTables_scrollBody table tbody tr td.dtsp-countColumn{text-align:right}div.dtsp-searchPane .dtsp-searchIcon{display:block;position:relative;padding:18px 13px;border:1px solid #ced4da}div.dtsp-searchPane div.dataTables_wrapper div.dataTables_filter{display:none}div.dtsp-searchPane div.dataTables_wrapper div.row{margin-left:-7px;margin-right:-7px}div.dtsp-searchPane div.badge{min-width:30px}div.dtsp-panes{padding:5px;border:2px solid #f0f0f0;border-radius:10px;margin:5px;clear:both}div.dtsp-panes div.dtsp-titleRow{padding-bottom:10px;padding-left:20px;padding-right:20px}div.dtsp-panes div.dtsp-title{float:left;margin-bottom:0px;margin-top:10px;padding-left:0;padding-right:0}div.dtsp-panes button.dtsp-clearAll{float:right}div.dtsp-hidden{display:none !important}@media screen and (max-width: 767px){div.dtsp-columns-4,div.dtsp-columns-5,div.dtsp-columns-6{max-width:31% !important;min-width:31% !important}}@media screen and (max-width: 640px){div.dtsp-searchPanes{flex-direction:column !important}div.dtsp-searchPane{max-width:98% !important;min-width:98% !important}} diff --git a/plugins/datatables-searchpanes/js/dataTables.searchPanes.js b/plugins/datatables-searchpanes/js/dataTables.searchPanes.js new file mode 100644 index 000000000..3567e1df7 --- /dev/null +++ b/plugins/datatables-searchpanes/js/dataTables.searchPanes.js @@ -0,0 +1,2550 @@ +/*! SearchPanes 1.2.1 + * 2019-2020 SpryMedia Ltd - datatables.net/license + */ +(function () { + 'use strict'; + + var $; + var DataTable; + function setJQuery(jq) { + $ = jq; + DataTable = jq.fn.dataTable; + } + var SearchPane = /** @class */ (function () { + /** + * Creates the panes, sets up the search function + * @param paneSettings The settings for the searchPanes + * @param opts The options for the default features + * @param idx the index of the column for this pane + * @returns {object} the pane that has been created, including the table and the index of the pane + */ + function SearchPane(paneSettings, opts, idx, layout, panesContainer, panes) { + var _this = this; + if (panes === void 0) { panes = null; } + // Check that the required version of DataTables is included + if (!DataTable || !DataTable.versionCheck || !DataTable.versionCheck('1.10.0')) { + throw new Error('SearchPane requires DataTables 1.10 or newer'); + } + // Check that Select is included + if (!DataTable.select) { + throw new Error('SearchPane requires Select'); + } + var table = new DataTable.Api(paneSettings); + this.classes = $.extend(true, {}, SearchPane.classes); + // Get options from user + this.c = $.extend(true, {}, SearchPane.defaults, opts); + this.customPaneSettings = panes; + this.s = { + cascadeRegen: false, + clearing: false, + colOpts: [], + deselect: false, + displayed: false, + dt: table, + dtPane: undefined, + filteringActive: false, + index: idx, + indexes: [], + lastCascade: false, + lastSelect: false, + listSet: false, + name: undefined, + redraw: false, + rowData: { + arrayFilter: [], + arrayOriginal: [], + arrayTotals: [], + bins: {}, + binsOriginal: {}, + binsTotal: {}, + filterMap: new Map(), + totalOptions: 0 + }, + scrollTop: 0, + searchFunction: undefined, + selectPresent: false, + serverSelect: [], + serverSelecting: false, + showFiltered: false, + tableLength: null, + updating: false + }; + var rowLength = table.columns().eq(0).toArray().length; + this.colExists = this.s.index < rowLength; + // Add extra elements to DOM object including clear and hide buttons + this.c.layout = layout; + var layVal = parseInt(layout.split('-')[1], 10); + this.dom = { + buttonGroup: $('<div/>').addClass(this.classes.buttonGroup), + clear: $('<button type="button">×</button>') + .addClass(this.classes.dull) + .addClass(this.classes.paneButton) + .addClass(this.classes.clearButton), + container: $('<div/>').addClass(this.classes.container).addClass(this.classes.layout + + (layVal < 10 ? layout : layout.split('-')[0] + '-9')), + countButton: $('<button type="button"></button>') + .addClass(this.classes.paneButton) + .addClass(this.classes.countButton), + dtP: $('<table><thead><tr><th>' + + (this.colExists + ? $(table.column(this.colExists ? this.s.index : 0).header()).text() + : this.customPaneSettings.header || 'Custom Pane') + '</th><th/></tr></thead></table>'), + lower: $('<div/>').addClass(this.classes.subRow2).addClass(this.classes.narrowButton), + nameButton: $('<button type="button"></button>').addClass(this.classes.paneButton).addClass(this.classes.nameButton), + panesContainer: panesContainer, + searchBox: $('<input/>').addClass(this.classes.paneInputButton).addClass(this.classes.search), + searchButton: $('<button type = "button" class="' + this.classes.searchIcon + '"></button>') + .addClass(this.classes.paneButton), + searchCont: $('<div/>').addClass(this.classes.searchCont), + searchLabelCont: $('<div/>').addClass(this.classes.searchLabelCont), + topRow: $('<div/>').addClass(this.classes.topRow), + upper: $('<div/>').addClass(this.classes.subRow1).addClass(this.classes.narrowSearch) + }; + this.s.displayed = false; + table = this.s.dt; + this.selections = []; + this.s.colOpts = this.colExists ? this._getOptions() : this._getBonusOptions(); + var colOpts = this.s.colOpts; + var clear = $('<button type="button">X</button>').addClass(this.classes.paneButton); + $(clear).text(table.i18n('searchPanes.clearPane', 'X')); + this.dom.container.addClass(colOpts.className); + this.dom.container.addClass((this.customPaneSettings !== null && this.customPaneSettings.className !== undefined) + ? this.customPaneSettings.className + : ''); + // Set the value of name incase ordering is desired + if (this.s.colOpts.name !== undefined) { + this.s.name = this.s.colOpts.name; + } + else if (this.customPaneSettings !== null && this.customPaneSettings.name !== undefined) { + this.s.name = this.customPaneSettings.name; + } + else { + this.s.name = this.colExists ? + $(table.column(this.s.index).header()).text() : + this.customPaneSettings.header || 'Custom Pane'; + } + $(panesContainer).append(this.dom.container); + var tableNode = table.table(0).node(); + // Custom search function for table + this.s.searchFunction = function (settings, searchData, dataIndex, origData) { + // If no data has been selected then show all + if (_this.selections.length === 0) { + return true; + } + if (settings.nTable !== tableNode) { + return true; + } + var filter = null; + if (_this.colExists) { + // Get the current filtered data + filter = searchData[_this.s.index]; + if (colOpts.orthogonal.filter !== 'filter') { + // get the filter value from the map + filter = _this.s.rowData.filterMap.get(dataIndex); + if (filter instanceof $.fn.dataTable.Api) { + filter = filter.toArray(); + } + } + } + return _this._search(filter, dataIndex); + }; + $.fn.dataTable.ext.search.push(this.s.searchFunction); + // If the clear button for this pane is clicked clear the selections + if (this.c.clear) { + $(clear).on('click', function () { + var searches = _this.dom.container.find(_this.classes.search); + searches.each(function () { + $(this).val(''); + $(this).trigger('input'); + }); + _this.clearPane(); + }); + } + // Sometimes the top row of the panes containing the search box and ordering buttons appears + // weird if the width of the panes is lower than expected, this fixes the design. + // Equally this may occur when the table is resized. + table.on('draw.dtsp', function () { + _this._adjustTopRow(); + }); + table.on('buttons-action', function () { + _this._adjustTopRow(); + }); + $(window).on('resize.dtsp', DataTable.util.throttle(function () { + _this._adjustTopRow(); + })); + // When column-reorder is present and the columns are moved, it is necessary to + // reassign all of the panes indexes to the new index of the column. + table.on('column-reorder.dtsp', function (e, settings, details) { + _this.s.index = details.mapping[_this.s.index]; + }); + return this; + } + /** + * In the case of a rebuild there is potential for new data to have been included or removed + * so all of the rowData must be reset as a precaution. + */ + SearchPane.prototype.clearData = function () { + this.s.rowData = { + arrayFilter: [], + arrayOriginal: [], + arrayTotals: [], + bins: {}, + binsOriginal: {}, + binsTotal: {}, + filterMap: new Map(), + totalOptions: 0 + }; + }; + /** + * Clear the selections in the pane + */ + SearchPane.prototype.clearPane = function () { + // Deselect all rows which are selected and update the table and filter count. + this.s.dtPane.rows({ selected: true }).deselect(); + this.updateTable(); + return this; + }; + /** + * Strips all of the SearchPanes elements from the document and turns all of the listeners for the buttons off + */ + SearchPane.prototype.destroy = function () { + $(this.s.dtPane).off('.dtsp'); + $(this.s.dt).off('.dtsp'); + $(this.dom.nameButton).off('.dtsp'); + $(this.dom.countButton).off('.dtsp'); + $(this.dom.clear).off('.dtsp'); + $(this.dom.searchButton).off('.dtsp'); + $(this.dom.container).remove(); + var searchIdx = $.fn.dataTable.ext.search.indexOf(this.s.searchFunction); + while (searchIdx !== -1) { + $.fn.dataTable.ext.search.splice(searchIdx, 1); + searchIdx = $.fn.dataTable.ext.search.indexOf(this.s.searchFunction); + } + // If the datatables have been defined for the panes then also destroy these + if (this.s.dtPane !== undefined) { + this.s.dtPane.destroy(); + } + this.s.listSet = false; + }; + /** + * Updates the number of filters that have been applied in the title + */ + SearchPane.prototype.getPaneCount = function () { + return this.s.dtPane !== undefined ? + this.s.dtPane.rows({ selected: true }).data().toArray().length : + 0; + }; + /** + * Rebuilds the panes from the start having deleted the old ones + * @param? last boolean to indicate if this is the last pane a selection was made in + * @param? dataIn data to be used in buildPane + * @param? init Whether this is the initial draw or not + * @param? maintainSelection Whether the current selections are to be maintained over rebuild + */ + SearchPane.prototype.rebuildPane = function (last, dataIn, init, maintainSelection) { + if (last === void 0) { last = false; } + if (dataIn === void 0) { dataIn = null; } + if (init === void 0) { init = null; } + if (maintainSelection === void 0) { maintainSelection = false; } + this.clearData(); + var selectedRows = []; + this.s.serverSelect = []; + var prevEl = null; + // When rebuilding strip all of the HTML Elements out of the container and start from scratch + if (this.s.dtPane !== undefined) { + if (maintainSelection) { + if (!this.s.dt.page.info().serverSide) { + selectedRows = this.s.dtPane.rows({ selected: true }).data().toArray(); + } + else { + this.s.serverSelect = this.s.dtPane.rows({ selected: true }).data().toArray(); + } + } + this.s.dtPane.clear().destroy(); + prevEl = $(this.dom.container).prev(); + this.destroy(); + this.s.dtPane = undefined; + $.fn.dataTable.ext.search.push(this.s.searchFunction); + } + this.dom.container.removeClass(this.classes.hidden); + this.s.displayed = false; + this._buildPane(!this.s.dt.page.info().serverSide ? + selectedRows : + this.s.serverSelect, last, dataIn, init, prevEl); + return this; + }; + /** + * removes the pane from the page and sets the displayed property to false. + */ + SearchPane.prototype.removePane = function () { + this.s.displayed = false; + $(this.dom.container).hide(); + }; + /** + * Sets the cascadeRegen property of the pane. Accessible from above because as SearchPanes.ts deals with the rebuilds. + * @param val the boolean value that the cascadeRegen property is to be set to + */ + SearchPane.prototype.setCascadeRegen = function (val) { + this.s.cascadeRegen = val; + }; + /** + * This function allows the clearing property to be assigned. This is used when implementing cascadePane. + * In setting this to true for the clearing of the panes selection on the deselects it forces the pane to + * repopulate from the entire dataset not just the displayed values. + * @param val the boolean value which the clearing property is to be assigned + */ + SearchPane.prototype.setClear = function (val) { + this.s.clearing = val; + }; + /** + * Updates the values of all of the panes + * @param draw whether this has been triggered by a draw event or not + */ + SearchPane.prototype.updatePane = function (draw) { + if (draw === void 0) { draw = false; } + this.s.updating = true; + this._updateCommon(draw); + this.s.updating = false; + }; + /** + * Updates the panes if one of the options to do so has been set to true + * rather than the filtered message when using viewTotal. + */ + SearchPane.prototype.updateTable = function () { + var selectedRows = this.s.dtPane.rows({ selected: true }).data().toArray(); + this.selections = selectedRows; + this._searchExtras(); + // If either of the options that effect how the panes are displayed are selected then update the Panes + if (this.c.cascadePanes || this.c.viewTotal) { + this.updatePane(); + } + }; + /** + * Sets the listeners for the pane. + * + * Having it in it's own function makes it easier to only set them once + */ + SearchPane.prototype._setListeners = function () { + var _this = this; + var rowData = this.s.rowData; + var t0; + // When an item is selected on the pane, add these to the array which holds selected items. + // Custom search will perform. + this.s.dtPane.on('select.dtsp', function () { + clearTimeout(t0); + if (_this.s.dt.page.info().serverSide && !_this.s.updating) { + if (!_this.s.serverSelecting) { + _this.s.serverSelect = _this.s.dtPane.rows({ selected: true }).data().toArray(); + _this.s.scrollTop = $(_this.s.dtPane.table().node()).parent()[0].scrollTop; + _this.s.selectPresent = true; + _this.s.dt.draw(false); + } + } + else { + $(_this.dom.clear).removeClass(_this.classes.dull); + _this.s.selectPresent = true; + if (!_this.s.updating) { + _this._makeSelection(); + } + _this.s.selectPresent = false; + } + }); + // When an item is deselected on the pane, re add the currently selected items to the array + // which holds selected items. Custom search will be performed. + this.s.dtPane.on('deselect.dtsp', function () { + t0 = setTimeout(function () { + if (_this.s.dt.page.info().serverSide && !_this.s.updating) { + if (!_this.s.serverSelecting) { + _this.s.serverSelect = _this.s.dtPane.rows({ selected: true }).data().toArray(); + _this.s.deselect = true; + _this.s.dt.draw(false); + } + } + else { + _this.s.deselect = true; + if (_this.s.dtPane.rows({ selected: true }).data().toArray().length === 0) { + $(_this.dom.clear).addClass(_this.classes.dull); + } + _this._makeSelection(); + _this.s.deselect = false; + _this.s.dt.state.save(); + } + }, 50); + }); + // When saving the state store all of the selected rows for preselection next time around + this.s.dt.on('stateSaveParams.dtsp', function (e, settings, data) { + // If the data being passed in is empty then a state clear must have occured so clear the panes state as well + if ($.isEmptyObject(data)) { + _this.s.dtPane.state.clear(); + return; + } + var selected = []; + var searchTerm; + var order; + var bins; + var arrayFilter; + // Get all of the data needed for the state save from the pane + if (_this.s.dtPane !== undefined) { + selected = _this.s.dtPane.rows({ selected: true }).data().map(function (item) { return item.filter.toString(); }).toArray(); + searchTerm = $(_this.dom.searchBox).val(); + order = _this.s.dtPane.order(); + bins = rowData.binsOriginal; + arrayFilter = rowData.arrayOriginal; + } + if (data.searchPanes === undefined) { + data.searchPanes = {}; + } + if (data.searchPanes.panes === undefined) { + data.searchPanes.panes = []; + } + // Add the panes data to the state object + data.searchPanes.panes.push({ + arrayFilter: arrayFilter, + bins: bins, + id: _this.s.index, + order: order, + searchTerm: searchTerm, + selected: selected + }); + }); + this.s.dtPane.on('user-select.dtsp', function (e, _dt, type, cell, originalEvent) { + originalEvent.stopPropagation(); + }); + this.s.dtPane.on('draw.dtsp', function () { + _this._adjustTopRow(); + }); + // When the button to order by the name of the options is clicked then + // change the ordering to whatever it isn't currently + $(this.dom.nameButton).on('click.dtsp', function () { + var currentOrder = _this.s.dtPane.order()[0][1]; + _this.s.dtPane.order([0, currentOrder === 'asc' ? 'desc' : 'asc']).draw(); + _this.s.dt.state.save(); + }); + // When the button to order by the number of entries in the column is clicked then + // change the ordering to whatever it isn't currently + $(this.dom.countButton).on('click.dtsp', function () { + var currentOrder = _this.s.dtPane.order()[0][1]; + _this.s.dtPane.order([1, currentOrder === 'asc' ? 'desc' : 'asc']).draw(); + _this.s.dt.state.save(); + }); + // When the clear button is clicked reset the pane + $(this.dom.clear).on('click.dtsp', function () { + var searches = _this.dom.container.find('.' + _this.classes.search); + searches.each(function () { + // set the value of the search box to be an empty string and then search on that, effectively reseting + $(this).val(''); + $(this).trigger('input'); + }); + _this.clearPane(); + }); + // When the search button is clicked then draw focus to the search box + $(this.dom.searchButton).on('click.dtsp', function () { + $(_this.dom.searchBox).focus(); + }); + // When a character is inputted into the searchbox search the pane for matching values. + // Doing it this way means that no button has to be clicked to trigger a search, it is done asynchronously + $(this.dom.searchBox).on('input.dtsp', function () { + _this.s.dtPane.search($(_this.dom.searchBox).val()).draw(); + _this.s.dt.state.save(); + }); + // Make sure to save the state once the pane has been built + this.s.dt.state.save(); + return true; + }; + /** + * Takes in potentially undetected rows and adds them to the array if they are not yet featured + * @param filter the filter value of the potential row + * @param display the display value of the potential row + * @param sort the sort value of the potential row + * @param type the type value of the potential row + * @param arrayFilter the array to be populated + * @param bins the bins to be populated + */ + SearchPane.prototype._addOption = function (filter, display, sort, type, arrayFilter, bins) { + // If the filter is an array then take a note of this, and add the elements to the arrayFilter array + if (Array.isArray(filter) || filter instanceof DataTable.Api) { + // Convert to an array so that we can work with it + if (filter instanceof DataTable.Api) { + filter = filter.toArray(); + display = display.toArray(); + } + if (filter.length === display.length) { + for (var i = 0; i < filter.length; i++) { + // If we haven't seen this row before add it + if (!bins[filter[i]]) { + bins[filter[i]] = 1; + arrayFilter.push({ + display: display[i], + filter: filter[i], + sort: sort[i], + type: type[i] + }); + } + // Otherwise just increment the count + else { + bins[filter[i]]++; + } + this.s.rowData.totalOptions++; + } + return; + } + else { + throw new Error('display and filter not the same length'); + } + } + // If the values were affected by othogonal data and are not an array then check if it is already present + else if (typeof this.s.colOpts.orthogonal === 'string') { + if (!bins[filter]) { + bins[filter] = 1; + arrayFilter.push({ + display: display, + filter: filter, + sort: sort, + type: type + }); + this.s.rowData.totalOptions++; + } + else { + bins[filter]++; + this.s.rowData.totalOptions++; + return; + } + } + // Otherwise we must just be adding an option + else { + arrayFilter.push({ + display: display, + filter: filter, + sort: sort, + type: type + }); + } + }; + /** + * Adds a row to the panes table + * @param display the value to be displayed to the user + * @param filter the value to be filtered on when searchpanes is implemented + * @param shown the number of rows in the table that are currently visible matching this criteria + * @param total the total number of rows in the table that match this criteria + * @param sort the value to be sorted in the pane table + * @param type the value of which the type is to be derived from + */ + SearchPane.prototype._addRow = function (display, filter, shown, total, sort, type, className) { + var index; + for (var _i = 0, _a = this.s.indexes; _i < _a.length; _i++) { + var entry = _a[_i]; + if (entry.filter === filter) { + index = entry.index; + } + } + if (index === undefined) { + index = this.s.indexes.length; + this.s.indexes.push({ filter: filter, index: index }); + } + return this.s.dtPane.row.add({ + className: className, + display: display !== '' ? + display : + this.s.colOpts.emptyMessage !== false ? + this.s.colOpts.emptyMessage : + this.c.emptyMessage, + filter: filter, + index: index, + shown: shown, + sort: sort !== '' ? + sort : + this.s.colOpts.emptyMessage !== false ? + this.s.colOpts.emptyMessage : + this.c.emptyMessage, + total: total, + type: type + }); + }; + /** + * Adjusts the layout of the top row when the screen is resized + */ + SearchPane.prototype._adjustTopRow = function () { + var subContainers = this.dom.container.find('.' + this.classes.subRowsContainer); + var subRow1 = this.dom.container.find('.dtsp-subRow1'); + var subRow2 = this.dom.container.find('.dtsp-subRow2'); + var topRow = this.dom.container.find('.' + this.classes.topRow); + // If the width is 0 then it is safe to assume that the pane has not yet been displayed. + // Even if it has, if the width is 0 it won't make a difference if it has the narrow class or not + if (($(subContainers[0]).width() < 252 || $(topRow[0]).width() < 252) && $(subContainers[0]).width() !== 0) { + $(subContainers[0]).addClass(this.classes.narrow); + $(subRow1[0]).addClass(this.classes.narrowSub).removeClass(this.classes.narrowSearch); + $(subRow2[0]).addClass(this.classes.narrowSub).removeClass(this.classes.narrowButton); + } + else { + $(subContainers[0]).removeClass(this.classes.narrow); + $(subRow1[0]).removeClass(this.classes.narrowSub).addClass(this.classes.narrowSearch); + $(subRow2[0]).removeClass(this.classes.narrowSub).addClass(this.classes.narrowButton); + } + }; + /** + * Method to construct the actual pane. + * @param selectedRows previously selected Rows to be reselected + * @last boolean to indicate whether this pane was the last one to have a selection made + */ + SearchPane.prototype._buildPane = function (selectedRows, last, dataIn, init, prevEl) { + var _this = this; + if (selectedRows === void 0) { selectedRows = []; } + if (last === void 0) { last = false; } + if (dataIn === void 0) { dataIn = null; } + if (init === void 0) { init = null; } + if (prevEl === void 0) { prevEl = null; } + // Aliases + this.selections = []; + var table = this.s.dt; + var column = table.column(this.colExists ? this.s.index : 0); + var colOpts = this.s.colOpts; + var rowData = this.s.rowData; + // Other Variables + var countMessage = table.i18n('searchPanes.count', '{total}'); + var filteredMessage = table.i18n('searchPanes.countFiltered', '{shown} ({total})'); + var loadedFilter = table.state.loaded(); + // If the listeners have not been set yet then using the latest state may result in funny errors + if (this.s.listSet) { + loadedFilter = table.state(); + } + // If it is not a custom pane in place + if (this.colExists) { + var idx = -1; + if (loadedFilter && loadedFilter.searchPanes && loadedFilter.searchPanes.panes) { + for (var i = 0; i < loadedFilter.searchPanes.panes.length; i++) { + if (loadedFilter.searchPanes.panes[i].id === this.s.index) { + idx = i; + break; + } + } + } + // Perform checks that do not require populate pane to run + if ((colOpts.show === false + || (colOpts.show !== undefined && colOpts.show !== true)) && + idx === -1) { + this.dom.container.addClass(this.classes.hidden); + this.s.displayed = false; + return false; + } + else if (colOpts.show === true || idx !== -1) { + this.s.displayed = true; + } + if (!this.s.dt.page.info().serverSide && dataIn === null) { + // Only run populatePane if the data has not been collected yet + if (rowData.arrayFilter.length === 0) { + this._populatePane(last); + this.s.rowData.totalOptions = 0; + this._detailsPane(); + if (loadedFilter && loadedFilter.searchPanes && loadedFilter.searchPanes.panes) { + // If the index is not found then no data has been added to the state for this pane, + // which will only occur if it has previously failed to meet the criteria to be + // displayed, therefore we can just hide it again here + if (idx !== -1) { + rowData.binsOriginal = loadedFilter.searchPanes.panes[idx].bins; + rowData.arrayOriginal = loadedFilter.searchPanes.panes[idx].arrayFilter; + } + else { + this.dom.container.addClass(this.classes.hidden); + this.s.displayed = false; + return; + } + } + else { + rowData.arrayOriginal = rowData.arrayTotals; + rowData.binsOriginal = rowData.binsTotal; + } + } + var binLength = Object.keys(rowData.binsOriginal).length; + var uniqueRatio = this._uniqueRatio(binLength, table.rows()[0].length); + // Don't show the pane if there isn't enough variance in the data, or there is only 1 entry for that pane + if (this.s.displayed === false && ((colOpts.show === undefined && colOpts.threshold === null ? + uniqueRatio > this.c.threshold : + uniqueRatio > colOpts.threshold) + || (colOpts.show !== true && binLength <= 1))) { + this.dom.container.addClass(this.classes.hidden); + this.s.displayed = false; + return; + } + // If the option viewTotal is true then find + // the total count for the whole table to display alongside the displayed count + if (this.c.viewTotal && rowData.arrayTotals.length === 0) { + this.s.rowData.totalOptions = 0; + this._detailsPane(); + } + else { + rowData.binsTotal = rowData.bins; + } + this.dom.container.addClass(this.classes.show); + this.s.displayed = true; + } + else if (dataIn !== null) { + if (dataIn.tableLength !== undefined) { + this.s.tableLength = dataIn.tableLength; + this.s.rowData.totalOptions = this.s.tableLength; + } + else if (this.s.tableLength === null || table.rows()[0].length > this.s.tableLength) { + this.s.tableLength = table.rows()[0].length; + this.s.rowData.totalOptions = this.s.tableLength; + } + var colTitle = table.column(this.s.index).dataSrc(); + if (dataIn[colTitle] !== undefined) { + for (var _i = 0, _a = dataIn[colTitle]; _i < _a.length; _i++) { + var dataPoint = _a[_i]; + this.s.rowData.arrayFilter.push({ + display: dataPoint.label, + filter: dataPoint.value, + sort: dataPoint.label, + type: dataPoint.label + }); + this.s.rowData.bins[dataPoint.value] = this.c.viewTotal || this.c.cascadePanes ? + dataPoint.count : + dataPoint.total; + this.s.rowData.binsTotal[dataPoint.value] = dataPoint.total; + } + } + var binLength = Object.keys(rowData.binsTotal).length; + var uniqueRatio = this._uniqueRatio(binLength, this.s.tableLength); + // Don't show the pane if there isn't enough variance in the data, or there is only 1 entry for that pane + if (this.s.displayed === false && ((colOpts.show === undefined && colOpts.threshold === null ? + uniqueRatio > this.c.threshold : + uniqueRatio > colOpts.threshold) + || (colOpts.show !== true && binLength <= 1))) { + this.dom.container.addClass(this.classes.hidden); + this.s.displayed = false; + return; + } + this.s.rowData.arrayOriginal = this.s.rowData.arrayFilter; + this.s.rowData.binsOriginal = this.s.rowData.bins; + this.s.displayed = true; + } + } + else { + this.s.displayed = true; + } + // If the variance is accceptable then display the search pane + this._displayPane(); + if (!this.s.listSet) { + // Here, when the state is loaded if the data object on the original table is empty, + // then a state.clear() must have occurred, so delete all of the panes tables state objects too. + this.dom.dtP.on('stateLoadParams.dt', function (e, settings, data) { + if ($.isEmptyObject(table.state.loaded())) { + $.each(data, function (index, value) { + delete data[index]; + }); + } + }); + } + // Add the container to the document in its original location + if (prevEl !== null && $(this.dom.panesContainer).has(prevEl).length > 0) { + $(this.dom.container).insertAfter(prevEl); + } + else { + $(this.dom.panesContainer).prepend(this.dom.container); + } + // Declare the datatable for the pane + var errMode = $.fn.dataTable.ext.errMode; + $.fn.dataTable.ext.errMode = 'none'; + var haveScroller = DataTable.Scroller; + this.s.dtPane = $(this.dom.dtP).DataTable($.extend(true, { + columnDefs: [ + { + className: 'dtsp-nameColumn', + data: 'display', + render: function (data, type, row) { + if (type === 'sort') { + return row.sort; + } + else if (type === 'type') { + return row.type; + } + var message; + (_this.s.filteringActive || _this.s.showFiltered) && _this.c.viewTotal + ? message = filteredMessage.replace(/{total}/, row.total) + : message = countMessage.replace(/{total}/, row.total); + message = message.replace(/{shown}/, row.shown); + while (message.indexOf('{total}') !== -1) { + message = message.replace(/{total}/, row.total); + } + while (message.indexOf('{shown}') !== -1) { + message = message.replace(/{shown}/, row.shown); + } + // We are displaying the count in the same columne as the name of the search option. + // This is so that there is not need to call columns.adjust(), which in turn speeds up the code + var pill = '<span class="' + _this.classes.pill + '">' + message + '</span>'; + if (_this.c.hideCount || colOpts.hideCount) { + pill = ''; + } + return '<div class="' + _this.classes.nameCont + '"><span title="' + + (typeof data === 'string' && data.match(/<[^>]*>/) !== null ? data.replace(/<[^>]*>/g, '') : data) + + '" class="' + _this.classes.name + '">' + + data + '</span>' + + pill + '</div>'; + }, + targets: 0, + // Accessing the private datatables property to set type based on the original table. + // This is null if not defined by the user, meaning that automatic type detection would take place + type: table.settings()[0].aoColumns[this.s.index] !== undefined ? + table.settings()[0].aoColumns[this.s.index]._sManualType : + null + }, + { + className: 'dtsp-countColumn ' + this.classes.badgePill, + data: 'shown', + orderData: [1, 2], + targets: 1, + visible: false + }, + { + data: 'total', + targets: 2, + visible: false + } + ], + deferRender: true, + dom: 't', + info: false, + language: this.s.dt.settings()[0].oLanguage, + paging: haveScroller ? true : false, + scrollX: false, + scrollY: '200px', + scroller: haveScroller ? true : false, + select: true, + stateSave: table.settings()[0].oFeatures.bStateSave ? true : false + }, this.c.dtOpts, colOpts !== undefined ? colOpts.dtOpts : {}, (this.s.colOpts.options !== undefined || !this.colExists) + ? { + createdRow: function (row, data, dataIndex) { + $(row).addClass(data.className); + } + } + : undefined, (this.customPaneSettings !== null && this.customPaneSettings.dtOpts !== undefined) + ? this.customPaneSettings.dtOpts + : {})); + $(this.dom.dtP).addClass(this.classes.table); + // This is hacky but necessary for when datatables is generating the column titles automatically + $(this.dom.searchBox).attr('placeholder', colOpts.header !== undefined + ? colOpts.header + : this.colExists + ? table.settings()[0].aoColumns[this.s.index].sTitle + : this.customPaneSettings.header || 'Custom Pane'); + // As the pane table is not in the document yet we must initialise select ourselves + $.fn.dataTable.select.init(this.s.dtPane); + $.fn.dataTable.ext.errMode = errMode; + // If it is not a custom pane + if (this.colExists) { + // On initialisation, do we need to set a filtering value from a + // saved state or init option? + var search = column.search(); + search = search ? search.substr(1, search.length - 2).split('|') : []; + // Count the number of empty cells + var count_1 = 0; + rowData.arrayFilter.forEach(function (element) { + if (element.filter === '') { + count_1++; + } + }); + // Add all of the search options to the pane + for (var i = 0, ien = rowData.arrayFilter.length; i < ien; i++) { + var selected = false; + for (var _b = 0, _c = this.s.serverSelect; _b < _c.length; _b++) { + var option = _c[_b]; + if (option.filter === rowData.arrayFilter[i].filter) { + selected = true; + } + } + if (this.s.dt.page.info().serverSide && + (!this.c.cascadePanes || + (this.c.cascadePanes && rowData.bins[rowData.arrayFilter[i].filter] !== 0) || + (this.c.cascadePanes && init !== null) || + selected)) { + var row = this._addRow(rowData.arrayFilter[i].display, rowData.arrayFilter[i].filter, init ? + rowData.binsTotal[rowData.arrayFilter[i].filter] : + rowData.bins[rowData.arrayFilter[i].filter], this.c.viewTotal || init + ? String(rowData.binsTotal[rowData.arrayFilter[i].filter]) + : rowData.bins[rowData.arrayFilter[i].filter], rowData.arrayFilter[i].sort, rowData.arrayFilter[i].type); + for (var _d = 0, _e = this.s.serverSelect; _d < _e.length; _d++) { + var option = _e[_d]; + if (option.filter === rowData.arrayFilter[i].filter) { + this.s.serverSelecting = true; + row.select(); + this.s.serverSelecting = false; + } + } + } + else if (!this.s.dt.page.info().serverSide && + rowData.arrayFilter[i] && + (rowData.bins[rowData.arrayFilter[i].filter] !== undefined || !this.c.cascadePanes)) { + this._addRow(rowData.arrayFilter[i].display, rowData.arrayFilter[i].filter, rowData.bins[rowData.arrayFilter[i].filter], rowData.binsTotal[rowData.arrayFilter[i].filter], rowData.arrayFilter[i].sort, rowData.arrayFilter[i].type); + } + else if (!this.s.dt.page.info().serverSide) { + // Just pass an empty string as the message will be calculated based on that in _addRow() + this._addRow('', count_1, count_1, '', '', ''); + } + } + } + DataTable.select.init(this.s.dtPane); + // If there are custom options set or it is a custom pane then get them + if (colOpts.options !== undefined || + (this.customPaneSettings !== null && this.customPaneSettings.options !== undefined)) { + this._getComparisonRows(); + } + // Display the pane + this.s.dtPane.draw(); + this._adjustTopRow(); + if (!this.s.listSet) { + this._setListeners(); + this.s.listSet = true; + } + for (var _f = 0, selectedRows_1 = selectedRows; _f < selectedRows_1.length; _f++) { + var selection = selectedRows_1[_f]; + if (selection !== undefined) { + for (var _g = 0, _h = this.s.dtPane.rows().indexes().toArray(); _g < _h.length; _g++) { + var row = _h[_g]; + if (this.s.dtPane.row(row).data() !== undefined && selection.filter === this.s.dtPane.row(row).data().filter) { + // If this is happening when serverSide processing is happening then different behaviour is needed + if (this.s.dt.page.info().serverSide) { + this.s.serverSelecting = true; + this.s.dtPane.row(row).select(); + this.s.serverSelecting = false; + } + else { + this.s.dtPane.row(row).select(); + } + } + } + } + } + // If SSP and the table is ready, apply the search for the pane + if (this.s.dt.page.info().serverSide) { + this.s.dtPane.search($(this.dom.searchBox).val()).draw(); + } + // Reload the selection, searchbox entry and ordering from the previous state + if (loadedFilter && loadedFilter.searchPanes && loadedFilter.searchPanes.panes) { + if (!this.c.cascadePanes) { + this._reloadSelect(loadedFilter); + } + for (var _j = 0, _k = loadedFilter.searchPanes.panes; _j < _k.length; _j++) { + var pane = _k[_j]; + if (pane.id === this.s.index) { + $(this.dom.searchBox).val(pane.searchTerm); + $(this.dom.searchBox).trigger('input'); + this.s.dtPane.order(pane.order).draw(); + } + } + } + // Make sure to save the state once the pane has been built + this.s.dt.state.save(); + return true; + }; + /** + * Update the array which holds the display and filter values for the table + */ + SearchPane.prototype._detailsPane = function () { + var table = this.s.dt; + this.s.rowData.arrayTotals = []; + this.s.rowData.binsTotal = {}; + var settings = this.s.dt.settings()[0]; + var indexArray = table.rows().indexes(); + if (!this.s.dt.page.info().serverSide) { + for (var _i = 0, indexArray_1 = indexArray; _i < indexArray_1.length; _i++) { + var rowIdx = indexArray_1[_i]; + this._populatePaneArray(rowIdx, this.s.rowData.arrayTotals, settings, this.s.rowData.binsTotal); + } + } + }; + /** + * Appends all of the HTML elements to their relevant parent Elements + */ + SearchPane.prototype._displayPane = function () { + var container = this.dom.container; + var colOpts = this.s.colOpts; + var layVal = parseInt(this.c.layout.split('-')[1], 10); + // Empty everything to start again + $(this.dom.topRow).empty(); + $(this.dom.dtP).empty(); + $(this.dom.topRow).addClass(this.classes.topRow); + // If there are more than 3 columns defined then make there be a smaller gap between the panes + if (layVal > 3) { + $(this.dom.container).addClass(this.classes.smallGap); + } + $(this.dom.topRow).addClass(this.classes.subRowsContainer); + $(this.dom.upper).appendTo(this.dom.topRow); + $(this.dom.lower).appendTo(this.dom.topRow); + $(this.dom.searchCont).appendTo(this.dom.upper); + $(this.dom.buttonGroup).appendTo(this.dom.lower); + // If no selections have been made in the pane then disable the clear button + if (this.c.dtOpts.searching === false || + (colOpts.dtOpts !== undefined && + colOpts.dtOpts.searching === false) || + (!this.c.controls || !colOpts.controls) || + (this.customPaneSettings !== null && + this.customPaneSettings.dtOpts !== undefined && + this.customPaneSettings.dtOpts.searching !== undefined && + !this.customPaneSettings.dtOpts.searching)) { + $(this.dom.searchBox).attr('disabled', 'disabled') + .removeClass(this.classes.paneInputButton) + .addClass(this.classes.disabledButton); + } + $(this.dom.searchBox).appendTo(this.dom.searchCont); + // Create the contents of the searchCont div. Worth noting that this function will change when using semantic ui + this._searchContSetup(); + // If the clear button is allowed to show then display it + if (this.c.clear && this.c.controls && colOpts.controls) { + $(this.dom.clear).appendTo(this.dom.buttonGroup); + } + if (this.c.orderable && colOpts.orderable && this.c.controls && colOpts.controls) { + $(this.dom.nameButton).appendTo(this.dom.buttonGroup); + } + // If the count column is hidden then don't display the ordering button for it + if (!this.c.hideCount && + !colOpts.hideCount && + this.c.orderable && + colOpts.orderable && + this.c.controls && + colOpts.controls) { + $(this.dom.countButton).appendTo(this.dom.buttonGroup); + } + $(this.dom.topRow).prependTo(this.dom.container); + $(container).append(this.dom.dtP); + $(container).show(); + }; + /** + * Gets the options for the row for the customPanes + * @returns {object} The options for the row extended to include the options from the user. + */ + SearchPane.prototype._getBonusOptions = function () { + // We need to reset the thresholds as if they have a value in colOpts then that value will be used + var defaultMutator = { + orthogonal: { + threshold: null + }, + threshold: null + }; + return $.extend(true, {}, SearchPane.defaults, defaultMutator, this.c !== undefined ? this.c : {}); + }; + /** + * Adds the custom options to the pane + * @returns {Array} Returns the array of rows which have been added to the pane + */ + SearchPane.prototype._getComparisonRows = function () { + var colOpts = this.s.colOpts; + // Find the appropriate options depending on whether this is a pane for a specific column or a custom pane + var options = colOpts.options !== undefined + ? colOpts.options + : this.customPaneSettings !== null && this.customPaneSettings.options !== undefined + ? this.customPaneSettings.options + : undefined; + if (options === undefined) { + return; + } + var tableVals = this.s.dt.rows({ search: 'applied' }).data().toArray(); + var appRows = this.s.dt.rows({ search: 'applied' }); + var tableValsTotal = this.s.dt.rows().data().toArray(); + var allRows = this.s.dt.rows(); + var rows = []; + // Clear all of the other rows from the pane, only custom options are to be displayed when they are defined + this.s.dtPane.clear(); + for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { + var comp = options_1[_i]; + // Initialise the object which is to be placed in the row + var insert = comp.label !== '' ? comp.label : this.c.emptyMessage; + var comparisonObj = { + className: comp.className, + display: insert, + filter: typeof comp.value === 'function' ? comp.value : [], + shown: 0, + sort: insert, + total: 0, + type: insert + }; + // If a custom function is in place + if (typeof comp.value === 'function') { + // Count the number of times the function evaluates to true for the data currently being displayed + for (var tVal = 0; tVal < tableVals.length; tVal++) { + if (comp.value.call(this.s.dt, tableVals[tVal], appRows[0][tVal])) { + comparisonObj.shown++; + } + } + // Count the number of times the function evaluates to true for the original data in the Table + for (var i = 0; i < tableValsTotal.length; i++) { + if (comp.value.call(this.s.dt, tableValsTotal[i], allRows[0][i])) { + comparisonObj.total++; + } + } + // Update the comparisonObj + if (typeof comparisonObj.filter !== 'function') { + comparisonObj.filter.push(comp.filter); + } + } + // If cascadePanes is not active or if it is and the comparisonObj should be shown then add it to the pane + if (!this.c.cascadePanes || (this.c.cascadePanes && comparisonObj.shown !== 0)) { + rows.push(this._addRow(comparisonObj.display, comparisonObj.filter, comparisonObj.shown, comparisonObj.total, comparisonObj.sort, comparisonObj.type, comparisonObj.className)); + } + } + return rows; + }; + /** + * Gets the options for the row for the customPanes + * @returns {object} The options for the row extended to include the options from the user. + */ + SearchPane.prototype._getOptions = function () { + var table = this.s.dt; + // We need to reset the thresholds as if they have a value in colOpts then that value will be used + var defaultMutator = { + emptyMessage: false, + orthogonal: { + threshold: null + }, + threshold: null + }; + return $.extend(true, {}, SearchPane.defaults, defaultMutator, table.settings()[0].aoColumns[this.s.index].searchPanes); + }; + /** + * This method allows for changes to the panes and table to be made when a selection or a deselection occurs + * @param select Denotes whether a selection has been made or not + */ + SearchPane.prototype._makeSelection = function () { + this.updateTable(); + this.s.updating = true; + this.s.dt.draw(); + this.s.updating = false; + }; + /** + * Fill the array with the values that are currently being displayed in the table + * @param last boolean to indicate whether this was the last pane a selection was made in + */ + SearchPane.prototype._populatePane = function (last) { + if (last === void 0) { last = false; } + var table = this.s.dt; + this.s.rowData.arrayFilter = []; + this.s.rowData.bins = {}; + var settings = this.s.dt.settings()[0]; + // If cascadePanes or viewTotal are active it is necessary to get the data which is currently + // being displayed for their functionality. Also make sure that this was not the last pane to have a selection made + if (!this.s.dt.page.info().serverSide) { + var indexArray = (this.c.cascadePanes || this.c.viewTotal) && (!this.s.clearing && !last) ? + table.rows({ search: 'applied' }).indexes() : + table.rows().indexes(); + for (var _i = 0, _a = indexArray.toArray(); _i < _a.length; _i++) { + var index = _a[_i]; + this._populatePaneArray(index, this.s.rowData.arrayFilter, settings); + } + } + }; + /** + * Populates an array with all of the data for the table + * @param rowIdx The current row index to be compared + * @param arrayFilter The array that is to be populated with row Details + * @param bins The bins object that is to be populated with the row counts + */ + SearchPane.prototype._populatePaneArray = function (rowIdx, arrayFilter, settings, bins) { + if (bins === void 0) { bins = this.s.rowData.bins; } + var colOpts = this.s.colOpts; + // Retrieve the rendered data from the cell using the fnGetCellData function + // rather than the cell().render API method for optimisation + if (typeof colOpts.orthogonal === 'string') { + var rendered = settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal); + this.s.rowData.filterMap.set(rowIdx, rendered); + this._addOption(rendered, rendered, rendered, rendered, arrayFilter, bins); + } + else { + var filter = settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal.search); + if (typeof filter === 'string') { + filter = filter.replace(/<[^>]*>/g, ''); + } + this.s.rowData.filterMap.set(rowIdx, filter); + if (!bins[filter]) { + bins[filter] = 1; + this._addOption(filter, settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal.display), settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal.sort), settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal.type), arrayFilter, bins); + this.s.rowData.totalOptions++; + } + else { + bins[filter]++; + this.s.rowData.totalOptions++; + return; + } + } + }; + /** + * Reloads all of the previous selects into the panes + * @param loadedFilter The loaded filters from a previous state + */ + SearchPane.prototype._reloadSelect = function (loadedFilter) { + // If the state was not saved don't selected any + if (loadedFilter === undefined) { + return; + } + var idx; + // For each pane, check that the loadedFilter list exists and is not null, + // find the id of each search item and set it to be selected. + for (var i = 0; i < loadedFilter.searchPanes.panes.length; i++) { + if (loadedFilter.searchPanes.panes[i].id === this.s.index) { + idx = i; + break; + } + } + if (idx !== undefined) { + var table = this.s.dtPane; + var rows = table.rows({ order: 'index' }).data().map(function (item) { return item.filter !== null ? + item.filter.toString() : + null; }).toArray(); + for (var _i = 0, _a = loadedFilter.searchPanes.panes[idx].selected; _i < _a.length; _i++) { + var filter = _a[_i]; + var id = -1; + if (filter !== null) { + id = rows.indexOf(filter.toString()); + } + if (id > -1) { + table.row(id).select(); + this.s.dt.state.save(); + } + } + } + }; + /** + * This method decides whether a row should contribute to the pane or not + * @param filter the value that the row is to be filtered on + * @param dataIndex the row index + */ + SearchPane.prototype._search = function (filter, dataIndex) { + var colOpts = this.s.colOpts; + var table = this.s.dt; + // For each item selected in the pane, check if it is available in the cell + for (var _i = 0, _a = this.selections; _i < _a.length; _i++) { + var colSelect = _a[_i]; + // if the filter is an array then is the column present in it + if (Array.isArray(filter)) { + if (filter.indexOf(colSelect.filter) !== -1) { + return true; + } + } + // if the filter is a function then does it meet the criteria of that function or not + else if (typeof colSelect.filter === 'function') { + if (colSelect.filter.call(table, table.row(dataIndex).data(), dataIndex)) { + if (colOpts.combiner === 'or') { + return true; + } + } + // If the combiner is an "and" then we need to check against all possible selections + // so if it fails here then the and is not met and return false + else if (colOpts.combiner === 'and') { + return false; + } + } + // otherwise if the two filter values are equal then return true + // Loose type checking incase number type in column comparing to a string + else if ((filter === colSelect.filter) || + (!(typeof filter === 'string' && filter.length === 0) && filter == colSelect.filter) || + (colSelect.filter === null && typeof filter === 'string' && filter === '')) { + return true; + } + } + // If the combiner is an and then we need to check against all possible selections + // so return true here if so because it would have returned false earlier if it had failed + if (colOpts.combiner === 'and') { + return true; + } + // Otherwise it hasn't matched with anything by this point so it must be false + else { + return false; + } + }; + /** + * Creates the contents of the searchCont div + * + * NOTE This is overridden when semantic ui styling in order to integrate the search button into the text box. + */ + SearchPane.prototype._searchContSetup = function () { + if (this.c.controls && this.s.colOpts.controls) { + $(this.dom.searchButton).appendTo(this.dom.searchLabelCont); + } + if (!(this.c.dtOpts.searching === false || + this.s.colOpts.dtOpts.searching === false || + (this.customPaneSettings !== null && + this.customPaneSettings.dtOpts !== undefined && + this.customPaneSettings.dtOpts.searching !== undefined && + !this.customPaneSettings.dtOpts.searching))) { + $(this.dom.searchLabelCont).appendTo(this.dom.searchCont); + } + }; + /** + * Adds outline to the pane when a selection has been made + */ + SearchPane.prototype._searchExtras = function () { + var updating = this.s.updating; + this.s.updating = true; + var filters = this.s.dtPane.rows({ selected: true }).data().pluck('filter').toArray(); + var nullIndex = filters.indexOf(this.s.colOpts.emptyMessage !== false ? + this.s.colOpts.emptyMessage : + this.c.emptyMessage); + var container = $(this.s.dtPane.table().container()); + // If null index is found then search for empty cells as a filter. + if (nullIndex > -1) { + filters[nullIndex] = ''; + } + // If a filter has been applied then outline the respective pane, remove it when it no longer is. + if (filters.length > 0) { + container.addClass(this.classes.selected); + } + else if (filters.length === 0) { + container.removeClass(this.classes.selected); + } + this.s.updating = updating; + }; + /** + * Finds the ratio of the number of different options in the table to the number of rows + * @param bins the number of different options in the table + * @param rowCount the total number of rows in the table + * @returns {number} returns the ratio + */ + SearchPane.prototype._uniqueRatio = function (bins, rowCount) { + if (rowCount > 0 && + ((this.s.rowData.totalOptions > 0 && !this.s.dt.page.info().serverSide) || + (this.s.dt.page.info().serverSide && this.s.tableLength > 0))) { + return bins / this.s.rowData.totalOptions; + } + else { + return 1; + } + }; + /** + * updates the options within the pane + * @param draw a flag to define whether this has been called due to a draw event or not + */ + SearchPane.prototype._updateCommon = function (draw) { + if (draw === void 0) { draw = false; } + // Update the panes if doing a deselect. if doing a select then + // update all of the panes except for the one causing the change + if (!this.s.dt.page.info().serverSide && + this.s.dtPane !== undefined && + (!this.s.filteringActive || this.c.cascadePanes || draw === true) && + (this.c.cascadePanes !== true || this.s.selectPresent !== true) && (!this.s.lastSelect || !this.s.lastCascade)) { + var colOpts = this.s.colOpts; + var selected = this.s.dtPane.rows({ selected: true }).data().toArray(); + var scrollTop = $(this.s.dtPane.table().node()).parent()[0].scrollTop; + var rowData = this.s.rowData; + // Clear the pane in preparation for adding the updated search options + this.s.dtPane.clear(); + // If it is not a custom pane + if (this.colExists) { + // Only run populatePane if the data has not been collected yet + if (rowData.arrayFilter.length === 0) { + this._populatePane(); + } + // If cascadePanes is active and the table has returned to its default state then + // there is a need to update certain parts ofthe rowData. + else if (this.c.cascadePanes + && this.s.dt.rows().data().toArray().length === this.s.dt.rows({ search: 'applied' }).data().toArray().length) { + rowData.arrayFilter = rowData.arrayOriginal; + rowData.bins = rowData.binsOriginal; + } + // Otherwise if viewTotal or cascadePanes is active then the data from the table must be read. + else if (this.c.viewTotal || this.c.cascadePanes) { + this._populatePane(); + } + // If the viewTotal option is selected then find the totals for the table + if (this.c.viewTotal) { + this._detailsPane(); + } + else { + rowData.binsTotal = rowData.bins; + } + if (this.c.viewTotal && !this.c.cascadePanes) { + rowData.arrayFilter = rowData.arrayTotals; + } + var _loop_1 = function (dataP) { + // If both view Total and cascadePanes have been selected and the count of the row is not 0 then add it to pane + // Do this also if the viewTotal option has been selected and cascadePanes has not + if (dataP && ((rowData.bins[dataP.filter] !== undefined && rowData.bins[dataP.filter] !== 0 && this_1.c.cascadePanes) + || !this_1.c.cascadePanes + || this_1.s.clearing)) { + var row = this_1._addRow(dataP.display, dataP.filter, !this_1.c.viewTotal + ? rowData.bins[dataP.filter] + : rowData.bins[dataP.filter] !== undefined + ? rowData.bins[dataP.filter] + : 0, this_1.c.viewTotal + ? String(rowData.binsTotal[dataP.filter]) + : rowData.bins[dataP.filter], dataP.sort, dataP.type); + // Find out if the filter was selected in the previous search, if so select it and remove from array. + var selectIndex = selected.findIndex(function (element) { + return element.filter === dataP.filter; + }); + if (selectIndex !== -1) { + row.select(); + selected.splice(selectIndex, 1); + } + } + }; + var this_1 = this; + for (var _i = 0, _a = rowData.arrayFilter; _i < _a.length; _i++) { + var dataP = _a[_i]; + _loop_1(dataP); + } + } + if ((colOpts.searchPanes !== undefined && colOpts.searchPanes.options !== undefined) || + colOpts.options !== undefined || + (this.customPaneSettings !== null && this.customPaneSettings.options !== undefined)) { + var rows = this._getComparisonRows(); + var _loop_2 = function (row) { + var selectIndex = selected.findIndex(function (element) { + if (element.display === row.data().display) { + return true; + } + }); + if (selectIndex !== -1) { + row.select(); + selected.splice(selectIndex, 1); + } + }; + for (var _b = 0, rows_1 = rows; _b < rows_1.length; _b++) { + var row = rows_1[_b]; + _loop_2(row); + } + } + // Add search options which were previously selected but whos results are no + // longer present in the resulting data set. + for (var _c = 0, selected_1 = selected; _c < selected_1.length; _c++) { + var selectedEl = selected_1[_c]; + var row = this._addRow(selectedEl.display, selectedEl.filter, 0, this.c.viewTotal + ? selectedEl.total + : 0, selectedEl.display, selectedEl.display); + this.s.updating = true; + row.select(); + this.s.updating = false; + } + this.s.dtPane.draw(); + this.s.dtPane.table().node().parentNode.scrollTop = scrollTop; + } + }; + SearchPane.version = '1.1.0'; + SearchPane.classes = { + buttonGroup: 'dtsp-buttonGroup', + buttonSub: 'dtsp-buttonSub', + clear: 'dtsp-clear', + clearAll: 'dtsp-clearAll', + clearButton: 'clearButton', + container: 'dtsp-searchPane', + countButton: 'dtsp-countButton', + disabledButton: 'dtsp-disabledButton', + dull: 'dtsp-dull', + hidden: 'dtsp-hidden', + hide: 'dtsp-hide', + layout: 'dtsp-', + name: 'dtsp-name', + nameButton: 'dtsp-nameButton', + nameCont: 'dtsp-nameCont', + narrow: 'dtsp-narrow', + paneButton: 'dtsp-paneButton', + paneInputButton: 'dtsp-paneInputButton', + pill: 'dtsp-pill', + search: 'dtsp-search', + searchCont: 'dtsp-searchCont', + searchIcon: 'dtsp-searchIcon', + searchLabelCont: 'dtsp-searchButtonCont', + selected: 'dtsp-selected', + smallGap: 'dtsp-smallGap', + subRow1: 'dtsp-subRow1', + subRow2: 'dtsp-subRow2', + subRowsContainer: 'dtsp-subRowsContainer', + title: 'dtsp-title', + topRow: 'dtsp-topRow' + }; + // Define SearchPanes default options + SearchPane.defaults = { + cascadePanes: false, + clear: true, + combiner: 'or', + controls: true, + container: function (dt) { + return dt.table().container(); + }, + dtOpts: {}, + emptyMessage: '<i>No Data</i>', + hideCount: false, + layout: 'columns-3', + name: undefined, + orderable: true, + orthogonal: { + display: 'display', + filter: 'filter', + hideCount: false, + search: 'filter', + show: undefined, + sort: 'sort', + threshold: 0.6, + type: 'type' + }, + preSelect: [], + threshold: 0.6, + viewTotal: false + }; + return SearchPane; + }()); + + var $$1; + var DataTable$1; + function setJQuery$1(jq) { + $$1 = jq; + DataTable$1 = jq.fn.dataTable; + } + var SearchPanes = /** @class */ (function () { + function SearchPanes(paneSettings, opts, fromInit) { + var _this = this; + if (fromInit === void 0) { fromInit = false; } + this.regenerating = false; + // Check that the required version of DataTables is included + if (!DataTable$1 || !DataTable$1.versionCheck || !DataTable$1.versionCheck('1.10.0')) { + throw new Error('SearchPane requires DataTables 1.10 or newer'); + } + // Check that Select is included + if (!DataTable$1.select) { + throw new Error('SearchPane requires Select'); + } + var table = new DataTable$1.Api(paneSettings); + this.classes = $$1.extend(true, {}, SearchPanes.classes); + // Get options from user + this.c = $$1.extend(true, {}, SearchPanes.defaults, opts); + // Add extra elements to DOM object including clear + this.dom = { + clearAll: $$1('<button type="button">Clear All</button>').addClass(this.classes.clearAll), + container: $$1('<div/>').addClass(this.classes.panes).text(table.i18n('searchPanes.loadMessage', 'Loading Search Panes...')), + emptyMessage: $$1('<div/>').addClass(this.classes.emptyMessage), + options: $$1('<div/>').addClass(this.classes.container), + panes: $$1('<div/>').addClass(this.classes.container), + title: $$1('<div/>').addClass(this.classes.title), + titleRow: $$1('<div/>').addClass(this.classes.titleRow), + wrapper: $$1('<div/>') + }; + this.s = { + colOpts: [], + dt: table, + filterPane: -1, + panes: [], + selectionList: [], + serverData: {}, + stateRead: false, + updating: false + }; + if (table.settings()[0]._searchPanes !== undefined) { + return; + } + // We are using the xhr event to rebuild the panes if required due to viewTotal being enabled + // If viewTotal is not enabled then we simply update the data from the server + table.on('xhr', function (e, settings, json, xhr) { + if (json.searchPanes && json.searchPanes.options) { + _this.s.serverData = json.searchPanes.options; + _this.s.serverData.tableLength = json.recordsTotal; + _this._serverTotals(); + } + }); + table.settings()[0]._searchPanes = this; + this.dom.clearAll.text(table.i18n('searchPanes.clearMessage', 'Clear All')); + this._getState(); + if (this.s.dt.settings()[0]._bInitComplete || fromInit) { + this._paneDeclare(table, paneSettings, opts); + } + else { + table.one('preInit.dt', function (settings) { + _this._paneDeclare(table, paneSettings, opts); + }); + } + return this; + } + /** + * Clear the selections of all of the panes + */ + SearchPanes.prototype.clearSelections = function () { + // Load in all of the searchBoxes in the documents + var searches = this.dom.container.find(this.classes.search); + // For each searchBox set the input text to be empty and then trigger + // an input on them so that they no longer filter the panes + searches.each(function () { + $$1(this).val(''); + $$1(this).trigger('input'); + }); + var returnArray = []; + // For every pane, clear the selections in the pane + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (pane.s.dtPane !== undefined) { + returnArray.push(pane.clearPane()); + } + } + this.s.dt.draw(); + return returnArray; + }; + /** + * returns the container node for the searchPanes + */ + SearchPanes.prototype.getNode = function () { + return this.dom.container; + }; + /** + * rebuilds all of the panes + */ + SearchPanes.prototype.rebuild = function (targetIdx, maintainSelection) { + if (targetIdx === void 0) { targetIdx = false; } + if (maintainSelection === void 0) { maintainSelection = false; } + $$1(this.dom.emptyMessage).remove(); + // As a rebuild from scratch is required, empty the searchpanes container. + var returnArray = []; + // Rebuild each pane individually, if a specific pane has been selected then only rebuild that one + if (targetIdx === false) { + $$1(this.dom.panes).empty(); + } + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (targetIdx !== false && pane.s.index !== targetIdx) { + continue; + } + pane.clearData(); + returnArray.push( + // Pass a boolean to say whether this is the last choice made for maintaining selections when rebuilding + pane.rebuildPane(this.s.selectionList[this.s.selectionList.length - 1] !== undefined ? + pane.s.index === this.s.selectionList[this.s.selectionList.length - 1].index : + false, this.s.dt.page.info().serverSide ? + this.s.serverData : + undefined, null, maintainSelection)); + $$1(this.dom.panes).append(pane.dom.container); + } + // Only need to trigger a search if it is not server side processing + if (!this.s.dt.page.info().serverSide) { + this.s.dt.draw(); + } + if (this.c.cascadePanes || this.c.viewTotal) { + this.redrawPanes(true); + } + else { + this._updateSelection(); + } + // Attach panes, clear buttons, and title bar to the document + this._updateFilterCount(); + this._attachPaneContainer(); + this.s.dt.draw(); + // If a single pane has been rebuilt then return only that pane + if (returnArray.length === 1) { + return returnArray[0]; + } + // Otherwise return all of the panes that have been rebuilt + else { + return returnArray; + } + }; + /** + * Redraws all of the panes + */ + SearchPanes.prototype.redrawPanes = function (rebuild) { + if (rebuild === void 0) { rebuild = false; } + var table = this.s.dt; + // Only do this if the redraw isn't being triggered by the panes updating themselves + if (!this.s.updating && !this.s.dt.page.info().serverSide) { + var filterActive = true; + var filterPane = this.s.filterPane; + // If the number of rows currently visible is equal to the number of rows in the table + // then there can't be any filtering taking place + if (table.rows({ search: 'applied' }).data().toArray().length === table.rows().data().toArray().length) { + filterActive = false; + } + // Otherwise if viewTotal is active then it is necessary to determine which panes a select is present in. + // If there is only one pane with a selection present then it should not show the filtered message as + // more selections may be made in that pane. + else if (this.c.viewTotal) { + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (pane.s.dtPane !== undefined) { + var selectLength = pane.s.dtPane.rows({ selected: true }).data().toArray().length; + if (selectLength === 0) { + for (var _b = 0, _c = this.s.selectionList; _b < _c.length; _b++) { + var selection = _c[_b]; + if (selection.index === pane.s.index && selection.rows.length !== 0) { + selectLength = selection.rows.length; + } + } + } + // If filterPane === -1 then a pane with a selection has not been found yet, so set filterPane to that panes index + if (selectLength > 0 && filterPane === -1) { + filterPane = pane.s.index; + } + // Then if another pane is found with a selection then set filterPane to null to + // show that multiple panes have selections present + else if (selectLength > 0) { + filterPane = null; + } + } + } + } + var deselectIdx = void 0; + var newSelectionList = []; + // Don't run this if it is due to the panes regenerating + if (!this.regenerating) { + for (var _d = 0, _e = this.s.panes; _d < _e.length; _d++) { + var pane = _e[_d]; + // Identify the pane where a selection or deselection has been made and add it to the list. + if (pane.s.selectPresent) { + this.s.selectionList.push({ index: pane.s.index, rows: pane.s.dtPane.rows({ selected: true }).data().toArray(), protect: false }); + table.state.save(); + break; + } + else if (pane.s.deselect) { + deselectIdx = pane.s.index; + var selectedData = pane.s.dtPane.rows({ selected: true }).data().toArray(); + if (selectedData.length > 0) { + this.s.selectionList.push({ index: pane.s.index, rows: selectedData, protect: true }); + } + } + } + if (this.s.selectionList.length > 0) { + var last = this.s.selectionList[this.s.selectionList.length - 1].index; + for (var _f = 0, _g = this.s.panes; _f < _g.length; _f++) { + var pane = _g[_f]; + pane.s.lastSelect = (pane.s.index === last); + } + } + // Remove selections from the list from the pane where a deselect has taken place + for (var i = 0; i < this.s.selectionList.length; i++) { + if (this.s.selectionList[i].index !== deselectIdx || this.s.selectionList[i].protect === true) { + var further = false; + // Find out if this selection is the last one in the list for that pane + for (var j = i + 1; j < this.s.selectionList.length; j++) { + if (this.s.selectionList[j].index === this.s.selectionList[i].index) { + further = true; + } + } + // If there are no selections for this pane in the list then just push this one + if (!further) { + newSelectionList.push(this.s.selectionList[i]); + this.s.selectionList[i].protect = false; + } + } + } + var solePane = -1; + if (newSelectionList.length === 1) { + solePane = newSelectionList[0].index; + } + // Update all of the panes to reflect the current state of the filters + for (var _h = 0, _j = this.s.panes; _h < _j.length; _h++) { + var pane = _j[_h]; + if (pane.s.dtPane !== undefined) { + var tempFilter = true; + pane.s.filteringActive = true; + if ((filterPane !== -1 && filterPane !== null && filterPane === pane.s.index) || + filterActive === false || + pane.s.index === solePane) { + tempFilter = false; + pane.s.filteringActive = false; + } + pane.updatePane(!tempFilter ? false : filterActive); + } + } + // Update the label that shows how many filters are in place + this._updateFilterCount(); + // If the length of the selections are different then some of them have been removed and a deselect has occured + if (newSelectionList.length > 0 && (newSelectionList.length < this.s.selectionList.length || rebuild)) { + this._cascadeRegen(newSelectionList); + var last = newSelectionList[newSelectionList.length - 1].index; + for (var _k = 0, _l = this.s.panes; _k < _l.length; _k++) { + var pane = _l[_k]; + pane.s.lastSelect = (pane.s.index === last); + } + } + else if (newSelectionList.length > 0) { + // Update all of the other panes as you would just making a normal selection + for (var _m = 0, _o = this.s.panes; _m < _o.length; _m++) { + var paneUpdate = _o[_m]; + if (paneUpdate.s.dtPane !== undefined) { + var tempFilter = true; + paneUpdate.s.filteringActive = true; + if ((filterPane !== -1 && filterPane !== null && filterPane === paneUpdate.s.index) || filterActive === false) { + tempFilter = false; + paneUpdate.s.filteringActive = false; + } + paneUpdate.updatePane(!tempFilter ? tempFilter : filterActive); + } + } + } + } + else { + var solePane = -1; + if (newSelectionList.length === 1) { + solePane = newSelectionList[0].index; + } + for (var _p = 0, _q = this.s.panes; _p < _q.length; _p++) { + var pane = _q[_p]; + if (pane.s.dtPane !== undefined) { + var tempFilter = true; + pane.s.filteringActive = true; + if ((filterPane !== -1 && filterPane !== null && filterPane === pane.s.index) || + filterActive === false || + pane.s.index === solePane) { + tempFilter = false; + pane.s.filteringActive = false; + } + pane.updatePane(!tempFilter ? tempFilter : filterActive); + } + } + // Update the label that shows how many filters are in place + this._updateFilterCount(); + } + if (!filterActive) { + this.s.selectionList = []; + } + } + }; + /** + * Attach the panes, buttons and title to the document + */ + SearchPanes.prototype._attach = function () { + var _this = this; + $$1(this.dom.container).removeClass(this.classes.hide); + $$1(this.dom.titleRow).removeClass(this.classes.hide); + $$1(this.dom.titleRow).remove(); + $$1(this.dom.title).appendTo(this.dom.titleRow); + // If the clear button is permitted attach it + if (this.c.clear) { + $$1(this.dom.clearAll).appendTo(this.dom.titleRow); + $$1(this.dom.clearAll).on('click.dtsps', function () { + _this.clearSelections(); + }); + } + $$1(this.dom.titleRow).appendTo(this.dom.container); + // Attach the container for each individual pane to the overall container + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + $$1(pane.dom.container).appendTo(this.dom.panes); + } + // Attach everything to the document + $$1(this.dom.panes).appendTo(this.dom.container); + if ($$1('div.' + this.classes.container).length === 0) { + $$1(this.dom.container).prependTo(this.s.dt); + } + return this.dom.container; + }; + /** + * Attach the top row containing the filter count and clear all button + */ + SearchPanes.prototype._attachExtras = function () { + $$1(this.dom.container).removeClass(this.classes.hide); + $$1(this.dom.titleRow).removeClass(this.classes.hide); + $$1(this.dom.titleRow).remove(); + $$1(this.dom.title).appendTo(this.dom.titleRow); + // If the clear button is permitted attach it + if (this.c.clear) { + $$1(this.dom.clearAll).appendTo(this.dom.titleRow); + } + $$1(this.dom.titleRow).appendTo(this.dom.container); + return this.dom.container; + }; + /** + * If there are no panes to display then this method is called to either + * display a message in their place or hide them completely. + */ + SearchPanes.prototype._attachMessage = function () { + // Create a message to display on the screen + var message; + try { + message = this.s.dt.i18n('searchPanes.emptyPanes', 'No SearchPanes'); + } + catch (error) { + message = null; + } + // If the message is an empty string then searchPanes.emptyPanes is undefined, + // therefore the pane container should be removed from the display + if (message === null) { + $$1(this.dom.container).addClass(this.classes.hide); + $$1(this.dom.titleRow).removeClass(this.classes.hide); + return; + } + else { + $$1(this.dom.container).removeClass(this.classes.hide); + $$1(this.dom.titleRow).addClass(this.classes.hide); + } + // Otherwise display the message + $$1(this.dom.emptyMessage).text(message); + this.dom.emptyMessage.appendTo(this.dom.container); + return this.dom.container; + }; + /** + * Attaches the panes to the document and displays a message or hides if there are none + */ + SearchPanes.prototype._attachPaneContainer = function () { + // If a pane is to be displayed then attach the normal pane output + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (pane.s.displayed === true) { + return this._attach(); + } + } + // Otherwise attach the custom message or remove the container from the display + return this._attachMessage(); + }; + /** + * Prepares the panes for selections to be made when cascade is active and a deselect has occured + * @param newSelectionList the list of selections which are to be made + */ + SearchPanes.prototype._cascadeRegen = function (newSelectionList) { + // Set this to true so that the actions taken do not cause this to run until it is finished + this.regenerating = true; + // If only one pane has been selected then take note of its index + var solePane = -1; + if (newSelectionList.length === 1) { + solePane = newSelectionList[0].index; + } + // Let the pane know that a cascadeRegen is taking place to avoid unexpected behaviour + // and clear all of the previous selections in the pane + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + pane.setCascadeRegen(true); + pane.setClear(true); + // If this is the same as the pane with the only selection then pass it as a parameter into clearPane + if ((pane.s.dtPane !== undefined && pane.s.index === solePane) || pane.s.dtPane !== undefined) { + pane.clearPane(); + } + pane.setClear(false); + } + // Remake Selections + this._makeCascadeSelections(newSelectionList); + // Set the selection list property to be the list without the selections from the deselect pane + this.s.selectionList = newSelectionList; + // The regeneration of selections is over so set it back to false + for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) { + var pane = _c[_b]; + pane.setCascadeRegen(false); + } + this.regenerating = false; + }; + /** + * Attaches the message to the document but does not add any panes + */ + SearchPanes.prototype._checkMessage = function () { + // If a pane is to be displayed then attach the normal pane output + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (pane.s.displayed === true) { + return; + } + } + // Otherwise attach the custom message or remove the container from the display + return this._attachMessage(); + }; + /** + * Gets the selection list from the previous state and stores it in the selectionList Property + */ + SearchPanes.prototype._getState = function () { + var loadedFilter = this.s.dt.state.loaded(); + if (loadedFilter && loadedFilter.searchPanes && loadedFilter.searchPanes.selectionList !== undefined) { + this.s.selectionList = loadedFilter.searchPanes.selectionList; + } + }; + /** + * Makes all of the selections when cascade is active + * @param newSelectionList the list of selections to be made, in the order they were originally selected + */ + SearchPanes.prototype._makeCascadeSelections = function (newSelectionList) { + // make selections in the order they were made previously, excluding those from the pane where a deselect was made + for (var i = 0; i < newSelectionList.length; i++) { + var _loop_1 = function (pane) { + if (pane.s.index === newSelectionList[i].index && pane.s.dtPane !== undefined) { + // When regenerating the cascade selections we need this flag so that the panes are only ignored if it + // is the last selection and the pane for that selection + if (i === newSelectionList.length - 1) { + pane.s.lastCascade = true; + } + // if there are any selections currently in the pane then deselect them as we are about to make our new selections + if (pane.s.dtPane.rows({ selected: true }).data().toArray().length > 0 && pane.s.dtPane !== undefined) { + pane.setClear(true); + pane.clearPane(); + pane.setClear(false); + } + var _loop_2 = function (row) { + pane.s.dtPane.rows().every(function (rowIdx) { + if (pane.s.dtPane.row(rowIdx).data() !== undefined && + row !== undefined && + pane.s.dtPane.row(rowIdx).data().filter === row.filter) { + pane.s.dtPane.row(rowIdx).select(); + } + }); + }; + // select every row in the pane that was selected previously + for (var _i = 0, _a = newSelectionList[i].rows; _i < _a.length; _i++) { + var row = _a[_i]; + _loop_2(row); + } + // Update the label that shows how many filters are in place + this_1._updateFilterCount(); + pane.s.lastCascade = false; + } + }; + var this_1 = this; + // As the selections may have been made across the panes in a different order to the pane index we must identify + // which pane has the index of the selection. This is also important for colreorder etc + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + _loop_1(pane); + } + } + // Make sure that the state is saved after all of these selections + this.s.dt.state.save(); + }; + /** + * Declares the instances of individual searchpanes dependant on the number of columns. + * It is necessary to run this once preInit has completed otherwise no panes will be + * created as the column count will be 0. + * @param table the DataTable api for the parent table + * @param paneSettings the settings passed into the constructor + * @param opts the options passed into the constructor + */ + SearchPanes.prototype._paneDeclare = function (table, paneSettings, opts) { + var _this = this; + // Create Panes + table + .columns(this.c.columns.length > 0 ? this.c.columns : undefined) + .eq(0) + .each(function (idx) { + _this.s.panes.push(new SearchPane(paneSettings, opts, idx, _this.c.layout, _this.dom.panes)); + }); + // If there is any extra custom panes defined then create panes for them too + var rowLength = table.columns().eq(0).toArray().length; + var paneLength = this.c.panes.length; + for (var i = 0; i < paneLength; i++) { + var id = rowLength + i; + this.s.panes.push(new SearchPane(paneSettings, opts, id, this.c.layout, this.dom.panes, this.c.panes[i])); + } + // If a custom ordering is being used + if (this.c.order.length > 0) { + // Make a new Array of panes based upon the order + var newPanes = this.c.order.map(function (name, index, values) { + return _this._findPane(name); + }); + // Remove the old panes from the dom + this.dom.panes.empty(); + this.s.panes = newPanes; + // Append the panes in the correct order + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + this.dom.panes.append(pane.dom.container); + } + } + // If this internal property is true then the DataTable has been initialised already + if (this.s.dt.settings()[0]._bInitComplete) { + this._startup(table); + } + else { + // Otherwise add the paneStartup function to the list of functions that are to be run when the table is initialised + // This will garauntee that the panes are initialised before the init event and init Complete callback is fired + this.s.dt.settings()[0].aoInitComplete.push({ fn: function () { + _this._startup(table); + } }); + } + }; + /** + * Finds a pane based upon the name of that pane + * @param name string representing the name of the pane + * @returns SearchPane The pane which has that name + */ + SearchPanes.prototype._findPane = function (name) { + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (name === pane.s.name) { + return pane; + } + } + }; + /** + * Works out which panes to update when data is recieved from the server and viewTotal is active + */ + SearchPanes.prototype._serverTotals = function () { + var selectPresent = false; + var deselectPresent = false; + var table = this.s.dt; + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + // Identify the pane where a selection or deselection has been made and add it to the list. + if (pane.s.selectPresent) { + this.s.selectionList.push({ index: pane.s.index, rows: pane.s.dtPane.rows({ selected: true }).data().toArray(), protect: false }); + table.state.save(); + pane.s.selectPresent = false; + selectPresent = true; + break; + } + else if (pane.s.deselect) { + var selectedData = pane.s.dtPane.rows({ selected: true }).data().toArray(); + if (selectedData.length > 0) { + this.s.selectionList.push({ index: pane.s.index, rows: selectedData, protect: true }); + } + selectPresent = true; + deselectPresent = true; + } + } + // Build an updated list based on any selections or deselections added + if (!selectPresent) { + this.s.selectionList = []; + } + else { + var newSelectionList = []; + for (var i = 0; i < this.s.selectionList.length; i++) { + var further = false; + // Find out if this selection is the last one in the list for that pane + for (var j = i + 1; j < this.s.selectionList.length; j++) { + if (this.s.selectionList[j].index === this.s.selectionList[i].index) { + further = true; + } + } + // If there are no selections for this pane in the list then just push this one + if (!further && + this.s.panes[this.s.selectionList[i].index].s.dtPane.rows({ selected: true }).data().toArray().length > 0) { + newSelectionList.push(this.s.selectionList[i]); + } + } + this.s.selectionList = newSelectionList; + } + var initIdx = -1; + // If there has been a deselect and only one pane has a selection then update everything + if (deselectPresent && this.s.selectionList.length === 1) { + for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) { + var pane = _c[_b]; + pane.s.lastSelect = false; + pane.s.deselect = false; + if (pane.s.dtPane !== undefined && pane.s.dtPane.rows({ selected: true }).data().toArray().length > 0) { + initIdx = pane.s.index; + } + } + } + // Otherwise if there are more 1 selections then find the last one and set it to not update that pane + else if (this.s.selectionList.length > 0) { + var last = this.s.selectionList[this.s.selectionList.length - 1].index; + for (var _d = 0, _e = this.s.panes; _d < _e.length; _d++) { + var pane = _e[_d]; + pane.s.lastSelect = (pane.s.index === last); + pane.s.deselect = false; + } + } + // Otherwise if there are no selections then find where that took place and do not update to maintain scrolling + else if (this.s.selectionList.length === 0) { + for (var _f = 0, _g = this.s.panes; _f < _g.length; _f++) { + var pane = _g[_f]; + // pane.s.lastSelect = (pane.s.deselect === true); + pane.s.lastSelect = false; + pane.s.deselect = false; + } + } + $$1(this.dom.panes).empty(); + // Rebuild the desired panes + for (var _h = 0, _j = this.s.panes; _h < _j.length; _h++) { + var pane = _j[_h]; + if (!pane.s.lastSelect) { + pane.rebuildPane(undefined, this.s.dt.page.info().serverSide ? this.s.serverData : undefined, pane.s.index === initIdx ? true : null, true); + } + else { + pane._setListeners(); + } + // append all of the panes and enable select + $$1(this.dom.panes).append(pane.dom.container); + if (pane.s.dtPane !== undefined) { + $$1(pane.s.dtPane.table().node()).parent()[0].scrollTop = pane.s.scrollTop; + $$1.fn.dataTable.select.init(pane.s.dtPane); + } + } + // Only need to trigger a search if it is not server side processing + if (!this.s.dt.page.info().serverSide) { + this.s.dt.draw(); + } + }; + /** + * Initialises the tables previous/preset selections and initialises callbacks for events + * @param table the parent table for which the searchPanes are being created + */ + SearchPanes.prototype._startup = function (table) { + var _this = this; + $$1(this.dom.container).text(''); + // Attach clear button and title bar to the document + this._attachExtras(); + $$1(this.dom.container).append(this.dom.panes); + $$1(this.dom.panes).empty(); + var loadedFilter = this.s.dt.state.loaded(); + if (this.c.viewTotal && !this.c.cascadePanes) { + if (loadedFilter !== null && + loadedFilter !== undefined && + loadedFilter.searchPanes !== undefined && + loadedFilter.searchPanes.panes !== undefined) { + var filterActive = false; + for (var _i = 0, _a = loadedFilter.searchPanes.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (pane.selected.length > 0) { + filterActive = true; + break; + } + } + if (filterActive) { + for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) { + var pane = _c[_b]; + pane.s.showFiltered = true; + } + } + } + } + for (var _d = 0, _e = this.s.panes; _d < _e.length; _d++) { + var pane = _e[_d]; + pane.rebuildPane(undefined, Object.keys(this.s.serverData).length > 0 ? this.s.serverData : undefined); + $$1(this.dom.panes).append(pane.dom.container); + } + // Only need to trigger a search if it is not server side processing + if (!this.s.dt.page.info().serverSide) { + this.s.dt.draw(); + } + // Reset the paging if that has been saved in the state + if (!this.s.stateRead && loadedFilter !== null && loadedFilter !== undefined) { + this.s.dt.page((loadedFilter.start / this.s.dt.page.len())); + this.s.dt.draw('page'); + } + this.s.stateRead = true; + if (this.c.viewTotal && !this.c.cascadePanes) { + for (var _f = 0, _g = this.s.panes; _f < _g.length; _f++) { + var pane = _g[_f]; + pane.updatePane(); + } + } + this._updateFilterCount(); + this._checkMessage(); + // When a draw is called on the DataTable, update all of the panes incase the data in the DataTable has changed + table.on('preDraw.dtsps', function () { + _this._updateFilterCount(); + if ((_this.c.cascadePanes || _this.c.viewTotal) && !_this.s.dt.page.info().serverSide) { + _this.redrawPanes(); + } + else { + _this._updateSelection(); + } + _this.s.filterPane = -1; + }); + // Whenever a state save occurs store the selection list in the state object + this.s.dt.on('stateSaveParams.dtsp', function (e, settings, data) { + if (data.searchPanes === undefined) { + data.searchPanes = {}; + } + data.searchPanes.selectionList = _this.s.selectionList; + }); + // If the data is reloaded from the server then it is possible that it has changed completely, + // so we need to rebuild the panes + this.s.dt.on('xhr', function () { + var processing = false; + if (!_this.s.dt.page.info().serverSide) { + _this.s.dt.one('preDraw', function () { + if (processing) { + return; + } + processing = true; + $$1(_this.dom.panes).empty(); + for (var _i = 0, _a = _this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + pane.clearData(); // Clears all of the bins and will mean that the data has to be re-read + // Pass a boolean to say whether this is the last choice made for maintaining selections when rebuilding + pane.rebuildPane(_this.s.selectionList[_this.s.selectionList.length - 1] !== undefined ? + pane.s.index === _this.s.selectionList[_this.s.selectionList.length - 1].index : + false, undefined, undefined, true); + $$1(_this.dom.panes).append(pane.dom.container); + } + if (!_this.s.dt.page.info().serverSide) { + _this.s.dt.draw(); + } + if (_this.c.cascadePanes || _this.c.viewTotal) { + _this.redrawPanes(_this.c.cascadePanes); + } + else { + _this._updateSelection(); + } + _this._checkMessage(); + }); + } + }); + // PreSelect any selections which have been defined using the preSelect option + for (var _h = 0, _j = this.s.panes; _h < _j.length; _h++) { + var pane = _j[_h]; + if (pane !== undefined && + pane.s.dtPane !== undefined && + (pane.s.colOpts.preSelect !== undefined || pane.customPaneSettings.preSelect !== undefined)) { + var tableLength = pane.s.dtPane.rows().data().toArray().length; + for (var i = 0; i < tableLength; i++) { + if (pane.s.colOpts.preSelect.indexOf(pane.s.dtPane.cell(i, 0).data()) !== -1 || + (pane.customPaneSettings !== null && + pane.customPaneSettings.preSelect !== undefined && + pane.customPaneSettings.preSelect.indexOf(pane.s.dtPane.cell(i, 0).data()) !== -1)) { + pane.s.dtPane.row(i).select(); + } + } + pane.updateTable(); + } + } + if (this.s.selectionList !== undefined && this.s.selectionList.length > 0) { + var last = this.s.selectionList[this.s.selectionList.length - 1].index; + for (var _k = 0, _l = this.s.panes; _k < _l.length; _k++) { + var pane = _l[_k]; + pane.s.lastSelect = (pane.s.index === last); + } + } + // If cascadePanes is active then make the previous selections in the order they were previously + if (this.s.selectionList.length > 0 && this.c.cascadePanes) { + this._cascadeRegen(this.s.selectionList); + } + // Update the title bar to show how many filters have been selected + this._updateFilterCount(); + // If the table is destroyed and restarted then clear the selections so that they do not persist. + table.on('destroy.dtsps', function () { + for (var _i = 0, _a = _this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + pane.destroy(); + } + table.off('.dtsps'); + $$1(_this.dom.clearAll).off('.dtsps'); + $$1(_this.dom.container).remove(); + _this.clearSelections(); + }); + // When the clear All button has been pressed clear all of the selections in the panes + if (this.c.clear) { + $$1(this.dom.clearAll).on('click.dtsps', function () { + _this.clearSelections(); + }); + } + if (this.s.dt.page.info().serverSide) { + table.on('preXhr.dt', function (e, settings, data) { + if (data.searchPanes === undefined) { + data.searchPanes = {}; + } + for (var _i = 0, _a = _this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + var src = _this.s.dt.column(pane.s.index).dataSrc(); + if (data.searchPanes[src] === undefined) { + data.searchPanes[src] = {}; + } + if (pane.s.dtPane !== undefined) { + var rowData = pane.s.dtPane.rows({ selected: true }).data().toArray(); + for (var i = 0; i < rowData.length; i++) { + data.searchPanes[src][i] = rowData[i].filter; + } + } + } + if (_this.c.viewTotal) { + _this._prepViewTotal(); + } + }); + } + else { + table.on('preXhr.dt', function (e, settings, data) { + for (var _i = 0, _a = _this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + pane.clearData(); + } + }); + } + table.settings()[0]._searchPanes = this; + }; + SearchPanes.prototype._prepViewTotal = function () { + var filterPane = this.s.filterPane; + var filterActive = false; + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (pane.s.dtPane !== undefined) { + var selectLength = pane.s.dtPane.rows({ selected: true }).data().toArray().length; + // If filterPane === -1 then a pane with a selection has not been found yet, so set filterPane to that panes index + if (selectLength > 0 && filterPane === -1) { + filterPane = pane.s.index; + filterActive = true; + } + // Then if another pane is found with a selection then set filterPane to null to + // show that multiple panes have selections present + else if (selectLength > 0) { + filterPane = null; + } + } + } + // Update all of the panes to reflect the current state of the filters + for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) { + var pane = _c[_b]; + if (pane.s.dtPane !== undefined) { + pane.s.filteringActive = true; + if ((filterPane !== -1 && filterPane !== null && filterPane === pane.s.index) || filterActive === false) { + pane.s.filteringActive = false; + } + } + } + }; + /** + * Updates the number of filters that have been applied in the title + */ + SearchPanes.prototype._updateFilterCount = function () { + var filterCount = 0; + // Add the number of all of the filters throughout the panes + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (pane.s.dtPane !== undefined) { + filterCount += pane.getPaneCount(); + } + } + // Run the message through the internationalisation method to improve readability + var message = this.s.dt.i18n('searchPanes.title', 'Filters Active - %d', filterCount); + $$1(this.dom.title).text(message); + if (this.c.filterChanged !== undefined && typeof this.c.filterChanged === 'function') { + this.c.filterChanged.call(this.s.dt, filterCount); + } + }; + /** + * Updates the selectionList when cascade is not in place + */ + SearchPanes.prototype._updateSelection = function () { + this.s.selectionList = []; + for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) { + var pane = _a[_i]; + if (pane.s.dtPane !== undefined) { + this.s.selectionList.push({ index: pane.s.index, rows: pane.s.dtPane.rows({ selected: true }).data().toArray(), protect: false }); + } + } + this.s.dt.state.save(); + }; + SearchPanes.version = '1.2.1'; + SearchPanes.classes = { + clear: 'dtsp-clear', + clearAll: 'dtsp-clearAll', + container: 'dtsp-searchPanes', + emptyMessage: 'dtsp-emptyMessage', + hide: 'dtsp-hidden', + panes: 'dtsp-panesContainer', + search: 'dtsp-search', + title: 'dtsp-title', + titleRow: 'dtsp-titleRow' + }; + // Define SearchPanes default options + SearchPanes.defaults = { + cascadePanes: false, + clear: true, + container: function (dt) { + return dt.table().container(); + }, + columns: [], + filterChanged: undefined, + layout: 'columns-3', + order: [], + panes: [], + viewTotal: false + }; + return SearchPanes; + }()); + + /*! SearchPanes 1.2.1 + * 2019-2020 SpryMedia Ltd - datatables.net/license + */ + // DataTables extensions common UMD. Note that this allows for AMD, CommonJS + // (with window and jQuery being allowed as parameters to the returned + // function) or just default browser loading. + (function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD + define(['jquery', 'datatables.net'], function ($) { + return factory($, window, document); + }); + } + else if (typeof exports === 'object') { + // CommonJS + module.exports = function (root, $) { + if (!root) { + root = window; + } + if (!$ || !$.fn.dataTable) { + $ = require('datatables.net')(root, $).$; + } + return factory($, root, root.document); + }; + } + else { + // Browser - assume jQuery has already been loaded + factory(window.jQuery, window, document); + } + }(function ($, window, document) { + setJQuery($); + setJQuery$1($); + var DataTable = $.fn.dataTable; + $.fn.dataTable.SearchPanes = SearchPanes; + $.fn.DataTable.SearchPanes = SearchPanes; + $.fn.dataTable.SearchPane = SearchPane; + $.fn.DataTable.SearchPane = SearchPane; + var apiRegister = $.fn.dataTable.Api.register; + apiRegister('searchPanes()', function () { + return this; + }); + apiRegister('searchPanes.clearSelections()', function () { + return this.iterator('table', function (ctx) { + if (ctx._searchPanes) { + ctx._searchPanes.clearSelections(); + } + }); + }); + apiRegister('searchPanes.rebuildPane()', function (targetIdx, maintainSelections) { + return this.iterator('table', function (ctx) { + if (ctx._searchPanes) { + ctx._searchPanes.rebuild(targetIdx, maintainSelections); + } + }); + }); + apiRegister('searchPanes.container()', function () { + var ctx = this.context[0]; + return ctx._searchPanes + ? ctx._searchPanes.getNode() + : null; + }); + $.fn.dataTable.ext.buttons.searchPanesClear = { + text: 'Clear Panes', + action: function (e, dt, node, config) { + dt.searchPanes.clearSelections(); + } + }; + $.fn.dataTable.ext.buttons.searchPanes = { + action: function (e, dt, node, config) { + e.stopPropagation(); + this.popover(config._panes.getNode(), { + align: 'dt-container' + }); + config._panes.rebuild(undefined, true); + }, + config: {}, + init: function (dt, node, config) { + var panes = new $.fn.dataTable.SearchPanes(dt, $.extend({ + filterChanged: function (count) { + dt.button(node).text(dt.i18n('searchPanes.collapse', { 0: 'SearchPanes', _: 'SearchPanes (%d)' }, count)); + } + }, config.config)); + var message = dt.i18n('searchPanes.collapse', 'SearchPanes', 0); + dt.button(node).text(message); + config._panes = panes; + }, + text: 'Search Panes' + }; + function _init(settings, fromPre) { + if (fromPre === void 0) { fromPre = false; } + var api = new DataTable.Api(settings); + var opts = api.init().searchPanes || DataTable.defaults.searchPanes; + var searchPanes = new SearchPanes(api, opts, fromPre); + var node = searchPanes.getNode(); + return node; + } + // Attach a listener to the document which listens for DataTables initialisation + // events so we can automatically initialise + $(document).on('preInit.dt.dtsp', function (e, settings, json) { + if (e.namespace !== 'dt') { + return; + } + if (settings.oInit.searchPanes || + DataTable.defaults.searchPanes) { + if (!settings._searchPanes) { + _init(settings, true); + } + } + }); + // DataTables `dom` feature option + DataTable.ext.feature.push({ + cFeature: 'P', + fnInit: _init + }); + // DataTables 2 layout feature + if (DataTable.ext.features) { + DataTable.ext.features.register('searchPanes', _init); + } + })); + +}()); diff --git a/plugins/datatables-searchpanes/js/dataTables.searchPanes.min.js b/plugins/datatables-searchpanes/js/dataTables.searchPanes.min.js new file mode 100644 index 000000000..16c769182 --- /dev/null +++ b/plugins/datatables-searchpanes/js/dataTables.searchPanes.min.js @@ -0,0 +1,89 @@ +/*! + SearchPanes 1.2.1 + 2019-2020 SpryMedia Ltd - datatables.net/license +*/ +(function(){var g,q,t,l=function(a,b,c,d,e,h){var f=this;void 0===h&&(h=null);if(!q||!q.versionCheck||!q.versionCheck("1.10.0"))throw Error("SearchPane requires DataTables 1.10 or newer");if(!q.select)throw Error("SearchPane requires Select");a=new q.Api(a);this.classes=g.extend(!0,{},l.classes);this.c=g.extend(!0,{},l.defaults,b);this.customPaneSettings=h;this.s={cascadeRegen:!1,clearing:!1,colOpts:[],deselect:!1,displayed:!1,dt:a,dtPane:void 0,filteringActive:!1,index:c,indexes:[],lastCascade:!1, +lastSelect:!1,listSet:!1,name:void 0,redraw:!1,rowData:{arrayFilter:[],arrayOriginal:[],arrayTotals:[],bins:{},binsOriginal:{},binsTotal:{},filterMap:new Map,totalOptions:0},scrollTop:0,searchFunction:void 0,selectPresent:!1,serverSelect:[],serverSelecting:!1,showFiltered:!1,tableLength:null,updating:!1};b=a.columns().eq(0).toArray().length;this.colExists=this.s.index<b;this.c.layout=d;b=parseInt(d.split("-")[1],10);this.dom={buttonGroup:g("<div/>").addClass(this.classes.buttonGroup),clear:g('<button type="button">×</button>').addClass(this.classes.dull).addClass(this.classes.paneButton).addClass(this.classes.clearButton), +container:g("<div/>").addClass(this.classes.container).addClass(this.classes.layout+(10>b?d:d.split("-")[0]+"-9")),countButton:g('<button type="button"></button>').addClass(this.classes.paneButton).addClass(this.classes.countButton),dtP:g("<table><thead><tr><th>"+(this.colExists?g(a.column(this.colExists?this.s.index:0).header()).text():this.customPaneSettings.header||"Custom Pane")+"</th><th/></tr></thead></table>"),lower:g("<div/>").addClass(this.classes.subRow2).addClass(this.classes.narrowButton), +nameButton:g('<button type="button"></button>').addClass(this.classes.paneButton).addClass(this.classes.nameButton),panesContainer:e,searchBox:g("<input/>").addClass(this.classes.paneInputButton).addClass(this.classes.search),searchButton:g('<button type = "button" class="'+this.classes.searchIcon+'"></button>').addClass(this.classes.paneButton),searchCont:g("<div/>").addClass(this.classes.searchCont),searchLabelCont:g("<div/>").addClass(this.classes.searchLabelCont),topRow:g("<div/>").addClass(this.classes.topRow), +upper:g("<div/>").addClass(this.classes.subRow1).addClass(this.classes.narrowSearch)};this.s.displayed=!1;a=this.s.dt;this.selections=[];this.s.colOpts=this.colExists?this._getOptions():this._getBonusOptions();var o=this.s.colOpts,d=g('<button type="button">X</button>').addClass(this.classes.paneButton);g(d).text(a.i18n("searchPanes.clearPane","X"));this.dom.container.addClass(o.className);this.dom.container.addClass(null!==this.customPaneSettings&&void 0!==this.customPaneSettings.className?this.customPaneSettings.className: +"");this.s.name=void 0!==this.s.colOpts.name?this.s.colOpts.name:null!==this.customPaneSettings&&void 0!==this.customPaneSettings.name?this.customPaneSettings.name:this.colExists?g(a.column(this.s.index).header()).text():this.customPaneSettings.header||"Custom Pane";g(e).append(this.dom.container);var n=a.table(0).node();this.s.searchFunction=function(a,b,d){if(0===f.selections.length||a.nTable!==n)return!0;a=null;f.colExists&&(a=b[f.s.index],"filter"!==o.orthogonal.filter&&(a=f.s.rowData.filterMap.get(d), +a instanceof g.fn.dataTable.Api&&(a=a.toArray())));return f._search(a,d)};g.fn.dataTable.ext.search.push(this.s.searchFunction);if(this.c.clear)g(d).on("click",function(){f.dom.container.find(f.classes.search).each(function(){g(this).val("");g(this).trigger("input")});f.clearPane()});a.on("draw.dtsp",function(){f._adjustTopRow()});a.on("buttons-action",function(){f._adjustTopRow()});g(window).on("resize.dtsp",q.util.throttle(function(){f._adjustTopRow()}));a.on("column-reorder.dtsp",function(a,b, +d){f.s.index=d.mapping[f.s.index]});return this};l.prototype.clearData=function(){this.s.rowData={arrayFilter:[],arrayOriginal:[],arrayTotals:[],bins:{},binsOriginal:{},binsTotal:{},filterMap:new Map,totalOptions:0}};l.prototype.clearPane=function(){this.s.dtPane.rows({selected:!0}).deselect();this.updateTable();return this};l.prototype.destroy=function(){g(this.s.dtPane).off(".dtsp");g(this.s.dt).off(".dtsp");g(this.dom.nameButton).off(".dtsp");g(this.dom.countButton).off(".dtsp");g(this.dom.clear).off(".dtsp"); +g(this.dom.searchButton).off(".dtsp");g(this.dom.container).remove();for(var a=g.fn.dataTable.ext.search.indexOf(this.s.searchFunction);-1!==a;)g.fn.dataTable.ext.search.splice(a,1),a=g.fn.dataTable.ext.search.indexOf(this.s.searchFunction);void 0!==this.s.dtPane&&this.s.dtPane.destroy();this.s.listSet=!1};l.prototype.getPaneCount=function(){return void 0!==this.s.dtPane?this.s.dtPane.rows({selected:!0}).data().toArray().length:0};l.prototype.rebuildPane=function(a,b,c,d){void 0===a&&(a=!1);void 0=== +b&&(b=null);void 0===c&&(c=null);void 0===d&&(d=!1);this.clearData();var e=[];this.s.serverSelect=[];var h=null;void 0!==this.s.dtPane&&(d&&(this.s.dt.page.info().serverSide?this.s.serverSelect=this.s.dtPane.rows({selected:!0}).data().toArray():e=this.s.dtPane.rows({selected:!0}).data().toArray()),this.s.dtPane.clear().destroy(),h=g(this.dom.container).prev(),this.destroy(),this.s.dtPane=void 0,g.fn.dataTable.ext.search.push(this.s.searchFunction));this.dom.container.removeClass(this.classes.hidden); +this.s.displayed=!1;this._buildPane(!this.s.dt.page.info().serverSide?e:this.s.serverSelect,a,b,c,h);return this};l.prototype.removePane=function(){this.s.displayed=!1;g(this.dom.container).hide()};l.prototype.setCascadeRegen=function(a){this.s.cascadeRegen=a};l.prototype.setClear=function(a){this.s.clearing=a};l.prototype.updatePane=function(a){void 0===a&&(a=!1);this.s.updating=!0;this._updateCommon(a);this.s.updating=!1};l.prototype.updateTable=function(){this.selections=this.s.dtPane.rows({selected:!0}).data().toArray(); +this._searchExtras();(this.c.cascadePanes||this.c.viewTotal)&&this.updatePane()};l.prototype._setListeners=function(){var a=this,b=this.s.rowData,c;this.s.dtPane.on("select.dtsp",function(){clearTimeout(c);a.s.dt.page.info().serverSide&&!a.s.updating?a.s.serverSelecting||(a.s.serverSelect=a.s.dtPane.rows({selected:!0}).data().toArray(),a.s.scrollTop=g(a.s.dtPane.table().node()).parent()[0].scrollTop,a.s.selectPresent=!0,a.s.dt.draw(!1)):(g(a.dom.clear).removeClass(a.classes.dull),a.s.selectPresent= +!0,a.s.updating||a._makeSelection(),a.s.selectPresent=!1)});this.s.dtPane.on("deselect.dtsp",function(){c=setTimeout(function(){a.s.dt.page.info().serverSide&&!a.s.updating?a.s.serverSelecting||(a.s.serverSelect=a.s.dtPane.rows({selected:!0}).data().toArray(),a.s.deselect=!0,a.s.dt.draw(!1)):(a.s.deselect=!0,0===a.s.dtPane.rows({selected:!0}).data().toArray().length&&g(a.dom.clear).addClass(a.classes.dull),a._makeSelection(),a.s.deselect=!1,a.s.dt.state.save())},50)});this.s.dt.on("stateSaveParams.dtsp", +function(d,c,h){if(g.isEmptyObject(h))a.s.dtPane.state.clear();else{var d=[],f,o,n,j;void 0!==a.s.dtPane&&(d=a.s.dtPane.rows({selected:!0}).data().map(function(a){return a.filter.toString()}).toArray(),f=g(a.dom.searchBox).val(),o=a.s.dtPane.order(),n=b.binsOriginal,j=b.arrayOriginal);void 0===h.searchPanes&&(h.searchPanes={});void 0===h.searchPanes.panes&&(h.searchPanes.panes=[]);h.searchPanes.panes.push({arrayFilter:j,bins:n,id:a.s.index,order:o,searchTerm:f,selected:d})}});this.s.dtPane.on("user-select.dtsp", +function(a,b,c,f,o){o.stopPropagation()});this.s.dtPane.on("draw.dtsp",function(){a._adjustTopRow()});g(this.dom.nameButton).on("click.dtsp",function(){var b=a.s.dtPane.order()[0][1];a.s.dtPane.order([0,"asc"===b?"desc":"asc"]).draw();a.s.dt.state.save()});g(this.dom.countButton).on("click.dtsp",function(){var b=a.s.dtPane.order()[0][1];a.s.dtPane.order([1,"asc"===b?"desc":"asc"]).draw();a.s.dt.state.save()});g(this.dom.clear).on("click.dtsp",function(){a.dom.container.find("."+a.classes.search).each(function(){g(this).val(""); +g(this).trigger("input")});a.clearPane()});g(this.dom.searchButton).on("click.dtsp",function(){g(a.dom.searchBox).focus()});g(this.dom.searchBox).on("input.dtsp",function(){a.s.dtPane.search(g(a.dom.searchBox).val()).draw();a.s.dt.state.save()});this.s.dt.state.save();return!0};l.prototype._addOption=function(a,b,c,d,e,h){if(Array.isArray(a)||a instanceof q.Api)if(a instanceof q.Api&&(a=a.toArray(),b=b.toArray()),a.length===b.length)for(var f=0;f<a.length;f++)h[a[f]]?h[a[f]]++:(h[a[f]]=1,e.push({display:b[f], +filter:a[f],sort:c[f],type:d[f]})),this.s.rowData.totalOptions++;else throw Error("display and filter not the same length");else"string"===typeof this.s.colOpts.orthogonal?(h[a]?h[a]++:(h[a]=1,e.push({display:b,filter:a,sort:c,type:d})),this.s.rowData.totalOptions++):e.push({display:b,filter:a,sort:c,type:d})};l.prototype._addRow=function(a,b,c,d,e,h,f){for(var o,g=0,j=this.s.indexes;g<j.length;g++){var i=j[g];i.filter===b&&(o=i.index)}void 0===o&&(o=this.s.indexes.length,this.s.indexes.push({filter:b, +index:o}));return this.s.dtPane.row.add({className:f,display:""!==a?a:!1!==this.s.colOpts.emptyMessage?this.s.colOpts.emptyMessage:this.c.emptyMessage,filter:b,index:o,shown:c,sort:""!==e?e:!1!==this.s.colOpts.emptyMessage?this.s.colOpts.emptyMessage:this.c.emptyMessage,total:d,type:h})};l.prototype._adjustTopRow=function(){var a=this.dom.container.find("."+this.classes.subRowsContainer),b=this.dom.container.find(".dtsp-subRow1"),c=this.dom.container.find(".dtsp-subRow2"),d=this.dom.container.find("."+ +this.classes.topRow);(252>g(a[0]).width()||252>g(d[0]).width())&&0!==g(a[0]).width()?(g(a[0]).addClass(this.classes.narrow),g(b[0]).addClass(this.classes.narrowSub).removeClass(this.classes.narrowSearch),g(c[0]).addClass(this.classes.narrowSub).removeClass(this.classes.narrowButton)):(g(a[0]).removeClass(this.classes.narrow),g(b[0]).removeClass(this.classes.narrowSub).addClass(this.classes.narrowSearch),g(c[0]).removeClass(this.classes.narrowSub).addClass(this.classes.narrowButton))};l.prototype._buildPane= +function(a,b,c,d,e){var h=this;void 0===a&&(a=[]);void 0===b&&(b=!1);void 0===c&&(c=null);void 0===d&&(d=null);void 0===e&&(e=null);this.selections=[];var f=this.s.dt,o=f.column(this.colExists?this.s.index:0),n=this.s.colOpts,j=this.s.rowData,i=f.i18n("searchPanes.count","{total}"),l=f.i18n("searchPanes.countFiltered","{shown} ({total})"),p=f.state.loaded();this.s.listSet&&(p=f.state());if(this.colExists){var m=-1;if(p&&p.searchPanes&&p.searchPanes.panes)for(var k=0;k<p.searchPanes.panes.length;k++)if(p.searchPanes.panes[k].id=== +this.s.index){m=k;break}if((!1===n.show||void 0!==n.show&&!0!==n.show)&&-1===m)return this.dom.container.addClass(this.classes.hidden),this.s.displayed=!1;if(!0===n.show||-1!==m)this.s.displayed=!0;if(!this.s.dt.page.info().serverSide&&null===c){if(0===j.arrayFilter.length)if(this._populatePane(b),this.s.rowData.totalOptions=0,this._detailsPane(),p&&p.searchPanes&&p.searchPanes.panes)if(-1!==m)j.binsOriginal=p.searchPanes.panes[m].bins,j.arrayOriginal=p.searchPanes.panes[m].arrayFilter;else{this.dom.container.addClass(this.classes.hidden); +this.s.displayed=!1;return}else j.arrayOriginal=j.arrayTotals,j.binsOriginal=j.binsTotal;k=Object.keys(j.binsOriginal).length;c=this._uniqueRatio(k,f.rows()[0].length);if(!1===this.s.displayed&&((void 0===n.show&&null===n.threshold?c>this.c.threshold:c>n.threshold)||!0!==n.show&&1>=k)){this.dom.container.addClass(this.classes.hidden);this.s.displayed=!1;return}this.c.viewTotal&&0===j.arrayTotals.length?(this.s.rowData.totalOptions=0,this._detailsPane()):j.binsTotal=j.bins;this.dom.container.addClass(this.classes.show); +this.s.displayed=!0}else if(null!==c){if(void 0!==c.tableLength)this.s.tableLength=c.tableLength,this.s.rowData.totalOptions=this.s.tableLength;else if(null===this.s.tableLength||f.rows()[0].length>this.s.tableLength)this.s.tableLength=f.rows()[0].length,this.s.rowData.totalOptions=this.s.tableLength;b=f.column(this.s.index).dataSrc();if(void 0!==c[b]){k=0;for(c=c[b];k<c.length;k++)b=c[k],this.s.rowData.arrayFilter.push({display:b.label,filter:b.value,sort:b.label,type:b.label}),this.s.rowData.bins[b.value]= +this.c.viewTotal||this.c.cascadePanes?b.count:b.total,this.s.rowData.binsTotal[b.value]=b.total}k=Object.keys(j.binsTotal).length;c=this._uniqueRatio(k,this.s.tableLength);if(!1===this.s.displayed&&((void 0===n.show&&null===n.threshold?c>this.c.threshold:c>n.threshold)||!0!==n.show&&1>=k)){this.dom.container.addClass(this.classes.hidden);this.s.displayed=!1;return}this.s.rowData.arrayOriginal=this.s.rowData.arrayFilter;this.s.rowData.binsOriginal=this.s.rowData.bins;this.s.displayed=!0}}else this.s.displayed= +!0;this._displayPane();if(!this.s.listSet)this.dom.dtP.on("stateLoadParams.dt",function(a,b,d){g.isEmptyObject(f.state.loaded())&&g.each(d,function(a){delete d[a]})});null!==e&&0<g(this.dom.panesContainer).has(e).length?g(this.dom.container).insertAfter(e):g(this.dom.panesContainer).prepend(this.dom.container);k=g.fn.dataTable.ext.errMode;g.fn.dataTable.ext.errMode="none";e=q.Scroller;this.s.dtPane=g(this.dom.dtP).DataTable(g.extend(!0,{columnDefs:[{className:"dtsp-nameColumn",data:"display",render:function(a, +b,d){if(b==="sort")return d.sort;if(b==="type")return d.type;var c;(h.s.filteringActive||h.s.showFiltered)&&h.c.viewTotal?c=l.replace(/{total}/,d.total):c=i.replace(/{total}/,d.total);for(c=c.replace(/{shown}/,d.shown);c.indexOf("{total}")!==-1;)c=c.replace(/{total}/,d.total);for(;c.indexOf("{shown}")!==-1;)c=c.replace(/{shown}/,d.shown);b='<span class="'+h.classes.pill+'">'+c+"</span>";if(h.c.hideCount||n.hideCount)b="";return'<div class="'+h.classes.nameCont+'"><span title="'+(typeof a==="string"&& +a.match(/<[^>]*>/)!==null?a.replace(/<[^>]*>/g,""):a)+'" class="'+h.classes.name+'">'+a+"</span>"+b+"</div>"},targets:0,type:void 0!==f.settings()[0].aoColumns[this.s.index]?f.settings()[0].aoColumns[this.s.index]._sManualType:null},{className:"dtsp-countColumn "+this.classes.badgePill,data:"shown",orderData:[1,2],targets:1,visible:!1},{data:"total",targets:2,visible:!1}],deferRender:!0,dom:"t",info:!1,language:this.s.dt.settings()[0].oLanguage,paging:e?!0:!1,scrollX:!1,scrollY:"200px",scroller:e? +!0:!1,select:!0,stateSave:f.settings()[0].oFeatures.bStateSave?!0:!1},this.c.dtOpts,void 0!==n?n.dtOpts:{},void 0!==this.s.colOpts.options||!this.colExists?{createdRow:function(a,b){g(a).addClass(b.className)}}:void 0,null!==this.customPaneSettings&&void 0!==this.customPaneSettings.dtOpts?this.customPaneSettings.dtOpts:{}));g(this.dom.dtP).addClass(this.classes.table);g(this.dom.searchBox).attr("placeholder",void 0!==n.header?n.header:this.colExists?f.settings()[0].aoColumns[this.s.index].sTitle: +this.customPaneSettings.header||"Custom Pane");g.fn.dataTable.select.init(this.s.dtPane);g.fn.dataTable.ext.errMode=k;if(this.colExists){var o=(o=o.search())?o.substr(1,o.length-2).split("|"):[],r=0;j.arrayFilter.forEach(function(a){""===a.filter&&r++});k=0;for(e=j.arrayFilter.length;k<e;k++){o=!1;b=0;for(m=this.s.serverSelect;b<m.length;b++)c=m[b],c.filter===j.arrayFilter[k].filter&&(o=!0);if(this.s.dt.page.info().serverSide&&(!this.c.cascadePanes||this.c.cascadePanes&&0!==j.bins[j.arrayFilter[k].filter]|| +this.c.cascadePanes&&null!==d||o)){o=this._addRow(j.arrayFilter[k].display,j.arrayFilter[k].filter,d?j.binsTotal[j.arrayFilter[k].filter]:j.bins[j.arrayFilter[k].filter],this.c.viewTotal||d?String(j.binsTotal[j.arrayFilter[k].filter]):j.bins[j.arrayFilter[k].filter],j.arrayFilter[k].sort,j.arrayFilter[k].type);b=0;for(m=this.s.serverSelect;b<m.length;b++)c=m[b],c.filter===j.arrayFilter[k].filter&&(this.s.serverSelecting=!0,o.select(),this.s.serverSelecting=!1)}else!this.s.dt.page.info().serverSide&& +j.arrayFilter[k]&&(void 0!==j.bins[j.arrayFilter[k].filter]||!this.c.cascadePanes)?this._addRow(j.arrayFilter[k].display,j.arrayFilter[k].filter,j.bins[j.arrayFilter[k].filter],j.binsTotal[j.arrayFilter[k].filter],j.arrayFilter[k].sort,j.arrayFilter[k].type):this.s.dt.page.info().serverSide||this._addRow("",r,r,"","","")}}q.select.init(this.s.dtPane);(void 0!==n.options||null!==this.customPaneSettings&&void 0!==this.customPaneSettings.options)&&this._getComparisonRows();this.s.dtPane.draw();this._adjustTopRow(); +this.s.listSet||(this._setListeners(),this.s.listSet=!0);for(d=0;d<a.length;d++)if(j=a[d],void 0!==j){k=0;for(e=this.s.dtPane.rows().indexes().toArray();k<e.length;k++)o=e[k],void 0!==this.s.dtPane.row(o).data()&&j.filter===this.s.dtPane.row(o).data().filter&&(this.s.dt.page.info().serverSide?(this.s.serverSelecting=!0,this.s.dtPane.row(o).select(),this.s.serverSelecting=!1):this.s.dtPane.row(o).select())}this.s.dt.page.info().serverSide&&this.s.dtPane.search(g(this.dom.searchBox).val()).draw();if(p&& +p.searchPanes&&p.searchPanes.panes){this.c.cascadePanes||this._reloadSelect(p);a=0;for(p=p.searchPanes.panes;a<p.length;a++)d=p[a],d.id===this.s.index&&(g(this.dom.searchBox).val(d.searchTerm),g(this.dom.searchBox).trigger("input"),this.s.dtPane.order(d.order).draw())}this.s.dt.state.save();return!0};l.prototype._detailsPane=function(){var a=this.s.dt;this.s.rowData.arrayTotals=[];this.s.rowData.binsTotal={};var b=this.s.dt.settings()[0],a=a.rows().indexes();if(!this.s.dt.page.info().serverSide)for(var c= +0;c<a.length;c++)this._populatePaneArray(a[c],this.s.rowData.arrayTotals,b,this.s.rowData.binsTotal)};l.prototype._displayPane=function(){var a=this.dom.container,b=this.s.colOpts,c=parseInt(this.c.layout.split("-")[1],10);g(this.dom.topRow).empty();g(this.dom.dtP).empty();g(this.dom.topRow).addClass(this.classes.topRow);3<c&&g(this.dom.container).addClass(this.classes.smallGap);g(this.dom.topRow).addClass(this.classes.subRowsContainer);g(this.dom.upper).appendTo(this.dom.topRow);g(this.dom.lower).appendTo(this.dom.topRow); +g(this.dom.searchCont).appendTo(this.dom.upper);g(this.dom.buttonGroup).appendTo(this.dom.lower);(!1===this.c.dtOpts.searching||void 0!==b.dtOpts&&!1===b.dtOpts.searching||!this.c.controls||!b.controls||null!==this.customPaneSettings&&void 0!==this.customPaneSettings.dtOpts&&void 0!==this.customPaneSettings.dtOpts.searching&&!this.customPaneSettings.dtOpts.searching)&&g(this.dom.searchBox).attr("disabled","disabled").removeClass(this.classes.paneInputButton).addClass(this.classes.disabledButton); +g(this.dom.searchBox).appendTo(this.dom.searchCont);this._searchContSetup();this.c.clear&&(this.c.controls&&b.controls)&&g(this.dom.clear).appendTo(this.dom.buttonGroup);this.c.orderable&&(b.orderable&&this.c.controls&&b.controls)&&g(this.dom.nameButton).appendTo(this.dom.buttonGroup);!this.c.hideCount&&(!b.hideCount&&this.c.orderable&&b.orderable&&this.c.controls&&b.controls)&&g(this.dom.countButton).appendTo(this.dom.buttonGroup);g(this.dom.topRow).prependTo(this.dom.container);g(a).append(this.dom.dtP); +g(a).show()};l.prototype._getBonusOptions=function(){return g.extend(!0,{},l.defaults,{orthogonal:{threshold:null},threshold:null},void 0!==this.c?this.c:{})};l.prototype._getComparisonRows=function(){var a=this.s.colOpts,a=void 0!==a.options?a.options:null!==this.customPaneSettings&&void 0!==this.customPaneSettings.options?this.customPaneSettings.options:void 0;if(void 0!==a){var b=this.s.dt.rows({search:"applied"}).data().toArray(),c=this.s.dt.rows({search:"applied"}),d=this.s.dt.rows().data().toArray(), +e=this.s.dt.rows(),h=[];this.s.dtPane.clear();for(var f=0;f<a.length;f++){var g=a[f],n=""!==g.label?g.label:this.c.emptyMessage,j=g.className,i=n,l="function"===typeof g.value?g.value:[],m=0,q=n,k=0;if("function"===typeof g.value){for(var r=0;r<b.length;r++)g.value.call(this.s.dt,b[r],c[0][r])&&m++;for(r=0;r<d.length;r++)g.value.call(this.s.dt,d[r],e[0][r])&&k++;"function"!==typeof l&&l.push(g.filter)}(!this.c.cascadePanes||this.c.cascadePanes&&0!==m)&&h.push(this._addRow(i,l,m,k,q,n,j))}return h}}; +l.prototype._getOptions=function(){return g.extend(!0,{},l.defaults,{emptyMessage:!1,orthogonal:{threshold:null},threshold:null},this.s.dt.settings()[0].aoColumns[this.s.index].searchPanes)};l.prototype._makeSelection=function(){this.updateTable();this.s.updating=!0;this.s.dt.draw();this.s.updating=!1};l.prototype._populatePane=function(a){void 0===a&&(a=!1);var b=this.s.dt;this.s.rowData.arrayFilter=[];this.s.rowData.bins={};var c=this.s.dt.settings()[0];if(!this.s.dt.page.info().serverSide)for(var d= +0,a=((this.c.cascadePanes||this.c.viewTotal)&&!this.s.clearing&&!a?b.rows({search:"applied"}).indexes():b.rows().indexes()).toArray();d<a.length;d++)this._populatePaneArray(a[d],this.s.rowData.arrayFilter,c)};l.prototype._populatePaneArray=function(a,b,c,d){void 0===d&&(d=this.s.rowData.bins);var e=this.s.colOpts;if("string"===typeof e.orthogonal)c=c.oApi._fnGetCellData(c,a,this.s.index,e.orthogonal),this.s.rowData.filterMap.set(a,c),this._addOption(c,c,c,c,b,d);else{var h=c.oApi._fnGetCellData(c, +a,this.s.index,e.orthogonal.search);"string"===typeof h&&(h=h.replace(/<[^>]*>/g,""));this.s.rowData.filterMap.set(a,h);d[h]?d[h]++:(d[h]=1,this._addOption(h,c.oApi._fnGetCellData(c,a,this.s.index,e.orthogonal.display),c.oApi._fnGetCellData(c,a,this.s.index,e.orthogonal.sort),c.oApi._fnGetCellData(c,a,this.s.index,e.orthogonal.type),b,d));this.s.rowData.totalOptions++}};l.prototype._reloadSelect=function(a){if(void 0!==a){for(var b,c=0;c<a.searchPanes.panes.length;c++)if(a.searchPanes.panes[c].id=== +this.s.index){b=c;break}if(void 0!==b)for(var c=this.s.dtPane,d=c.rows({order:"index"}).data().map(function(a){return null!==a.filter?a.filter.toString():null}).toArray(),e=0,a=a.searchPanes.panes[b].selected;e<a.length;e++){b=a[e];var h=-1;null!==b&&(h=d.indexOf(b.toString()));-1<h&&(c.row(h).select(),this.s.dt.state.save())}}};l.prototype._search=function(a,b){for(var c=this.s.colOpts,d=this.s.dt,e=0,h=this.selections;e<h.length;e++){var f=h[e];if(Array.isArray(a)){if(-1!==a.indexOf(f.filter))return!0}else if("function"=== +typeof f.filter)if(f.filter.call(d,d.row(b).data(),b)){if("or"===c.combiner)return!0}else{if("and"===c.combiner)return!1}else if(a===f.filter||!("string"===typeof a&&0===a.length)&&a==f.filter||null===f.filter&&"string"===typeof a&&""===a)return!0}return"and"===c.combiner?!0:!1};l.prototype._searchContSetup=function(){this.c.controls&&this.s.colOpts.controls&&g(this.dom.searchButton).appendTo(this.dom.searchLabelCont);!1===this.c.dtOpts.searching||(!1===this.s.colOpts.dtOpts.searching||null!==this.customPaneSettings&& +void 0!==this.customPaneSettings.dtOpts&&void 0!==this.customPaneSettings.dtOpts.searching&&!this.customPaneSettings.dtOpts.searching)||g(this.dom.searchLabelCont).appendTo(this.dom.searchCont)};l.prototype._searchExtras=function(){var a=this.s.updating;this.s.updating=!0;var b=this.s.dtPane.rows({selected:!0}).data().pluck("filter").toArray(),c=b.indexOf(!1!==this.s.colOpts.emptyMessage?this.s.colOpts.emptyMessage:this.c.emptyMessage),d=g(this.s.dtPane.table().container());-1<c&&(b[c]="");0<b.length? +d.addClass(this.classes.selected):0===b.length&&d.removeClass(this.classes.selected);this.s.updating=a};l.prototype._uniqueRatio=function(a,b){return 0<b&&(0<this.s.rowData.totalOptions&&!this.s.dt.page.info().serverSide||this.s.dt.page.info().serverSide&&0<this.s.tableLength)?a/this.s.rowData.totalOptions:1};l.prototype._updateCommon=function(a){void 0===a&&(a=!1);if(!this.s.dt.page.info().serverSide&&void 0!==this.s.dtPane&&(!this.s.filteringActive||this.c.cascadePanes||!0===a)&&(!0!==this.c.cascadePanes|| +!0!==this.s.selectPresent)&&(!this.s.lastSelect||!this.s.lastCascade)){var b=this.s.colOpts,c=this.s.dtPane.rows({selected:!0}).data().toArray(),a=g(this.s.dtPane.table().node()).parent()[0].scrollTop,d=this.s.rowData;this.s.dtPane.clear();if(this.colExists){0===d.arrayFilter.length?this._populatePane():this.c.cascadePanes&&this.s.dt.rows().data().toArray().length===this.s.dt.rows({search:"applied"}).data().toArray().length?(d.arrayFilter=d.arrayOriginal,d.bins=d.binsOriginal):(this.c.viewTotal|| +this.c.cascadePanes)&&this._populatePane();this.c.viewTotal?this._detailsPane():d.binsTotal=d.bins;this.c.viewTotal&&!this.c.cascadePanes&&(d.arrayFilter=d.arrayTotals);for(var e=function(a){if(a&&(d.bins[a.filter]!==void 0&&d.bins[a.filter]!==0&&h.c.cascadePanes||!h.c.cascadePanes||h.s.clearing)){var b=h._addRow(a.display,a.filter,!h.c.viewTotal?d.bins[a.filter]:d.bins[a.filter]!==void 0?d.bins[a.filter]:0,h.c.viewTotal?String(d.binsTotal[a.filter]):d.bins[a.filter],a.sort,a.type),f=c.findIndex(function(b){return b.filter=== +a.filter});if(f!==-1){b.select();c.splice(f,1)}}},h=this,f=0,o=d.arrayFilter;f<o.length;f++)e(o[f])}if(void 0!==b.searchPanes&&void 0!==b.searchPanes.options||void 0!==b.options||null!==this.customPaneSettings&&void 0!==this.customPaneSettings.options){e=function(a){var b=c.findIndex(function(b){if(b.display===a.data().display)return!0});-1!==b&&(a.select(),c.splice(b,1))};f=0;for(o=this._getComparisonRows();f<o.length;f++)b=o[f],e(b)}for(e=0;e<c.length;e++)b=c[e],b=this._addRow(b.display,b.filter, +0,this.c.viewTotal?b.total:0,b.display,b.display),this.s.updating=!0,b.select(),this.s.updating=!1;this.s.dtPane.draw();this.s.dtPane.table().node().parentNode.scrollTop=a}};l.version="1.1.0";l.classes={buttonGroup:"dtsp-buttonGroup",buttonSub:"dtsp-buttonSub",clear:"dtsp-clear",clearAll:"dtsp-clearAll",clearButton:"clearButton",container:"dtsp-searchPane",countButton:"dtsp-countButton",disabledButton:"dtsp-disabledButton",dull:"dtsp-dull",hidden:"dtsp-hidden",hide:"dtsp-hide",layout:"dtsp-",name:"dtsp-name", +nameButton:"dtsp-nameButton",nameCont:"dtsp-nameCont",narrow:"dtsp-narrow",paneButton:"dtsp-paneButton",paneInputButton:"dtsp-paneInputButton",pill:"dtsp-pill",search:"dtsp-search",searchCont:"dtsp-searchCont",searchIcon:"dtsp-searchIcon",searchLabelCont:"dtsp-searchButtonCont",selected:"dtsp-selected",smallGap:"dtsp-smallGap",subRow1:"dtsp-subRow1",subRow2:"dtsp-subRow2",subRowsContainer:"dtsp-subRowsContainer",title:"dtsp-title",topRow:"dtsp-topRow"};l.defaults={cascadePanes:!1,clear:!0,combiner:"or", +controls:!0,container:function(a){return a.table().container()},dtOpts:{},emptyMessage:"<i>No Data</i>",hideCount:!1,layout:"columns-3",name:void 0,orderable:!0,orthogonal:{display:"display",filter:"filter",hideCount:!1,search:"filter",show:void 0,sort:"sort",threshold:0.6,type:"type"},preSelect:[],threshold:0.6,viewTotal:!1};t=l;var i,s,u,m=function(a,b,c){var d=this;void 0===c&&(c=!1);this.regenerating=!1;if(!s||!s.versionCheck||!s.versionCheck("1.10.0"))throw Error("SearchPane requires DataTables 1.10 or newer"); +if(!s.select)throw Error("SearchPane requires Select");var e=new s.Api(a);this.classes=i.extend(!0,{},m.classes);this.c=i.extend(!0,{},m.defaults,b);this.dom={clearAll:i('<button type="button">Clear All</button>').addClass(this.classes.clearAll),container:i("<div/>").addClass(this.classes.panes).text(e.i18n("searchPanes.loadMessage","Loading Search Panes...")),emptyMessage:i("<div/>").addClass(this.classes.emptyMessage),options:i("<div/>").addClass(this.classes.container),panes:i("<div/>").addClass(this.classes.container), +title:i("<div/>").addClass(this.classes.title),titleRow:i("<div/>").addClass(this.classes.titleRow),wrapper:i("<div/>")};this.s={colOpts:[],dt:e,filterPane:-1,panes:[],selectionList:[],serverData:{},stateRead:!1,updating:!1};if(void 0===e.settings()[0]._searchPanes){e.on("xhr",function(a,b,c){c.searchPanes&&c.searchPanes.options&&(d.s.serverData=c.searchPanes.options,d.s.serverData.tableLength=c.recordsTotal,d._serverTotals())});e.settings()[0]._searchPanes=this;this.dom.clearAll.text(e.i18n("searchPanes.clearMessage", +"Clear All"));this._getState();if(this.s.dt.settings()[0]._bInitComplete||c)this._paneDeclare(e,a,b);else e.one("preInit.dt",function(){d._paneDeclare(e,a,b)});return this}};m.prototype.clearSelections=function(){this.dom.container.find(this.classes.search).each(function(){i(this).val("");i(this).trigger("input")});for(var a=[],b=0,c=this.s.panes;b<c.length;b++){var d=c[b];void 0!==d.s.dtPane&&a.push(d.clearPane())}this.s.dt.draw();return a};m.prototype.getNode=function(){return this.dom.container}; +m.prototype.rebuild=function(a,b){void 0===a&&(a=!1);void 0===b&&(b=!1);i(this.dom.emptyMessage).remove();var c=[];!1===a&&i(this.dom.panes).empty();for(var d=0,e=this.s.panes;d<e.length;d++){var h=e[d];!1!==a&&h.s.index!==a||(h.clearData(),c.push(h.rebuildPane(void 0!==this.s.selectionList[this.s.selectionList.length-1]?h.s.index===this.s.selectionList[this.s.selectionList.length-1].index:!1,this.s.dt.page.info().serverSide?this.s.serverData:void 0,null,b)),i(this.dom.panes).append(h.dom.container))}this.s.dt.page.info().serverSide|| +this.s.dt.draw();this.c.cascadePanes||this.c.viewTotal?this.redrawPanes(!0):this._updateSelection();this._updateFilterCount();this._attachPaneContainer();this.s.dt.draw();return 1===c.length?c[0]:c};m.prototype.redrawPanes=function(a){void 0===a&&(a=!1);var b=this.s.dt;if(!this.s.updating&&!this.s.dt.page.info().serverSide){var c=!0,d=this.s.filterPane;if(b.rows({search:"applied"}).data().toArray().length===b.rows().data().toArray().length)c=!1;else if(this.c.viewTotal)for(var e=0,h=this.s.panes;e< +h.length;e++){var f=h[e];if(void 0!==f.s.dtPane){var g=f.s.dtPane.rows({selected:!0}).data().toArray().length;if(0===g)for(var n=0,j=this.s.selectionList;n<j.length;n++){var i=j[n];i.index===f.s.index&&0!==i.rows.length&&(g=i.rows.length)}0<g&&-1===d?d=f.s.index:0<g&&(d=null)}}h=void 0;e=[];if(this.regenerating){h=-1;1===e.length&&(h=e[0].index);a=0;for(e=this.s.panes;a<e.length;a++)if(f=e[a],void 0!==f.s.dtPane){b=!0;f.s.filteringActive=!0;if(-1!==d&&null!==d&&d===f.s.index||!1===c||f.s.index=== +h)b=!1,f.s.filteringActive=!1;f.updatePane(!b?b:c)}this._updateFilterCount()}else{g=0;for(n=this.s.panes;g<n.length;g++)if(f=n[g],f.s.selectPresent){this.s.selectionList.push({index:f.s.index,rows:f.s.dtPane.rows({selected:!0}).data().toArray(),protect:!1});b.state.save();break}else f.s.deselect&&(h=f.s.index,j=f.s.dtPane.rows({selected:!0}).data().toArray(),0<j.length&&this.s.selectionList.push({index:f.s.index,rows:j,protect:!0}));if(0<this.s.selectionList.length){b=this.s.selectionList[this.s.selectionList.length- +1].index;g=0;for(n=this.s.panes;g<n.length;g++)f=n[g],f.s.lastSelect=f.s.index===b}for(f=0;f<this.s.selectionList.length;f++)if(this.s.selectionList[f].index!==h||!0===this.s.selectionList[f].protect){b=!1;for(g=f+1;g<this.s.selectionList.length;g++)this.s.selectionList[g].index===this.s.selectionList[f].index&&(b=!0);b||(e.push(this.s.selectionList[f]),this.s.selectionList[f].protect=!1)}h=-1;1===e.length&&(h=e[0].index);g=0;for(n=this.s.panes;g<n.length;g++)if(f=n[g],void 0!==f.s.dtPane){b=!0;f.s.filteringActive= +!0;if(-1!==d&&null!==d&&d===f.s.index||!1===c||f.s.index===h)b=!1,f.s.filteringActive=!1;f.updatePane(!b?!1:c)}this._updateFilterCount();if(0<e.length&&(e.length<this.s.selectionList.length||a)){this._cascadeRegen(e);b=e[e.length-1].index;d=0;for(a=this.s.panes;d<a.length;d++)f=a[d],f.s.lastSelect=f.s.index===b}else if(0<e.length){f=0;for(a=this.s.panes;f<a.length;f++)if(e=a[f],void 0!==e.s.dtPane){b=!0;e.s.filteringActive=!0;if(-1!==d&&null!==d&&d===e.s.index||!1===c)b=!1,e.s.filteringActive=!1; +e.updatePane(!b?b:c)}}}c||(this.s.selectionList=[])}};m.prototype._attach=function(){var a=this;i(this.dom.container).removeClass(this.classes.hide);i(this.dom.titleRow).removeClass(this.classes.hide);i(this.dom.titleRow).remove();i(this.dom.title).appendTo(this.dom.titleRow);this.c.clear&&(i(this.dom.clearAll).appendTo(this.dom.titleRow),i(this.dom.clearAll).on("click.dtsps",function(){a.clearSelections()}));i(this.dom.titleRow).appendTo(this.dom.container);for(var b=0,c=this.s.panes;b<c.length;b++)i(c[b].dom.container).appendTo(this.dom.panes); +i(this.dom.panes).appendTo(this.dom.container);0===i("div."+this.classes.container).length&&i(this.dom.container).prependTo(this.s.dt);return this.dom.container};m.prototype._attachExtras=function(){i(this.dom.container).removeClass(this.classes.hide);i(this.dom.titleRow).removeClass(this.classes.hide);i(this.dom.titleRow).remove();i(this.dom.title).appendTo(this.dom.titleRow);this.c.clear&&i(this.dom.clearAll).appendTo(this.dom.titleRow);i(this.dom.titleRow).appendTo(this.dom.container);return this.dom.container}; +m.prototype._attachMessage=function(){var a;try{a=this.s.dt.i18n("searchPanes.emptyPanes","No SearchPanes")}catch(b){a=null}if(null===a)i(this.dom.container).addClass(this.classes.hide),i(this.dom.titleRow).removeClass(this.classes.hide);else return i(this.dom.container).removeClass(this.classes.hide),i(this.dom.titleRow).addClass(this.classes.hide),i(this.dom.emptyMessage).text(a),this.dom.emptyMessage.appendTo(this.dom.container),this.dom.container};m.prototype._attachPaneContainer=function(){for(var a= +0,b=this.s.panes;a<b.length;a++)if(!0===b[a].s.displayed)return this._attach();return this._attachMessage()};m.prototype._cascadeRegen=function(a){this.regenerating=!0;var b=-1;1===a.length&&(b=a[0].index);for(var c=0,d=this.s.panes;c<d.length;c++){var e=d[c];e.setCascadeRegen(!0);e.setClear(!0);(void 0!==e.s.dtPane&&e.s.index===b||void 0!==e.s.dtPane)&&e.clearPane();e.setClear(!1)}this._makeCascadeSelections(a);this.s.selectionList=a;a=0;for(b=this.s.panes;a<b.length;a++)e=b[a],e.setCascadeRegen(!1); +this.regenerating=!1};m.prototype._checkMessage=function(){for(var a=0,b=this.s.panes;a<b.length;a++)if(!0===b[a].s.displayed)return;return this._attachMessage()};m.prototype._getState=function(){var a=this.s.dt.state.loaded();a&&(a.searchPanes&&void 0!==a.searchPanes.selectionList)&&(this.s.selectionList=a.searchPanes.selectionList)};m.prototype._makeCascadeSelections=function(a){for(var b=0;b<a.length;b++)for(var c=function(c){if(c.s.index===a[b].index&&void 0!==c.s.dtPane){b===a.length-1&&(c.s.lastCascade= +!0);0<c.s.dtPane.rows({selected:!0}).data().toArray().length&&void 0!==c.s.dtPane&&(c.setClear(!0),c.clearPane(),c.setClear(!1));for(var e=function(a){c.s.dtPane.rows().every(function(b){c.s.dtPane.row(b).data()!==void 0&&(a!==void 0&&c.s.dtPane.row(b).data().filter===a.filter)&&c.s.dtPane.row(b).select()})},h=0,g=a[b].rows;h<g.length;h++)e(g[h]);d._updateFilterCount();c.s.lastCascade=!1}},d=this,e=0,h=this.s.panes;e<h.length;e++)c(h[e]);this.s.dt.state.save()};m.prototype._paneDeclare=function(a, +b,c){var d=this;a.columns(0<this.c.columns.length?this.c.columns:void 0).eq(0).each(function(a){d.s.panes.push(new t(b,c,a,d.c.layout,d.dom.panes))});for(var e=a.columns().eq(0).toArray().length,h=this.c.panes.length,f=0;f<h;f++)this.s.panes.push(new t(b,c,e+f,this.c.layout,this.dom.panes,this.c.panes[f]));if(0<this.c.order.length){e=this.c.order.map(function(a){return d._findPane(a)});this.dom.panes.empty();this.s.panes=e;e=0;for(h=this.s.panes;e<h.length;e++)this.dom.panes.append(h[e].dom.container)}this.s.dt.settings()[0]._bInitComplete? +this._startup(a):this.s.dt.settings()[0].aoInitComplete.push({fn:function(){d._startup(a)}})};m.prototype._findPane=function(a){for(var b=0,c=this.s.panes;b<c.length;b++){var d=c[b];if(a===d.s.name)return d}};m.prototype._serverTotals=function(){for(var a=!1,b=!1,c=this.s.dt,d=0,e=this.s.panes;d<e.length;d++){var h=e[d];if(h.s.selectPresent){this.s.selectionList.push({index:h.s.index,rows:h.s.dtPane.rows({selected:!0}).data().toArray(),protect:!1});c.state.save();h.s.selectPresent=!1;a=!0;break}else h.s.deselect&& +(b=h.s.dtPane.rows({selected:!0}).data().toArray(),0<b.length&&this.s.selectionList.push({index:h.s.index,rows:b,protect:!0}),b=a=!0)}if(a){h=[];for(c=0;c<this.s.selectionList.length;c++){d=!1;for(e=c+1;e<this.s.selectionList.length;e++)this.s.selectionList[e].index===this.s.selectionList[c].index&&(d=!0);!d&&0<this.s.panes[this.s.selectionList[c].index].s.dtPane.rows({selected:!0}).data().toArray().length&&h.push(this.s.selectionList[c])}this.s.selectionList=h}else this.s.selectionList=[];c=-1;if(b&& +1===this.s.selectionList.length){b=0;for(d=this.s.panes;b<d.length;b++)h=d[b],h.s.lastSelect=!1,h.s.deselect=!1,void 0!==h.s.dtPane&&0<h.s.dtPane.rows({selected:!0}).data().toArray().length&&(c=h.s.index)}else if(0<this.s.selectionList.length){b=this.s.selectionList[this.s.selectionList.length-1].index;d=0;for(e=this.s.panes;d<e.length;d++)h=e[d],h.s.lastSelect=h.s.index===b,h.s.deselect=!1}else if(0===this.s.selectionList.length){b=0;for(d=this.s.panes;b<d.length;b++)h=d[b],h.s.lastSelect=!1,h.s.deselect= +!1}i(this.dom.panes).empty();b=0;for(d=this.s.panes;b<d.length;b++)h=d[b],h.s.lastSelect?h._setListeners():h.rebuildPane(void 0,this.s.dt.page.info().serverSide?this.s.serverData:void 0,h.s.index===c?!0:null,!0),i(this.dom.panes).append(h.dom.container),void 0!==h.s.dtPane&&(i(h.s.dtPane.table().node()).parent()[0].scrollTop=h.s.scrollTop,i.fn.dataTable.select.init(h.s.dtPane));this.s.dt.page.info().serverSide||this.s.dt.draw()};m.prototype._startup=function(a){var b=this;i(this.dom.container).text(""); +this._attachExtras();i(this.dom.container).append(this.dom.panes);i(this.dom.panes).empty();var c=this.s.dt.state.loaded();if(this.c.viewTotal&&!this.c.cascadePanes&&null!==c&&void 0!==c&&void 0!==c.searchPanes&&void 0!==c.searchPanes.panes){for(var d=!1,e=0,h=c.searchPanes.panes;e<h.length;e++){var f=h[e];if(0<f.selected.length){d=!0;break}}if(d){d=0;for(e=this.s.panes;d<e.length;d++)f=e[d],f.s.showFiltered=!0}}d=0;for(e=this.s.panes;d<e.length;d++)f=e[d],f.rebuildPane(void 0,0<Object.keys(this.s.serverData).length? +this.s.serverData:void 0),i(this.dom.panes).append(f.dom.container);this.s.dt.page.info().serverSide||this.s.dt.draw();!this.s.stateRead&&(null!==c&&void 0!==c)&&(this.s.dt.page(c.start/this.s.dt.page.len()),this.s.dt.draw("page"));this.s.stateRead=!0;if(this.c.viewTotal&&!this.c.cascadePanes){c=0;for(d=this.s.panes;c<d.length;c++)f=d[c],f.updatePane()}this._updateFilterCount();this._checkMessage();a.on("preDraw.dtsps",function(){b._updateFilterCount();(b.c.cascadePanes||b.c.viewTotal)&&!b.s.dt.page.info().serverSide? +b.redrawPanes():b._updateSelection();b.s.filterPane=-1});this.s.dt.on("stateSaveParams.dtsp",function(a,c,d){if(d.searchPanes===void 0)d.searchPanes={};d.searchPanes.selectionList=b.s.selectionList});this.s.dt.on("xhr",function(){var a=false;if(!b.s.dt.page.info().serverSide)b.s.dt.one("preDraw",function(){if(!a){a=true;i(b.dom.panes).empty();for(var c=0,d=b.s.panes;c<d.length;c++){var f=d[c];f.clearData();f.rebuildPane(b.s.selectionList[b.s.selectionList.length-1]!==void 0?f.s.index===b.s.selectionList[b.s.selectionList.length- +1].index:false,void 0,void 0,true);i(b.dom.panes).append(f.dom.container)}b.s.dt.page.info().serverSide||b.s.dt.draw();b.c.cascadePanes||b.c.viewTotal?b.redrawPanes(b.c.cascadePanes):b._updateSelection();b._checkMessage()}})});c=0;for(d=this.s.panes;c<d.length;c++)if(f=d[c],void 0!==f&&void 0!==f.s.dtPane&&(void 0!==f.s.colOpts.preSelect||void 0!==f.customPaneSettings.preSelect)){e=f.s.dtPane.rows().data().toArray().length;for(h=0;h<e;h++)(-1!==f.s.colOpts.preSelect.indexOf(f.s.dtPane.cell(h,0).data())|| +null!==f.customPaneSettings&&void 0!==f.customPaneSettings.preSelect&&-1!==f.customPaneSettings.preSelect.indexOf(f.s.dtPane.cell(h,0).data()))&&f.s.dtPane.row(h).select();f.updateTable()}if(void 0!==this.s.selectionList&&0<this.s.selectionList.length){c=this.s.selectionList[this.s.selectionList.length-1].index;d=0;for(e=this.s.panes;d<e.length;d++)f=e[d],f.s.lastSelect=f.s.index===c}0<this.s.selectionList.length&&this.c.cascadePanes&&this._cascadeRegen(this.s.selectionList);this._updateFilterCount(); +a.on("destroy.dtsps",function(){for(var c=0,d=b.s.panes;c<d.length;c++)d[c].destroy();a.off(".dtsps");i(b.dom.clearAll).off(".dtsps");i(b.dom.container).remove();b.clearSelections()});if(this.c.clear)i(this.dom.clearAll).on("click.dtsps",function(){b.clearSelections()});if(this.s.dt.page.info().serverSide)a.on("preXhr.dt",function(a,c,d){if(d.searchPanes===void 0)d.searchPanes={};a=0;for(c=b.s.panes;a<c.length;a++){var f=c[a],e=b.s.dt.column(f.s.index).dataSrc();d.searchPanes[e]===void 0&&(d.searchPanes[e]= +{});if(f.s.dtPane!==void 0)for(var f=f.s.dtPane.rows({selected:true}).data().toArray(),h=0;h<f.length;h++)d.searchPanes[e][h]=f[h].filter}b.c.viewTotal&&b._prepViewTotal()});else a.on("preXhr.dt",function(){for(var a=0,c=b.s.panes;a<c.length;a++)c[a].clearData()});a.settings()[0]._searchPanes=this};m.prototype._prepViewTotal=function(){for(var a=this.s.filterPane,b=!1,c=0,d=this.s.panes;c<d.length;c++){var e=d[c];if(void 0!==e.s.dtPane){var h=e.s.dtPane.rows({selected:!0}).data().toArray().length; +0<h&&-1===a?(a=e.s.index,b=!0):0<h&&(a=null)}}c=0;for(d=this.s.panes;c<d.length;c++)if(e=d[c],void 0!==e.s.dtPane&&(e.s.filteringActive=!0,-1!==a&&null!==a&&a===e.s.index||!1===b))e.s.filteringActive=!1};m.prototype._updateFilterCount=function(){for(var a=0,b=0,c=this.s.panes;b<c.length;b++){var d=c[b];void 0!==d.s.dtPane&&(a+=d.getPaneCount())}b=this.s.dt.i18n("searchPanes.title","Filters Active - %d",a);i(this.dom.title).text(b);void 0!==this.c.filterChanged&&"function"===typeof this.c.filterChanged&& +this.c.filterChanged.call(this.s.dt,a)};m.prototype._updateSelection=function(){this.s.selectionList=[];for(var a=0,b=this.s.panes;a<b.length;a++){var c=b[a];void 0!==c.s.dtPane&&this.s.selectionList.push({index:c.s.index,rows:c.s.dtPane.rows({selected:!0}).data().toArray(),protect:!1})}this.s.dt.state.save()};m.version="1.2.1";m.classes={clear:"dtsp-clear",clearAll:"dtsp-clearAll",container:"dtsp-searchPanes",emptyMessage:"dtsp-emptyMessage",hide:"dtsp-hidden",panes:"dtsp-panesContainer",search:"dtsp-search", +title:"dtsp-title",titleRow:"dtsp-titleRow"};m.defaults={cascadePanes:!1,clear:!0,container:function(a){return a.table().container()},columns:[],filterChanged:void 0,layout:"columns-3",order:[],panes:[],viewTotal:!1};u=m;var v=function(a,b,c){function d(a,b){void 0===b&&(b=!1);var c=new e.Api(a),d=c.init().searchPanes||e.defaults.searchPanes;return(new u(c,d,b)).getNode()}g=a;q=a.fn.dataTable;i=a;var e=s=a.fn.dataTable;a.fn.dataTable.SearchPanes=u;a.fn.DataTable.SearchPanes=u;a.fn.dataTable.SearchPane= +t;a.fn.DataTable.SearchPane=t;b=a.fn.dataTable.Api.register;b("searchPanes()",function(){return this});b("searchPanes.clearSelections()",function(){return this.iterator("table",function(a){a._searchPanes&&a._searchPanes.clearSelections()})});b("searchPanes.rebuildPane()",function(a,b){return this.iterator("table",function(c){c._searchPanes&&c._searchPanes.rebuild(a,b)})});b("searchPanes.container()",function(){var a=this.context[0];return a._searchPanes?a._searchPanes.getNode():null});a.fn.dataTable.ext.buttons.searchPanesClear= +{text:"Clear Panes",action:function(a,b){b.searchPanes.clearSelections()}};a.fn.dataTable.ext.buttons.searchPanes={action:function(a,b,c,d){a.stopPropagation();this.popover(d._panes.getNode(),{align:"dt-container"});d._panes.rebuild(void 0,!0)},config:{},init:function(b,c,d){var e=new a.fn.dataTable.SearchPanes(b,a.extend({filterChanged:function(a){b.button(c).text(b.i18n("searchPanes.collapse",{"0":"SearchPanes",_:"SearchPanes (%d)"},a))}},d.config)),g=b.i18n("searchPanes.collapse","SearchPanes", +0);b.button(c).text(g);d._panes=e},text:"Search Panes"};a(c).on("preInit.dt.dtsp",function(a,b){if("dt"===a.namespace&&(b.oInit.searchPanes||e.defaults.searchPanes))b._searchPanes||d(b,!0)});e.ext.feature.push({cFeature:"P",fnInit:d});e.ext.features&&e.ext.features.register("searchPanes",d)};"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return v(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);if(!b||!b.fn.dataTable)b= +require("datatables.net")(a,b).$;return v(b,a,a.document)}:v(window.jQuery,window,document)})(); diff --git a/plugins/datatables-searchpanes/js/searchPanes.bootstrap4.js b/plugins/datatables-searchpanes/js/searchPanes.bootstrap4.js new file mode 100644 index 000000000..4403ff986 --- /dev/null +++ b/plugins/datatables-searchpanes/js/searchPanes.bootstrap4.js @@ -0,0 +1,58 @@ +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD + define(['jquery', 'datatables.net-bs4', 'datatables.net-searchpanes'], function ($) { + return factory($, window, document); + }); + } + else if (typeof exports === 'object') { + // CommonJS + module.exports = function (root, $) { + if (!root) { + root = window; + } + if (!$ || !$.fn.dataTable) { + $ = require('datatables.net-bs4')(root, $).$; + } + console.log($.fn.dataTable); + if (!$.fn.dataTable.SearchPanes) { + console.log("not present"); + require('datatables.net-searchpanes')(root, $); + } + return factory($, root, root.document); + }; + } + else { + // Browser + factory(jQuery, window, document); + } +}(function ($, window, document) { + 'use strict'; + var DataTable = $.fn.dataTable; + $.extend(true, DataTable.SearchPane.classes, { + buttonGroup: 'btn-group col justify-content-end', + disabledButton: 'disabled', + dull: '', + narrow: 'col', + pane: { + container: 'table' + }, + paneButton: 'btn btn-light', + pill: 'pill badge badge-pill badge-secondary', + search: 'col-sm form-control search', + searchCont: 'input-group col-sm', + searchLabelCont: 'input-group-append', + subRow1: 'dtsp-subRow1', + subRow2: 'dtsp-subRow2', + table: 'table table-sm table-borderless', + topRow: 'dtsp-topRow row' + }); + $.extend(true, DataTable.SearchPanes.classes, { + clearAll: 'dtsp-clearAll col-auto btn btn-light', + container: 'dtsp-searchPanes', + panes: 'dtsp-panes dtsp-container', + title: 'dtsp-title col', + titleRow: 'dtsp-titleRow row' + }); + return DataTable.searchPanes; +})); diff --git a/plugins/datatables-searchpanes/js/searchPanes.bootstrap4.min.js b/plugins/datatables-searchpanes/js/searchPanes.bootstrap4.min.js new file mode 100644 index 000000000..df54bc27d --- /dev/null +++ b/plugins/datatables-searchpanes/js/searchPanes.bootstrap4.min.js @@ -0,0 +1,3 @@ +(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net-bs4","datatables.net-searchpanes"],function(a){return c(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);if(!b||!b.fn.dataTable)b=require("datatables.net-bs4")(a,b).$;console.log(b.fn.dataTable);b.fn.dataTable.SearchPanes||(console.log("not present"),require("datatables.net-searchpanes")(a,b));return c(b,a,a.document)}:c(jQuery,window,document)})(function(c){var a=c.fn.dataTable; +c.extend(!0,a.SearchPane.classes,{buttonGroup:"btn-group col justify-content-end",disabledButton:"disabled",dull:"",narrow:"col",pane:{container:"table"},paneButton:"btn btn-light",pill:"pill badge badge-pill badge-secondary",search:"col-sm form-control search",searchCont:"input-group col-sm",searchLabelCont:"input-group-append",subRow1:"dtsp-subRow1",subRow2:"dtsp-subRow2",table:"table table-sm table-borderless",topRow:"dtsp-topRow row"});c.extend(!0,a.SearchPanes.classes,{clearAll:"dtsp-clearAll col-auto btn btn-light", +container:"dtsp-searchPanes",panes:"dtsp-panes dtsp-container",title:"dtsp-title col",titleRow:"dtsp-titleRow row"});return a.searchPanes});