From bd21cad28667ac8b65e3a8562f982fedddd9b555 Mon Sep 17 00:00:00 2001 From: "Portugal, Marcelo" Date: Wed, 16 May 2018 19:59:14 -0400 Subject: [PATCH] gh-pages v4.4.11 --- docs/index.html | 10 +- docs/js/docs-setup.js | 4 +- docs/partials/tutorial/100_preReqs.html | 6 +- docs/partials/tutorial/499_FAQ.html | 7 +- index.html | 10 +- release/4.4.11/i18n/ui-grid.language.all.js | 2791 ++ .../4.4.11/i18n/ui-grid.language.all.min.js | 7 + release/4.4.11/i18n/ui-grid.language.ar.js | 118 + .../4.4.11/i18n/ui-grid.language.ar.min.js | 7 + release/4.4.11/i18n/ui-grid.language.bg.js | 114 + .../4.4.11/i18n/ui-grid.language.bg.min.js | 7 + release/4.4.11/i18n/ui-grid.language.cs.js | 95 + .../4.4.11/i18n/ui-grid.language.cs.min.js | 7 + release/4.4.11/i18n/ui-grid.language.da.js | 84 + .../4.4.11/i18n/ui-grid.language.da.min.js | 7 + release/4.4.11/i18n/ui-grid.language.de.js | 119 + .../4.4.11/i18n/ui-grid.language.de.min.js | 7 + release/4.4.11/i18n/ui-grid.language.es.js | 90 + .../4.4.11/i18n/ui-grid.language.es.min.js | 7 + release/4.4.11/i18n/ui-grid.language.fa.js | 92 + .../4.4.11/i18n/ui-grid.language.fa.min.js | 7 + release/4.4.11/i18n/ui-grid.language.fi.js | 75 + .../4.4.11/i18n/ui-grid.language.fi.min.js | 7 + release/4.4.11/i18n/ui-grid.language.fr.js | 120 + .../4.4.11/i18n/ui-grid.language.fr.min.js | 7 + release/4.4.11/i18n/ui-grid.language.he.js | 70 + .../4.4.11/i18n/ui-grid.language.he.min.js | 7 + release/4.4.11/i18n/ui-grid.language.hy.js | 75 + .../4.4.11/i18n/ui-grid.language.hy.min.js | 7 + release/4.4.11/i18n/ui-grid.language.is.js | 117 + .../4.4.11/i18n/ui-grid.language.is.min.js | 7 + release/4.4.11/i18n/ui-grid.language.it.js | 104 + .../4.4.11/i18n/ui-grid.language.it.min.js | 7 + release/4.4.11/i18n/ui-grid.language.ja.js | 117 + .../4.4.11/i18n/ui-grid.language.ja.min.js | 7 + release/4.4.11/i18n/ui-grid.language.ko.js | 76 + .../4.4.11/i18n/ui-grid.language.ko.min.js | 7 + release/4.4.11/i18n/ui-grid.language.nl.js | 90 + .../4.4.11/i18n/ui-grid.language.nl.min.js | 7 + release/4.4.11/i18n/ui-grid.language.no.js | 114 + .../4.4.11/i18n/ui-grid.language.no.min.js | 7 + release/4.4.11/i18n/ui-grid.language.pl.js | 125 + .../4.4.11/i18n/ui-grid.language.pl.min.js | 7 + release/4.4.11/i18n/ui-grid.language.pt-br.js | 125 + .../4.4.11/i18n/ui-grid.language.pt-br.min.js | 7 + release/4.4.11/i18n/ui-grid.language.pt.js | 125 + .../4.4.11/i18n/ui-grid.language.pt.min.js | 7 + release/4.4.11/i18n/ui-grid.language.ro.js | 111 + .../4.4.11/i18n/ui-grid.language.ro.min.js | 7 + release/4.4.11/i18n/ui-grid.language.ru.js | 111 + .../4.4.11/i18n/ui-grid.language.ru.min.js | 7 + release/4.4.11/i18n/ui-grid.language.sk.js | 67 + .../4.4.11/i18n/ui-grid.language.sk.min.js | 7 + release/4.4.11/i18n/ui-grid.language.sv.js | 76 + .../4.4.11/i18n/ui-grid.language.sv.min.js | 7 + release/4.4.11/i18n/ui-grid.language.ta.js | 86 + .../4.4.11/i18n/ui-grid.language.ta.min.js | 7 + release/4.4.11/i18n/ui-grid.language.tr.js | 111 + .../4.4.11/i18n/ui-grid.language.tr.min.js | 7 + release/4.4.11/i18n/ui-grid.language.ua.js | 111 + .../4.4.11/i18n/ui-grid.language.ua.min.js | 7 + release/4.4.11/i18n/ui-grid.language.zh-cn.js | 111 + .../4.4.11/i18n/ui-grid.language.zh-cn.min.js | 7 + release/4.4.11/i18n/ui-grid.language.zh-tw.js | 76 + .../4.4.11/i18n/ui-grid.language.zh-tw.min.js | 7 + release/4.4.11/less/animation.less | 85 + release/4.4.11/less/body.less | 77 + release/4.4.11/less/bootstrap/bootstrap.less | 78 + release/4.4.11/less/cell.less | 49 + release/4.4.11/less/cellnav/less/cellNav.less | 30 + release/4.4.11/less/edit/less/edit.less | 27 + release/4.4.11/less/elements.less | 156 + .../empty-base-layer/less/emptyBaseLayer.less | 8 + .../less/expandable/less/expandable.less | 29 + .../4.4.11/less/exporter/less/exporter.less | 4 + release/4.4.11/less/footer.less | 81 + release/4.4.11/less/grid.less | 86 + .../4.4.11/less/grouping/less/grouping.less | 5 + release/4.4.11/less/header.less | 243 + release/4.4.11/less/icons.less | 149 + .../4.4.11/less/importer/less/importer.less | 4 + release/4.4.11/less/main.less | 13 + release/4.4.11/less/menu.less | 88 + .../less/move-columns/less/colMovable.less | 12 + .../less/pagination/less/pagination.less | 154 + release/4.4.11/less/pinning/less/pinning.less | 86 + .../resize-columns/less/column-resizer.less | 53 + .../4.4.11/less/row-edit/less/rowEdit.less | 19 + release/4.4.11/less/rtl.less | 65 + .../4.4.11/less/selection/less/selection.less | 29 + release/4.4.11/less/sorting.less | 29 + .../4.4.11/less/tree-base/less/tree-base.less | 6 + .../4.4.11/less/tree-view/less/tree-view.less | 8 + .../4.4.11/less/validate/less/validate.less | 5 + release/4.4.11/less/variables.less | 91 + release/4.4.11/ui-grid.auto-resize.js | 61 + release/4.4.11/ui-grid.auto-resize.min.js | 7 + release/4.4.11/ui-grid.cellnav.js | 1194 + release/4.4.11/ui-grid.cellnav.min.js | 7 + release/4.4.11/ui-grid.core.js | 12891 +++++++ release/4.4.11/ui-grid.core.min.js | 7 + release/4.4.11/ui-grid.css | 1922 + release/4.4.11/ui-grid.edit.js | 1313 + release/4.4.11/ui-grid.edit.min.js | 7 + release/4.4.11/ui-grid.empty-base-layer.js | 167 + .../4.4.11/ui-grid.empty-base-layer.min.js | 7 + release/4.4.11/ui-grid.eot | Bin 0 -> 10320 bytes release/4.4.11/ui-grid.expandable.js | 590 + release/4.4.11/ui-grid.expandable.min.js | 7 + release/4.4.11/ui-grid.exporter.js | 1739 + release/4.4.11/ui-grid.exporter.min.js | 7 + release/4.4.11/ui-grid.grouping.js | 1281 + release/4.4.11/ui-grid.grouping.min.js | 7 + release/4.4.11/ui-grid.importer.js | 763 + release/4.4.11/ui-grid.importer.min.js | 7 + release/4.4.11/ui-grid.infinite-scroll.js | 546 + release/4.4.11/ui-grid.infinite-scroll.min.js | 7 + release/4.4.11/ui-grid.js | 30243 ++++++++++++++++ release/4.4.11/ui-grid.min.css | 4 + release/4.4.11/ui-grid.min.js | 7 + release/4.4.11/ui-grid.move-columns.js | 581 + release/4.4.11/ui-grid.move-columns.min.js | 7 + release/4.4.11/ui-grid.pagination.js | 498 + release/4.4.11/ui-grid.pagination.min.js | 7 + release/4.4.11/ui-grid.pinning.js | 282 + release/4.4.11/ui-grid.pinning.min.js | 7 + release/4.4.11/ui-grid.resize-columns.js | 569 + release/4.4.11/ui-grid.resize-columns.min.js | 7 + release/4.4.11/ui-grid.row-edit.js | 715 + release/4.4.11/ui-grid.row-edit.min.js | 7 + release/4.4.11/ui-grid.saveState.js | 836 + release/4.4.11/ui-grid.saveState.min.js | 7 + release/4.4.11/ui-grid.selection.js | 1023 + release/4.4.11/ui-grid.selection.min.js | 7 + release/4.4.11/ui-grid.svg | 56 + release/4.4.11/ui-grid.tree-base.js | 1675 + release/4.4.11/ui-grid.tree-base.min.js | 7 + release/4.4.11/ui-grid.tree-view.js | 219 + release/4.4.11/ui-grid.tree-view.min.js | 7 + release/4.4.11/ui-grid.ttf | Bin 0 -> 10156 bytes release/4.4.11/ui-grid.validate.js | 589 + release/4.4.11/ui-grid.validate.min.js | 7 + release/4.4.11/ui-grid.woff | Bin 0 -> 5728 bytes release/i18n/ui-grid.language.all.js | 2 +- release/i18n/ui-grid.language.all.min.js | 2 +- release/i18n/ui-grid.language.ar.js | 2 +- release/i18n/ui-grid.language.ar.min.js | 2 +- release/i18n/ui-grid.language.bg.js | 2 +- release/i18n/ui-grid.language.bg.min.js | 2 +- release/i18n/ui-grid.language.cs.js | 2 +- release/i18n/ui-grid.language.cs.min.js | 2 +- release/i18n/ui-grid.language.da.js | 2 +- release/i18n/ui-grid.language.da.min.js | 2 +- release/i18n/ui-grid.language.de.js | 2 +- release/i18n/ui-grid.language.de.min.js | 2 +- release/i18n/ui-grid.language.es.js | 2 +- release/i18n/ui-grid.language.es.min.js | 2 +- release/i18n/ui-grid.language.fa.js | 2 +- release/i18n/ui-grid.language.fa.min.js | 2 +- release/i18n/ui-grid.language.fi.js | 2 +- release/i18n/ui-grid.language.fi.min.js | 2 +- release/i18n/ui-grid.language.fr.js | 2 +- release/i18n/ui-grid.language.fr.min.js | 2 +- release/i18n/ui-grid.language.he.js | 2 +- release/i18n/ui-grid.language.he.min.js | 2 +- release/i18n/ui-grid.language.hy.js | 2 +- release/i18n/ui-grid.language.hy.min.js | 2 +- release/i18n/ui-grid.language.is.js | 2 +- release/i18n/ui-grid.language.is.min.js | 2 +- release/i18n/ui-grid.language.it.js | 2 +- release/i18n/ui-grid.language.it.min.js | 2 +- release/i18n/ui-grid.language.ja.js | 2 +- release/i18n/ui-grid.language.ja.min.js | 2 +- release/i18n/ui-grid.language.ko.js | 2 +- release/i18n/ui-grid.language.ko.min.js | 2 +- release/i18n/ui-grid.language.nl.js | 2 +- release/i18n/ui-grid.language.nl.min.js | 2 +- release/i18n/ui-grid.language.no.js | 2 +- release/i18n/ui-grid.language.no.min.js | 2 +- release/i18n/ui-grid.language.pl.js | 2 +- release/i18n/ui-grid.language.pl.min.js | 2 +- release/i18n/ui-grid.language.pt-br.js | 2 +- release/i18n/ui-grid.language.pt-br.min.js | 2 +- release/i18n/ui-grid.language.pt.js | 2 +- release/i18n/ui-grid.language.pt.min.js | 2 +- release/i18n/ui-grid.language.ro.js | 2 +- release/i18n/ui-grid.language.ro.min.js | 2 +- release/i18n/ui-grid.language.ru.js | 2 +- release/i18n/ui-grid.language.ru.min.js | 2 +- release/i18n/ui-grid.language.sk.js | 2 +- release/i18n/ui-grid.language.sk.min.js | 2 +- release/i18n/ui-grid.language.sv.js | 2 +- release/i18n/ui-grid.language.sv.min.js | 2 +- release/i18n/ui-grid.language.ta.js | 2 +- release/i18n/ui-grid.language.ta.min.js | 2 +- release/i18n/ui-grid.language.tr.js | 2 +- release/i18n/ui-grid.language.tr.min.js | 2 +- release/i18n/ui-grid.language.ua.js | 2 +- release/i18n/ui-grid.language.ua.min.js | 2 +- release/i18n/ui-grid.language.zh-cn.js | 2 +- release/i18n/ui-grid.language.zh-cn.min.js | 2 +- release/i18n/ui-grid.language.zh-tw.js | 2 +- release/i18n/ui-grid.language.zh-tw.min.js | 2 +- release/ui-grid.auto-resize.js | 2 +- release/ui-grid.auto-resize.min.js | 2 +- release/ui-grid.cellnav.js | 2 +- release/ui-grid.cellnav.min.js | 2 +- release/ui-grid.core.js | 16 +- release/ui-grid.core.min.js | 4 +- release/ui-grid.css | 2 +- release/ui-grid.edit.js | 2 +- release/ui-grid.edit.min.js | 2 +- release/ui-grid.empty-base-layer.js | 2 +- release/ui-grid.empty-base-layer.min.js | 2 +- release/ui-grid.expandable.js | 2 +- release/ui-grid.expandable.min.js | 2 +- release/ui-grid.exporter.js | 2 +- release/ui-grid.exporter.min.js | 2 +- release/ui-grid.grouping.js | 2 +- release/ui-grid.grouping.min.js | 2 +- release/ui-grid.importer.js | 2 +- release/ui-grid.importer.min.js | 2 +- release/ui-grid.infinite-scroll.js | 2 +- release/ui-grid.infinite-scroll.min.js | 2 +- release/ui-grid.js | 16 +- release/ui-grid.min.css | 2 +- release/ui-grid.min.js | 4 +- release/ui-grid.move-columns.js | 2 +- release/ui-grid.move-columns.min.js | 2 +- release/ui-grid.pagination.js | 2 +- release/ui-grid.pagination.min.js | 2 +- release/ui-grid.pinning.js | 2 +- release/ui-grid.pinning.min.js | 2 +- release/ui-grid.resize-columns.js | 2 +- release/ui-grid.resize-columns.min.js | 2 +- release/ui-grid.row-edit.js | 2 +- release/ui-grid.row-edit.min.js | 2 +- release/ui-grid.saveState.js | 2 +- release/ui-grid.saveState.min.js | 2 +- release/ui-grid.selection.js | 2 +- release/ui-grid.selection.min.js | 2 +- release/ui-grid.tree-base.js | 2 +- release/ui-grid.tree-base.min.js | 2 +- release/ui-grid.tree-view.js | 2 +- release/ui-grid.tree-view.min.js | 2 +- release/ui-grid.validate.js | 2 +- release/ui-grid.validate.min.js | 2 +- 247 files changed, 67717 insertions(+), 139 deletions(-) create mode 100644 release/4.4.11/i18n/ui-grid.language.all.js create mode 100644 release/4.4.11/i18n/ui-grid.language.all.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ar.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ar.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.bg.js create mode 100644 release/4.4.11/i18n/ui-grid.language.bg.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.cs.js create mode 100644 release/4.4.11/i18n/ui-grid.language.cs.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.da.js create mode 100644 release/4.4.11/i18n/ui-grid.language.da.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.de.js create mode 100644 release/4.4.11/i18n/ui-grid.language.de.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.es.js create mode 100644 release/4.4.11/i18n/ui-grid.language.es.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.fa.js create mode 100644 release/4.4.11/i18n/ui-grid.language.fa.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.fi.js create mode 100644 release/4.4.11/i18n/ui-grid.language.fi.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.fr.js create mode 100644 release/4.4.11/i18n/ui-grid.language.fr.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.he.js create mode 100644 release/4.4.11/i18n/ui-grid.language.he.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.hy.js create mode 100644 release/4.4.11/i18n/ui-grid.language.hy.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.is.js create mode 100644 release/4.4.11/i18n/ui-grid.language.is.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.it.js create mode 100644 release/4.4.11/i18n/ui-grid.language.it.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ja.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ja.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ko.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ko.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.nl.js create mode 100644 release/4.4.11/i18n/ui-grid.language.nl.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.no.js create mode 100644 release/4.4.11/i18n/ui-grid.language.no.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.pl.js create mode 100644 release/4.4.11/i18n/ui-grid.language.pl.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.pt-br.js create mode 100644 release/4.4.11/i18n/ui-grid.language.pt-br.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.pt.js create mode 100644 release/4.4.11/i18n/ui-grid.language.pt.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ro.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ro.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ru.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ru.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.sk.js create mode 100644 release/4.4.11/i18n/ui-grid.language.sk.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.sv.js create mode 100644 release/4.4.11/i18n/ui-grid.language.sv.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ta.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ta.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.tr.js create mode 100644 release/4.4.11/i18n/ui-grid.language.tr.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ua.js create mode 100644 release/4.4.11/i18n/ui-grid.language.ua.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.zh-cn.js create mode 100644 release/4.4.11/i18n/ui-grid.language.zh-cn.min.js create mode 100644 release/4.4.11/i18n/ui-grid.language.zh-tw.js create mode 100644 release/4.4.11/i18n/ui-grid.language.zh-tw.min.js create mode 100644 release/4.4.11/less/animation.less create mode 100644 release/4.4.11/less/body.less create mode 100644 release/4.4.11/less/bootstrap/bootstrap.less create mode 100644 release/4.4.11/less/cell.less create mode 100644 release/4.4.11/less/cellnav/less/cellNav.less create mode 100644 release/4.4.11/less/edit/less/edit.less create mode 100644 release/4.4.11/less/elements.less create mode 100644 release/4.4.11/less/empty-base-layer/less/emptyBaseLayer.less create mode 100644 release/4.4.11/less/expandable/less/expandable.less create mode 100644 release/4.4.11/less/exporter/less/exporter.less create mode 100644 release/4.4.11/less/footer.less create mode 100644 release/4.4.11/less/grid.less create mode 100644 release/4.4.11/less/grouping/less/grouping.less create mode 100644 release/4.4.11/less/header.less create mode 100644 release/4.4.11/less/icons.less create mode 100644 release/4.4.11/less/importer/less/importer.less create mode 100644 release/4.4.11/less/main.less create mode 100644 release/4.4.11/less/menu.less create mode 100644 release/4.4.11/less/move-columns/less/colMovable.less create mode 100644 release/4.4.11/less/pagination/less/pagination.less create mode 100644 release/4.4.11/less/pinning/less/pinning.less create mode 100644 release/4.4.11/less/resize-columns/less/column-resizer.less create mode 100644 release/4.4.11/less/row-edit/less/rowEdit.less create mode 100644 release/4.4.11/less/rtl.less create mode 100644 release/4.4.11/less/selection/less/selection.less create mode 100644 release/4.4.11/less/sorting.less create mode 100644 release/4.4.11/less/tree-base/less/tree-base.less create mode 100644 release/4.4.11/less/tree-view/less/tree-view.less create mode 100644 release/4.4.11/less/validate/less/validate.less create mode 100644 release/4.4.11/less/variables.less create mode 100644 release/4.4.11/ui-grid.auto-resize.js create mode 100644 release/4.4.11/ui-grid.auto-resize.min.js create mode 100644 release/4.4.11/ui-grid.cellnav.js create mode 100644 release/4.4.11/ui-grid.cellnav.min.js create mode 100644 release/4.4.11/ui-grid.core.js create mode 100644 release/4.4.11/ui-grid.core.min.js create mode 100644 release/4.4.11/ui-grid.css create mode 100644 release/4.4.11/ui-grid.edit.js create mode 100644 release/4.4.11/ui-grid.edit.min.js create mode 100644 release/4.4.11/ui-grid.empty-base-layer.js create mode 100644 release/4.4.11/ui-grid.empty-base-layer.min.js create mode 100644 release/4.4.11/ui-grid.eot create mode 100644 release/4.4.11/ui-grid.expandable.js create mode 100644 release/4.4.11/ui-grid.expandable.min.js create mode 100644 release/4.4.11/ui-grid.exporter.js create mode 100644 release/4.4.11/ui-grid.exporter.min.js create mode 100644 release/4.4.11/ui-grid.grouping.js create mode 100644 release/4.4.11/ui-grid.grouping.min.js create mode 100644 release/4.4.11/ui-grid.importer.js create mode 100644 release/4.4.11/ui-grid.importer.min.js create mode 100644 release/4.4.11/ui-grid.infinite-scroll.js create mode 100644 release/4.4.11/ui-grid.infinite-scroll.min.js create mode 100644 release/4.4.11/ui-grid.js create mode 100644 release/4.4.11/ui-grid.min.css create mode 100644 release/4.4.11/ui-grid.min.js create mode 100644 release/4.4.11/ui-grid.move-columns.js create mode 100644 release/4.4.11/ui-grid.move-columns.min.js create mode 100644 release/4.4.11/ui-grid.pagination.js create mode 100644 release/4.4.11/ui-grid.pagination.min.js create mode 100644 release/4.4.11/ui-grid.pinning.js create mode 100644 release/4.4.11/ui-grid.pinning.min.js create mode 100644 release/4.4.11/ui-grid.resize-columns.js create mode 100644 release/4.4.11/ui-grid.resize-columns.min.js create mode 100644 release/4.4.11/ui-grid.row-edit.js create mode 100644 release/4.4.11/ui-grid.row-edit.min.js create mode 100644 release/4.4.11/ui-grid.saveState.js create mode 100644 release/4.4.11/ui-grid.saveState.min.js create mode 100644 release/4.4.11/ui-grid.selection.js create mode 100644 release/4.4.11/ui-grid.selection.min.js create mode 100644 release/4.4.11/ui-grid.svg create mode 100644 release/4.4.11/ui-grid.tree-base.js create mode 100644 release/4.4.11/ui-grid.tree-base.min.js create mode 100644 release/4.4.11/ui-grid.tree-view.js create mode 100644 release/4.4.11/ui-grid.tree-view.min.js create mode 100644 release/4.4.11/ui-grid.ttf create mode 100644 release/4.4.11/ui-grid.validate.js create mode 100644 release/4.4.11/ui-grid.validate.min.js create mode 100644 release/4.4.11/ui-grid.woff diff --git a/docs/index.html b/docs/index.html index f63a587c8..01fc8f81b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -46,11 +46,11 @@ addTag('script', {src: 'js/marked.js'}, sync); - addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular.js'}, sync); + addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular.js'}, sync); - addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular-touch.js'}, sync); + addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular-touch.js'}, sync); - addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular-animate.js'}, sync); + addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular-animate.js'}, sync); addTag('script', {src: 'grunt-scripts/csv.js'}, sync); @@ -65,9 +65,9 @@ addTag('script', {src: 'grunt-scripts/excel-builder.dist.js'}, sync); - addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular-animate.js'}, sync); + addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular-animate.js'}, sync); - addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular-aria.js'}, sync); + addTag('script', {src: '//ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular-aria.js'}, sync); addTag('script', {src: 'grunt-scripts/prettify.js'}, sync); diff --git a/docs/js/docs-setup.js b/docs/js/docs-setup.js index 1ad882b00..5aee5e60d 100644 --- a/docs/js/docs-setup.js +++ b/docs/js/docs-setup.js @@ -1711,7 +1711,7 @@ NG_DOCS={ "type": "overview", "moduleName": "Tutorial: 100 Prerequisites", "shortDescription": "Browsers", - "keywords": "_blank ability adequately base behaviour browsers cases compatibility control critical current decided desired functions href https ie9 labs limited list marginal note number organizations overview performance poor prerequisites recommend retain small specific supported target tested testing tutorial verify work" + "keywords": "_blank ability adequately base behaviour browsers cases compatibility control current desired functions href https ie9 labs limited list marginal note overview performance poor prerequisites recommend specific target tested testing tutorial verify work" }, { "section": "tutorial", @@ -2350,7 +2350,7 @@ NG_DOCS={ "type": "overview", "moduleName": "Tutorial: 499 FAQ Frequently Asked Questions", "shortDescription": "There are a number of common gotchas in using the grid, this FAQ aims to cover most of them in an easy to use format.", - "keywords": "$scope ability achieve actual add adding adequately aims allowing angular answer appropriately asked attribute automatically aware bad base basis behaviour body box browser browsers build cases cell cells celltemplate central change characters chinese chrome class column columns common compatibility compatible compliant content control counter cover create critical css current currently custom data decide decided definitions depends desired display displayed displayname div doesn don dynamically easy edge editable enabled evaluate evaluated example excel expect explicit external faq feature field filter filtered filters firefox firstly fit flag fonts foreach format forward frequently full functionality functions general generally generic gotchas grid gridoptions grids hasn height hidden high html5 http ie9 implements implies indexof installation installed intend internal internals javascript korean limited list ll longer marginal match mydata names ng-grid ng-show note number numbers organisations original overview per-column percentage performance pixels plunker poor prereqs priority properly question questions reasonably recommend refer remain render rendercontainers renders resize responsive retain row rowheight rows rowsprocessor runs safari secondly sequence sequential set setting short simple single small sorted sorts space specific stands style supported syntax taller testing text things thirdly tooltips tricky turned tutorial ui ui-grid ui-grid-cell-contents unique useless verifies verify versions virtualization visible visiblerowcache white-space width widths work wrap wraps" + "keywords": "$scope ability achieve actual add adding adequately aims allowing angular answer appropriately asked attribute automatically aware bad base basis behaviour body box browser browsers build cases cell cells celltemplate central change characters chinese chrome class column columns common compatibility compatible compliant content control counter cover create css current currently custom data decide definitions depends desired display displayed displayname div doesn don dynamically easy edge editable enabled evaluate evaluated example excel expect explicit external faq feature field filter filtered filters firefox firstly fit flag fonts foreach format forward frequently full functionality functions general generally generic gotchas grid gridoptions grids hasn height hidden high html5 http ie10 ie9 implements implies indexof installation installed intend internal internals javascript korean limited list ll longer marginal match mydata names ng-grid ng-show note number numbers original overview per-column percentage performance pixels plunker poor prereqs priority properly question questions reasonably recommend refer remain render rendercontainers renders resize responsive row rowheight rows rowsprocessor runs safari secondly sequence sequential set setting short simple single sorted sorts space specific stands style supported syntax taller testing text things thirdly tooltips tricky turned tutorial ui ui-grid ui-grid-cell-contents unique useless verifies verify versions virtualization visible visiblerowcache white-space width widths work wrap wraps" } ], "apis": { diff --git a/docs/partials/tutorial/100_preReqs.html b/docs/partials/tutorial/100_preReqs.html index 02f81d1c7..9086555c1 100644 --- a/docs/partials/tutorial/100_preReqs.html +++ b/docs/partials/tutorial/100_preReqs.html @@ -5,7 +5,7 @@

Browsers

Current list of tested browsers: Sauce Labs

    -
  • IE9+
  • +
  • IE10+
  • Chrome
  • Firefox
  • Safari 5+
  • @@ -18,10 +18,10 @@
  • 1.4.0+
  • 1.5.0+
  • 1.6.0+
  • +
  • 1.7.0+

Note that IE9 compatibility is marginal - the base functions all work but performance is poor in some cases, -and some behaviour is not as desired. We have limited ability to control some of this, but have decided to retain IE9 -in the supported list due to the small number of organizations for whom this is critical. If using on IE9 we +and some behaviour is not as desired. We have limited ability to control some of this. If using on IE9 we recommend testing your specific use cases to verify all your desired functions work adequately.

diff --git a/docs/partials/tutorial/499_FAQ.html b/docs/partials/tutorial/499_FAQ.html index 6ee41e088..9e11d2ba4 100644 --- a/docs/partials/tutorial/499_FAQ.html +++ b/docs/partials/tutorial/499_FAQ.html @@ -27,14 +27,13 @@

How can I sh which would be something like:

  cellTemplate: '<div class="ui-grid-cell-contents">{{grid.renderContainers.body.visibleRowCache.indexOf(row)}}</div>'
 

What browsers are supported by ui.grid

-

Our current testing verifies against IE9+, Edge, Chrome, Firefox, and Safari 7+. We expect that the functionality +

Our current testing verifies against IE10+, Edge, Chrome, Firefox, and Safari 8+. We expect that the functionality is compatible with any HTML5 compliant and Javascript enabled browser. Refer preReqs. Note that IE9 compatibility is marginal - the base functions all work but performance is poor in some cases, and some behaviour is not - as desired. We have limited ability to control some of this, but have decided to retain IE9 in the supported list due to - the small number of organisations for whom this is critical. If using on IE9 we recommend testing your specific use cases + as desired. We have limited ability to control some of this. If using on IE9 we recommend testing your specific use cases to verify all your desired functions work adequately.

What angular versions are supported by ui.grid

-

Our current testing uses angular 1.4 - 1.6. We intend to remain compatible with all forward versions of 1.6. +

Our current testing uses angular 1.4 - 1.7. We intend to remain compatible with all forward versions of 1.7. Refer preReqs

How can I wrap text in a cell?

Refer also http://stackoverflow.com/questions/29298968/increase-width-of-column-in-ui-grid

diff --git a/index.html b/index.html index 165c16e4f..b1085f6d1 100644 --- a/index.html +++ b/index.html @@ -76,11 +76,11 @@

Angular UI Grid

Code on Github - + - + - Download ( 4.4.10 ) + Download ( 4.4.11 ) @@ -182,8 +182,8 @@

Complex Example

- - + + + +
+
+
+ + + + + */ +angular.module('ui.grid') + +.directive('uiGridMenu', ['$compile', '$timeout', '$window', '$document', 'gridUtil', 'uiGridConstants', 'i18nService', +function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18nService) { + var uiGridMenu = { + priority: 0, + scope: { + // shown: '&', + menuItems: '=', + autoHide: '=?' + }, + require: '?^uiGrid', + templateUrl: 'ui-grid/uiGridMenu', + replace: false, + link: function ($scope, $elm, $attrs, uiGridCtrl) { + $scope.dynamicStyles = ''; + if (uiGridCtrl && uiGridCtrl.grid && uiGridCtrl.grid.options && uiGridCtrl.grid.options.gridMenuTemplate) { + var gridMenuTemplate = uiGridCtrl.grid.options.gridMenuTemplate; + gridUtil.getTemplate(gridMenuTemplate).then(function (contents) { + var template = angular.element(contents); + var newElm = $compile(template)($scope); + $elm.replaceWith(newElm); + }).catch(angular.noop); + } + + var setupHeightStyle = function(gridHeight) { + //menu appears under header row, so substract that height from it's total + // additional 20px for general padding + var gridMenuMaxHeight = gridHeight - uiGridCtrl.grid.headerHeight - 20; + $scope.dynamicStyles = [ + '.grid' + uiGridCtrl.grid.id + ' .ui-grid-menu-mid {', + 'max-height: ' + gridMenuMaxHeight + 'px;', + '}' + ].join(' '); + }; + + if (uiGridCtrl) { + setupHeightStyle(uiGridCtrl.grid.gridHeight); + uiGridCtrl.grid.api.core.on.gridDimensionChanged($scope, function(oldGridHeight, oldGridWidth, newGridHeight, newGridWidth) { + setupHeightStyle(newGridHeight); + }); + } + + $scope.i18n = { + close: i18nService.getSafeText('columnMenu.close') + }; + + // *** Show/Hide functions ****** + $scope.showMenu = function(event, args) { + if ( !$scope.shown ){ + + /* + * In order to animate cleanly we remove the ng-if, wait a digest cycle, then + * animate the removal of the ng-hide. We can't successfully (so far as I can tell) + * animate removal of the ng-if, as the menu items aren't there yet. And we don't want + * to rely on ng-show only, as that leaves elements in the DOM that are needlessly evaluated + * on scroll events. + * + * Note when testing animation that animations don't run on the tutorials. When debugging it looks + * like they do, but angular has a default $animate provider that is just a stub, and that's what's + * being called. ALso don't be fooled by the fact that your browser has actually loaded the + * angular-translate.js, it's not using it. You need to test animations in an external application. + */ + $scope.shown = true; + + // Must be a timeout in order to work properly in Firefox. Issue #6533 + $timeout(function() { + $scope.shownMid = true; + $scope.$emit('menu-shown'); + }); + } else if ( !$scope.shownMid ) { + // we're probably doing a hide then show, so we don't need to wait for ng-if + $scope.shownMid = true; + $scope.$emit('menu-shown'); + } + + var docEventType = 'click'; + if (args && args.originalEvent && args.originalEvent.type && args.originalEvent.type === 'touchstart') { + docEventType = args.originalEvent.type; + } + + // Turn off an existing document click handler + angular.element(document).off('click touchstart', applyHideMenu); + $elm.off('keyup', checkKeyUp); + $elm.off('keydown', checkKeyDown); + + // Turn on the document click handler, but in a timeout so it doesn't apply to THIS click if there is one + $timeout(function() { + angular.element(document).on(docEventType, applyHideMenu); + $elm.on('keyup', checkKeyUp); + $elm.on('keydown', checkKeyDown); + }); + }; + + + $scope.hideMenu = function(event) { + if ( $scope.shown ){ + /* + * In order to animate cleanly we animate the addition of ng-hide, then use a $timeout to + * set the ng-if (shown = false) after the animation runs. In theory we can cascade off the + * callback on the addClass method, but it is very unreliable with unit tests for no discernable reason. + * + * The user may have clicked on the menu again whilst + * we're waiting, so we check that the mid isn't shown before applying the ng-if. + */ + $scope.shownMid = false; + $timeout( function() { + if ( !$scope.shownMid ){ + $scope.shown = false; + $scope.$emit('menu-hidden'); + } + }, 40); + } + + angular.element(document).off('click touchstart', applyHideMenu); + $elm.off('keyup', checkKeyUp); + $elm.off('keydown', checkKeyDown); + }; + + $scope.$on('hide-menu', function (event, args) { + $scope.hideMenu(event, args); + }); + + $scope.$on('show-menu', function (event, args) { + $scope.showMenu(event, args); + }); + + + // *** Auto hide when click elsewhere ****** + var applyHideMenu = function(){ + if ($scope.shown) { + $scope.$apply(function () { + $scope.hideMenu(); + }); + } + }; + + // close menu on ESC and keep tab cyclical + var checkKeyUp = function(event) { + if (event.keyCode === 27) { + $scope.hideMenu(); + } + }; + + var checkKeyDown = function(event) { + var setFocus = function(elm) { + elm.focus(); + event.preventDefault(); + return false; + }; + if (event.keyCode === 9) { + var firstMenuItem, lastMenuItem; + var menuItemButtons = $elm[0].querySelectorAll('button:not(.ng-hide)'); + if (menuItemButtons.length > 0) { + firstMenuItem = menuItemButtons[0]; + lastMenuItem = menuItemButtons[menuItemButtons.length - 1]; + if (event.target === lastMenuItem && !event.shiftKey) { + setFocus(firstMenuItem); + } else if (event.target === firstMenuItem && event.shiftKey) { + setFocus(lastMenuItem); + } + } + } + }; + + if (typeof($scope.autoHide) === 'undefined' || $scope.autoHide === undefined) { + $scope.autoHide = true; + } + + if ($scope.autoHide) { + angular.element($window).on('resize', applyHideMenu); + } + + $scope.$on('$destroy', function unbindEvents() { + angular.element($window).off('resize', applyHideMenu); + angular.element(document).off('click touchstart', applyHideMenu); + $elm.off('keyup', checkKeyUp); + $elm.off('keydown', checkKeyDown); + }); + + if (uiGridCtrl) { + $scope.$on('$destroy', uiGridCtrl.grid.api.core.on.scrollBegin($scope, applyHideMenu )); + } + + $scope.$on('$destroy', $scope.$on(uiGridConstants.events.ITEM_DRAGGING, applyHideMenu )); + } + }; + + return uiGridMenu; +}]) + +.directive('uiGridMenuItem', ['gridUtil', '$compile', 'i18nService', function (gridUtil, $compile, i18nService) { + return { + priority: 0, + scope: { + name: '=', + active: '=', + action: '=', + icon: '=', + shown: '=', + context: '=', + templateUrl: '=', + leaveOpen: '=', + screenReaderOnly: '=' + }, + require: ['?^uiGrid'], + templateUrl: 'ui-grid/uiGridMenuItem', + replace: false, + compile: function() { + return { + pre: function ($scope, $elm) { + if ($scope.templateUrl) { + gridUtil.getTemplate($scope.templateUrl) + .then(function (contents) { + var template = angular.element(contents); + + var newElm = $compile(template)($scope); + $elm.replaceWith(newElm); + }).catch(angular.noop); + } + }, + post: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + + // TODO(c0bra): validate that shown and active are functions if they're defined. An exception is already thrown above this though + // if (typeof($scope.shown) !== 'undefined' && $scope.shown && typeof($scope.shown) !== 'function') { + // throw new TypeError("$scope.shown is defined but not a function"); + // } + if (typeof($scope.shown) === 'undefined' || $scope.shown === null) { + $scope.shown = function() { return true; }; + } + + $scope.itemShown = function () { + var context = {}; + if ($scope.context) { + context.context = $scope.context; + } + + if (typeof(uiGridCtrl) !== 'undefined' && uiGridCtrl) { + context.grid = uiGridCtrl.grid; + } + + return $scope.shown.call(context); + }; + + $scope.itemAction = function($event,title) { + $event.stopPropagation(); + + if (typeof($scope.action) === 'function') { + var context = {}; + + if ($scope.context) { + context.context = $scope.context; + } + + // Add the grid to the function call context if the uiGrid controller is present + if (typeof(uiGridCtrl) !== 'undefined' && uiGridCtrl) { + context.grid = uiGridCtrl.grid; + } + + $scope.action.call(context, $event, title); + + if ( !$scope.leaveOpen ){ + $scope.$emit('hide-menu'); + } else { + // Maintain focus on the selected item + var correctParent = $event.target.parentElement; + + // nodeName of 'I' means target is i element, need the next parent + if (angular.element($event.target)[0].nodeName === 'I') { + correctParent = correctParent.parentElement; + } + + gridUtil.focus.bySelector(correctParent, 'button[type=button]', true); + } + } + }; + + $scope.label = function(){ + var toBeDisplayed = $scope.name; + + if (typeof($scope.name) === 'function'){ + toBeDisplayed = $scope.name.call(); + } + + return toBeDisplayed; + }; + + $scope.i18n = i18nService.get(); + } + }; + } + }; +}]); + +})(); + +(function(){ + 'use strict'; + /** + * @ngdoc overview + * @name ui.grid.directive:uiGridOneBind + * @summary A group of directives that provide a one time bind to a dom element. + * @description A group of directives that provide a one time bind to a dom element. + * As one time bindings are not supported in Angular 1.2.* this directive provdes this capability. + * This is done to reduce the number of watchers on the dom. + *
+ *

Short Example ({@link ui.grid.directive:uiGridOneBindSrc ui-grid-one-bind-src})

+ *
+        
+ +
+
+ * Will become: + *
+       
+ +
+
+
+

Short Example ({@link ui.grid.directive:uiGridOneBindText ui-grid-one-bind-text})

+ *
+        
+
+ * Will become: + *
+   
Add this text
+
+
+ * Note: This behavior is slightly different for the {@link ui.grid.directive:uiGridOneBindIdGrid uiGridOneBindIdGrid} + * and {@link ui.grid.directive:uiGridOneBindAriaLabelledbyGrid uiGridOneBindAriaLabelledbyGrid} directives. + * + */ + //https://github.com/joshkurz/Black-Belt-AngularJS-Directives/blob/master/directives/Optimization/oneBind.js + var oneBinders = angular.module('ui.grid'); + angular.forEach([ + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindSrc + * @memberof ui.grid.directive:uiGridOneBind + * @element img + * @restrict A + * @param {String} uiGridOneBindSrc The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the src dom tag. + * + */ + {tag: 'Src', method: 'attr'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindText + * @element div + * @restrict A + * @param {String} uiGridOneBindText The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the text dom tag. + */ + {tag: 'Text', method: 'text'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindHref + * @element div + * @restrict A + * @param {String} uiGridOneBindHref The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the href dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + */ + {tag: 'Href', method: 'attr'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindClass + * @element div + * @restrict A + * @param {String} uiGridOneBindClass The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @param {Object} uiGridOneBindClass The object that you want to bind. At least one of the values in the object must be something other than null or undefined for the watcher to be removed. + * this is to prevent the watcher from being removed before the scope is initialized. + * @param {Array} uiGridOneBindClass An array of classes to bind to this element. + * @description One time binding for the class dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + */ + {tag: 'Class', method: 'addClass'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindHtml + * @element div + * @restrict A + * @param {String} uiGridOneBindHtml The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the html method on a dom element. For more information see {@link ui.grid.directive:uiGridOneBind}. + */ + {tag: 'Html', method: 'html'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindAlt + * @element div + * @restrict A + * @param {String} uiGridOneBindAlt The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the alt dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + */ + {tag: 'Alt', method: 'attr'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindStyle + * @element div + * @restrict A + * @param {String} uiGridOneBindStyle The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the style dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + */ + {tag: 'Style', method: 'css'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindValue + * @element div + * @restrict A + * @param {String} uiGridOneBindValue The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the value dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + */ + {tag: 'Value', method: 'attr'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindId + * @element div + * @restrict A + * @param {String} uiGridOneBindId The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the value dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + */ + {tag: 'Id', method: 'attr'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindIdGrid + * @element div + * @restrict A + * @param {String} uiGridOneBindIdGrid The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the id dom tag. + *

Important Note!

+ * If the id tag passed as a parameter does not contain the grid id as a substring + * then the directive will search the scope and the parent controller (if it is a uiGridController) for the grid.id value. + * If this value is found then it is appended to the begining of the id tag. If the grid is not found then the directive throws an error. + * This is done in order to ensure uniqueness of id tags across the grid. + * This is to prevent two grids in the same document having duplicate id tags. + */ + {tag: 'Id', directiveName:'IdGrid', method: 'attr', appendGridId: true}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindTitle + * @element div + * @restrict A + * @param {String} uiGridOneBindTitle The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the title dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + */ + {tag: 'Title', method: 'attr'}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindAriaLabel + * @element div + * @restrict A + * @param {String} uiGridOneBindAriaLabel The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the aria-label dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + *
+ *
+            
+
+ * Will become: + *
+            
+
+ */ + {tag: 'Label', method: 'attr', aria:true}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindAriaLabelledby + * @element div + * @restrict A + * @param {String} uiGridOneBindAriaLabelledby The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + *
+ *
+            
+
+ * Will become: + *
+            
+
+ */ + {tag: 'Labelledby', method: 'attr', aria:true}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindAriaLabelledbyGrid + * @element div + * @restrict A + * @param {String} uiGridOneBindAriaLabelledbyGrid The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + * Works somewhat like {@link ui.grid.directive:uiGridOneBindIdGrid} however this one supports a list of ids (seperated by a space) and will dynamically add the + * grid id to each one. + *
+ *
+            
+
+ * Will become ([grid.id] will be replaced by the actual grid id): + *
+            
+
+ */ + {tag: 'Labelledby', directiveName:'LabelledbyGrid', appendGridId:true, method: 'attr', aria:true}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindAriaDescribedby + * @element ANY + * @restrict A + * @param {String} uiGridOneBindAriaDescribedby The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the aria-describedby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + *
+ *
+            
+
+ * Will become: + *
+            
+
+ */ + {tag: 'Describedby', method: 'attr', aria:true}, + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridOneBindAriaDescribedbyGrid + * @element ANY + * @restrict A + * @param {String} uiGridOneBindAriaDescribedbyGrid The angular string you want to bind. Does not support interpolation. Don't use {{scopeElt}} instead use scopeElt. + * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}. + * Works somewhat like {@link ui.grid.directive:uiGridOneBindIdGrid} however this one supports a list of ids (seperated by a space) and will dynamically add the + * grid id to each one. + *
+ *
+            
+
+ * Will become ([grid.id] will be replaced by the actual grid id): + *
+            
+
+ */ + {tag: 'Describedby', directiveName:'DescribedbyGrid', appendGridId:true, method: 'attr', aria:true}], + function(v){ + + var baseDirectiveName = 'uiGridOneBind'; + //If it is an aria tag then append the aria label seperately + //This is done because the aria tags are formatted aria-* and the directive name can't have a '-' character in it. + //If the diretiveName has to be overridden then it does so here. This is because the tag being modified and the directive sometimes don't match up. + var directiveName = (v.aria ? baseDirectiveName + 'Aria' : baseDirectiveName) + (v.directiveName ? v.directiveName : v.tag); + oneBinders.directive(directiveName, ['gridUtil', function(gridUtil){ + return { + restrict: 'A', + require: ['?uiGrid','?^uiGrid'], + link: function(scope, iElement, iAttrs, controllers){ + /* Appends the grid id to the beginnig of the value. */ + var appendGridId = function(val){ + var grid; //Get an instance of the grid if its available + //If its available in the scope then we don't need to try to find it elsewhere + if (scope.grid) { + grid = scope.grid; + } + //Another possible location to try to find the grid + else if (scope.col && scope.col.grid){ + grid = scope.col.grid; + } + //Last ditch effort: Search through the provided controllers. + else if (!controllers.some( //Go through the controllers till one has the element we need + function(controller){ + if (controller && controller.grid) { + grid = controller.grid; + return true; //We've found the grid + } + })){ + //We tried our best to find it for you + gridUtil.logError("["+directiveName+"] A valid grid could not be found to bind id. Are you using this directive " + + "within the correct scope? Trying to generate id: [gridID]-" + val); + throw new Error("No valid grid could be found"); + } + + if (grid){ + var idRegex = new RegExp(grid.id.toString()); + //If the grid id hasn't been appended already in the template declaration + if (!idRegex.test(val)){ + val = grid.id.toString() + '-' + val; + } + } + return val; + }; + + // The watch returns a function to remove itself. + var rmWatcher = scope.$watch(iAttrs[directiveName], function(newV){ + if (newV){ + //If we are trying to add an id element then we also apply the grid id if it isn't already there + if (v.appendGridId) { + var newIdString = null; + //Append the id to all of the new ids. + angular.forEach( newV.split(' '), function(s){ + newIdString = (newIdString ? (newIdString + ' ') : '') + appendGridId(s); + }); + newV = newIdString; + } + + // Append this newValue to the dom element. + switch (v.method) { + case 'attr': //The attr method takes two paraams the tag and the value + if (v.aria) { + //If it is an aria element then append the aria prefix + iElement[v.method]('aria-' + v.tag.toLowerCase(),newV); + } else { + iElement[v.method](v.tag.toLowerCase(),newV); + } + break; + case 'addClass': + //Pulled from https://github.com/Pasvaz/bindonce/blob/master/bindonce.js + if (angular.isObject(newV) && !angular.isArray(newV)) { + var results = []; + var nonNullFound = false; //We don't want to remove the binding unless the key is actually defined + angular.forEach(newV, function (value, index) { + if (value !== null && typeof(value) !== "undefined"){ + nonNullFound = true; //A non null value for a key was found so the object must have been initialized + if (value) {results.push(index);} + } + }); + //A non null value for a key wasn't found so assume that the scope values haven't been fully initialized + if (!nonNullFound){ + return; // If not initialized then the watcher should not be removed yet. + } + newV = results; + } + + if (newV) { + iElement.addClass(angular.isArray(newV) ? newV.join(' ') : newV); + } else { + return; + } + break; + default: + iElement[v.method](newV); + break; + } + + //Removes the watcher on itself after the bind + rmWatcher(); + } + // True ensures that equality is determined using angular.equals instead of === + }, true); //End rm watchers + } //End compile function + }; //End directive return + } // End directive function + ]); //End directive + }); // End angular foreach +})(); + +(function () { + 'use strict'; + + var module = angular.module('ui.grid'); + + module.directive('uiGridRenderContainer', ['$timeout', '$document', 'uiGridConstants', 'gridUtil', 'ScrollEvent', + function($timeout, $document, uiGridConstants, gridUtil, ScrollEvent) { + return { + replace: true, + transclude: true, + templateUrl: 'ui-grid/uiGridRenderContainer', + require: ['^uiGrid', 'uiGridRenderContainer'], + scope: { + containerId: '=', + rowContainerName: '=', + colContainerName: '=', + bindScrollHorizontal: '=', + bindScrollVertical: '=', + enableVerticalScrollbar: '=', + enableHorizontalScrollbar: '=' + }, + controller: 'uiGridRenderContainer as RenderContainer', + compile: function () { + return { + pre: function prelink($scope, $elm, $attrs, controllers) { + + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + var grid = $scope.grid = uiGridCtrl.grid; + + // Verify that the render container for this element exists + if (!$scope.rowContainerName) { + throw new Error("No row render container name specified"); + } + if (!$scope.colContainerName) { + throw new Error("No column render container name specified"); + } + + if (!grid.renderContainers[$scope.rowContainerName]) { + throw new Error("Row render container '" + $scope.rowContainerName + "' is not registered."); + } + if (!grid.renderContainers[$scope.colContainerName]) { + throw new Error("Column render container '" + $scope.colContainerName + "' is not registered."); + } + + var rowContainer = $scope.rowContainer = grid.renderContainers[$scope.rowContainerName]; + var colContainer = $scope.colContainer = grid.renderContainers[$scope.colContainerName]; + + containerCtrl.containerId = $scope.containerId; + containerCtrl.rowContainer = rowContainer; + containerCtrl.colContainer = colContainer; + }, + post: function postlink($scope, $elm, $attrs, controllers) { + + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + + var grid = uiGridCtrl.grid; + var rowContainer = containerCtrl.rowContainer; + var colContainer = containerCtrl.colContainer; + var scrollTop = null; + var scrollLeft = null; + + + var renderContainer = grid.renderContainers[$scope.containerId]; + + // Put the container name on this element as a class + $elm.addClass('ui-grid-render-container-' + $scope.containerId); + + // Scroll the render container viewport when the mousewheel is used + gridUtil.on.mousewheel($elm, function (event) { + var scrollEvent = new ScrollEvent(grid, rowContainer, colContainer, ScrollEvent.Sources.RenderContainerMouseWheel); + if (event.deltaY !== 0) { + var scrollYAmount = event.deltaY * -1 * event.deltaFactor; + + scrollTop = containerCtrl.viewport[0].scrollTop; + + // Get the scroll percentage + scrollEvent.verticalScrollLength = rowContainer.getVerticalScrollLength(); + var scrollYPercentage = (scrollTop + scrollYAmount) / scrollEvent.verticalScrollLength; + + // If we should be scrolled 100%, make sure the scrollTop matches the maximum scroll length + // Viewports that have "overflow: hidden" don't let the mousewheel scroll all the way to the bottom without this check + if (scrollYPercentage >= 1 && scrollTop < scrollEvent.verticalScrollLength) { + containerCtrl.viewport[0].scrollTop = scrollEvent.verticalScrollLength; + } + + // Keep scrollPercentage within the range 0-1. + if (scrollYPercentage < 0) { scrollYPercentage = 0; } + else if (scrollYPercentage > 1) { scrollYPercentage = 1; } + + scrollEvent.y = { percentage: scrollYPercentage, pixels: scrollYAmount }; + } + if (event.deltaX !== 0) { + var scrollXAmount = event.deltaX * event.deltaFactor; + + // Get the scroll percentage + scrollLeft = gridUtil.normalizeScrollLeft(containerCtrl.viewport, grid); + scrollEvent.horizontalScrollLength = (colContainer.getCanvasWidth() - colContainer.getViewportWidth()); + var scrollXPercentage = (scrollLeft + scrollXAmount) / scrollEvent.horizontalScrollLength; + + // Keep scrollPercentage within the range 0-1. + if (scrollXPercentage < 0) { scrollXPercentage = 0; } + else if (scrollXPercentage > 1) { scrollXPercentage = 1; } + + scrollEvent.x = { percentage: scrollXPercentage, pixels: scrollXAmount }; + } + + // Let the parent container scroll if the grid is already at the top/bottom + if ((event.deltaY !== 0 && (scrollEvent.atTop(scrollTop) || scrollEvent.atBottom(scrollTop))) || + (event.deltaX !== 0 && (scrollEvent.atLeft(scrollLeft) || scrollEvent.atRight(scrollLeft)))) { + //parent controller scrolls + } + else { + event.preventDefault(); + event.stopPropagation(); + scrollEvent.fireThrottledScrollingEvent('', scrollEvent); + } + + }); + + $elm.bind('$destroy', function() { + $elm.unbind('keydown'); + + ['touchstart', 'touchmove', 'touchend','keydown', 'wheel', 'mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'].forEach(function (eventName) { + $elm.unbind(eventName); + }); + }); + + // TODO(c0bra): Handle resizing the inner canvas based on the number of elements + function update() { + var ret = ''; + + var canvasWidth = colContainer.canvasWidth; + var viewportWidth = colContainer.getViewportWidth(); + + var canvasHeight = rowContainer.getCanvasHeight(); + + //add additional height for scrollbar on left and right container + //if ($scope.containerId !== 'body') { + // canvasHeight -= grid.scrollbarHeight; + //} + + var viewportHeight = rowContainer.getViewportHeight(); + //shorten the height to make room for a scrollbar placeholder + if (colContainer.needsHScrollbarPlaceholder()) { + viewportHeight -= grid.scrollbarHeight; + } + + var headerViewportWidth, + footerViewportWidth; + headerViewportWidth = footerViewportWidth = colContainer.getHeaderViewportWidth(); + + // Set canvas dimensions + ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-canvas { width: ' + canvasWidth + 'px; height: ' + canvasHeight + 'px; }'; + + ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { width: ' + (canvasWidth + grid.scrollbarWidth) + 'px; }'; + + if (renderContainer.explicitHeaderCanvasHeight) { + // get height from body container + var reHCHeight = document.querySelector( + '.grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-body .ui-grid-header-canvas'); + + if (reHCHeight) { + renderContainer.explicitHeaderCanvasHeight = reHCHeight.offsetHeight; + } + + ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + + ' .ui-grid-header-canvas { height: ' + renderContainer.explicitHeaderCanvasHeight + 'px; }'; + } + else { + ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { height: inherit; }'; + } + + ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + + ' .ui-grid-viewport { width: ' + viewportWidth + 'px; height: ' + viewportHeight + 'px; }'; + ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + + ' .ui-grid-header-viewport { width: ' + headerViewportWidth + 'px; }'; + + ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + + ' .ui-grid-footer-canvas { width: ' + (canvasWidth + grid.scrollbarWidth) + 'px; }'; + ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + + ' .ui-grid-footer-viewport { width: ' + footerViewportWidth + 'px; }'; + + return ret; + } + + uiGridCtrl.grid.registerStyleComputation({ + priority: 6, + func: update + }); + } + }; + } + }; + + }]); + + module.controller('uiGridRenderContainer', ['$scope', 'gridUtil', function ($scope, gridUtil) { + + }]); + +})(); + +(function(){ + 'use strict'; + + angular.module('ui.grid').directive('uiGridRow', ['gridUtil', function(gridUtil) { + return { + replace: true, + // priority: 2001, + // templateUrl: 'ui-grid/ui-grid-row', + require: ['^uiGrid', '^uiGridRenderContainer'], + scope: { + row: '=uiGridRow', + //rowRenderIndex is added to scope to give the true visual index of the row to any directives that need it + rowRenderIndex: '=' + }, + compile: function() { + return { + pre: function($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + + var grid = uiGridCtrl.grid; + + $scope.grid = uiGridCtrl.grid; + $scope.colContainer = containerCtrl.colContainer; + + // Function for attaching the template to this scope + var clonedElement, cloneScope; + function compileTemplate() { + $scope.row.getRowTemplateFn.then(function (compiledElementFn) { + // var compiledElementFn = $scope.row.compiledElementFn; + + // Create a new scope for the contents of this row, so we can destroy it later if need be + var newScope = $scope.$new(); + + compiledElementFn(newScope, function (newElm, scope) { + // If we already have a cloned element, we need to remove it and destroy its scope + if (clonedElement) { + clonedElement.remove(); + cloneScope.$destroy(); + } + + // Empty the row and append the new element + $elm.empty().append(newElm); + + // Save the new cloned element and scope + clonedElement = newElm; + cloneScope = newScope; + }); + }).catch(angular.noop); + } + + // Initially attach the compiled template to this scope + compileTemplate(); + + // If the row's compiled element function changes, we need to replace this element's contents with the new compiled template + $scope.$watch('row.getRowTemplateFn', function (newFunc, oldFunc) { + if (newFunc !== oldFunc) { + compileTemplate(); + } + }); + }, + post: function($scope, $elm, $attrs, controllers) { + + } + }; + } + }; + }]); + +})(); + +(function(){ +// 'use strict'; + + /** + * @ngdoc directive + * @name ui.grid.directive:uiGridStyle + * @element style + * @restrict A + * + * @description + * Allows us to interpolate expressions in ` + I am in a box. + + + + it('should apply the right class to the element', function () { + element(by.css('.blah')).getCssValue('border-top-width') + .then(function(c) { + expect(c).toContain('1px'); + }); + }); + + + */ + + + angular.module('ui.grid').directive('uiGridStyle', ['gridUtil', '$interpolate', function(gridUtil, $interpolate) { + return { + // restrict: 'A', + // priority: 1000, + // require: '?^uiGrid', + link: function($scope, $elm, $attrs, uiGridCtrl) { + // gridUtil.logDebug('ui-grid-style link'); + // if (uiGridCtrl === undefined) { + // gridUtil.logWarn('[ui-grid-style link] uiGridCtrl is undefined!'); + // } + + var interpolateFn = $interpolate($elm.text(), true); + + if (interpolateFn) { + $scope.$watch(interpolateFn, function(value) { + $elm.text(value); + }); + } + + // uiGridCtrl.recalcRowStyles = function() { + // var offset = (scope.options.offsetTop || 0) - (scope.options.excessRows * scope.options.rowHeight); + // var rowHeight = scope.options.rowHeight; + + // var ret = ''; + // var rowStyleCount = uiGridCtrl.minRowsToRender() + (scope.options.excessRows * 2); + // for (var i = 1; i <= rowStyleCount; i++) { + // ret = ret + ' .grid' + scope.gridId + ' .ui-grid-row:nth-child(' + i + ') { top: ' + offset + 'px; }'; + // offset = offset + rowHeight; + // } + + // scope.rowStyles = ret; + // }; + + // uiGridCtrl.styleComputions.push(uiGridCtrl.recalcRowStyles); + + } + }; + }]); + +})(); + +(function(){ + 'use strict'; + + angular.module('ui.grid').directive('uiGridViewport', ['gridUtil','ScrollEvent','uiGridConstants', '$log', + function(gridUtil, ScrollEvent, uiGridConstants, $log) { + return { + replace: true, + scope: {}, + controllerAs: 'Viewport', + templateUrl: 'ui-grid/uiGridViewport', + require: ['^uiGrid', '^uiGridRenderContainer'], + link: function($scope, $elm, $attrs, controllers) { + // gridUtil.logDebug('viewport post-link'); + + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + + $scope.containerCtrl = containerCtrl; + + var rowContainer = containerCtrl.rowContainer; + var colContainer = containerCtrl.colContainer; + + var grid = uiGridCtrl.grid; + + $scope.grid = uiGridCtrl.grid; + + // Put the containers in scope so we can get rows and columns from them + $scope.rowContainer = containerCtrl.rowContainer; + $scope.colContainer = containerCtrl.colContainer; + + // Register this viewport with its container + containerCtrl.viewport = $elm; + + /** + * @ngdoc function + * @name customScroller + * @methodOf ui.grid.class:GridOptions + * @description (optional) uiGridViewport.on('scroll', scrollHandler) by default. + * A function that allows you to provide your own scroller function. It is particularly helpful if you want to use third party scrollers + * as this allows you to do that. + * + * + *
Example
+ *
+           *   $scope.gridOptions = {
+           *       customScroller: function myScrolling(uiGridViewport, scrollHandler) {
+           *           uiGridViewport.on('scroll', function myScrollingOverride(event) {
+           *               // Do something here
+           *
+           *               scrollHandler(event);
+           *           });
+           *       }
+           *   };
+           * 
+ * @param {object} uiGridViewport Element being scrolled. (this gets passed in by the grid). + * @param {function} scrollHandler Function that needs to be called when scrolling happens. (this gets passed in by the grid). + */ + if (grid && grid.options && grid.options.customScroller) { + grid.options.customScroller($elm, scrollHandler); + } else { + $elm.on('scroll', scrollHandler); + } + + var ignoreScroll = false; + + function scrollHandler(evt) { + //Leaving in this commented code in case it can someday be used + //It does improve performance, but because the horizontal scroll is normalized, + // using this code will lead to the column header getting slightly out of line with columns + // + //if (ignoreScroll && (grid.isScrollingHorizontally || grid.isScrollingHorizontally)) { + // //don't ask for scrollTop if we just set it + // ignoreScroll = false; + // return; + //} + //ignoreScroll = true; + + var newScrollTop = $elm[0].scrollTop; + var newScrollLeft = gridUtil.normalizeScrollLeft($elm, grid); + + var vertScrollPercentage = rowContainer.scrollVertical(newScrollTop); + var horizScrollPercentage = colContainer.scrollHorizontal(newScrollLeft); + + var scrollEvent = new ScrollEvent(grid, rowContainer, colContainer, ScrollEvent.Sources.ViewPortScroll); + scrollEvent.newScrollLeft = newScrollLeft; + scrollEvent.newScrollTop = newScrollTop; + if ( horizScrollPercentage > -1 ){ + scrollEvent.x = { percentage: horizScrollPercentage }; + } + + if ( vertScrollPercentage > -1 ){ + scrollEvent.y = { percentage: vertScrollPercentage }; + } + + grid.scrollContainers($scope.$parent.containerId, scrollEvent); + } + + if ($scope.$parent.bindScrollVertical) { + grid.addVerticalScrollSync($scope.$parent.containerId, syncVerticalScroll); + } + + if ($scope.$parent.bindScrollHorizontal) { + grid.addHorizontalScrollSync($scope.$parent.containerId, syncHorizontalScroll); + grid.addHorizontalScrollSync($scope.$parent.containerId + 'header', syncHorizontalHeader); + grid.addHorizontalScrollSync($scope.$parent.containerId + 'footer', syncHorizontalFooter); + } + + function syncVerticalScroll(scrollEvent){ + containerCtrl.prevScrollArgs = scrollEvent; + var newScrollTop = scrollEvent.getNewScrollTop(rowContainer,containerCtrl.viewport); + $elm[0].scrollTop = newScrollTop; + + } + + function syncHorizontalScroll(scrollEvent){ + containerCtrl.prevScrollArgs = scrollEvent; + var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport); + $elm[0].scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid); + } + + function syncHorizontalHeader(scrollEvent){ + var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport); + if (containerCtrl.headerViewport) { + containerCtrl.headerViewport.scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid); + } + } + + function syncHorizontalFooter(scrollEvent){ + var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport); + if (containerCtrl.footerViewport) { + containerCtrl.footerViewport.scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid); + } + } + + $scope.$on('$destroy', function unbindEvents() { + $elm.off(); + }); + }, + controller: ['$scope', function ($scope) { + this.rowStyle = function (index) { + var rowContainer = $scope.rowContainer; + var colContainer = $scope.colContainer; + + var styles = {}; + + if (rowContainer.currentTopRow !== 0){ + //top offset based on hidden rows count + var translateY = "translateY("+ (rowContainer.currentTopRow * rowContainer.grid.options.rowHeight) +"px)"; + styles['transform'] = translateY; + styles['-webkit-transform'] = translateY; + styles['-ms-transform'] = translateY; + } + + if (colContainer.currentFirstColumn !== 0) { + if (colContainer.grid.isRTL()) { + styles['margin-right'] = colContainer.columnOffset + 'px'; + } + else { + styles['margin-left'] = colContainer.columnOffset + 'px'; + } + } + + return styles; + }; + }] + }; + } + ]); + +})(); + +(function() { + +angular.module('ui.grid') +.directive('uiGridVisible', function uiGridVisibleAction() { + return function ($scope, $elm, $attr) { + $scope.$watch($attr.uiGridVisible, function (visible) { + // $elm.css('visibility', visible ? 'visible' : 'hidden'); + $elm[visible ? 'removeClass' : 'addClass']('ui-grid-invisible'); + }); + }; +}); + +})(); +(function () { + 'use strict'; + + angular.module('ui.grid').controller('uiGridController', ['$scope', '$element', '$attrs', 'gridUtil', '$q', 'uiGridConstants', + 'gridClassFactory', '$parse', '$compile', + function ($scope, $elm, $attrs, gridUtil, $q, uiGridConstants, + gridClassFactory, $parse, $compile) { + // gridUtil.logDebug('ui-grid controller'); + var self = this; + var deregFunctions = []; + + self.grid = gridClassFactory.createGrid($scope.uiGrid); + + //assign $scope.$parent if appScope not already assigned + self.grid.appScope = self.grid.appScope || $scope.$parent; + + $elm.addClass('grid' + self.grid.id); + self.grid.rtl = gridUtil.getStyles($elm[0])['direction'] === 'rtl'; + + + // angular.extend(self.grid.options, ); + + //all properties of grid are available on scope + $scope.grid = self.grid; + + if ($attrs.uiGridColumns) { + deregFunctions.push( $attrs.$observe('uiGridColumns', function(value) { + self.grid.options.columnDefs = angular.isString(value) ? angular.fromJson(value) : value; + self.grid.buildColumns() + .then(function(){ + self.grid.preCompileCellTemplates(); + + self.grid.refreshCanvas(true); + }).catch(angular.noop); + }) ); + } + + // prevents an error from being thrown when the array is not defined yet and fastWatch is on + function getSize(array) { + return array ? array.length : 0; + } + + // if fastWatch is set we watch only the length and the reference, not every individual object + if (self.grid.options.fastWatch) { + self.uiGrid = $scope.uiGrid; + if (angular.isString($scope.uiGrid.data)) { + deregFunctions.push( $scope.$parent.$watch($scope.uiGrid.data, dataWatchFunction) ); + deregFunctions.push( $scope.$parent.$watch(function() { + if ( self.grid.appScope[$scope.uiGrid.data] ){ + return self.grid.appScope[$scope.uiGrid.data].length; + } else { + return undefined; + } + }, dataWatchFunction) ); + } else { + deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.data; }, dataWatchFunction) ); + deregFunctions.push( $scope.$parent.$watch(function() { return getSize($scope.uiGrid.data); }, function(){ dataWatchFunction($scope.uiGrid.data); }) ); + } + deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.columnDefs; }, columnDefsWatchFunction) ); + deregFunctions.push( $scope.$parent.$watch(function() { return getSize($scope.uiGrid.columnDefs); }, function(){ columnDefsWatchFunction($scope.uiGrid.columnDefs); }) ); + } else { + if (angular.isString($scope.uiGrid.data)) { + deregFunctions.push( $scope.$parent.$watchCollection($scope.uiGrid.data, dataWatchFunction) ); + } else { + deregFunctions.push( $scope.$parent.$watchCollection(function() { return $scope.uiGrid.data; }, dataWatchFunction) ); + } + deregFunctions.push( $scope.$parent.$watchCollection(function() { return $scope.uiGrid.columnDefs; }, columnDefsWatchFunction) ); + } + + + function columnDefsWatchFunction(n, o) { + if (n && n !== o) { + self.grid.options.columnDefs = $scope.uiGrid.columnDefs; + self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.COLUMN, { + orderByColumnDefs: true, + preCompileCellTemplates: true + }); + } + } + + var mostRecentData; + + function dataWatchFunction(newData) { + // gridUtil.logDebug('dataWatch fired'); + var promises = []; + + if ( self.grid.options.fastWatch ) { + if (angular.isString($scope.uiGrid.data)) { + newData = self.grid.appScope.$eval($scope.uiGrid.data); + } else { + newData = $scope.uiGrid.data; + } + } + + mostRecentData = newData; + + if (newData) { + // columns length is greater than the number of row header columns, which don't count because they're created automatically + var hasColumns = self.grid.columns.length > (self.grid.rowHeaderColumns ? self.grid.rowHeaderColumns.length : 0); + + if ( + // If we have no columns + !hasColumns && + // ... and we don't have a ui-grid-columns attribute, which would define columns for us + !$attrs.uiGridColumns && + // ... and we have no pre-defined columns + self.grid.options.columnDefs.length === 0 && + // ... but we DO have data + newData.length > 0 + ) { + // ... then build the column definitions from the data that we have + self.grid.buildColumnDefsFromData(newData); + } + + // If we haven't built columns before and either have some columns defined or some data defined + if (!hasColumns && (self.grid.options.columnDefs.length > 0 || newData.length > 0)) { + // Build the column set, then pre-compile the column cell templates + promises.push(self.grid.buildColumns() + .then(function() { + self.grid.preCompileCellTemplates(); + }).catch(angular.noop)); + } + + $q.all(promises).then(function() { + // use most recent data, rather than the potentially outdated data passed into watcher handler + self.grid.modifyRows(mostRecentData) + .then(function () { + // if (self.viewport) { + self.grid.redrawInPlace(true); + // } + + $scope.$evalAsync(function() { + self.grid.refreshCanvas(true); + self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.ROW); + }); + }).catch(angular.noop); + }).catch(angular.noop); + } + } + + var styleWatchDereg = $scope.$watch(function () { return self.grid.styleComputations; }, function() { + self.grid.refreshCanvas(true); + }); + + $scope.$on('$destroy', function() { + deregFunctions.forEach( function( deregFn ){ deregFn(); }); + styleWatchDereg(); + }); + + self.fireEvent = function(eventName, args) { + args = args || {}; + + // Add the grid to the event arguments if it's not there + if (angular.isUndefined(args.grid)) { + args.grid = self.grid; + } + + $scope.$broadcast(eventName, args); + }; + + self.innerCompile = function innerCompile(elm) { + $compile(elm)($scope); + }; + }]); + +/** + * @ngdoc directive + * @name ui.grid.directive:uiGrid + * @element div + * @restrict EA + * @param {Object} uiGrid Options for the grid to use + * + * @description Create a very basic grid. + * + * @example + + + var app = angular.module('app', ['ui.grid']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + }]); + + +
+
+
+
+
+ */ +angular.module('ui.grid').directive('uiGrid', uiGridDirective); + +uiGridDirective.$inject = ['$window', 'gridUtil', 'uiGridConstants']; +function uiGridDirective($window, gridUtil, uiGridConstants) { + return { + templateUrl: 'ui-grid/ui-grid', + scope: { + uiGrid: '=' + }, + replace: true, + transclude: true, + controller: 'uiGridController', + compile: function () { + return { + post: function ($scope, $elm, $attrs, uiGridCtrl) { + var grid = uiGridCtrl.grid; + // Initialize scrollbars (TODO: move to controller??) + uiGridCtrl.scrollbars = []; + grid.element = $elm; + + + // See if the grid has a rendered width, if not, wait a bit and try again + var sizeCheckInterval = 100; // ms + var maxSizeChecks = 20; // 2 seconds total + var sizeChecks = 0; + + // Setup (event listeners) the grid + setup(); + + // And initialize it + init(); + + // Mark rendering complete so API events can happen + grid.renderingComplete(); + + // If the grid doesn't have size currently, wait for a bit to see if it gets size + checkSize(); + + /*-- Methods --*/ + + function checkSize() { + // If the grid has no width and we haven't checked more than times, check again in milliseconds + if ($elm[0].offsetWidth <= 0 && sizeChecks < maxSizeChecks) { + setTimeout(checkSize, sizeCheckInterval); + sizeChecks++; + } else { + $scope.$applyAsync(init); + } + } + + // Setup event listeners and watchers + function setup() { + var deregisterLeftWatcher, deregisterRightWatcher; + + // Bind to window resize events + angular.element($window).on('resize', gridResize); + + // Unbind from window resize events when the grid is destroyed + $elm.on('$destroy', function () { + angular.element($window).off('resize', gridResize); + deregisterLeftWatcher(); + deregisterRightWatcher(); + }); + + // If we add a left container after render, we need to watch and react + deregisterLeftWatcher = $scope.$watch(function () { return grid.hasLeftContainer();}, function (newValue, oldValue) { + if (newValue === oldValue) { + return; + } + grid.refreshCanvas(true); + }); + + // If we add a right container after render, we need to watch and react + deregisterRightWatcher = $scope.$watch(function () { return grid.hasRightContainer();}, function (newValue, oldValue) { + if (newValue === oldValue) { + return; + } + grid.refreshCanvas(true); + }); + } + + // Initialize the directive + function init() { + grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm); + + // Default canvasWidth to the grid width, in case we don't get any column definitions to calculate it from + grid.canvasWidth = uiGridCtrl.grid.gridWidth; + + grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm); + + // If the grid isn't tall enough to fit a single row, it's kind of useless. Resize it to fit a minimum number of rows + if (grid.gridHeight - grid.scrollbarHeight <= grid.options.rowHeight && grid.options.enableMinHeightCheck) { + autoAdjustHeight(); + } + + // Run initial canvas refresh + grid.refreshCanvas(true); + } + + // Set the grid's height ourselves in the case that its height would be unusably small + function autoAdjustHeight() { + // Figure out the new height + var contentHeight = grid.options.minRowsToShow * grid.options.rowHeight; + var headerHeight = grid.options.showHeader ? grid.options.headerRowHeight : 0; + var footerHeight = grid.calcFooterHeight(); + + var scrollbarHeight = 0; + if (grid.options.enableHorizontalScrollbar === uiGridConstants.scrollbars.ALWAYS) { + scrollbarHeight = gridUtil.getScrollbarWidth(); + } + + var maxNumberOfFilters = 0; + // Calculates the maximum number of filters in the columns + angular.forEach(grid.options.columnDefs, function(col) { + if (col.hasOwnProperty('filter')) { + if (maxNumberOfFilters < 1) { + maxNumberOfFilters = 1; + } + } + else if (col.hasOwnProperty('filters')) { + if (maxNumberOfFilters < col.filters.length) { + maxNumberOfFilters = col.filters.length; + } + } + }); + + if (grid.options.enableFiltering && !maxNumberOfFilters) { + var allColumnsHaveFilteringTurnedOff = grid.options.columnDefs.length && grid.options.columnDefs.every(function(col) { + return col.enableFiltering === false; + }); + + if (!allColumnsHaveFilteringTurnedOff) { + maxNumberOfFilters = 1; + } + } + + var filterHeight = maxNumberOfFilters * headerHeight; + + var newHeight = headerHeight + contentHeight + footerHeight + scrollbarHeight + filterHeight; + + $elm.css('height', newHeight + 'px'); + + grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm); + } + + // Resize the grid on window resize events + function gridResize() { + grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm); + grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm); + + grid.refreshCanvas(true); + } + } + }; + } + }; +} +})(); + +(function(){ + 'use strict'; + + // TODO: rename this file to ui-grid-pinned-container.js + + angular.module('ui.grid').directive('uiGridPinnedContainer', ['gridUtil', function (gridUtil) { + return { + restrict: 'EA', + replace: true, + template: '
', + scope: { + side: '=uiGridPinnedContainer' + }, + require: '^uiGrid', + compile: function compile() { + return { + post: function ($scope, $elm, $attrs, uiGridCtrl) { + // gridUtil.logDebug('ui-grid-pinned-container ' + $scope.side + ' link'); + + var grid = uiGridCtrl.grid; + + var myWidth = 0; + + $elm.addClass('ui-grid-pinned-container-' + $scope.side); + + // Monkey-patch the viewport width function + if ($scope.side === 'left' || $scope.side === 'right') { + grid.renderContainers[$scope.side].getViewportWidth = monkeyPatchedGetViewportWidth; + } + + function monkeyPatchedGetViewportWidth() { + /*jshint validthis: true */ + var self = this; + + var viewportWidth = 0; + self.visibleColumnCache.forEach(function (column) { + viewportWidth += column.drawnWidth; + }); + + var adjustment = self.getViewportAdjustment(); + + viewportWidth = viewportWidth + adjustment.width; + + return viewportWidth; + } + + function updateContainerWidth() { + if ($scope.side === 'left' || $scope.side === 'right') { + var cols = grid.renderContainers[$scope.side].visibleColumnCache; + var width = 0; + for (var i = 0; i < cols.length; i++) { + var col = cols[i]; + width += col.drawnWidth || col.width || 0; + } + + return width; + } + } + + function updateContainerDimensions() { + var ret = ''; + + // Column containers + if ($scope.side === 'left' || $scope.side === 'right') { + myWidth = updateContainerWidth(); + + // gridUtil.logDebug('myWidth', myWidth); + + // TODO(c0bra): Subtract sum of col widths from grid viewport width and update it + $elm.attr('style', null); + + // var myHeight = grid.renderContainers.body.getViewportHeight(); // + grid.horizontalScrollbarHeight; + + ret += '.grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.side + ', .grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.side + ' .ui-grid-render-container-' + $scope.side + ' .ui-grid-viewport { width: ' + myWidth + 'px; } '; + } + + return ret; + } + + grid.renderContainers.body.registerViewportAdjuster(function (adjustment) { + myWidth = updateContainerWidth(); + + // Subtract our own width + adjustment.width -= myWidth; + adjustment.side = $scope.side; + + return adjustment; + }); + + // Register style computation to adjust for columns in `side`'s render container + grid.registerStyleComputation({ + priority: 15, + func: updateContainerDimensions + }); + } + }; + } + }; + }]); +})(); + +(function(){ + +angular.module('ui.grid') +.factory('Grid', ['$q', '$compile', '$parse', 'gridUtil', 'uiGridConstants', 'GridOptions', 'GridColumn', 'GridRow', 'GridApi', 'rowSorter', 'rowSearcher', 'GridRenderContainer', '$timeout','ScrollEvent', + function($q, $compile, $parse, gridUtil, uiGridConstants, GridOptions, GridColumn, GridRow, GridApi, rowSorter, rowSearcher, GridRenderContainer, $timeout, ScrollEvent) { + + /** + * @ngdoc object + * @name ui.grid.core.api:PublicApi + * @description Public Api for the core grid features + * + */ + + /** + * @ngdoc function + * @name ui.grid.class:Grid + * @description Grid is the main viewModel. Any properties or methods needed to maintain state are defined in + * this prototype. One instance of Grid is created per Grid directive instance. + * @param {object} options Object map of options to pass into the grid. An 'id' property is expected. + */ + var Grid = function Grid(options) { + var self = this; + // Get the id out of the options, then remove it + if (options !== undefined && typeof(options.id) !== 'undefined' && options.id) { + if (!/^[_a-zA-Z0-9-]+$/.test(options.id)) { + throw new Error("Grid id '" + options.id + '" is invalid. It must follow CSS selector syntax rules.'); + } + } + else { + throw new Error('No ID provided. An ID must be given when creating a grid.'); + } + + self.id = options.id; + delete options.id; + + // Get default options + self.options = GridOptions.initialize( options ); + + /** + * @ngdoc object + * @name appScope + * @propertyOf ui.grid.class:Grid + * @description reference to the application scope (the parent scope of the ui-grid element). Assigned in ui-grid controller + *
+ * use gridOptions.appScopeProvider to override the default assignment of $scope.$parent with any reference + */ + self.appScope = self.options.appScopeProvider; + + self.headerHeight = self.options.headerRowHeight; + + + /** + * @ngdoc object + * @name footerHeight + * @propertyOf ui.grid.class:Grid + * @description returns the total footer height gridFooter + columnFooter + */ + self.footerHeight = self.calcFooterHeight(); + + + /** + * @ngdoc object + * @name columnFooterHeight + * @propertyOf ui.grid.class:Grid + * @description returns the total column footer height + */ + self.columnFooterHeight = self.calcColumnFooterHeight(); + + self.rtl = false; + self.gridHeight = 0; + self.gridWidth = 0; + self.columnBuilders = []; + self.rowBuilders = []; + self.rowsProcessors = []; + self.columnsProcessors = []; + self.styleComputations = []; + self.viewportAdjusters = []; + self.rowHeaderColumns = []; + self.dataChangeCallbacks = {}; + self.verticalScrollSyncCallBackFns = {}; + self.horizontalScrollSyncCallBackFns = {}; + + // self.visibleRowCache = []; + + // Set of 'render' containers for self grid, which can render sets of rows + self.renderContainers = {}; + + // Create a + self.renderContainers.body = new GridRenderContainer('body', self); + + self.cellValueGetterCache = {}; + + // Cached function to use with custom row templates + self.getRowTemplateFn = null; + + + //representation of the rows on the grid. + //these are wrapped references to the actual data rows (options.data) + self.rows = []; + + //represents the columns on the grid + self.columns = []; + + /** + * @ngdoc boolean + * @name isScrollingVertically + * @propertyOf ui.grid.class:Grid + * @description set to true when Grid is scrolling vertically. Set to false via debounced method + */ + self.isScrollingVertically = false; + + /** + * @ngdoc boolean + * @name isScrollingHorizontally + * @propertyOf ui.grid.class:Grid + * @description set to true when Grid is scrolling horizontally. Set to false via debounced method + */ + self.isScrollingHorizontally = false; + + /** + * @ngdoc property + * @name scrollDirection + * @propertyOf ui.grid.class:Grid + * @description set one of the {@link ui.grid.service:uiGridConstants#properties_scrollDirection uiGridConstants.scrollDirection} + * values (UP, DOWN, LEFT, RIGHT, NONE), which tells us which direction we are scrolling. + * Set to NONE via debounced method + */ + self.scrollDirection = uiGridConstants.scrollDirection.NONE; + + //if true, grid will not respond to any scroll events + self.disableScrolling = false; + + + function vertical (scrollEvent) { + self.isScrollingVertically = false; + self.api.core.raise.scrollEnd(scrollEvent); + self.scrollDirection = uiGridConstants.scrollDirection.NONE; + } + + var debouncedVertical = gridUtil.debounce(vertical, self.options.scrollDebounce); + var debouncedVerticalMinDelay = gridUtil.debounce(vertical, 0); + + function horizontal (scrollEvent) { + self.isScrollingHorizontally = false; + self.api.core.raise.scrollEnd(scrollEvent); + self.scrollDirection = uiGridConstants.scrollDirection.NONE; + } + + var debouncedHorizontal = gridUtil.debounce(horizontal, self.options.scrollDebounce); + var debouncedHorizontalMinDelay = gridUtil.debounce(horizontal, 0); + + + /** + * @ngdoc function + * @name flagScrollingVertically + * @methodOf ui.grid.class:Grid + * @description sets isScrollingVertically to true and sets it to false in a debounced function + */ + self.flagScrollingVertically = function(scrollEvent) { + if (!self.isScrollingVertically && !self.isScrollingHorizontally) { + self.api.core.raise.scrollBegin(scrollEvent); + } + self.isScrollingVertically = true; + if (self.options.scrollDebounce === 0 || !scrollEvent.withDelay) { + debouncedVerticalMinDelay(scrollEvent); + } + else { + debouncedVertical(scrollEvent); + } + }; + + /** + * @ngdoc function + * @name flagScrollingHorizontally + * @methodOf ui.grid.class:Grid + * @description sets isScrollingHorizontally to true and sets it to false in a debounced function + */ + self.flagScrollingHorizontally = function(scrollEvent) { + if (!self.isScrollingVertically && !self.isScrollingHorizontally) { + self.api.core.raise.scrollBegin(scrollEvent); + } + self.isScrollingHorizontally = true; + if (self.options.scrollDebounce === 0 || !scrollEvent.withDelay) { + debouncedHorizontalMinDelay(scrollEvent); + } + else { + debouncedHorizontal(scrollEvent); + } + }; + + self.scrollbarHeight = 0; + self.scrollbarWidth = 0; + if (self.options.enableHorizontalScrollbar !== uiGridConstants.scrollbars.NEVER) { + self.scrollbarHeight = gridUtil.getScrollbarWidth(); + } + + if (self.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER) { + self.scrollbarWidth = gridUtil.getScrollbarWidth(); + } + + + + self.api = new GridApi(self); + + /** + * @ngdoc function + * @name refresh + * @methodOf ui.grid.core.api:PublicApi + * @description Refresh the rendered grid on screen. + * The refresh method re-runs both the columnProcessors and the + * rowProcessors, as well as calling refreshCanvas to update all + * the grid sizing. In general you should prefer to use queueGridRefresh + * instead, which is basically a debounced version of refresh. + * + * If you only want to resize the grid, not regenerate all the rows + * and columns, you should consider directly calling refreshCanvas instead. + * + * @param {boolean} [rowsAltered] Optional flag for refreshing when the number of rows has changed + */ + self.api.registerMethod( 'core', 'refresh', this.refresh ); + + /** + * @ngdoc function + * @name queueGridRefresh + * @methodOf ui.grid.core.api:PublicApi + * @description Request a refresh of the rendered grid on screen, if multiple + * calls to queueGridRefresh are made within a digest cycle only one will execute. + * The refresh method re-runs both the columnProcessors and the + * rowProcessors, as well as calling refreshCanvas to update all + * the grid sizing. In general you should prefer to use queueGridRefresh + * instead, which is basically a debounced version of refresh. + * + */ + self.api.registerMethod( 'core', 'queueGridRefresh', this.queueGridRefresh ); + + /** + * @ngdoc function + * @name refreshRows + * @methodOf ui.grid.core.api:PublicApi + * @description Runs only the rowProcessors, columns remain as they were. + * It then calls redrawInPlace and refreshCanvas, which adjust the grid sizing. + * @returns {promise} promise that is resolved when render completes? + * + */ + self.api.registerMethod( 'core', 'refreshRows', this.refreshRows ); + + /** + * @ngdoc function + * @name queueRefresh + * @methodOf ui.grid.core.api:PublicApi + * @description Requests execution of refreshCanvas, if multiple requests are made + * during a digest cycle only one will run. RefreshCanvas updates the grid sizing. + * @returns {promise} promise that is resolved when render completes? + * + */ + self.api.registerMethod( 'core', 'queueRefresh', this.queueRefresh ); + + /** + * @ngdoc function + * @name handleWindowResize + * @methodOf ui.grid.core.api:PublicApi + * @description Trigger a grid resize, normally this would be picked + * up by a watch on window size, but in some circumstances it is necessary + * to call this manually + * @returns {promise} promise that is resolved when render completes? + * + */ + self.api.registerMethod( 'core', 'handleWindowResize', this.handleWindowResize ); + + + /** + * @ngdoc function + * @name addRowHeaderColumn + * @methodOf ui.grid.core.api:PublicApi + * @description adds a row header column to the grid + * @param {object} column def + * @param {number} order Determines order of header column on grid. Lower order means header + * is positioned to the left of higher order headers + * + */ + self.api.registerMethod( 'core', 'addRowHeaderColumn', this.addRowHeaderColumn ); + + /** + * @ngdoc function + * @name scrollToIfNecessary + * @methodOf ui.grid.core.api:PublicApi + * @description Scrolls the grid to make a certain row and column combo visible, + * in the case that it is not completely visible on the screen already. + * @param {GridRow} gridRow row to make visible + * @param {GridColumn} gridCol column to make visible + * @returns {promise} a promise that is resolved when scrolling is complete + * + */ + self.api.registerMethod( 'core', 'scrollToIfNecessary', function(gridRow, gridCol) { return self.scrollToIfNecessary(gridRow, gridCol);} ); + + /** + * @ngdoc function + * @name scrollTo + * @methodOf ui.grid.core.api:PublicApi + * @description Scroll the grid such that the specified + * row and column is in view + * @param {object} rowEntity gridOptions.data[] array instance to make visible + * @param {object} colDef to make visible + * @returns {promise} a promise that is resolved after any scrolling is finished + */ + self.api.registerMethod( 'core', 'scrollTo', function (rowEntity, colDef) { return self.scrollTo(rowEntity, colDef);} ); + + /** + * @ngdoc function + * @name registerRowsProcessor + * @methodOf ui.grid.core.api:PublicApi + * @description + * Register a "rows processor" function. When the rows are updated, + * the grid calls each registered "rows processor", which has a chance + * to alter the set of rows (sorting, etc) as long as the count is not + * modified. + * + * @param {function(renderedRowsToProcess, columns )} processorFunction rows processor function, which + * is run in the context of the grid (i.e. this for the function will be the grid), and must + * return the updated rows list, which is passed to the next processor in the chain + * @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room + * for other people to inject rows processors at intermediate priorities. Lower priority rowsProcessors run earlier. + * + * At present allRowsVisible is running at 50, sort manipulations running at 60-65, filter is running at 100, + * sort is at 200, grouping and treeview at 400-410, selectable rows at 500, pagination at 900 (pagination will generally want to be last) + */ + self.api.registerMethod( 'core', 'registerRowsProcessor', this.registerRowsProcessor ); + + /** + * @ngdoc function + * @name registerColumnsProcessor + * @methodOf ui.grid.core.api:PublicApi + * @description + * Register a "columns processor" function. When the columns are updated, + * the grid calls each registered "columns processor", which has a chance + * to alter the set of columns as long as the count is not + * modified. + * + * @param {function(renderedColumnsToProcess, rows )} processorFunction columns processor function, which + * is run in the context of the grid (i.e. this for the function will be the grid), and must + * return the updated columns list, which is passed to the next processor in the chain + * @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room + * for other people to inject columns processors at intermediate priorities. Lower priority columnsProcessors run earlier. + * + * At present allRowsVisible is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at 500, pagination at 900 (pagination will generally want to be last) + */ + self.api.registerMethod( 'core', 'registerColumnsProcessor', this.registerColumnsProcessor ); + + + + /** + * @ngdoc function + * @name sortHandleNulls + * @methodOf ui.grid.core.api:PublicApi + * @description A null handling method that can be used when building custom sort + * functions + * @example + *
+     *   mySortFn = function(a, b) {
+     *   var nulls = $scope.gridApi.core.sortHandleNulls(a, b);
+     *   if ( nulls !== null ){
+     *     return nulls;
+     *   } else {
+     *     // your code for sorting here
+     *   };
+     * 
+ * @param {object} a sort value a + * @param {object} b sort value b + * @returns {number} null if there were no nulls/undefineds, otherwise returns + * a sort value that should be passed back from the sort function + * + */ + self.api.registerMethod( 'core', 'sortHandleNulls', rowSorter.handleNulls ); + + + /** + * @ngdoc function + * @name sortChanged + * @methodOf ui.grid.core.api:PublicApi + * @description The sort criteria on one or more columns has + * changed. Provides as parameters the grid and the output of + * getColumnSorting, which is an array of gridColumns + * that have sorting on them, sorted in priority order. + * + * @param {$scope} scope The scope of the controller. This is used to deregister this event when the scope is destroyed. + * @param {Function} callBack Will be called when the event is emited. The function passes back the grid and an array of + * columns with sorts on them, in priority order. + * + * @example + *
+     *      gridApi.core.on.sortChanged( $scope, function(grid, sortColumns){
+     *        // do something
+     *      });
+     * 
+ */ + self.api.registerEvent( 'core', 'sortChanged' ); + + /** + * @ngdoc function + * @name columnVisibilityChanged + * @methodOf ui.grid.core.api:PublicApi + * @description The visibility of a column has changed, + * the column itself is passed out as a parameter of the event. + * + * @param {$scope} scope The scope of the controller. This is used to deregister this event when the scope is destroyed. + * @param {Function} callBack Will be called when the event is emited. The function passes back the GridCol that has changed. + * + * @example + *
+     *      gridApi.core.on.columnVisibilityChanged( $scope, function (column) {
+     *        // do something
+     *      } );
+     * 
+ */ + self.api.registerEvent( 'core', 'columnVisibilityChanged' ); + + /** + * @ngdoc method + * @name notifyDataChange + * @methodOf ui.grid.core.api:PublicApi + * @description Notify the grid that a data or config change has occurred, + * where that change isn't something the grid was otherwise noticing. This + * might be particularly relevant where you've changed values within the data + * and you'd like cell classes to be re-evaluated, or changed config within + * the columnDef and you'd like headerCellClasses to be re-evaluated. + * @param {string} type one of the + * {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange} + * values (ALL, ROW, EDIT, COLUMN, OPTIONS), which tells us which refreshes to fire. + * + * - ALL: listeners fired on any of these events, fires listeners on all events. + * - ROW: fired when a row is added or removed. + * - EDIT: fired when the data in a cell is edited. + * - COLUMN: fired when the column definitions are modified. + * - OPTIONS: fired when the grid options are modified. + */ + self.api.registerMethod( 'core', 'notifyDataChange', this.notifyDataChange ); + + /** + * @ngdoc method + * @name clearAllFilters + * @methodOf ui.grid.core.api:PublicApi + * @description Clears all filters and optionally refreshes the visible rows. + * @param {object} refreshRows Defaults to true. + * @param {object} clearConditions Defaults to false. + * @param {object} clearFlags Defaults to false. + * @returns {promise} If `refreshRows` is true, returns a promise of the rows refreshing. + */ + self.api.registerMethod('core', 'clearAllFilters', this.clearAllFilters); + + self.registerDataChangeCallback( self.columnRefreshCallback, [uiGridConstants.dataChange.COLUMN]); + self.registerDataChangeCallback( self.processRowsCallback, [uiGridConstants.dataChange.EDIT]); + self.registerDataChangeCallback( self.updateFooterHeightCallback, [uiGridConstants.dataChange.OPTIONS]); + + self.registerStyleComputation({ + priority: 10, + func: self.getFooterStyles + }); + }; + + Grid.prototype.calcFooterHeight = function () { + if (!this.hasFooter()) { + return 0; + } + + var height = 0; + if (this.options.showGridFooter) { + height += this.options.gridFooterHeight; + } + + height += this.calcColumnFooterHeight(); + + return height; + }; + + Grid.prototype.calcColumnFooterHeight = function () { + var height = 0; + + if (this.options.showColumnFooter) { + height += this.options.columnFooterHeight; + } + + return height; + }; + + Grid.prototype.getFooterStyles = function () { + var style = '.grid' + this.id + ' .ui-grid-footer-aggregates-row { height: ' + this.options.columnFooterHeight + 'px; }'; + style += ' .grid' + this.id + ' .ui-grid-footer-info { height: ' + this.options.gridFooterHeight + 'px; }'; + return style; + }; + + Grid.prototype.hasFooter = function () { + return this.options.showGridFooter || this.options.showColumnFooter; + }; + + /** + * @ngdoc function + * @name isRTL + * @methodOf ui.grid.class:Grid + * @description Returns true if grid is RightToLeft + */ + Grid.prototype.isRTL = function () { + return this.rtl; + }; + + + /** + * @ngdoc function + * @name registerColumnBuilder + * @methodOf ui.grid.class:Grid + * @description When the build creates columns from column definitions, the columnbuilders will be called to add + * additional properties to the column. + * @param {function(colDef, col, gridOptions)} columnBuilder function to be called + */ + Grid.prototype.registerColumnBuilder = function registerColumnBuilder(columnBuilder) { + this.columnBuilders.push(columnBuilder); + }; + + /** + * @ngdoc function + * @name buildColumnDefsFromData + * @methodOf ui.grid.class:Grid + * @description Populates columnDefs from the provided data + * @param {function(colDef, col, gridOptions)} rowBuilder function to be called + */ + Grid.prototype.buildColumnDefsFromData = function (dataRows){ + this.options.columnDefs = gridUtil.getColumnsFromData(dataRows, this.options.excludeProperties); + }; + + /** + * @ngdoc function + * @name registerRowBuilder + * @methodOf ui.grid.class:Grid + * @description When the build creates rows from gridOptions.data, the rowBuilders will be called to add + * additional properties to the row. + * @param {function(row, gridOptions)} rowBuilder function to be called + */ + Grid.prototype.registerRowBuilder = function registerRowBuilder(rowBuilder) { + this.rowBuilders.push(rowBuilder); + }; + + + /** + * @ngdoc function + * @name registerDataChangeCallback + * @methodOf ui.grid.class:Grid + * @description When a data change occurs, the data change callbacks of the specified type + * will be called. The rules are: + * + * - when the data watch fires, that is considered a ROW change (the data watch only notices + * added or removed rows) + * - when the api is called to inform us of a change, the declared type of that change is used + * - when a cell edit completes, the EDIT callbacks are triggered + * - when the columnDef watch fires, the COLUMN callbacks are triggered + * - when the options watch fires, the OPTIONS callbacks are triggered + * + * For a given event: + * - ALL calls ROW, EDIT, COLUMN, OPTIONS and ALL callbacks + * - ROW calls ROW and ALL callbacks + * - EDIT calls EDIT and ALL callbacks + * - COLUMN calls COLUMN and ALL callbacks + * - OPTIONS calls OPTIONS and ALL callbacks + * + * @param {function(grid)} callback function to be called + * @param {array} types the types of data change you want to be informed of. Values from + * the {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange} + * values ( ALL, EDIT, ROW, COLUMN, OPTIONS ). Optional and defaults to ALL + * @returns {function} deregister function - a function that can be called to deregister this callback + */ + Grid.prototype.registerDataChangeCallback = function registerDataChangeCallback(callback, types, _this) { + var uid = gridUtil.nextUid(); + if ( !types ){ + types = [uiGridConstants.dataChange.ALL]; + } + if ( !Array.isArray(types)){ + gridUtil.logError("Expected types to be an array or null in registerDataChangeCallback, value passed was: " + types ); + } + this.dataChangeCallbacks[uid] = { callback: callback, types: types, _this:_this }; + + var self = this; + var deregisterFunction = function() { + delete self.dataChangeCallbacks[uid]; + }; + return deregisterFunction; + }; + + /** + * @ngdoc function + * @name callDataChangeCallbacks + * @methodOf ui.grid.class:Grid + * @description Calls the callbacks based on the type of data change that + * has occurred. Always calls the ALL callbacks, calls the ROW, EDIT, COLUMN and OPTIONS callbacks if the + * event type is matching, or if the type is ALL. + * @param {string} type the type of event that occurred - one of the + * {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange} + * values (ALL, ROW, EDIT, COLUMN, OPTIONS) + */ + Grid.prototype.callDataChangeCallbacks = function callDataChangeCallbacks(type, options) { + angular.forEach( this.dataChangeCallbacks, function( callback, uid ){ + if ( callback.types.indexOf( uiGridConstants.dataChange.ALL ) !== -1 || + callback.types.indexOf( type ) !== -1 || + type === uiGridConstants.dataChange.ALL ) { + if (callback._this) { + callback.callback.apply(callback._this, this, options); + } + else { + callback.callback(this, options); + } + } + }, this); + }; + + /** + * @ngdoc function + * @name notifyDataChange + * @methodOf ui.grid.class:Grid + * @description Notifies us that a data change has occurred, used in the public + * api for users to tell us when they've changed data or some other event that + * our watches cannot pick up + * @param {string} type the type of event that occurred - one of the + * uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN, OPTIONS) + * + * - ALL: listeners fired on any of these events, fires listeners on all events. + * - ROW: fired when a row is added or removed. + * - EDIT: fired when the data in a cell is edited. + * - COLUMN: fired when the column definitions are modified. + * - OPTIONS: fired when the grid options are modified. + */ + Grid.prototype.notifyDataChange = function notifyDataChange(type) { + var constants = uiGridConstants.dataChange; + if ( type === constants.ALL || + type === constants.COLUMN || + type === constants.EDIT || + type === constants.ROW || + type === constants.OPTIONS ){ + this.callDataChangeCallbacks( type ); + } else { + gridUtil.logError("Notified of a data change, but the type was not recognised, so no action taken, type was: " + type); + } + }; + + + /** + * @ngdoc function + * @name columnRefreshCallback + * @methodOf ui.grid.class:Grid + * @description refreshes the grid when a column refresh + * is notified, which triggers handling of the visible flag. + * This is called on uiGridConstants.dataChange.COLUMN, and is + * registered as a dataChangeCallback in grid.js + * @param {object} grid The grid object. + * @param {object} options Any options passed into the callback. + */ + Grid.prototype.columnRefreshCallback = function columnRefreshCallback(grid, options){ + grid.buildColumns(options); + grid.queueGridRefresh(); + }; + + + /** + * @ngdoc function + * @name processRowsCallback + * @methodOf ui.grid.class:Grid + * @description calls the row processors, specifically + * intended to reset the sorting when an edit is called, + * registered as a dataChangeCallback on uiGridConstants.dataChange.EDIT + * @param {string} name column name + */ + Grid.prototype.processRowsCallback = function processRowsCallback( grid ){ + grid.queueGridRefresh(); + }; + + + /** + * @ngdoc function + * @name updateFooterHeightCallback + * @methodOf ui.grid.class:Grid + * @description recalculates the footer height, + * registered as a dataChangeCallback on uiGridConstants.dataChange.OPTIONS + * @param {string} name column name + */ + Grid.prototype.updateFooterHeightCallback = function updateFooterHeightCallback( grid ){ + grid.footerHeight = grid.calcFooterHeight(); + grid.columnFooterHeight = grid.calcColumnFooterHeight(); + }; + + + /** + * @ngdoc function + * @name getColumn + * @methodOf ui.grid.class:Grid + * @description returns a grid column for the column name + * @param {string} name column name + */ + Grid.prototype.getColumn = function getColumn(name) { + var columns = this.columns.filter(function (column) { + return column.colDef.name === name; + }); + return columns.length > 0 ? columns[0] : null; + }; + + /** + * @ngdoc function + * @name getColDef + * @methodOf ui.grid.class:Grid + * @description returns a grid colDef for the column name + * @param {string} name column.field + */ + Grid.prototype.getColDef = function getColDef(name) { + var colDefs = this.options.columnDefs.filter(function (colDef) { + return colDef.name === name; + }); + return colDefs.length > 0 ? colDefs[0] : null; + }; + + /** + * @ngdoc function + * @name assignTypes + * @methodOf ui.grid.class:Grid + * @description uses the first row of data to assign colDef.type for any types not defined. + */ + /** + * @ngdoc property + * @name type + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description the type of the column, used in sorting. If not provided then the + * grid will guess the type. Add this only if the grid guessing is not to your + * satisfaction. One of: + * - 'string' + * - 'boolean' + * - 'number' + * - 'date' + * - 'object' + * - 'numberStr' + * Note that if you choose date, your dates should be in a javascript date type + * + */ + Grid.prototype.assignTypes = function(){ + var self = this; + self.options.columnDefs.forEach(function (colDef, index) { + + //Assign colDef type if not specified + if (!colDef.type) { + var col = new GridColumn(colDef, index, self); + var firstRow = self.rows.length > 0 ? self.rows[0] : null; + if (firstRow) { + colDef.type = gridUtil.guessType(self.getCellValue(firstRow, col)); + } + else { + colDef.type = 'string'; + } + } + }); + }; + + + /** + * @ngdoc function + * @name isRowHeaderColumn + * @methodOf ui.grid.class:Grid + * @description returns true if the column is a row Header + * @param {object} column column + */ + Grid.prototype.isRowHeaderColumn = function isRowHeaderColumn(column) { + return this.rowHeaderColumns.indexOf(column) !== -1; + }; + + /** + * @ngdoc function + * @name addRowHeaderColumn + * @methodOf ui.grid.class:Grid + * @description adds a row header column to the grid + * @param {object} colDef Column definition object. + * @param {float} order Number that indicates where the column should be placed in the grid. + * @param {boolean} stopColumnBuild Prevents the buildColumn callback from being triggered. This is useful to improve + * performance of the grid during initial load. + */ + Grid.prototype.addRowHeaderColumn = function addRowHeaderColumn(colDef, order, stopColumnBuild) { + var self = this; + + //default order + if (order === undefined) { + order = 0; + } + + var rowHeaderCol = new GridColumn(colDef, gridUtil.nextUid(), self); + rowHeaderCol.isRowHeader = true; + if (self.isRTL()) { + self.createRightContainer(); + rowHeaderCol.renderContainer = 'right'; + } + else { + self.createLeftContainer(); + rowHeaderCol.renderContainer = 'left'; + } + + // relies on the default column builder being first in array, as it is instantiated + // as part of grid creation + self.columnBuilders[0](colDef,rowHeaderCol,self.options) + .then(function(){ + rowHeaderCol.enableFiltering = false; + rowHeaderCol.enableSorting = false; + rowHeaderCol.enableHiding = false; + rowHeaderCol.headerPriority = order; + self.rowHeaderColumns.push(rowHeaderCol); + self.rowHeaderColumns = self.rowHeaderColumns.sort(function (a, b) { + return a.headerPriority - b.headerPriority; + }); + + if (!stopColumnBuild) { + self.buildColumns() + .then(function() { + self.preCompileCellTemplates(); + self.queueGridRefresh(); + }).catch(angular.noop); + } + }).catch(angular.noop); + }; + + /** + * @ngdoc function + * @name getOnlyDataColumns + * @methodOf ui.grid.class:Grid + * @description returns all columns except for rowHeader columns + */ + Grid.prototype.getOnlyDataColumns = function getOnlyDataColumns() { + var self = this; + var cols = []; + self.columns.forEach(function (col) { + if (self.rowHeaderColumns.indexOf(col) === -1) { + cols.push(col); + } + }); + return cols; + }; + + /** + * @ngdoc function + * @name buildColumns + * @methodOf ui.grid.class:Grid + * @description creates GridColumn objects from the columnDefinition. Calls each registered + * columnBuilder to further process the column + * @param {object} options An object contains options to use when building columns + * + * * **orderByColumnDefs**: defaults to **false**. When true, `buildColumns` will reorder existing columns according to the order within the column definitions. + * + * @returns {Promise} a promise to load any needed column resources + */ + Grid.prototype.buildColumns = function buildColumns(opts) { + var options = { + orderByColumnDefs: false + }; + + angular.extend(options, opts); + + // gridUtil.logDebug('buildColumns'); + var self = this; + var builderPromises = []; + var headerOffset = self.rowHeaderColumns.length; + var i; + + // Remove any columns for which a columnDef cannot be found + // Deliberately don't use forEach, as it doesn't like splice being called in the middle + // Also don't cache columns.length, as it will change during this operation + for (i = 0; i < self.columns.length; i++){ + if (!self.getColDef(self.columns[i].name)) { + self.columns.splice(i, 1); + i--; + } + } + + //add row header columns to the grid columns array _after_ columns without columnDefs have been removed + //rowHeaderColumns is ordered by priority so insert in reverse + for (var j = self.rowHeaderColumns.length - 1; j >= 0; j--) { + self.columns.unshift(self.rowHeaderColumns[j]); + } + + + + // look at each column def, and update column properties to match. If the column def + // doesn't have a column, then splice in a new gridCol + self.options.columnDefs.forEach(function (colDef, index) { + self.preprocessColDef(colDef); + var col = self.getColumn(colDef.name); + + if (!col) { + col = new GridColumn(colDef, gridUtil.nextUid(), self); + self.columns.splice(index + headerOffset, 0, col); + } + else { + // tell updateColumnDef that the column was pre-existing + col.updateColumnDef(colDef, false); + } + + self.columnBuilders.forEach(function (builder) { + builderPromises.push(builder.call(self, colDef, col, self.options)); + }); + }); + + /*** Reorder columns if necessary ***/ + if (!!options.orderByColumnDefs) { + // Create a shallow copy of the columns as a cache + var columnCache = self.columns.slice(0); + + // We need to allow for the "row headers" when mapping from the column defs array to the columns array + // If we have a row header in columns[0] and don't account for it we'll overwrite it with the column in columnDefs[0] + + // Go through all the column defs, use the shorter of columns length and colDefs.length because if a user has given two columns the same name then + // columns will be shorter than columnDefs. In this situation we'll avoid an error, but the user will still get an unexpected result + var len = Math.min(self.options.columnDefs.length, self.columns.length); + for (i = 0; i < len; i++) { + // If the column at this index has a different name than the column at the same index in the column defs... + if (self.columns[i + headerOffset].name !== self.options.columnDefs[i].name) { + // Replace the one in the cache with the appropriate column + columnCache[i + headerOffset] = self.getColumn(self.options.columnDefs[i].name); + } + else { + // Otherwise just copy over the one from the initial columns + columnCache[i + headerOffset] = self.columns[i + headerOffset]; + } + } + + // Empty out the columns array, non-destructively + self.columns.length = 0; + + // And splice in the updated, ordered columns from the cache + Array.prototype.splice.apply(self.columns, [0, 0].concat(columnCache)); + } + + return $q.all(builderPromises).then(function(){ + if (self.rows.length > 0){ + self.assignTypes(); + } + if (options.preCompileCellTemplates) { + self.preCompileCellTemplates(); + } + }).catch(angular.noop); + }; + + Grid.prototype.preCompileCellTemplate = function(col) { + var self = this; + var html = col.cellTemplate.replace(uiGridConstants.MODEL_COL_FIELD, self.getQualifiedColField(col)); + html = html.replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)'); + + col.compiledElementFn = $compile(html); + + if (col.compiledElementFnDefer) { + col.compiledElementFnDefer.resolve(col.compiledElementFn); + } + }; + +/** + * @ngdoc function + * @name preCompileCellTemplates + * @methodOf ui.grid.class:Grid + * @description precompiles all cell templates + */ + Grid.prototype.preCompileCellTemplates = function() { + var self = this; + self.columns.forEach(function (col) { + if ( col.cellTemplate ){ + self.preCompileCellTemplate( col ); + } else if ( col.cellTemplatePromise ){ + col.cellTemplatePromise.then( function() { + self.preCompileCellTemplate( col ); + }).catch(angular.noop); + } + }); + }; + + /** + * @ngdoc function + * @name getGridQualifiedColField + * @methodOf ui.grid.class:Grid + * @description Returns the $parse-able accessor for a column within its $scope + * @param {GridColumn} col col object + */ + Grid.prototype.getQualifiedColField = function (col) { + var base = 'row.entity'; + if ( col.field === uiGridConstants.ENTITY_BINDING ) { + return base; + } + return gridUtil.preEval(base + '.' + col.field); + }; + + /** + * @ngdoc function + * @name createLeftContainer + * @methodOf ui.grid.class:Grid + * @description creates the left render container if it doesn't already exist + */ + Grid.prototype.createLeftContainer = function() { + if (!this.hasLeftContainer()) { + this.renderContainers.left = new GridRenderContainer('left', this, { disableColumnOffset: true }); + } + }; + + /** + * @ngdoc function + * @name createRightContainer + * @methodOf ui.grid.class:Grid + * @description creates the right render container if it doesn't already exist + */ + Grid.prototype.createRightContainer = function() { + if (!this.hasRightContainer()) { + this.renderContainers.right = new GridRenderContainer('right', this, { disableColumnOffset: true }); + } + }; + + /** + * @ngdoc function + * @name hasLeftContainer + * @methodOf ui.grid.class:Grid + * @description returns true if leftContainer exists + */ + Grid.prototype.hasLeftContainer = function() { + return this.renderContainers.left !== undefined; + }; + + /** + * @ngdoc function + * @name hasRightContainer + * @methodOf ui.grid.class:Grid + * @description returns true if rightContainer exists + */ + Grid.prototype.hasRightContainer = function() { + return this.renderContainers.right !== undefined; + }; + + + /** + * undocumented function + * @name preprocessColDef + * @methodOf ui.grid.class:Grid + * @description defaults the name property from field to maintain backwards compatibility with 2.x + * validates that name or field is present + */ + Grid.prototype.preprocessColDef = function preprocessColDef(colDef) { + var self = this; + + if (!colDef.field && !colDef.name) { + throw new Error('colDef.name or colDef.field property is required'); + } + + //maintain backwards compatibility with 2.x + //field was required in 2.x. now name is required + if (colDef.name === undefined && colDef.field !== undefined) { + // See if the column name already exists: + var newName = colDef.field, + counter = 2; + while (self.getColumn(newName)) { + newName = colDef.field + counter.toString(); + counter++; + } + colDef.name = newName; + } + }; + + // Return a list of items that exist in the `n` array but not the `o` array. Uses optional property accessors passed as third & fourth parameters + Grid.prototype.newInN = function newInN(o, n, oAccessor, nAccessor) { + var self = this; + + var t = []; + for (var i = 0; i < n.length; i++) { + var nV = nAccessor ? n[i][nAccessor] : n[i]; + + var found = false; + for (var j = 0; j < o.length; j++) { + var oV = oAccessor ? o[j][oAccessor] : o[j]; + if (self.options.rowEquality(nV, oV)) { + found = true; + break; + } + } + if (!found) { + t.push(nV); + } + } + + return t; + }; + + /** + * @ngdoc function + * @name getRow + * @methodOf ui.grid.class:Grid + * @description returns the GridRow that contains the rowEntity + * @param {object} rowEntity the gridOptions.data array element instance + * @param {array} lookInRows [optional] the rows to look in - if not provided then + * looks in grid.rows + */ + Grid.prototype.getRow = function getRow(rowEntity, lookInRows) { + var self = this; + + lookInRows = typeof(lookInRows) === 'undefined' ? self.rows : lookInRows; + + var rows = lookInRows.filter(function (row) { + return self.options.rowEquality(row.entity, rowEntity); + }); + return rows.length > 0 ? rows[0] : null; + }; + + + /** + * @ngdoc function + * @name modifyRows + * @methodOf ui.grid.class:Grid + * @description creates or removes GridRow objects from the newRawData array. Calls each registered + * rowBuilder to further process the row + * @param {array} newRawData Modified set of data + * + * This method aims to achieve three things: + * 1. the resulting rows array is in the same order as the newRawData, we'll call + * rowsProcessors immediately after to sort the data anyway + * 2. if we have row hashing available, we try to use the rowHash to find the row + * 3. no memory leaks - rows that are no longer in newRawData need to be garbage collected + * + * The basic logic flow makes use of the newRawData, oldRows and oldHash, and creates + * the newRows and newHash + * + * ``` + * newRawData.forEach newEntity + * if (hashing enabled) + * check oldHash for newEntity + * else + * look for old row directly in oldRows + * if !oldRowFound // must be a new row + * create newRow + * append to the newRows and add to newHash + * run the processors + * ``` + * + * Rows are identified using the hashKey if configured. If not configured, then rows + * are identified using the gridOptions.rowEquality function + * + * This method is useful when trying to select rows immediately after loading data without + * using a $timeout/$interval, e.g.: + * + * $scope.gridOptions.data = someData; + * $scope.gridApi.grid.modifyRows($scope.gridOptions.data); + * $scope.gridApi.selection.selectRow($scope.gridOptions.data[0]); + * + * OR to persist row selection after data update (e.g. rows selected, new data loaded, want + * originally selected rows to be re-selected)) + */ + Grid.prototype.modifyRows = function modifyRows(newRawData) { + var self = this; + var oldRows = self.rows.slice(0); + var oldRowHash = self.rowHashMap || self.createRowHashMap(); + var allRowsSelected = true; + self.rowHashMap = self.createRowHashMap(); + self.rows.length = 0; + + newRawData.forEach( function( newEntity, i ) { + var newRow, oldRow; + + if ( self.options.enableRowHashing ){ + // if hashing is enabled, then this row will be in the hash if we already know about it + oldRow = oldRowHash.get( newEntity ); + } else { + // otherwise, manually search the oldRows to see if we can find this row + oldRow = self.getRow(newEntity, oldRows); + } + + // update newRow to have an entity + if ( oldRow ) { + newRow = oldRow; + newRow.entity = newEntity; + } + + // if we didn't find the row, it must be new, so create it + if ( !newRow ){ + newRow = self.processRowBuilders(new GridRow(newEntity, i, self)); + } + + self.rows.push( newRow ); + self.rowHashMap.put( newEntity, newRow ); + if (!newRow.isSelected) { + allRowsSelected = false; + } + }); + + if (self.selection && self.rows.length) { + self.selection.selectAll = allRowsSelected; + } + + self.assignTypes(); + + var p1 = $q.when(self.processRowsProcessors(self.rows)) + .then(function (renderableRows) { + return self.setVisibleRows(renderableRows); + }).catch(angular.noop); + + var p2 = $q.when(self.processColumnsProcessors(self.columns)) + .then(function (renderableColumns) { + return self.setVisibleColumns(renderableColumns); + }).catch(angular.noop); + + return $q.all([p1, p2]); + }; + + + /** + * Private Undocumented Method + * @name addRows + * @methodOf ui.grid.class:Grid + * @description adds the newRawData array of rows to the grid and calls all registered + * rowBuilders. this keyword will reference the grid + */ + Grid.prototype.addRows = function addRows(newRawData) { + var self = this; + + var existingRowCount = self.rows.length; + for (var i = 0; i < newRawData.length; i++) { + var newRow = self.processRowBuilders(new GridRow(newRawData[i], i + existingRowCount, self)); + + if (self.options.enableRowHashing) { + var found = self.rowHashMap.get(newRow.entity); + if (found) { + found.row = newRow; + } + } + + self.rows.push(newRow); + } + }; + + /** + * @ngdoc function + * @name processRowBuilders + * @methodOf ui.grid.class:Grid + * @description processes all RowBuilders for the gridRow + * @param {GridRow} gridRow reference to gridRow + * @returns {GridRow} the gridRow with all additional behavior added + */ + Grid.prototype.processRowBuilders = function processRowBuilders(gridRow) { + var self = this; + + self.rowBuilders.forEach(function (builder) { + builder.call(self, gridRow, self.options); + }); + + return gridRow; + }; + + /** + * @ngdoc function + * @name registerStyleComputation + * @methodOf ui.grid.class:Grid + * @description registered a styleComputation function + * + * If the function returns a value it will be appended into the grid's `
" + ); + + + $templateCache.put('ui-grid/uiGridCell', + "
{{COL_FIELD CUSTOM_FILTERS}}
" + ); + + + $templateCache.put('ui-grid/uiGridColumnMenu', + "
" + ); + + + $templateCache.put('ui-grid/uiGridFooterCell', + "
{{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}
" + ); + + + $templateCache.put('ui-grid/uiGridHeaderCell', + "
{{ col.displayName CUSTOM_FILTERS }} {{col.sort.priority + 1}}
 
" + ); + + + $templateCache.put('ui-grid/uiGridMenu', + "
" + ); + + + $templateCache.put('ui-grid/uiGridMenuItem', + "" + ); + + + $templateCache.put('ui-grid/uiGridRenderContainer', + "
" + ); + + + $templateCache.put('ui-grid/uiGridViewport', + "
" + ); + + + $templateCache.put('ui-grid/cellEditor', + "
" + ); + + + $templateCache.put('ui-grid/dropdownEditor', + "
" + ); + + + $templateCache.put('ui-grid/fileChooserEditor', + "
" + ); + + + $templateCache.put('ui-grid/emptyBaseLayerContainer', + "
" + ); + + + $templateCache.put('ui-grid/expandableRow', + "
" + ); + + + $templateCache.put('ui-grid/expandableRowHeader', + "
" + ); + + + $templateCache.put('ui-grid/expandableScrollFiller', + "
" + ); + + + $templateCache.put('ui-grid/expandableTopRowHeader', + "
" + ); + + + $templateCache.put('ui-grid/csvLink', + "
LINK_LABEL" + ); + + + $templateCache.put('ui-grid/importerMenuItem', + "
  • " + ); + + + $templateCache.put('ui-grid/importerMenuItemContainer', + "
    " + ); + + + $templateCache.put('ui-grid/pagination', + "
    0\">/ {{ paginationApi.getTotalPages() }}
    1 && !grid.options.useCustomPagination\"> {{sizesLabel}}
    {{grid.options.paginationPageSize}} {{sizesLabel}}
    0\">{{ 1 + paginationApi.getFirstRowIndex() }} - {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
    " + ); + + + $templateCache.put('ui-grid/columnResizer', + "
    " + ); + + + $templateCache.put('ui-grid/gridFooterSelectedItems', + "({{\"search.selectedItems\" | t}} {{grid.selection.selectedCount}})" + ); + + + $templateCache.put('ui-grid/selectionHeaderCell', + "
    " + ); + + + $templateCache.put('ui-grid/selectionRowHeader', + "
    " + ); + + + $templateCache.put('ui-grid/selectionRowHeaderButtons', + "
     
    " + ); + + + $templateCache.put('ui-grid/selectionSelectAllButtons', + "
    " + ); + + + $templateCache.put('ui-grid/treeBaseExpandAllButtons', + "
    " + ); + + + $templateCache.put('ui-grid/treeBaseHeaderCell', + "
    " + ); + + + $templateCache.put('ui-grid/treeBaseRowHeader', + "
    " + ); + + + $templateCache.put('ui-grid/treeBaseRowHeaderButtons', + "
    -1 }\" ng-click=\"treeButtonClick(row, $event)\">  
    " + ); + + + $templateCache.put('ui-grid/cellTitleValidator', + "
    {{COL_FIELD CUSTOM_FILTERS}}
    " + ); + + + $templateCache.put('ui-grid/cellTooltipValidator', + "
    {{COL_FIELD CUSTOM_FILTERS}}
    " + ); + +}]); diff --git a/release/4.4.11/ui-grid.core.min.js b/release/4.4.11/ui-grid.core.min.js new file mode 100644 index 000000000..62340ebca --- /dev/null +++ b/release/4.4.11/ui-grid.core.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";angular.module("ui.grid.i18n",[]),angular.module("ui.grid",["ui.grid.i18n"])}(),function(){"use strict";angular.module("ui.grid").constant("uiGridConstants",{LOG_DEBUG_MESSAGES:!0,LOG_WARN_MESSAGES:!0,LOG_ERROR_MESSAGES:!0,CUSTOM_FILTERS:/CUSTOM_FILTERS/g,COL_FIELD:/COL_FIELD/g,MODEL_COL_FIELD:/MODEL_COL_FIELD/g,TOOLTIP:/title=\"TOOLTIP\"/g,DISPLAY_CELL_TEMPLATE:/DISPLAY_CELL_TEMPLATE/g,TEMPLATE_REGEXP:/<.+>/,FUNC_REGEXP:/(\([^)]*\))?$/,DOT_REGEXP:/\./g,APOS_REGEXP:/'/g,BRACKET_REGEXP:/^(.*)((?:\s*\[\s*\d+\s*\]\s*)|(?:\s*\[\s*"(?:[^"\\]|\\.)*"\s*\]\s*)|(?:\s*\[\s*'(?:[^'\\]|\\.)*'\s*\]\s*))(.*)$/,COL_CLASS_PREFIX:"ui-grid-col",ENTITY_BINDING:"$$this",events:{GRID_SCROLL:"uiGridScroll",COLUMN_MENU_SHOWN:"uiGridColMenuShown",ITEM_DRAGGING:"uiGridItemDragStart",COLUMN_HEADER_CLICK:"uiGridColumnHeaderClick"},keymap:{TAB:9,STRG:17,CAPSLOCK:20,CTRL:17,CTRLRIGHT:18,CTRLR:18,SHIFT:16,RETURN:13,ENTER:13,BACKSPACE:8,BCKSP:8,ALT:18,ALTR:17,ALTRIGHT:17,SPACE:32,WIN:91,MAC:91,FN:null,PG_UP:33,PG_DOWN:34,UP:38,DOWN:40,LEFT:37,RIGHT:39,ESC:27,DEL:46,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123},ASC:"asc",DESC:"desc",filter:{STARTS_WITH:2,ENDS_WITH:4,EXACT:8,CONTAINS:16,GREATER_THAN:32,GREATER_THAN_OR_EQUAL:64,LESS_THAN:128,LESS_THAN_OR_EQUAL:256,NOT_EQUAL:512,SELECT:"select",INPUT:"input"},aggregationTypes:{sum:2,count:4,avg:8,min:16,max:32},CURRENCY_SYMBOLS:["¤","؋","Ar","Ƀ","฿","B/.","Br","Bs.","Bs.F.","GH₵","¢","c","Ch.","₡","C$","D","ден","دج",".د.ب","د.ع","JD","د.ك","ل.د","дин","د.ت","د.م.","د.إ","Db","$","₫","Esc","€","ƒ","Ft","FBu","FCFA","CFA","Fr","FRw","G","gr","₲","h","₴","₭","Kč","kr","kn","MK","ZK","Kz","K","L","Le","лв","E","lp","M","KM","MT","₥","Nfk","₦","Nu.","UM","T$","MOP$","₱","Pt.","£","ج.م.","LL","LS","P","Q","q","R","R$","ر.ع.","ر.ق","ر.س","៛","RM","p","Rf.","₹","₨","SRe","Rp","₪","Ksh","Sh.So.","USh","S/","SDR","сом","৳\t","WS$","₮","VT","₩","¥","zł"],scrollDirection:{UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",NONE:"none"},dataChange:{ALL:"all",EDIT:"edit",ROW:"row",COLUMN:"column",OPTIONS:"options"},scrollbars:{NEVER:0,ALWAYS:1,WHEN_NEEDED:2}})}(),angular.module("ui.grid").directive("uiGridCell",["$compile","$parse","gridUtil","uiGridConstants",function(l,e,a,c){return{priority:0,scope:!1,require:"?^uiGrid",compile:function(){return{pre:function(t,r,e,i){if(i&&t.col.compiledElementFn)(0,t.col.compiledElementFn)(t,function(e,t){r.append(e)});else if(i&&!t.col.compiledElementFn)t.col.getCompiledElementFn().then(function(e){e(t,function(e,t){r.append(e)})}).catch(angular.noop);else{var n=t.col.cellTemplate.replace(c.MODEL_COL_FIELD,"row.entity."+a.preEval(t.col.field)).replace(c.COL_FIELD,"grid.getCellValue(row, col)"),o=l(n)(t);r.append(o)}},post:function(i,n,e,t){var o,l=i.col.getColClass(!1);n.addClass(l);var a=function(e){var t=n;o&&(t.removeClass(o),o=null),o=angular.isFunction(i.col.cellClass)?i.col.cellClass(i.grid,i.row,i.col,i.rowRenderIndex,i.colRenderIndex):i.col.cellClass,t.addClass(o)};i.col.cellClass&&a();var r=i.grid.registerDataChangeCallback(a,[c.dataChange.COLUMN,c.dataChange.EDIT]),s=i.$watch("row",function(e,t){if(e!==t){(o||i.col.cellClass)&&a();var r=i.col.getColClass(!1);r!==l&&(n.removeClass(l),n.addClass(r),l=r)}}),d=function(){r(),s()};i.$on("$destroy",d),n.on("$destroy",d)}}}}}]),angular.module("ui.grid").service("uiGridColumnMenuService",["i18nService","uiGridConstants","gridUtil",function(e,r,g){var i={initialize:function(e,t){e.grid=t.grid,(t.columnMenuScope=e).menuShown=!1},setColMenuItemWatch:function(t){var e=t.$watch("col.menuItems",function(e){void 0!==e&&e&&angular.isArray(e)?(e.forEach(function(e){void 0!==e.context&&e.context||(e.context={}),e.context.col=t.col}),t.menuItems=t.defaultMenuItems.concat(e)):t.menuItems=t.defaultMenuItems});t.$on("$destroy",e)},sortable:function(e){return!!(e.grid.options.enableSorting&&void 0!==e.col&&e.col&&e.col.enableSorting)},isActiveSort:function(e,t){return void 0!==e.col&&void 0!==e.col.sort&&void 0!==e.col.sort.direction&&e.col.sort.direction===t},suppressRemoveSort:function(e){return!(!e.col||!e.col.suppressRemoveSort)},hideable:function(e){return void 0===e.col||!e.col||!e.col.colDef||!1!==e.col.colDef.enableHiding},getDefaultMenuItems:function(t){return[{title:function(){return e.getSafeText("sort.ascending")},icon:"ui-grid-icon-sort-alt-up",action:function(e){e.stopPropagation(),t.sortColumn(e,r.ASC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.ASC)}},{title:function(){return e.getSafeText("sort.descending")},icon:"ui-grid-icon-sort-alt-down",action:function(e){e.stopPropagation(),t.sortColumn(e,r.DESC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.DESC)}},{title:function(){return e.getSafeText("sort.remove")},icon:"ui-grid-icon-cancel",action:function(e){e.stopPropagation(),t.unsortColumn()},shown:function(){return i.sortable(t)&&void 0!==t.col&&void 0!==t.col.sort&&void 0!==t.col.sort.direction&&null!==t.col.sort.direction&&!i.suppressRemoveSort(t)}},{title:function(){return e.getSafeText("column.hide")},icon:"ui-grid-icon-cancel",shown:function(){return i.hideable(t)},action:function(e){e.stopPropagation(),t.hideColumn()}}]},getColumnElementPosition:function(e,t,r){var i={};return i.left=r[0].offsetLeft,i.top=r[0].offsetTop,i.parentLeft=r[0].offsetParent.offsetLeft,i.offset=0,t.grid.options.offsetLeft&&(i.offset=t.grid.options.offsetLeft),i.height=g.elementHeight(r,!0),i.width=g.elementWidth(r,!0),i},repositionMenu:function(e,t,r,i,n){var o=i[0].querySelectorAll(".ui-grid-menu"),l=g.closestElm(n,".ui-grid-render-container"),a=l.getBoundingClientRect().left-e.grid.element[0].getBoundingClientRect().left,s=l.querySelectorAll(".ui-grid-viewport")[0].scrollLeft,d=g.elementWidth(o,!0),c=t.lastMenuPaddingRight?t.lastMenuPaddingRight:e.lastMenuPaddingRight?e.lastMenuPaddingRight:10;0!==o.length&&0!==o[0].querySelectorAll(".ui-grid-menu-mid").length&&(c=parseInt(g.getStyles(angular.element(o)[0]).paddingRight,10),e.lastMenuPaddingRight=c,t.lastMenuPaddingRight=c);var u=r.left+a-s+r.parentLeft+r.width+c;u(c.grid.rowHeaderColumns?c.grid.rowHeaderColumns.length:0);!r&&!n.uiGridColumns&&0===c.grid.options.columnDefs.length&&0
    ',scope:{side:"=uiGridPinnedContainer"},require:"^uiGrid",compile:function(){return{post:function(n,t,e,r){var o=r.grid,i=0;function l(){if("left"===n.side||"right"===n.side){for(var e=o.renderContainers[n.side].visibleColumnCache,t=0,r=0;r=t&&(t=e.sort.priority+1)}),t},e.prototype.resetColumnSorting=function(t){this.columns.forEach(function(e){e===t||e.suppressRemoveSort||(e.sort={})})},e.prototype.getColumnSorting=function(){var t=[];return this.columns.slice(0).sort(h.prioritySort).forEach(function(e){e.sort&&void 0!==e.sort.direction&&e.sort.direction&&(e.sort.direction===s.ASC||e.sort.direction===s.DESC)&&t.push(e)}),t},e.prototype.sortColumn=function(e,t,r){var i=this,n=null;if(void 0===e||!e)throw new Error("No column parameter provided");if("boolean"==typeof t?r=t:n=t,r?void 0===e.sort.priority&&(e.sort.priority=i.getNextColumnSortPriority()):(i.resetColumnSorting(e),e.sort.priority=void 0,e.sort.priority=i.getNextColumnSortPriority()),n)e.sort.direction=n;else{var o=e.sortDirectionCycle.indexOf(e.sort.direction?e.sort.direction:null);o=(o+1)%e.sortDirectionCycle.length,e.colDef&&e.suppressRemoveSort&&!e.sortDirectionCycle[o]&&(o=(o+1)%e.sortDirectionCycle.length),e.sortDirectionCycle[o]?e.sort.direction=e.sortDirectionCycle[o]:l(e,i)}return i.api.core.raise.sortChanged(i,i.getColumnSorting()),S.when(e)};var l=function(t,e){e.columns.forEach(function(e){e.sort&&void 0!==e.sort.priority&&e.sort.priority>t.sort.priority&&(e.sort.priority-=1)}),t.sort={}};function n(e,t){var r=e/t;return r<=1?r:1}function T(e,t,r){if(n(e,t)!==r)return{percentage:n(e,t)}}function R(e,t,r){var i=e/t;if((i=1Math.ceil(s)&&(c=h-s+r.renderContainers.body.prevScrollTop,i.y=T(c,g,r.renderContainers.body.prevScrolltopPercentage))}if(null!==t){for(var p=o.indexOf(t),f=r.renderContainers.body.getCanvasWidth()-r.renderContainers.body.getViewportWidth(),m=0,v=0;vt&&(e.sort.priority-=1)}),this.sort={},this.grid.api.core.raise.sortChanged(this.grid,this.grid.getColumnSorting())},t.prototype.getColClass=function(e){var t=c.COL_CLASS_PREFIX+this.uid;return e?"."+t:t},t.prototype.isPinnedLeft=function(){return"left"===this.renderContainer},t.prototype.isPinnedRight=function(){return"right"===this.renderContainer},t.prototype.getColClassDefinition=function(){return" .grid"+this.grid.id+" "+this.getColClass(!0)+" { min-width: "+this.drawnWidth+"px; max-width: "+this.drawnWidth+"px; }"},t.prototype.getRenderContainer=function(){var e=this.renderContainer;return null!==e&&""!==e&&void 0!==e||(e="body"),this.grid.renderContainers[e]},t.prototype.showColumn=function(){this.colDef.visible=!0},t.prototype.getAggregationText=function(){if(this.colDef.aggregationHideLabel)return"";if(this.colDef.aggregationLabel)return this.colDef.aggregationLabel;switch(this.colDef.aggregationType){case c.aggregationTypes.count:return e.getSafeText("aggregation.count");case c.aggregationTypes.sum:return e.getSafeText("aggregation.sum");case c.aggregationTypes.avg:return e.getSafeText("aggregation.avg");case c.aggregationTypes.min:return e.getSafeText("aggregation.min");case c.aggregationTypes.max:return e.getSafeText("aggregation.max");default:return""}},t.prototype.getCellTemplate=function(){return this.cellTemplatePromise},t.prototype.getCompiledElementFn=function(){return this.compiledElementFnDefer.promise},t}]),angular.module("ui.grid").factory("GridOptions",["gridUtil","uiGridConstants",function(t,r){return{initialize:function(e){return e.onRegisterApi=e.onRegisterApi||angular.noop(),e.data=e.data||[],e.columnDefs=e.columnDefs||[],e.excludeProperties=e.excludeProperties||["$$hashKey"],e.enableRowHashing=!1!==e.enableRowHashing,e.rowIdentity=e.rowIdentity||function(e){return t.hashKey(e)},e.getRowIdentity=e.getRowIdentity||function(e){return e.$$hashKey},e.flatEntityAccess=!0===e.flatEntityAccess,e.showHeader=void 0===e.showHeader||e.showHeader,e.showHeader?e.headerRowHeight=void 0!==e.headerRowHeight?e.headerRowHeight:30:e.headerRowHeight=0,"string"==typeof e.rowHeight?e.rowHeight=parseInt(e.rowHeight)||30:e.rowHeight=e.rowHeight||30,e.minRowsToShow=void 0!==e.minRowsToShow?e.minRowsToShow:10,e.showGridFooter=!0===e.showGridFooter,e.showColumnFooter=!0===e.showColumnFooter,e.columnFooterHeight=void 0!==e.columnFooterHeight?e.columnFooterHeight:30,e.gridFooterHeight=void 0!==e.gridFooterHeight?e.gridFooterHeight:30,e.columnWidth=void 0!==e.columnWidth?e.columnWidth:50,e.maxVisibleColumnCount=void 0!==e.maxVisibleColumnCount?e.maxVisibleColumnCount:200,e.virtualizationThreshold=void 0!==e.virtualizationThreshold?e.virtualizationThreshold:20,e.columnVirtualizationThreshold=void 0!==e.columnVirtualizationThreshold?e.columnVirtualizationThreshold:10,e.excessRows=void 0!==e.excessRows?e.excessRows:4,e.scrollThreshold=void 0!==e.scrollThreshold?e.scrollThreshold:4,e.excessColumns=void 0!==e.excessColumns?e.excessColumns:4,e.horizontalScrollThreshold=void 0!==e.horizontalScrollThreshold?e.horizontalScrollThreshold:2,e.aggregationCalcThrottle=void 0!==e.aggregationCalcThrottle?e.aggregationCalcThrottle:500,e.wheelScrollThrottle=void 0!==e.wheelScrollThrottle?e.wheelScrollThrottle:70,e.scrollDebounce=void 0!==e.scrollDebounce?e.scrollDebounce:300,e.enableSorting=!1!==e.enableSorting,e.enableFiltering=!0===e.enableFiltering,e.enableColumnMenus=!1!==e.enableColumnMenus,e.enableVerticalScrollbar=void 0!==e.enableVerticalScrollbar?e.enableVerticalScrollbar:r.scrollbars.ALWAYS,e.enableHorizontalScrollbar=void 0!==e.enableHorizontalScrollbar?e.enableHorizontalScrollbar:r.scrollbars.ALWAYS,e.enableMinHeightCheck=!1!==e.enableMinHeightCheck,e.minimumColumnSize=void 0!==e.minimumColumnSize?e.minimumColumnSize:30,e.rowEquality=e.rowEquality||function(e,t){return e===t},e.headerTemplate=e.headerTemplate||null,e.footerTemplate=e.footerTemplate||"ui-grid/ui-grid-footer",e.gridFooterTemplate=e.gridFooterTemplate||"ui-grid/ui-grid-grid-footer",e.rowTemplate=e.rowTemplate||"ui-grid/ui-grid-row",e.gridMenuTemplate=e.gridMenuTemplate||"ui-grid/uiGridMenu",e.appScopeProvider=e.appScopeProvider||null,e}}}]),angular.module("ui.grid").factory("GridRenderContainer",["gridUtil","uiGridConstants",function(y,n){function e(e,t,r){var i=this;i.name=e,i.grid=t,i.visibleRowCache=[],i.visibleColumnCache=[],i.renderedRows=[],i.renderedColumns=[],i.prevScrollTop=0,i.prevScrolltopPercentage=0,i.prevRowScrollIndex=0,i.prevScrollLeft=0,i.prevScrollleftPercentage=0,i.prevColumnScrollIndex=0,i.columnStyles="",i.viewportAdjusters=[],i.hasHScrollbar=!1,i.hasVScrollbar=!1,i.canvasHeightShouldUpdate=!0,i.$$canvasHeight=0,r&&angular.isObject(r)&&angular.extend(i,r),t.registerStyleComputation({priority:5,func:function(){return i.updateColumnWidths(),i.columnStyles}})}return e.prototype.reset=function(){this.visibleColumnCache.length=0,this.visibleRowCache.length=0,this.renderedRows.length=0,this.renderedColumns.length=0},e.prototype.containsColumn=function(e){return-1!==this.visibleColumnCache.indexOf(e)},e.prototype.minRowsToRender=function(){for(var e=0,t=0,r=this.getViewportHeight(),i=this.visibleRowCache.length-1;ti.grid.options.virtualizationThreshold){if(null!=e){if(!i.grid.suppressParentScrollDown&&i.prevScrollTope&&a>i.prevRowScrollIndex-i.grid.options.scrollThreshold&&ar.grid.options.columnVirtualizationThreshold&&r.getCanvasWidth()>r.getViewportWidth())a=[Math.max(0,l-r.grid.options.excessColumns),Math.min(n.length,l+i+r.grid.options.excessColumns)];else{var s=r.visibleColumnCache.length;a=[0,Math.max(s,i+r.grid.options.excessColumns)]}r.updateViewableColumnRange(a),r.prevColumnScrollIndex=l},e.prototype.updateViewableRowRange=function(e){var t=this.visibleRowCache.slice(e[0],e[1]);this.currentTopRow=e[0],this.setRenderedRows(t)},e.prototype.updateViewableColumnRange=function(e){var t=this.visibleColumnCache.slice(e[0],e[1]);this.currentFirstColumn=e[0],this.setRenderedColumns(t)},e.prototype.headerCellWrapperStyle=function(){if(0!==this.currentFirstColumn){var e=this.columnOffset;return this.grid.isRTL()?{"margin-right":e+"px"}:{"margin-left":e+"px"}}return null},e.prototype.updateColumnWidths=function(){var i=this,n=[],o=0,l=0,t="",a=!1,s=[],d=[],c=0,u=i.grid.getViewportWidth()-i.grid.scrollbarWidth,r=[];angular.forEach(i.grid.renderContainers,function(e){r=r.concat(e.visibleColumnCache)}),r.forEach(function(e){var t=0;if(e.visible)if(a&&(u+=i.grid.scrollbarWidth),!a&&e.colDef.pinnedRight&&(a=!0),angular.isNumber(e.width))t=parseInt(e.width,10),l+=t,e.drawnWidth=t,s.push(e);else if(y.endsWith(e.width,"%")){var r=parseInt(e.width.replace(/%/g,""),10);(t=parseInt(r/100*u))>e.maxWidth&&(t=e.maxWidth),te.maxWidth&&(t=e.maxWidth),te.minWidth&&0e.offsetWidth)},e.prototype.getViewportStyle=function(){var e=this,t={},r={};return r[n.scrollbars.ALWAYS]="scroll",r[n.scrollbars.WHEN_NEEDED]="auto",e.hasHScrollbar=!1,e.hasVScrollbar=!1,e.grid.disableScrolling?(t["overflow-x"]="hidden",t["overflow-y"]="hidden"):("body"===e.name?(e.hasHScrollbar=e.grid.options.enableHorizontalScrollbar!==n.scrollbars.NEVER,e.grid.isRTL()?e.grid.hasLeftContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER):e.grid.hasRightContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER)):"left"===e.name?e.hasVScrollbar=!!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER:e.hasVScrollbar=!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER,t["overflow-x"]=e.hasHScrollbar?r[e.grid.options.enableHorizontalScrollbar]:"hidden",t["overflow-y"]=e.hasVScrollbar?r[e.grid.options.enableVerticalScrollbar]:"hidden"),t},e}]),angular.module("ui.grid").factory("GridRow",["gridUtil","uiGridConstants",function(i,t){function e(e,t,r){this.grid=r,this.entity=e,this.uid=i.nextUid(),this.visible=!0,this.isSelected=!1,this.$$height=r.options.rowHeight}return Object.defineProperty(e.prototype,"height",{get:function(){return this.$$height},set:function(e){e!==this.$$height&&(this.grid.updateCanvasHeight(),this.$$height=e)}}),e.prototype.getQualifiedColField=function(e){return"row."+this.getEntityQualifiedColField(e)},e.prototype.getEntityQualifiedColField=function(e){return e.field===t.ENTITY_BINDING?"entity":i.preEval("entity."+e.field)},e.prototype.setRowInvisible=function(e){e&&e.setThisRowInvisible&&e.setThisRowInvisible("user")},e.prototype.clearRowInvisible=function(e){e&&e.clearThisRowInvisible&&e.clearThisRowInvisible("user")},e.prototype.setThisRowInvisible=function(e,t){this.invisibleReason||(this.invisibleReason={}),this.invisibleReason[e]=!0,this.evaluateRowVisibility(t)},e.prototype.clearThisRowInvisible=function(e,t){void 0!==this.invisibleReason&&delete this.invisibleReason[e],this.evaluateRowVisibility(t)},e.prototype.evaluateRowVisibility=function(e){var r=!0;void 0!==this.invisibleReason&&angular.forEach(this.invisibleReason,function(e,t){e&&(r=!1)}),void 0!==this.visible&&this.visible===r||(this.visible=r,e||(this.grid.queueGridRefresh(),this.grid.api.core.raise.rowsVisibleChanged(this)))},e}]),function(){"use strict";angular.module("ui.grid").factory("GridRowColumn",["$parse","$filter",function(e,t){var r=function e(t,r){if(!(this instanceof e))throw"Using GridRowColumn as a function insead of as a constructor. Must be called with `new` keyword";this.row=t,this.col=r};return r.prototype.getIntersectionValueRaw=function(){return e(this.row.getEntityQualifiedColField(this.col))(this.row)},r}])}(),angular.module("ui.grid").factory("ScrollEvent",["gridUtil",function(l){function e(e,t,r,i){var n=this;if(!e)throw new Error("grid argument is required");n.grid=e,n.source=i,n.withDelay=!0,n.sourceRowContainer=t,n.sourceColContainer=r,n.newScrollLeft=null,n.newScrollTop=null,n.x=null,n.y=null,n.verticalScrollLength=-9999999,n.horizontalScrollLength=-999999,n.fireThrottledScrollingEvent=l.throttle(function(e){n.grid.scrollContainers(e,n)},n.grid.options.wheelScrollThrottle,{trailing:!0})}return e.prototype.getNewScrollLeft=function(e,t){var r=this;if(!r.newScrollLeft){var i,n=e.getCanvasWidth()-e.getViewportWidth(),o=l.normalizeScrollLeft(t,r.grid);if(void 0!==r.x.percentage&&void 0!==r.x.percentage)i=r.x.percentage;else{if(void 0===r.x.pixels||void 0===r.x.pixels)throw new Error("No percentage or pixel value provided for scroll event X axis");i=r.x.percentage=(o+r.x.pixels)/n}return Math.max(0,i*n)}return r.newScrollLeft},e.prototype.getNewScrollTop=function(e,t){var r=this;if(!r.newScrollTop){var i,n=e.getVerticalScrollLength(),o=t[0].scrollTop;if(void 0!==r.y.percentage&&void 0!==r.y.percentage)i=r.y.percentage;else{if(void 0===r.y.pixels||void 0===r.y.pixels)throw new Error("No percentage or pixel value provided for scroll event Y axis");i=r.y.percentage=(o+r.y.pixels)/n}return Math.max(0,i*n)}return r.newScrollTop},e.prototype.atTop=function(e){return this.y&&(0===this.y.percentage||this.verticalScrollLength<0)&&0===e},e.prototype.atBottom=function(e){return this.y&&(1===this.y.percentage||0===this.verticalScrollLength)&&0A')[0],r="reverse";return document.body.appendChild(t),0
     
     
    '),e.put("ui-grid/ui-grid-footer",''),e.put("ui-grid/ui-grid-grid-footer",''),e.put("ui-grid/ui-grid-header",'
    \x3c!-- theader --\x3e
    '),e.put("ui-grid/ui-grid-menu-button",'
     
    '),e.put("ui-grid/ui-grid-menu-header-item",'
  • '),e.put("ui-grid/ui-grid-no-header",'
    '),e.put("ui-grid/ui-grid-row","
    "),e.put("ui-grid/ui-grid",'
    \x3c!-- TODO (c0bra): add "scoped" attr here, eventually? --\x3e
    '),e.put("ui-grid/uiGridCell",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/uiGridColumnMenu",'
    \x3c!--
    \n
    \n
      \n
      \n
    • Sort Ascending
    • \n
    • Sort Descending
    • \n
    • Remove Sort
    • \n
      \n
    \n
    \n
    --\x3e
    '),e.put("ui-grid/uiGridFooterCell",'
    {{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}
    '),e.put("ui-grid/uiGridHeaderCell",'
    {{ col.displayName CUSTOM_FILTERS }} {{col.sort.priority + 1}}
    '),e.put("ui-grid/uiGridMenu",'
    '),e.put("ui-grid/uiGridMenuItem",''),e.put("ui-grid/uiGridRenderContainer","
    \x3c!-- All of these dom elements are replaced in place --\x3e
    "),e.put("ui-grid/uiGridViewport",'
    \x3c!-- tbody --\x3e
    '),e.put("ui-grid/cellEditor",'
    '),e.put("ui-grid/dropdownEditor",'
    '),e.put("ui-grid/fileChooserEditor",'
    '),e.put("ui-grid/emptyBaseLayerContainer",'
    '),e.put("ui-grid/expandableRow",'
    '),e.put("ui-grid/expandableRowHeader",'
    '),e.put("ui-grid/expandableScrollFiller","
    "),e.put("ui-grid/expandableTopRowHeader",'
    '),e.put("ui-grid/csvLink",'LINK_LABEL'),e.put("ui-grid/importerMenuItem",'
  • '),e.put("ui-grid/importerMenuItemContainer","
    "),e.put("ui-grid/pagination",'
    {{ 1 + paginationApi.getFirstRowIndex() }} - {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
    '),e.put("ui-grid/columnResizer",'
    '),e.put("ui-grid/gridFooterSelectedItems",'({{"search.selectedItems" | t}} {{grid.selection.selectedCount}})'),e.put("ui-grid/selectionHeaderCell",'
    \x3c!--
     
    --\x3e
    '),e.put("ui-grid/selectionRowHeader",'
    '),e.put("ui-grid/selectionRowHeaderButtons",''),e.put("ui-grid/selectionSelectAllButtons",'
    '),e.put("ui-grid/treeBaseExpandAllButtons",'
    '),e.put("ui-grid/treeBaseHeaderCell",'
    '),e.put("ui-grid/treeBaseRowHeader",'
    '),e.put("ui-grid/treeBaseRowHeaderButtons",'
     
    '),e.put("ui-grid/cellTitleValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/cellTooltipValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    ')}]); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.css b/release/4.4.11/ui-grid.css new file mode 100644 index 000000000..87e7ef1d4 --- /dev/null +++ b/release/4.4.11/ui-grid.css @@ -0,0 +1,1922 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ +@media screen and (max-width: 767px) { +} +@media (min-width: 768px) { +} +.ui-grid { + border: 1px solid #d4d4d4; + box-sizing: content-box; + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; + -webkit-transform: translateZ(0); + -moz-transform: translateZ(0); + -o-transform: translateZ(0); + -ms-transform: translateZ(0); + transform: translateZ(0); +} +.ui-grid-vertical-bar { + position: absolute; + right: 0; + width: 0; +} +.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar, +.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar { + width: 1px; +} +.ui-grid-scrollbar-placeholder { + background-color: transparent; +} +.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar { + background-color: #d4d4d4; +} +.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar { + background-color: #d4d4d4; +} +.ui-grid-header-cell:last-child .ui-grid-vertical-bar { + right: -1px; + width: 1px; + background-color: #d4d4d4; +} +.ui-grid-clearfix:before, +.ui-grid-clearfix:after { + content: ""; + display: table; +} +.ui-grid-clearfix:after { + clear: both; +} +.ui-grid-invisible { + visibility: hidden; +} +.ui-grid-contents-wrapper { + position: relative; + height: 100%; + width: 100%; +} +.ui-grid-sr-only { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip: rect(0, 0, 0, 0); + border: 0; +} +.ui-grid-icon-button { + background-color: transparent; + border: none; + padding: 0; +} +.ui-grid-top-panel-background { + background-color: #f3f3f3; +} +.ui-grid-header { + border-bottom: 1px solid #d4d4d4; + box-sizing: border-box; +} +.ui-grid-top-panel { + position: relative; + overflow: hidden; + font-weight: bold; + background-color: #f3f3f3; + -webkit-border-top-right-radius: -1px; + -webkit-border-bottom-right-radius: 0; + -webkit-border-bottom-left-radius: 0; + -webkit-border-top-left-radius: -1px; + -moz-border-radius-topright: -1px; + -moz-border-radius-bottomright: 0; + -moz-border-radius-bottomleft: 0; + -moz-border-radius-topleft: -1px; + border-top-right-radius: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; + border-top-left-radius: -1px; + -moz-background-clip: padding-box; + -webkit-background-clip: padding-box; + background-clip: padding-box; +} +.ui-grid-header-viewport { + overflow: hidden; +} +.ui-grid-header-canvas:before, +.ui-grid-header-canvas:after { + content: ""; + display: table; + line-height: 0; +} +.ui-grid-header-canvas:after { + clear: both; +} +.ui-grid-header-cell-wrapper { + position: relative; + display: table; + box-sizing: border-box; + height: 100%; +} +.ui-grid-header-cell-row { + display: table-row; +} +.ui-grid-header-cell { + position: relative; + box-sizing: border-box; + background-color: inherit; + border-right: 1px solid; + border-color: #d4d4d4; + display: table-cell; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + width: 0; +} +.ui-grid-header-cell:last-child { + border-right: 0; +} +.ui-grid-header-cell .sortable { + cursor: pointer; +} +.ui-grid-header-cell .ui-grid-sort-priority-number { + margin-left: -8px; +} +.ui-grid-header .ui-grid-vertical-bar { + top: 0; + bottom: 0; +} +.ui-grid-column-menu-button { + position: absolute; + right: 1px; + top: 0; +} +.ui-grid-column-menu-button .ui-grid-icon-angle-down { + vertical-align: sub; +} +.ui-grid-header-cell-last-col .ui-grid-cell-contents, +.ui-grid-header-cell-last-col .ui-grid-filter-container, +.ui-grid-header-cell-last-col .ui-grid-column-menu-button, +.ui-grid-header-cell-last-col + .ui-grid-column-resizer.right { + margin-right: 13px; +} +.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-cell-contents, +.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-filter-container, +.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-column-menu-button, +.ui-grid-render-container-right .ui-grid-header-cell-last-col + .ui-grid-column-resizer.right { + margin-right: 28px; +} +.ui-grid-column-menu { + position: absolute; +} +/* Slide up/down animations */ +.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add, +.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove { + -webkit-transition: all 0.04s linear; + -moz-transition: all 0.04s linear; + -o-transition: all 0.04s linear; + transition: all 0.04s linear; + display: block !important; +} +.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add.ng-hide-add-active, +.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove { + -webkit-transform: translateY(-100%); + -moz-transform: translateY(-100%); + -o-transform: translateY(-100%); + -ms-transform: translateY(-100%); + transform: translateY(-100%); +} +.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add, +.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove.ng-hide-remove-active { + -webkit-transform: translateY(0); + -moz-transform: translateY(0); + -o-transform: translateY(0); + -ms-transform: translateY(0); + transform: translateY(0); +} +/* Slide up/down animations */ +.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add, +.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove { + -webkit-transition: all 0.04s linear; + -moz-transition: all 0.04s linear; + -o-transition: all 0.04s linear; + transition: all 0.04s linear; + display: block !important; +} +.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add.ng-hide-add-active, +.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove { + -webkit-transform: translateY(-100%); + -moz-transform: translateY(-100%); + -o-transform: translateY(-100%); + -ms-transform: translateY(-100%); + transform: translateY(-100%); +} +.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add, +.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove.ng-hide-remove-active { + -webkit-transform: translateY(0); + -moz-transform: translateY(0); + -o-transform: translateY(0); + -ms-transform: translateY(0); + transform: translateY(0); +} +.ui-grid-filter-container { + padding: 4px 10px; + position: relative; +} +.ui-grid-filter-container .ui-grid-filter-button { + position: absolute; + top: 0; + bottom: 0; + right: 0; +} +.ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"] { + position: absolute; + top: 50%; + line-height: 32px; + margin-top: -16px; + right: 10px; + opacity: 0.66; +} +.ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"]:hover { + opacity: 1; +} +.ui-grid-filter-container .ui-grid-filter-button-select { + position: absolute; + top: 0; + bottom: 0; + right: 0; +} +.ui-grid-filter-container .ui-grid-filter-button-select [class^="ui-grid-icon"] { + position: absolute; + top: 50%; + line-height: 32px; + margin-top: -16px; + right: 0px; + opacity: 0.66; +} +.ui-grid-filter-container .ui-grid-filter-button-select [class^="ui-grid-icon"]:hover { + opacity: 1; +} +input[type="text"].ui-grid-filter-input { + box-sizing: border-box; + padding: 0 18px 0 0; + margin: 0; + border: 0; + width: 100%; + border: 1px solid #d4d4d4; + -webkit-border-top-right-radius: 0px; + -webkit-border-bottom-right-radius: 0; + -webkit-border-bottom-left-radius: 0; + -webkit-border-top-left-radius: 0; + -moz-border-radius-topright: 0px; + -moz-border-radius-bottomright: 0; + -moz-border-radius-bottomleft: 0; + -moz-border-radius-topleft: 0; + border-top-right-radius: 0px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; + border-top-left-radius: 0; + -moz-background-clip: padding-box; + -webkit-background-clip: padding-box; + background-clip: padding-box; +} +input[type="text"].ui-grid-filter-input:hover { + border: 1px solid #d4d4d4; +} +select.ui-grid-filter-select { + padding: 0; + margin: 0; + border: 0; + width: 90%; + border: 1px solid #d4d4d4; + -webkit-border-top-right-radius: 0px; + -webkit-border-bottom-right-radius: 0; + -webkit-border-bottom-left-radius: 0; + -webkit-border-top-left-radius: 0; + -moz-border-radius-topright: 0px; + -moz-border-radius-bottomright: 0; + -moz-border-radius-bottomleft: 0; + -moz-border-radius-topleft: 0; + border-top-right-radius: 0px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; + border-top-left-radius: 0; + -moz-background-clip: padding-box; + -webkit-background-clip: padding-box; + background-clip: padding-box; +} +select.ui-grid-filter-select:hover { + border: 1px solid #d4d4d4; +} +.ui-grid-filter-cancel-button-hidden select.ui-grid-filter-select { + width: 100%; +} +.ui-grid-render-container { + position: inherit; + -webkit-border-top-right-radius: 0; + -webkit-border-bottom-right-radius: 0px; + -webkit-border-bottom-left-radius: 0px; + -webkit-border-top-left-radius: 0; + -moz-border-radius-topright: 0; + -moz-border-radius-bottomright: 0px; + -moz-border-radius-bottomleft: 0px; + -moz-border-radius-topleft: 0; + border-top-right-radius: 0; + border-bottom-right-radius: 0px; + border-bottom-left-radius: 0px; + border-top-left-radius: 0; + -moz-background-clip: padding-box; + -webkit-background-clip: padding-box; + background-clip: padding-box; +} +.ui-grid-render-container:focus { + outline: none; +} +.ui-grid-viewport { + min-height: 20px; + position: relative; + overflow-y: scroll; + -webkit-overflow-scrolling: touch; +} +.ui-grid-viewport:focus { + outline: none !important; +} +.ui-grid-canvas { + position: relative; + padding-top: 1px; +} +.ui-grid-row { + clear: both; +} +.ui-grid-row:nth-child(odd) .ui-grid-cell { + background-color: #fdfdfd; +} +.ui-grid-row:nth-child(even) .ui-grid-cell { + background-color: #f3f3f3; +} +.ui-grid-row:last-child .ui-grid-cell { + border-bottom-color: #d4d4d4; + border-bottom-style: solid; +} +.ui-grid-no-row-overlay { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: 10%; + background-color: #f3f3f3; + -webkit-border-top-right-radius: 0px; + -webkit-border-bottom-right-radius: 0; + -webkit-border-bottom-left-radius: 0; + -webkit-border-top-left-radius: 0; + -moz-border-radius-topright: 0px; + -moz-border-radius-bottomright: 0; + -moz-border-radius-bottomleft: 0; + -moz-border-radius-topleft: 0; + border-top-right-radius: 0px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; + border-top-left-radius: 0; + -moz-background-clip: padding-box; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #d4d4d4; + font-size: 2em; + text-align: center; +} +.ui-grid-no-row-overlay > * { + position: absolute; + display: table; + margin: auto 0; + width: 100%; + top: 0; + bottom: 0; + left: 0; + right: 0; + opacity: 0.66; +} +.ui-grid-cell { + overflow: hidden; + float: left; + background-color: inherit; + border-right: 1px solid; + border-color: #d4d4d4; + box-sizing: border-box; +} +.ui-grid-cell:last-child { + border-right: 0; +} +.ui-grid-cell-contents { + padding: 5px; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + white-space: nowrap; + -ms-text-overflow: ellipsis; + -o-text-overflow: ellipsis; + text-overflow: ellipsis; + overflow: hidden; + height: 100%; +} +.ui-grid-cell-contents-hidden { + visibility: hidden; + width: 0; + height: 0; + display: none; +} +.ui-grid-row .ui-grid-cell.ui-grid-row-header-cell { + background-color: #F0F0EE; + border-bottom: solid 1px #d4d4d4; +} +.ui-grid-cell-empty { + display: inline-block; + width: 10px; + height: 10px; +} +.ui-grid-footer-info { + padding: 5px 10px; +} +.ui-grid-footer-panel-background { + background-color: #f3f3f3; +} +.ui-grid-footer-panel { + position: relative; + border-bottom: 1px solid #d4d4d4; + border-top: 1px solid #d4d4d4; + overflow: hidden; + font-weight: bold; + background-color: #f3f3f3; + -webkit-border-top-right-radius: -1px; + -webkit-border-bottom-right-radius: 0; + -webkit-border-bottom-left-radius: 0; + -webkit-border-top-left-radius: -1px; + -moz-border-radius-topright: -1px; + -moz-border-radius-bottomright: 0; + -moz-border-radius-bottomleft: 0; + -moz-border-radius-topleft: -1px; + border-top-right-radius: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; + border-top-left-radius: -1px; + -moz-background-clip: padding-box; + -webkit-background-clip: padding-box; + background-clip: padding-box; +} +.ui-grid-grid-footer { + float: left; + width: 100%; +} +.ui-grid-footer-viewport, +.ui-grid-footer-canvas { + display: flex; + flex: 1 1 auto; + height: 100%; +} +.ui-grid-footer-viewport { + overflow: hidden; +} +.ui-grid-footer-canvas { + position: relative; +} +.ui-grid-footer-canvas:before, +.ui-grid-footer-canvas:after { + content: ""; + display: table; + line-height: 0; +} +.ui-grid-footer-canvas:after { + clear: both; +} +.ui-grid-footer-cell-wrapper { + position: relative; + display: table; + box-sizing: border-box; + height: 100%; +} +.ui-grid-footer-cell-row { + display: table-row; +} +.ui-grid-footer-cell { + overflow: hidden; + background-color: inherit; + border-right: 1px solid; + border-color: #d4d4d4; + box-sizing: border-box; + display: table-cell; +} +.ui-grid-footer-cell:last-child { + border-right: 0; +} +.ui-grid-menu-button { + z-index: 2; + position: absolute; + right: 0; + top: 0; + background: #f3f3f3; + border: 0; + border-left: 1px solid #d4d4d4; + border-bottom: 1px solid #d4d4d4; + cursor: pointer; + height: 32px; + font-weight: normal; +} +.ui-grid-menu-button .ui-grid-icon-container { + margin-top: 5px; + margin-left: 2px; +} +.ui-grid-menu-button .ui-grid-menu { + right: 0; +} +.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid { + overflow: scroll; +} +.ui-grid-menu { + overflow: hidden; + max-width: 320px; + z-index: 2; + position: absolute; + right: 100%; + padding: 0 10px 20px 10px; + cursor: pointer; + box-sizing: border-box; +} +.ui-grid-menu-item { + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.ui-grid-menu .ui-grid-menu-inner { + background: #fff; + border: 1px solid #d4d4d4; + position: relative; + white-space: nowrap; + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; +} +.ui-grid-menu .ui-grid-menu-inner ul { + margin: 0; + padding: 0; + list-style-type: none; +} +.ui-grid-menu .ui-grid-menu-inner ul li { + padding: 0; +} +.ui-grid-menu .ui-grid-menu-inner ul li .ui-grid-menu-item { + color: #000; + min-width: 100%; + padding: 8px; + text-align: left; + background: transparent; + border: none; + cursor: default; +} +.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item { + cursor: pointer; +} +.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item:hover, +.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item:focus { + background-color: #b3c4c7; +} +.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item.ui-grid-menu-item-active { + background-color: #9cb2b6; +} +.ui-grid-menu .ui-grid-menu-inner ul li:not(:last-child) > .ui-grid-menu-item { + border-bottom: 1px solid #d4d4d4; +} +.ui-grid-sortarrow { + right: 5px; + position: absolute; + width: 20px; + top: 0; + bottom: 0; + background-position: center; +} +.ui-grid-sortarrow.down { + -webkit-transform: rotate(180deg); + -moz-transform: rotate(180deg); + -o-transform: rotate(180deg); + -ms-transform: rotate(180deg); + transform: rotate(180deg); +} +@font-face { + font-family: 'ui-grid'; + src: url('ui-grid.eot'); + src: url('ui-grid.eot#iefix') format('embedded-opentype'), url('ui-grid.woff') format('woff'), url('ui-grid.ttf') format('truetype'), url('ui-grid.svg?#ui-grid') format('svg'); + font-weight: normal; + font-style: normal; +} +/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */ +/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */ +/* +@media screen and (-webkit-min-device-pixel-ratio:0) { + @font-face { + font-family: 'ui-grid'; + src: url('@{font-path}ui-grid.svg?12312827#ui-grid') format('svg'); + } +} +*/ +[class^="ui-grid-icon"]:before, +[class*=" ui-grid-icon"]:before { + font-family: "ui-grid"; + font-style: normal; + font-weight: normal; + speak: none; + display: inline-block; + text-decoration: inherit; + width: 1em; + margin-right: .2em; + text-align: center; + /* opacity: .8; */ + /* For safety - reset parent styles, that can break glyph codes*/ + font-variant: normal; + text-transform: none; + /* fix buttons height, for twitter bootstrap */ + line-height: 1em; + /* Animation center compensation - margins should be symmetric */ + /* remove if not needed */ + margin-left: .2em; + /* you can be more comfortable with increased icons size */ + /* font-size: 120%; */ + /* Uncomment for 3D effect */ + /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ +} +.ui-grid-icon-blank::before { + width: 1em; + content: ' '; +} +.ui-grid-icon-plus-squared:before { + content: '\c350'; +} +.ui-grid-icon-minus-squared:before { + content: '\c351'; +} +.ui-grid-icon-search:before { + content: '\c352'; +} +.ui-grid-icon-cancel:before { + content: '\c353'; +} +.ui-grid-icon-info-circled:before { + content: '\c354'; +} +.ui-grid-icon-lock:before { + content: '\c355'; +} +.ui-grid-icon-lock-open:before { + content: '\c356'; +} +.ui-grid-icon-pencil:before { + content: '\c357'; +} +.ui-grid-icon-down-dir:before { + content: '\c358'; +} +.ui-grid-icon-up-dir:before { + content: '\c359'; +} +.ui-grid-icon-left-dir:before { + content: '\c35a'; +} +.ui-grid-icon-right-dir:before { + content: '\c35b'; +} +.ui-grid-icon-left-open:before { + content: '\c35c'; +} +.ui-grid-icon-right-open:before { + content: '\c35d'; +} +.ui-grid-icon-angle-down:before { + content: '\c35e'; +} +.ui-grid-icon-filter:before { + content: '\c35f'; +} +.ui-grid-icon-sort-alt-up:before { + content: '\c360'; +} +.ui-grid-icon-sort-alt-down:before { + content: '\c361'; +} +.ui-grid-icon-ok:before { + content: '\c362'; +} +.ui-grid-icon-menu:before { + content: '\c363'; +} +.ui-grid-icon-indent-left:before { + content: '\e800'; +} +.ui-grid-icon-indent-right:before { + content: '\e801'; +} +.ui-grid-icon-spin5:before { + content: '\ea61'; +} +/* +* RTL Styles +*/ +.ui-grid[dir=rtl] .ui-grid-header-cell, +.ui-grid[dir=rtl] .ui-grid-footer-cell, +.ui-grid[dir=rtl] .ui-grid-cell { + float: right !important; +} +.ui-grid[dir=rtl] .ui-grid-column-menu-button { + position: absolute; + left: 1px; + top: 0; + right: inherit; +} +.ui-grid[dir=rtl] .ui-grid-cell:first-child, +.ui-grid[dir=rtl] .ui-grid-header-cell:first-child, +.ui-grid[dir=rtl] .ui-grid-footer-cell:first-child { + border-right: 0; +} +.ui-grid[dir=rtl] .ui-grid-cell:last-child, +.ui-grid[dir=rtl] .ui-grid-header-cell:last-child { + border-right: 1px solid #d4d4d4; + border-left: 0; +} +.ui-grid[dir=rtl] .ui-grid-header-cell:first-child .ui-grid-vertical-bar, +.ui-grid[dir=rtl] .ui-grid-footer-cell:first-child .ui-grid-vertical-bar, +.ui-grid[dir=rtl] .ui-grid-cell:first-child .ui-grid-vertical-bar { + width: 0; +} +.ui-grid[dir=rtl] .ui-grid-menu-button { + z-index: 2; + position: absolute; + left: 0; + right: auto; + background: #f3f3f3; + border: 1px solid #d4d4d4; + cursor: pointer; + min-height: 27px; + font-weight: normal; +} +.ui-grid[dir=rtl] .ui-grid-menu-button .ui-grid-menu { + left: 0; + right: auto; +} +.ui-grid[dir=rtl] .ui-grid-filter-container .ui-grid-filter-button { + right: initial; + left: 0; +} +.ui-grid[dir=rtl] .ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"] { + right: initial; + left: 10px; +} +/* + Animation example, for spinners +*/ +.ui-grid-animate-spin { + -moz-animation: ui-grid-spin 2s infinite linear; + -o-animation: ui-grid-spin 2s infinite linear; + -webkit-animation: ui-grid-spin 2s infinite linear; + animation: ui-grid-spin 2s infinite linear; + display: inline-block; +} +@-moz-keyframes ui-grid-spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@-webkit-keyframes ui-grid-spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@-o-keyframes ui-grid-spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@-ms-keyframes ui-grid-spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@keyframes ui-grid-spin { + 0% { + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -moz-transform: rotate(359deg); + -o-transform: rotate(359deg); + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +/*--------------------------------------------------- + LESS Elements 0.9 + --------------------------------------------------- + A set of useful LESS mixins + More info at: http://lesselements.com + ---------------------------------------------------*/ +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +@media screen and (max-width: 767px) { +} +@media (min-width: 768px) { +} +.ui-grid-cell-focus { + outline: 0; + background-color: #b3c4c7; +} +.ui-grid-focuser { + position: absolute; + left: 0px; + top: 0px; + z-index: -1; + width: 100%; + height: 100%; +} +.ui-grid-focuser:focus { + border-color: #66afe9; + outline: 0; + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); + box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); +} +.ui-grid-offscreen { + display: block; + position: absolute; + left: -10000px; + top: -10000px; + clip: rect(0px, 0px, 0px, 0px); +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-cell input { + border-radius: inherit; + padding: 0; + width: 100%; + color: inherit; + height: auto; + font: inherit; + outline: none; +} +.ui-grid-cell input:focus { + color: inherit; + outline: none; +} +.ui-grid-cell input[type="checkbox"] { + margin: 9px 0 0 6px; + width: auto; +} +.ui-grid-cell input.ng-invalid { + border: 1px solid #fc8f8f; +} +.ui-grid-cell input.ng-valid { + border: 1px solid #d4d4d4; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-viewport .ui-grid-empty-base-layer-container { + position: absolute; + overflow: hidden; + pointer-events: none; + z-index: -1; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.expandableRow .ui-grid-row:nth-child(odd) .ui-grid-cell { + background-color: #fdfdfd; +} +.expandableRow .ui-grid-row:nth-child(even) .ui-grid-cell { + background-color: #f3f3f3; +} +.ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell { + pointer-events: none; +} +.ui-grid-expandable-buttons-cell i { + pointer-events: all; +} +.scrollFiller { + float: left; + border: 1px solid #d4d4d4; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-tree-header-row { + font-weight: bold !important; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.movingColumn { + position: absolute; + top: 0; + border: 1px solid #d4d4d4; + box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.2); +} +.movingColumn .ui-grid-icon-angle-down { + display: none; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/*--------------------------------------------------- + LESS Elements 0.9 + --------------------------------------------------- + A set of useful LESS mixins + More info at: http://lesselements.com + ---------------------------------------------------*/ +@media screen and (max-width: 767px) { +} +@media (min-width: 768px) { +} +.ui-grid-pager-panel { + display: flex; + justify-content: space-between; + align-items: center; + position: absolute; + left: 0; + bottom: 0; + width: 100%; + padding-top: 3px; + padding-bottom: 3px; + box-sizing: content-box; +} +.ui-grid-pager-container { + float: left; +} +.ui-grid-pager-control { + padding: 5px 0; + display: flex; + flex-flow: row nowrap; + align-items: center; + margin-right: 10px; + margin-left: 10px; + min-width: 135px; + float: left; +} +.ui-grid-pager-control button, +.ui-grid-pager-control span, +.ui-grid-pager-control input { + margin-right: 4px; +} +.ui-grid-pager-control button { + height: 25px; + min-width: 26px; + display: inline-block; + margin-bottom: 0; + font-weight: normal; + text-align: center; + vertical-align: middle; + touch-action: manipulation; + cursor: pointer; + background-image: none; + border: 1px solid transparent; + white-space: nowrap; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857143; + border-radius: 4px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + color: #eee; + background-color: #f3f3f3; + border-color: #ccc; +} +.ui-grid-pager-control button:focus, +.ui-grid-pager-control button:active:focus, +.ui-grid-pager-control button.active:focus, +.ui-grid-pager-control button.focus, +.ui-grid-pager-control button:active.focus, +.ui-grid-pager-control button.active.focus { + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} +.ui-grid-pager-control button:hover, +.ui-grid-pager-control button:focus, +.ui-grid-pager-control button.focus { + color: #333; + text-decoration: none; +} +.ui-grid-pager-control button:active, +.ui-grid-pager-control button.active { + outline: 0; + background-image: none; + -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); + box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); +} +.ui-grid-pager-control button.disabled, +.ui-grid-pager-control button[disabled], +fieldset[disabled] .ui-grid-pager-control button { + cursor: not-allowed; + opacity: 0.65; + filter: alpha(opacity=65); + -webkit-box-shadow: none; + box-shadow: none; +} +a.ui-grid-pager-control button.disabled, +fieldset[disabled] a.ui-grid-pager-control button { + pointer-events: none; +} +.ui-grid-pager-control button:focus, +.ui-grid-pager-control button.focus { + color: #eee; + background-color: #dadada; + border-color: #8c8c8c; +} +.ui-grid-pager-control button:hover { + color: #eee; + background-color: #dadada; + border-color: #adadad; +} +.ui-grid-pager-control button:active, +.ui-grid-pager-control button.active, +.open > .dropdown-toggle.ui-grid-pager-control button { + color: #eee; + background-color: #dadada; + border-color: #adadad; +} +.ui-grid-pager-control button:active:hover, +.ui-grid-pager-control button.active:hover, +.open > .dropdown-toggle.ui-grid-pager-control button:hover, +.ui-grid-pager-control button:active:focus, +.ui-grid-pager-control button.active:focus, +.open > .dropdown-toggle.ui-grid-pager-control button:focus, +.ui-grid-pager-control button:active.focus, +.ui-grid-pager-control button.active.focus, +.open > .dropdown-toggle.ui-grid-pager-control button.focus { + color: #eee; + background-color: #c8c8c8; + border-color: #8c8c8c; +} +.ui-grid-pager-control button:active, +.ui-grid-pager-control button.active, +.open > .dropdown-toggle.ui-grid-pager-control button { + background-image: none; +} +.ui-grid-pager-control button.disabled:hover, +.ui-grid-pager-control button[disabled]:hover, +fieldset[disabled] .ui-grid-pager-control button:hover, +.ui-grid-pager-control button.disabled:focus, +.ui-grid-pager-control button[disabled]:focus, +fieldset[disabled] .ui-grid-pager-control button:focus, +.ui-grid-pager-control button.disabled.focus, +.ui-grid-pager-control button[disabled].focus, +fieldset[disabled] .ui-grid-pager-control button.focus { + background-color: #f3f3f3; + border-color: #ccc; +} +.ui-grid-pager-control button .badge { + color: #f3f3f3; + background-color: #eee; +} +.ui-grid-pager-control input { + display: block; + width: 100%; + height: 34px; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857143; + color: #555555; + background-color: #fff; + background-image: none; + border: 1px solid #ccc; + border-radius: 4px; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + height: 30px; + padding: 5px 10px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; + display: inline; + height: 26px; + width: 50px; + vertical-align: top; +} +.ui-grid-pager-control input:focus { + border-color: #66afe9; + outline: 0; + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); + box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); +} +.ui-grid-pager-control input::-moz-placeholder { + color: #999; + opacity: 1; +} +.ui-grid-pager-control input:-ms-input-placeholder { + color: #999; +} +.ui-grid-pager-control input::-webkit-input-placeholder { + color: #999; +} +.ui-grid-pager-control input::-ms-expand { + border: 0; + background-color: transparent; +} +.ui-grid-pager-control input[disabled], +.ui-grid-pager-control input[readonly], +fieldset[disabled] .ui-grid-pager-control input { + background-color: #eeeeee; + opacity: 1; +} +.ui-grid-pager-control input[disabled], +fieldset[disabled] .ui-grid-pager-control input { + cursor: not-allowed; +} +textarea.ui-grid-pager-control input { + height: auto; +} +select.ui-grid-pager-control input { + height: 30px; + line-height: 30px; +} +textarea.ui-grid-pager-control input, +select[multiple].ui-grid-pager-control input { + height: auto; +} +.ui-grid-pager-control .ui-grid-pager-max-pages-number { + vertical-align: bottom; +} +.ui-grid-pager-control .ui-grid-pager-max-pages-number > * { + vertical-align: bottom; +} +.ui-grid-pager-control .ui-grid-pager-max-pages-number abbr { + border-bottom: none; + text-decoration: none; +} +.ui-grid-pager-control .first-bar { + width: 10px; + border-left: 2px solid #4d4d4d; + margin-top: -6px; + height: 12px; + margin-left: -3px; +} +.ui-grid-pager-control .first-bar-rtl { + width: 10px; + border-left: 2px solid #4d4d4d; + margin-top: -6px; + height: 12px; + margin-right: -7px; +} +.ui-grid-pager-control .first-triangle { + width: 0; + height: 0; + border-style: solid; + border-width: 5px 8.7px 5px 0; + border-color: transparent #4d4d4d transparent transparent; + margin-left: 2px; +} +.ui-grid-pager-control .next-triangle { + margin-left: 1px; +} +.ui-grid-pager-control .prev-triangle { + margin-left: 0; +} +.ui-grid-pager-control .last-triangle { + width: 0; + height: 0; + border-style: solid; + border-width: 5px 0 5px 8.7px; + border-color: transparent transparent transparent #4d4d4d; + margin-left: -1px; +} +.ui-grid-pager-control .last-bar { + width: 10px; + border-left: 2px solid #4d4d4d; + margin-top: -6px; + height: 12px; + margin-left: 1px; +} +.ui-grid-pager-control .last-bar-rtl { + width: 10px; + border-left: 2px solid #4d4d4d; + margin-top: -6px; + height: 12px; + margin-right: -11px; +} +.ui-grid-pager-row-count-picker { + float: left; + padding: 5px 10px; +} +.ui-grid-pager-row-count-picker select { + display: block; + width: 100%; + height: 34px; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857143; + color: #555555; + background-color: #fff; + background-image: none; + border: 1px solid #ccc; + border-radius: 4px; + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + height: 30px; + padding: 5px 10px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; + height: 25px; + width: 67px; + display: inline; + vertical-align: middle; +} +.ui-grid-pager-row-count-picker select:focus { + border-color: #66afe9; + outline: 0; + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); + box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6); +} +.ui-grid-pager-row-count-picker select::-moz-placeholder { + color: #999; + opacity: 1; +} +.ui-grid-pager-row-count-picker select:-ms-input-placeholder { + color: #999; +} +.ui-grid-pager-row-count-picker select::-webkit-input-placeholder { + color: #999; +} +.ui-grid-pager-row-count-picker select::-ms-expand { + border: 0; + background-color: transparent; +} +.ui-grid-pager-row-count-picker select[disabled], +.ui-grid-pager-row-count-picker select[readonly], +fieldset[disabled] .ui-grid-pager-row-count-picker select { + background-color: #eeeeee; + opacity: 1; +} +.ui-grid-pager-row-count-picker select[disabled], +fieldset[disabled] .ui-grid-pager-row-count-picker select { + cursor: not-allowed; +} +textarea.ui-grid-pager-row-count-picker select { + height: auto; +} +select.ui-grid-pager-row-count-picker select { + height: 30px; + line-height: 30px; +} +textarea.ui-grid-pager-row-count-picker select, +select[multiple].ui-grid-pager-row-count-picker select { + height: auto; +} +.ui-grid-pager-row-count-picker .ui-grid-pager-row-count-label { + margin-top: 3px; +} +.ui-grid-pager-count-container { + float: right; + margin-top: 4px; + min-width: 50px; +} +.ui-grid-pager-count-container .ui-grid-pager-count { + margin-right: 10px; + margin-left: 10px; + float: right; +} +.ui-grid-pager-count-container .ui-grid-pager-count abbr { + border-bottom: none; + text-decoration: none; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-pinned-container { + position: absolute; + display: inline; + top: 0; +} +.ui-grid-pinned-container.ui-grid-pinned-container-left { + float: left; + left: 0; +} +.ui-grid-pinned-container.ui-grid-pinned-container-right { + float: right; + right: 0; +} +.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:last-child { + box-sizing: border-box; + border-right: 1px solid; + border-width: 1px; + border-right-color: #aeaeae; +} +.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-cell:last-child { + box-sizing: border-box; + border-right: 1px solid; + border-width: 1px; + border-right-color: #aeaeae; +} +.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar, +.ui-grid-pinned-container .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar { + width: 1px; +} +.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar { + background-color: #d4d4d4; +} +.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar { + background-color: #aeaeae; +} +.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:last-child .ui-grid-vertical-bar { + right: -1px; + width: 1px; + background-color: #aeaeae; +} +.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:first-child { + box-sizing: border-box; + border-left: 1px solid; + border-width: 1px; + border-left-color: #aeaeae; +} +.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-cell:first-child { + box-sizing: border-box; + border-left: 1px solid; + border-width: 1px; + border-left-color: #aeaeae; +} +.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar, +.ui-grid-pinned-container .ui-grid-cell:not(:first-child) .ui-grid-vertical-bar { + width: 1px; +} +.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar { + background-color: #d4d4d4; +} +.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar { + background-color: #aeaeae; +} +.ui-grid-pinned-container.ui-grid-pinned-container-first .ui-grid-header-cell:first-child .ui-grid-vertical-bar { + left: -1px; + width: 1px; + background-color: #aeaeae; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-column-resizer { + top: 0; + bottom: 0; + width: 5px; + position: absolute; + cursor: col-resize; +} +.ui-grid-column-resizer.left { + left: 0; +} +.ui-grid-column-resizer.right { + right: 0; +} +.ui-grid-header-cell:last-child .ui-grid-column-resizer.right { + border-right: 1px solid #d4d4d4; +} +.ui-grid[dir=rtl] .ui-grid-header-cell:last-child .ui-grid-column-resizer.right { + border-right: 0; +} +.ui-grid[dir=rtl] .ui-grid-header-cell:last-child .ui-grid-column-resizer.left { + border-left: 1px solid #d4d4d4; +} +.ui-grid.column-resizing { + cursor: col-resize; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.ui-grid.column-resizing .ui-grid-resize-overlay { + position: absolute; + top: 0; + height: 100%; + width: 1px; + background-color: #aeaeae; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-row-saving .ui-grid-cell { + color: #848484 !important; +} +.ui-grid-row-dirty .ui-grid-cell { + color: #610B38; +} +.ui-grid-row-error .ui-grid-cell { + color: #FF0000 !important; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-row.ui-grid-row-selected > [ui-grid-row] > .ui-grid-cell { + background-color: #C9DDE1; +} +.ui-grid-disable-selection { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: default; +} +.ui-grid-selection-row-header-buttons { + display: flex; + align-items: center; + height: 100%; + cursor: pointer; +} +.ui-grid-selection-row-header-buttons::before { + opacity: 0.1; +} +.ui-grid-selection-row-header-buttons.ui-grid-row-selected::before, +.ui-grid-selection-row-header-buttons.ui-grid-all-selected::before { + opacity: 1; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-tree-row-header-buttons.ui-grid-tree-header { + cursor: pointer; + opacity: 1; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-tree-header-row { + font-weight: bold !important; +} +.ui-grid-tree-header-row .ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell { + pointer-events: all; +} + +/* This file contains variable declarations (do not remove this line) */ +/*-- VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +/** +* @section Grid styles +*/ +/** +* @section Header styles +*/ +/** @description Colors for header gradient */ +/** +* @section Grid body styles +*/ +/** @description Colors used for row alternation */ +/** +* @section Grid Menu colors +*/ +/** +* @section Sort arrow colors +*/ +/** +* @section Scrollbar styles +*/ +/** +* @section font library path +*/ +/*-- END VARIABLES (DO NOT REMOVE THESE COMMENTS) --*/ +.ui-grid-cell-contents.invalid { + border: 1px solid #fc8f8f; +} diff --git a/release/4.4.11/ui-grid.edit.js b/release/4.4.11/ui-grid.edit.js new file mode 100644 index 000000000..587a70be5 --- /dev/null +++ b/release/4.4.11/ui-grid.edit.js @@ -0,0 +1,1313 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.edit + * @description + * + * # ui.grid.edit + * + * + * + * This module provides cell editing capability to ui.grid. The goal was to emulate keying data in a spreadsheet via + * a keyboard. + *
    + *
    + * To really get the full spreadsheet-like data entry, the ui.grid.cellNav module should be used. This will allow the + * user to key data and then tab, arrow, or enter to the cells beside or below. + * + *
    + */ + + var module = angular.module('ui.grid.edit', ['ui.grid']); + + /** + * @ngdoc object + * @name ui.grid.edit.constant:uiGridEditConstants + * + * @description constants available in edit module + */ + module.constant('uiGridEditConstants', { + EDITABLE_CELL_TEMPLATE: /EDITABLE_CELL_TEMPLATE/g, + //must be lowercase because template bulder converts to lower + EDITABLE_CELL_DIRECTIVE: /editable_cell_directive/g, + events: { + BEGIN_CELL_EDIT: 'uiGridEventBeginCellEdit', + END_CELL_EDIT: 'uiGridEventEndCellEdit', + CANCEL_CELL_EDIT: 'uiGridEventCancelCellEdit' + } + }); + + /** + * @ngdoc service + * @name ui.grid.edit.service:uiGridEditService + * + * @description Services for editing features + */ + module.service('uiGridEditService', ['$q', 'uiGridConstants', 'gridUtil', + function ($q, uiGridConstants, gridUtil) { + + var service = { + + initializeGrid: function (grid) { + + service.defaultGridOptions(grid.options); + + grid.registerColumnBuilder(service.editColumnBuilder); + grid.edit = {}; + + /** + * @ngdoc object + * @name ui.grid.edit.api:PublicApi + * + * @description Public Api for edit feature + */ + var publicApi = { + events: { + edit: { + /** + * @ngdoc event + * @name afterCellEdit + * @eventOf ui.grid.edit.api:PublicApi + * @description raised when cell editing is complete + *
    +                 *      gridApi.edit.on.afterCellEdit(scope,function(rowEntity, colDef){})
    +                 * 
    + * @param {object} rowEntity the options.data element that was edited + * @param {object} colDef the column that was edited + * @param {object} newValue new value + * @param {object} oldValue old value + */ + afterCellEdit: function (rowEntity, colDef, newValue, oldValue) { + }, + /** + * @ngdoc event + * @name beginCellEdit + * @eventOf ui.grid.edit.api:PublicApi + * @description raised when cell editing starts on a cell + *
    +                 *      gridApi.edit.on.beginCellEdit(scope,function(rowEntity, colDef){})
    +                 * 
    + * @param {object} rowEntity the options.data element that was edited + * @param {object} colDef the column that was edited + * @param {object} triggerEvent the event that triggered the edit. Useful to prevent losing keystrokes on some + * complex editors + */ + beginCellEdit: function (rowEntity, colDef, triggerEvent) { + }, + /** + * @ngdoc event + * @name cancelCellEdit + * @eventOf ui.grid.edit.api:PublicApi + * @description raised when cell editing is cancelled on a cell + *
    +                 *      gridApi.edit.on.cancelCellEdit(scope,function(rowEntity, colDef){})
    +                 * 
    + * @param {object} rowEntity the options.data element that was edited + * @param {object} colDef the column that was edited + */ + cancelCellEdit: function (rowEntity, colDef) { + } + } + }, + methods: { + edit: { } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + //grid.api.registerMethodsFromObject(publicApi.methods); + + }, + + defaultGridOptions: function (gridOptions) { + + /** + * @ngdoc object + * @name ui.grid.edit.api:GridOptions + * + * @description Options for configuring the edit feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc object + * @name enableCellEdit + * @propertyOf ui.grid.edit.api:GridOptions + * @description If defined, sets the default value for the editable flag on each individual colDefs + * if their individual enableCellEdit configuration is not defined. Defaults to undefined. + */ + + /** + * @ngdoc object + * @name cellEditableCondition + * @propertyOf ui.grid.edit.api:GridOptions + * @description If specified, either a value or function to be used by all columns before editing. + * If false, then editing of cell is not allowed. + * @example + *
    +           *  function($scope, triggerEvent){
    +           *    //use $scope.row.entity, $scope.col.colDef and triggerEvent to determine if editing is allowed
    +           *    return true;
    +           *  }
    +           *  
    + */ + gridOptions.cellEditableCondition = gridOptions.cellEditableCondition === undefined ? true : gridOptions.cellEditableCondition; + + /** + * @ngdoc object + * @name editableCellTemplate + * @propertyOf ui.grid.edit.api:GridOptions + * @description If specified, cellTemplate to use as the editor for all columns. + *
    defaults to 'ui-grid/cellTextEditor' + */ + + /** + * @ngdoc object + * @name enableCellEditOnFocus + * @propertyOf ui.grid.edit.api:GridOptions + * @description If true, then editor is invoked as soon as cell receives focus. Default false. + *
    _requires cellNav feature and the edit feature to be enabled_ + */ + //enableCellEditOnFocus can only be used if cellnav module is used + gridOptions.enableCellEditOnFocus = gridOptions.enableCellEditOnFocus === undefined ? false : gridOptions.enableCellEditOnFocus; + }, + + /** + * @ngdoc service + * @name editColumnBuilder + * @methodOf ui.grid.edit.service:uiGridEditService + * @description columnBuilder function that adds edit properties to grid column + * @returns {promise} promise that will load any needed templates when resolved + */ + editColumnBuilder: function (colDef, col, gridOptions) { + + var promises = []; + + /** + * @ngdoc object + * @name ui.grid.edit.api:ColumnDef + * + * @description Column Definition for edit feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs} + */ + + /** + * @ngdoc object + * @name enableCellEdit + * @propertyOf ui.grid.edit.api:ColumnDef + * @description enable editing on column + */ + colDef.enableCellEdit = colDef.enableCellEdit === undefined ? (gridOptions.enableCellEdit === undefined ? + (colDef.type !== 'object') : gridOptions.enableCellEdit) : colDef.enableCellEdit; + + /** + * @ngdoc object + * @name cellEditableCondition + * @propertyOf ui.grid.edit.api:ColumnDef + * @description If specified, either a value or function evaluated before editing cell. If falsy, then editing of cell is not allowed. + * @example + *
    +           *  function($scope, triggerEvent){
    +           *    //use $scope.row.entity, $scope.col.colDef and triggerEvent to determine if editing is allowed
    +           *    return true;
    +           *  }
    +           *  
    + */ + colDef.cellEditableCondition = colDef.cellEditableCondition === undefined ? gridOptions.cellEditableCondition : colDef.cellEditableCondition; + + /** + * @ngdoc object + * @name editableCellTemplate + * @propertyOf ui.grid.edit.api:ColumnDef + * @description cell template to be used when editing this column. Can be Url or text template + *
    Defaults to gridOptions.editableCellTemplate + */ + if (colDef.enableCellEdit) { + colDef.editableCellTemplate = colDef.editableCellTemplate || gridOptions.editableCellTemplate || 'ui-grid/cellEditor'; + + promises.push(gridUtil.getTemplate(colDef.editableCellTemplate) + .then( + function (template) { + col.editableCellTemplate = template; + }, + function (res) { + // Todo handle response error here? + throw new Error("Couldn't fetch/use colDef.editableCellTemplate '" + colDef.editableCellTemplate + "'"); + })); + } + + /** + * @ngdoc object + * @name enableCellEditOnFocus + * @propertyOf ui.grid.edit.api:ColumnDef + * @requires ui.grid.cellNav + * @description If true, then editor is invoked as soon as cell receives focus. Default false. + *
    _requires both the cellNav feature and the edit feature to be enabled_ + */ + //enableCellEditOnFocus can only be used if cellnav module is used + colDef.enableCellEditOnFocus = colDef.enableCellEditOnFocus === undefined ? gridOptions.enableCellEditOnFocus : colDef.enableCellEditOnFocus; + + + /** + * @ngdoc string + * @name editModelField + * @propertyOf ui.grid.edit.api:ColumnDef + * @description a bindable string value that is used when binding to edit controls instead of colDef.field + *
    example: You have a complex property on and object like state:{abbrev:'MS',name:'Mississippi'}. The + * grid should display state.name in the cell and sort/filter based on the state.name property but the editor + * requires the full state object. + *
    colDef.field = 'state.name' + *
    colDef.editModelField = 'state' + */ + //colDef.editModelField + + return $q.all(promises); + }, + + /** + * @ngdoc service + * @name isStartEditKey + * @methodOf ui.grid.edit.service:uiGridEditService + * @description Determines if a keypress should start editing. Decorate this service to override with your + * own key events. See service decorator in angular docs. + * @param {Event} evt keydown event + * @returns {boolean} true if an edit should start + */ + isStartEditKey: function (evt) { + if (evt.metaKey || + evt.keyCode === uiGridConstants.keymap.ESC || + evt.keyCode === uiGridConstants.keymap.SHIFT || + evt.keyCode === uiGridConstants.keymap.CTRL || + evt.keyCode === uiGridConstants.keymap.ALT || + evt.keyCode === uiGridConstants.keymap.WIN || + evt.keyCode === uiGridConstants.keymap.CAPSLOCK || + + evt.keyCode === uiGridConstants.keymap.LEFT || + (evt.keyCode === uiGridConstants.keymap.TAB && evt.shiftKey) || + + evt.keyCode === uiGridConstants.keymap.RIGHT || + evt.keyCode === uiGridConstants.keymap.TAB || + + evt.keyCode === uiGridConstants.keymap.UP || + (evt.keyCode === uiGridConstants.keymap.ENTER && evt.shiftKey) || + + evt.keyCode === uiGridConstants.keymap.DOWN || + evt.keyCode === uiGridConstants.keymap.ENTER) { + return false; + + } + return true; + } + + + }; + + return service; + + }]); + + /** + * @ngdoc directive + * @name ui.grid.edit.directive:uiGridEdit + * @element div + * @restrict A + * + * @description Adds editing features to the ui-grid directive. + * + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.edit']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + + $scope.columnDefs = [ + {name: 'name', enableCellEdit: true}, + {name: 'title', enableCellEdit: true} + ]; + }]); + + +
    +
    +
    +
    +
    + */ + module.directive('uiGridEdit', ['gridUtil', 'uiGridEditService', function (gridUtil, uiGridEditService) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridEditService.initializeGrid(uiGridCtrl.grid); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.edit.directive:uiGridRenderContainer + * @element div + * @restrict A + * + * @description Adds keydown listeners to renderContainer element so we can capture when to begin edits + * + */ + module.directive('uiGridViewport', [ 'uiGridEditConstants', + function ( uiGridEditConstants) { + return { + replace: true, + priority: -99998, //run before cellNav + require: ['^uiGrid', '^uiGridRenderContainer'], + scope: false, + compile: function () { + return { + post: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + + // Skip attaching if edit and cellNav is not enabled + if (!uiGridCtrl.grid.api.edit || !uiGridCtrl.grid.api.cellNav) { return; } + + var containerId = controllers[1].containerId; + //no need to process for other containers + if (containerId !== 'body') { + return; + } + + //refocus on the grid + $scope.$on(uiGridEditConstants.events.CANCEL_CELL_EDIT, function () { + uiGridCtrl.focus(); + }); + $scope.$on(uiGridEditConstants.events.END_CELL_EDIT, function () { + uiGridCtrl.focus(); + }); + + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.edit.directive:uiGridCell + * @element div + * @restrict A + * + * @description Stacks on top of ui.grid.uiGridCell to provide in-line editing capabilities to the cell + * Editing Actions. + * + * Binds edit start events to the uiGridCell element. When the events fire, the gridCell element is appended + * with the columnDef.editableCellTemplate element ('cellEditor.html' by default). + * + * The editableCellTemplate should respond to uiGridEditConstants.events.BEGIN\_CELL\_EDIT angular event + * and do the initial steps needed to edit the cell (setfocus on input element, etc). + * + * When the editableCellTemplate recognizes that the editing is ended (blur event, Enter key, etc.) + * it should emit the uiGridEditConstants.events.END\_CELL\_EDIT event. + * + * If editableCellTemplate recognizes that the editing has been cancelled (esc key) + * it should emit the uiGridEditConstants.events.CANCEL\_CELL\_EDIT event. The original value + * will be set back on the model by the uiGridCell directive. + * + * Events that invoke editing: + * - dblclick + * - F2 keydown (when using cell selection) + * + * Events that end editing: + * - Dependent on the specific editableCellTemplate + * - Standards should be blur and enter keydown + * + * Events that cancel editing: + * - Dependent on the specific editableCellTemplate + * - Standards should be Esc keydown + * + * Grid Events that end editing: + * - uiGridConstants.events.GRID_SCROLL + * + */ + + /** + * @ngdoc object + * @name ui.grid.edit.api:GridRow + * + * @description GridRow options for edit feature, these are available to be + * set internally only, by other features + */ + + /** + * @ngdoc object + * @name enableCellEdit + * @propertyOf ui.grid.edit.api:GridRow + * @description enable editing on row, grouping for example might disable editing on group header rows + */ + + module.directive('uiGridCell', + ['$compile', '$injector', '$timeout', 'uiGridConstants', 'uiGridEditConstants', 'gridUtil', '$parse', 'uiGridEditService', '$rootScope', '$q', + function ($compile, $injector, $timeout, uiGridConstants, uiGridEditConstants, gridUtil, $parse, uiGridEditService, $rootScope, $q) { + var touchstartTimeout = 500; + if ($injector.has('uiGridCellNavService')) { + var uiGridCellNavService = $injector.get('uiGridCellNavService'); + } + + return { + priority: -100, // run after default uiGridCell directive + restrict: 'A', + scope: false, + require: '?^uiGrid', + link: function ($scope, $elm, $attrs, uiGridCtrl) { + var html; + var origCellValue; + var inEdit = false; + var cellModel; + var cancelTouchstartTimeout; + + var editCellScope; + + if (!$scope.col.colDef.enableCellEdit) { + return; + } + + var cellNavNavigateDereg = function() {}; + var viewPortKeyDownDereg = function() {}; + + + var setEditable = function() { + if ($scope.col.colDef.enableCellEdit && $scope.row.enableCellEdit !== false) { + if (!$scope.beginEditEventsWired) { //prevent multiple attachments + registerBeginEditEvents(); + } + } else { + if ($scope.beginEditEventsWired) { + cancelBeginEditEvents(); + } + } + }; + + setEditable(); + + var rowWatchDereg = $scope.$watch('row', function (n, o) { + if (n !== o) { + setEditable(); + } + }); + + + $scope.$on('$destroy', function destroyEvents() { + rowWatchDereg(); + // unbind all jquery events in order to avoid memory leaks + $elm.off(); + }); + + function registerBeginEditEvents() { + $elm.on('dblclick', beginEdit); + + // Add touchstart handling. If the users starts a touch and it doesn't end after X milliseconds, then start the edit + $elm.on('touchstart', touchStart); + + if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) { + + viewPortKeyDownDereg = uiGridCtrl.grid.api.cellNav.on.viewPortKeyDown($scope, function (evt, rowCol) { + if (rowCol === null) { + return; + } + + if (rowCol.row === $scope.row && rowCol.col === $scope.col && !$scope.col.colDef.enableCellEditOnFocus) { + //important to do this before scrollToIfNecessary + beginEditKeyDown(evt); + } + }); + + cellNavNavigateDereg = uiGridCtrl.grid.api.cellNav.on.navigate($scope, function (newRowCol, oldRowCol, evt) { + if ($scope.col.colDef.enableCellEditOnFocus) { + // Don't begin edit if the cell hasn't changed + if (newRowCol.row === $scope.row && newRowCol.col === $scope.col && + (evt === null || (evt && (evt.type === 'click' || evt.type === 'keydown')))) { + $timeout(function() { + beginEdit(evt); + }); + } + } + }); + } + + $scope.beginEditEventsWired = true; + } + + function touchStart(event) { + // jQuery masks events + if (typeof(event.originalEvent) !== 'undefined' && event.originalEvent !== undefined) { + event = event.originalEvent; + } + + // Bind touchend handler + $elm.on('touchend', touchEnd); + + // Start a timeout + cancelTouchstartTimeout = $timeout(function() { }, touchstartTimeout); + + // Timeout's done! Start the edit + cancelTouchstartTimeout.then(function () { + // Use setTimeout to start the edit because beginEdit expects to be outside of $digest + setTimeout(beginEdit, 0); + + // Undbind the touchend handler, we don't need it anymore + $elm.off('touchend', touchEnd); + }); + } + + // Cancel any touchstart timeout + function touchEnd(event) { + $timeout.cancel(cancelTouchstartTimeout); + $elm.off('touchend', touchEnd); + } + + function cancelBeginEditEvents() { + $elm.off('dblclick', beginEdit); + $elm.off('keydown', beginEditKeyDown); + $elm.off('touchstart', touchStart); + cellNavNavigateDereg(); + viewPortKeyDownDereg(); + $scope.beginEditEventsWired = false; + } + + function beginEditKeyDown(evt) { + if (uiGridEditService.isStartEditKey(evt)) { + beginEdit(evt); + } + } + + function shouldEdit(col, row, triggerEvent) { + return !row.isSaving && + ( angular.isFunction(col.colDef.cellEditableCondition) ? + col.colDef.cellEditableCondition($scope, triggerEvent) : + col.colDef.cellEditableCondition ); + } + + + function beginEdit(triggerEvent) { + //we need to scroll the cell into focus before invoking the editor + $scope.grid.api.core.scrollToIfNecessary($scope.row, $scope.col) + .then(function () { + beginEditAfterScroll(triggerEvent); + }); + } + + /** + * @ngdoc property + * @name editDropdownOptionsArray + * @propertyOf ui.grid.edit.api:ColumnDef + * @description an array of values in the format + * [ {id: xxx, value: xxx} ], which is populated + * into the edit dropdown + * + */ + /** + * @ngdoc property + * @name editDropdownIdLabel + * @propertyOf ui.grid.edit.api:ColumnDef + * @description the label for the "id" field + * in the editDropdownOptionsArray. Defaults + * to 'id' + * @example + *
    +             *    $scope.gridOptions = {
    +             *      columnDefs: [
    +             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
    +             *          editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],
    +             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }
    +             *      ],
    +             *  
    + * + */ + /** + * @ngdoc property + * @name editDropdownRowEntityOptionsArrayPath + * @propertyOf ui.grid.edit.api:ColumnDef + * @description a path to a property on row.entity containing an + * array of values in the format + * [ {id: xxx, value: xxx} ], which will be used to populate + * the edit dropdown. This can be used when the dropdown values are dependent on + * the backing row entity. + * If this property is set then editDropdownOptionsArray will be ignored. + * @example + *
    +             *    $scope.gridOptions = {
    +             *      columnDefs: [
    +             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
    +             *          editDropdownRowEntityOptionsArrayPath: 'foo.bars[0].baz',
    +             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }
    +             *      ],
    +             *  
    + * + */ + /** + * @ngdoc service + * @name editDropdownOptionsFunction + * @methodOf ui.grid.edit.api:ColumnDef + * @description a function returning an array of values in the format + * [ {id: xxx, value: xxx} ], which will be used to populate + * the edit dropdown. This can be used when the dropdown values are dependent on + * the backing row entity with some kind of algorithm. + * If this property is set then both editDropdownOptionsArray and + * editDropdownRowEntityOptionsArrayPath will be ignored. + * @param {object} rowEntity the options.data element that the returned array refers to + * @param {object} colDef the column that implements this dropdown + * @returns {object} an array of values in the format + * [ {id: xxx, value: xxx} ] used to populate the edit dropdown + * @example + *
    +             *    $scope.gridOptions = {
    +             *      columnDefs: [
    +             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
    +             *          editDropdownOptionsFunction: function(rowEntity, colDef) {
    +             *            if (rowEntity.foo === 'bar') {
    +             *              return [{id: 'bar1', value: 'BAR 1'},
    +             *                      {id: 'bar2', value: 'BAR 2'},
    +             *                      {id: 'bar3', value: 'BAR 3'}];
    +             *            } else {
    +             *              return [{id: 'foo1', value: 'FOO 1'},
    +             *                      {id: 'foo2', value: 'FOO 2'}];
    +             *            }
    +             *          },
    +             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }
    +             *      ],
    +             *  
    + * + */ + /** + * @ngdoc property + * @name editDropdownValueLabel + * @propertyOf ui.grid.edit.api:ColumnDef + * @description the label for the "value" field + * in the editDropdownOptionsArray. Defaults + * to 'value' + * @example + *
    +             *    $scope.gridOptions = {
    +             *      columnDefs: [
    +             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
    +             *          editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],
    +             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status' }
    +             *      ],
    +             *  
    + * + */ + /** + * @ngdoc property + * @name editDropdownFilter + * @propertyOf ui.grid.edit.api:ColumnDef + * @description A filter that you would like to apply to the values in the options list + * of the dropdown. For example if you were using angular-translate you might set this + * to `'translate'` + * @example + *
    +             *    $scope.gridOptions = {
    +             *      columnDefs: [
    +             *        {name: 'status', editableCellTemplate: 'ui-grid/dropdownEditor',
    +             *          editDropdownOptionsArray: [{code: 1, status: 'active'}, {code: 2, status: 'inactive'}],
    +             *          editDropdownIdLabel: 'code', editDropdownValueLabel: 'status', editDropdownFilter: 'translate' }
    +             *      ],
    +             *  
    + * + */ + function beginEditAfterScroll(triggerEvent) { + // If we are already editing, then just skip this so we don't try editing twice... + if (inEdit) { + return; + } + + if (!shouldEdit($scope.col, $scope.row, triggerEvent)) { + return; + } + + var modelField = $scope.row.getQualifiedColField($scope.col); + if ($scope.col.colDef.editModelField) { + modelField = gridUtil.preEval('row.entity.' + $scope.col.colDef.editModelField); + } + + cellModel = $parse(modelField); + + //get original value from the cell + origCellValue = cellModel($scope); + + html = $scope.col.editableCellTemplate; + html = html.replace(uiGridConstants.MODEL_COL_FIELD, modelField); + html = html.replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)'); + + var optionFilter = $scope.col.colDef.editDropdownFilter ? '|' + $scope.col.colDef.editDropdownFilter : ''; + html = html.replace(uiGridConstants.CUSTOM_FILTERS, optionFilter); + + var inputType = 'text'; + switch ($scope.col.colDef.type){ + case 'boolean': + inputType = 'checkbox'; + break; + case 'number': + inputType = 'number'; + break; + case 'date': + inputType = 'date'; + break; + } + html = html.replace('INPUT_TYPE', inputType); + + // In order to fill dropdown options we use: + // - A function/promise or + // - An array inside of row entity if no function exists or + // - A single array for the whole column if none of the previous exists. + var editDropdownOptionsFunction = $scope.col.colDef.editDropdownOptionsFunction; + if (editDropdownOptionsFunction) { + $q.when(editDropdownOptionsFunction($scope.row.entity, $scope.col.colDef)) + .then(function(result) { + $scope.editDropdownOptionsArray = result; + }); + } else { + var editDropdownRowEntityOptionsArrayPath = $scope.col.colDef.editDropdownRowEntityOptionsArrayPath; + if (editDropdownRowEntityOptionsArrayPath) { + $scope.editDropdownOptionsArray = resolveObjectFromPath($scope.row.entity, editDropdownRowEntityOptionsArrayPath); + } + else { + $scope.editDropdownOptionsArray = $scope.col.colDef.editDropdownOptionsArray; + } + } + $scope.editDropdownIdLabel = $scope.col.colDef.editDropdownIdLabel ? $scope.col.colDef.editDropdownIdLabel : 'id'; + $scope.editDropdownValueLabel = $scope.col.colDef.editDropdownValueLabel ? $scope.col.colDef.editDropdownValueLabel : 'value'; + + var cellElement; + var createEditor = function(){ + inEdit = true; + cancelBeginEditEvents(); + var cellElement = angular.element(html); + $elm.append(cellElement); + editCellScope = $scope.$new(); + $compile(cellElement)(editCellScope); + var gridCellContentsEl = angular.element($elm.children()[0]); + gridCellContentsEl.addClass('ui-grid-cell-contents-hidden'); + }; + if (!$rootScope.$$phase) { + $scope.$apply(createEditor); + } else { + createEditor(); + } + + //stop editing when grid is scrolled + var deregOnGridScroll = $scope.col.grid.api.core.on.scrollBegin($scope, function () { + if ($scope.grid.disableScrolling) { + return; + } + endEdit(); + $scope.grid.api.edit.raise.afterCellEdit($scope.row.entity, $scope.col.colDef, cellModel($scope), origCellValue); + deregOnGridScroll(); + deregOnEndCellEdit(); + deregOnCancelCellEdit(); + }); + + //end editing + var deregOnEndCellEdit = $scope.$on(uiGridEditConstants.events.END_CELL_EDIT, function () { + endEdit(); + $scope.grid.api.edit.raise.afterCellEdit($scope.row.entity, $scope.col.colDef, cellModel($scope), origCellValue); + deregOnEndCellEdit(); + deregOnGridScroll(); + deregOnCancelCellEdit(); + }); + + //cancel editing + var deregOnCancelCellEdit = $scope.$on(uiGridEditConstants.events.CANCEL_CELL_EDIT, function () { + cancelEdit(); + deregOnCancelCellEdit(); + deregOnGridScroll(); + deregOnEndCellEdit(); + }); + + $scope.$broadcast(uiGridEditConstants.events.BEGIN_CELL_EDIT, triggerEvent); + $timeout(function () { + // execute in a timeout to give any complex editor templates a cycle to completely render + $scope.grid.api.edit.raise.beginCellEdit($scope.row.entity, $scope.col.colDef, triggerEvent); + }); + } + + function endEdit() { + $scope.grid.disableScrolling = false; + if (!inEdit) { + return; + } + + //sometimes the events can't keep up with the keyboard and grid focus is lost, so always focus + //back to grid here. The focus call needs to be before the $destroy and removal of the control, + //otherwise ng-model-options of UpdateOn: 'blur' will not work. + if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) { + uiGridCtrl.focus(); + } + + var gridCellContentsEl = angular.element($elm.children()[0]); + //remove edit element + editCellScope.$destroy(); + var children = $elm.children(); + for (var i = 1; i < children.length; i++) { + angular.element(children[i]).remove(); + } + gridCellContentsEl.removeClass('ui-grid-cell-contents-hidden'); + inEdit = false; + registerBeginEditEvents(); + $scope.grid.api.core.notifyDataChange( uiGridConstants.dataChange.EDIT ); + } + + function cancelEdit() { + $scope.grid.disableScrolling = false; + if (!inEdit) { + return; + } + cellModel.assign($scope, origCellValue); + $scope.$apply(); + + $scope.grid.api.edit.raise.cancelCellEdit($scope.row.entity, $scope.col.colDef); + endEdit(); + } + + // resolves a string path against the given object + // shamelessly borrowed from + // http://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-with-string-key + function resolveObjectFromPath(object, path) { + path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties + path = path.replace(/^\./, ''); // strip a leading dot + var a = path.split('.'); + while (a.length) { + var n = a.shift(); + if (n in object) { + object = object[n]; + } else { + return; + } + } + return object; + } + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.edit.directive:uiGridEditor + * @element div + * @restrict A + * + * @description input editor directive for editable fields. + * Provides EndEdit and CancelEdit events + * + * Events that end editing: + * blur and enter keydown + * + * Events that cancel editing: + * - Esc keydown + * + */ + module.directive('uiGridEditor', + ['gridUtil', 'uiGridConstants', 'uiGridEditConstants','$timeout', 'uiGridEditService', + function (gridUtil, uiGridConstants, uiGridEditConstants, $timeout, uiGridEditService) { + return { + scope: true, + require: ['?^uiGrid', '?^uiGridRenderContainer', 'ngModel'], + compile: function () { + return { + pre: function ($scope, $elm, $attrs) { + + }, + post: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl, renderContainerCtrl, ngModel; + if (controllers[0]) { uiGridCtrl = controllers[0]; } + if (controllers[1]) { renderContainerCtrl = controllers[1]; } + if (controllers[2]) { ngModel = controllers[2]; } + + //set focus at start of edit + $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function (evt,triggerEvent) { + // must be in a timeout since it requires a new digest cycle + $timeout(function () { + $elm[0].focus(); + //only select text if it is not being replaced below in the cellNav viewPortKeyPress + if ($elm[0].select && ($scope.col.colDef.enableCellEditOnFocus || !(uiGridCtrl && uiGridCtrl.grid.api.cellNav))) { + $elm[0].select(); + } + else { + //some browsers (Chrome) stupidly, imo, support the w3 standard that number, email, ... + //fields should not allow setSelectionRange. We ignore the error for those browsers + //https://www.w3.org/Bugs/Public/show_bug.cgi?id=24796 + try { + $elm[0].setSelectionRange($elm[0].value.length, $elm[0].value.length); + } + catch (ex) { + //ignore + } + } + }); + + //set the keystroke that started the edit event + //we must do this because the BeginEdit is done in a different event loop than the intitial + //keydown event + //fire this event for the keypress that is received + if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) { + var viewPortKeyDownUnregister = uiGridCtrl.grid.api.cellNav.on.viewPortKeyPress($scope, function (evt, rowCol) { + if (uiGridEditService.isStartEditKey(evt)) { + var code = typeof evt.which === 'number' ? evt.which : evt.keyCode; + if (code > 0) { + ngModel.$setViewValue(String.fromCharCode(code), evt); + ngModel.$render(); + } + } + viewPortKeyDownUnregister(); + }); + } + + // macOS will blur the checkbox when clicked in Safari and Firefox, + // to get around this, we disable the blur handler on mousedown, + // and then focus the checkbox and re-enable the blur handler after $timeout + $elm.on('mousedown', function(evt) { + if ($elm[0].type === 'checkbox') { + $elm.off('blur', $scope.stopEdit); + $timeout(function() { + $elm[0].focus(); + $elm.on('blur', $scope.stopEdit); + }); + } + }); + + $elm.on('blur', $scope.stopEdit); + }); + + + $scope.deepEdit = false; + + $scope.stopEdit = function (evt) { + if ($scope.inputForm && !$scope.inputForm.$valid) { + evt.stopPropagation(); + $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT); + } + else { + $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT); + } + $scope.deepEdit = false; + }; + + + $elm.on('click', function (evt) { + if ($elm[0].type !== 'checkbox') { + $scope.deepEdit = true; + $scope.$applyAsync(function () { + $scope.grid.disableScrolling = true; + }); + } + }); + + $elm.on('keydown', function (evt) { + switch (evt.keyCode) { + case uiGridConstants.keymap.ESC: + evt.stopPropagation(); + $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT); + break; + } + + if ($scope.deepEdit && + (evt.keyCode === uiGridConstants.keymap.LEFT || + evt.keyCode === uiGridConstants.keymap.RIGHT || + evt.keyCode === uiGridConstants.keymap.UP || + evt.keyCode === uiGridConstants.keymap.DOWN)) { + evt.stopPropagation(); + } + // Pass the keydown event off to the cellNav service, if it exists + else if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) { + evt.uiGridTargetRenderContainerId = renderContainerCtrl.containerId; + if (uiGridCtrl.cellNav.handleKeyDown(evt) !== null) { + $scope.stopEdit(evt); + } + } + else { + //handle enter and tab for editing not using cellNav + switch (evt.keyCode) { + case uiGridConstants.keymap.ENTER: // Enter (Leave Field) + case uiGridConstants.keymap.TAB: + evt.stopPropagation(); + evt.preventDefault(); + $scope.stopEdit(evt); + break; + } + } + + return true; + }); + + $scope.$on('$destroy', function unbindEvents() { + // unbind all jquery events in order to avoid memory leaks + $elm.off(); + }); + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.edit.directive:input + * @element input + * @restrict E + * + * @description directive to provide binding between input[date] value and ng-model for angular 1.2 + * It is similar to input[date] directive of angular 1.3 + * + * Supported date format for input is 'yyyy-MM-dd' + * The directive will set the $valid property of input element and the enclosing form to false if + * model is invalid date or value of input is entered wrong. + * + */ + module.directive('uiGridEditor', ['$filter', function ($filter) { + function parseDateString(dateString) { + if (typeof(dateString) === 'undefined' || dateString === '') { + return null; + } + var parts = dateString.split('-'); + if (parts.length !== 3) { + return null; + } + var year = parseInt(parts[0], 10); + var month = parseInt(parts[1], 10); + var day = parseInt(parts[2], 10); + + if (month < 1 || year < 1 || day < 1) { + return null; + } + return new Date(year, (month - 1), day); + } + return { + priority: -100, // run after default uiGridEditor directive + require: '?ngModel', + link: function (scope, element, attrs, ngModel) { + + if (angular.version.minor === 2 && attrs.type && attrs.type === 'date' && ngModel) { + + ngModel.$formatters.push(function (modelValue) { + ngModel.$setValidity(null,(!modelValue || !isNaN(modelValue.getTime()))); + return $filter('date')(modelValue, 'yyyy-MM-dd'); + }); + + ngModel.$parsers.push(function (viewValue) { + if (viewValue && viewValue.length > 0) { + var dateValue = parseDateString(viewValue); + ngModel.$setValidity(null, (dateValue && !isNaN(dateValue.getTime()))); + return dateValue; + } + else { + ngModel.$setValidity(null, true); + return null; + } + }); + } + } + }; + }]); + + + /** + * @ngdoc directive + * @name ui.grid.edit.directive:uiGridEditDropdown + * @element div + * @restrict A + * + * @description dropdown editor for editable fields. + * Provides EndEdit and CancelEdit events + * + * Events that end editing: + * blur and enter keydown, and any left/right nav + * + * Events that cancel editing: + * - Esc keydown + * + */ + module.directive('uiGridEditDropdown', + ['uiGridConstants', 'uiGridEditConstants', '$timeout', + function (uiGridConstants, uiGridEditConstants, $timeout) { + return { + require: ['?^uiGrid', '?^uiGridRenderContainer'], + scope: true, + compile: function () { + return { + pre: function ($scope, $elm, $attrs) { + + }, + post: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + var renderContainerCtrl = controllers[1]; + + //set focus at start of edit + $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () { + $timeout(function(){ + $elm[0].focus(); + }); + + $elm[0].style.width = ($elm[0].parentElement.offsetWidth - 1) + 'px'; + $elm.on('blur', function (evt) { + $scope.stopEdit(evt); + }); + }); + + + $scope.stopEdit = function (evt) { + // no need to validate a dropdown - invalid values shouldn't be + // available in the list + $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT); + }; + + $elm.on('keydown', function (evt) { + switch (evt.keyCode) { + case uiGridConstants.keymap.ESC: + evt.stopPropagation(); + $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT); + break; + } + if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) { + evt.uiGridTargetRenderContainerId = renderContainerCtrl.containerId; + if (uiGridCtrl.cellNav.handleKeyDown(evt) !== null) { + $scope.stopEdit(evt); + } + } + else { + //handle enter and tab for editing not using cellNav + switch (evt.keyCode) { + case uiGridConstants.keymap.ENTER: // Enter (Leave Field) + case uiGridConstants.keymap.TAB: + evt.stopPropagation(); + evt.preventDefault(); + $scope.stopEdit(evt); + break; + } + } + return true; + }); + + $scope.$on('$destroy', function unbindEvents() { + // unbind jquery events to prevent memory leaks + $elm.off(); + }); + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.edit.directive:uiGridEditFileChooser + * @element div + * @restrict A + * + * @description input editor directive for editable fields. + * Provides EndEdit and CancelEdit events + * + * Events that end editing: + * blur and enter keydown + * + * Events that cancel editing: + * - Esc keydown + * + */ + module.directive('uiGridEditFileChooser', + ['gridUtil', 'uiGridConstants', 'uiGridEditConstants', + function (gridUtil, uiGridConstants, uiGridEditConstants) { + return { + scope: true, + require: ['?^uiGrid', '?^uiGridRenderContainer'], + compile: function () { + return { + pre: function ($scope, $elm, $attrs) { + + }, + post: function ($scope, $elm) { + function handleFileSelect(event) { + var target = event.srcElement || event.target; + + if (target && target.files && target.files.length > 0) { + /** + * @ngdoc property + * @name editFileChooserCallback + * @propertyOf ui.grid.edit.api:ColumnDef + * @description A function that should be called when any files have been chosen + * by the user. You should use this to process the files appropriately for your + * application. + * + * It passes the gridCol, the gridRow (from which you can get gridRow.entity), + * and the files. The files are in the format as returned from the file chooser, + * an array of files, with each having useful information such as: + * - `files[0].lastModifiedDate` + * - `files[0].name` + * - `files[0].size` (appears to be in bytes) + * - `files[0].type` (MIME type by the looks) + * + * Typically you would do something with these files - most commonly you would + * use the filename or read the file itself in. The example function does both. + * + * @example + *
    +                     *  editFileChooserCallBack: function(gridRow, gridCol, files ){
    +                     *    // ignore all but the first file, it can only choose one anyway
    +                     *    // set the filename into this column
    +                     *    gridRow.entity.filename = file[0].name;
    +                     *
    +                     *    // read the file and set it into a hidden column, which we may do stuff with later
    +                     *    var setFile = function(fileContent){
    +                     *      gridRow.entity.file = fileContent.currentTarget.result;
    +                     *    };
    +                     *    var reader = new FileReader();
    +                     *    reader.onload = setFile;
    +                     *    reader.readAsText( files[0] );
    +                     *  }
    +                     *  
    + */ + if ( typeof($scope.col.colDef.editFileChooserCallback) === 'function' ) { + $scope.col.colDef.editFileChooserCallback($scope.row, $scope.col, target.files); + } else { + gridUtil.logError('You need to set colDef.editFileChooserCallback to use the file chooser'); + } + + target.form.reset(); + $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT); + } else { + $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT); + } + $elm[0].removeEventListener('change', handleFileSelect, false); + } + + $elm[0].addEventListener('change', handleFileSelect, false); + + $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () { + $elm[0].focus(); + $elm[0].select(); + + $elm.on('blur', function () { + $scope.$emit(uiGridEditConstants.events.END_CELL_EDIT); + $elm.off(); + }); + }); + } + }; + } + }; + }]); +})(); diff --git a/release/4.4.11/ui-grid.edit.min.js b/release/4.4.11/ui-grid.edit.min.js new file mode 100644 index 000000000..9521a3326 --- /dev/null +++ b/release/4.4.11/ui-grid.edit.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.edit",["ui.grid"]);e.constant("uiGridEditConstants",{EDITABLE_CELL_TEMPLATE:/EDITABLE_CELL_TEMPLATE/g,EDITABLE_CELL_DIRECTIVE:/editable_cell_directive/g,events:{BEGIN_CELL_EDIT:"uiGridEventBeginCellEdit",END_CELL_EDIT:"uiGridEventEndCellEdit",CANCEL_CELL_EDIT:"uiGridEventCancelCellEdit"}}),e.service("uiGridEditService",["$q","uiGridConstants","gridUtil",function(o,i,l){var t={initializeGrid:function(e){t.defaultGridOptions(e.options),e.registerColumnBuilder(t.editColumnBuilder),e.edit={};e.api.registerEventsFromObject({edit:{afterCellEdit:function(e,i,t,n){},beginCellEdit:function(e,i,t){},cancelCellEdit:function(e,i){}}})},defaultGridOptions:function(e){e.cellEditableCondition=void 0===e.cellEditableCondition||e.cellEditableCondition,e.enableCellEditOnFocus=void 0!==e.enableCellEditOnFocus&&e.enableCellEditOnFocus},editColumnBuilder:function(i,t,e){var n=[];return i.enableCellEdit=void 0===i.enableCellEdit?void 0===e.enableCellEdit?"object"!==i.type:e.enableCellEdit:i.enableCellEdit,i.cellEditableCondition=void 0===i.cellEditableCondition?e.cellEditableCondition:i.cellEditableCondition,i.enableCellEdit&&(i.editableCellTemplate=i.editableCellTemplate||e.editableCellTemplate||"ui-grid/cellEditor",n.push(l.getTemplate(i.editableCellTemplate).then(function(e){t.editableCellTemplate=e},function(e){throw new Error("Couldn't fetch/use colDef.editableCellTemplate '"+i.editableCellTemplate+"'")}))),i.enableCellEditOnFocus=void 0===i.enableCellEditOnFocus?e.enableCellEditOnFocus:i.enableCellEditOnFocus,o.all(n)},isStartEditKey:function(e){return!(e.metaKey||e.keyCode===i.keymap.ESC||e.keyCode===i.keymap.SHIFT||e.keyCode===i.keymap.CTRL||e.keyCode===i.keymap.ALT||e.keyCode===i.keymap.WIN||e.keyCode===i.keymap.CAPSLOCK||e.keyCode===i.keymap.LEFT||e.keyCode===i.keymap.TAB&&e.shiftKey||e.keyCode===i.keymap.RIGHT||e.keyCode===i.keymap.TAB||e.keyCode===i.keymap.UP||e.keyCode===i.keymap.ENTER&&e.shiftKey||e.keyCode===i.keymap.DOWN||e.keyCode===i.keymap.ENTER)}};return t}]),e.directive("uiGridEdit",["gridUtil","uiGridEditService",function(e,o){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,i,t,n){o.initializeGrid(n.grid)},post:function(e,i,t,n){}}}}}]),e.directive("uiGridViewport",["uiGridEditConstants",function(l){return{replace:!0,priority:-99998,require:["^uiGrid","^uiGridRenderContainer"],scope:!1,compile:function(){return{post:function(e,i,t,n){var o=n[0];o.grid.api.edit&&o.grid.api.cellNav&&("body"===n[1].containerId&&(e.$on(l.events.CANCEL_CELL_EDIT,function(){o.focus()}),e.$on(l.events.END_CELL_EDIT,function(){o.focus()})))}}}}}]),e.directive("uiGridCell",["$compile","$injector","$timeout","uiGridConstants","uiGridEditConstants","gridUtil","$parse","uiGridEditService","$rootScope","$q",function(L,e,k,h,T,w,_,f,G,I){var $=500;if(e.has("uiGridCellNavService"))e.get("uiGridCellNavService");return{priority:-100,restrict:"A",scope:!1,require:"?^uiGrid",link:function(E,p,e,n){var C,v,y,i,g,D=!1;if(E.col.colDef.enableCellEdit){var t=function(){},o=function(){},l=function(){E.col.colDef.enableCellEdit&&!1!==E.row.enableCellEdit?E.beginEditEventsWired||d():E.beginEditEventsWired&&m()};l();var r=E.$watch("row",function(e,i){e!==i&&l()});E.$on("$destroy",function(){r(),p.off()})}function d(){p.on("dblclick",s),p.on("touchstart",c),n&&n.grid.api.cellNav&&(o=n.grid.api.cellNav.on.viewPortKeyDown(E,function(e,i){null!==i&&(i.row!==E.row||i.col!==E.col||E.col.colDef.enableCellEditOnFocus||u(e))}),t=n.grid.api.cellNav.on.navigate(E,function(e,i,t){E.col.colDef.enableCellEditOnFocus&&(e.row!==E.row||e.col!==E.col||null!==t&&(!t||"click"!==t.type&&"keydown"!==t.type)||k(function(){s(t)}))})),E.beginEditEventsWired=!0}function c(e){void 0!==e.originalEvent&&void 0!==e.originalEvent&&(e=e.originalEvent),p.on("touchend",a),(i=k(function(){},$)).then(function(){setTimeout(s,0),p.off("touchend",a)})}function a(e){k.cancel(i),p.off("touchend",a)}function m(){p.off("dblclick",s),p.off("keydown",u),p.off("touchstart",c),t(),o(),E.beginEditEventsWired=!1}function u(e){f.isStartEditKey(e)&&s(e)}function s(e){E.grid.api.core.scrollToIfNecessary(E.row,E.col).then(function(){!function(e){if(D)return;if(i=E.col,t=E.row,n=e,t.isSaving||(angular.isFunction(i.colDef.cellEditableCondition)?!i.colDef.cellEditableCondition(E,n):!i.colDef.cellEditableCondition))return;var i,t,n;var o=E.row.getQualifiedColField(E.col);E.col.colDef.editModelField&&(o=w.preEval("row.entity."+E.col.colDef.editModelField));y=_(o),v=y(E),C=(C=(C=E.col.editableCellTemplate).replace(h.MODEL_COL_FIELD,o)).replace(h.COL_FIELD,"grid.getCellValue(row, col)");var l=E.col.colDef.editDropdownFilter?"|"+E.col.colDef.editDropdownFilter:"";C=C.replace(h.CUSTOM_FILTERS,l);var r="text";switch(E.col.colDef.type){case"boolean":r="checkbox";break;case"number":r="number";break;case"date":r="date"}C=C.replace("INPUT_TYPE",r);var d=E.col.colDef.editDropdownOptionsFunction;if(d)I.when(d(E.row.entity,E.col.colDef)).then(function(e){E.editDropdownOptionsArray=e});else{var c=E.col.colDef.editDropdownRowEntityOptionsArrayPath;E.editDropdownOptionsArray=c?function(e,i){var t=(i=(i=i.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split(".");for(;t.length;){var n=t.shift();if(!(n in e))return;e=e[n]}return e}(E.row.entity,c):E.col.colDef.editDropdownOptionsArray}E.editDropdownIdLabel=E.col.colDef.editDropdownIdLabel?E.col.colDef.editDropdownIdLabel:"id",E.editDropdownValueLabel=E.col.colDef.editDropdownValueLabel?E.col.colDef.editDropdownValueLabel:"value";var a=function(){D=!0,m();var e=angular.element(C);p.append(e),g=E.$new(),L(e)(g);var i=angular.element(p.children()[0]);i.addClass("ui-grid-cell-contents-hidden")};G.$$phase?a():E.$apply(a);var u=E.col.grid.api.core.on.scrollBegin(E,function(){E.grid.disableScrolling||(b(),E.grid.api.edit.raise.afterCellEdit(E.row.entity,E.col.colDef,y(E),v),u(),s(),f())}),s=E.$on(T.events.END_CELL_EDIT,function(){b(),E.grid.api.edit.raise.afterCellEdit(E.row.entity,E.col.colDef,y(E),v),s(),u(),f()}),f=E.$on(T.events.CANCEL_CELL_EDIT,function(){!function(){if(E.grid.disableScrolling=!1,!D)return;y.assign(E,v),E.$apply(),E.grid.api.edit.raise.cancelCellEdit(E.row.entity,E.col.colDef),b()}(),f(),u(),s()});E.$broadcast(T.events.BEGIN_CELL_EDIT,e),k(function(){E.grid.api.edit.raise.beginCellEdit(E.row.entity,E.col.colDef,e)})}(e)})}function b(){if(E.grid.disableScrolling=!1,D){n&&n.grid.api.cellNav&&n.focus();var e=angular.element(p.children()[0]);g.$destroy();for(var i=p.children(),t=1;tAlpha This feature is in development. There will almost certainly be breaking api changes, or there are major outstanding bugs. + * + * This module provides the ability to have the background of the ui-grid be empty rows, this would be displayed in the case were + * the grid height is greater then the amount of rows displayed. + * + *
    + */ + var module = angular.module('ui.grid.emptyBaseLayer', ['ui.grid']); + + + /** + * @ngdoc service + * @name ui.grid.emptyBaseLayer.service:uiGridBaseLayerService + * + * @description Services for the empty base layer grid + */ + module.service('uiGridBaseLayerService', ['gridUtil', '$compile', function (gridUtil, $compile) { + var service = { + initializeGrid: function (grid, disableEmptyBaseLayer) { + + /** + * @ngdoc object + * @name ui.grid.emptyBaseLayer.api:GridOptions + * + * @description GridOptions for emptyBaseLayer feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + grid.baseLayer = { + emptyRows: [] + }; + + /** + * @ngdoc object + * @name enableEmptyGridBaseLayer + * @propertyOf ui.grid.emptyBaseLayer.api:GridOptions + * @description Enable empty base layer, which shows empty rows as background on the entire grid + *
    Defaults to true, if the directive is used. + *
    Set to false either by setting this attribute or passing false to the directive. + */ + //default option to true unless it was explicitly set to false + if (grid.options.enableEmptyGridBaseLayer !== false) { + grid.options.enableEmptyGridBaseLayer = !disableEmptyBaseLayer; + } + }, + + setNumberOfEmptyRows: function(viewportHeight, grid) { + var rowHeight = grid.options.rowHeight, + rows = Math.ceil(viewportHeight / rowHeight); + if (rows > 0) { + grid.baseLayer.emptyRows = []; + for (var i = 0; i < rows; i++) { + grid.baseLayer.emptyRows.push({}); + } + } + } + }; + return service; + }]); + + /** + * @ngdoc object + * @name ui.grid.emptyBaseLayer.directive:uiGridEmptyBaseLayer + * @description Shows empty rows in the background of the ui-grid, these span + * the full height of the ui-grid, so that there won't be blank space below the shown rows. + * @example + *
    +   *  
    + *
    + * Or you can enable/disable it dynamically by passing in true or false. It doesn't + * the value, so it would only be set on initial render. + *
    +   *  
    + *
    + */ + module.directive('uiGridEmptyBaseLayer', ['gridUtil', 'uiGridBaseLayerService', + '$parse', + function (gridUtil, uiGridBaseLayerService, $parse) { + return { + require: '^uiGrid', + scope: false, + compile: function ($elm, $attrs) { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + var disableEmptyBaseLayer = $parse($attrs.uiGridEmptyBaseLayer)($scope) === false; + uiGridBaseLayerService.initializeGrid(uiGridCtrl.grid, disableEmptyBaseLayer); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + if (!uiGridCtrl.grid.options.enableEmptyGridBaseLayer) { + return; + } + + var renderBodyContainer = uiGridCtrl.grid.renderContainers.body, + viewportHeight = renderBodyContainer.getViewportHeight(); + + function heightHasChanged() { + var newViewPortHeight = renderBodyContainer.getViewportHeight(); + + if (newViewPortHeight !== viewportHeight) { + viewportHeight = newViewPortHeight; + return true; + } + return false; + } + + function getEmptyBaseLayerCss(viewportHeight) { + // Set ui-grid-empty-base-layer height + return '.grid' + uiGridCtrl.grid.id + + ' .ui-grid-render-container ' + + '.ui-grid-empty-base-layer-container.ui-grid-canvas ' + + '{ height: ' + viewportHeight + 'px; }'; + } + + uiGridCtrl.grid.registerStyleComputation({ + func: function() { + if (heightHasChanged()) { + uiGridBaseLayerService.setNumberOfEmptyRows(viewportHeight, uiGridCtrl.grid); + } + return getEmptyBaseLayerCss(viewportHeight); + } + }); + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.emptyBaseLayer.directive:uiGridViewport + * @description stacks on the uiGridViewport directive to append the empty grid base layer html elements to the + * default gridRow template + */ + module.directive('uiGridViewport', + ['$compile', 'gridUtil', '$templateCache', + function ($compile, gridUtil, $templateCache) { + return { + priority: -200, + scope: false, + compile: function ($elm, $attrs) { + var emptyBaseLayerContainer = $templateCache.get('ui-grid/emptyBaseLayerContainer'); + $elm.prepend(emptyBaseLayerContainer); + return { + pre: function ($scope, $elm, $attrs, controllers) { + }, + post: function ($scope, $elm, $attrs, controllers) { + } + }; + } + }; + }]); + +})(); diff --git a/release/4.4.11/ui-grid.empty-base-layer.min.js b/release/4.4.11/ui-grid.empty-base-layer.min.js new file mode 100644 index 000000000..b2fd2cbbc --- /dev/null +++ b/release/4.4.11/ui-grid.empty-base-layer.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.emptyBaseLayer",["ui.grid"]);e.service("uiGridBaseLayerService",["gridUtil","$compile",function(e,i){return{initializeGrid:function(e,i){!(e.baseLayer={emptyRows:[]})!==e.options.enableEmptyGridBaseLayer&&(e.options.enableEmptyGridBaseLayer=!i)},setNumberOfEmptyRows:function(e,i){var r=i.options.rowHeight,t=Math.ceil(e/r);if(0H%n1Pb3i#c+ny)7;uCTcozfSMOq2LYNZI_ zM;@LuOw&|#u-}%mW&-uRJ`ObH~doP0<82f`J#yAsU{>fF+Vv+VXP?|Vy!dZuUq?Hgn;OZqe0Adq#=^VN z?wHIxIn8IwehuvpqiyChliAO_>_3k7XQ1DoPEVbgO?xxu9#jy~$;;BW?19Ij&V z=a`21KPWI0d&a5xk6Am18!Y<(`d0h~$NEQEY+>-dj54%%iXBmg*ozRLnVcWS#40fs zLBYJ3#p#;^m#7G8L-JJy44{>p9B*OdI)5*-xCm^Ca#0Qizq;0uhlBo%lC zyAGSFz(3$&PJySu`xfVwl;UL;>ts7)JIXoZ>$$3kgaD;*rc7#FQSo;g=5prZX{PGB zI?Pm6PcmKA_jPqyogu5tqr>nE0yQ(sv zyK3tiyDB$#_tbWT#2W$s<&ZDo5AaJUA>SpZaoHC-e>{Hc-T3k2aS@Im=UaFCLj1B6 zxg7AzhA$NIT@LUEZ(Z*@&eJ=^YN}x6vR!_*o~?^LfVEYoXyvCE7kr8dG1k@9*r{r( z9i3}QU1(Z+Z~Y2oa$5egd+OvUa}PC`SX^8@rM#k)!#`?Sb8N$U&Y2ImiiC_1DoaBr zMQ|kzmCD7Quob9UrDL#gli_f^0ZM#6BPCK4B(o%!bVZ{_t5e&c7aJw22HqlS7wT$WdZ-vsTDKR$bHcJ|tPbfGmM zKmEBl2YX%c(@n7^O%ddvOiaQb@=WDiTEvr#t9+kT)zDp4p=%E`SJgsc9}jEA&D4a= z6z=TW+}#m!1v@)Jm-)Kk$A>w8+YH@$H(bNbP~{7M`Jz|_@?vh=uo&F_O5smJ;0JkM z$mF@P7hV|4)xZ~_5B#-^HL$i=R3%m54wHzDaMROFQSwaVTpMPZMmlMHUsXew6|5(n zcn}-gs%zZNNj0fP_;&T6@(vzSUJ3c?eW9Tzhj^D%tf(J<;`z6q6P3@(jrOcmF;^2_ zp(HuAJXzr*`^6$0Ai&nZdp{n-Ktfv=^0^SX)+hp-ox_3E#9n*VU^3RkG@)V7D`Kh? z2RIwifvw7iP;vDUAg%7Ljy2vb$)@fWOvMm(Yt7Z+3ctq3pR&)nqYL0Z?@`O zTn`31J9>C`QxbhbD1J?_!@A6Nr3m$v-XfSvVL0s-%I8ZPD3C@ggEP%D+JV95) zIX2c65L&32CU*90cPE9~ZN?4nTJH^S$VZ`!f7=Hde``Y+ky8dDw()OcyvmqwX{2BW zjnoj(n`-M?xU=msQov6^QIy>op^Uuyrk@c*F?Vx_W)db?RxkJH0Ep??J~ZnI_6ojJoRcgOqzNGML4~#39%1L zDkGjaU-&-XXc)(!WZ{I@%RdJkjv3LW_xw`x zuU#eQFRo#aM+V>Sjxa*5IE87~dXHi14TT@bNidngCkh!yE54C$a0E!O z#6o_lfFK;C!vw+sMGFH`_^!0{_5d%Edf}#4p%!lH`dUQecm5uYwL1U0ODp^rLV*U} zT3vtV9qJ}q7k`dDx>_s%>(#NKkD}Ub&bg&YIzY(9D+4YZZ8%iADtROMsN(lj7Jd?P zx%|enM&T!`s#c3P!r~7@U=~h<4aNJc*T?<5s*;jy%FJ-SUPmS#W=*VzCD-qOOiZEzJx=B)wdSvfT)5EU6+6 zma{#F4({LE9}nXcX$)BPfigNqN*k(s8x9j(Izqup#9Ixq&q7jz*e7?Ia*uW~Hp-i* zA19HNr$P9q^-I9;vfEvLS{^DmSHyn9U1+0|gTL)Iz%G1RHnOsDgJ@j9f0jsGT6EVX zO}p#~DvUU{nDPG78D;R$G8sJWGI*IzjN8~N@$|36bFE^i%XoTlCU7-@%uwgL!dKv_ zIC!eSQ&oW{94v`bWCfl;Gu&tqo`l=&INT54hCAe{(557^gg3Qs$6tJT8J5D&?#7ls zA;BvlxB}T_%-1Yo_TXL6zO~fH?~fxMZrW8 zRd}zMGx5C4u0$w=4!@s=oMh`FpF*~U{7IhQN5nNeJFI7|tS7d416MVA%%qf4W2&O5 zX^0`?6lv(d_^@0d3J?1lyYR1*j&g#V;B7)iK{-0PE5g5Qhl_23oBCxt6{xuRQ+aeN zm3|xr_iv3-qVHt*AzndQd?|hQB`BRw(CyL}kvspV@-A|ta<&eyRJODI?2*`TV&Fl= z?dfT4f$udnuCL)5)50M?4t+I2`)X&0PM*SLNhyB>LqhTKpQ0#QOy#9_(<9@_g* zV`CVI$zz0)td&FKb3&-)Si?ckbII8pD2Pc`p||lJ@pW z{CqN--oYMb$=IRYi5T$P($?x$b-tm=T<-#a$YlPP0PfrC0Ju6BkO0cK*w}-ZNXO&< z6~Sw;*$?Z;cBTGTgphyC4fqf}ce)LXQ}~w>Yyjw&fDj-S&lW$cWnF9!JBmd3Y4#ku zz^<@2*bmv4V;9PhA+N>5hd8t!4<{cwbLxbu=)c9?+BNQVeg7N6<9&-89(SU=lu1{h z&!xFtlg#DST;9{n<2Aepqn5tD@0^I)hOhdlYcR_EtFq)=_`HOTOG@K)X>d2Q{)C0-{nC6Df;8{68Q zTifp#UAv2c!L8C=OVe4Uk=xprh9*|9q(NKzis|Uaw)XHHlkxA+L*Ibra%r#X>Z6L# zdR0R_DulY77Y1=v1zH|W){4lg;(32C0O(i@?|h+K3zyfBow5_772w*1s>#(PN}>4g>#Sjd;gtz75Recd%4d( zjvhueGQU%Z+Vnn6zTG4~-6!9fGUYn@f3CbMN0ME|%W4`)!5cGKUS3>O@RmzSE#49z zL;bSD7u)CwWpR;bF(it3qgY6$664Ysr9xv}$2hVSXUQ>}75Hv`Rk+0w@gqf7BFeDx zxbijSKh%ht*4&z{UDqGh|J8NggExj!%hl{1dRvE|z_aFNytZfTig#La@RFSUXvvl? z@CYHgx)3oOT7d2?(hBH!kyb%JRHQY$8$3{?=?(AEB5kl{Hd3U$c)xcZM>kjTevzGG zuM}x|q2w*n0`!_9t$=PS(kke#BCW9yj~8hj{8W)P*kL|iq`j<>|8ab3`l*?T@sqRW zhWJLa1N+@P@sv3Q)p)pj1FbT&*m~S z#a6L8oSiu{F_kylTiS}8L^hwD$;@U)Y2-7Hk9W+@j+tXKQi`?!ae*cGeB*1SCvI(ifR=lswDeTa1b8 zS=@0__MAaGhBAg$9^5P>a-drP{}jUh%I`8Ozv!&&TiLqzm!6d}3Cxz4UxYGp=27V3 z=zNAf4vjm&orPwk-Hg=6WCM5TX#xl8JB4vZAl)L-m<4w$(!kdH+67M%baz84-O`4?O3YXw6_qoC6zMg z9ihyqy#cIZ%e335zl|iX4kk?~F_$rIV=$Qp$D}@ksBWUV)79xzDphUs=2XhE*@~rh_)UJ%|J&@dc&|y~Bf?p;1t0MEv zA3v0w_xrJanLgX!Oil{d?VB&7OF1q!4`C&ghQZ`Kc`m@}o5S+bw3})z+*YEioqoCn zzE8a=SdxJLi8K~*#Zuj80q60J%L2r4o9(!S%vgFuRfNqm(LbED{Z^mZZ+qdC1}0AT znQ2V_)rtz7kgTt7E%N9|x_o>LtH&QymZ^9t3gBl9ZNYa;U+ z)el7Gb*if)^De5_M&{jAuZzrksIG}HyS({VP-Hz6slfmy6rs8nicnn#MX0u*2-Wpa zgz5$;LUkh)p}Gl*P`v?)P`xo?_DVnB6oLH}X){h((4u8f+Z)NLnj`k6W_uI1O9Y;p zfJ@zTzgU?q7R9RnQ3C!FwWCXGz(aOqlg)!|66KcLQCZp58Zo=1o^6of{daFyM1gy% zMSK>*|6jmw*A8pTd@B#al6Ke)Melh_8eW^(616)bE#cm%-T8||;b9{X-;AYTp$4^6{Ac>fbn1}7!$?>p@`MVH8Lhye4NfFxDUeZGtn3!E_EMj2w0-7z7ZM(61O>@9X&}6h)?~{;`0YyaF zaI(eh#lc4!7nvAr8FIY=tv%>kI$E8Dy4$(ZR&iyZW7OVS)F573nlzogcbZsQ%54$L zY$4PJ5OsS~E%SJ3j*Zv5#Kvkav$rp?rF7}m6*4;_c2{$$XT_ioM(pn9IrtDc%N(}j zT@zzjTI^=bACqvA1D4Pw=d!RXTChnR9d{yFAV4p9YRTST?23tdImWNzeS{mum0oL0 zb?t5IU7ITE*hgTLK#i0AwS+vWShQowk1BkUeP-S;O zCK0hWquNcV^#fOP0B2SSr#%sJM|(G5eJFB?v7I3Hg5X5#i(KN8vmb=yJWMiu=z2fN z5HUzHL>wR)B8Et22Z)0tL&Px25OIiPh&W6#F%XZC3=v6^AtFUGL>wWRIEY6{hKQpi zL&PzXA>ug6JP6`3k|82ZGDKuZhKLgpyJrdJ5o*}mz#f%UFQ}~aC$P7pF&446EJ=@3 zLrR~N6iH7=ibPLE?Ds8+o~DKr%}I(xCnZIq`G~!BNpy-DQgm8UB>DkKk?2h1vPTuA z%&4!~c4uv+e(*^;YN8BD_P2(RfbjDO%1&B6JQaoG^u?NIo#NtE9Anz)K? z4`^54Yb@r_3fnbb&p&YhS>q>?^UCP1`9^BJ=Kd%iyknmjLFxn%B*&@CWrCM&y22NK N-Bv$|gJKtB{|!M-?z{j1 literal 0 HcmV?d00001 diff --git a/release/4.4.11/ui-grid.expandable.js b/release/4.4.11/ui-grid.expandable.js new file mode 100644 index 000000000..0e9191696 --- /dev/null +++ b/release/4.4.11/ui-grid.expandable.js @@ -0,0 +1,590 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.expandable + * @description + * + * # ui.grid.expandable + * + * + * + * This module provides the ability to create subgrids with the ability to expand a row + * to show the subgrid. + * + *
    + */ + var module = angular.module('ui.grid.expandable', ['ui.grid']); + + /** + * @ngdoc service + * @name ui.grid.expandable.service:uiGridExpandableService + * + * @description Services for the expandable grid + */ + module.service('uiGridExpandableService', ['gridUtil', '$compile', function (gridUtil, $compile) { + var service = { + initializeGrid: function (grid) { + + grid.expandable = {}; + grid.expandable.expandedAll = false; + + /** + * @ngdoc object + * @name enableExpandable + * @propertyOf ui.grid.expandable.api:GridOptions + * @description Whether or not to use expandable feature, allows you to turn off expandable on specific grids + * within your application, or in specific modes on _this_ grid. Defaults to true. + * @example + *
    +         *    $scope.gridOptions = {
    +         *      enableExpandable: false
    +         *    }
    +         *  
    + */ + grid.options.enableExpandable = grid.options.enableExpandable !== false; + + /** + * @ngdoc object + * @name showExpandAllButton + * @propertyOf ui.grid.expandable.api:GridOptions + * @description Whether or not to display the expand all button, allows you to hide expand all button on specific grids + * within your application, or in specific modes on _this_ grid. Defaults to true. + * @example + *
    +         *    $scope.gridOptions = {
    +         *      showExpandAllButton: false
    +         *    }
    +         *  
    + */ + grid.options.showExpandAllButton = grid.options.showExpandAllButton !== false; + + /** + * @ngdoc object + * @name expandableRowHeight + * @propertyOf ui.grid.expandable.api:GridOptions + * @description Height in pixels of the expanded subgrid. Defaults to + * 150 + * @example + *
    +         *    $scope.gridOptions = {
    +         *      expandableRowHeight: 150
    +         *    }
    +         *  
    + */ + grid.options.expandableRowHeight = grid.options.expandableRowHeight || 150; + + /** + * @ngdoc object + * @name expandableRowHeaderWidth + * @propertyOf ui.grid.expandable.api:GridOptions + * @description Width in pixels of the expandable column. Defaults to 40 + * @example + *
    +         *    $scope.gridOptions = {
    +         *      expandableRowHeaderWidth: 40
    +         *    }
    +         *  
    + */ + grid.options.expandableRowHeaderWidth = grid.options.expandableRowHeaderWidth || 40; + + /** + * @ngdoc object + * @name expandableRowTemplate + * @propertyOf ui.grid.expandable.api:GridOptions + * @description Mandatory. The template for your expanded row + * @example + *
    +         *    $scope.gridOptions = {
    +         *      expandableRowTemplate: 'expandableRowTemplate.html'
    +         *    }
    +         *  
    + */ + if ( grid.options.enableExpandable && !grid.options.expandableRowTemplate ){ + gridUtil.logError( 'You have not set the expandableRowTemplate, disabling expandable module' ); + grid.options.enableExpandable = false; + } + + /** + * @ngdoc object + * @name ui.grid.expandable.api:PublicApi + * + * @description Public Api for expandable feature + */ + /** + * @ngdoc object + * @name ui.grid.expandable.api:GridRow + * + * @description Additional properties added to GridRow when using the expandable module + */ + /** + * @ngdoc object + * @name ui.grid.expandable.api:GridOptions + * + * @description Options for configuring the expandable feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + var publicApi = { + events: { + expandable: { + /** + * @ngdoc event + * @name rowExpandedBeforeStateChanged + * @eventOf ui.grid.expandable.api:PublicApi + * @description raised when row is expanding or collapsing + *
    +               *      gridApi.expandable.on.rowExpandedBeforeStateChanged(scope,function(row){})
    +               * 
    + * @param {scope} scope the application scope + * @param {GridRow} row the row that was expanded + */ + rowExpandedBeforeStateChanged: function(scope, row){ + }, + /** + * @ngdoc event + * @name rowExpandedStateChanged + * @eventOf ui.grid.expandable.api:PublicApi + * @description raised when row expanded or collapsed + *
    +               *      gridApi.expandable.on.rowExpandedStateChanged(scope,function(row){})
    +               * 
    + * @param {scope} scope the application scope + * @param {GridRow} row the row that was expanded + */ + rowExpandedStateChanged: function (scope, row) { + } + } + }, + + methods: { + expandable: { + /** + * @ngdoc method + * @name toggleRowExpansion + * @methodOf ui.grid.expandable.api:PublicApi + * @description Toggle a specific row + *
    +               *      gridApi.expandable.toggleRowExpansion(rowEntity);
    +               * 
    + * @param {object} rowEntity the data entity for the row you want to expand + */ + toggleRowExpansion: function (rowEntity) { + var row = grid.getRow(rowEntity); + if (row !== null) { + service.toggleRowExpansion(grid, row); + } + }, + + /** + * @ngdoc method + * @name expandAllRows + * @methodOf ui.grid.expandable.api:PublicApi + * @description Expand all subgrids. + *
    +               *      gridApi.expandable.expandAllRows();
    +               * 
    + */ + expandAllRows: function() { + service.expandAllRows(grid); + }, + + /** + * @ngdoc method + * @name collapseAllRows + * @methodOf ui.grid.expandable.api:PublicApi + * @description Collapse all subgrids. + *
    +               *      gridApi.expandable.collapseAllRows();
    +               * 
    + */ + collapseAllRows: function() { + service.collapseAllRows(grid); + }, + + /** + * @ngdoc method + * @name toggleAllRows + * @methodOf ui.grid.expandable.api:PublicApi + * @description Toggle all subgrids. + *
    +               *      gridApi.expandable.toggleAllRows();
    +               * 
    + */ + toggleAllRows: function() { + service.toggleAllRows(grid); + }, + /** + * @ngdoc function + * @name expandRow + * @methodOf ui.grid.expandable.api:PublicApi + * @description Expand the data row + * @param {object} rowEntity gridOptions.data[] array instance + */ + expandRow: function (rowEntity) { + var row = grid.getRow(rowEntity); + if (row !== null && !row.isExpanded) { + service.toggleRowExpansion(grid, row); + } + }, + /** + * @ngdoc function + * @name collapseRow + * @methodOf ui.grid.expandable.api:PublicApi + * @description Collapse the data row + * @param {object} rowEntity gridOptions.data[] array instance + */ + collapseRow: function (rowEntity) { + var row = grid.getRow(rowEntity); + if (row !== null && row.isExpanded) { + service.toggleRowExpansion(grid, row); + } + }, + /** + * @ngdoc function + * @name getExpandedRows + * @methodOf ui.grid.expandable.api:PublicApi + * @description returns all expandedRow's entity references + */ + getExpandedRows: function () { + return service.getExpandedRows(grid).map(function (gridRow) { + return gridRow.entity; + }); + } + } + } + }; + grid.api.registerEventsFromObject(publicApi.events); + grid.api.registerMethodsFromObject(publicApi.methods); + }, + + toggleRowExpansion: function (grid, row) { + // trigger the "before change" event. Can change row height dynamically this way. + grid.api.expandable.raise.rowExpandedBeforeStateChanged(row); + /** + * @ngdoc object + * @name isExpanded + * @propertyOf ui.grid.expandable.api:GridRow + * @description Whether or not the row is currently expanded. + * @example + *
    +         *    $scope.api.expandable.on.rowExpandedStateChanged($scope, function (row) {
    +         *      if (row.isExpanded) {
    +         *        //...
    +         *      }
    +         *    });
    +         *  
    + */ + row.isExpanded = !row.isExpanded; + if (angular.isUndefined(row.expandedRowHeight)){ + row.expandedRowHeight = grid.options.expandableRowHeight; + } + + if (row.isExpanded) { + row.height = row.grid.options.rowHeight + row.expandedRowHeight; + grid.expandable.expandedAll = service.getExpandedRows(grid).length === grid.rows.length; + } else { + row.height = row.grid.options.rowHeight; + grid.expandable.expandedAll = false; + } + grid.api.expandable.raise.rowExpandedStateChanged(row); + }, + + expandAllRows: function(grid) { + grid.renderContainers.body.visibleRowCache.forEach( function(row) { + if (!row.isExpanded && !(row.entity.subGridOptions && row.entity.subGridOptions.disableRowExpandable)) { + service.toggleRowExpansion(grid, row); + } + }); + grid.expandable.expandedAll = true; + grid.queueGridRefresh(); + }, + + collapseAllRows: function(grid) { + grid.renderContainers.body.visibleRowCache.forEach( function(row) { + if (row.isExpanded) { + service.toggleRowExpansion(grid, row); + } + }); + grid.expandable.expandedAll = false; + grid.queueGridRefresh(); + }, + + toggleAllRows: function(grid) { + if (grid.expandable.expandedAll) { + service.collapseAllRows(grid); + } + else { + service.expandAllRows(grid); + } + }, + + getExpandedRows: function (grid) { + return grid.rows.filter(function (row) { + return row.isExpanded; + }); + } + }; + return service; + }]); + + /** + * @ngdoc object + * @name enableExpandableRowHeader + * @propertyOf ui.grid.expandable.api:GridOptions + * @description Show a rowHeader to provide the expandable buttons. If set to false then implies + * you're going to use a custom method for expanding and collapsing the subgrids. Defaults to true. + * @example + *
    +   *    $scope.gridOptions = {
    +   *      enableExpandableRowHeader: false
    +   *    }
    +   *  
    + */ + module.directive('uiGridExpandable', ['uiGridExpandableService', '$templateCache', + function (uiGridExpandableService, $templateCache) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridExpandableService.initializeGrid(uiGridCtrl.grid); + + if (!uiGridCtrl.grid.options.enableExpandable) { + return; + } + + if (uiGridCtrl.grid.options.enableExpandableRowHeader !== false ) { + var expandableRowHeaderColDef = { + name: 'expandableButtons', + displayName: '', + exporterSuppressExport: true, + enableColumnResizing: false, + enableColumnMenu: false, + width: uiGridCtrl.grid.options.expandableRowHeaderWidth || 40 + }; + expandableRowHeaderColDef.cellTemplate = $templateCache.get('ui-grid/expandableRowHeader'); + expandableRowHeaderColDef.headerCellTemplate = $templateCache.get('ui-grid/expandableTopRowHeader'); + uiGridCtrl.grid.addRowHeaderColumn(expandableRowHeaderColDef, -90); + } + + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.expandable.directive:uiGrid + * @description stacks on the uiGrid directive to register child grid with parent row when child is created + */ + module.directive('uiGrid', ['uiGridExpandableService', '$templateCache', + function (uiGridExpandableService, $templateCache) { + return { + replace: true, + priority: 599, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + + uiGridCtrl.grid.api.core.on.renderingComplete($scope, function() { + //if a parent grid row is on the scope, then add the parentRow property to this childGrid + if ($scope.row && $scope.row.grid && $scope.row.grid.options && $scope.row.grid.options.enableExpandable) { + + /** + * @ngdoc directive + * @name ui.grid.expandable.class:Grid + * @description Additional Grid properties added by expandable module + */ + + /** + * @ngdoc object + * @name parentRow + * @propertyOf ui.grid.expandable.class:Grid + * @description reference to the expanded parent row that owns this grid + */ + uiGridCtrl.grid.parentRow = $scope.row; + + //todo: adjust height on parent row when child grid height changes. we need some sort of gridHeightChanged event + // uiGridCtrl.grid.core.on.canvasHeightChanged($scope, function(oldHeight, newHeight) { + // uiGridCtrl.grid.parentRow = newHeight; + // }); + } + + }); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.expandable.directive:uiGridExpandableRow + * @description directive to render the expandable row template + */ + module.directive('uiGridExpandableRow', + ['uiGridExpandableService', '$timeout', '$compile', 'uiGridConstants','gridUtil','$interval', '$log', + function (uiGridExpandableService, $timeout, $compile, uiGridConstants, gridUtil, $interval, $log) { + + return { + replace: false, + priority: 0, + scope: false, + + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + gridUtil.getTemplate($scope.grid.options.expandableRowTemplate).then( + function (template) { + if ($scope.grid.options.expandableRowScope) { + /** + * @ngdoc object + * @name expandableRowScope + * @propertyOf ui.grid.expandable.api:GridOptions + * @description Variables of object expandableScope will be available in the scope of the expanded subgrid + * @example + *
    +                     *    $scope.gridOptions = {
    +                     *      expandableRowScope: expandableScope
    +                     *    }
    +                     *  
    + */ + var expandableRowScope = $scope.grid.options.expandableRowScope; + for (var property in expandableRowScope) { + if (expandableRowScope.hasOwnProperty(property)) { + $scope[property] = expandableRowScope[property]; + } + } + } + var expandedRowElement = angular.element(template); + $elm.append(expandedRowElement); + expandedRowElement = $compile(expandedRowElement)($scope); + $scope.row.expandedRendered = true; + }); + }, + + post: function ($scope, $elm, $attrs, uiGridCtrl) { + $scope.$on('$destroy', function() { + $scope.row.expandedRendered = false; + }); + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.expandable.directive:uiGridRow + * @description stacks on the uiGridRow directive to add support for expandable rows + */ + module.directive('uiGridRow', + ['$compile', 'gridUtil', '$templateCache', + function ($compile, gridUtil, $templateCache) { + return { + priority: -200, + scope: false, + compile: function ($elm, $attrs) { + return { + pre: function ($scope, $elm, $attrs, controllers) { + + if (!$scope.grid.options.enableExpandable) { + return; + } + + $scope.expandableRow = {}; + + $scope.expandableRow.shouldRenderExpand = function () { + var ret = $scope.colContainer.name === 'body' && $scope.grid.options.enableExpandable !== false && $scope.row.isExpanded && (!$scope.grid.isScrollingVertically || $scope.row.expandedRendered); + return ret; + }; + + $scope.expandableRow.shouldRenderFiller = function () { + var ret = $scope.row.isExpanded && ( $scope.colContainer.name !== 'body' || ($scope.grid.isScrollingVertically && !$scope.row.expandedRendered)); + return ret; + }; + + /* + * Commented out @PaulL1. This has no purpose that I can see, and causes #2964. If this code needs to be reinstated for some + * reason it needs to use drawnWidth, not width, and needs to check column visibility. It should really use render container + * visible column cache also instead of checking column.renderContainer. + function updateRowContainerWidth() { + var grid = $scope.grid; + var colWidth = 0; + grid.columns.forEach( function (column) { + if (column.renderContainer === 'left') { + colWidth += column.width; + } + }); + colWidth = Math.floor(colWidth); + return '.grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.colContainer.name + ', .grid' + grid.id + + ' .ui-grid-pinned-container-' + $scope.colContainer.name + ' .ui-grid-render-container-' + $scope.colContainer.name + + ' .ui-grid-viewport .ui-grid-canvas .ui-grid-row { width: ' + colWidth + 'px; }'; + } + + if ($scope.colContainer.name === 'left') { + $scope.grid.registerStyleComputation({ + priority: 15, + func: updateRowContainerWidth + }); + }*/ + + }, + post: function ($scope, $elm, $attrs, controllers) { + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.expandable.directive:uiGridViewport + * @description stacks on the uiGridViewport directive to append the expandable row html elements to the + * default gridRow template + */ + module.directive('uiGridViewport', + ['$compile', 'gridUtil', '$templateCache', + function ($compile, gridUtil, $templateCache) { + return { + priority: -200, + scope: false, + compile: function ($elm, $attrs) { + + //todo: this adds ng-if watchers to each row even if the grid is not using expandable directive + // or options.enableExpandable == false + // The alternative is to compile the template and append to each row in a uiGridRow directive + + var rowRepeatDiv = angular.element($elm.children().children()[0]); + var expandedRowFillerElement = $templateCache.get('ui-grid/expandableScrollFiller'); + var expandedRowElement = $templateCache.get('ui-grid/expandableRow'); + rowRepeatDiv.append(expandedRowElement); + rowRepeatDiv.append(expandedRowFillerElement); + return { + pre: function ($scope, $elm, $attrs, controllers) { + }, + post: function ($scope, $elm, $attrs, controllers) { + } + }; + } + }; + }]); + +})(); diff --git a/release/4.4.11/ui-grid.expandable.min.js b/release/4.4.11/ui-grid.expandable.min.js new file mode 100644 index 000000000..7bceaef08 --- /dev/null +++ b/release/4.4.11/ui-grid.expandable.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.expandable",["ui.grid"]);e.service("uiGridExpandableService",["gridUtil","$compile",function(n,e){var i={initializeGrid:function(o){o.expandable={},o.expandable.expandedAll=!1,o.options.enableExpandable=!1!==o.options.enableExpandable,o.options.showExpandAllButton=!1!==o.options.showExpandAllButton,o.options.expandableRowHeight=o.options.expandableRowHeight||150,o.options.expandableRowHeaderWidth=o.options.expandableRowHeaderWidth||40,o.options.enableExpandable&&!o.options.expandableRowTemplate&&(n.logError("You have not set the expandableRowTemplate, disabling expandable module"),o.options.enableExpandable=!1);var e={events:{expandable:{rowExpandedBeforeStateChanged:function(e,n){},rowExpandedStateChanged:function(e,n){}}},methods:{expandable:{toggleRowExpansion:function(e){var n=o.getRow(e);null!==n&&i.toggleRowExpansion(o,n)},expandAllRows:function(){i.expandAllRows(o)},collapseAllRows:function(){i.collapseAllRows(o)},toggleAllRows:function(){i.toggleAllRows(o)},expandRow:function(e){var n=o.getRow(e);null===n||n.isExpanded||i.toggleRowExpansion(o,n)},collapseRow:function(e){var n=o.getRow(e);null!==n&&n.isExpanded&&i.toggleRowExpansion(o,n)},getExpandedRows:function(){return i.getExpandedRows(o).map(function(e){return e.entity})}}}};o.api.registerEventsFromObject(e.events),o.api.registerMethodsFromObject(e.methods)},toggleRowExpansion:function(e,n){e.api.expandable.raise.rowExpandedBeforeStateChanged(n),n.isExpanded=!n.isExpanded,angular.isUndefined(n.expandedRowHeight)&&(n.expandedRowHeight=e.options.expandableRowHeight),n.isExpanded?(n.height=n.grid.options.rowHeight+n.expandedRowHeight,e.expandable.expandedAll=i.getExpandedRows(e).length===e.rows.length):(n.height=n.grid.options.rowHeight,e.expandable.expandedAll=!1),e.api.expandable.raise.rowExpandedStateChanged(n)},expandAllRows:function(n){n.renderContainers.body.visibleRowCache.forEach(function(e){e.isExpanded||e.entity.subGridOptions&&e.entity.subGridOptions.disableRowExpandable||i.toggleRowExpansion(n,e)}),n.expandable.expandedAll=!0,n.queueGridRefresh()},collapseAllRows:function(n){n.renderContainers.body.visibleRowCache.forEach(function(e){e.isExpanded&&i.toggleRowExpansion(n,e)}),n.expandable.expandedAll=!1,n.queueGridRefresh()},toggleAllRows:function(e){e.expandable.expandedAll?i.collapseAllRows(e):i.expandAllRows(e)},getExpandedRows:function(e){return e.rows.filter(function(e){return e.isExpanded})}};return i}]),e.directive("uiGridExpandable",["uiGridExpandableService","$templateCache",function(d,t){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,n,o,i){if(d.initializeGrid(i.grid),i.grid.options.enableExpandable&&!1!==i.grid.options.enableExpandableRowHeader){var a={name:"expandableButtons",displayName:"",exporterSuppressExport:!0,enableColumnResizing:!1,enableColumnMenu:!1,width:i.grid.options.expandableRowHeaderWidth||40};a.cellTemplate=t.get("ui-grid/expandableRowHeader"),a.headerCellTemplate=t.get("ui-grid/expandableTopRowHeader"),i.grid.addRowHeaderColumn(a,-90)}},post:function(e,n,o,i){}}}}}]),e.directive("uiGrid",["uiGridExpandableService","$templateCache",function(e,n){return{replace:!0,priority:599,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,n,o,i){i.grid.api.core.on.renderingComplete(e,function(){e.row&&e.row.grid&&e.row.grid.options&&e.row.grid.options.enableExpandable&&(i.grid.parentRow=e.row)})},post:function(e,n,o,i){}}}}}]),e.directive("uiGridExpandableRow",["uiGridExpandableService","$timeout","$compile","uiGridConstants","gridUtil","$interval","$log",function(e,n,t,o,i,a,d){return{replace:!1,priority:0,scope:!1,compile:function(){return{pre:function(a,d,e,n){i.getTemplate(a.grid.options.expandableRowTemplate).then(function(e){if(a.grid.options.expandableRowScope){var n=a.grid.options.expandableRowScope;for(var o in n)n.hasOwnProperty(o)&&(a[o]=n[o])}var i=angular.element(e);d.append(i),i=t(i)(a),a.row.expandedRendered=!0})},post:function(e,n,o,i){e.$on("$destroy",function(){e.row.expandedRendered=!1})}}}}}]),e.directive("uiGridRow",["$compile","gridUtil","$templateCache",function(e,n,o){return{priority:-200,scope:!1,compile:function(e,n){return{pre:function(e,n,o,i){e.grid.options.enableExpandable&&(e.expandableRow={},e.expandableRow.shouldRenderExpand=function(){return"body"===e.colContainer.name&&!1!==e.grid.options.enableExpandable&&e.row.isExpanded&&(!e.grid.isScrollingVertically||e.row.expandedRendered)},e.expandableRow.shouldRenderFiller=function(){return e.row.isExpanded&&("body"!==e.colContainer.name||e.grid.isScrollingVertically&&!e.row.expandedRendered)})},post:function(e,n,o,i){}}}}}]),e.directive("uiGridViewport",["$compile","gridUtil","$templateCache",function(e,n,d){return{priority:-200,scope:!1,compile:function(e,n){var o=angular.element(e.children().children()[0]),i=d.get("ui-grid/expandableScrollFiller"),a=d.get("ui-grid/expandableRow");return o.append(a),o.append(i),{pre:function(e,n,o,i){},post:function(e,n,o,i){}}}}}])}(); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.exporter.js b/release/4.4.11/ui-grid.exporter.js new file mode 100644 index 000000000..cb4c03133 --- /dev/null +++ b/release/4.4.11/ui-grid.exporter.js @@ -0,0 +1,1739 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +/* global ExcelBuilder */ +/* global console */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.exporter + * @description + * + * # ui.grid.exporter + * + * + * + * This module provides the ability to export data from the grid. + * + * Data can be exported in a range of formats, and all data, visible + * data, or selected rows can be exported, with all columns or visible + * columns. + * + * No UI is provided, the caller should provide their own UI/buttons + * as appropriate, or enable the gridMenu + * + *
    + *
    + * + *
    + */ + + var module = angular.module('ui.grid.exporter', ['ui.grid']); + + /** + * @ngdoc object + * @name ui.grid.exporter.constant:uiGridExporterConstants + * + * @description constants available in exporter module + */ + /** + * @ngdoc property + * @propertyOf ui.grid.exporter.constant:uiGridExporterConstants + * @name ALL + * @description export all data, including data not visible. Can + * be set for either rowTypes or colTypes + */ + /** + * @ngdoc property + * @propertyOf ui.grid.exporter.constant:uiGridExporterConstants + * @name VISIBLE + * @description export only visible data, including data not visible. Can + * be set for either rowTypes or colTypes + */ + /** + * @ngdoc property + * @propertyOf ui.grid.exporter.constant:uiGridExporterConstants + * @name SELECTED + * @description export all data, including data not visible. Can + * be set only for rowTypes, selection of only some columns is + * not supported + */ + module.constant('uiGridExporterConstants', { + featureName: 'exporter', + rowHeaderColName: 'treeBaseRowHeaderCol', + selectionRowHeaderColName: 'selectionRowHeaderCol', + ALL: 'all', + VISIBLE: 'visible', + SELECTED: 'selected', + CSV_CONTENT: 'CSV_CONTENT', + BUTTON_LABEL: 'BUTTON_LABEL', + FILE_NAME: 'FILE_NAME' + }); + + /** + * @ngdoc service + * @name ui.grid.exporter.service:uiGridExporterService + * + * @description Services for exporter feature + */ + module.service('uiGridExporterService', ['$filter', '$q', 'uiGridExporterConstants', 'gridUtil', '$compile', '$interval', 'i18nService', + function ($filter, $q, uiGridExporterConstants, gridUtil, $compile, $interval, i18nService) { + var service = { + + delay: 100, + + initializeGrid: function (grid) { + + //add feature namespace and any properties to grid for needed state + grid.exporter = {}; + this.defaultGridOptions(grid.options); + + /** + * @ngdoc object + * @name ui.grid.exporter.api:PublicApi + * + * @description Public Api for exporter feature + */ + var publicApi = { + events: { + exporter: { + } + }, + methods: { + exporter: { + /** + * @ngdoc function + * @name csvExport + * @methodOf ui.grid.exporter.api:PublicApi + * @description Exports rows from the grid in csv format, + * the data exported is selected based on the provided options + * @param {string} rowTypes which rows to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + * @param {string} colTypes which columns to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE + */ + csvExport: function (rowTypes, colTypes) { + service.csvExport(grid, rowTypes, colTypes); + }, + /** + * @ngdoc function + * @name pdfExport + * @methodOf ui.grid.exporter.api:PublicApi + * @description Exports rows from the grid in pdf format, + * the data exported is selected based on the provided options + * Note that this function has a dependency on pdfMake, all + * going well this has been installed for you. + * The resulting pdf opens in a new browser window. + * @param {string} rowTypes which rows to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + * @param {string} colTypes which columns to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE + */ + pdfExport: function (rowTypes, colTypes) { + service.pdfExport(grid, rowTypes, colTypes); + }, + /** + * @ngdoc function + * @name excelExport + * @methodOf ui.grid.exporter.api:PublicApi + * @description Exports rows from the grid in excel format, + * the data exported is selected based on the provided options + * @param {string} rowTypes which rows to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + * @param {string} colTypes which columns to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE + */ + excelExport: function (rowTypes, colTypes) { + service.excelExport(grid, rowTypes, colTypes); + } + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + + grid.api.registerMethodsFromObject(publicApi.methods); + + if (grid.api.core.addToGridMenu){ + service.addToMenu( grid ); + } else { + // order of registration is not guaranteed, register in a little while + $interval( function() { + if (grid.api.core.addToGridMenu){ + service.addToMenu( grid ); + } + }, this.delay, 1); + } + + }, + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.exporter.api:GridOptions + * + * @description GridOptions for exporter feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + /** + * @ngdoc object + * @name ui.grid.exporter.api:ColumnDef + * @description ColumnDef settings for exporter + */ + /** + * @ngdoc object + * @name exporterSuppressMenu + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Don't show the export menu button, implying the user + * will roll their own UI for calling the exporter + *
    Defaults to false + */ + gridOptions.exporterSuppressMenu = gridOptions.exporterSuppressMenu === true; + /** + * @ngdoc object + * @name exporterMenuLabel + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The text to show on the exporter menu button + * link + *
    Defaults to 'Export' + */ + gridOptions.exporterMenuLabel = gridOptions.exporterMenuLabel ? gridOptions.exporterMenuLabel : 'Export'; + /** + * @ngdoc object + * @name exporterSuppressColumns + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Columns that should not be exported. The selectionRowHeader is already automatically + * suppressed, but if you had a button column or some other "system" column that shouldn't be shown in the + * output then add it in this list. You should provide an array of column names. + *
    Defaults to: [] + *
    +           *   gridOptions.exporterSuppressColumns = [ 'buttons' ];
    +           * 
    + */ + gridOptions.exporterSuppressColumns = gridOptions.exporterSuppressColumns ? gridOptions.exporterSuppressColumns : []; + /** + * @ngdoc object + * @name exporterCsvColumnSeparator + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The character to use as column separator + * link + *
    Defaults to ',' + */ + gridOptions.exporterCsvColumnSeparator = gridOptions.exporterCsvColumnSeparator ? gridOptions.exporterCsvColumnSeparator : ','; + /** + * @ngdoc object + * @name exporterCsvFilename + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The default filename to use when saving the downloaded csv. + * This will only work in some browsers. + *
    Defaults to 'download.csv' + */ + gridOptions.exporterCsvFilename = gridOptions.exporterCsvFilename ? gridOptions.exporterCsvFilename : 'download.csv'; + /** + * @ngdoc object + * @name exporterPdfFilename + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The default filename to use when saving the downloaded pdf, only used in IE (other browsers open pdfs in a new window) + *
    Defaults to 'download.pdf' + */ + gridOptions.exporterPdfFilename = gridOptions.exporterPdfFilename ? gridOptions.exporterPdfFilename : 'download.pdf'; + /** + * @ngdoc object + * @name exporterExcelFilename + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The default filename to use when saving the downloaded excel, only used in IE (other browsers open excels in a new window) + *
    Defaults to 'download.xlsx' + */ + gridOptions.exporterExcelFilename = gridOptions.exporterExcelFilename ? gridOptions.exporterExcelFilename : 'download.xlsx'; + + /** + * @ngdoc object + * @name exporterExcelSheetName + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The default sheetname to use when saving the downloaded to excel + *
    Defaults to 'Sheet1' + */ + gridOptions.exporterExcelSheetName = gridOptions.exporterExcelSheetName ? gridOptions.exporterExcelSheetName : 'Sheet1'; + + /** + * @ngdoc object + * @name exporterOlderExcelCompatibility + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Some versions of excel don't like the utf-16 BOM on the front, and it comes + * through as  in the first column header. Setting this option to false will suppress this, at the + * expense of proper utf-16 handling in applications that do recognise the BOM + *
    Defaults to false + */ + gridOptions.exporterOlderExcelCompatibility = gridOptions.exporterOlderExcelCompatibility === true; + /** + * @ngdoc object + * @name exporterIsExcelCompatible + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Separator header, used to set a custom column separator in a csv file, only works on MS Excel. + * Used it on other programs will make csv content display unproperly. Setting this option to false won't add this header. + *
    Defaults to false + */ + gridOptions.exporterIsExcelCompatible = gridOptions.exporterIsExcelCompatible === true; + /** + * @ngdoc object + * @name exporterMenuItemOrder + * @propertyOf ui.grid.exporter.api:GridOptions + * @description An option to determine the starting point for the menu items created by the exporter + *
    Defaults to 200 + */ + gridOptions.exporterMenuItemOrder = gridOptions.exporterMenuItemOrder ? gridOptions.exporterMenuItemOrder : 200; + /** + * @ngdoc object + * @name exporterPdfDefaultStyle + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The default style in pdfMake format + *
    Defaults to: + *
    +           *   {
    +           *     fontSize: 11
    +           *   }
    +           * 
    + */ + gridOptions.exporterPdfDefaultStyle = gridOptions.exporterPdfDefaultStyle ? gridOptions.exporterPdfDefaultStyle : { fontSize: 11 }; + /** + * @ngdoc object + * @name exporterPdfTableStyle + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The table style in pdfMake format + *
    Defaults to: + *
    +           *   {
    +           *     margin: [0, 5, 0, 15]
    +           *   }
    +           * 
    + */ + gridOptions.exporterPdfTableStyle = gridOptions.exporterPdfTableStyle ? gridOptions.exporterPdfTableStyle : { margin: [0, 5, 0, 15] }; + /** + * @ngdoc object + * @name exporterPdfTableHeaderStyle + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The tableHeader style in pdfMake format + *
    Defaults to: + *
    +           *   {
    +           *     bold: true,
    +           *     fontSize: 12,
    +           *     color: 'black'
    +           *   }
    +           * 
    + */ + gridOptions.exporterPdfTableHeaderStyle = gridOptions.exporterPdfTableHeaderStyle ? gridOptions.exporterPdfTableHeaderStyle : { bold: true, fontSize: 12, color: 'black' }; + /** + * @ngdoc object + * @name exporterPdfHeader + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The header section for pdf exports. Can be + * simple text: + *
    +           *   gridOptions.exporterPdfHeader = 'My Header';
    +           * 
    + * Can be a more complex object in pdfMake format: + *
    +           *   gridOptions.exporterPdfHeader = {
    +           *     columns: [
    +           *       'Left part',
    +           *       { text: 'Right part', alignment: 'right' }
    +           *     ]
    +           *   };
    +           * 
    + * Or can be a function, allowing page numbers and the like + *
    +           *   gridOptions.exporterPdfHeader: function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; };
    +           * 
    + */ + gridOptions.exporterPdfHeader = gridOptions.exporterPdfHeader ? gridOptions.exporterPdfHeader : null; + /** + * @ngdoc object + * @name exporterPdfFooter + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The header section for pdf exports. Can be + * simple text: + *
    +           *   gridOptions.exporterPdfFooter = 'My Footer';
    +           * 
    + * Can be a more complex object in pdfMake format: + *
    +           *   gridOptions.exporterPdfFooter = {
    +           *     columns: [
    +           *       'Left part',
    +           *       { text: 'Right part', alignment: 'right' }
    +           *     ]
    +           *   };
    +           * 
    + * Or can be a function, allowing page numbers and the like + *
    +           *   gridOptions.exporterPdfFooter: function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; };
    +           * 
    + */ + gridOptions.exporterPdfFooter = gridOptions.exporterPdfFooter ? gridOptions.exporterPdfFooter : null; + /** + * @ngdoc object + * @name exporterPdfOrientation + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The orientation, should be a valid pdfMake value, + * 'landscape' or 'portrait' + *
    Defaults to landscape + */ + gridOptions.exporterPdfOrientation = gridOptions.exporterPdfOrientation ? gridOptions.exporterPdfOrientation : 'landscape'; + /** + * @ngdoc object + * @name exporterPdfPageSize + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The orientation, should be a valid pdfMake + * paper size, usually 'A4' or 'LETTER' + * {@link https://github.com/bpampuch/pdfmake/blob/master/src/standardPageSizes.js pdfMake page sizes} + *
    Defaults to A4 + */ + gridOptions.exporterPdfPageSize = gridOptions.exporterPdfPageSize ? gridOptions.exporterPdfPageSize : 'A4'; + /** + * @ngdoc object + * @name exporterPdfMaxGridWidth + * @propertyOf ui.grid.exporter.api:GridOptions + * @description The maxium grid width - the current grid width + * will be scaled to match this, with any fixed width columns + * being adjusted accordingly. + *
    Defaults to 720 (for A4 landscape), use 670 for LETTER + */ + gridOptions.exporterPdfMaxGridWidth = gridOptions.exporterPdfMaxGridWidth ? gridOptions.exporterPdfMaxGridWidth : 720; + /** + * @ngdoc object + * @name exporterPdfTableLayout + * @propertyOf ui.grid.exporter.api:GridOptions + * @description A tableLayout in pdfMake format, + * controls gridlines and the like. We use the default + * layout usually. + *
    Defaults to null, which means no layout + */ + + /** + * @ngdoc object + * @name exporterMenuAllData + * @porpertyOf ui.grid.exporter.api:GridOptions + * @description Add export all data as cvs/pdf menu items to the ui-grid grid menu, if it's present. Defaults to true. + */ + gridOptions.exporterMenuAllData = gridOptions.exporterMenuAllData !== undefined ? gridOptions.exporterMenuAllData : true; + + /** + * @ngdoc object + * @name exporterMenuVisibleData + * @porpertyOf ui.grid.exporter.api:GridOptions + * @description Add export visible data as cvs/pdf menu items to the ui-grid grid menu, if it's present. Defaults to true. + */ + gridOptions.exporterMenuVisibleData = gridOptions.exporterMenuVisibleData !== undefined ? gridOptions.exporterMenuVisibleData : true; + + /** + * @ngdoc object + * @name exporterMenuSelectedData + * @porpertyOf ui.grid.exporter.api:GridOptions + * @description Add export selected data as cvs/pdf menu items to the ui-grid grid menu, if it's present. Defaults to true. + */ + gridOptions.exporterMenuSelectedData = gridOptions.exporterMenuSelectedData !== undefined ? gridOptions.exporterMenuSelectedData : true; + + /** + * @ngdoc object + * @name exporterMenuCsv + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Add csv export menu items to the ui-grid grid menu, if it's present. Defaults to true. + */ + gridOptions.exporterMenuCsv = gridOptions.exporterMenuCsv !== undefined ? gridOptions.exporterMenuCsv : true; + + /** + * @ngdoc object + * @name exporterMenuPdf + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Add pdf export menu items to the ui-grid grid menu, if it's present. Defaults to true. + */ + gridOptions.exporterMenuPdf = gridOptions.exporterMenuPdf !== undefined ? gridOptions.exporterMenuPdf : true; + + /** + * @ngdoc object + * @name exporterMenuExcel + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Add excel export menu items to the ui-grid grid menu, if it's present. Defaults to true. + */ + gridOptions.exporterMenuExcel = gridOptions.exporterMenuExcel !== undefined ? gridOptions.exporterMenuExcel : true; + + /** + * @ngdoc object + * @name exporterPdfCustomFormatter + * @propertyOf ui.grid.exporter.api:GridOptions + * @description A custom callback routine that changes the pdf document, adding any + * custom styling or content that is supported by pdfMake. Takes in the complete docDefinition, and + * must return an updated docDefinition ready for pdfMake. + * @example + * In this example we add a style to the style array, so that we can use it in our + * footer definition. + *
    +           *   gridOptions.exporterPdfCustomFormatter = function ( docDefinition ) {
    +           *     docDefinition.styles.footerStyle = { bold: true, fontSize: 10 };
    +           *     return docDefinition;
    +           *   }
    +           *
    +           *   gridOptions.exporterPdfFooter = { text: 'My footer', style: 'footerStyle' }
    +           * 
    + */ + gridOptions.exporterPdfCustomFormatter = ( gridOptions.exporterPdfCustomFormatter && typeof( gridOptions.exporterPdfCustomFormatter ) === 'function' ) ? gridOptions.exporterPdfCustomFormatter : function ( docDef ) { return docDef; }; + + /** + * @ngdoc object + * @name exporterHeaderFilterUseName + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Defaults to false, which leads to `displayName` being passed into the headerFilter. + * If set to true, then will pass `name` instead. + * + * + * @example + *
    +           *   gridOptions.exporterHeaderFilterUseName = true;
    +           * 
    + */ + gridOptions.exporterHeaderFilterUseName = gridOptions.exporterHeaderFilterUseName === true; + + /** + * @ngdoc object + * @name exporterHeaderFilter + * @propertyOf ui.grid.exporter.api:GridOptions + * @description A function to apply to the header displayNames before exporting. Useful for internationalisation, + * for example if you were using angular-translate you'd set this to `$translate.instant`. Note that this + * call must be synchronous, it cannot be a call that returns a promise. + * + * Behaviour can be changed to pass in `name` instead of `displayName` through use of `exporterHeaderFilterUseName: true`. + * + * @example + *
    +           *   gridOptions.exporterHeaderFilter = function( displayName ){ return 'col: ' + name; };
    +           * 
    + * OR + *
    +           *   gridOptions.exporterHeaderFilter = $translate.instant;
    +           * 
    + */ + + /** + * @ngdoc function + * @name exporterFieldCallback + * @propertyOf ui.grid.exporter.api:GridOptions + * @description A function to call for each field before exporting it. Allows + * massaging of raw data into a display format, for example if you have applied + * filters to convert codes into decodes, or you require + * a specific date format in the exported content. + * + * The method is called once for each field exported, and provides the grid, the + * gridCol and the GridRow for you to use as context in massaging the data. + * + * @param {Grid} grid provides the grid in case you have need of it + * @param {GridRow} row the row from which the data comes + * @param {GridColumn} col the column from which the data comes + * @param {object} value the value for your massaging + * @returns {object} you must return the massaged value ready for exporting + * + * @example + *
    +           *   gridOptions.exporterFieldCallback = function ( grid, row, col, value ){
    +           *     if ( col.name === 'status' ){
    +           *       value = decodeStatus( value );
    +           *     }
    +           *     return value;
    +           *   }
    +           * 
    + */ + gridOptions.exporterFieldCallback = gridOptions.exporterFieldCallback ? gridOptions.exporterFieldCallback : defaultExporterFieldCallback; + + /** + * @ngdoc function + * @name exporterFieldFormatCallback + * @propertyOf ui.grid.exporter.api:GridOptions + * @description A function to call for each field before exporting it. Allows + * general object to be return to modify the format of a cell in the case of + * excel exports + * + * The method is called once for each field exported, and provides the grid, the + * gridCol and the GridRow for you to use as context in massaging the data. + * + * @param {Grid} grid provides the grid in case you have need of it + * @param {GridRow} row the row from which the data comes + * @param {GridColumn} col the column from which the data comes + * @param {object} value the value for your massaging + * @returns {object} you must return the massaged value ready for exporting + * + * @example + *
    +           *   gridOptions.exporterFieldCallback = function ( grid, row, col, value ){
    +           *     if ( col.name === 'status' ){
    +           *       value = decodeStatus( value );
    +           *     }
    +           *     return value;
    +           *   }
    +           * 
    + */ + gridOptions.exporterFieldFormatCallback = gridOptions.exporterFieldFormatCallback ? gridOptions.exporterFieldFormatCallback : function( grid, row, col, value ) { return null; }; + + /** + * @ngdoc function + * @name exporterExcelCustomFormatters + * @propertyOf ui.grid.exporter.api:GridOptions + * @description A function to call to setup formatters and store on docDefinition. + * + * The method is called at the start and can setup all the formatters to export to excel + * + * @param {Grid} grid provides the grid in case you have need of it + * @param {Workbook} row the row from which the data comes + * @param {docDefinition} The docDefinition that will have styles as a object to store formatters + * @returns {docDefinition} Updated docDefinition with formatter styles + * + * @example + *
    +           *   gridOptions.exporterExcelCustomFormatters = function(grid, workbook, docDefinition) {
    +           *     const formatters = {};
    +           *     const stylesheet = workbook.getStyleSheet();
    +           *     const headerFormatDefn = {
    +           *       'font': { 'size': 11, 'fontName': 'Calibri', 'bold': true },
    +           *       'alignment': { 'wrapText': false }
    +           *     };
    +           *
    +           *     formatters['header'] = headerFormatter;
    +           *     Object.assign(docDefinition.styles , formatters);
    +           *     grid.docDefinition = docDefinition;
    +           *     return docDefinition;
    +           *   }
    +           * 
    + */ + gridOptions.exporterExcelCustomFormatters = gridOptions.exporterExcelCustomFormatters ? gridOptions.exporterExcelCustomFormatters : function( grid, workbook, docDefinition ) { return null; }; + + /** + * @ngdoc function + * @name exporterExcelHeader + * @propertyOf ui.grid.exporter.api:GridOptions + * @description A function to write formatted header data to sheet. + * + * The method is called to provide custom header building for Excel. This data comes before the grid header + * + * @param {grid} grid provides the grid in case you have need of it + * @param {Workbook} row the row from which the data comes + * @param {Sheet} the sheet to insert data + * @param {docDefinition} The docDefinition that will have styles as a object to store formatters + * @returns {docDefinition} Updated docDefinition with formatter styles + * + * @example + *
    +           *   gridOptions.exporterExcelCustomFormatters = function (grid, workbook, sheet, docDefinition) {
    +           *      const headerFormatter = docDefinition.styles['header'];
    +           *      let cols = [];
    +           *      // push data in A1 cell with metadata formatter
    +           *      cols.push({ value: 'Summary Report', metadata: {style: headerFormatter.id} });
    +           *      sheet.data.push(cols);
    +           *   }
    +           * 
    + */ + gridOptions.exporterExcelHeader = gridOptions.exporterExcelHeader ? gridOptions.exporterExcelHeader : function( grid, workbook, sheet, docDefinition ) { return null; }; + + + /** + * @ngdoc object + * @name exporterColumnScaleFactor + * @propertyOf ui.grid.exporter.api:GridOptions + * @description A scaling factor to divide the drawnwidth of a column to convert to target excel column + * format size + * @example + * In this example we add a number to divide the drawnwidth of a column to get the excel width. + *
    Defaults to 3.5 + */ + gridOptions.exporterColumnScaleFactor = gridOptions.exporterColumnScaleFactor ? gridOptions.exporterColumnScaleFactor : 3.5; + + /** + * @ngdoc object + * @name exporterFieldApplyFilters + * @propertyOf ui.grid.exporter.api:GridOptions + * @description Defaults to false, which leads to filters being evaluated on export * + * + * @example + *
    +           *   gridOptions.exporterFieldApplyFilters = true;
    +           * 
    + */ + gridOptions.exporterFieldApplyFilters = gridOptions.exporterFieldApplyFilters === true; + + /** + * @ngdoc function + * @name exporterAllDataFn + * @propertyOf ui.grid.exporter.api:GridOptions + * @description This promise is needed when exporting all rows, + * and the data need to be provided by server side. Default is null. + * @returns {Promise} a promise to load all data from server + * + * @example + *
    +           *   gridOptions.exporterAllDataFn = function () {
    +           *     return $http.get('/data/100.json')
    +           *   }
    +           * 
    + */ + gridOptions.exporterAllDataFn = gridOptions.exporterAllDataFn ? gridOptions.exporterAllDataFn : null; + + /** + * @ngdoc function + * @name exporterAllDataPromise + * @propertyOf ui.grid.exporter.api:GridOptions + * @description DEPRECATED - exporterAllDataFn used to be + * called this, but it wasn't a promise, it was a function that returned + * a promise. Deprecated, but supported for backward compatibility, use + * exporterAllDataFn instead. + * @returns {Promise} a promise to load all data from server + * + * @example + *
    +           *   gridOptions.exporterAllDataFn = function () {
    +           *     return $http.get('/data/100.json')
    +           *   }
    +           * 
    + */ + if ( gridOptions.exporterAllDataFn === null && gridOptions.exporterAllDataPromise ) { + gridOptions.exporterAllDataFn = gridOptions.exporterAllDataPromise; + } + }, + + + /** + * @ngdoc function + * @name addToMenu + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Adds export items to the grid menu, + * allowing the user to select export options + * @param {Grid} grid the grid from which data should be exported + */ + addToMenu: function ( grid ) { + grid.api.core.addToGridMenu( grid, [ + { + title: i18nService.getSafeText('gridMenu.exporterAllAsCsv'), + action: function ($event) { + grid.api.exporter.csvExport( uiGridExporterConstants.ALL, uiGridExporterConstants.ALL ); + }, + shown: function() { + return grid.options.exporterMenuCsv && grid.options.exporterMenuAllData; + }, + order: grid.options.exporterMenuItemOrder + }, + { + title: i18nService.getSafeText('gridMenu.exporterVisibleAsCsv'), + action: function ($event) { + grid.api.exporter.csvExport( uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE ); + }, + shown: function() { + return grid.options.exporterMenuCsv && grid.options.exporterMenuVisibleData; + }, + order: grid.options.exporterMenuItemOrder + 1 + }, + { + title: i18nService.getSafeText('gridMenu.exporterSelectedAsCsv'), + action: function ($event) { + grid.api.exporter.csvExport( uiGridExporterConstants.SELECTED, uiGridExporterConstants.VISIBLE ); + }, + shown: function() { + return grid.options.exporterMenuCsv && grid.options.exporterMenuSelectedData && + ( grid.api.selection && grid.api.selection.getSelectedRows().length > 0 ); + }, + order: grid.options.exporterMenuItemOrder + 2 + }, + { + title: i18nService.getSafeText('gridMenu.exporterAllAsPdf'), + action: function ($event) { + grid.api.exporter.pdfExport( uiGridExporterConstants.ALL, uiGridExporterConstants.ALL ); + }, + shown: function() { + return grid.options.exporterMenuPdf && grid.options.exporterMenuAllData; + }, + order: grid.options.exporterMenuItemOrder + 3 + }, + { + title: i18nService.getSafeText('gridMenu.exporterVisibleAsPdf'), + action: function ($event) { + grid.api.exporter.pdfExport( uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE ); + }, + shown: function() { + return grid.options.exporterMenuPdf && grid.options.exporterMenuVisibleData; + }, + order: grid.options.exporterMenuItemOrder + 4 + }, + { + title: i18nService.getSafeText('gridMenu.exporterSelectedAsPdf'), + action: function ($event) { + grid.api.exporter.pdfExport( uiGridExporterConstants.SELECTED, uiGridExporterConstants.VISIBLE ); + }, + shown: function() { + return grid.options.exporterMenuPdf && grid.options.exporterMenuSelectedData && + ( grid.api.selection && grid.api.selection.getSelectedRows().length > 0 ); + }, + order: grid.options.exporterMenuItemOrder + 5 + }, + { + title: i18nService.getSafeText('gridMenu.exporterAllAsExcel'), + action: function ($event) { + grid.api.exporter.excelExport( uiGridExporterConstants.ALL, uiGridExporterConstants.ALL ); + }, + shown: function() { + return grid.options.exporterMenuExcel && grid.options.exporterMenuAllData; + }, + order: grid.options.exporterMenuItemOrder + 6 + }, + { + title: i18nService.getSafeText('gridMenu.exporterVisibleAsExcel'), + action: function ($event) { + grid.api.exporter.excelExport( uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE ); + }, + shown: function() { + return grid.options.exporterMenuExcel && grid.options.exporterMenuVisibleData; + }, + order: grid.options.exporterMenuItemOrder + 7 + }, + { + title: i18nService.getSafeText('gridMenu.exporterSelectedAsExcel'), + action: function ($event) { + grid.api.exporter.excelExport( uiGridExporterConstants.SELECTED, uiGridExporterConstants.VISIBLE ); + }, + shown: function() { + return grid.options.exporterMenuExcel && grid.options.exporterMenuSelectedData && + ( grid.api.selection && grid.api.selection.getSelectedRows().length > 0 ); + }, + order: grid.options.exporterMenuItemOrder + 8 + } + ]); + }, + + + /** + * @ngdoc function + * @name csvExport + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Exports rows from the grid in csv format, + * the data exported is selected based on the provided options + * @param {Grid} grid the grid from which data should be exported + * @param {string} rowTypes which rows to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + * @param {string} colTypes which columns to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + */ + csvExport: function (grid, rowTypes, colTypes) { + var self = this; + this.loadAllDataIfNeeded(grid, rowTypes, colTypes).then(function() { + var exportColumnHeaders = grid.options.showHeader ? self.getColumnHeaders(grid, colTypes) : []; + var exportData = self.getData(grid, rowTypes, colTypes); + var csvContent = self.formatAsCsv(exportColumnHeaders, exportData, grid.options.exporterCsvColumnSeparator); + + self.downloadFile (grid.options.exporterCsvFilename, csvContent, grid.options.exporterCsvColumnSeparator, grid.options.exporterOlderExcelCompatibility, grid.options.exporterIsExcelCompatible); + }); + }, + + /** + * @ngdoc function + * @name loadAllDataIfNeeded + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description When using server side pagination, use exporterAllDataFn to + * load all data before continuing processing. + * When using client side pagination, return a resolved promise so processing + * continues immediately + * @param {Grid} grid the grid from which data should be exported + * @param {string} rowTypes which rows to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + * @param {string} colTypes which columns to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + */ + loadAllDataIfNeeded: function (grid, rowTypes, colTypes) { + if ( rowTypes === uiGridExporterConstants.ALL && grid.rows.length !== grid.options.totalItems && grid.options.exporterAllDataFn) { + return grid.options.exporterAllDataFn() + .then(function(allData) { + grid.modifyRows(allData); + }); + } else { + var deferred = $q.defer(); + deferred.resolve(); + return deferred.promise; + } + }, + + /** + * @ngdoc property + * @propertyOf ui.grid.exporter.api:ColumnDef + * @name exporterSuppressExport + * @description Suppresses export for this column. Used by selection and expandable. + */ + + /** + * @ngdoc function + * @name getColumnHeaders + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Gets the column headers from the grid to use + * as a title row for the exported file, all headers have + * headerCellFilters applied as appropriate. + * + * Column headers are an array of objects, each object has + * name, displayName, width and align attributes. Only name is + * used for csv, all attributes are used for pdf. + * + * @param {Grid} grid the grid from which data should be exported + * @param {string} colTypes which columns to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + */ + getColumnHeaders: function (grid, colTypes) { + var headers = []; + var columns; + + if ( colTypes === uiGridExporterConstants.ALL ){ + columns = grid.columns; + } else { + var leftColumns = grid.renderContainers.left ? grid.renderContainers.left.visibleColumnCache.filter( function( column ){ return column.visible; } ) : []; + var bodyColumns = grid.renderContainers.body ? grid.renderContainers.body.visibleColumnCache.filter( function( column ){ return column.visible; } ) : []; + var rightColumns = grid.renderContainers.right ? grid.renderContainers.right.visibleColumnCache.filter( function( column ){ return column.visible; } ) : []; + + columns = leftColumns.concat(bodyColumns,rightColumns); + } + + columns.forEach( function( gridCol ) { + // $$hashKey check since when grouping and sorting pragmatically this ends up in export. Filtering it out + if ( gridCol.colDef.exporterSuppressExport !== true && gridCol.field !== '$$hashKey' && + grid.options.exporterSuppressColumns.indexOf( gridCol.name ) === -1 ){ + var headerEntry = { + name: gridCol.field, + displayName: getDisplayName(grid, gridCol), + width: gridCol.drawnWidth ? gridCol.drawnWidth : gridCol.width, + align: gridCol.colDef.align ? gridCol.colDef.align : (gridCol.colDef.type === 'number' ? 'right' : 'left') + }; + headers.push(headerEntry); + } + }); + + return headers; + }, + + + /** + * @ngdoc property + * @propertyOf ui.grid.exporter.api:ColumnDef + * @name exporterPdfAlign + * @description the alignment you'd like for this specific column when + * exported into a pdf. Can be 'left', 'right', 'center' or any other + * valid pdfMake alignment option. + */ + + + /** + * @ngdoc object + * @name ui.grid.exporter.api:GridRow + * @description GridRow settings for exporter + */ + /** + * @ngdoc object + * @name exporterEnableExporting + * @propertyOf ui.grid.exporter.api:GridRow + * @description If set to false, then don't export this row, notwithstanding visible or + * other settings + *
    Defaults to true + */ + + + /** + * @ngdoc function + * @name getRowsFromNode + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Gets rows from a node. If the node is grouped it will + * recurse down into the children to get to the raw data element + * which is a row without children (a leaf). + * @param {Node} aNode the tree node on the grid + * @returns {Array} an array of leaf nodes + */ + getRowsFromNode: function(aNode) { + var rows = []; + for (var i = 0; i 0 ? (self.formatRowAsCsv(this, separator)(bareHeaders) + '\n') : ''; + + csv += exportData.map(this.formatRowAsCsv(this, separator)).join('\n'); + + return csv; + }, + + /** + * @ngdoc function + * @name formatRowAsCsv + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Renders a single field as a csv field, including + * quotes around the value + * @param {exporterService} exporter pass in exporter + * @param {array} row the row to be turned into a csv string + * @returns {string} a csv-ified version of the row + */ + formatRowAsCsv: function (exporter, separator) { + return function (row) { + return row.map(exporter.formatFieldAsCsv).join(separator); + }; + }, + + /** + * @ngdoc function + * @name formatFieldAsCsv + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Renders a single field as a csv field, including + * quotes around the value + * @param {field} field the field to be turned into a csv string, + * may be of any type + * @returns {string} a csv-ified version of the field + */ + formatFieldAsCsv: function (field) { + if (field.value == null) { // we want to catch anything null-ish, hence just == not === + return ''; + } + if (typeof(field.value) === 'number') { + return field.value; + } + if (typeof(field.value) === 'boolean') { + return (field.value ? 'TRUE' : 'FALSE') ; + } + if (typeof(field.value) === 'string') { + return '"' + field.value.replace(/"/g,'""') + '"'; + } + + return JSON.stringify(field.value); + }, + + + /** + * @ngdoc function + * @name isIE + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Checks whether current browser is IE and returns it's version if it is + */ + isIE: function () { + var match = navigator.userAgent.search(/(?:Edge|MSIE|Trident\/.*; rv:)/); + var isIE = false; + + if (match !== -1) { + isIE = true; + } + + return isIE; + }, + + + /** + * @ngdoc function + * @name downloadFile + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Triggers download of a csv file. Logic provided + * by @cssensei (from his colleagues at https://github.com/ifeelgoods) in issue #2391 + * @param {string} fileName the filename we'd like our file to be + * given + * @param {string} csvContent the csv content that we'd like to + * download as a file + * @param {boolean} exporterOlderExcelCompatibility whether or not we put a utf-16 BOM on the from (\uFEFF) + * @param {boolean} exporterIsExcelCompatible whether or not we add separator header ('sep=X') + */ + downloadFile: function (fileName, csvContent, columnSeparator, exporterOlderExcelCompatibility, exporterIsExcelCompatible) { + var D = document; + var a = D.createElement('a'); + var strMimeType = 'application/octet-stream;charset=utf-8'; + var rawFile; + var ieVersion = this.isIE(); + + if (exporterIsExcelCompatible) { + csvContent = 'sep=' + columnSeparator + '\r\n' + csvContent; + } + + // IE10+ + if (navigator.msSaveBlob) { + return navigator.msSaveOrOpenBlob( + new Blob( + [exporterOlderExcelCompatibility ? "\uFEFF" : '', csvContent], + { type: strMimeType } ), + fileName + ); + } + + if (ieVersion) { + var frame = D.createElement('iframe'); + document.body.appendChild(frame); + + frame.contentWindow.document.open('text/html', 'replace'); + frame.contentWindow.document.write(csvContent); + frame.contentWindow.document.close(); + frame.contentWindow.focus(); + frame.contentWindow.document.execCommand('SaveAs', true, fileName); + + document.body.removeChild(frame); + return true; + } + + //html5 A[download] + if ('download' in a) { + var blob = new Blob( + [exporterOlderExcelCompatibility ? "\uFEFF" : '', csvContent], + { type: strMimeType } + ); + rawFile = URL.createObjectURL(blob); + a.setAttribute('download', fileName); + } else { + rawFile = 'data:' + strMimeType + ',' + encodeURIComponent(csvContent); + a.setAttribute('target', '_blank'); + } + + a.href = rawFile; + a.setAttribute('style', 'display:none;'); + D.body.appendChild(a); + setTimeout(function() { + if (a.click) { + a.click(); + // Workaround for Safari 5 + } else if (document.createEvent) { + var eventObj = document.createEvent('MouseEvents'); + eventObj.initEvent('click', true, true); + a.dispatchEvent(eventObj); + } + D.body.removeChild(a); + + }, this.delay); + }, + + /** + * @ngdoc function + * @name pdfExport + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Exports rows from the grid in pdf format, + * the data exported is selected based on the provided options. + * Note that this function has a dependency on pdfMake, which must + * be installed. The resulting pdf opens in a new + * browser window. + * @param {Grid} grid the grid from which data should be exported + * @param {string} rowTypes which rows to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + * @param {string} colTypes which columns to export, valid values are + * uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE, + * uiGridExporterConstants.SELECTED + */ + pdfExport: function (grid, rowTypes, colTypes) { + var self = this; + this.loadAllDataIfNeeded(grid, rowTypes, colTypes).then(function () { + var exportColumnHeaders = self.getColumnHeaders(grid, colTypes); + var exportData = self.getData(grid, rowTypes, colTypes); + var docDefinition = self.prepareAsPdf(grid, exportColumnHeaders, exportData); + + if (self.isIE() || navigator.appVersion.indexOf("Edge") !== -1) { + self.downloadPDF(grid.options.exporterPdfFilename, docDefinition); + } else { + pdfMake.createPdf(docDefinition).open(); + } + }); + }, + + + /** + * @ngdoc function + * @name downloadPdf + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Generates and retrieves the pdf as a blob, then downloads + * it as a file. Only used in IE, in all other browsers we use the native + * pdfMake.open function to just open the PDF + * @param {string} fileName the filename to give to the pdf, can be set + * through exporterPdfFilename + * @param {object} docDefinition a pdf docDefinition that we can generate + * and get a blob from + */ + downloadPDF: function (fileName, docDefinition) { + var D = document; + var a = D.createElement('a'); + var strMimeType = 'application/octet-stream;charset=utf-8'; + var rawFile; + var ieVersion; + + ieVersion = this.isIE(); // This is now a boolean value + var doc = pdfMake.createPdf(docDefinition); + var blob; + + doc.getBuffer( function (buffer) { + blob = new Blob([buffer]); + + // IE10+ + if (navigator.msSaveBlob) { + return navigator.msSaveBlob( + blob, fileName + ); + } + + // Previously: && ieVersion < 10 + // ieVersion now returns a boolean for the + // sake of sanity. We just check `msSaveBlob` first. + if (ieVersion) { + var frame = D.createElement('iframe'); + document.body.appendChild(frame); + + frame.contentWindow.document.open("text/html", "replace"); + frame.contentWindow.document.write(blob); + frame.contentWindow.document.close(); + frame.contentWindow.focus(); + frame.contentWindow.document.execCommand('SaveAs', true, fileName); + + document.body.removeChild(frame); + return true; + } + }); + }, + + + /** + * @ngdoc function + * @name renderAsPdf + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Renders the data into a pdf, and opens that pdf. + * + * @param {Grid} grid the grid from which data should be exported + * @param {array} exportColumnHeaders an array of column headers, + * where each header is an object with name, width and maybe alignment + * @param {array} exportData an array of rows, where each row is + * an array of column data + * @returns {object} a pdfMake format document definition, ready + * for generation + */ + prepareAsPdf: function(grid, exportColumnHeaders, exportData) { + var headerWidths = this.calculatePdfHeaderWidths( grid, exportColumnHeaders ); + + var headerColumns = exportColumnHeaders.map( function( header ) { + return { text: header.displayName, style: 'tableHeader' }; + }); + + var stringData = exportData.map(this.formatRowAsPdf(this)); + + var allData = [headerColumns].concat(stringData); + + var docDefinition = { + pageOrientation: grid.options.exporterPdfOrientation, + pageSize: grid.options.exporterPdfPageSize, + content: [{ + style: 'tableStyle', + table: { + headerRows: 1, + widths: headerWidths, + body: allData + } + }], + styles: { + tableStyle: grid.options.exporterPdfTableStyle, + tableHeader: grid.options.exporterPdfTableHeaderStyle + }, + defaultStyle: grid.options.exporterPdfDefaultStyle + }; + + if ( grid.options.exporterPdfLayout ){ + docDefinition.layout = grid.options.exporterPdfLayout; + } + + if ( grid.options.exporterPdfHeader ){ + docDefinition.header = grid.options.exporterPdfHeader; + } + + if ( grid.options.exporterPdfFooter ){ + docDefinition.footer = grid.options.exporterPdfFooter; + } + + if ( grid.options.exporterPdfCustomFormatter ){ + docDefinition = grid.options.exporterPdfCustomFormatter( docDefinition ); + } + return docDefinition; + + }, + + + /** + * @ngdoc function + * @name calculatePdfHeaderWidths + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Determines the column widths base on the + * widths we got from the grid. If the column is drawn + * then we have a drawnWidth. If the column is not visible + * then we have '*', 'x%' or a width. When columns are + * not visible they don't contribute to the overall gridWidth, + * so we need to adjust to allow for extra columns + * + * Our basic heuristic is to take the current gridWidth, plus + * numeric columns and call this the base gridwidth. + * + * To that we add 100 for any '*' column, and x% of the base gridWidth + * for any column that is a % + * + * @param {Grid} grid the grid from which data should be exported + * @param {array} exportHeaders array of header information + * @returns {object} an array of header widths + */ + calculatePdfHeaderWidths: function ( grid, exportHeaders ) { + var baseGridWidth = 0; + exportHeaders.forEach( function(value){ + if (typeof(value.width) === 'number'){ + baseGridWidth += value.width; + } + }); + + var extraColumns = 0; + exportHeaders.forEach( function(value){ + if (value.width === '*'){ + extraColumns += 100; + } + if (typeof(value.width) === 'string' && value.width.match(/(\d)*%/)) { + var percent = parseInt(value.width.match(/(\d)*%/)[0]); + + value.width = baseGridWidth * percent / 100; + extraColumns += value.width; + } + }); + + var gridWidth = baseGridWidth + extraColumns; + + return exportHeaders.map(function( header ) { + return header.width === '*' ? header.width : header.width * grid.options.exporterPdfMaxGridWidth / gridWidth; + }); + + }, + + /** + * @ngdoc function + * @name formatRowAsPdf + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Renders a row in a format consumable by PDF, + * mainly meaning casting everything to a string + * @param {exporterService} exporter pass in exporter + * @param {array} row the row to be turned into a csv string + * @returns {string} a csv-ified version of the row + */ + formatRowAsPdf: function ( exporter ) { + return function( row ) { + return row.map(exporter.formatFieldAsPdfString); + }; + }, + + + /** + * @ngdoc function + * @name formatFieldAsCsv + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Renders a single field as a pdf-able field, which + * is different from a csv field only in that strings don't have quotes + * around them + * @param {field} field the field to be turned into a pdf string, + * may be of any type + * @returns {string} a string-ified version of the field + */ + formatFieldAsPdfString: function (field) { + var returnVal; + if (field.value == null) { // we want to catch anything null-ish, hence just == not === + returnVal = ''; + } else if (typeof(field.value) === 'number') { + returnVal = field.value.toString(); + } else if (typeof(field.value) === 'boolean') { + returnVal = (field.value ? 'TRUE' : 'FALSE') ; + } else if (typeof(field.value) === 'string') { + returnVal = field.value.replace(/"/g,'""'); + } else if (field.value instanceof Date) { + returnVal = JSON.stringify(field.value).replace(/^"/,'').replace(/"$/,''); + } else if (typeof(field.value) === 'object') { + returnVal = field.value; + } else { + returnVal = JSON.stringify(field.value).replace(/^"/,'').replace(/"$/,''); + } + + if (field.alignment && typeof(field.alignment) === 'string' ){ + returnVal = { text: returnVal, alignment: field.alignment }; + } + + return returnVal; + }, + + /** + * @ngdoc function + * @name formatAsExcel + * @methodOf ui.grid.exporter.service:uiGridExporterService + * @description Formats the column headers and data as a excel, + * and sends that data to the user + * @param {array} exportColumnHeaders an array of column headers, + * where each header is an object with name, width and maybe alignment + * @param {array} exportData an array of rows, where each row is + * an array of column data + * @param {string} separator a string that represents the separator to be used in the csv file + * @returns {string} csv the formatted excel as a string + */ + formatAsExcel: function (exportColumnHeaders, exportData, workbook, sheet, docDefinition) { + var self = this; + + var bareHeaders = exportColumnHeaders.map(function(header){return { value: header.displayName };}); + + var sheetData = []; + var headerData = []; + for (var i = 0; i < bareHeaders.length; i++) { + // TODO - probably need callback to determine header value and header styling + var exportStyle = 'header'; + switch (exportColumnHeaders[i].align) { + case 'center': + exportStyle = 'headerCenter'; + break; + case 'right': + exportStyle = 'headerRight'; + break; + } + var metadata = (docDefinition.styles && docDefinition.styles[exportStyle]) ? {style: docDefinition.styles[exportStyle].id} : null; + headerData.push({value: bareHeaders[i].value, metadata: metadata}); + } + sheetData.push(headerData); + + var result = exportData.map(this.formatRowAsExcel(this, workbook, sheet)); + for (var j = 0; j + + var app = angular.module('app', ['ui.grid', 'ui.grid.exporter']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + + $scope.gridOptions = { + enableGridMenu: true, + exporterMenuCsv: false, + columnDefs: [ + {name: 'name', enableCellEdit: true}, + {name: 'title', enableCellEdit: true} + ], + data: $scope.data + }; + }]); + + +
    +
    +
    +
    + + */ + module.directive('uiGridExporter', ['uiGridExporterConstants', 'uiGridExporterService', 'gridUtil', '$compile', + function (uiGridExporterConstants, uiGridExporterService, gridUtil, $compile) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + link: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridExporterService.initializeGrid(uiGridCtrl.grid); + uiGridCtrl.grid.exporter.$scope = $scope; + } + }; + } + ]); +})(); diff --git a/release/4.4.11/ui-grid.exporter.min.js b/release/4.4.11/ui-grid.exporter.min.js new file mode 100644 index 000000000..b19dec1d9 --- /dev/null +++ b/release/4.4.11/ui-grid.exporter.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.exporter",["ui.grid"]);e.constant("uiGridExporterConstants",{featureName:"exporter",rowHeaderColName:"treeBaseRowHeaderCol",selectionRowHeaderColName:"selectionRowHeaderCol",ALL:"all",VISIBLE:"visible",SELECTED:"selected",CSV_CONTENT:"CSV_CONTENT",BUTTON_LABEL:"BUTTON_LABEL",FILE_NAME:"FILE_NAME"}),e.service("uiGridExporterService",["$filter","$q","uiGridExporterConstants","gridUtil","$compile","$interval","i18nService",function(l,n,x,d,e,t,r){var o={delay:100,initializeGrid:function(r){r.exporter={},this.defaultGridOptions(r.options);var e={events:{exporter:{}},methods:{exporter:{csvExport:function(e,t){o.csvExport(r,e,t)},pdfExport:function(e,t){o.pdfExport(r,e,t)},excelExport:function(e,t){o.excelExport(r,e,t)}}}};r.api.registerEventsFromObject(e.events),r.api.registerMethodsFromObject(e.methods),r.api.core.addToGridMenu?o.addToMenu(r):t(function(){r.api.core.addToGridMenu&&o.addToMenu(r)},this.delay,1)},defaultGridOptions:function(e){e.exporterSuppressMenu=!0===e.exporterSuppressMenu,e.exporterMenuLabel=e.exporterMenuLabel?e.exporterMenuLabel:"Export",e.exporterSuppressColumns=e.exporterSuppressColumns?e.exporterSuppressColumns:[],e.exporterCsvColumnSeparator=e.exporterCsvColumnSeparator?e.exporterCsvColumnSeparator:",",e.exporterCsvFilename=e.exporterCsvFilename?e.exporterCsvFilename:"download.csv",e.exporterPdfFilename=e.exporterPdfFilename?e.exporterPdfFilename:"download.pdf",e.exporterExcelFilename=e.exporterExcelFilename?e.exporterExcelFilename:"download.xlsx",e.exporterExcelSheetName=e.exporterExcelSheetName?e.exporterExcelSheetName:"Sheet1",e.exporterOlderExcelCompatibility=!0===e.exporterOlderExcelCompatibility,e.exporterIsExcelCompatible=!0===e.exporterIsExcelCompatible,e.exporterMenuItemOrder=e.exporterMenuItemOrder?e.exporterMenuItemOrder:200,e.exporterPdfDefaultStyle=e.exporterPdfDefaultStyle?e.exporterPdfDefaultStyle:{fontSize:11},e.exporterPdfTableStyle=e.exporterPdfTableStyle?e.exporterPdfTableStyle:{margin:[0,5,0,15]},e.exporterPdfTableHeaderStyle=e.exporterPdfTableHeaderStyle?e.exporterPdfTableHeaderStyle:{bold:!0,fontSize:12,color:"black"},e.exporterPdfHeader=e.exporterPdfHeader?e.exporterPdfHeader:null,e.exporterPdfFooter=e.exporterPdfFooter?e.exporterPdfFooter:null,e.exporterPdfOrientation=e.exporterPdfOrientation?e.exporterPdfOrientation:"landscape",e.exporterPdfPageSize=e.exporterPdfPageSize?e.exporterPdfPageSize:"A4",e.exporterPdfMaxGridWidth=e.exporterPdfMaxGridWidth?e.exporterPdfMaxGridWidth:720,e.exporterMenuAllData=void 0===e.exporterMenuAllData||e.exporterMenuAllData,e.exporterMenuVisibleData=void 0===e.exporterMenuVisibleData||e.exporterMenuVisibleData,e.exporterMenuSelectedData=void 0===e.exporterMenuSelectedData||e.exporterMenuSelectedData,e.exporterMenuCsv=void 0===e.exporterMenuCsv||e.exporterMenuCsv,e.exporterMenuPdf=void 0===e.exporterMenuPdf||e.exporterMenuPdf,e.exporterMenuExcel=void 0===e.exporterMenuExcel||e.exporterMenuExcel,e.exporterPdfCustomFormatter=e.exporterPdfCustomFormatter&&"function"==typeof e.exporterPdfCustomFormatter?e.exporterPdfCustomFormatter:function(e){return e},e.exporterHeaderFilterUseName=!0===e.exporterHeaderFilterUseName,e.exporterFieldCallback=e.exporterFieldCallback?e.exporterFieldCallback:i,e.exporterFieldFormatCallback=e.exporterFieldFormatCallback?e.exporterFieldFormatCallback:function(e,t,r,o){return null},e.exporterExcelCustomFormatters=e.exporterExcelCustomFormatters?e.exporterExcelCustomFormatters:function(e,t,r){return null},e.exporterExcelHeader=e.exporterExcelHeader?e.exporterExcelHeader:function(e,t,r,o){return null},e.exporterColumnScaleFactor=e.exporterColumnScaleFactor?e.exporterColumnScaleFactor:3.5,e.exporterFieldApplyFilters=!0===e.exporterFieldApplyFilters,e.exporterAllDataFn=e.exporterAllDataFn?e.exporterAllDataFn:null,null===e.exporterAllDataFn&&e.exporterAllDataPromise&&(e.exporterAllDataFn=e.exporterAllDataPromise)},addToMenu:function(t){t.api.core.addToGridMenu(t,[{title:r.getSafeText("gridMenu.exporterAllAsCsv"),action:function(e){t.api.exporter.csvExport(x.ALL,x.ALL)},shown:function(){return t.options.exporterMenuCsv&&t.options.exporterMenuAllData},order:t.options.exporterMenuItemOrder},{title:r.getSafeText("gridMenu.exporterVisibleAsCsv"),action:function(e){t.api.exporter.csvExport(x.VISIBLE,x.VISIBLE)},shown:function(){return t.options.exporterMenuCsv&&t.options.exporterMenuVisibleData},order:t.options.exporterMenuItemOrder+1},{title:r.getSafeText("gridMenu.exporterSelectedAsCsv"),action:function(e){t.api.exporter.csvExport(x.SELECTED,x.VISIBLE)},shown:function(){return t.options.exporterMenuCsv&&t.options.exporterMenuSelectedData&&t.api.selection&&0Beta This feature is ready for testing, but it either hasn't seen a lot of use or has some known bugs. + * + * This module provides grouping of rows based on the data in them, similar + * in concept to excel grouping. You can group multiple columns, resulting in + * nested grouping. + * + * In concept this feature is similar to sorting + grid footer/aggregation, it + * sorts the data based on the grouped columns, then creates group rows that + * reflect a break in the data. Each of those group rows can have aggregations for + * the data within that group. + * + * This feature leverages treeBase to provide the tree functionality itself, + * the key thing this feature does therefore is to set treeLevels on the rows + * and insert the group headers. + * + * Design information: + * ------------------- + * + * Each column will get new menu items - group by, and aggregate by. Group by + * will cause this column to be sorted (if not already), and will move this column + * to the front of the sorted columns (i.e. grouped columns take precedence over + * sorted columns). It will respect the sort order already set if there is one, + * and it will allow the sorting logic to change that sort order, it just forces + * the column to the front of the sorting. You can group by multiple columns, the + * logic will add this column to the sorting after any already grouped columns. + * + * Once a grouping is defined, grouping logic is added to the rowsProcessors. This + * will process the rows, identifying a break in the data value, and inserting a grouping row. + * Grouping rows have specific attributes on them: + * + * - internalRow = true: tells us that this isn't a real row, so we can ignore it + * from any processing that it looking at core data rows. This is used by the core + * logic (or will be one day), as it's not grouping specific + * - groupHeader = true: tells us this is a groupHeader. This is used by the grouping logic + * to know if this is a groupHeader row or not + * + * Since the logic is baked into the rowsProcessors, it should get triggered whenever + * row order or filtering or anything like that is changed. In order to avoid the row instantiation + * time, and to preserve state across invocations, we hold a cache of the rows that we created + * last time, and we use them again this time if we can. + * + * By default rows are collapsed, which means all data rows have their visible property + * set to false, and only level 0 group rows are set to visible. + * + *
    + *
    + * + *
    + */ + + var module = angular.module('ui.grid.grouping', ['ui.grid', 'ui.grid.treeBase']); + + /** + * @ngdoc object + * @name ui.grid.grouping.constant:uiGridGroupingConstants + * + * @description constants available in grouping module, this includes + * all the constants declared in the treeBase module (these are manually copied + * as there isn't an easy way to include constants in another constants file, and + * we don't want to make users include treeBase) + * + */ + module.constant('uiGridGroupingConstants', { + featureName: "grouping", + rowHeaderColName: 'treeBaseRowHeaderCol', + EXPANDED: 'expanded', + COLLAPSED: 'collapsed', + aggregation: { + COUNT: 'count', + SUM: 'sum', + MAX: 'max', + MIN: 'min', + AVG: 'avg' + } + }); + + /** + * @ngdoc service + * @name ui.grid.grouping.service:uiGridGroupingService + * + * @description Services for grouping features + */ + module.service('uiGridGroupingService', ['$q', 'uiGridGroupingConstants', 'gridUtil', 'rowSorter', 'GridRow', 'gridClassFactory', 'i18nService', 'uiGridConstants', 'uiGridTreeBaseService', + function ($q, uiGridGroupingConstants, gridUtil, rowSorter, GridRow, gridClassFactory, i18nService, uiGridConstants, uiGridTreeBaseService) { + + var service = { + + initializeGrid: function (grid, $scope) { + uiGridTreeBaseService.initializeGrid( grid, $scope ); + + //add feature namespace and any properties to grid for needed + /** + * @ngdoc object + * @name ui.grid.grouping.grid:grouping + * + * @description Grid properties and functions added for grouping + */ + grid.grouping = {}; + + /** + * @ngdoc property + * @propertyOf ui.grid.grouping.grid:grouping + * @name groupHeaderCache + * + * @description Cache that holds the group header rows we created last time, we'll + * reuse these next time, not least because they hold our expanded states. + * + * We need to take care with these that they don't become a memory leak, we + * create a new cache each time using the values from the old cache. This works + * so long as we're creating group rows for invisible rows as well. + * + * The cache is a nested hash, indexed on the value we grouped by. So if we + * grouped by gender then age, we'd maybe have something like: + * ``` + * { + * male: { + * row: , + * children: { + * 22: { row: }, + * 31: { row: } + * }, + * female: { + * row: , + * children: { + * 28: { row: }, + * 55: { row: } + * } + * } + * ``` + * + * We create new rows for any missing rows, this means that they come in as collapsed. + * + */ + grid.grouping.groupHeaderCache = {}; + + service.defaultGridOptions(grid.options); + + grid.registerRowsProcessor(service.groupRows, 400); + + grid.registerColumnBuilder( service.groupingColumnBuilder); + + grid.registerColumnsProcessor(service.groupingColumnProcessor, 400); + + /** + * @ngdoc object + * @name ui.grid.grouping.api:PublicApi + * + * @description Public Api for grouping feature + */ + var publicApi = { + events: { + grouping: { + /** + * @ngdoc event + * @eventOf ui.grid.grouping.api:PublicApi + * @name aggregationChanged + * @description raised whenever aggregation is changed, added or removed from a column + * + *
    +               *      gridApi.grouping.on.aggregationChanged(scope,function(col){})
    +               * 
    + * @param {GridColumn} col the column which on which aggregation changed. The aggregation + * type is available as `col.treeAggregation.type` + */ + aggregationChanged: {}, + /** + * @ngdoc event + * @eventOf ui.grid.grouping.api:PublicApi + * @name groupingChanged + * @description raised whenever the grouped columns changes + * + *
    +               *      gridApi.grouping.on.groupingChanged(scope,function(col){})
    +               * 
    + * @param {GridColumn} col the column which on which grouping changed. The new grouping is + * available as `col.grouping` + */ + groupingChanged: {} + } + }, + methods: { + grouping: { + /** + * @ngdoc function + * @name getGrouping + * @methodOf ui.grid.grouping.api:PublicApi + * @description Get the grouping configuration for this grid, + * used by the saveState feature. Adds expandedState to the information + * provided by the internal getGrouping, and removes any aggregations that have a source + * of grouping (i.e. will be automatically reapplied when we regroup the column) + * Returned grouping is an object + * `{ grouping: groupArray, treeAggregations: aggregateArray, expandedState: hash }` + * where grouping contains an array of objects: + * `{ field: column.field, colName: column.name, groupPriority: column.grouping.groupPriority }` + * and aggregations contains an array of objects: + * `{ field: column.field, colName: column.name, aggregation: column.grouping.aggregation }` + * and expandedState is a hash of the currently expanded nodes + * + * The groupArray will be sorted by groupPriority. + * + * @param {boolean} getExpanded whether or not to return the expanded state + * @returns {object} grouping configuration + */ + getGrouping: function ( getExpanded ) { + var grouping = service.getGrouping(grid); + + grouping.grouping.forEach( function( group ) { + group.colName = group.col.name; + delete group.col; + }); + + grouping.aggregations.forEach( function( aggregation ) { + aggregation.colName = aggregation.col.name; + delete aggregation.col; + }); + + grouping.aggregations = grouping.aggregations.filter( function( aggregation ){ + return !aggregation.aggregation.source || aggregation.aggregation.source !== 'grouping'; + }); + + if ( getExpanded ){ + grouping.rowExpandedStates = service.getRowExpandedStates( grid.grouping.groupingHeaderCache ); + } + + return grouping; + }, + + /** + * @ngdoc function + * @name setGrouping + * @methodOf ui.grid.grouping.api:PublicApi + * @description Set the grouping configuration for this grid, + * used by the saveState feature, but can also be used by any + * user to specify a combined grouping and aggregation configuration + * @param {object} config the config you want to apply, in the format + * provided out by getGrouping + */ + setGrouping: function ( config ) { + service.setGrouping(grid, config); + }, + + /** + * @ngdoc function + * @name groupColumn + * @methodOf ui.grid.grouping.api:PublicApi + * @description Adds this column to the existing grouping, at the end of the priority order. + * If the column doesn't have a sort, adds one, by default ASC + * + * This column will move to the left of any non-group columns, the + * move is handled in a columnProcessor, so gets called as part of refresh + * + * @param {string} columnName the name of the column we want to group + */ + groupColumn: function( columnName ) { + var column = grid.getColumn(columnName); + service.groupColumn(grid, column); + }, + + /** + * @ngdoc function + * @name ungroupColumn + * @methodOf ui.grid.grouping.api:PublicApi + * @description Removes the groupPriority from this column. If the + * column was previously aggregated the aggregation will come back. + * The sort will remain. + * + * This column will move to the right of any other group columns, the + * move is handled in a columnProcessor, so gets called as part of refresh + * + * @param {string} columnName the name of the column we want to ungroup + */ + ungroupColumn: function( columnName ) { + var column = grid.getColumn(columnName); + service.ungroupColumn(grid, column); + }, + + /** + * @ngdoc function + * @name clearGrouping + * @methodOf ui.grid.grouping.api:PublicApi + * @description Clear any grouped columns and any aggregations. Doesn't remove sorting, + * as we don't know whether that sorting was added by grouping or was there beforehand + * + */ + clearGrouping: function() { + service.clearGrouping(grid); + }, + + /** + * @ngdoc function + * @name aggregateColumn + * @methodOf ui.grid.grouping.api:PublicApi + * @description Sets the aggregation type on a column, if the + * column is currently grouped then it removes the grouping first. + * If the aggregationDef is null then will result in the aggregation + * being removed + * + * @param {string} columnName the column we want to aggregate + * @param {string} or {function} aggregationDef one of the recognised types + * from uiGridGroupingConstants or a custom aggregation function. + * @param {string} aggregationLabel (optional) The label to use for this aggregation. + */ + aggregateColumn: function( columnName, aggregationDef, aggregationLabel){ + var column = grid.getColumn(columnName); + service.aggregateColumn( grid, column, aggregationDef, aggregationLabel); + } + + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + + grid.api.registerMethodsFromObject(publicApi.methods); + + grid.api.core.on.sortChanged( $scope, service.tidyPriorities); + + }, + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.grouping.api:GridOptions + * + * @description GridOptions for grouping feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc object + * @name enableGrouping + * @propertyOf ui.grid.grouping.api:GridOptions + * @description Enable row grouping for entire grid. + *
    Defaults to true + */ + gridOptions.enableGrouping = gridOptions.enableGrouping !== false; + + /** + * @ngdoc object + * @name groupingShowCounts + * @propertyOf ui.grid.grouping.api:GridOptions + * @description shows counts on the groupHeader rows. Not that if you are using a cellFilter or a + * sortingAlgorithm which relies on a specific format or data type, showing counts may cause that + * to break, since the group header rows will always be a string with groupingShowCounts enabled. + *
    Defaults to true except on columns of types 'date' and 'object' + */ + gridOptions.groupingShowCounts = gridOptions.groupingShowCounts !== false; + + /** + * @ngdoc object + * @name groupingNullLabel + * @propertyOf ui.grid.grouping.api:GridOptions + * @description The string to use for the grouping header row label on rows which contain a null or undefined value in the grouped column. + *
    Defaults to "Null" + */ + gridOptions.groupingNullLabel = typeof(gridOptions.groupingNullLabel) === 'undefined' ? 'Null' : gridOptions.groupingNullLabel; + + /** + * @ngdoc object + * @name enableGroupHeaderSelection + * @propertyOf ui.grid.grouping.api:GridOptions + * @description Allows group header rows to be selected. + *
    Defaults to false + */ + gridOptions.enableGroupHeaderSelection = gridOptions.enableGroupHeaderSelection === true; + }, + + + /** + * @ngdoc function + * @name groupingColumnBuilder + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Sets the grouping defaults based on the columnDefs + * + * @param {object} colDef columnDef we're basing on + * @param {GridColumn} col the column we're to update + * @param {object} gridOptions the options we should use + * @returns {promise} promise for the builder - actually we do it all inline so it's immediately resolved + */ + groupingColumnBuilder: function (colDef, col, gridOptions) { + /** + * @ngdoc object + * @name ui.grid.grouping.api:ColumnDef + * + * @description ColumnDef for grouping feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs} + */ + + /** + * @ngdoc object + * @name enableGrouping + * @propertyOf ui.grid.grouping.api:ColumnDef + * @description Enable grouping on this column + *
    Defaults to true. + */ + if (colDef.enableGrouping === false){ + return; + } + + /** + * @ngdoc object + * @name grouping + * @propertyOf ui.grid.grouping.api:ColumnDef + * @description Set the grouping for a column. Format is: + * ``` + * { + * groupPriority: + * } + * ``` + * + * **Note that aggregation used to be included in grouping, but is now separately set on the column via treeAggregation + * setting in treeBase** + * + * We group in the priority order given, this will also put these columns to the high order of the sort irrespective + * of the sort priority given them. If there is no sort defined then we sort ascending, if there is a sort defined then + * we use that sort. + * + * If the groupPriority is undefined or less than 0, then we expect to be aggregating, and we look at the + * aggregation types to determine what sort of aggregation we can do. Values are in the constants file, but + * include SUM, COUNT, MAX, MIN + * + * groupPriorities should generally be sequential, if they're not then the next time getGrouping is called + * we'll renumber them to be sequential. + *
    Defaults to undefined. + */ + + if ( typeof(col.grouping) === 'undefined' && typeof(colDef.grouping) !== 'undefined') { + col.grouping = angular.copy(colDef.grouping); + if ( typeof(col.grouping.groupPriority) !== 'undefined' && col.grouping.groupPriority > -1 ){ + col.treeAggregationFn = uiGridTreeBaseService.nativeAggregations()[uiGridGroupingConstants.aggregation.COUNT].aggregationFn; + col.treeAggregationFinalizerFn = service.groupedFinalizerFn; + } + } else if (typeof(col.grouping) === 'undefined'){ + col.grouping = {}; + } + + if (typeof(col.grouping) !== 'undefined' && typeof(col.grouping.groupPriority) !== 'undefined' && col.grouping.groupPriority >= 0){ + col.suppressRemoveSort = true; + } + + var groupColumn = { + name: 'ui.grid.grouping.group', + title: i18nService.get().grouping.group, + icon: 'ui-grid-icon-indent-right', + shown: function () { + return typeof(this.context.col.grouping) === 'undefined' || + typeof(this.context.col.grouping.groupPriority) === 'undefined' || + this.context.col.grouping.groupPriority < 0; + }, + action: function () { + service.groupColumn( this.context.col.grid, this.context.col ); + } + }; + + var ungroupColumn = { + name: 'ui.grid.grouping.ungroup', + title: i18nService.get().grouping.ungroup, + icon: 'ui-grid-icon-indent-left', + shown: function () { + return typeof(this.context.col.grouping) !== 'undefined' && + typeof(this.context.col.grouping.groupPriority) !== 'undefined' && + this.context.col.grouping.groupPriority >= 0; + }, + action: function () { + service.ungroupColumn( this.context.col.grid, this.context.col ); + } + }; + + var aggregateRemove = { + name: 'ui.grid.grouping.aggregateRemove', + title: i18nService.get().grouping.aggregate_remove, + shown: function () { + return typeof(this.context.col.treeAggregationFn) !== 'undefined'; + }, + action: function () { + service.aggregateColumn( this.context.col.grid, this.context.col, null); + } + }; + + // generic adder for the aggregation menus, which follow a pattern + var addAggregationMenu = function(type, title){ + title = title || i18nService.get().grouping['aggregate_' + type] || type; + var menuItem = { + name: 'ui.grid.grouping.aggregate' + type, + title: title, + shown: function () { + return typeof(this.context.col.treeAggregation) === 'undefined' || + typeof(this.context.col.treeAggregation.type) === 'undefined' || + this.context.col.treeAggregation.type !== type; + }, + action: function () { + service.aggregateColumn( this.context.col.grid, this.context.col, type); + } + }; + + if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.grouping.aggregate' + type)) { + col.menuItems.push(menuItem); + } + }; + + /** + * @ngdoc object + * @name groupingShowGroupingMenu + * @propertyOf ui.grid.grouping.api:ColumnDef + * @description Show the grouping (group and ungroup items) menu on this column + *
    Defaults to true. + */ + if ( col.colDef.groupingShowGroupingMenu !== false ){ + if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.grouping.group')) { + col.menuItems.push(groupColumn); + } + + if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.grouping.ungroup')) { + col.menuItems.push(ungroupColumn); + } + } + + + /** + * @ngdoc object + * @name groupingShowAggregationMenu + * @propertyOf ui.grid.grouping.api:ColumnDef + * @description Show the aggregation menu on this column + *
    Defaults to true. + */ + if ( col.colDef.groupingShowAggregationMenu !== false ){ + angular.forEach(uiGridTreeBaseService.nativeAggregations(), function(aggregationDef, name){ + addAggregationMenu(name); + }); + angular.forEach(gridOptions.treeCustomAggregations, function(aggregationDef, name){ + addAggregationMenu(name, aggregationDef.menuTitle); + }); + + if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.grouping.aggregateRemove')) { + col.menuItems.push(aggregateRemove); + } + } + }, + + + + + /** + * @ngdoc function + * @name groupingColumnProcessor + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Moves the columns around based on which are grouped + * + * @param {array} columns the columns to consider rendering + * @param {array} rows the grid rows, which we don't use but are passed to us + * @returns {array} updated columns array + */ + groupingColumnProcessor: function( columns, rows ) { + var grid = this; + + columns = service.moveGroupColumns(this, columns, rows); + return columns; + }, + + /** + * @ngdoc function + * @name groupedFinalizerFn + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Used on group columns to display the rendered value and optionally + * display the count of rows. + * + * @param {aggregation} the aggregation entity for a grouped column + */ + groupedFinalizerFn: function( aggregation ){ + var col = this; + + if ( typeof(aggregation.groupVal) !== 'undefined') { + aggregation.rendered = aggregation.groupVal; + if ( col.grid.options.groupingShowCounts && col.colDef.type !== 'date' && col.colDef.type !== 'object' ){ + aggregation.rendered += (' (' + aggregation.value + ')'); + } + } else { + aggregation.rendered = null; + } + }, + + /** + * @ngdoc function + * @name moveGroupColumns + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Moves the column order so that the grouped columns are lined up + * to the left (well, unless you're RTL, then it's the right). By doing this in + * the columnsProcessor, we make it transient - when the column is ungrouped it'll + * go back to where it was. + * + * Does nothing if the option `moveGroupColumns` is set to false. + * + * @param {Grid} grid grid object + * @param {array} columns the columns that we should process/move + * @param {array} rows the grid rows + * @returns {array} updated columns + */ + moveGroupColumns: function( grid, columns, rows ){ + if ( grid.options.moveGroupColumns === false){ + return columns; + } + + columns.forEach( function(column, index){ + // position used to make stable sort in moveGroupColumns + column.groupingPosition = index; + }); + + columns.sort(function(a, b){ + var a_group, b_group; + if (a.isRowHeader){ + a_group = a.headerPriority; + } + else if ( typeof(a.grouping) === 'undefined' || typeof(a.grouping.groupPriority) === 'undefined' || a.grouping.groupPriority < 0){ + a_group = null; + } else { + a_group = a.grouping.groupPriority; + } + + if (b.isRowHeader){ + b_group = b.headerPriority; + } + else if ( typeof(b.grouping) === 'undefined' || typeof(b.grouping.groupPriority) === 'undefined' || b.grouping.groupPriority < 0){ + b_group = null; + } else { + b_group = b.grouping.groupPriority; + } + + // groups get sorted to the top + if ( a_group !== null && b_group === null) { return -1; } + if ( b_group !== null && a_group === null) { return 1; } + if ( a_group !== null && b_group !== null) {return a_group - b_group; } + + return a.groupingPosition - b.groupingPosition; + }); + + columns.forEach( function(column, index) { + delete column.groupingPosition; + }); + + return columns; + }, + + + /** + * @ngdoc function + * @name groupColumn + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Adds this column to the existing grouping, at the end of the priority order. + * If the column doesn't have a sort, adds one, by default ASC + * + * This column will move to the left of any non-group columns, the + * move is handled in a columnProcessor, so gets called as part of refresh + * + * @param {Grid} grid grid object + * @param {GridColumn} column the column we want to group + */ + groupColumn: function( grid, column){ + if ( typeof(column.grouping) === 'undefined' ){ + column.grouping = {}; + } + + // set the group priority to the next number in the hierarchy + var existingGrouping = service.getGrouping( grid ); + column.grouping.groupPriority = existingGrouping.grouping.length; + + // save sort in order to restore it when column is ungrouped + column.previousSort = angular.copy(column.sort); + + // add sort if not present + if ( !column.sort ){ + column.sort = { direction: uiGridConstants.ASC }; + } else if ( typeof(column.sort.direction) === 'undefined' || column.sort.direction === null ){ + column.sort.direction = uiGridConstants.ASC; + } + + column.treeAggregation = { type: uiGridGroupingConstants.aggregation.COUNT, source: 'grouping' }; + column.treeAggregationFn = uiGridTreeBaseService.nativeAggregations()[uiGridGroupingConstants.aggregation.COUNT].aggregationFn; + column.treeAggregationFinalizerFn = service.groupedFinalizerFn; + + grid.api.grouping.raise.groupingChanged(column); + // This indirectly calls service.tidyPriorities( grid ); + grid.api.core.raise.sortChanged(grid, grid.getColumnSorting()); + + grid.queueGridRefresh(); + }, + + + /** + * @ngdoc function + * @name ungroupColumn + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Removes the groupPriority from this column. If the + * column was previously aggregated the aggregation will come back. + * The sort will remain. + * + * This column will move to the right of any other group columns, the + * move is handled in a columnProcessor, so gets called as part of refresh + * + * @param {Grid} grid grid object + * @param {GridColumn} column the column we want to ungroup + */ + ungroupColumn: function( grid, column){ + if ( typeof(column.grouping) === 'undefined' ){ + return; + } + + delete column.grouping.groupPriority; + delete column.treeAggregation; + delete column.customTreeAggregationFinalizer; + + if (column.previousSort) { + column.sort = column.previousSort; + delete column.previousSort; + } + + service.tidyPriorities( grid ); + + grid.api.grouping.raise.groupingChanged(column); + grid.api.core.raise.sortChanged(grid, grid.getColumnSorting()); + + grid.queueGridRefresh(); + }, + + /** + * @ngdoc function + * @name aggregateColumn + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Sets the aggregation type on a column, if the + * column is currently grouped then it removes the grouping first. + * + * @param {Grid} grid grid object + * @param {GridColumn} column the column we want to aggregate + * @param {string} aggregationType of the recognised types from uiGridGroupingConstants or one of the custom aggregations from gridOptions + */ + aggregateColumn: function( grid, column, aggregationType){ + + if (typeof(column.grouping) !== 'undefined' && typeof(column.grouping.groupPriority) !== 'undefined' && column.grouping.groupPriority >= 0){ + service.ungroupColumn( grid, column ); + } + + var aggregationDef = {}; + if ( typeof(grid.options.treeCustomAggregations[aggregationType]) !== 'undefined' ){ + aggregationDef = grid.options.treeCustomAggregations[aggregationType]; + } else if ( typeof(uiGridTreeBaseService.nativeAggregations()[aggregationType]) !== 'undefined' ){ + aggregationDef = uiGridTreeBaseService.nativeAggregations()[aggregationType]; + } + + column.treeAggregation = { type: aggregationType, label: i18nService.get().aggregation[aggregationDef.label] || aggregationDef.label }; + column.treeAggregationFn = aggregationDef.aggregationFn; + column.treeAggregationFinalizerFn = aggregationDef.finalizerFn; + + grid.api.grouping.raise.aggregationChanged(column); + + grid.queueGridRefresh(); + }, + + + /** + * @ngdoc function + * @name setGrouping + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Set the grouping based on a config object, used by the save state feature + * (more specifically, by the restore function in that feature ) + * + * @param {Grid} grid grid object + * @param {object} config the config we want to set, same format as that returned by getGrouping + */ + setGrouping: function ( grid, config ){ + if ( typeof(config) === 'undefined' ){ + return; + } + + // first remove any existing grouping + service.clearGrouping(grid); + + if ( config.grouping && config.grouping.length && config.grouping.length > 0 ){ + config.grouping.forEach( function( group ) { + var col = grid.getColumn(group.colName); + + if ( col ) { + service.groupColumn( grid, col ); + } + }); + } + + if ( config.aggregations && config.aggregations.length ){ + config.aggregations.forEach( function( aggregation ) { + var col = grid.getColumn(aggregation.colName); + + if ( col ) { + service.aggregateColumn( grid, col, aggregation.aggregation.type ); + } + }); + } + + if ( config.rowExpandedStates ){ + service.applyRowExpandedStates( grid.grouping.groupingHeaderCache, config.rowExpandedStates ); + } + }, + + + /** + * @ngdoc function + * @name clearGrouping + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Clear any grouped columns and any aggregations. Doesn't remove sorting, + * as we don't know whether that sorting was added by grouping or was there beforehand + * + * @param {Grid} grid grid object + */ + clearGrouping: function( grid ) { + var currentGrouping = service.getGrouping(grid); + + if ( currentGrouping.grouping.length > 0 ){ + currentGrouping.grouping.forEach( function( group ) { + if (!group.col){ + // should have a group.colName if there's no col + group.col = grid.getColumn(group.colName); + } + service.ungroupColumn(grid, group.col); + }); + } + + if ( currentGrouping.aggregations.length > 0 ){ + currentGrouping.aggregations.forEach( function( aggregation ){ + if (!aggregation.col){ + // should have a group.colName if there's no col + aggregation.col = grid.getColumn(aggregation.colName); + } + service.aggregateColumn(grid, aggregation.col, null); + }); + } + }, + + + /** + * @ngdoc function + * @name tidyPriorities + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Renumbers groupPriority and sortPriority such that + * groupPriority is contiguous, and sortPriority either matches + * groupPriority (for group columns), and otherwise is contiguous and + * higher than groupPriority. + * + * @param {Grid} grid grid object + */ + tidyPriorities: function( grid ){ + // if we're called from sortChanged, grid is in this, not passed as param, the param can be a column or undefined + if ( ( typeof(grid) === 'undefined' || typeof(grid.grid) !== 'undefined' ) && typeof(this.grid) !== 'undefined' ) { + grid = this.grid; + } + + var groupArray = []; + var sortArray = []; + + grid.columns.forEach( function(column, index){ + if ( typeof(column.grouping) !== 'undefined' && typeof(column.grouping.groupPriority) !== 'undefined' && column.grouping.groupPriority >= 0){ + groupArray.push(column); + } else if ( typeof(column.sort) !== 'undefined' && typeof(column.sort.priority) !== 'undefined' && column.sort.priority >= 0){ + sortArray.push(column); + } + }); + + groupArray.sort(function(a, b){ return a.grouping.groupPriority - b.grouping.groupPriority; }); + groupArray.forEach( function(column, index){ + column.grouping.groupPriority = index; + column.suppressRemoveSort = true; + if ( typeof(column.sort) === 'undefined'){ + column.sort = {}; + } + column.sort.priority = index; + }); + + var i = groupArray.length; + sortArray.sort(function(a, b){ return a.sort.priority - b.sort.priority; }); + sortArray.forEach( function(column, index){ + column.sort.priority = i; + column.suppressRemoveSort = column.colDef.suppressRemoveSort; + i++; + }); + }, + + + /** + * @ngdoc function + * @name groupRows + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description The rowProcessor that creates the groupHeaders (i.e. does + * the actual grouping). + * + * Assumes it is always called after the sorting processor, guaranteed by the priority setting + * + * Processes all the rows in order, inserting a groupHeader row whenever there is a change + * in value of a grouped row, based on the sortAlgorithm used for the column. The group header row + * is looked up in the groupHeaderCache, and used from there if there is one. The entity is reset + * to {} if one is found. + * + * As it processes it maintains a `processingState` array. This records, for each level of grouping we're + * working with, the following information: + * ``` + * { + * fieldName: name, + * col: col, + * initialised: boolean, + * currentValue: value, + * currentRow: gridRow, + * } + * ``` + * We look for changes in the currentValue at any of the levels. Where we find a change we: + * + * - create a new groupHeader row in the array + * + * @param {array} renderableRows the rows we want to process, usually the output from the previous rowProcessor + * @returns {array} the updated rows, including our new group rows + */ + groupRows: function( renderableRows ) { + if (renderableRows.length === 0){ + return renderableRows; + } + + var grid = this; + grid.grouping.oldGroupingHeaderCache = grid.grouping.groupingHeaderCache || {}; + grid.grouping.groupingHeaderCache = {}; + + var processingState = service.initialiseProcessingState( grid ); + + // processes each of the fields we are grouping by, checks if the value has changed and inserts a groupHeader + // Broken out as shouldn't create functions in a loop. + var updateProcessingState = function( groupFieldState, stateIndex ) { + var fieldValue = grid.getCellValue(row, groupFieldState.col); + + // look for change of value - and insert a header + if ( !groupFieldState.initialised || rowSorter.getSortFn(grid, groupFieldState.col, renderableRows)(fieldValue, groupFieldState.currentValue) !== 0 ){ + service.insertGroupHeader( grid, renderableRows, i, processingState, stateIndex ); + i++; + } + }; + + // use a for loop because it's tolerant of the array length changing whilst we go - we can + // manipulate the iterator when we insert groupHeader rows + for (var i = 0; i < renderableRows.length; i++ ){ + var row = renderableRows[i]; + + if ( row.visible ){ + processingState.forEach( updateProcessingState ); + } + } + + delete grid.grouping.oldGroupingHeaderCache; + return renderableRows; + }, + + + /** + * @ngdoc function + * @name initialiseProcessingState + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Creates the processing state array that is used + * for groupRows. + * + * @param {Grid} grid grid object + * @returns {array} an array in the format described in the groupRows method, + * initialised with blank values + */ + initialiseProcessingState: function( grid ){ + var processingState = []; + var columnSettings = service.getGrouping( grid ); + + columnSettings.grouping.forEach( function( groupItem, index){ + processingState.push({ + fieldName: groupItem.field, + col: groupItem.col, + initialised: false, + currentValue: null, + currentRow: null + }); + }); + + return processingState; + }, + + + /** + * @ngdoc function + * @name getGrouping + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Get the grouping settings from the columns. As a side effect + * this always renumbers the grouping starting at 0 + * @param {Grid} grid grid object + * @returns {array} an array of the group fields, in order of priority + */ + getGrouping: function( grid ){ + var groupArray = []; + var aggregateArray = []; + + // get all the grouping + grid.columns.forEach( function(column, columnIndex){ + if ( column.grouping ){ + if ( typeof(column.grouping.groupPriority) !== 'undefined' && column.grouping.groupPriority >= 0){ + groupArray.push({ field: column.field, col: column, groupPriority: column.grouping.groupPriority, grouping: column.grouping }); + } + } + if ( column.treeAggregation && column.treeAggregation.type ){ + aggregateArray.push({ field: column.field, col: column, aggregation: column.treeAggregation }); + } + }); + + // sort grouping into priority order + groupArray.sort( function(a, b){ + return a.groupPriority - b.groupPriority; + }); + + // renumber the priority in case it was somewhat messed up, then remove the grouping reference + groupArray.forEach( function( group, index) { + group.grouping.groupPriority = index; + group.groupPriority = index; + delete group.grouping; + }); + + return { grouping: groupArray, aggregations: aggregateArray }; + }, + + + /** + * @ngdoc function + * @name insertGroupHeader + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Create a group header row, and link it to the various configuration + * items that we use. + * + * Look for the row in the oldGroupingHeaderCache, write the row into the new groupingHeaderCache. + * + * @param {Grid} grid grid object + * @param {array} renderableRows the rows that we are processing + * @param {number} rowIndex the row we were up to processing + * @param {array} processingState the current processing state + * @param {number} stateIndex the processing state item that we were on when we triggered a new group header - + * i.e. the column that we want to create a header for + */ + insertGroupHeader: function( grid, renderableRows, rowIndex, processingState, stateIndex ) { + // set the value that caused the end of a group into the header row and the processing state + var fieldName = processingState[stateIndex].fieldName; + var col = processingState[stateIndex].col; + + var newValue = grid.getCellValue(renderableRows[rowIndex], col); + var newDisplayValue = newValue; + if ( typeof(newValue) === 'undefined' || newValue === null ) { + newDisplayValue = grid.options.groupingNullLabel; + } + + var getKeyAsValueForCacheMap = function(key) { + if (angular.isObject(key)) { + return JSON.stringify(key); + } else { + return key; + } + }; + + var cacheItem = grid.grouping.oldGroupingHeaderCache; + for ( var i = 0; i < stateIndex; i++ ){ + if ( cacheItem && cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)] ){ + cacheItem = cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)].children; + } + } + + var headerRow; + if ( cacheItem && cacheItem[getKeyAsValueForCacheMap(newValue)]){ + headerRow = cacheItem[getKeyAsValueForCacheMap(newValue)].row; + headerRow.entity = {}; + } else { + headerRow = new GridRow( {}, null, grid ); + gridClassFactory.rowTemplateAssigner.call(grid, headerRow); + } + + headerRow.entity['$$' + processingState[stateIndex].col.uid] = { groupVal: newDisplayValue }; + headerRow.treeLevel = stateIndex; + headerRow.groupHeader = true; + headerRow.internalRow = true; + headerRow.enableCellEdit = false; + headerRow.enableSelection = grid.options.enableGroupHeaderSelection; + processingState[stateIndex].initialised = true; + processingState[stateIndex].currentValue = newValue; + processingState[stateIndex].currentRow = headerRow; + + // set all processing states below this one to not be initialised - change of this state + // means all those need to start again + service.finaliseProcessingState( processingState, stateIndex + 1); + + // insert our new header row + renderableRows.splice(rowIndex, 0, headerRow); + + // add our new header row to the cache + cacheItem = grid.grouping.groupingHeaderCache; + for ( i = 0; i < stateIndex; i++ ){ + cacheItem = cacheItem[getKeyAsValueForCacheMap(processingState[i].currentValue)].children; + } + cacheItem[getKeyAsValueForCacheMap(newValue)] = { row: headerRow, children: {} }; + }, + + + /** + * @ngdoc function + * @name finaliseProcessingState + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Set all processing states lower than the one that had a break in value to + * no longer be initialised. Render the counts into the entity ready for display. + * + * @param {array} processingState the current processing state + * @param {number} stateIndex the processing state item that we were on when we triggered a new group header, all + * processing states after this need to be finalised + */ + finaliseProcessingState: function( processingState, stateIndex ){ + for ( var i = stateIndex; i < processingState.length; i++){ + processingState[i].initialised = false; + processingState[i].currentRow = null; + processingState[i].currentValue = null; + } + }, + + + /** + * @ngdoc function + * @name getRowExpandedStates + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Extract the groupHeaderCache hash, pulling out only the states. + * + * The example below shows a grid that is grouped by gender then age + * + *
    +       *   {
    +       *     male: {
    +       *       state: 'expanded',
    +       *       children: {
    +       *         22: { state: 'expanded' },
    +       *         30: { state: 'collapsed' }
    +       *       }
    +       *     },
    +       *     female: {
    +       *       state: 'expanded',
    +       *       children: {
    +       *         28: { state: 'expanded' },
    +       *         55: { state: 'collapsed' }
    +       *       }
    +       *     }
    +       *   }
    +       * 
    + * + * @param {object} treeChildren The tree children elements object + * @returns {object} the expanded states as an object + */ + getRowExpandedStates: function(treeChildren){ + if ( typeof(treeChildren) === 'undefined' ){ + return {}; + } + + var newChildren = {}; + + angular.forEach( treeChildren, function( value, key ){ + newChildren[key] = { state: value.row.treeNode.state }; + if ( value.children ){ + newChildren[key].children = service.getRowExpandedStates( value.children ); + } else { + newChildren[key].children = {}; + } + }); + + return newChildren; + }, + + + /** + * @ngdoc function + * @name applyRowExpandedStates + * @methodOf ui.grid.grouping.service:uiGridGroupingService + * @description Take a hash in the format as created by getRowExpandedStates, + * and apply it to the grid.grouping.groupHeaderCache. + * + * Takes a treeSubset, and applies to a treeSubset - so can be called + * recursively. + * + * @param {object} currentNode can be grid.grouping.groupHeaderCache, or any of + * the children of that hash + * @param {object} expandedStates can be the full expanded states, or children + * of that expanded states (which hopefully matches the subset of the groupHeaderCache) + */ + applyRowExpandedStates: function( currentNode, expandedStates ){ + if ( typeof(expandedStates) === 'undefined' ){ + return; + } + + angular.forEach(expandedStates, function( value, key ) { + if ( currentNode[key] ){ + currentNode[key].row.treeNode.state = value.state; + + if (value.children && currentNode[key].children){ + service.applyRowExpandedStates( currentNode[key].children, value.children ); + } + } + }); + } + + + }; + + return service; + + }]); + + + /** + * @ngdoc directive + * @name ui.grid.grouping.directive:uiGridGrouping + * @element div + * @restrict A + * + * @description Adds grouping features to grid + * + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.grouping']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + + $scope.columnDefs = [ + {name: 'name', enableCellEdit: true}, + {name: 'title', enableCellEdit: true} + ]; + + $scope.gridOptions = { columnDefs: $scope.columnDefs, data: $scope.data }; + }]); + + +
    +
    +
    +
    +
    + */ + module.directive('uiGridGrouping', ['uiGridGroupingConstants', 'uiGridGroupingService', + function (uiGridGroupingConstants, uiGridGroupingService) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + if (uiGridCtrl.grid.options.enableGrouping !== false){ + uiGridGroupingService.initializeGrid(uiGridCtrl.grid, $scope); + } + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + } + }; + } + }; + }]); + +})(); diff --git a/release/4.4.11/ui-grid.grouping.min.js b/release/4.4.11/ui-grid.grouping.min.js new file mode 100644 index 000000000..8bc3661b1 --- /dev/null +++ b/release/4.4.11/ui-grid.grouping.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var r=angular.module("ui.grid.grouping",["ui.grid","ui.grid.treeBase"]);r.constant("uiGridGroupingConstants",{featureName:"grouping",rowHeaderColName:"treeBaseRowHeaderCol",EXPANDED:"expanded",COLLAPSED:"collapsed",aggregation:{COUNT:"count",SUM:"sum",MAX:"max",MIN:"min",AVG:"avg"}}),r.service("uiGridGroupingService",["$q","uiGridGroupingConstants","gridUtil","rowSorter","GridRow","gridClassFactory","i18nService","uiGridConstants","uiGridTreeBaseService",function(r,u,a,p,s,d,l,e,c){var f={initializeGrid:function(n,r){c.initializeGrid(n,r),n.grouping={},n.grouping.groupHeaderCache={},f.defaultGridOptions(n.options),n.registerRowsProcessor(f.groupRows,400),n.registerColumnBuilder(f.groupingColumnBuilder),n.registerColumnsProcessor(f.groupingColumnProcessor,400);var o={events:{grouping:{aggregationChanged:{},groupingChanged:{}}},methods:{grouping:{getGrouping:function(r){var o=f.getGrouping(n);return o.grouping.forEach(function(r){r.colName=r.col.name,delete r.col}),o.aggregations.forEach(function(r){r.colName=r.col.name,delete r.col}),o.aggregations=o.aggregations.filter(function(r){return!r.aggregation.source||"grouping"!==r.aggregation.source}),r&&(o.rowExpandedStates=f.getRowExpandedStates(n.grouping.groupingHeaderCache)),o},setGrouping:function(r){f.setGrouping(n,r)},groupColumn:function(r){var o=n.getColumn(r);f.groupColumn(n,o)},ungroupColumn:function(r){var o=n.getColumn(r);f.ungroupColumn(n,o)},clearGrouping:function(){f.clearGrouping(n)},aggregateColumn:function(r,o,i){var e=n.getColumn(r);f.aggregateColumn(n,e,o,i)}}}};n.api.registerEventsFromObject(o.events),n.api.registerMethodsFromObject(o.methods),n.api.core.on.sortChanged(r,f.tidyPriorities)},defaultGridOptions:function(r){r.enableGrouping=!1!==r.enableGrouping,r.groupingShowCounts=!1!==r.groupingShowCounts,r.groupingNullLabel=void 0===r.groupingNullLabel?"Null":r.groupingNullLabel,r.enableGroupHeaderSelection=!0===r.enableGroupHeaderSelection},groupingColumnBuilder:function(r,e,o){if(!1!==r.enableGrouping){void 0===e.grouping&&void 0!==r.grouping?(e.grouping=angular.copy(r.grouping),void 0!==e.grouping.groupPriority&&-1Stable This feature is stable. There should no longer be breaking api changes without a deprecation warning. + * + * This module provides the ability to import data into the grid. It + * uses the column defs to work out which data belongs in which column, + * and creates entities from a configured class (typically a $resource). + * + * If the rowEdit feature is enabled, it also calls save on those newly + * created objects, and then displays any errors in the imported data. + * + * Currently the importer imports only CSV and json files, although provision has been + * made to process other file formats, and these can be added over time. + * + * For json files, the properties within each object in the json must match the column names + * (to put it another way, the importer doesn't process the json, it just copies the objects + * within the json into a new instance of the specified object type) + * + * For CSV import, the default column identification relies on each column in the + * header row matching a column.name or column.displayName. Optionally, a column identification + * callback can be used. This allows matching using other attributes, which is particularly + * useful if your application has internationalised column headings (i.e. the headings that + * the user sees don't match the column names). + * + * The importer makes use of the grid menu as the UI for requesting an + * import. + * + *
    + */ + + var module = angular.module('ui.grid.importer', ['ui.grid']); + + /** + * @ngdoc object + * @name ui.grid.importer.constant:uiGridImporterConstants + * + * @description constants available in importer module + */ + + module.constant('uiGridImporterConstants', { + featureName: 'importer' + }); + + /** + * @ngdoc service + * @name ui.grid.importer.service:uiGridImporterService + * + * @description Services for importer feature + */ + module.service('uiGridImporterService', ['$q', 'uiGridConstants', 'uiGridImporterConstants', 'gridUtil', '$compile', '$interval', 'i18nService', '$window', + function ($q, uiGridConstants, uiGridImporterConstants, gridUtil, $compile, $interval, i18nService, $window) { + + var service = { + + initializeGrid: function ($scope, grid) { + + //add feature namespace and any properties to grid for needed state + grid.importer = { + $scope: $scope + }; + + this.defaultGridOptions(grid.options); + + /** + * @ngdoc object + * @name ui.grid.importer.api:PublicApi + * + * @description Public Api for importer feature + */ + var publicApi = { + events: { + importer: { + } + }, + methods: { + importer: { + /** + * @ngdoc function + * @name importFile + * @methodOf ui.grid.importer.api:PublicApi + * @description Imports a file into the grid using the file object + * provided. Bypasses the grid menu + * @param {File} fileObject the file we want to import, as a javascript + * File object + */ + importFile: function ( fileObject ) { + service.importThisFile( grid, fileObject ); + } + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + + grid.api.registerMethodsFromObject(publicApi.methods); + + if ( grid.options.enableImporter && grid.options.importerShowMenu ){ + if ( grid.api.core.addToGridMenu ){ + service.addToMenu( grid ); + } else { + // order of registration is not guaranteed, register in a little while + $interval( function() { + if (grid.api.core.addToGridMenu){ + service.addToMenu( grid ); + } + }, 100, 1); + } + } + }, + + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.importer.api:GridOptions + * + * @description GridOptions for importer feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc property + * @propertyOf ui.grid.importer.api:GridOptions + * @name enableImporter + * @description Whether or not importer is enabled. Automatically set + * to false if the user's browser does not support the required fileApi. + * Otherwise defaults to true. + * + */ + if (gridOptions.enableImporter || gridOptions.enableImporter === undefined) { + if ( !($window.hasOwnProperty('File') && $window.hasOwnProperty('FileReader') && $window.hasOwnProperty('FileList') && $window.hasOwnProperty('Blob')) ) { + gridUtil.logError('The File APIs are not fully supported in this browser, grid importer cannot be used.'); + gridOptions.enableImporter = false; + } else { + gridOptions.enableImporter = true; + } + } else { + gridOptions.enableImporter = false; + } + + /** + * @ngdoc method + * @name importerProcessHeaders + * @methodOf ui.grid.importer.api:GridOptions + * @description A callback function that will process headers using custom + * logic. Set this callback function if the headers that your user will provide in their + * import file don't necessarily match the grid header or field names. This might commonly + * occur where your application is internationalised, and therefore the field names + * that the user recognises are in a different language than the field names that + * ui-grid knows about. + * + * Defaults to the internal `processHeaders` method, which seeks to match using both + * displayName and column.name. Any non-matching columns are discarded. + * + * Your callback routine should respond by processing the header array, and returning an array + * of matching column names. A null value in any given position means "don't import this column" + * + *
    +           *      gridOptions.importerProcessHeaders: function( grid, headerArray ) {
    +           *        var myHeaderColumns = [];
    +           *        var thisCol;
    +           *        headerArray.forEach( function( value, index ) {
    +           *          thisCol = mySpecialLookupFunction( value );
    +           *          myHeaderColumns.push( thisCol.name );
    +           *        });
    +           *
    +           *        return myHeaderCols;
    +           *      })
    +           * 
    + * @param {Grid} grid the grid we're importing into + * @param {array} headerArray an array of the text from the first row of the csv file, + * which you need to match to column.names + * @returns {array} array of matching column names, in the same order as the headerArray + * + */ + gridOptions.importerProcessHeaders = gridOptions.importerProcessHeaders || service.processHeaders; + + /** + * @ngdoc method + * @name importerHeaderFilter + * @methodOf ui.grid.importer.api:GridOptions + * @description A callback function that will filter (usually translate) a single + * header. Used when you want to match the passed in column names to the column + * displayName after the header filter. + * + * Your callback routine needs to return the filtered header value. + *
    +           *      gridOptions.importerHeaderFilter: function( displayName ) {
    +           *        return $translate.instant( displayName );
    +           *      })
    +           * 
    + * + * or: + *
    +           *      gridOptions.importerHeaderFilter: $translate.instant
    +           * 
    + * @param {string} displayName the displayName that we'd like to translate + * @returns {string} the translated name + * + */ + gridOptions.importerHeaderFilter = gridOptions.importerHeaderFilter || function( displayName ) { return displayName; }; + + /** + * @ngdoc method + * @name importerErrorCallback + * @methodOf ui.grid.importer.api:GridOptions + * @description A callback function that provides custom error handling, rather + * than the standard grid behaviour of an alert box and a console message. You + * might use this to internationalise the console log messages, or to write to a + * custom logging routine that returned errors to the server. + * + *
    +           *      gridOptions.importerErrorCallback: function( grid, errorKey, consoleMessage, context ) {
    +           *        myUserDisplayRoutine( errorKey );
    +           *        myLoggingRoutine( consoleMessage, context );
    +           *      })
    +           * 
    + * @param {Grid} grid the grid we're importing into, may be useful if you're positioning messages + * in some way + * @param {string} errorKey one of the i18n keys the importer can return - importer.noHeaders, + * importer.noObjects, importer.invalidCsv, importer.invalidJson, importer.jsonNotArray + * @param {string} consoleMessage the English console message that importer would have written + * @param {object} context the context data that importer would have appended to that console message, + * often the file content itself or the element that is in error + * + */ + if ( !gridOptions.importerErrorCallback || typeof(gridOptions.importerErrorCallback) !== 'function' ){ + delete gridOptions.importerErrorCallback; + } + + /** + * @ngdoc method + * @name importerDataAddCallback + * @methodOf ui.grid.importer.api:GridOptions + * @description A mandatory callback function that adds data to the source data array. The grid + * generally doesn't add rows to the source data array, it is tidier to handle this through a user + * callback. + * + *
    +           *      gridOptions.importerDataAddCallback: function( grid, newObjects ) {
    +           *        $scope.myData = $scope.myData.concat( newObjects );
    +           *      })
    +           * 
    + * @param {Grid} grid the grid we're importing into, may be useful in some way + * @param {array} newObjects an array of new objects that you should add to your data + * + */ + if ( gridOptions.enableImporter === true && !gridOptions.importerDataAddCallback ) { + gridUtil.logError("You have not set an importerDataAddCallback, importer is disabled"); + gridOptions.enableImporter = false; + } + + /** + * @ngdoc object + * @name importerNewObject + * @propertyOf ui.grid.importer.api:GridOptions + * @description An object on which we call `new` to create each new row before inserting it into + * the data array. Typically this would be a $resource entity, which means that if you're using + * the rowEdit feature, you can directly call save on this entity when the save event is triggered. + * + * Defaults to a vanilla javascript object + * + * @example + *
    +           *   gridOptions.importerNewObject = MyRes;
    +           * 
    + * + */ + + /** + * @ngdoc property + * @propertyOf ui.grid.importer.api:GridOptions + * @name importerShowMenu + * @description Whether or not to show an item in the grid menu. Defaults to true. + * + */ + gridOptions.importerShowMenu = gridOptions.importerShowMenu !== false; + + /** + * @ngdoc method + * @methodOf ui.grid.importer.api:GridOptions + * @name importerObjectCallback + * @description A callback that massages the data for each object. For example, + * you might have data stored as a code value, but display the decode. This callback + * can be used to change the decoded value back into a code. Defaults to doing nothing. + * @param {Grid} grid in case you need it + * @param {object} newObject the new object as importer has created it, modify it + * then return the modified version + * @returns {object} the modified object + * @example + *
    +           *   gridOptions.importerObjectCallback = function ( grid, newObject ) {
    +           *     switch newObject.status {
    +           *       case 'Active':
    +           *         newObject.status = 1;
    +           *         break;
    +           *       case 'Inactive':
    +           *         newObject.status = 2;
    +           *         break;
    +           *     }
    +           *     return newObject;
    +           *   };
    +           * 
    + */ + gridOptions.importerObjectCallback = gridOptions.importerObjectCallback || function( grid, newObject ) { return newObject; }; + }, + + + /** + * @ngdoc function + * @name addToMenu + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Adds import menu item to the grid menu, + * allowing the user to request import of a file + * @param {Grid} grid the grid into which data should be imported + */ + addToMenu: function ( grid ) { + grid.api.core.addToGridMenu( grid, [ + { + title: i18nService.getSafeText('gridMenu.importerTitle'), + order: 150 + }, + { + templateUrl: 'ui-grid/importerMenuItemContainer', + action: function ($event) { + this.grid.api.importer.importAFile( grid ); + }, + order: 151 + } + ]); + }, + + + /** + * @ngdoc function + * @name importThisFile + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Imports the provided file into the grid using the file object + * provided. Bypasses the grid menu + * @param {Grid} grid the grid we're importing into + * @param {File} fileObject the file we want to import, as returned from the File + * javascript object + */ + importThisFile: function ( grid, fileObject ) { + if (!fileObject){ + gridUtil.logError( 'No file object provided to importThisFile, should be impossible, aborting'); + return; + } + + var reader = new FileReader(); + + switch ( fileObject.type ){ + case 'application/json': + reader.onload = service.importJsonClosure( grid ); + break; + default: + reader.onload = service.importCsvClosure( grid ); + break; + } + + reader.readAsText( fileObject ); + }, + + + /** + * @ngdoc function + * @name importJson + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Creates a function that imports a json file into the grid. + * The json data is imported into new objects of type `gridOptions.importerNewObject`, + * and if the rowEdit feature is enabled the rows are marked as dirty + * @param {Grid} grid the grid we want to import into + * @param {FileObject} importFile the file that we want to import, as + * a FileObject + */ + importJsonClosure: function( grid ) { + return function( importFile ){ + var newObjects = []; + var newObject; + + var importArray = service.parseJson( grid, importFile ); + if (importArray === null){ + return; + } + importArray.forEach( function( value, index ) { + newObject = service.newObject( grid ); + angular.extend( newObject, value ); + newObject = grid.options.importerObjectCallback( grid, newObject ); + newObjects.push( newObject ); + }); + + service.addObjects( grid, newObjects ); + + }; + }, + + + /** + * @ngdoc function + * @name parseJson + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Parses a json file, returns the parsed data. + * Displays an error if file doesn't parse + * @param {Grid} grid the grid that we want to import into + * @param {FileObject} importFile the file that we want to import, as + * a FileObject + * @returns {array} array of objects from the imported json + */ + parseJson: function( grid, importFile ){ + var loadedObjects; + try { + loadedObjects = JSON.parse( importFile.target.result ); + } catch (e) { + service.alertError( grid, 'importer.invalidJson', 'File could not be processed, is it valid json? Content was: ', importFile.target.result ); + return; + } + + if ( !Array.isArray( loadedObjects ) ){ + service.alertError( grid, 'importer.jsonNotarray', 'Import failed, file is not an array, file was: ', importFile.target.result ); + return []; + } else { + return loadedObjects; + } + }, + + + + /** + * @ngdoc function + * @name importCsvClosure + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Creates a function that imports a csv file into the grid + * (allowing it to be used in the reader.onload event) + * @param {Grid} grid the grid that we want to import into + * @param {FileObject} importFile the file that we want to import, as + * a file object + */ + importCsvClosure: function( grid ) { + return function( importFile ){ + var importArray = service.parseCsv( importFile ); + if ( !importArray || importArray.length < 1 ){ + service.alertError( grid, 'importer.invalidCsv', 'File could not be processed, is it valid csv? Content was: ', importFile.target.result ); + return; + } + + var newObjects = service.createCsvObjects( grid, importArray ); + if ( !newObjects || newObjects.length === 0 ){ + service.alertError( grid, 'importer.noObjects', 'Objects were not able to be derived, content was: ', importFile.target.result ); + return; + } + + service.addObjects( grid, newObjects ); + }; + }, + + + /** + * @ngdoc function + * @name parseCsv + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Parses a csv file into an array of arrays, with the first + * array being the headers, and the remaining arrays being the data. + * The logic for this comes from https://github.com/thetalecrafter/excel.js/blob/master/src/csv.js, + * which is noted as being under the MIT license. The code is modified to pass the jscs yoda condition + * checker + * @param {FileObject} importFile the file that we want to import, as a + * file object + */ + parseCsv: function( importFile ) { + var csv = importFile.target.result; + + // use the CSV-JS library to parse + return CSV.parse(csv); + }, + + + /** + * @ngdoc function + * @name createCsvObjects + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Converts an array of arrays (representing the csv file) + * into a set of objects. Uses the provided `gridOptions.importerNewObject` + * to create the objects, and maps the header row into the individual columns + * using either `gridOptions.importerProcessHeaders`, or by using a native method + * of matching to either the displayName, column name or column field of + * the columns in the column defs. The resulting objects will have attributes + * that are named based on the column.field or column.name, in that order. + * @param {Grid} grid the grid that we want to import into + * @param {Array} importArray the data that we want to import, as an array + */ + createCsvObjects: function( grid, importArray ){ + // pull off header row and turn into headers + var headerMapping = grid.options.importerProcessHeaders( grid, importArray.shift() ); + if ( !headerMapping || headerMapping.length === 0 ){ + service.alertError( grid, 'importer.noHeaders', 'Column names could not be derived, content was: ', importArray ); + return []; + } + + var newObjects = []; + var newObject; + importArray.forEach( function( row, index ) { + newObject = service.newObject( grid ); + if ( row !== null ){ + row.forEach( function( field, index ){ + if ( headerMapping[index] !== null ){ + newObject[ headerMapping[index] ] = field; + } + }); + } + newObject = grid.options.importerObjectCallback( grid, newObject ); + newObjects.push( newObject ); + }); + + return newObjects; + }, + + + /** + * @ngdoc function + * @name processHeaders + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Determines the columns that the header row from + * a csv (or other) file represents. + * @param {Grid} grid the grid we're importing into + * @param {array} headerRow the header row that we wish to match against + * the column definitions + * @returns {array} an array of the attribute names that should be used + * for that column, based on matching the headers or creating the headers + * + */ + processHeaders: function( grid, headerRow ) { + var headers = []; + if ( !grid.options.columnDefs || grid.options.columnDefs.length === 0 ){ + // we are going to create new columnDefs for all these columns, so just remove + // spaces from the names to create fields + headerRow.forEach( function( value, index ) { + headers.push( value.replace( /[^0-9a-zA-Z\-_]/g, '_' ) ); + }); + return headers; + } else { + var lookupHash = service.flattenColumnDefs( grid, grid.options.columnDefs ); + headerRow.forEach( function( value, index ) { + if ( lookupHash[value] ) { + headers.push( lookupHash[value] ); + } else if ( lookupHash[ value.toLowerCase() ] ) { + headers.push( lookupHash[ value.toLowerCase() ] ); + } else { + headers.push( null ); + } + }); + return headers; + } + }, + + + /** + * @name flattenColumnDefs + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Runs through the column defs and creates a hash of + * the displayName, name and field, and of each of those values forced to lower case, + * with each pointing to the field or name + * (whichever is present). Used to lookup column headers and decide what + * attribute name to give to the resulting field. + * @param {Grid} grid the grid we're importing into + * @param {array} columnDefs the columnDefs that we should flatten + * @returns {hash} the flattened version of the column def information, allowing + * us to look up a value by `flattenedHash[ headerValue ]` + */ + flattenColumnDefs: function( grid, columnDefs ){ + var flattenedHash = {}; + columnDefs.forEach( function( columnDef, index) { + if ( columnDef.name ){ + flattenedHash[ columnDef.name ] = columnDef.field || columnDef.name; + flattenedHash[ columnDef.name.toLowerCase() ] = columnDef.field || columnDef.name; + } + + if ( columnDef.field ){ + flattenedHash[ columnDef.field ] = columnDef.field || columnDef.name; + flattenedHash[ columnDef.field.toLowerCase() ] = columnDef.field || columnDef.name; + } + + if ( columnDef.displayName ){ + flattenedHash[ columnDef.displayName ] = columnDef.field || columnDef.name; + flattenedHash[ columnDef.displayName.toLowerCase() ] = columnDef.field || columnDef.name; + } + + if ( columnDef.displayName && grid.options.importerHeaderFilter ){ + flattenedHash[ grid.options.importerHeaderFilter(columnDef.displayName) ] = columnDef.field || columnDef.name; + flattenedHash[ grid.options.importerHeaderFilter(columnDef.displayName).toLowerCase() ] = columnDef.field || columnDef.name; + } + }); + + return flattenedHash; + }, + + + /** + * @ngdoc function + * @name addObjects + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Inserts our new objects into the grid data, and + * sets the rows to dirty if the rowEdit feature is being used + * + * Does this by registering a watch on dataChanges, which essentially + * is waiting on the result of the grid data watch, and downstream processing. + * + * When the callback is called, it deregisters itself - we don't want to run + * again next time data is added. + * + * If we never get called, we deregister on destroy. + * + * @param {Grid} grid the grid we're importing into + * @param {array} newObjects the objects we want to insert into the grid data + * @returns {object} the new object + */ + addObjects: function( grid, newObjects, $scope ){ + if ( grid.api.rowEdit ){ + var dataChangeDereg = grid.registerDataChangeCallback( function() { + grid.api.rowEdit.setRowsDirty( newObjects ); + dataChangeDereg(); + }, [uiGridConstants.dataChange.ROW] ); + + grid.importer.$scope.$on( '$destroy', dataChangeDereg ); + } + + grid.importer.$scope.$apply( grid.options.importerDataAddCallback( grid, newObjects ) ); + + }, + + + /** + * @ngdoc function + * @name newObject + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Makes a new object based on `gridOptions.importerNewObject`, + * or based on an empty object if not present + * @param {Grid} grid the grid we're importing into + * @returns {object} the new object + */ + newObject: function( grid ){ + if ( typeof(grid.options) !== "undefined" && typeof(grid.options.importerNewObject) !== "undefined" ){ + return new grid.options.importerNewObject(); + } else { + return {}; + } + }, + + + /** + * @ngdoc function + * @name alertError + * @methodOf ui.grid.importer.service:uiGridImporterService + * @description Provides an internationalised user alert for the failure, + * and logs a console message including diagnostic content. + * Optionally, if the the `gridOptions.importerErrorCallback` routine + * is defined, then calls that instead, allowing user specified error routines + * @param {Grid} grid the grid we're importing into + * @param {array} headerRow the header row that we wish to match against + * the column definitions + */ + alertError: function( grid, alertI18nToken, consoleMessage, context ){ + if ( grid.options.importerErrorCallback ){ + grid.options.importerErrorCallback( grid, alertI18nToken, consoleMessage, context ); + } else { + $window.alert(i18nService.getSafeText( alertI18nToken )); + gridUtil.logError(consoleMessage + context ); + } + } + }; + + return service; + + } + ]); + + /** + * @ngdoc directive + * @name ui.grid.importer.directive:uiGridImporter + * @element div + * @restrict A + * + * @description Adds importer features to grid + * + */ + module.directive('uiGridImporter', ['uiGridImporterConstants', 'uiGridImporterService', 'gridUtil', '$compile', + function (uiGridImporterConstants, uiGridImporterService, gridUtil, $compile) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + link: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridImporterService.initializeGrid($scope, uiGridCtrl.grid); + } + }; + } + ]); + + /** + * @ngdoc directive + * @name ui.grid.importer.directive:uiGridImporterMenuItem + * @element div + * @restrict A + * + * @description Handles the processing from the importer menu item - once a file is + * selected + * + */ + module.directive('uiGridImporterMenuItem', ['uiGridImporterConstants', 'uiGridImporterService', 'gridUtil', '$compile', + function (uiGridImporterConstants, uiGridImporterService, gridUtil, $compile) { + return { + replace: true, + priority: 0, + require: '?^uiGrid', + scope: false, + templateUrl: 'ui-grid/importerMenuItem', + link: function ($scope, $elm, $attrs, uiGridCtrl) { + var grid; + + function handleFileSelect(event) { + var target = event.srcElement || event.target; + + if (target && target.files && target.files.length === 1) { + var fileObject = target.files[0]; + + // Define grid if the uiGrid controller is present + if (typeof(uiGridCtrl) !== 'undefined' && uiGridCtrl) { + grid = uiGridCtrl.grid; + + uiGridImporterService.importThisFile( grid, fileObject ); + target.form.reset(); + } else { + gridUtil.logError('Could not import file because UI Grid was not found.'); + } + } + } + + var fileChooser = $elm[0].querySelectorAll('.ui-grid-importer-file-chooser'); + + if ( fileChooser.length !== 1 ){ + gridUtil.logError('Found > 1 or < 1 file choosers within the menu item, error, cannot continue'); + } else { + fileChooser[0].addEventListener('change', handleFileSelect, false); + } + } + }; + } + ]); +})(); diff --git a/release/4.4.11/ui-grid.importer.min.js b/release/4.4.11/ui-grid.importer.min.js new file mode 100644 index 000000000..260481f7f --- /dev/null +++ b/release/4.4.11/ui-grid.importer.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.importer",["ui.grid"]);e.constant("uiGridImporterConstants",{featureName:"importer"}),e.service("uiGridImporterService",["$q","uiGridConstants","uiGridImporterConstants","gridUtil","$compile","$interval","i18nService","$window",function(e,i,r,n,t,o,a,s){var l={initializeGrid:function(e,r){r.importer={$scope:e},this.defaultGridOptions(r.options);var t={events:{importer:{}},methods:{importer:{importFile:function(e){l.importThisFile(r,e)}}}};r.api.registerEventsFromObject(t.events),r.api.registerMethodsFromObject(t.methods),r.options.enableImporter&&r.options.importerShowMenu&&(r.api.core.addToGridMenu?l.addToMenu(r):o(function(){r.api.core.addToGridMenu&&l.addToMenu(r)},100,1))},defaultGridOptions:function(e){e.enableImporter||void 0===e.enableImporter?s.hasOwnProperty("File")&&s.hasOwnProperty("FileReader")&&s.hasOwnProperty("FileList")&&s.hasOwnProperty("Blob")?e.enableImporter=!0:(n.logError("The File APIs are not fully supported in this browser, grid importer cannot be used."),e.enableImporter=!1):e.enableImporter=!1,e.importerProcessHeaders=e.importerProcessHeaders||l.processHeaders,e.importerHeaderFilter=e.importerHeaderFilter||function(e){return e},e.importerErrorCallback&&"function"==typeof e.importerErrorCallback||delete e.importerErrorCallback,!0!==e.enableImporter||e.importerDataAddCallback||(n.logError("You have not set an importerDataAddCallback, importer is disabled"),e.enableImporter=!1),e.importerShowMenu=!1!==e.importerShowMenu,e.importerObjectCallback=e.importerObjectCallback||function(e,r){return r}},addToMenu:function(r){r.api.core.addToGridMenu(r,[{title:a.getSafeText("gridMenu.importerTitle"),order:150},{templateUrl:"ui-grid/importerMenuItemContainer",action:function(e){this.grid.api.importer.importAFile(r)},order:151}])},importThisFile:function(e,r){if(r){var t=new FileReader;switch(r.type){case"application/json":t.onload=l.importJsonClosure(e);break;default:t.onload=l.importCsvClosure(e)}t.readAsText(r)}else n.logError("No file object provided to importThisFile, should be impossible, aborting")},importJsonClosure:function(i){return function(e){var t,o=[],r=l.parseJson(i,e);null!==r&&(r.forEach(function(e,r){t=l.newObject(i),angular.extend(t,e),t=i.options.importerObjectCallback(i,t),o.push(t)}),l.addObjects(i,o))}},parseJson:function(r,t){var e;try{e=JSON.parse(t.target.result)}catch(e){return void l.alertError(r,"importer.invalidJson","File could not be processed, is it valid json? Content was: ",t.target.result)}return Array.isArray(e)?e:(l.alertError(r,"importer.jsonNotarray","Import failed, file is not an array, file was: ",t.target.result),[])},importCsvClosure:function(o){return function(e){var r=l.parseCsv(e);if(!r||r.length<1)l.alertError(o,"importer.invalidCsv","File could not be processed, is it valid csv? Content was: ",e.target.result);else{var t=l.createCsvObjects(o,r);t&&0!==t.length?l.addObjects(o,t):l.alertError(o,"importer.noObjects","Objects were not able to be derived, content was: ",e.target.result)}}},parseCsv:function(e){var r=e.target.result;return CSV.parse(r)},createCsvObjects:function(t,e){var o=t.options.importerProcessHeaders(t,e.shift());if(!o||0===o.length)return l.alertError(t,"importer.noHeaders","Column names could not be derived, content was: ",e),[];var i,n=[];return e.forEach(function(e,r){i=l.newObject(t),null!==e&&e.forEach(function(e,r){null!==o[r]&&(i[o[r]]=e)}),i=t.options.importerObjectCallback(t,i),n.push(i)}),n},processHeaders:function(e,r){var t=[];if(e.options.columnDefs&&0!==e.options.columnDefs.length){var o=l.flattenColumnDefs(e,e.options.columnDefs);return r.forEach(function(e,r){o[e]?t.push(o[e]):o[e.toLowerCase()]?t.push(o[e.toLowerCase()]):t.push(null)}),t}return r.forEach(function(e,r){t.push(e.replace(/[^0-9a-zA-Z\-_]/g,"_"))}),t},flattenColumnDefs:function(t,e){var o={};return e.forEach(function(e,r){e.name&&(o[e.name]=e.field||e.name,o[e.name.toLowerCase()]=e.field||e.name),e.field&&(o[e.field]=e.field||e.name,o[e.field.toLowerCase()]=e.field||e.name),e.displayName&&(o[e.displayName]=e.field||e.name,o[e.displayName.toLowerCase()]=e.field||e.name),e.displayName&&t.options.importerHeaderFilter&&(o[t.options.importerHeaderFilter(e.displayName)]=e.field||e.name,o[t.options.importerHeaderFilter(e.displayName).toLowerCase()]=e.field||e.name)}),o},addObjects:function(e,r,t){if(e.api.rowEdit){var o=e.registerDataChangeCallback(function(){e.api.rowEdit.setRowsDirty(r),o()},[i.dataChange.ROW]);e.importer.$scope.$on("$destroy",o)}e.importer.$scope.$apply(e.options.importerDataAddCallback(e,r))},newObject:function(e){return void 0!==e.options&&void 0!==e.options.importerNewObject?new e.options.importerNewObject:{}},alertError:function(e,r,t,o){e.options.importerErrorCallback?e.options.importerErrorCallback(e,r,t,o):(s.alert(a.getSafeText(r)),n.logError(t+o))}};return l}]),e.directive("uiGridImporter",["uiGridImporterConstants","uiGridImporterService","gridUtil","$compile",function(e,i,r,t){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,link:function(e,r,t,o){i.initializeGrid(e,o.grid)}}}]),e.directive("uiGridImporterMenuItem",["uiGridImporterConstants","uiGridImporterService","gridUtil","$compile",function(e,a,s,r){return{replace:!0,priority:0,require:"?^uiGrid",scope:!1,templateUrl:"ui-grid/importerMenuItem",link:function(e,r,t,o){var i;var n=r[0].querySelectorAll(".ui-grid-importer-file-chooser");1!==n.length?s.logError("Found > 1 or < 1 file choosers within the menu item, error, cannot continue"):n[0].addEventListener("change",function(e){var r=e.srcElement||e.target;if(r&&r.files&&1===r.files.length){var t=r.files[0];void 0!==o&&o?(i=o.grid,a.importThisFile(i,t),r.form.reset()):s.logError("Could not import file because UI Grid was not found.")}},!1)}}}])}(); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.infinite-scroll.js b/release/4.4.11/ui-grid.infinite-scroll.js new file mode 100644 index 000000000..14082ec65 --- /dev/null +++ b/release/4.4.11/ui-grid.infinite-scroll.js @@ -0,0 +1,546 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function() { + 'use strict'; + /** + * @ngdoc overview + * @name ui.grid.infiniteScroll + * + * @description + * + * #ui.grid.infiniteScroll + * + * + * + * This module provides infinite scroll functionality to ui-grid + * + */ + var module = angular.module('ui.grid.infiniteScroll', ['ui.grid']); + /** + * @ngdoc service + * @name ui.grid.infiniteScroll.service:uiGridInfiniteScrollService + * + * @description Service for infinite scroll features + */ + module.service('uiGridInfiniteScrollService', ['gridUtil', '$compile', '$rootScope', 'uiGridConstants', 'ScrollEvent', '$q', function (gridUtil, $compile, $rootScope, uiGridConstants, ScrollEvent, $q) { + + var service = { + + /** + * @ngdoc function + * @name initializeGrid + * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService + * @description This method register events and methods into grid public API + */ + + initializeGrid: function(grid, $scope) { + service.defaultGridOptions(grid.options); + + if (!grid.options.enableInfiniteScroll){ + return; + } + + grid.infiniteScroll = { dataLoading: false }; + service.setScrollDirections( grid, grid.options.infiniteScrollUp, grid.options.infiniteScrollDown ); + grid.api.core.on.scrollEnd($scope, service.handleScroll); + + /** + * @ngdoc object + * @name ui.grid.infiniteScroll.api:PublicAPI + * + * @description Public API for infinite scroll feature + */ + var publicApi = { + events: { + infiniteScroll: { + + /** + * @ngdoc event + * @name needLoadMoreData + * @eventOf ui.grid.infiniteScroll.api:PublicAPI + * @description This event fires when scroll reaches bottom percentage of grid + * and needs to load data + */ + + needLoadMoreData: function ($scope, fn) { + }, + + /** + * @ngdoc event + * @name needLoadMoreDataTop + * @eventOf ui.grid.infiniteScroll.api:PublicAPI + * @description This event fires when scroll reaches top percentage of grid + * and needs to load data + */ + + needLoadMoreDataTop: function ($scope, fn) { + } + } + }, + methods: { + infiniteScroll: { + + /** + * @ngdoc function + * @name dataLoaded + * @methodOf ui.grid.infiniteScroll.api:PublicAPI + * @description Call this function when you have loaded the additional data + * requested. You should set scrollUp and scrollDown to indicate + * whether there are still more pages in each direction. + * + * If you call dataLoaded without first calling `saveScrollPercentage` then we will + * scroll the user to the start of the newly loaded data, which usually gives a smooth scroll + * experience, but can give a jumpy experience with large `infiniteScrollRowsFromEnd` values, and + * on variable speed internet connections. Using `saveScrollPercentage` as demonstrated in the tutorial + * should give a smoother scrolling experience for users. + * + * See infinite_scroll tutorial for example of usage + * @param {boolean} scrollUp if set to false flags that there are no more pages upwards, so don't fire + * any more infinite scroll events upward + * @param {boolean} scrollDown if set to false flags that there are no more pages downwards, so don't + * fire any more infinite scroll events downward + * @returns {promise} a promise that is resolved when the grid scrolling is fully adjusted. If you're + * planning to remove pages, you should wait on this promise first, or you'll break the scroll positioning + */ + dataLoaded: function( scrollUp, scrollDown ) { + service.setScrollDirections(grid, scrollUp, scrollDown); + + var promise = service.adjustScroll(grid).then(function() { + grid.infiniteScroll.dataLoading = false; + }); + + return promise; + }, + + /** + * @ngdoc function + * @name resetScroll + * @methodOf ui.grid.infiniteScroll.api:PublicAPI + * @description Call this function when you have taken some action that makes the current + * scroll position invalid. For example, if you're using external sorting and you've resorted + * then you might reset the scroll, or if you've otherwise substantially changed the data, perhaps + * you've reused an existing grid for a new data set + * + * You must tell us whether there is data upwards or downwards after the reset + * + * @param {boolean} scrollUp flag that there are pages upwards, fire + * infinite scroll events upward + * @param {boolean} scrollDown flag that there are pages downwards, so + * fire infinite scroll events downward + */ + resetScroll: function( scrollUp, scrollDown ) { + service.setScrollDirections( grid, scrollUp, scrollDown); + + service.adjustInfiniteScrollPosition(grid, 0); + }, + + + /** + * @ngdoc function + * @name saveScrollPercentage + * @methodOf ui.grid.infiniteScroll.api:PublicAPI + * @description Saves the scroll percentage and number of visible rows before you adjust the data, + * used if you're subsequently going to call `dataRemovedTop` or `dataRemovedBottom` + */ + saveScrollPercentage: function() { + grid.infiniteScroll.prevScrollTop = grid.renderContainers.body.prevScrollTop; + grid.infiniteScroll.previousVisibleRows = grid.getVisibleRowCount(); + }, + + + /** + * @ngdoc function + * @name dataRemovedTop + * @methodOf ui.grid.infiniteScroll.api:PublicAPI + * @description Adjusts the scroll position after you've removed data at the top + * @param {boolean} scrollUp flag that there are pages upwards, fire + * infinite scroll events upward + * @param {boolean} scrollDown flag that there are pages downwards, so + * fire infinite scroll events downward + */ + dataRemovedTop: function( scrollUp, scrollDown ) { + service.dataRemovedTop( grid, scrollUp, scrollDown ); + }, + + /** + * @ngdoc function + * @name dataRemovedBottom + * @methodOf ui.grid.infiniteScroll.api:PublicAPI + * @description Adjusts the scroll position after you've removed data at the bottom + * @param {boolean} scrollUp flag that there are pages upwards, fire + * infinite scroll events upward + * @param {boolean} scrollDown flag that there are pages downwards, so + * fire infinite scroll events downward + */ + dataRemovedBottom: function( scrollUp, scrollDown ) { + service.dataRemovedBottom( grid, scrollUp, scrollDown ); + }, + + /** + * @ngdoc function + * @name setScrollDirections + * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService + * @description Sets the scrollUp and scrollDown flags, handling nulls and undefined, + * and also sets the grid.suppressParentScroll + * @param {boolean} scrollUp whether there are pages available up - defaults to false + * @param {boolean} scrollDown whether there are pages available down - defaults to true + */ + setScrollDirections: function ( scrollUp, scrollDown ) { + service.setScrollDirections( grid, scrollUp, scrollDown ); + } + + } + } + }; + grid.api.registerEventsFromObject(publicApi.events); + grid.api.registerMethodsFromObject(publicApi.methods); + }, + + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.infiniteScroll.api:GridOptions + * + * @description GridOptions for infinite scroll feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc object + * @name enableInfiniteScroll + * @propertyOf ui.grid.infiniteScroll.api:GridOptions + * @description Enable infinite scrolling for this grid + *
    Defaults to true + */ + gridOptions.enableInfiniteScroll = gridOptions.enableInfiniteScroll !== false; + + /** + * @ngdoc property + * @name infiniteScrollRowsFromEnd + * @propertyOf ui.grid.class:GridOptions + * @description This setting controls how close to the end of the dataset a user gets before + * more data is requested by the infinite scroll, whether scrolling up or down. This allows you to + * 'prefetch' rows before the user actually runs out of scrolling. + * + * Note that if you set this value too high it may give jumpy scrolling behaviour, if you're getting + * this behaviour you could use the `saveScrollPercentageMethod` right before loading your data, and we'll + * preserve that scroll position + * + *
    Defaults to 20 + */ + gridOptions.infiniteScrollRowsFromEnd = gridOptions.infiniteScrollRowsFromEnd || 20; + + /** + * @ngdoc property + * @name infiniteScrollUp + * @propertyOf ui.grid.class:GridOptions + * @description Whether you allow infinite scroll up, implying that the first page of data + * you have displayed is in the middle of your data set. If set to true then we trigger the + * needMoreDataTop event when the user hits the top of the scrollbar. + *
    Defaults to false + */ + gridOptions.infiniteScrollUp = gridOptions.infiniteScrollUp === true; + + /** + * @ngdoc property + * @name infiniteScrollDown + * @propertyOf ui.grid.class:GridOptions + * @description Whether you allow infinite scroll down, implying that the first page of data + * you have displayed is in the middle of your data set. If set to true then we trigger the + * needMoreData event when the user hits the bottom of the scrollbar. + *
    Defaults to true + */ + gridOptions.infiniteScrollDown = gridOptions.infiniteScrollDown !== false; + }, + + + /** + * @ngdoc function + * @name setScrollDirections + * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService + * @description Sets the scrollUp and scrollDown flags, handling nulls and undefined, + * and also sets the grid.suppressParentScroll + * @param {grid} grid the grid we're operating on + * @param {boolean} scrollUp whether there are pages available up - defaults to false + * @param {boolean} scrollDown whether there are pages available down - defaults to true + */ + setScrollDirections: function ( grid, scrollUp, scrollDown ) { + grid.infiniteScroll.scrollUp = ( scrollUp === true ); + grid.suppressParentScrollUp = ( scrollUp === true ); + + grid.infiniteScroll.scrollDown = ( scrollDown !== false); + grid.suppressParentScrollDown = ( scrollDown !== false); + }, + + + /** + * @ngdoc function + * @name handleScroll + * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService + * @description Called whenever the grid scrolls, determines whether the scroll should + * trigger an infinite scroll request for more data + * @param {object} args the args from the event + */ + handleScroll: function (args) { + // don't request data if already waiting for data, or if source is coming from ui.grid.adjustInfiniteScrollPosition() function + if ( args.grid.infiniteScroll && args.grid.infiniteScroll.dataLoading || args.source === 'ui.grid.adjustInfiniteScrollPosition' ){ + return; + } + + if (args.y) { + + // If the user is scrolling very quickly all the way to the top/bottom, the scroll handler can get confused + // about the direction. First we check if they've gone all the way, and data always is loaded in this case. + if (args.y.percentage === 0) { + args.grid.scrollDirection = uiGridConstants.scrollDirection.UP; + service.loadData(args.grid); + } else if (args.y.percentage === 1) { + args.grid.scrollDirection = uiGridConstants.scrollDirection.DOWN; + service.loadData(args.grid); + } else { // Scroll position is somewhere in between top/bottom, so determine whether it's far enough to load more data. + var percentage; + var targetPercentage = args.grid.options.infiniteScrollRowsFromEnd / args.grid.renderContainers.body.visibleRowCache.length; + if (args.grid.scrollDirection === uiGridConstants.scrollDirection.UP ) { + percentage = args.y.percentage; + if (percentage <= targetPercentage){ + service.loadData(args.grid); + } + } else if (args.grid.scrollDirection === uiGridConstants.scrollDirection.DOWN) { + percentage = 1 - args.y.percentage; + if (percentage <= targetPercentage){ + service.loadData(args.grid); + } + } + } + } + }, + + + /** + * @ngdoc function + * @name loadData + * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService + * @description This function fires 'needLoadMoreData' or 'needLoadMoreDataTop' event based on scrollDirection + * and whether there are more pages upwards or downwards. It also stores the number of rows that we had previously, + * and clears out any saved scroll position so that we know whether or not the user calls `saveScrollPercentage` + * @param {Grid} grid the grid we're working on + */ + loadData: function (grid) { + // save number of currently visible rows to calculate new scroll position later - we know that we want + // to be at approximately the row we're currently at + grid.infiniteScroll.previousVisibleRows = grid.renderContainers.body.visibleRowCache.length; + grid.infiniteScroll.direction = grid.scrollDirection; + delete grid.infiniteScroll.prevScrollTop; + + if (grid.scrollDirection === uiGridConstants.scrollDirection.UP && grid.infiniteScroll.scrollUp ) { + grid.infiniteScroll.dataLoading = true; + grid.api.infiniteScroll.raise.needLoadMoreDataTop(); + } else if (grid.scrollDirection === uiGridConstants.scrollDirection.DOWN && grid.infiniteScroll.scrollDown ) { + grid.infiniteScroll.dataLoading = true; + grid.api.infiniteScroll.raise.needLoadMoreData(); + } + }, + + + /** + * @ngdoc function + * @name adjustScroll + * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService + * @description Once we are informed that data has been loaded, adjust the scroll position to account for that + * addition and to make things look clean. + * + * If we're scrolling up we scroll to the first row of the old data set - + * so we're assuming that you would have gotten to the top of the grid (from the 20% need more data trigger) by + * the time the data comes back. If we're scrolling down we scroll to the last row of the old data set - so we're + * assuming that you would have gotten to the bottom of the grid (from the 80% need more data trigger) by the time + * the data comes back. + * + * Neither of these are good assumptions, but making this a smoother experience really requires + * that trigger to not be a percentage, and to be much closer to the end of the data (say, 5 rows off the end). Even then + * it'd be better still to actually run into the end. But if the data takes a while to come back, they may have scrolled + * somewhere else in the mean-time, in which case they'll get a jump back to the new data. Anyway, this will do for + * now, until someone wants to do better. + * @param {Grid} grid the grid we're working on + * @returns {promise} a promise that is resolved when scrolling has finished + */ + adjustScroll: function(grid){ + var promise = $q.defer(); + $rootScope.$applyAsync(function () { + var newPercentage, viewportHeight, rowHeight, newVisibleRows, oldTop, newTop; + + viewportHeight = grid.getViewportHeight() + grid.headerHeight - grid.renderContainers.body.headerHeight - grid.scrollbarHeight; + rowHeight = grid.options.rowHeight; + + if ( grid.infiniteScroll.direction === undefined ){ + // called from initialize, tweak our scroll up a little + service.adjustInfiniteScrollPosition(grid, 0); + } + + newVisibleRows = grid.getVisibleRowCount(); + + // in case not enough data is loaded to enable scroller - load more data + var canvasHeight = rowHeight * newVisibleRows; + if (grid.infiniteScroll.scrollDown && (viewportHeight > canvasHeight)) { + grid.api.infiniteScroll.raise.needLoadMoreData(); + } + + if ( grid.infiniteScroll.direction === uiGridConstants.scrollDirection.UP ){ + oldTop = grid.infiniteScroll.prevScrollTop || 0; + newTop = oldTop + (newVisibleRows - grid.infiniteScroll.previousVisibleRows)*rowHeight; + service.adjustInfiniteScrollPosition(grid, newTop); + $rootScope.$applyAsync( function() { + promise.resolve(); + }); + } + + if ( grid.infiniteScroll.direction === uiGridConstants.scrollDirection.DOWN ){ + newTop = grid.infiniteScroll.prevScrollTop || (grid.infiniteScroll.previousVisibleRows*rowHeight - viewportHeight); + service.adjustInfiniteScrollPosition(grid, newTop); + $rootScope.$applyAsync( function() { + promise.resolve(); + }); + } + }, 0); + + return promise.promise; + }, + + + /** + * @ngdoc function + * @name adjustInfiniteScrollPosition + * @methodOf ui.grid.infiniteScroll.service:uiGridInfiniteScrollService + * @description This function fires 'needLoadMoreData' or 'needLoadMoreDataTop' event based on scrollDirection + * @param {Grid} grid the grid we're working on + * @param {number} scrollTop the position through the grid that we want to scroll to + */ + adjustInfiniteScrollPosition: function (grid, scrollTop) { + var scrollEvent = new ScrollEvent(grid, null, null, 'ui.grid.adjustInfiniteScrollPosition'), + visibleRows = grid.getVisibleRowCount(), + viewportHeight = grid.getViewportHeight() + grid.headerHeight - grid.renderContainers.body.headerHeight - grid.scrollbarHeight, + rowHeight = grid.options.rowHeight, + scrollHeight = visibleRows*rowHeight-viewportHeight; + + //for infinite scroll, if there are pages upwards then never allow it to be at the zero position so the up button can be active + if (scrollTop === 0 && grid.infiniteScroll.scrollUp) { + // using pixels results in a relative scroll, hence we have to use percentage + scrollEvent.y = {percentage: 1/scrollHeight}; + } + else { + scrollEvent.y = {percentage: scrollTop/scrollHeight}; + } + grid.scrollContainers('', scrollEvent); + }, + + + /** + * @ngdoc function + * @name dataRemovedTop + * @methodOf ui.grid.infiniteScroll.api:PublicAPI + * @description Adjusts the scroll position after you've removed data at the top. You should + * have called `saveScrollPercentage` before you remove the data, and if you're doing this in + * response to a `needMoreData` you should wait until the promise from `loadData` has resolved + * before you start removing data + * @param {Grid} grid the grid we're working on + * @param {boolean} scrollUp flag that there are pages upwards, fire + * infinite scroll events upward + * @param {boolean} scrollDown flag that there are pages downwards, so + * fire infinite scroll events downward + */ + dataRemovedTop: function( grid, scrollUp, scrollDown ) { + var newVisibleRows, oldTop, newTop, rowHeight; + service.setScrollDirections( grid, scrollUp, scrollDown ); + + newVisibleRows = grid.renderContainers.body.visibleRowCache.length; + oldTop = grid.infiniteScroll.prevScrollTop; + rowHeight = grid.options.rowHeight; + + // since we removed from the top, our new scroll row will be the old scroll row less the number + // of rows removed + newTop = oldTop - ( grid.infiniteScroll.previousVisibleRows - newVisibleRows )*rowHeight; + + service.adjustInfiniteScrollPosition( grid, newTop ); + }, + + /** + * @ngdoc function + * @name dataRemovedBottom + * @methodOf ui.grid.infiniteScroll.api:PublicAPI + * @description Adjusts the scroll position after you've removed data at the bottom. You should + * have called `saveScrollPercentage` before you remove the data, and if you're doing this in + * response to a `needMoreData` you should wait until the promise from `loadData` has resolved + * before you start removing data + * @param {Grid} grid the grid we're working on + * @param {boolean} scrollUp flag that there are pages upwards, fire + * infinite scroll events upward + * @param {boolean} scrollDown flag that there are pages downwards, so + * fire infinite scroll events downward + */ + dataRemovedBottom: function( grid, scrollUp, scrollDown ) { + var newTop; + service.setScrollDirections( grid, scrollUp, scrollDown ); + + newTop = grid.infiniteScroll.prevScrollTop; + + service.adjustInfiniteScrollPosition( grid, newTop ); + } + }; + return service; + }]); + /** + * @ngdoc directive + * @name ui.grid.infiniteScroll.directive:uiGridInfiniteScroll + * @element div + * @restrict A + * + * @description Adds infinite scroll features to grid + * + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.infiniteScroll']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Alex', car: 'Toyota' }, + { name: 'Sam', car: 'Lexus' } + ]; + + $scope.columnDefs = [ + {name: 'name'}, + {name: 'car'} + ]; + }]); + + +
    +
    +
    +
    +
    + */ + + module.directive('uiGridInfiniteScroll', ['uiGridInfiniteScrollService', + function (uiGridInfiniteScrollService) { + return { + priority: -200, + scope: false, + require: '^uiGrid', + compile: function($scope, $elm, $attr){ + return { + pre: function($scope, $elm, $attr, uiGridCtrl) { + uiGridInfiniteScrollService.initializeGrid(uiGridCtrl.grid, $scope); + }, + post: function($scope, $elm, $attr) { + } + }; + } + }; + }]); + +})(); diff --git a/release/4.4.11/ui-grid.infinite-scroll.min.js b/release/4.4.11/ui-grid.infinite-scroll.min.js new file mode 100644 index 000000000..3bfdac98e --- /dev/null +++ b/release/4.4.11/ui-grid.infinite-scroll.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var i=angular.module("ui.grid.infiniteScroll",["ui.grid"]);i.service("uiGridInfiniteScrollService",["gridUtil","$compile","$rootScope","uiGridConstants","ScrollEvent","$q",function(i,o,c,s,t,n){var a={initializeGrid:function(n,i){if(a.defaultGridOptions(n.options),n.options.enableInfiniteScroll){n.infiniteScroll={dataLoading:!1},a.setScrollDirections(n,n.options.infiniteScrollUp,n.options.infiniteScrollDown),n.api.core.on.scrollEnd(i,a.handleScroll);var o={events:{infiniteScroll:{needLoadMoreData:function(i,o){},needLoadMoreDataTop:function(i,o){}}},methods:{infiniteScroll:{dataLoaded:function(i,o){return a.setScrollDirections(n,i,o),a.adjustScroll(n).then(function(){n.infiniteScroll.dataLoading=!1})},resetScroll:function(i,o){a.setScrollDirections(n,i,o),a.adjustInfiniteScrollPosition(n,0)},saveScrollPercentage:function(){n.infiniteScroll.prevScrollTop=n.renderContainers.body.prevScrollTop,n.infiniteScroll.previousVisibleRows=n.getVisibleRowCount()},dataRemovedTop:function(i,o){a.dataRemovedTop(n,i,o)},dataRemovedBottom:function(i,o){a.dataRemovedBottom(n,i,o)},setScrollDirections:function(i,o){a.setScrollDirections(n,i,o)}}}};n.api.registerEventsFromObject(o.events),n.api.registerMethodsFromObject(o.methods)}},defaultGridOptions:function(i){i.enableInfiniteScroll=!1!==i.enableInfiniteScroll,i.infiniteScrollRowsFromEnd=i.infiniteScrollRowsFromEnd||20,i.infiniteScrollUp=!0===i.infiniteScrollUp,i.infiniteScrollDown=!1!==i.infiniteScrollDown},setScrollDirections:function(i,o,n){i.infiniteScroll.scrollUp=!0===o,i.suppressParentScrollUp=!0===o,i.infiniteScroll.scrollDown=!1!==n,i.suppressParentScrollDown=!1!==n},handleScroll:function(i){if(!(i.grid.infiniteScroll&&i.grid.infiniteScroll.dataLoading||"ui.grid.adjustInfiniteScrollPosition"===i.source)&&i.y)if(0===i.y.percentage)i.grid.scrollDirection=s.scrollDirection.UP,a.loadData(i.grid);else if(1===i.y.percentage)i.grid.scrollDirection=s.scrollDirection.DOWN,a.loadData(i.grid);else{var o=i.grid.options.infiniteScrollRowsFromEnd/i.grid.renderContainers.body.visibleRowCache.length;i.grid.scrollDirection===s.scrollDirection.UP?i.y.percentage<=o&&a.loadData(i.grid):i.grid.scrollDirection===s.scrollDirection.DOWN&&1-i.y.percentage<=o&&a.loadData(i.grid)}},loadData:function(i){i.infiniteScroll.previousVisibleRows=i.renderContainers.body.visibleRowCache.length,i.infiniteScroll.direction=i.scrollDirection,delete i.infiniteScroll.prevScrollTop,i.scrollDirection===s.scrollDirection.UP&&i.infiniteScroll.scrollUp?(i.infiniteScroll.dataLoading=!0,i.api.infiniteScroll.raise.needLoadMoreDataTop()):i.scrollDirection===s.scrollDirection.DOWN&&i.infiniteScroll.scrollDown&&(i.infiniteScroll.dataLoading=!0,i.api.infiniteScroll.raise.needLoadMoreData())},adjustScroll:function(l){var t=n.defer();return c.$applyAsync(function(){var i,o,n,e;i=l.getViewportHeight()+l.headerHeight-l.renderContainers.body.headerHeight-l.scrollbarHeight,o=l.options.rowHeight,void 0===l.infiniteScroll.direction&&a.adjustInfiniteScrollPosition(l,0);var r=o*(n=l.getVisibleRowCount());l.infiniteScroll.scrollDown&&r/, + FUNC_REGEXP: /(\([^)]*\))?$/, + DOT_REGEXP: /\./g, + APOS_REGEXP: /'/g, + BRACKET_REGEXP: /^(.*)((?:\s*\[\s*\d+\s*\]\s*)|(?:\s*\[\s*"(?:[^"\\]|\\.)*"\s*\]\s*)|(?:\s*\[\s*'(?:[^'\\]|\\.)*'\s*\]\s*))(.*)$/, + COL_CLASS_PREFIX: 'ui-grid-col', + ENTITY_BINDING: '$$this', + events: { + GRID_SCROLL: 'uiGridScroll', + COLUMN_MENU_SHOWN: 'uiGridColMenuShown', + ITEM_DRAGGING: 'uiGridItemDragStart', // For any item being dragged + COLUMN_HEADER_CLICK: 'uiGridColumnHeaderClick' + }, + // copied from http://www.lsauer.com/2011/08/javascript-keymap-keycodes-in-json.html + keymap: { + TAB: 9, + STRG: 17, + CAPSLOCK: 20, + CTRL: 17, + CTRLRIGHT: 18, + CTRLR: 18, + SHIFT: 16, + RETURN: 13, + ENTER: 13, + BACKSPACE: 8, + BCKSP: 8, + ALT: 18, + ALTR: 17, + ALTRIGHT: 17, + SPACE: 32, + WIN: 91, + MAC: 91, + FN: null, + PG_UP: 33, + PG_DOWN: 34, + UP: 38, + DOWN: 40, + LEFT: 37, + RIGHT: 39, + ESC: 27, + DEL: 46, + F1: 112, + F2: 113, + F3: 114, + F4: 115, + F5: 116, + F6: 117, + F7: 118, + F8: 119, + F9: 120, + F10: 121, + F11: 122, + F12: 123 + }, + /** + * @ngdoc object + * @name ASC + * @propertyOf ui.grid.service:uiGridConstants + * @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_sort columnDef.sort} and + * {@link ui.grid.class:GridOptions.columnDef#properties_sortDirectionCycle columnDef.sortDirectionCycle} + * to configure the sorting direction of the column + */ + ASC: 'asc', + /** + * @ngdoc object + * @name DESC + * @propertyOf ui.grid.service:uiGridConstants + * @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_sort columnDef.sort} and + * {@link ui.grid.class:GridOptions.columnDef#properties_sortDirectionCycle columnDef.sortDirectionCycle} + * to configure the sorting direction of the column + */ + DESC: 'desc', + + + /** + * @ngdoc object + * @name filter + * @propertyOf ui.grid.service:uiGridConstants + * @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_filter columnDef.filter} + * to configure filtering on the column + * + * `SELECT` and `INPUT` are used with the `type` property of the filter, the rest are used to specify + * one of the built-in conditions. + * + * Available `condition` options are: + * - `uiGridConstants.filter.STARTS_WITH` + * - `uiGridConstants.filter.ENDS_WITH` + * - `uiGridConstants.filter.CONTAINS` + * - `uiGridConstants.filter.GREATER_THAN` + * - `uiGridConstants.filter.GREATER_THAN_OR_EQUAL` + * - `uiGridConstants.filter.LESS_THAN` + * - `uiGridConstants.filter.LESS_THAN_OR_EQUAL` + * - `uiGridConstants.filter.NOT_EQUAL` + * + * + * Available `type` options are: + * - `uiGridConstants.filter.SELECT` - use a dropdown box for the cell header filter field + * - `uiGridConstants.filter.INPUT` - use a text box for the cell header filter field + */ + filter: { + STARTS_WITH: 2, + ENDS_WITH: 4, + EXACT: 8, + CONTAINS: 16, + GREATER_THAN: 32, + GREATER_THAN_OR_EQUAL: 64, + LESS_THAN: 128, + LESS_THAN_OR_EQUAL: 256, + NOT_EQUAL: 512, + SELECT: 'select', + INPUT: 'input' + }, + + /** + * @ngdoc object + * @name aggregationTypes + * @propertyOf ui.grid.service:uiGridConstants + * @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_aggregationType columnDef.aggregationType} + * to specify the type of built-in aggregation the column should use. + * + * Available options are: + * - `uiGridConstants.aggregationTypes.sum` - add the values in this column to produce the aggregated value + * - `uiGridConstants.aggregationTypes.count` - count the number of rows to produce the aggregated value + * - `uiGridConstants.aggregationTypes.avg` - average the values in this column to produce the aggregated value + * - `uiGridConstants.aggregationTypes.min` - use the minimum value in this column as the aggregated value + * - `uiGridConstants.aggregationTypes.max` - use the maximum value in this column as the aggregated value + */ + aggregationTypes: { + sum: 2, + count: 4, + avg: 8, + min: 16, + max: 32 + }, + + /** + * @ngdoc array + * @name CURRENCY_SYMBOLS + * @propertyOf ui.grid.service:uiGridConstants + * @description A list of all presently circulating currency symbols that was copied from + * https://en.wikipedia.org/wiki/Currency_symbol#List_of_presently-circulating_currency_symbols + * + * Can be used on {@link ui.grid.class:rowSorter} to create a number string regex that ignores currency symbols. + */ + CURRENCY_SYMBOLS: ['¤', '؋', 'Ar', 'Ƀ', '฿', 'B/.', 'Br', 'Bs.', 'Bs.F.', 'GH₵', '¢', 'c', 'Ch.', '₡', 'C$', 'D', 'ден', + 'دج', '.د.ب', 'د.ع', 'JD', 'د.ك', 'ل.د', 'дин', 'د.ت', 'د.م.', 'د.إ', 'Db', '$', '₫', 'Esc', '€', 'ƒ', 'Ft', 'FBu', + 'FCFA', 'CFA', 'Fr', 'FRw', 'G', 'gr', '₲', 'h', '₴', '₭', 'Kč', 'kr', 'kn', 'MK', 'ZK', 'Kz', 'K', 'L', 'Le', 'лв', + 'E', 'lp', 'M', 'KM', 'MT', '₥', 'Nfk', '₦', 'Nu.', 'UM', 'T$', 'MOP$', '₱', 'Pt.', '£', 'ج.م.', 'LL', 'LS', 'P', 'Q', + 'q', 'R', 'R$', 'ر.ع.', 'ر.ق', 'ر.س', '៛', 'RM', 'p', 'Rf.', '₹', '₨', 'SRe', 'Rp', '₪', 'Ksh', 'Sh.So.', 'USh', 'S/', + 'SDR', 'сом', '৳ ', 'WS$', '₮', 'VT', '₩', '¥', 'zł'], + + /** + * @ngdoc object + * @name scrollDirection + * @propertyOf ui.grid.service:uiGridConstants + * @description Set on {@link ui.grid.class:Grid#properties_scrollDirection Grid.scrollDirection}, + * to indicate the direction the grid is currently scrolling in + * + * Available options are: + * - `uiGridConstants.scrollDirection.UP` - set when the grid is scrolling up + * - `uiGridConstants.scrollDirection.DOWN` - set when the grid is scrolling down + * - `uiGridConstants.scrollDirection.LEFT` - set when the grid is scrolling left + * - `uiGridConstants.scrollDirection.RIGHT` - set when the grid is scrolling right + * - `uiGridConstants.scrollDirection.NONE` - set when the grid is not scrolling, this is the default + */ + scrollDirection: { + UP: 'up', + DOWN: 'down', + LEFT: 'left', + RIGHT: 'right', + NONE: 'none' + + }, + + /** + * @ngdoc object + * @name dataChange + * @propertyOf ui.grid.service:uiGridConstants + * @description Used with {@link ui.grid.core.api:PublicApi#methods_notifyDataChange PublicApi.notifyDataChange}, + * {@link ui.grid.class:Grid#methods_callDataChangeCallbacks Grid.callDataChangeCallbacks}, + * and {@link ui.grid.class:Grid#methods_registerDataChangeCallback Grid.registerDataChangeCallback} + * to specify the type of the event(s). + * + * Available options are: + * - `uiGridConstants.dataChange.ALL` - listeners fired on any of these events, fires listeners on all events. + * - `uiGridConstants.dataChange.EDIT` - fired when the data in a cell is edited + * - `uiGridConstants.dataChange.ROW` - fired when a row is added or removed + * - `uiGridConstants.dataChange.COLUMN` - fired when the column definitions are modified + * - `uiGridConstants.dataChange.OPTIONS` - fired when the grid options are modified + */ + dataChange: { + ALL: 'all', + EDIT: 'edit', + ROW: 'row', + COLUMN: 'column', + OPTIONS: 'options' + }, + + /** + * @ngdoc object + * @name scrollbars + * @propertyOf ui.grid.service:uiGridConstants + * @description Used with {@link ui.grid.class:GridOptions#properties_enableHorizontalScrollbar GridOptions.enableHorizontalScrollbar} + * and {@link ui.grid.class:GridOptions#properties_enableVerticalScrollbar GridOptions.enableVerticalScrollbar} + * to specify the scrollbar policy for that direction. + * + * Available options are: + * - `uiGridConstants.scrollbars.NEVER` - never show scrollbars in this direction + * - `uiGridConstants.scrollbars.ALWAYS` - always show scrollbars in this direction + * - `uiGridConstants.scrollbars.WHEN_NEEDED` - shows scrollbars in this direction when needed + */ + + scrollbars: { + NEVER: 0, + ALWAYS: 1, + WHEN_NEEDED: 2 + } + }); + +})(); + +angular.module('ui.grid').directive('uiGridCell', ['$compile', '$parse', 'gridUtil', 'uiGridConstants', function ($compile, $parse, gridUtil, uiGridConstants) { + var uiGridCell = { + priority: 0, + scope: false, + require: '?^uiGrid', + compile: function() { + return { + pre: function($scope, $elm, $attrs, uiGridCtrl) { + function compileTemplate() { + var compiledElementFn = $scope.col.compiledElementFn; + + compiledElementFn($scope, function(clonedElement, scope) { + $elm.append(clonedElement); + }); + } + + // If the grid controller is present, use it to get the compiled cell template function + if (uiGridCtrl && $scope.col.compiledElementFn) { + compileTemplate(); + } + // No controller, compile the element manually (for unit tests) + else { + if ( uiGridCtrl && !$scope.col.compiledElementFn ){ + // gridUtil.logError('Render has been called before precompile. Please log a ui-grid issue'); + + $scope.col.getCompiledElementFn() + .then(function (compiledElementFn) { + compiledElementFn($scope, function(clonedElement, scope) { + $elm.append(clonedElement); + }); + }).catch(angular.noop); + } + else { + var html = $scope.col.cellTemplate + .replace(uiGridConstants.MODEL_COL_FIELD, 'row.entity.' + gridUtil.preEval($scope.col.field)) + .replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)'); + + var cellElement = $compile(html)($scope); + $elm.append(cellElement); + } + } + }, + post: function($scope, $elm, $attrs, uiGridCtrl) { + var initColClass = $scope.col.getColClass(false); + $elm.addClass(initColClass); + + var classAdded; + var updateClass = function( grid ){ + var contents = $elm; + if ( classAdded ){ + contents.removeClass( classAdded ); + classAdded = null; + } + + if (angular.isFunction($scope.col.cellClass)) { + classAdded = $scope.col.cellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex); + } + else { + classAdded = $scope.col.cellClass; + } + contents.addClass(classAdded); + }; + + if ($scope.col.cellClass) { + updateClass(); + } + + // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs + var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateClass, [uiGridConstants.dataChange.COLUMN, uiGridConstants.dataChange.EDIT]); + + // watch the col and row to see if they change - which would indicate that we've scrolled or sorted or otherwise + // changed the row/col that this cell relates to, and we need to re-evaluate cell classes and maybe other things + var cellChangeFunction = function( n, o ){ + if ( n !== o ) { + if ( classAdded || $scope.col.cellClass ){ + updateClass(); + } + + // See if the column's internal class has changed + var newColClass = $scope.col.getColClass(false); + if (newColClass !== initColClass) { + $elm.removeClass(initColClass); + $elm.addClass(newColClass); + initColClass = newColClass; + } + } + }; + + // TODO(c0bra): Turn this into a deep array watch +/* shouldn't be needed any more given track by col.name + var colWatchDereg = $scope.$watch( 'col', cellChangeFunction ); +*/ + var rowWatchDereg = $scope.$watch( 'row', cellChangeFunction ); + + + var deregisterFunction = function() { + dataChangeDereg(); +// colWatchDereg(); + rowWatchDereg(); + }; + + $scope.$on( '$destroy', deregisterFunction ); + $elm.on( '$destroy', deregisterFunction ); + } + }; + } + }; + + return uiGridCell; +}]); + + +(function(){ + +angular.module('ui.grid') +.service('uiGridColumnMenuService', [ 'i18nService', 'uiGridConstants', 'gridUtil', +function ( i18nService, uiGridConstants, gridUtil ) { +/** + * @ngdoc service + * @name ui.grid.service:uiGridColumnMenuService + * + * @description Services for working with column menus, factored out + * to make the code easier to understand + */ + + var service = { + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name initialize + * @description Sets defaults, puts a reference to the $scope on + * the uiGridController + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * @param {controller} uiGridCtrl the uiGridController for the grid + * we're on + * + */ + initialize: function( $scope, uiGridCtrl ){ + $scope.grid = uiGridCtrl.grid; + + // Store a reference to this link/controller in the main uiGrid controller + // to allow showMenu later + uiGridCtrl.columnMenuScope = $scope; + + // Save whether we're shown or not so the columns can check + $scope.menuShown = false; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name setColMenuItemWatch + * @description Setup a watch on $scope.col.menuItems, and update + * menuItems based on this. $scope.col needs to be set by the column + * before calling the menu. + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * @param {controller} uiGridCtrl the uiGridController for the grid + * we're on + * + */ + setColMenuItemWatch: function ( $scope ){ + var deregFunction = $scope.$watch('col.menuItems', function (n) { + if (typeof(n) !== 'undefined' && n && angular.isArray(n)) { + n.forEach(function (item) { + if (typeof(item.context) === 'undefined' || !item.context) { + item.context = {}; + } + item.context.col = $scope.col; + }); + + $scope.menuItems = $scope.defaultMenuItems.concat(n); + } + else { + $scope.menuItems = $scope.defaultMenuItems; + } + }); + + $scope.$on( '$destroy', deregFunction ); + }, + + + /** + * @ngdoc boolean + * @name enableSorting + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) True by default. When enabled, this setting adds sort + * widgets to the column header, allowing sorting of the data in the individual column. + */ + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name sortable + * @description determines whether this column is sortable + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * + */ + sortable: function( $scope ) { + if ( $scope.grid.options.enableSorting && typeof($scope.col) !== 'undefined' && $scope.col && $scope.col.enableSorting) { + return true; + } + else { + return false; + } + }, + + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name isActiveSort + * @description determines whether the requested sort direction is current active, to + * allow highlighting in the menu + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * @param {string} direction the direction that we'd have selected for us to be active + * + */ + isActiveSort: function( $scope, direction ){ + return (typeof($scope.col) !== 'undefined' && typeof($scope.col.sort) !== 'undefined' && + typeof($scope.col.sort.direction) !== 'undefined' && $scope.col.sort.direction === direction); + + }, + + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name suppressRemoveSort + * @description determines whether we should suppress the removeSort option + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * + */ + suppressRemoveSort: function( $scope ) { + if ($scope.col && $scope.col.suppressRemoveSort) { + return true; + } + else { + return false; + } + }, + + + /** + * @ngdoc boolean + * @name enableHiding + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description (optional) True by default. When set to false, this setting prevents a user from hiding the column + * using the column menu or the grid menu. + */ + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name hideable + * @description determines whether a column can be hidden, by checking the enableHiding columnDef option + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * + */ + hideable: function( $scope ) { + if (typeof($scope.col) !== 'undefined' && $scope.col && $scope.col.colDef && $scope.col.colDef.enableHiding === false ) { + return false; + } + else { + return true; + } + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name getDefaultMenuItems + * @description returns the default menu items for a column menu + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * + */ + getDefaultMenuItems: function( $scope ){ + return [ + { + title: function(){return i18nService.getSafeText('sort.ascending');}, + icon: 'ui-grid-icon-sort-alt-up', + action: function($event) { + $event.stopPropagation(); + $scope.sortColumn($event, uiGridConstants.ASC); + }, + shown: function () { + return service.sortable( $scope ); + }, + active: function() { + return service.isActiveSort( $scope, uiGridConstants.ASC); + } + }, + { + title: function(){return i18nService.getSafeText('sort.descending');}, + icon: 'ui-grid-icon-sort-alt-down', + action: function($event) { + $event.stopPropagation(); + $scope.sortColumn($event, uiGridConstants.DESC); + }, + shown: function() { + return service.sortable( $scope ); + }, + active: function() { + return service.isActiveSort( $scope, uiGridConstants.DESC); + } + }, + { + title: function(){return i18nService.getSafeText('sort.remove');}, + icon: 'ui-grid-icon-cancel', + action: function ($event) { + $event.stopPropagation(); + $scope.unsortColumn(); + }, + shown: function() { + return service.sortable( $scope ) && + typeof($scope.col) !== 'undefined' && (typeof($scope.col.sort) !== 'undefined' && + typeof($scope.col.sort.direction) !== 'undefined') && $scope.col.sort.direction !== null && + !service.suppressRemoveSort( $scope ); + } + }, + { + title: function(){return i18nService.getSafeText('column.hide');}, + icon: 'ui-grid-icon-cancel', + shown: function() { + return service.hideable( $scope ); + }, + action: function ($event) { + $event.stopPropagation(); + $scope.hideColumn(); + } + } + ]; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name getColumnElementPosition + * @description gets the position information needed to place the column + * menu below the column header + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * @param {GridCol} column the column we want to position below + * @param {element} $columnElement the column element we want to position below + * @returns {hash} containing left, top, offset, height, width + * + */ + getColumnElementPosition: function( $scope, column, $columnElement ){ + var positionData = {}; + positionData.left = $columnElement[0].offsetLeft; + positionData.top = $columnElement[0].offsetTop; + positionData.parentLeft = $columnElement[0].offsetParent.offsetLeft; + + // Get the grid scrollLeft + positionData.offset = 0; + if (column.grid.options.offsetLeft) { + positionData.offset = column.grid.options.offsetLeft; + } + + positionData.height = gridUtil.elementHeight($columnElement, true); + positionData.width = gridUtil.elementWidth($columnElement, true); + + return positionData; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.service:uiGridColumnMenuService + * @name repositionMenu + * @description Reposition the menu below the new column. If the menu has no child nodes + * (i.e. it's not currently visible) then we guess it's width at 100, we'll be called again + * later to fix it + * @param {$scope} $scope the $scope from the uiGridColumnMenu + * @param {GridCol} column the column we want to position below + * @param {hash} positionData a hash containing left, top, offset, height, width + * @param {element} $elm the column menu element that we want to reposition + * @param {element} $columnElement the column element that we want to reposition underneath + * + */ + repositionMenu: function( $scope, column, positionData, $elm, $columnElement ) { + var menu = $elm[0].querySelectorAll('.ui-grid-menu'); + + // It's possible that the render container of the column we're attaching to is + // offset from the grid (i.e. pinned containers), we need to get the difference in the offsetLeft + // between the render container and the grid + var renderContainerElm = gridUtil.closestElm($columnElement, '.ui-grid-render-container'); + var renderContainerOffset = renderContainerElm.getBoundingClientRect().left - $scope.grid.element[0].getBoundingClientRect().left; + + var containerScrollLeft = renderContainerElm.querySelectorAll('.ui-grid-viewport')[0].scrollLeft; + + // repositionMenu is now always called after it's visible in the DOM, + // allowing us to simply get the width every time the menu is opened + var myWidth = gridUtil.elementWidth(menu, true); + var paddingRight = column.lastMenuPaddingRight ? column.lastMenuPaddingRight : ( $scope.lastMenuPaddingRight ? $scope.lastMenuPaddingRight : 10); + + if ( menu.length !== 0 ){ + var mid = menu[0].querySelectorAll('.ui-grid-menu-mid'); + if ( mid.length !== 0 ) { + // TODO(c0bra): use padding-left/padding-right based on document direction (ltr/rtl), place menu on proper side + // Get the column menu right padding + paddingRight = parseInt(gridUtil.getStyles(angular.element(menu)[0])['paddingRight'], 10); + $scope.lastMenuPaddingRight = paddingRight; + column.lastMenuPaddingRight = paddingRight; + } + } + + var left = positionData.left + renderContainerOffset - containerScrollLeft + positionData.parentLeft + positionData.width + paddingRight; + + if (left < positionData.offset + myWidth) { + left = Math.max(positionData.left - containerScrollLeft + positionData.parentLeft - paddingRight + myWidth, positionData.offset + myWidth); + } + + $elm.css('left', left + 'px'); + $elm.css('top', (positionData.top + positionData.height) + 'px'); + } + + }; + + return service; +}]) + + +.directive('uiGridColumnMenu', ['$timeout', 'gridUtil', 'uiGridConstants', 'uiGridColumnMenuService', '$document', +function ($timeout, gridUtil, uiGridConstants, uiGridColumnMenuService, $document) { +/** + * @ngdoc directive + * @name ui.grid.directive:uiGridColumnMenu + * @description Provides the column menu framework, leverages uiGridMenu underneath + * + */ + + var uiGridColumnMenu = { + priority: 0, + scope: true, + require: '^uiGrid', + templateUrl: 'ui-grid/uiGridColumnMenu', + replace: true, + link: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridColumnMenuService.initialize( $scope, uiGridCtrl ); + + $scope.defaultMenuItems = uiGridColumnMenuService.getDefaultMenuItems( $scope ); + + // Set the menu items for use with the column menu. The user can later add additional items via the watch + $scope.menuItems = $scope.defaultMenuItems; + uiGridColumnMenuService.setColMenuItemWatch( $scope ); + + + /** + * @ngdoc method + * @methodOf ui.grid.directive:uiGridColumnMenu + * @name showMenu + * @description Shows the column menu. If the menu is already displayed it + * calls the menu to ask it to hide (it will animate), then it repositions the menu + * to the right place whilst hidden (it will make an assumption on menu width), + * then it asks the menu to show (it will animate), then it repositions the menu again + * once we can calculate it's size. + * @param {GridCol} column the column we want to position below + * @param {element} $columnElement the column element we want to position below + */ + $scope.showMenu = function(column, $columnElement, event) { + // Swap to this column + $scope.col = column; + + // Get the position information for the column element + var colElementPosition = uiGridColumnMenuService.getColumnElementPosition( $scope, column, $columnElement ); + + if ($scope.menuShown) { + // we want to hide, then reposition, then show, but we want to wait for animations + // we set a variable, and then rely on the menu-hidden event to call the reposition and show + $scope.colElement = $columnElement; + $scope.colElementPosition = colElementPosition; + $scope.hideThenShow = true; + + $scope.$broadcast('hide-menu', { originalEvent: event }); + } else { + $scope.menuShown = true; + + $scope.colElement = $columnElement; + $scope.colElementPosition = colElementPosition; + $scope.$broadcast('show-menu', { originalEvent: event }); + + } + }; + + + /** + * @ngdoc method + * @methodOf ui.grid.directive:uiGridColumnMenu + * @name hideMenu + * @description Hides the column menu. + * @param {boolean} broadcastTrigger true if we were triggered by a broadcast + * from the menu itself - in which case don't broadcast again as we'll get + * an infinite loop + */ + $scope.hideMenu = function( broadcastTrigger ) { + $scope.menuShown = false; + if ( !broadcastTrigger ){ + $scope.$broadcast('hide-menu'); + } + }; + + + $scope.$on('menu-hidden', function() { + var menuItems = angular.element($elm[0].querySelector('.ui-grid-menu-items'))[0]; + + $elm[0].removeAttribute('style'); + + if ( $scope.hideThenShow ){ + delete $scope.hideThenShow; + + $scope.$broadcast('show-menu'); + + $scope.menuShown = true; + } else { + $scope.hideMenu( true ); + + if ($scope.col) { + //Focus on the menu button + gridUtil.focus.bySelector($document, '.ui-grid-header-cell.' + $scope.col.getColClass()+ ' .ui-grid-column-menu-button', $scope.col.grid, false); + } + } + + if (menuItems) { + menuItems.onkeydown = null; + angular.forEach(menuItems.children, function removeHandlers(item) { + item.onkeydown = null; + }); + } + }); + + $scope.$on('menu-shown', function() { + $timeout( function() { + uiGridColumnMenuService.repositionMenu( $scope, $scope.col, $scope.colElementPosition, $elm, $scope.colElement ); + + //automatically set the focus to the first button element in the now open menu. + gridUtil.focus.bySelector($document, '.ui-grid-menu-items .ui-grid-menu-item:not(.ng-hide)', true); + delete $scope.colElementPosition; + delete $scope.columnElement; + addKeydownHandlersToMenu(); + }); + }); + + + /* Column methods */ + $scope.sortColumn = function (event, dir) { + event.stopPropagation(); + + $scope.grid.sortColumn($scope.col, dir, true) + .then(function () { + $scope.grid.refresh(); + $scope.hideMenu(); + }).catch(angular.noop); + }; + + $scope.unsortColumn = function () { + $scope.col.unsort(); + + $scope.grid.refresh(); + $scope.hideMenu(); + }; + + function addKeydownHandlersToMenu() { + var menu = angular.element($elm[0].querySelector('.ui-grid-menu-items'))[0], + menuItems, + visibleMenuItems = []; + + if (menu) { + menu.onkeydown = function closeMenu(event) { + if (event.keyCode === uiGridConstants.keymap.ESC) { + event.preventDefault(); + $scope.hideMenu(); + } + }; + + menuItems = menu.querySelectorAll('.ui-grid-menu-item:not(.ng-hide)'); + angular.forEach(menuItems, function filterVisibleItems(item) { + if (item.offsetParent !== null) { + this.push(item); + } + }, visibleMenuItems); + + if (visibleMenuItems.length) { + if (visibleMenuItems.length === 1) { + visibleMenuItems[0].onkeydown = function singleItemHandler(event) { + circularFocusHandler(event, true); + }; + } else { + visibleMenuItems[0].onkeydown = function firstItemHandler(event) { + circularFocusHandler(event, false, event.shiftKey, visibleMenuItems.length - 1); + }; + visibleMenuItems[visibleMenuItems.length - 1].onkeydown = function lastItemHandler(event) { + circularFocusHandler(event, false, !event.shiftKey, 0); + }; + } + } + } + + function circularFocusHandler(event, isSingleItem, shiftKeyStatus, index) { + if (event.keyCode === uiGridConstants.keymap.TAB) { + if (isSingleItem) { + event.preventDefault(); + } else if (shiftKeyStatus) { + event.preventDefault(); + visibleMenuItems[index].focus(); + } + } + } + } + + // Since we are hiding this column the default hide action will fail so we need to focus somewhere else. + var setFocusOnHideColumn = function(){ + $timeout(function() { + // Get the UID of the first + var focusToGridMenu = function(){ + return gridUtil.focus.byId('grid-menu', $scope.grid); + }; + + var thisIndex; + $scope.grid.columns.some(function(element, index){ + if (angular.equals(element, $scope.col)) { + thisIndex = index; + return true; + } + }); + + var previousVisibleCol; + // Try and find the next lower or nearest column to focus on + $scope.grid.columns.some(function(element, index){ + if (!element.visible){ + return false; + } // This columns index is below the current column index + else if ( index < thisIndex){ + previousVisibleCol = element; + } // This elements index is above this column index and we haven't found one that is lower + else if ( index > thisIndex && !previousVisibleCol) { + // This is the next best thing + previousVisibleCol = element; + // We've found one so use it. + return true; + } // We've reached an element with an index above this column and the previousVisibleCol variable has been set + else if (index > thisIndex && previousVisibleCol) { + // We are done. + return true; + } + }); + // If found then focus on it + if (previousVisibleCol){ + var colClass = previousVisibleCol.getColClass(); + gridUtil.focus.bySelector($document, '.ui-grid-header-cell.' + colClass+ ' .ui-grid-header-cell-primary-focus', true).then(angular.noop, function(reason){ + if (reason !== 'canceled'){ // If this is canceled then don't perform the action + //The fallback action is to focus on the grid menu + return focusToGridMenu(); + } + }).catch(angular.noop); + } else { + // Fallback action to focus on the grid menu + focusToGridMenu(); + } + }); + }; + + $scope.hideColumn = function () { + $scope.col.colDef.visible = false; + $scope.col.visible = false; + + $scope.grid.queueGridRefresh(); + $scope.hideMenu(); + $scope.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN ); + $scope.grid.api.core.raise.columnVisibilityChanged( $scope.col ); + + // We are hiding so the default action of focusing on the button that opened this menu will fail. + setFocusOnHideColumn(); + }; + }, + + + + controller: ['$scope', function ($scope) { + var self = this; + + $scope.$watch('menuItems', function (n) { + self.menuItems = n; + }); + }] + }; + + return uiGridColumnMenu; + +}]); + +})(); + +(function(){ + 'use strict'; + + angular.module('ui.grid').directive('uiGridFilter', ['$compile', '$templateCache', 'i18nService', 'gridUtil', function ($compile, $templateCache, i18nService, gridUtil) { + + return { + compile: function() { + return { + pre: function ($scope, $elm, $attrs, controllers) { + $scope.col.updateFilters = function( filterable ){ + $elm.children().remove(); + if ( filterable ) { + var template = $scope.col.filterHeaderTemplate; + if (template === undefined && $scope.col.providedFilterHeaderTemplate !== '') { + if ($scope.col.filterHeaderTemplatePromise) { + $scope.col.filterHeaderTemplatePromise.then(function () { + template = $scope.col.filterHeaderTemplate; + $elm.append($compile(template)($scope)); + }); + } + } + else { + $elm.append($compile(template)($scope)); + } + } + }; + + $scope.$on( '$destroy', function() { + delete $scope.col.updateFilters; + }); + }, + post: function ($scope, $elm, $attrs, controllers){ + $scope.aria = i18nService.getSafeText('headerCell.aria'); + $scope.removeFilter = function(colFilter, index){ + colFilter.term = null; + //Set the focus to the filter input after the action disables the button + gridUtil.focus.bySelector($elm, '.ui-grid-filter-input-' + index); + }; + } + }; + } + }; + }]); +})(); + +(function () { + 'use strict'; + + angular.module('ui.grid').directive('uiGridFooterCell', ['$timeout', 'gridUtil', 'uiGridConstants', '$compile', + function ($timeout, gridUtil, uiGridConstants, $compile) { + var uiGridFooterCell = { + priority: 0, + scope: { + col: '=', + row: '=', + renderIndex: '=' + }, + replace: true, + require: '^uiGrid', + compile: function compile(tElement, tAttrs, transclude) { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + var template = $scope.col.footerCellTemplate; + if (template === undefined && $scope.col.providedFooterCellTemplate !== '') { + if ($scope.col.footerCellTemplatePromise) { + $scope.col.footerCellTemplatePromise.then(function () { + template = $scope.col.footerCellTemplate; + $elm.append($compile(template)($scope)); + }); + } + } + else { + $elm.append($compile(template)($scope)); + } + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + //$elm.addClass($scope.col.getColClass(false)); + $scope.grid = uiGridCtrl.grid; + + var initColClass = $scope.col.getColClass(false); + $elm.addClass(initColClass); + + // apply any footerCellClass + var classAdded; + var updateClass = function( grid ){ + var contents = $elm; + if ( classAdded ){ + contents.removeClass( classAdded ); + classAdded = null; + } + + if (angular.isFunction($scope.col.footerCellClass)) { + classAdded = $scope.col.footerCellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex); + } + else { + classAdded = $scope.col.footerCellClass; + } + contents.addClass(classAdded); + }; + + if ($scope.col.footerCellClass) { + updateClass(); + } + + $scope.col.updateAggregationValue(); + + // Watch for column changes so we can alter the col cell class properly +/* shouldn't be needed any more, given track by col.name + $scope.$watch('col', function (n, o) { + if (n !== o) { + // See if the column's internal class has changed + var newColClass = $scope.col.getColClass(false); + if (newColClass !== initColClass) { + $elm.removeClass(initColClass); + $elm.addClass(newColClass); + initColClass = newColClass; + } + } + }); +*/ + + + // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs + var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateClass, [uiGridConstants.dataChange.COLUMN]); + // listen for visible rows change and update aggregation values + $scope.grid.api.core.on.rowsRendered( $scope, $scope.col.updateAggregationValue ); + $scope.grid.api.core.on.rowsRendered( $scope, updateClass ); + $scope.$on( '$destroy', dataChangeDereg ); + } + }; + } + }; + + return uiGridFooterCell; + }]); + +})(); + +(function () { + 'use strict'; + + angular.module('ui.grid').directive('uiGridFooter', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', function ($templateCache, $compile, uiGridConstants, gridUtil, $timeout) { + + return { + restrict: 'EA', + replace: true, + // priority: 1000, + require: ['^uiGrid', '^uiGridRenderContainer'], + scope: true, + compile: function ($elm, $attrs) { + return { + pre: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + + $scope.grid = uiGridCtrl.grid; + $scope.colContainer = containerCtrl.colContainer; + + containerCtrl.footer = $elm; + + var footerTemplate = $scope.grid.options.footerTemplate; + gridUtil.getTemplate(footerTemplate) + .then(function (contents) { + var template = angular.element(contents); + + var newElm = $compile(template)($scope); + $elm.append(newElm); + + if (containerCtrl) { + // Inject a reference to the footer viewport (if it exists) into the grid controller for use in the horizontal scroll handler below + var footerViewport = $elm[0].getElementsByClassName('ui-grid-footer-viewport')[0]; + + if (footerViewport) { + containerCtrl.footerViewport = footerViewport; + } + } + }).catch(angular.noop); + }, + + post: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + + // gridUtil.logDebug('ui-grid-footer link'); + + var grid = uiGridCtrl.grid; + + // Don't animate footer cells + gridUtil.disableAnimations($elm); + + containerCtrl.footer = $elm; + + var footerViewport = $elm[0].getElementsByClassName('ui-grid-footer-viewport')[0]; + if (footerViewport) { + containerCtrl.footerViewport = footerViewport; + } + } + }; + } + }; + }]); + +})(); + +(function () { + 'use strict'; + + angular.module('ui.grid').directive('uiGridGridFooter', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', function ($templateCache, $compile, uiGridConstants, gridUtil, $timeout) { + + return { + restrict: 'EA', + replace: true, + // priority: 1000, + require: '^uiGrid', + scope: true, + compile: function ($elm, $attrs) { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + + $scope.grid = uiGridCtrl.grid; + + + + var footerTemplate = $scope.grid.options.gridFooterTemplate; + gridUtil.getTemplate(footerTemplate) + .then(function (contents) { + var template = angular.element(contents); + + var newElm = $compile(template)($scope); + $elm.append(newElm); + }).catch(angular.noop); + }, + + post: function ($scope, $elm, $attrs, controllers) { + + } + }; + } + }; + }]); + +})(); + +(function(){ + 'use strict'; + + angular.module('ui.grid').directive('uiGridHeaderCell', ['$compile', '$timeout', '$window', '$document', 'gridUtil', 'uiGridConstants', 'ScrollEvent', 'i18nService', + function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, ScrollEvent, i18nService) { + // Do stuff after mouse has been down this many ms on the header cell + var mousedownTimeout = 500; + var changeModeTimeout = 500; // length of time between a touch event and a mouse event being recognised again, and vice versa + + var uiGridHeaderCell = { + priority: 0, + scope: { + col: '=', + row: '=', + renderIndex: '=' + }, + require: ['^uiGrid', '^uiGridRenderContainer'], + replace: true, + compile: function() { + return { + pre: function ($scope, $elm, $attrs) { + var template = $scope.col.headerCellTemplate; + if (template === undefined && $scope.col.providedHeaderCellTemplate !== '') { + if ($scope.col.headerCellTemplatePromise) { + $scope.col.headerCellTemplatePromise.then(function () { + template = $scope.col.headerCellTemplate; + $elm.append($compile(template)($scope)); + }); + } + } + else { + $elm.append($compile(template)($scope)); + } + }, + + post: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + var renderContainerCtrl = controllers[1]; + + $scope.i18n = { + headerCell: i18nService.getSafeText('headerCell'), + sort: i18nService.getSafeText('sort') + }; + $scope.isSortPriorityVisible = function() { + //show sort priority if column is sorted and there is at least one other sorted column + return angular.isNumber($scope.col.sort.priority) && $scope.grid.columns.some(function(element, index){ + return angular.isNumber(element.sort.priority) && element !== $scope.col; + }); + }; + $scope.getSortDirectionAriaLabel = function(){ + var col = $scope.col; + //Trying to recreate this sort of thing but it was getting messy having it in the template. + //Sort direction {{col.sort.direction == asc ? 'ascending' : ( col.sort.direction == desc ? 'descending':'none')}}. {{col.sort.priority ? {{columnPriorityText}} {{col.sort.priority}} : ''} + var sortDirectionText = col.sort.direction === uiGridConstants.ASC ? $scope.i18n.sort.ascending : ( col.sort.direction === uiGridConstants.DESC ? $scope.i18n.sort.descending : $scope.i18n.sort.none); + var label = sortDirectionText; + + if ($scope.isSortPriorityVisible()) { + label = label + '. ' + $scope.i18n.headerCell.priority + ' ' + (col.sort.priority + 1); + } + return label; + }; + + $scope.grid = uiGridCtrl.grid; + + $scope.renderContainer = uiGridCtrl.grid.renderContainers[renderContainerCtrl.containerId]; + + var initColClass = $scope.col.getColClass(false); + $elm.addClass(initColClass); + + // Hide the menu by default + $scope.menuShown = false; + + // Put asc and desc sort directions in scope + $scope.asc = uiGridConstants.ASC; + $scope.desc = uiGridConstants.DESC; + + // Store a reference to menu element + var $colMenu = angular.element( $elm[0].querySelectorAll('.ui-grid-header-cell-menu') ); + + var $contentsElm = angular.element( $elm[0].querySelectorAll('.ui-grid-cell-contents') ); + + + // apply any headerCellClass + var classAdded; + var previousMouseX; + + // filter watchers + var filterDeregisters = []; + + + /* + * Our basic approach here for event handlers is that we listen for a down event (mousedown or touchstart). + * Once we have a down event, we need to work out whether we have a click, a drag, or a + * hold. A click would sort the grid (if sortable). A drag would be used by moveable, so + * we ignore it. A hold would open the menu. + * + * So, on down event, we put in place handlers for move and up events, and a timer. If the + * timer expires before we see a move or up, then we have a long press and hence a column menu open. + * If the up happens before the timer, then we have a click, and we sort if the column is sortable. + * If a move happens before the timer, then we are doing column move, so we do nothing, the moveable feature + * will handle it. + * + * To deal with touch enabled devices that also have mice, we only create our handlers when + * we get the down event, and we create the corresponding handlers - if we're touchstart then + * we get touchmove and touchend, if we're mousedown then we get mousemove and mouseup. + * + * We also suppress the click action whilst this is happening - otherwise after the mouseup there + * will be a click event and that can cause the column menu to close + * + */ + + $scope.downFn = function( event ){ + event.stopPropagation(); + + if (typeof(event.originalEvent) !== 'undefined' && event.originalEvent !== undefined) { + event = event.originalEvent; + } + + // Don't show the menu if it's not the left button + if (event.button && event.button !== 0) { + return; + } + previousMouseX = event.pageX; + + $scope.mousedownStartTime = (new Date()).getTime(); + $scope.mousedownTimeout = $timeout(function() { }, mousedownTimeout); + + $scope.mousedownTimeout.then(function () { + if ( $scope.colMenu ) { + uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm, event); + } + }).catch(angular.noop); + + uiGridCtrl.fireEvent(uiGridConstants.events.COLUMN_HEADER_CLICK, {event: event, columnName: $scope.col.colDef.name}); + + $scope.offAllEvents(); + if ( event.type === 'touchstart'){ + $document.on('touchend', $scope.upFn); + $document.on('touchmove', $scope.moveFn); + } else if ( event.type === 'mousedown' ){ + $document.on('mouseup', $scope.upFn); + $document.on('mousemove', $scope.moveFn); + } + }; + + $scope.upFn = function( event ){ + event.stopPropagation(); + $timeout.cancel($scope.mousedownTimeout); + $scope.offAllEvents(); + $scope.onDownEvents(event.type); + + var mousedownEndTime = (new Date()).getTime(); + var mousedownTime = mousedownEndTime - $scope.mousedownStartTime; + + if (mousedownTime > mousedownTimeout) { + // long click, handled above with mousedown + } + else { + // short click + if ( $scope.sortable ){ + $scope.handleClick(event); + } + } + }; + + $scope.handleKeyDown = function(event) { + if (event.keyCode === 32) { + event.preventDefault(); + } + }; + + $scope.moveFn = function( event ){ + // Chrome is known to fire some bogus move events. + var changeValue = event.pageX - previousMouseX; + if ( changeValue === 0 ){ return; } + + // we're a move, so do nothing and leave for column move (if enabled) to take over + $timeout.cancel($scope.mousedownTimeout); + $scope.offAllEvents(); + $scope.onDownEvents(event.type); + }; + + $scope.clickFn = function ( event ){ + event.stopPropagation(); + $contentsElm.off('click', $scope.clickFn); + }; + + + $scope.offAllEvents = function(){ + $contentsElm.off('touchstart', $scope.downFn); + $contentsElm.off('mousedown', $scope.downFn); + + $document.off('touchend', $scope.upFn); + $document.off('mouseup', $scope.upFn); + + $document.off('touchmove', $scope.moveFn); + $document.off('mousemove', $scope.moveFn); + + $contentsElm.off('click', $scope.clickFn); + }; + + $scope.onDownEvents = function( type ){ + // If there is a previous event, then wait a while before + // activating the other mode - i.e. if the last event was a touch event then + // don't enable mouse events for a wee while (500ms or so) + // Avoids problems with devices that emulate mouse events when you have touch events + + switch (type){ + case 'touchmove': + case 'touchend': + $contentsElm.on('click', $scope.clickFn); + $contentsElm.on('touchstart', $scope.downFn); + $timeout(function(){ + $contentsElm.on('mousedown', $scope.downFn); + }, changeModeTimeout); + break; + case 'mousemove': + case 'mouseup': + $contentsElm.on('click', $scope.clickFn); + $contentsElm.on('mousedown', $scope.downFn); + $timeout(function(){ + $contentsElm.on('touchstart', $scope.downFn); + }, changeModeTimeout); + break; + default: + $contentsElm.on('click', $scope.clickFn); + $contentsElm.on('touchstart', $scope.downFn); + $contentsElm.on('mousedown', $scope.downFn); + } + }; + + + var updateHeaderOptions = function( grid ){ + var contents = $elm; + if ( classAdded ){ + contents.removeClass( classAdded ); + classAdded = null; + } + + if (angular.isFunction($scope.col.headerCellClass)) { + classAdded = $scope.col.headerCellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex); + } + else { + classAdded = $scope.col.headerCellClass; + } + contents.addClass(classAdded); + + $scope.$applyAsync(function() { + var rightMostContainer = $scope.grid.renderContainers['right'] && $scope.grid.renderContainers['right'].visibleColumnCache.length ? + $scope.grid.renderContainers['right'] : $scope.grid.renderContainers['body']; + $scope.isLastCol = uiGridCtrl.grid.options && uiGridCtrl.grid.options.enableGridMenu && + $scope.col === rightMostContainer.visibleColumnCache[ rightMostContainer.visibleColumnCache.length - 1 ]; + }); + + // Figure out whether this column is sortable or not + $scope.sortable = Boolean($scope.col.enableSorting); + + // Figure out whether this column is filterable or not + var oldFilterable = $scope.filterable; + $scope.filterable = Boolean(uiGridCtrl.grid.options.enableFiltering && $scope.col.enableFiltering); + + if ( oldFilterable !== $scope.filterable){ + if ( typeof($scope.col.updateFilters) !== 'undefined' ){ + $scope.col.updateFilters($scope.filterable); + } + + // if column is filterable add a filter watcher + if ($scope.filterable) { + $scope.col.filters.forEach( function(filter, i) { + filterDeregisters.push($scope.$watch('col.filters[' + i + '].term', function(n, o) { + if (n !== o) { + uiGridCtrl.grid.api.core.raise.filterChanged(); + uiGridCtrl.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN ); + uiGridCtrl.grid.queueGridRefresh(); + } + })); + }); + $scope.$on('$destroy', function() { + filterDeregisters.forEach( function(filterDeregister) { + filterDeregister(); + }); + }); + } else { + filterDeregisters.forEach( function(filterDeregister) { + filterDeregister(); + }); + } + + } + + // figure out whether we support column menus + if ($scope.col.grid.options && $scope.col.grid.options.enableColumnMenus !== false && + $scope.col.colDef && $scope.col.colDef.enableColumnMenu !== false){ + $scope.colMenu = true; + } else { + $scope.colMenu = false; + } + + /** + * @ngdoc property + * @name enableColumnMenu + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description if column menus are enabled, controls the column menus for this specific + * column (i.e. if gridOptions.enableColumnMenus, then you can control column menus + * using this option. If gridOptions.enableColumnMenus === false then you get no column + * menus irrespective of the value of this option ). Defaults to true. + * + * By default column menu's trigger is hidden before mouse over, but you can always force it to be visible with CSS: + * + *
    +               *  .ui-grid-column-menu-button {
    +               *    display: block;
    +               *  }
    +               * 
    + */ + /** + * @ngdoc property + * @name enableColumnMenus + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description Override for column menus everywhere - if set to false then you get no + * column menus. Defaults to true. + * + */ + + $scope.offAllEvents(); + + if ($scope.sortable || $scope.colMenu) { + $scope.onDownEvents(); + + $scope.$on('$destroy', function () { + $scope.offAllEvents(); + }); + } + }; + +/* + $scope.$watch('col', function (n, o) { + if (n !== o) { + // See if the column's internal class has changed + var newColClass = $scope.col.getColClass(false); + if (newColClass !== initColClass) { + $elm.removeClass(initColClass); + $elm.addClass(newColClass); + initColClass = newColClass; + } + } + }); +*/ + updateHeaderOptions(); + + // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs + var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateHeaderOptions, [uiGridConstants.dataChange.COLUMN]); + + $scope.$on( '$destroy', dataChangeDereg ); + + $scope.handleClick = function(event) { + // If the shift key is being held down, add this column to the sort + var add = false; + if (event.shiftKey) { + add = true; + } + + // Sort this column then rebuild the grid's rows + uiGridCtrl.grid.sortColumn($scope.col, add) + .then(function () { + if (uiGridCtrl.columnMenuScope) { uiGridCtrl.columnMenuScope.hideMenu(); } + uiGridCtrl.grid.refresh(); + }).catch(angular.noop); + }; + + $scope.headerCellArrowKeyDown = function(event) { + if (event.keyCode === 32 || event.keyCode === 13) { + event.preventDefault(); + $scope.toggleMenu(event); + } + }; + + $scope.toggleMenu = function(event) { + + event.stopPropagation(); + + // If the menu is already showing... + if (uiGridCtrl.columnMenuScope.menuShown) { + // ... and we're the column the menu is on... + if (uiGridCtrl.columnMenuScope.col === $scope.col) { + // ... hide it + uiGridCtrl.columnMenuScope.hideMenu(); + } + // ... and we're NOT the column the menu is on + else { + // ... move the menu to our column + uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm); + } + } + // If the menu is NOT showing + else { + // ... show it on our column + uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm); + } + }; + } + }; + } + }; + + return uiGridHeaderCell; + }]); + +})(); + +(function(){ + 'use strict'; + + angular.module('ui.grid').directive('uiGridHeader', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', 'ScrollEvent', + function($templateCache, $compile, uiGridConstants, gridUtil, $timeout, ScrollEvent) { + var defaultTemplate = 'ui-grid/ui-grid-header'; + var emptyTemplate = 'ui-grid/ui-grid-no-header'; + + return { + restrict: 'EA', + // templateUrl: 'ui-grid/ui-grid-header', + replace: true, + // priority: 1000, + require: ['^uiGrid', '^uiGridRenderContainer'], + scope: true, + compile: function($elm, $attrs) { + return { + pre: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + + $scope.grid = uiGridCtrl.grid; + $scope.colContainer = containerCtrl.colContainer; + + updateHeaderReferences(); + + var headerTemplate; + if (!$scope.grid.options.showHeader) { + headerTemplate = emptyTemplate; + } + else { + headerTemplate = ($scope.grid.options.headerTemplate) ? $scope.grid.options.headerTemplate : defaultTemplate; + } + + gridUtil.getTemplate(headerTemplate) + .then(function (contents) { + var template = angular.element(contents); + + var newElm = $compile(template)($scope); + $elm.replaceWith(newElm); + + // And update $elm to be the new element + $elm = newElm; + + updateHeaderReferences(); + + if (containerCtrl) { + // Inject a reference to the header viewport (if it exists) into the grid controller for use in the horizontal scroll handler below + var headerViewport = $elm[0].getElementsByClassName('ui-grid-header-viewport')[0]; + + + if (headerViewport) { + containerCtrl.headerViewport = headerViewport; + angular.element(headerViewport).on('scroll', scrollHandler); + $scope.$on('$destroy', function () { + angular.element(headerViewport).off('scroll', scrollHandler); + }); + } + } + + $scope.grid.queueRefresh(); + }).catch(angular.noop); + + function updateHeaderReferences() { + containerCtrl.header = containerCtrl.colContainer.header = $elm; + + var headerCanvases = $elm[0].getElementsByClassName('ui-grid-header-canvas'); + + if (headerCanvases.length > 0) { + containerCtrl.headerCanvas = containerCtrl.colContainer.headerCanvas = headerCanvases[0]; + } + else { + containerCtrl.headerCanvas = null; + } + } + + function scrollHandler(evt) { + if (uiGridCtrl.grid.isScrollingHorizontally) { + return; + } + var newScrollLeft = gridUtil.normalizeScrollLeft(containerCtrl.headerViewport, uiGridCtrl.grid); + var horizScrollPercentage = containerCtrl.colContainer.scrollHorizontal(newScrollLeft); + + var scrollEvent = new ScrollEvent(uiGridCtrl.grid, null, containerCtrl.colContainer, ScrollEvent.Sources.ViewPortScroll); + scrollEvent.newScrollLeft = newScrollLeft; + if ( horizScrollPercentage > -1 ){ + scrollEvent.x = { percentage: horizScrollPercentage }; + } + + uiGridCtrl.grid.scrollContainers(null, scrollEvent); + } + }, + + post: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + + // gridUtil.logDebug('ui-grid-header link'); + + var grid = uiGridCtrl.grid; + + // Don't animate header cells + gridUtil.disableAnimations($elm); + + function updateColumnWidths() { + // this styleBuilder always runs after the renderContainer, so we can rely on the column widths + // already being populated correctly + + var columnCache = containerCtrl.colContainer.visibleColumnCache; + + // Build the CSS + // uiGridCtrl.grid.columns.forEach(function (column) { + var ret = ''; + var canvasWidth = 0; + columnCache.forEach(function (column) { + ret = ret + column.getColClassDefinition(); + canvasWidth += column.drawnWidth; + }); + + containerCtrl.colContainer.canvasWidth = canvasWidth; + + // Return the styles back to buildStyles which pops them into the `customStyles` scope variable + return ret; + } + + containerCtrl.header = $elm; + + var headerViewport = $elm[0].getElementsByClassName('ui-grid-header-viewport')[0]; + if (headerViewport) { + containerCtrl.headerViewport = headerViewport; + } + + //todo: remove this if by injecting gridCtrl into unit tests + if (uiGridCtrl) { + uiGridCtrl.grid.registerStyleComputation({ + priority: 15, + func: updateColumnWidths + }); + } + } + }; + } + }; + }]); + +})(); + +(function(){ + +angular.module('ui.grid') +.service('uiGridGridMenuService', [ 'gridUtil', 'i18nService', 'uiGridConstants', function( gridUtil, i18nService, uiGridConstants ) { + /** + * @ngdoc service + * @name ui.grid.uiGridGridMenuService + * + * @description Methods for working with the grid menu + */ + + var service = { + /** + * @ngdoc method + * @methodOf ui.grid.uiGridGridMenuService + * @name initialize + * @description Sets up the gridMenu. Most importantly, sets our + * scope onto the grid object as grid.gridMenuScope, allowing us + * to operate when passed only the grid. Second most importantly, + * we register the 'addToGridMenu' and 'removeFromGridMenu' methods + * on the core api. + * @param {$scope} $scope the scope of this gridMenu + * @param {Grid} grid the grid to which this gridMenu is associated + */ + initialize: function( $scope, grid ){ + grid.gridMenuScope = $scope; + $scope.grid = grid; + $scope.registeredMenuItems = []; + + // not certain this is needed, but would be bad to create a memory leak + $scope.$on('$destroy', function() { + if ( $scope.grid && $scope.grid.gridMenuScope ){ + $scope.grid.gridMenuScope = null; + } + if ( $scope.grid ){ + $scope.grid = null; + } + if ( $scope.registeredMenuItems ){ + $scope.registeredMenuItems = null; + } + }); + + $scope.registeredMenuItems = []; + + /** + * @ngdoc function + * @name addToGridMenu + * @methodOf ui.grid.core.api:PublicApi + * @description add items to the grid menu. Used by features + * to add their menu items if they are enabled, can also be used by + * end users to add menu items. This method has the advantage of allowing + * remove again, which can simplify management of which items are included + * in the menu when. (Noting that in most cases the shown and active functions + * provide a better way to handle visibility of menu items) + * @param {Grid} grid the grid on which we are acting + * @param {array} items menu items in the format as described in the tutorial, with + * the added note that if you want to use remove you must also specify an `id` field, + * which is provided when you want to remove an item. The id should be unique. + * + */ + grid.api.registerMethod( 'core', 'addToGridMenu', service.addToGridMenu ); + + /** + * @ngdoc function + * @name removeFromGridMenu + * @methodOf ui.grid.core.api:PublicApi + * @description Remove an item from the grid menu based on a provided id. Assumes + * that the id is unique, removes only the last instance of that id. Does nothing if + * the specified id is not found + * @param {Grid} grid the grid on which we are acting + * @param {string} id the id we'd like to remove from the menu + * + */ + grid.api.registerMethod( 'core', 'removeFromGridMenu', service.removeFromGridMenu ); + }, + + + /** + * @ngdoc function + * @name addToGridMenu + * @propertyOf ui.grid.uiGridGridMenuService + * @description add items to the grid menu. Used by features + * to add their menu items if they are enabled, can also be used by + * end users to add menu items. This method has the advantage of allowing + * remove again, which can simplify management of which items are included + * in the menu when. (Noting that in most cases the shown and active functions + * provide a better way to handle visibility of menu items) + * @param {Grid} grid the grid on which we are acting + * @param {array} menuItems menu items in the format as described in the tutorial, with + * the added note that if you want to use remove you must also specify an `id` field, + * which is provided when you want to remove an item. The id should be unique. + * + */ + addToGridMenu: function( grid, menuItems ) { + if ( !angular.isArray( menuItems ) ) { + gridUtil.logError( 'addToGridMenu: menuItems must be an array, and is not, not adding any items'); + } else { + if ( grid.gridMenuScope ){ + grid.gridMenuScope.registeredMenuItems = grid.gridMenuScope.registeredMenuItems ? grid.gridMenuScope.registeredMenuItems : []; + grid.gridMenuScope.registeredMenuItems = grid.gridMenuScope.registeredMenuItems.concat( menuItems ); + } else { + gridUtil.logError( 'Asked to addToGridMenu, but gridMenuScope not present. Timing issue? Please log issue with ui-grid'); + } + } + }, + + + /** + * @ngdoc function + * @name removeFromGridMenu + * @methodOf ui.grid.uiGridGridMenuService + * @description Remove an item from the grid menu based on a provided id. Assumes + * that the id is unique, removes only the last instance of that id. Does nothing if + * the specified id is not found. If there is no gridMenuScope or registeredMenuItems + * then do nothing silently - the desired result is those menu items not be present and they + * aren't. + * @param {Grid} grid the grid on which we are acting + * @param {string} id the id we'd like to remove from the menu + * + */ + removeFromGridMenu: function( grid, id ){ + var foundIndex = -1; + + if ( grid && grid.gridMenuScope ){ + grid.gridMenuScope.registeredMenuItems.forEach( function( value, index ) { + if ( value.id === id ){ + if (foundIndex > -1) { + gridUtil.logError( 'removeFromGridMenu: found multiple items with the same id, removing only the last' ); + } else { + + foundIndex = index; + } + } + }); + } + + if ( foundIndex > -1 ){ + grid.gridMenuScope.registeredMenuItems.splice( foundIndex, 1 ); + } + }, + + + /** + * @ngdoc array + * @name gridMenuCustomItems + * @propertyOf ui.grid.class:GridOptions + * @description (optional) An array of menu items that should be added to + * the gridMenu. Follow the format documented in the tutorial for column + * menu customisation. The context provided to the action function will + * include context.grid. An alternative if working with dynamic menus is to use the + * provided api - core.addToGridMenu and core.removeFromGridMenu, which handles + * some of the management of items for you. + * + */ + /** + * @ngdoc boolean + * @name gridMenuShowHideColumns + * @propertyOf ui.grid.class:GridOptions + * @description true by default, whether the grid menu should allow hide/show + * of columns + * + */ + /** + * @ngdoc method + * @methodOf ui.grid.uiGridGridMenuService + * @name getMenuItems + * @description Decides the menu items to show in the menu. This is a + * combination of: + * + * - the default menu items that are always included, + * - any menu items that have been provided through the addMenuItem api. These + * are typically added by features within the grid + * - any menu items included in grid.options.gridMenuCustomItems. These can be + * changed dynamically, as they're always recalculated whenever we show the + * menu + * @param {$scope} $scope the scope of this gridMenu, from which we can find all + * the information that we need + * @returns {Array} an array of menu items that can be shown + */ + getMenuItems: function( $scope ) { + var menuItems = [ + // this is where we add any menu items we want to always include + ]; + + if ( $scope.grid.options.gridMenuCustomItems ){ + if ( !angular.isArray( $scope.grid.options.gridMenuCustomItems ) ){ + gridUtil.logError( 'gridOptions.gridMenuCustomItems must be an array, and is not'); + } else { + menuItems = menuItems.concat( $scope.grid.options.gridMenuCustomItems ); + } + } + + var clearFilters = [{ + title: i18nService.getSafeText('gridMenu.clearAllFilters'), + action: function ($event) { + $scope.grid.clearAllFilters(); + }, + shown: function() { + return $scope.grid.options.enableFiltering; + }, + order: 100 + }]; + menuItems = menuItems.concat( clearFilters ); + + menuItems = menuItems.concat( $scope.registeredMenuItems ); + + if ( $scope.grid.options.gridMenuShowHideColumns !== false ){ + menuItems = menuItems.concat( service.showHideColumns( $scope ) ); + } + + menuItems.sort(function(a, b){ + return a.order - b.order; + }); + + return menuItems; + }, + + + /** + * @ngdoc array + * @name gridMenuTitleFilter + * @propertyOf ui.grid.class:GridOptions + * @description (optional) A function that takes a title string + * (usually the col.displayName), and converts it into a display value. The function + * must return either a string or a promise. + * + * Used for internationalization of the grid menu column names - for angular-translate + * you can pass $translate as the function, for i18nService you can pass getSafeText as the + * function + * @example + *
    +     *   gridOptions = {
    +     *     gridMenuTitleFilter: $translate
    +     *   }
    +     * 
    + */ + /** + * @ngdoc method + * @methodOf ui.grid.uiGridGridMenuService + * @name showHideColumns + * @description Adds two menu items for each of the columns in columnDefs. One + * menu item for hide, one menu item for show. Each is visible when appropriate + * (show when column is not visible, hide when column is visible). Each toggles + * the visible property on the columnDef using toggleColumnVisibility + * @param {$scope} $scope of a gridMenu, which contains a reference to the grid + */ + showHideColumns: function( $scope ){ + var showHideColumns = []; + if ( !$scope.grid.options.columnDefs || $scope.grid.options.columnDefs.length === 0 || $scope.grid.columns.length === 0 ) { + return showHideColumns; + } + + function isColumnVisible(colDef) { + return colDef.visible === true || colDef.visible === undefined; + } + + // add header for columns + showHideColumns.push({ + title: i18nService.getSafeText('gridMenu.columns'), + order: 300, + templateUrl: 'ui-grid/ui-grid-menu-header-item' + }); + + $scope.grid.options.gridMenuTitleFilter = $scope.grid.options.gridMenuTitleFilter ? $scope.grid.options.gridMenuTitleFilter : function( title ) { return title; }; + + $scope.grid.options.columnDefs.forEach( function( colDef, index ){ + if ( colDef.enableHiding !== false ){ + // add hide menu item - shows an OK icon as we only show when column is already visible + var menuItem = { + icon: isColumnVisible(colDef) ? 'ui-grid-icon-ok' : 'ui-grid-icon-cancel', + action: function($event) { + $event.stopPropagation(); + + service.toggleColumnVisibility( this.context.gridCol ); + + if ($event.target && $event.target.firstChild) { + $event.target.firstChild.className = isColumnVisible(this.context.gridCol.colDef) ? + 'ui-grid-icon-ok' : 'ui-grid-icon-cancel'; + } + }, + shown: function() { + return this.context.gridCol.colDef.enableHiding !== false; + }, + context: { gridCol: $scope.grid.getColumn(colDef.name || colDef.field) }, + leaveOpen: true, + order: 301 + index + }; + service.setMenuItemTitle( menuItem, colDef, $scope.grid ); + showHideColumns.push( menuItem ); + } + }); + return showHideColumns; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.uiGridGridMenuService + * @name setMenuItemTitle + * @description Handles the response from gridMenuTitleFilter, adding it directly to the menu + * item if it returns a string, otherwise waiting for the promise to resolve or reject then + * putting the result into the title + * @param {object} menuItem the menuItem we want to put the title on + * @param {object} colDef the colDef from which we can get displayName, name or field + * @param {Grid} grid the grid, from which we can get the options.gridMenuTitleFilter + * + */ + setMenuItemTitle: function( menuItem, colDef, grid ){ + var title = grid.options.gridMenuTitleFilter( colDef.displayName || gridUtil.readableColumnName(colDef.name) || colDef.field ); + + if ( typeof(title) === 'string' ){ + menuItem.title = title; + } else if ( title.then ){ + // must be a promise + menuItem.title = ""; + title.then( function( successValue ) { + menuItem.title = successValue; + }, function( errorValue ) { + menuItem.title = errorValue; + }).catch(angular.noop); + } else { + gridUtil.logError('Expected gridMenuTitleFilter to return a string or a promise, it has returned neither, bad config'); + menuItem.title = 'badconfig'; + } + }, + + /** + * @ngdoc method + * @methodOf ui.grid.uiGridGridMenuService + * @name toggleColumnVisibility + * @description Toggles the visibility of an individual column. Expects to be + * provided a context that has on it a gridColumn, which is the column that + * we'll operate upon. We change the visibility, and refresh the grid as appropriate + * @param {GridColumn} gridCol the column that we want to toggle + * + */ + toggleColumnVisibility: function( gridCol ) { + gridCol.colDef.visible = !( gridCol.colDef.visible === true || gridCol.colDef.visible === undefined ); + + gridCol.grid.refresh(); + gridCol.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN ); + gridCol.grid.api.core.raise.columnVisibilityChanged( gridCol ); + } + }; + + return service; +}]) + + + +.directive('uiGridMenuButton', ['gridUtil', 'uiGridConstants', 'uiGridGridMenuService', 'i18nService', +function (gridUtil, uiGridConstants, uiGridGridMenuService, i18nService) { + + return { + priority: 0, + scope: true, + require: ['^uiGrid'], + templateUrl: 'ui-grid/ui-grid-menu-button', + replace: true, + + link: function ($scope, $elm, $attrs, controllers) { + var uiGridCtrl = controllers[0]; + + // For the aria label + $scope.i18n = { + aria: i18nService.getSafeText('gridMenu.aria') + }; + + uiGridGridMenuService.initialize($scope, uiGridCtrl.grid); + + $scope.shown = false; + + $scope.toggleMenu = function () { + if ( $scope.shown ){ + $scope.$broadcast('hide-menu'); + $scope.shown = false; + } else { + $scope.menuItems = uiGridGridMenuService.getMenuItems( $scope ); + $scope.$broadcast('show-menu'); + $scope.shown = true; + } + }; + + $scope.$on('menu-hidden', function() { + $scope.shown = false; + gridUtil.focus.bySelector($elm, '.ui-grid-icon-container'); + }); + } + }; + +}]); + +})(); + +(function(){ + +/** + * @ngdoc directive + * @name ui.grid.directive:uiGridMenu + * @element style + * @restrict A + * + * @description + * Allows us to interpolate expressions in ` + I am in a box. + + + + it('should apply the right class to the element', function () { + element(by.css('.blah')).getCssValue('border-top-width') + .then(function(c) { + expect(c).toContain('1px'); + }); + }); + + + */ + + + angular.module('ui.grid').directive('uiGridStyle', ['gridUtil', '$interpolate', function(gridUtil, $interpolate) { + return { + // restrict: 'A', + // priority: 1000, + // require: '?^uiGrid', + link: function($scope, $elm, $attrs, uiGridCtrl) { + // gridUtil.logDebug('ui-grid-style link'); + // if (uiGridCtrl === undefined) { + // gridUtil.logWarn('[ui-grid-style link] uiGridCtrl is undefined!'); + // } + + var interpolateFn = $interpolate($elm.text(), true); + + if (interpolateFn) { + $scope.$watch(interpolateFn, function(value) { + $elm.text(value); + }); + } + + // uiGridCtrl.recalcRowStyles = function() { + // var offset = (scope.options.offsetTop || 0) - (scope.options.excessRows * scope.options.rowHeight); + // var rowHeight = scope.options.rowHeight; + + // var ret = ''; + // var rowStyleCount = uiGridCtrl.minRowsToRender() + (scope.options.excessRows * 2); + // for (var i = 1; i <= rowStyleCount; i++) { + // ret = ret + ' .grid' + scope.gridId + ' .ui-grid-row:nth-child(' + i + ') { top: ' + offset + 'px; }'; + // offset = offset + rowHeight; + // } + + // scope.rowStyles = ret; + // }; + + // uiGridCtrl.styleComputions.push(uiGridCtrl.recalcRowStyles); + + } + }; + }]); + +})(); + +(function(){ + 'use strict'; + + angular.module('ui.grid').directive('uiGridViewport', ['gridUtil','ScrollEvent','uiGridConstants', '$log', + function(gridUtil, ScrollEvent, uiGridConstants, $log) { + return { + replace: true, + scope: {}, + controllerAs: 'Viewport', + templateUrl: 'ui-grid/uiGridViewport', + require: ['^uiGrid', '^uiGridRenderContainer'], + link: function($scope, $elm, $attrs, controllers) { + // gridUtil.logDebug('viewport post-link'); + + var uiGridCtrl = controllers[0]; + var containerCtrl = controllers[1]; + + $scope.containerCtrl = containerCtrl; + + var rowContainer = containerCtrl.rowContainer; + var colContainer = containerCtrl.colContainer; + + var grid = uiGridCtrl.grid; + + $scope.grid = uiGridCtrl.grid; + + // Put the containers in scope so we can get rows and columns from them + $scope.rowContainer = containerCtrl.rowContainer; + $scope.colContainer = containerCtrl.colContainer; + + // Register this viewport with its container + containerCtrl.viewport = $elm; + + /** + * @ngdoc function + * @name customScroller + * @methodOf ui.grid.class:GridOptions + * @description (optional) uiGridViewport.on('scroll', scrollHandler) by default. + * A function that allows you to provide your own scroller function. It is particularly helpful if you want to use third party scrollers + * as this allows you to do that. + * + * + *
    Example
    + *
    +           *   $scope.gridOptions = {
    +           *       customScroller: function myScrolling(uiGridViewport, scrollHandler) {
    +           *           uiGridViewport.on('scroll', function myScrollingOverride(event) {
    +           *               // Do something here
    +           *
    +           *               scrollHandler(event);
    +           *           });
    +           *       }
    +           *   };
    +           * 
    + * @param {object} uiGridViewport Element being scrolled. (this gets passed in by the grid). + * @param {function} scrollHandler Function that needs to be called when scrolling happens. (this gets passed in by the grid). + */ + if (grid && grid.options && grid.options.customScroller) { + grid.options.customScroller($elm, scrollHandler); + } else { + $elm.on('scroll', scrollHandler); + } + + var ignoreScroll = false; + + function scrollHandler(evt) { + //Leaving in this commented code in case it can someday be used + //It does improve performance, but because the horizontal scroll is normalized, + // using this code will lead to the column header getting slightly out of line with columns + // + //if (ignoreScroll && (grid.isScrollingHorizontally || grid.isScrollingHorizontally)) { + // //don't ask for scrollTop if we just set it + // ignoreScroll = false; + // return; + //} + //ignoreScroll = true; + + var newScrollTop = $elm[0].scrollTop; + var newScrollLeft = gridUtil.normalizeScrollLeft($elm, grid); + + var vertScrollPercentage = rowContainer.scrollVertical(newScrollTop); + var horizScrollPercentage = colContainer.scrollHorizontal(newScrollLeft); + + var scrollEvent = new ScrollEvent(grid, rowContainer, colContainer, ScrollEvent.Sources.ViewPortScroll); + scrollEvent.newScrollLeft = newScrollLeft; + scrollEvent.newScrollTop = newScrollTop; + if ( horizScrollPercentage > -1 ){ + scrollEvent.x = { percentage: horizScrollPercentage }; + } + + if ( vertScrollPercentage > -1 ){ + scrollEvent.y = { percentage: vertScrollPercentage }; + } + + grid.scrollContainers($scope.$parent.containerId, scrollEvent); + } + + if ($scope.$parent.bindScrollVertical) { + grid.addVerticalScrollSync($scope.$parent.containerId, syncVerticalScroll); + } + + if ($scope.$parent.bindScrollHorizontal) { + grid.addHorizontalScrollSync($scope.$parent.containerId, syncHorizontalScroll); + grid.addHorizontalScrollSync($scope.$parent.containerId + 'header', syncHorizontalHeader); + grid.addHorizontalScrollSync($scope.$parent.containerId + 'footer', syncHorizontalFooter); + } + + function syncVerticalScroll(scrollEvent){ + containerCtrl.prevScrollArgs = scrollEvent; + var newScrollTop = scrollEvent.getNewScrollTop(rowContainer,containerCtrl.viewport); + $elm[0].scrollTop = newScrollTop; + + } + + function syncHorizontalScroll(scrollEvent){ + containerCtrl.prevScrollArgs = scrollEvent; + var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport); + $elm[0].scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid); + } + + function syncHorizontalHeader(scrollEvent){ + var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport); + if (containerCtrl.headerViewport) { + containerCtrl.headerViewport.scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid); + } + } + + function syncHorizontalFooter(scrollEvent){ + var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport); + if (containerCtrl.footerViewport) { + containerCtrl.footerViewport.scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid); + } + } + + $scope.$on('$destroy', function unbindEvents() { + $elm.off(); + }); + }, + controller: ['$scope', function ($scope) { + this.rowStyle = function (index) { + var rowContainer = $scope.rowContainer; + var colContainer = $scope.colContainer; + + var styles = {}; + + if (rowContainer.currentTopRow !== 0){ + //top offset based on hidden rows count + var translateY = "translateY("+ (rowContainer.currentTopRow * rowContainer.grid.options.rowHeight) +"px)"; + styles['transform'] = translateY; + styles['-webkit-transform'] = translateY; + styles['-ms-transform'] = translateY; + } + + if (colContainer.currentFirstColumn !== 0) { + if (colContainer.grid.isRTL()) { + styles['margin-right'] = colContainer.columnOffset + 'px'; + } + else { + styles['margin-left'] = colContainer.columnOffset + 'px'; + } + } + + return styles; + }; + }] + }; + } + ]); + +})(); + +(function() { + +angular.module('ui.grid') +.directive('uiGridVisible', function uiGridVisibleAction() { + return function ($scope, $elm, $attr) { + $scope.$watch($attr.uiGridVisible, function (visible) { + // $elm.css('visibility', visible ? 'visible' : 'hidden'); + $elm[visible ? 'removeClass' : 'addClass']('ui-grid-invisible'); + }); + }; +}); + +})(); +(function () { + 'use strict'; + + angular.module('ui.grid').controller('uiGridController', ['$scope', '$element', '$attrs', 'gridUtil', '$q', 'uiGridConstants', + 'gridClassFactory', '$parse', '$compile', + function ($scope, $elm, $attrs, gridUtil, $q, uiGridConstants, + gridClassFactory, $parse, $compile) { + // gridUtil.logDebug('ui-grid controller'); + var self = this; + var deregFunctions = []; + + self.grid = gridClassFactory.createGrid($scope.uiGrid); + + //assign $scope.$parent if appScope not already assigned + self.grid.appScope = self.grid.appScope || $scope.$parent; + + $elm.addClass('grid' + self.grid.id); + self.grid.rtl = gridUtil.getStyles($elm[0])['direction'] === 'rtl'; + + + // angular.extend(self.grid.options, ); + + //all properties of grid are available on scope + $scope.grid = self.grid; + + if ($attrs.uiGridColumns) { + deregFunctions.push( $attrs.$observe('uiGridColumns', function(value) { + self.grid.options.columnDefs = angular.isString(value) ? angular.fromJson(value) : value; + self.grid.buildColumns() + .then(function(){ + self.grid.preCompileCellTemplates(); + + self.grid.refreshCanvas(true); + }).catch(angular.noop); + }) ); + } + + // prevents an error from being thrown when the array is not defined yet and fastWatch is on + function getSize(array) { + return array ? array.length : 0; + } + + // if fastWatch is set we watch only the length and the reference, not every individual object + if (self.grid.options.fastWatch) { + self.uiGrid = $scope.uiGrid; + if (angular.isString($scope.uiGrid.data)) { + deregFunctions.push( $scope.$parent.$watch($scope.uiGrid.data, dataWatchFunction) ); + deregFunctions.push( $scope.$parent.$watch(function() { + if ( self.grid.appScope[$scope.uiGrid.data] ){ + return self.grid.appScope[$scope.uiGrid.data].length; + } else { + return undefined; + } + }, dataWatchFunction) ); + } else { + deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.data; }, dataWatchFunction) ); + deregFunctions.push( $scope.$parent.$watch(function() { return getSize($scope.uiGrid.data); }, function(){ dataWatchFunction($scope.uiGrid.data); }) ); + } + deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.columnDefs; }, columnDefsWatchFunction) ); + deregFunctions.push( $scope.$parent.$watch(function() { return getSize($scope.uiGrid.columnDefs); }, function(){ columnDefsWatchFunction($scope.uiGrid.columnDefs); }) ); + } else { + if (angular.isString($scope.uiGrid.data)) { + deregFunctions.push( $scope.$parent.$watchCollection($scope.uiGrid.data, dataWatchFunction) ); + } else { + deregFunctions.push( $scope.$parent.$watchCollection(function() { return $scope.uiGrid.data; }, dataWatchFunction) ); + } + deregFunctions.push( $scope.$parent.$watchCollection(function() { return $scope.uiGrid.columnDefs; }, columnDefsWatchFunction) ); + } + + + function columnDefsWatchFunction(n, o) { + if (n && n !== o) { + self.grid.options.columnDefs = $scope.uiGrid.columnDefs; + self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.COLUMN, { + orderByColumnDefs: true, + preCompileCellTemplates: true + }); + } + } + + var mostRecentData; + + function dataWatchFunction(newData) { + // gridUtil.logDebug('dataWatch fired'); + var promises = []; + + if ( self.grid.options.fastWatch ) { + if (angular.isString($scope.uiGrid.data)) { + newData = self.grid.appScope.$eval($scope.uiGrid.data); + } else { + newData = $scope.uiGrid.data; + } + } + + mostRecentData = newData; + + if (newData) { + // columns length is greater than the number of row header columns, which don't count because they're created automatically + var hasColumns = self.grid.columns.length > (self.grid.rowHeaderColumns ? self.grid.rowHeaderColumns.length : 0); + + if ( + // If we have no columns + !hasColumns && + // ... and we don't have a ui-grid-columns attribute, which would define columns for us + !$attrs.uiGridColumns && + // ... and we have no pre-defined columns + self.grid.options.columnDefs.length === 0 && + // ... but we DO have data + newData.length > 0 + ) { + // ... then build the column definitions from the data that we have + self.grid.buildColumnDefsFromData(newData); + } + + // If we haven't built columns before and either have some columns defined or some data defined + if (!hasColumns && (self.grid.options.columnDefs.length > 0 || newData.length > 0)) { + // Build the column set, then pre-compile the column cell templates + promises.push(self.grid.buildColumns() + .then(function() { + self.grid.preCompileCellTemplates(); + }).catch(angular.noop)); + } + + $q.all(promises).then(function() { + // use most recent data, rather than the potentially outdated data passed into watcher handler + self.grid.modifyRows(mostRecentData) + .then(function () { + // if (self.viewport) { + self.grid.redrawInPlace(true); + // } + + $scope.$evalAsync(function() { + self.grid.refreshCanvas(true); + self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.ROW); + }); + }).catch(angular.noop); + }).catch(angular.noop); + } + } + + var styleWatchDereg = $scope.$watch(function () { return self.grid.styleComputations; }, function() { + self.grid.refreshCanvas(true); + }); + + $scope.$on('$destroy', function() { + deregFunctions.forEach( function( deregFn ){ deregFn(); }); + styleWatchDereg(); + }); + + self.fireEvent = function(eventName, args) { + args = args || {}; + + // Add the grid to the event arguments if it's not there + if (angular.isUndefined(args.grid)) { + args.grid = self.grid; + } + + $scope.$broadcast(eventName, args); + }; + + self.innerCompile = function innerCompile(elm) { + $compile(elm)($scope); + }; + }]); + +/** + * @ngdoc directive + * @name ui.grid.directive:uiGrid + * @element div + * @restrict EA + * @param {Object} uiGrid Options for the grid to use + * + * @description Create a very basic grid. + * + * @example + + + var app = angular.module('app', ['ui.grid']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + }]); + + +
    +
    +
    +
    +
    + */ +angular.module('ui.grid').directive('uiGrid', uiGridDirective); + +uiGridDirective.$inject = ['$window', 'gridUtil', 'uiGridConstants']; +function uiGridDirective($window, gridUtil, uiGridConstants) { + return { + templateUrl: 'ui-grid/ui-grid', + scope: { + uiGrid: '=' + }, + replace: true, + transclude: true, + controller: 'uiGridController', + compile: function () { + return { + post: function ($scope, $elm, $attrs, uiGridCtrl) { + var grid = uiGridCtrl.grid; + // Initialize scrollbars (TODO: move to controller??) + uiGridCtrl.scrollbars = []; + grid.element = $elm; + + + // See if the grid has a rendered width, if not, wait a bit and try again + var sizeCheckInterval = 100; // ms + var maxSizeChecks = 20; // 2 seconds total + var sizeChecks = 0; + + // Setup (event listeners) the grid + setup(); + + // And initialize it + init(); + + // Mark rendering complete so API events can happen + grid.renderingComplete(); + + // If the grid doesn't have size currently, wait for a bit to see if it gets size + checkSize(); + + /*-- Methods --*/ + + function checkSize() { + // If the grid has no width and we haven't checked more than times, check again in milliseconds + if ($elm[0].offsetWidth <= 0 && sizeChecks < maxSizeChecks) { + setTimeout(checkSize, sizeCheckInterval); + sizeChecks++; + } else { + $scope.$applyAsync(init); + } + } + + // Setup event listeners and watchers + function setup() { + var deregisterLeftWatcher, deregisterRightWatcher; + + // Bind to window resize events + angular.element($window).on('resize', gridResize); + + // Unbind from window resize events when the grid is destroyed + $elm.on('$destroy', function () { + angular.element($window).off('resize', gridResize); + deregisterLeftWatcher(); + deregisterRightWatcher(); + }); + + // If we add a left container after render, we need to watch and react + deregisterLeftWatcher = $scope.$watch(function () { return grid.hasLeftContainer();}, function (newValue, oldValue) { + if (newValue === oldValue) { + return; + } + grid.refreshCanvas(true); + }); + + // If we add a right container after render, we need to watch and react + deregisterRightWatcher = $scope.$watch(function () { return grid.hasRightContainer();}, function (newValue, oldValue) { + if (newValue === oldValue) { + return; + } + grid.refreshCanvas(true); + }); + } + + // Initialize the directive + function init() { + grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm); + + // Default canvasWidth to the grid width, in case we don't get any column definitions to calculate it from + grid.canvasWidth = uiGridCtrl.grid.gridWidth; + + grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm); + + // If the grid isn't tall enough to fit a single row, it's kind of useless. Resize it to fit a minimum number of rows + if (grid.gridHeight - grid.scrollbarHeight <= grid.options.rowHeight && grid.options.enableMinHeightCheck) { + autoAdjustHeight(); + } + + // Run initial canvas refresh + grid.refreshCanvas(true); + } + + // Set the grid's height ourselves in the case that its height would be unusably small + function autoAdjustHeight() { + // Figure out the new height + var contentHeight = grid.options.minRowsToShow * grid.options.rowHeight; + var headerHeight = grid.options.showHeader ? grid.options.headerRowHeight : 0; + var footerHeight = grid.calcFooterHeight(); + + var scrollbarHeight = 0; + if (grid.options.enableHorizontalScrollbar === uiGridConstants.scrollbars.ALWAYS) { + scrollbarHeight = gridUtil.getScrollbarWidth(); + } + + var maxNumberOfFilters = 0; + // Calculates the maximum number of filters in the columns + angular.forEach(grid.options.columnDefs, function(col) { + if (col.hasOwnProperty('filter')) { + if (maxNumberOfFilters < 1) { + maxNumberOfFilters = 1; + } + } + else if (col.hasOwnProperty('filters')) { + if (maxNumberOfFilters < col.filters.length) { + maxNumberOfFilters = col.filters.length; + } + } + }); + + if (grid.options.enableFiltering && !maxNumberOfFilters) { + var allColumnsHaveFilteringTurnedOff = grid.options.columnDefs.length && grid.options.columnDefs.every(function(col) { + return col.enableFiltering === false; + }); + + if (!allColumnsHaveFilteringTurnedOff) { + maxNumberOfFilters = 1; + } + } + + var filterHeight = maxNumberOfFilters * headerHeight; + + var newHeight = headerHeight + contentHeight + footerHeight + scrollbarHeight + filterHeight; + + $elm.css('height', newHeight + 'px'); + + grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm); + } + + // Resize the grid on window resize events + function gridResize() { + grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm); + grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm); + + grid.refreshCanvas(true); + } + } + }; + } + }; +} +})(); + +(function(){ + 'use strict'; + + // TODO: rename this file to ui-grid-pinned-container.js + + angular.module('ui.grid').directive('uiGridPinnedContainer', ['gridUtil', function (gridUtil) { + return { + restrict: 'EA', + replace: true, + template: '
    ', + scope: { + side: '=uiGridPinnedContainer' + }, + require: '^uiGrid', + compile: function compile() { + return { + post: function ($scope, $elm, $attrs, uiGridCtrl) { + // gridUtil.logDebug('ui-grid-pinned-container ' + $scope.side + ' link'); + + var grid = uiGridCtrl.grid; + + var myWidth = 0; + + $elm.addClass('ui-grid-pinned-container-' + $scope.side); + + // Monkey-patch the viewport width function + if ($scope.side === 'left' || $scope.side === 'right') { + grid.renderContainers[$scope.side].getViewportWidth = monkeyPatchedGetViewportWidth; + } + + function monkeyPatchedGetViewportWidth() { + /*jshint validthis: true */ + var self = this; + + var viewportWidth = 0; + self.visibleColumnCache.forEach(function (column) { + viewportWidth += column.drawnWidth; + }); + + var adjustment = self.getViewportAdjustment(); + + viewportWidth = viewportWidth + adjustment.width; + + return viewportWidth; + } + + function updateContainerWidth() { + if ($scope.side === 'left' || $scope.side === 'right') { + var cols = grid.renderContainers[$scope.side].visibleColumnCache; + var width = 0; + for (var i = 0; i < cols.length; i++) { + var col = cols[i]; + width += col.drawnWidth || col.width || 0; + } + + return width; + } + } + + function updateContainerDimensions() { + var ret = ''; + + // Column containers + if ($scope.side === 'left' || $scope.side === 'right') { + myWidth = updateContainerWidth(); + + // gridUtil.logDebug('myWidth', myWidth); + + // TODO(c0bra): Subtract sum of col widths from grid viewport width and update it + $elm.attr('style', null); + + // var myHeight = grid.renderContainers.body.getViewportHeight(); // + grid.horizontalScrollbarHeight; + + ret += '.grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.side + ', .grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.side + ' .ui-grid-render-container-' + $scope.side + ' .ui-grid-viewport { width: ' + myWidth + 'px; } '; + } + + return ret; + } + + grid.renderContainers.body.registerViewportAdjuster(function (adjustment) { + myWidth = updateContainerWidth(); + + // Subtract our own width + adjustment.width -= myWidth; + adjustment.side = $scope.side; + + return adjustment; + }); + + // Register style computation to adjust for columns in `side`'s render container + grid.registerStyleComputation({ + priority: 15, + func: updateContainerDimensions + }); + } + }; + } + }; + }]); +})(); + +(function(){ + +angular.module('ui.grid') +.factory('Grid', ['$q', '$compile', '$parse', 'gridUtil', 'uiGridConstants', 'GridOptions', 'GridColumn', 'GridRow', 'GridApi', 'rowSorter', 'rowSearcher', 'GridRenderContainer', '$timeout','ScrollEvent', + function($q, $compile, $parse, gridUtil, uiGridConstants, GridOptions, GridColumn, GridRow, GridApi, rowSorter, rowSearcher, GridRenderContainer, $timeout, ScrollEvent) { + + /** + * @ngdoc object + * @name ui.grid.core.api:PublicApi + * @description Public Api for the core grid features + * + */ + + /** + * @ngdoc function + * @name ui.grid.class:Grid + * @description Grid is the main viewModel. Any properties or methods needed to maintain state are defined in + * this prototype. One instance of Grid is created per Grid directive instance. + * @param {object} options Object map of options to pass into the grid. An 'id' property is expected. + */ + var Grid = function Grid(options) { + var self = this; + // Get the id out of the options, then remove it + if (options !== undefined && typeof(options.id) !== 'undefined' && options.id) { + if (!/^[_a-zA-Z0-9-]+$/.test(options.id)) { + throw new Error("Grid id '" + options.id + '" is invalid. It must follow CSS selector syntax rules.'); + } + } + else { + throw new Error('No ID provided. An ID must be given when creating a grid.'); + } + + self.id = options.id; + delete options.id; + + // Get default options + self.options = GridOptions.initialize( options ); + + /** + * @ngdoc object + * @name appScope + * @propertyOf ui.grid.class:Grid + * @description reference to the application scope (the parent scope of the ui-grid element). Assigned in ui-grid controller + *
    + * use gridOptions.appScopeProvider to override the default assignment of $scope.$parent with any reference + */ + self.appScope = self.options.appScopeProvider; + + self.headerHeight = self.options.headerRowHeight; + + + /** + * @ngdoc object + * @name footerHeight + * @propertyOf ui.grid.class:Grid + * @description returns the total footer height gridFooter + columnFooter + */ + self.footerHeight = self.calcFooterHeight(); + + + /** + * @ngdoc object + * @name columnFooterHeight + * @propertyOf ui.grid.class:Grid + * @description returns the total column footer height + */ + self.columnFooterHeight = self.calcColumnFooterHeight(); + + self.rtl = false; + self.gridHeight = 0; + self.gridWidth = 0; + self.columnBuilders = []; + self.rowBuilders = []; + self.rowsProcessors = []; + self.columnsProcessors = []; + self.styleComputations = []; + self.viewportAdjusters = []; + self.rowHeaderColumns = []; + self.dataChangeCallbacks = {}; + self.verticalScrollSyncCallBackFns = {}; + self.horizontalScrollSyncCallBackFns = {}; + + // self.visibleRowCache = []; + + // Set of 'render' containers for self grid, which can render sets of rows + self.renderContainers = {}; + + // Create a + self.renderContainers.body = new GridRenderContainer('body', self); + + self.cellValueGetterCache = {}; + + // Cached function to use with custom row templates + self.getRowTemplateFn = null; + + + //representation of the rows on the grid. + //these are wrapped references to the actual data rows (options.data) + self.rows = []; + + //represents the columns on the grid + self.columns = []; + + /** + * @ngdoc boolean + * @name isScrollingVertically + * @propertyOf ui.grid.class:Grid + * @description set to true when Grid is scrolling vertically. Set to false via debounced method + */ + self.isScrollingVertically = false; + + /** + * @ngdoc boolean + * @name isScrollingHorizontally + * @propertyOf ui.grid.class:Grid + * @description set to true when Grid is scrolling horizontally. Set to false via debounced method + */ + self.isScrollingHorizontally = false; + + /** + * @ngdoc property + * @name scrollDirection + * @propertyOf ui.grid.class:Grid + * @description set one of the {@link ui.grid.service:uiGridConstants#properties_scrollDirection uiGridConstants.scrollDirection} + * values (UP, DOWN, LEFT, RIGHT, NONE), which tells us which direction we are scrolling. + * Set to NONE via debounced method + */ + self.scrollDirection = uiGridConstants.scrollDirection.NONE; + + //if true, grid will not respond to any scroll events + self.disableScrolling = false; + + + function vertical (scrollEvent) { + self.isScrollingVertically = false; + self.api.core.raise.scrollEnd(scrollEvent); + self.scrollDirection = uiGridConstants.scrollDirection.NONE; + } + + var debouncedVertical = gridUtil.debounce(vertical, self.options.scrollDebounce); + var debouncedVerticalMinDelay = gridUtil.debounce(vertical, 0); + + function horizontal (scrollEvent) { + self.isScrollingHorizontally = false; + self.api.core.raise.scrollEnd(scrollEvent); + self.scrollDirection = uiGridConstants.scrollDirection.NONE; + } + + var debouncedHorizontal = gridUtil.debounce(horizontal, self.options.scrollDebounce); + var debouncedHorizontalMinDelay = gridUtil.debounce(horizontal, 0); + + + /** + * @ngdoc function + * @name flagScrollingVertically + * @methodOf ui.grid.class:Grid + * @description sets isScrollingVertically to true and sets it to false in a debounced function + */ + self.flagScrollingVertically = function(scrollEvent) { + if (!self.isScrollingVertically && !self.isScrollingHorizontally) { + self.api.core.raise.scrollBegin(scrollEvent); + } + self.isScrollingVertically = true; + if (self.options.scrollDebounce === 0 || !scrollEvent.withDelay) { + debouncedVerticalMinDelay(scrollEvent); + } + else { + debouncedVertical(scrollEvent); + } + }; + + /** + * @ngdoc function + * @name flagScrollingHorizontally + * @methodOf ui.grid.class:Grid + * @description sets isScrollingHorizontally to true and sets it to false in a debounced function + */ + self.flagScrollingHorizontally = function(scrollEvent) { + if (!self.isScrollingVertically && !self.isScrollingHorizontally) { + self.api.core.raise.scrollBegin(scrollEvent); + } + self.isScrollingHorizontally = true; + if (self.options.scrollDebounce === 0 || !scrollEvent.withDelay) { + debouncedHorizontalMinDelay(scrollEvent); + } + else { + debouncedHorizontal(scrollEvent); + } + }; + + self.scrollbarHeight = 0; + self.scrollbarWidth = 0; + if (self.options.enableHorizontalScrollbar !== uiGridConstants.scrollbars.NEVER) { + self.scrollbarHeight = gridUtil.getScrollbarWidth(); + } + + if (self.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER) { + self.scrollbarWidth = gridUtil.getScrollbarWidth(); + } + + + + self.api = new GridApi(self); + + /** + * @ngdoc function + * @name refresh + * @methodOf ui.grid.core.api:PublicApi + * @description Refresh the rendered grid on screen. + * The refresh method re-runs both the columnProcessors and the + * rowProcessors, as well as calling refreshCanvas to update all + * the grid sizing. In general you should prefer to use queueGridRefresh + * instead, which is basically a debounced version of refresh. + * + * If you only want to resize the grid, not regenerate all the rows + * and columns, you should consider directly calling refreshCanvas instead. + * + * @param {boolean} [rowsAltered] Optional flag for refreshing when the number of rows has changed + */ + self.api.registerMethod( 'core', 'refresh', this.refresh ); + + /** + * @ngdoc function + * @name queueGridRefresh + * @methodOf ui.grid.core.api:PublicApi + * @description Request a refresh of the rendered grid on screen, if multiple + * calls to queueGridRefresh are made within a digest cycle only one will execute. + * The refresh method re-runs both the columnProcessors and the + * rowProcessors, as well as calling refreshCanvas to update all + * the grid sizing. In general you should prefer to use queueGridRefresh + * instead, which is basically a debounced version of refresh. + * + */ + self.api.registerMethod( 'core', 'queueGridRefresh', this.queueGridRefresh ); + + /** + * @ngdoc function + * @name refreshRows + * @methodOf ui.grid.core.api:PublicApi + * @description Runs only the rowProcessors, columns remain as they were. + * It then calls redrawInPlace and refreshCanvas, which adjust the grid sizing. + * @returns {promise} promise that is resolved when render completes? + * + */ + self.api.registerMethod( 'core', 'refreshRows', this.refreshRows ); + + /** + * @ngdoc function + * @name queueRefresh + * @methodOf ui.grid.core.api:PublicApi + * @description Requests execution of refreshCanvas, if multiple requests are made + * during a digest cycle only one will run. RefreshCanvas updates the grid sizing. + * @returns {promise} promise that is resolved when render completes? + * + */ + self.api.registerMethod( 'core', 'queueRefresh', this.queueRefresh ); + + /** + * @ngdoc function + * @name handleWindowResize + * @methodOf ui.grid.core.api:PublicApi + * @description Trigger a grid resize, normally this would be picked + * up by a watch on window size, but in some circumstances it is necessary + * to call this manually + * @returns {promise} promise that is resolved when render completes? + * + */ + self.api.registerMethod( 'core', 'handleWindowResize', this.handleWindowResize ); + + + /** + * @ngdoc function + * @name addRowHeaderColumn + * @methodOf ui.grid.core.api:PublicApi + * @description adds a row header column to the grid + * @param {object} column def + * @param {number} order Determines order of header column on grid. Lower order means header + * is positioned to the left of higher order headers + * + */ + self.api.registerMethod( 'core', 'addRowHeaderColumn', this.addRowHeaderColumn ); + + /** + * @ngdoc function + * @name scrollToIfNecessary + * @methodOf ui.grid.core.api:PublicApi + * @description Scrolls the grid to make a certain row and column combo visible, + * in the case that it is not completely visible on the screen already. + * @param {GridRow} gridRow row to make visible + * @param {GridColumn} gridCol column to make visible + * @returns {promise} a promise that is resolved when scrolling is complete + * + */ + self.api.registerMethod( 'core', 'scrollToIfNecessary', function(gridRow, gridCol) { return self.scrollToIfNecessary(gridRow, gridCol);} ); + + /** + * @ngdoc function + * @name scrollTo + * @methodOf ui.grid.core.api:PublicApi + * @description Scroll the grid such that the specified + * row and column is in view + * @param {object} rowEntity gridOptions.data[] array instance to make visible + * @param {object} colDef to make visible + * @returns {promise} a promise that is resolved after any scrolling is finished + */ + self.api.registerMethod( 'core', 'scrollTo', function (rowEntity, colDef) { return self.scrollTo(rowEntity, colDef);} ); + + /** + * @ngdoc function + * @name registerRowsProcessor + * @methodOf ui.grid.core.api:PublicApi + * @description + * Register a "rows processor" function. When the rows are updated, + * the grid calls each registered "rows processor", which has a chance + * to alter the set of rows (sorting, etc) as long as the count is not + * modified. + * + * @param {function(renderedRowsToProcess, columns )} processorFunction rows processor function, which + * is run in the context of the grid (i.e. this for the function will be the grid), and must + * return the updated rows list, which is passed to the next processor in the chain + * @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room + * for other people to inject rows processors at intermediate priorities. Lower priority rowsProcessors run earlier. + * + * At present allRowsVisible is running at 50, sort manipulations running at 60-65, filter is running at 100, + * sort is at 200, grouping and treeview at 400-410, selectable rows at 500, pagination at 900 (pagination will generally want to be last) + */ + self.api.registerMethod( 'core', 'registerRowsProcessor', this.registerRowsProcessor ); + + /** + * @ngdoc function + * @name registerColumnsProcessor + * @methodOf ui.grid.core.api:PublicApi + * @description + * Register a "columns processor" function. When the columns are updated, + * the grid calls each registered "columns processor", which has a chance + * to alter the set of columns as long as the count is not + * modified. + * + * @param {function(renderedColumnsToProcess, rows )} processorFunction columns processor function, which + * is run in the context of the grid (i.e. this for the function will be the grid), and must + * return the updated columns list, which is passed to the next processor in the chain + * @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room + * for other people to inject columns processors at intermediate priorities. Lower priority columnsProcessors run earlier. + * + * At present allRowsVisible is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at 500, pagination at 900 (pagination will generally want to be last) + */ + self.api.registerMethod( 'core', 'registerColumnsProcessor', this.registerColumnsProcessor ); + + + + /** + * @ngdoc function + * @name sortHandleNulls + * @methodOf ui.grid.core.api:PublicApi + * @description A null handling method that can be used when building custom sort + * functions + * @example + *
    +     *   mySortFn = function(a, b) {
    +     *   var nulls = $scope.gridApi.core.sortHandleNulls(a, b);
    +     *   if ( nulls !== null ){
    +     *     return nulls;
    +     *   } else {
    +     *     // your code for sorting here
    +     *   };
    +     * 
    + * @param {object} a sort value a + * @param {object} b sort value b + * @returns {number} null if there were no nulls/undefineds, otherwise returns + * a sort value that should be passed back from the sort function + * + */ + self.api.registerMethod( 'core', 'sortHandleNulls', rowSorter.handleNulls ); + + + /** + * @ngdoc function + * @name sortChanged + * @methodOf ui.grid.core.api:PublicApi + * @description The sort criteria on one or more columns has + * changed. Provides as parameters the grid and the output of + * getColumnSorting, which is an array of gridColumns + * that have sorting on them, sorted in priority order. + * + * @param {$scope} scope The scope of the controller. This is used to deregister this event when the scope is destroyed. + * @param {Function} callBack Will be called when the event is emited. The function passes back the grid and an array of + * columns with sorts on them, in priority order. + * + * @example + *
    +     *      gridApi.core.on.sortChanged( $scope, function(grid, sortColumns){
    +     *        // do something
    +     *      });
    +     * 
    + */ + self.api.registerEvent( 'core', 'sortChanged' ); + + /** + * @ngdoc function + * @name columnVisibilityChanged + * @methodOf ui.grid.core.api:PublicApi + * @description The visibility of a column has changed, + * the column itself is passed out as a parameter of the event. + * + * @param {$scope} scope The scope of the controller. This is used to deregister this event when the scope is destroyed. + * @param {Function} callBack Will be called when the event is emited. The function passes back the GridCol that has changed. + * + * @example + *
    +     *      gridApi.core.on.columnVisibilityChanged( $scope, function (column) {
    +     *        // do something
    +     *      } );
    +     * 
    + */ + self.api.registerEvent( 'core', 'columnVisibilityChanged' ); + + /** + * @ngdoc method + * @name notifyDataChange + * @methodOf ui.grid.core.api:PublicApi + * @description Notify the grid that a data or config change has occurred, + * where that change isn't something the grid was otherwise noticing. This + * might be particularly relevant where you've changed values within the data + * and you'd like cell classes to be re-evaluated, or changed config within + * the columnDef and you'd like headerCellClasses to be re-evaluated. + * @param {string} type one of the + * {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange} + * values (ALL, ROW, EDIT, COLUMN, OPTIONS), which tells us which refreshes to fire. + * + * - ALL: listeners fired on any of these events, fires listeners on all events. + * - ROW: fired when a row is added or removed. + * - EDIT: fired when the data in a cell is edited. + * - COLUMN: fired when the column definitions are modified. + * - OPTIONS: fired when the grid options are modified. + */ + self.api.registerMethod( 'core', 'notifyDataChange', this.notifyDataChange ); + + /** + * @ngdoc method + * @name clearAllFilters + * @methodOf ui.grid.core.api:PublicApi + * @description Clears all filters and optionally refreshes the visible rows. + * @param {object} refreshRows Defaults to true. + * @param {object} clearConditions Defaults to false. + * @param {object} clearFlags Defaults to false. + * @returns {promise} If `refreshRows` is true, returns a promise of the rows refreshing. + */ + self.api.registerMethod('core', 'clearAllFilters', this.clearAllFilters); + + self.registerDataChangeCallback( self.columnRefreshCallback, [uiGridConstants.dataChange.COLUMN]); + self.registerDataChangeCallback( self.processRowsCallback, [uiGridConstants.dataChange.EDIT]); + self.registerDataChangeCallback( self.updateFooterHeightCallback, [uiGridConstants.dataChange.OPTIONS]); + + self.registerStyleComputation({ + priority: 10, + func: self.getFooterStyles + }); + }; + + Grid.prototype.calcFooterHeight = function () { + if (!this.hasFooter()) { + return 0; + } + + var height = 0; + if (this.options.showGridFooter) { + height += this.options.gridFooterHeight; + } + + height += this.calcColumnFooterHeight(); + + return height; + }; + + Grid.prototype.calcColumnFooterHeight = function () { + var height = 0; + + if (this.options.showColumnFooter) { + height += this.options.columnFooterHeight; + } + + return height; + }; + + Grid.prototype.getFooterStyles = function () { + var style = '.grid' + this.id + ' .ui-grid-footer-aggregates-row { height: ' + this.options.columnFooterHeight + 'px; }'; + style += ' .grid' + this.id + ' .ui-grid-footer-info { height: ' + this.options.gridFooterHeight + 'px; }'; + return style; + }; + + Grid.prototype.hasFooter = function () { + return this.options.showGridFooter || this.options.showColumnFooter; + }; + + /** + * @ngdoc function + * @name isRTL + * @methodOf ui.grid.class:Grid + * @description Returns true if grid is RightToLeft + */ + Grid.prototype.isRTL = function () { + return this.rtl; + }; + + + /** + * @ngdoc function + * @name registerColumnBuilder + * @methodOf ui.grid.class:Grid + * @description When the build creates columns from column definitions, the columnbuilders will be called to add + * additional properties to the column. + * @param {function(colDef, col, gridOptions)} columnBuilder function to be called + */ + Grid.prototype.registerColumnBuilder = function registerColumnBuilder(columnBuilder) { + this.columnBuilders.push(columnBuilder); + }; + + /** + * @ngdoc function + * @name buildColumnDefsFromData + * @methodOf ui.grid.class:Grid + * @description Populates columnDefs from the provided data + * @param {function(colDef, col, gridOptions)} rowBuilder function to be called + */ + Grid.prototype.buildColumnDefsFromData = function (dataRows){ + this.options.columnDefs = gridUtil.getColumnsFromData(dataRows, this.options.excludeProperties); + }; + + /** + * @ngdoc function + * @name registerRowBuilder + * @methodOf ui.grid.class:Grid + * @description When the build creates rows from gridOptions.data, the rowBuilders will be called to add + * additional properties to the row. + * @param {function(row, gridOptions)} rowBuilder function to be called + */ + Grid.prototype.registerRowBuilder = function registerRowBuilder(rowBuilder) { + this.rowBuilders.push(rowBuilder); + }; + + + /** + * @ngdoc function + * @name registerDataChangeCallback + * @methodOf ui.grid.class:Grid + * @description When a data change occurs, the data change callbacks of the specified type + * will be called. The rules are: + * + * - when the data watch fires, that is considered a ROW change (the data watch only notices + * added or removed rows) + * - when the api is called to inform us of a change, the declared type of that change is used + * - when a cell edit completes, the EDIT callbacks are triggered + * - when the columnDef watch fires, the COLUMN callbacks are triggered + * - when the options watch fires, the OPTIONS callbacks are triggered + * + * For a given event: + * - ALL calls ROW, EDIT, COLUMN, OPTIONS and ALL callbacks + * - ROW calls ROW and ALL callbacks + * - EDIT calls EDIT and ALL callbacks + * - COLUMN calls COLUMN and ALL callbacks + * - OPTIONS calls OPTIONS and ALL callbacks + * + * @param {function(grid)} callback function to be called + * @param {array} types the types of data change you want to be informed of. Values from + * the {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange} + * values ( ALL, EDIT, ROW, COLUMN, OPTIONS ). Optional and defaults to ALL + * @returns {function} deregister function - a function that can be called to deregister this callback + */ + Grid.prototype.registerDataChangeCallback = function registerDataChangeCallback(callback, types, _this) { + var uid = gridUtil.nextUid(); + if ( !types ){ + types = [uiGridConstants.dataChange.ALL]; + } + if ( !Array.isArray(types)){ + gridUtil.logError("Expected types to be an array or null in registerDataChangeCallback, value passed was: " + types ); + } + this.dataChangeCallbacks[uid] = { callback: callback, types: types, _this:_this }; + + var self = this; + var deregisterFunction = function() { + delete self.dataChangeCallbacks[uid]; + }; + return deregisterFunction; + }; + + /** + * @ngdoc function + * @name callDataChangeCallbacks + * @methodOf ui.grid.class:Grid + * @description Calls the callbacks based on the type of data change that + * has occurred. Always calls the ALL callbacks, calls the ROW, EDIT, COLUMN and OPTIONS callbacks if the + * event type is matching, or if the type is ALL. + * @param {string} type the type of event that occurred - one of the + * {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange} + * values (ALL, ROW, EDIT, COLUMN, OPTIONS) + */ + Grid.prototype.callDataChangeCallbacks = function callDataChangeCallbacks(type, options) { + angular.forEach( this.dataChangeCallbacks, function( callback, uid ){ + if ( callback.types.indexOf( uiGridConstants.dataChange.ALL ) !== -1 || + callback.types.indexOf( type ) !== -1 || + type === uiGridConstants.dataChange.ALL ) { + if (callback._this) { + callback.callback.apply(callback._this, this, options); + } + else { + callback.callback(this, options); + } + } + }, this); + }; + + /** + * @ngdoc function + * @name notifyDataChange + * @methodOf ui.grid.class:Grid + * @description Notifies us that a data change has occurred, used in the public + * api for users to tell us when they've changed data or some other event that + * our watches cannot pick up + * @param {string} type the type of event that occurred - one of the + * uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN, OPTIONS) + * + * - ALL: listeners fired on any of these events, fires listeners on all events. + * - ROW: fired when a row is added or removed. + * - EDIT: fired when the data in a cell is edited. + * - COLUMN: fired when the column definitions are modified. + * - OPTIONS: fired when the grid options are modified. + */ + Grid.prototype.notifyDataChange = function notifyDataChange(type) { + var constants = uiGridConstants.dataChange; + if ( type === constants.ALL || + type === constants.COLUMN || + type === constants.EDIT || + type === constants.ROW || + type === constants.OPTIONS ){ + this.callDataChangeCallbacks( type ); + } else { + gridUtil.logError("Notified of a data change, but the type was not recognised, so no action taken, type was: " + type); + } + }; + + + /** + * @ngdoc function + * @name columnRefreshCallback + * @methodOf ui.grid.class:Grid + * @description refreshes the grid when a column refresh + * is notified, which triggers handling of the visible flag. + * This is called on uiGridConstants.dataChange.COLUMN, and is + * registered as a dataChangeCallback in grid.js + * @param {object} grid The grid object. + * @param {object} options Any options passed into the callback. + */ + Grid.prototype.columnRefreshCallback = function columnRefreshCallback(grid, options){ + grid.buildColumns(options); + grid.queueGridRefresh(); + }; + + + /** + * @ngdoc function + * @name processRowsCallback + * @methodOf ui.grid.class:Grid + * @description calls the row processors, specifically + * intended to reset the sorting when an edit is called, + * registered as a dataChangeCallback on uiGridConstants.dataChange.EDIT + * @param {string} name column name + */ + Grid.prototype.processRowsCallback = function processRowsCallback( grid ){ + grid.queueGridRefresh(); + }; + + + /** + * @ngdoc function + * @name updateFooterHeightCallback + * @methodOf ui.grid.class:Grid + * @description recalculates the footer height, + * registered as a dataChangeCallback on uiGridConstants.dataChange.OPTIONS + * @param {string} name column name + */ + Grid.prototype.updateFooterHeightCallback = function updateFooterHeightCallback( grid ){ + grid.footerHeight = grid.calcFooterHeight(); + grid.columnFooterHeight = grid.calcColumnFooterHeight(); + }; + + + /** + * @ngdoc function + * @name getColumn + * @methodOf ui.grid.class:Grid + * @description returns a grid column for the column name + * @param {string} name column name + */ + Grid.prototype.getColumn = function getColumn(name) { + var columns = this.columns.filter(function (column) { + return column.colDef.name === name; + }); + return columns.length > 0 ? columns[0] : null; + }; + + /** + * @ngdoc function + * @name getColDef + * @methodOf ui.grid.class:Grid + * @description returns a grid colDef for the column name + * @param {string} name column.field + */ + Grid.prototype.getColDef = function getColDef(name) { + var colDefs = this.options.columnDefs.filter(function (colDef) { + return colDef.name === name; + }); + return colDefs.length > 0 ? colDefs[0] : null; + }; + + /** + * @ngdoc function + * @name assignTypes + * @methodOf ui.grid.class:Grid + * @description uses the first row of data to assign colDef.type for any types not defined. + */ + /** + * @ngdoc property + * @name type + * @propertyOf ui.grid.class:GridOptions.columnDef + * @description the type of the column, used in sorting. If not provided then the + * grid will guess the type. Add this only if the grid guessing is not to your + * satisfaction. One of: + * - 'string' + * - 'boolean' + * - 'number' + * - 'date' + * - 'object' + * - 'numberStr' + * Note that if you choose date, your dates should be in a javascript date type + * + */ + Grid.prototype.assignTypes = function(){ + var self = this; + self.options.columnDefs.forEach(function (colDef, index) { + + //Assign colDef type if not specified + if (!colDef.type) { + var col = new GridColumn(colDef, index, self); + var firstRow = self.rows.length > 0 ? self.rows[0] : null; + if (firstRow) { + colDef.type = gridUtil.guessType(self.getCellValue(firstRow, col)); + } + else { + colDef.type = 'string'; + } + } + }); + }; + + + /** + * @ngdoc function + * @name isRowHeaderColumn + * @methodOf ui.grid.class:Grid + * @description returns true if the column is a row Header + * @param {object} column column + */ + Grid.prototype.isRowHeaderColumn = function isRowHeaderColumn(column) { + return this.rowHeaderColumns.indexOf(column) !== -1; + }; + + /** + * @ngdoc function + * @name addRowHeaderColumn + * @methodOf ui.grid.class:Grid + * @description adds a row header column to the grid + * @param {object} colDef Column definition object. + * @param {float} order Number that indicates where the column should be placed in the grid. + * @param {boolean} stopColumnBuild Prevents the buildColumn callback from being triggered. This is useful to improve + * performance of the grid during initial load. + */ + Grid.prototype.addRowHeaderColumn = function addRowHeaderColumn(colDef, order, stopColumnBuild) { + var self = this; + + //default order + if (order === undefined) { + order = 0; + } + + var rowHeaderCol = new GridColumn(colDef, gridUtil.nextUid(), self); + rowHeaderCol.isRowHeader = true; + if (self.isRTL()) { + self.createRightContainer(); + rowHeaderCol.renderContainer = 'right'; + } + else { + self.createLeftContainer(); + rowHeaderCol.renderContainer = 'left'; + } + + // relies on the default column builder being first in array, as it is instantiated + // as part of grid creation + self.columnBuilders[0](colDef,rowHeaderCol,self.options) + .then(function(){ + rowHeaderCol.enableFiltering = false; + rowHeaderCol.enableSorting = false; + rowHeaderCol.enableHiding = false; + rowHeaderCol.headerPriority = order; + self.rowHeaderColumns.push(rowHeaderCol); + self.rowHeaderColumns = self.rowHeaderColumns.sort(function (a, b) { + return a.headerPriority - b.headerPriority; + }); + + if (!stopColumnBuild) { + self.buildColumns() + .then(function() { + self.preCompileCellTemplates(); + self.queueGridRefresh(); + }).catch(angular.noop); + } + }).catch(angular.noop); + }; + + /** + * @ngdoc function + * @name getOnlyDataColumns + * @methodOf ui.grid.class:Grid + * @description returns all columns except for rowHeader columns + */ + Grid.prototype.getOnlyDataColumns = function getOnlyDataColumns() { + var self = this; + var cols = []; + self.columns.forEach(function (col) { + if (self.rowHeaderColumns.indexOf(col) === -1) { + cols.push(col); + } + }); + return cols; + }; + + /** + * @ngdoc function + * @name buildColumns + * @methodOf ui.grid.class:Grid + * @description creates GridColumn objects from the columnDefinition. Calls each registered + * columnBuilder to further process the column + * @param {object} options An object contains options to use when building columns + * + * * **orderByColumnDefs**: defaults to **false**. When true, `buildColumns` will reorder existing columns according to the order within the column definitions. + * + * @returns {Promise} a promise to load any needed column resources + */ + Grid.prototype.buildColumns = function buildColumns(opts) { + var options = { + orderByColumnDefs: false + }; + + angular.extend(options, opts); + + // gridUtil.logDebug('buildColumns'); + var self = this; + var builderPromises = []; + var headerOffset = self.rowHeaderColumns.length; + var i; + + // Remove any columns for which a columnDef cannot be found + // Deliberately don't use forEach, as it doesn't like splice being called in the middle + // Also don't cache columns.length, as it will change during this operation + for (i = 0; i < self.columns.length; i++){ + if (!self.getColDef(self.columns[i].name)) { + self.columns.splice(i, 1); + i--; + } + } + + //add row header columns to the grid columns array _after_ columns without columnDefs have been removed + //rowHeaderColumns is ordered by priority so insert in reverse + for (var j = self.rowHeaderColumns.length - 1; j >= 0; j--) { + self.columns.unshift(self.rowHeaderColumns[j]); + } + + + + // look at each column def, and update column properties to match. If the column def + // doesn't have a column, then splice in a new gridCol + self.options.columnDefs.forEach(function (colDef, index) { + self.preprocessColDef(colDef); + var col = self.getColumn(colDef.name); + + if (!col) { + col = new GridColumn(colDef, gridUtil.nextUid(), self); + self.columns.splice(index + headerOffset, 0, col); + } + else { + // tell updateColumnDef that the column was pre-existing + col.updateColumnDef(colDef, false); + } + + self.columnBuilders.forEach(function (builder) { + builderPromises.push(builder.call(self, colDef, col, self.options)); + }); + }); + + /*** Reorder columns if necessary ***/ + if (!!options.orderByColumnDefs) { + // Create a shallow copy of the columns as a cache + var columnCache = self.columns.slice(0); + + // We need to allow for the "row headers" when mapping from the column defs array to the columns array + // If we have a row header in columns[0] and don't account for it we'll overwrite it with the column in columnDefs[0] + + // Go through all the column defs, use the shorter of columns length and colDefs.length because if a user has given two columns the same name then + // columns will be shorter than columnDefs. In this situation we'll avoid an error, but the user will still get an unexpected result + var len = Math.min(self.options.columnDefs.length, self.columns.length); + for (i = 0; i < len; i++) { + // If the column at this index has a different name than the column at the same index in the column defs... + if (self.columns[i + headerOffset].name !== self.options.columnDefs[i].name) { + // Replace the one in the cache with the appropriate column + columnCache[i + headerOffset] = self.getColumn(self.options.columnDefs[i].name); + } + else { + // Otherwise just copy over the one from the initial columns + columnCache[i + headerOffset] = self.columns[i + headerOffset]; + } + } + + // Empty out the columns array, non-destructively + self.columns.length = 0; + + // And splice in the updated, ordered columns from the cache + Array.prototype.splice.apply(self.columns, [0, 0].concat(columnCache)); + } + + return $q.all(builderPromises).then(function(){ + if (self.rows.length > 0){ + self.assignTypes(); + } + if (options.preCompileCellTemplates) { + self.preCompileCellTemplates(); + } + }).catch(angular.noop); + }; + + Grid.prototype.preCompileCellTemplate = function(col) { + var self = this; + var html = col.cellTemplate.replace(uiGridConstants.MODEL_COL_FIELD, self.getQualifiedColField(col)); + html = html.replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)'); + + col.compiledElementFn = $compile(html); + + if (col.compiledElementFnDefer) { + col.compiledElementFnDefer.resolve(col.compiledElementFn); + } + }; + +/** + * @ngdoc function + * @name preCompileCellTemplates + * @methodOf ui.grid.class:Grid + * @description precompiles all cell templates + */ + Grid.prototype.preCompileCellTemplates = function() { + var self = this; + self.columns.forEach(function (col) { + if ( col.cellTemplate ){ + self.preCompileCellTemplate( col ); + } else if ( col.cellTemplatePromise ){ + col.cellTemplatePromise.then( function() { + self.preCompileCellTemplate( col ); + }).catch(angular.noop); + } + }); + }; + + /** + * @ngdoc function + * @name getGridQualifiedColField + * @methodOf ui.grid.class:Grid + * @description Returns the $parse-able accessor for a column within its $scope + * @param {GridColumn} col col object + */ + Grid.prototype.getQualifiedColField = function (col) { + var base = 'row.entity'; + if ( col.field === uiGridConstants.ENTITY_BINDING ) { + return base; + } + return gridUtil.preEval(base + '.' + col.field); + }; + + /** + * @ngdoc function + * @name createLeftContainer + * @methodOf ui.grid.class:Grid + * @description creates the left render container if it doesn't already exist + */ + Grid.prototype.createLeftContainer = function() { + if (!this.hasLeftContainer()) { + this.renderContainers.left = new GridRenderContainer('left', this, { disableColumnOffset: true }); + } + }; + + /** + * @ngdoc function + * @name createRightContainer + * @methodOf ui.grid.class:Grid + * @description creates the right render container if it doesn't already exist + */ + Grid.prototype.createRightContainer = function() { + if (!this.hasRightContainer()) { + this.renderContainers.right = new GridRenderContainer('right', this, { disableColumnOffset: true }); + } + }; + + /** + * @ngdoc function + * @name hasLeftContainer + * @methodOf ui.grid.class:Grid + * @description returns true if leftContainer exists + */ + Grid.prototype.hasLeftContainer = function() { + return this.renderContainers.left !== undefined; + }; + + /** + * @ngdoc function + * @name hasRightContainer + * @methodOf ui.grid.class:Grid + * @description returns true if rightContainer exists + */ + Grid.prototype.hasRightContainer = function() { + return this.renderContainers.right !== undefined; + }; + + + /** + * undocumented function + * @name preprocessColDef + * @methodOf ui.grid.class:Grid + * @description defaults the name property from field to maintain backwards compatibility with 2.x + * validates that name or field is present + */ + Grid.prototype.preprocessColDef = function preprocessColDef(colDef) { + var self = this; + + if (!colDef.field && !colDef.name) { + throw new Error('colDef.name or colDef.field property is required'); + } + + //maintain backwards compatibility with 2.x + //field was required in 2.x. now name is required + if (colDef.name === undefined && colDef.field !== undefined) { + // See if the column name already exists: + var newName = colDef.field, + counter = 2; + while (self.getColumn(newName)) { + newName = colDef.field + counter.toString(); + counter++; + } + colDef.name = newName; + } + }; + + // Return a list of items that exist in the `n` array but not the `o` array. Uses optional property accessors passed as third & fourth parameters + Grid.prototype.newInN = function newInN(o, n, oAccessor, nAccessor) { + var self = this; + + var t = []; + for (var i = 0; i < n.length; i++) { + var nV = nAccessor ? n[i][nAccessor] : n[i]; + + var found = false; + for (var j = 0; j < o.length; j++) { + var oV = oAccessor ? o[j][oAccessor] : o[j]; + if (self.options.rowEquality(nV, oV)) { + found = true; + break; + } + } + if (!found) { + t.push(nV); + } + } + + return t; + }; + + /** + * @ngdoc function + * @name getRow + * @methodOf ui.grid.class:Grid + * @description returns the GridRow that contains the rowEntity + * @param {object} rowEntity the gridOptions.data array element instance + * @param {array} lookInRows [optional] the rows to look in - if not provided then + * looks in grid.rows + */ + Grid.prototype.getRow = function getRow(rowEntity, lookInRows) { + var self = this; + + lookInRows = typeof(lookInRows) === 'undefined' ? self.rows : lookInRows; + + var rows = lookInRows.filter(function (row) { + return self.options.rowEquality(row.entity, rowEntity); + }); + return rows.length > 0 ? rows[0] : null; + }; + + + /** + * @ngdoc function + * @name modifyRows + * @methodOf ui.grid.class:Grid + * @description creates or removes GridRow objects from the newRawData array. Calls each registered + * rowBuilder to further process the row + * @param {array} newRawData Modified set of data + * + * This method aims to achieve three things: + * 1. the resulting rows array is in the same order as the newRawData, we'll call + * rowsProcessors immediately after to sort the data anyway + * 2. if we have row hashing available, we try to use the rowHash to find the row + * 3. no memory leaks - rows that are no longer in newRawData need to be garbage collected + * + * The basic logic flow makes use of the newRawData, oldRows and oldHash, and creates + * the newRows and newHash + * + * ``` + * newRawData.forEach newEntity + * if (hashing enabled) + * check oldHash for newEntity + * else + * look for old row directly in oldRows + * if !oldRowFound // must be a new row + * create newRow + * append to the newRows and add to newHash + * run the processors + * ``` + * + * Rows are identified using the hashKey if configured. If not configured, then rows + * are identified using the gridOptions.rowEquality function + * + * This method is useful when trying to select rows immediately after loading data without + * using a $timeout/$interval, e.g.: + * + * $scope.gridOptions.data = someData; + * $scope.gridApi.grid.modifyRows($scope.gridOptions.data); + * $scope.gridApi.selection.selectRow($scope.gridOptions.data[0]); + * + * OR to persist row selection after data update (e.g. rows selected, new data loaded, want + * originally selected rows to be re-selected)) + */ + Grid.prototype.modifyRows = function modifyRows(newRawData) { + var self = this; + var oldRows = self.rows.slice(0); + var oldRowHash = self.rowHashMap || self.createRowHashMap(); + var allRowsSelected = true; + self.rowHashMap = self.createRowHashMap(); + self.rows.length = 0; + + newRawData.forEach( function( newEntity, i ) { + var newRow, oldRow; + + if ( self.options.enableRowHashing ){ + // if hashing is enabled, then this row will be in the hash if we already know about it + oldRow = oldRowHash.get( newEntity ); + } else { + // otherwise, manually search the oldRows to see if we can find this row + oldRow = self.getRow(newEntity, oldRows); + } + + // update newRow to have an entity + if ( oldRow ) { + newRow = oldRow; + newRow.entity = newEntity; + } + + // if we didn't find the row, it must be new, so create it + if ( !newRow ){ + newRow = self.processRowBuilders(new GridRow(newEntity, i, self)); + } + + self.rows.push( newRow ); + self.rowHashMap.put( newEntity, newRow ); + if (!newRow.isSelected) { + allRowsSelected = false; + } + }); + + if (self.selection && self.rows.length) { + self.selection.selectAll = allRowsSelected; + } + + self.assignTypes(); + + var p1 = $q.when(self.processRowsProcessors(self.rows)) + .then(function (renderableRows) { + return self.setVisibleRows(renderableRows); + }).catch(angular.noop); + + var p2 = $q.when(self.processColumnsProcessors(self.columns)) + .then(function (renderableColumns) { + return self.setVisibleColumns(renderableColumns); + }).catch(angular.noop); + + return $q.all([p1, p2]); + }; + + + /** + * Private Undocumented Method + * @name addRows + * @methodOf ui.grid.class:Grid + * @description adds the newRawData array of rows to the grid and calls all registered + * rowBuilders. this keyword will reference the grid + */ + Grid.prototype.addRows = function addRows(newRawData) { + var self = this; + + var existingRowCount = self.rows.length; + for (var i = 0; i < newRawData.length; i++) { + var newRow = self.processRowBuilders(new GridRow(newRawData[i], i + existingRowCount, self)); + + if (self.options.enableRowHashing) { + var found = self.rowHashMap.get(newRow.entity); + if (found) { + found.row = newRow; + } + } + + self.rows.push(newRow); + } + }; + + /** + * @ngdoc function + * @name processRowBuilders + * @methodOf ui.grid.class:Grid + * @description processes all RowBuilders for the gridRow + * @param {GridRow} gridRow reference to gridRow + * @returns {GridRow} the gridRow with all additional behavior added + */ + Grid.prototype.processRowBuilders = function processRowBuilders(gridRow) { + var self = this; + + self.rowBuilders.forEach(function (builder) { + builder.call(self, gridRow, self.options); + }); + + return gridRow; + }; + + /** + * @ngdoc function + * @name registerStyleComputation + * @methodOf ui.grid.class:Grid + * @description registered a styleComputation function + * + * If the function returns a value it will be appended into the grid's `
    " + ); + + + $templateCache.put('ui-grid/uiGridCell', + "
    {{COL_FIELD CUSTOM_FILTERS}}
    " + ); + + + $templateCache.put('ui-grid/uiGridColumnMenu', + "
    " + ); + + + $templateCache.put('ui-grid/uiGridFooterCell', + "
    {{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}
    " + ); + + + $templateCache.put('ui-grid/uiGridHeaderCell', + "
    {{ col.displayName CUSTOM_FILTERS }} {{col.sort.priority + 1}}
     
    " + ); + + + $templateCache.put('ui-grid/uiGridMenu', + "
    " + ); + + + $templateCache.put('ui-grid/uiGridMenuItem', + "" + ); + + + $templateCache.put('ui-grid/uiGridRenderContainer', + "
    " + ); + + + $templateCache.put('ui-grid/uiGridViewport', + "
    " + ); + + + $templateCache.put('ui-grid/cellEditor', + "
    " + ); + + + $templateCache.put('ui-grid/dropdownEditor', + "
    " + ); + + + $templateCache.put('ui-grid/fileChooserEditor', + "
    " + ); + + + $templateCache.put('ui-grid/emptyBaseLayerContainer', + "
    " + ); + + + $templateCache.put('ui-grid/expandableRow', + "
    " + ); + + + $templateCache.put('ui-grid/expandableRowHeader', + "
    " + ); + + + $templateCache.put('ui-grid/expandableScrollFiller', + "
    " + ); + + + $templateCache.put('ui-grid/expandableTopRowHeader', + "
    " + ); + + + $templateCache.put('ui-grid/csvLink', + "LINK_LABEL" + ); + + + $templateCache.put('ui-grid/importerMenuItem', + "
  • " + ); + + + $templateCache.put('ui-grid/importerMenuItemContainer', + "
    " + ); + + + $templateCache.put('ui-grid/pagination', + "
    0\">/ {{ paginationApi.getTotalPages() }}
    1 && !grid.options.useCustomPagination\"> {{sizesLabel}}
    {{grid.options.paginationPageSize}} {{sizesLabel}}
    0\">{{ 1 + paginationApi.getFirstRowIndex() }} - {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
    " + ); + + + $templateCache.put('ui-grid/columnResizer', + "
    " + ); + + + $templateCache.put('ui-grid/gridFooterSelectedItems', + "({{\"search.selectedItems\" | t}} {{grid.selection.selectedCount}})" + ); + + + $templateCache.put('ui-grid/selectionHeaderCell', + "
    " + ); + + + $templateCache.put('ui-grid/selectionRowHeader', + "
    " + ); + + + $templateCache.put('ui-grid/selectionRowHeaderButtons', + "
     
    " + ); + + + $templateCache.put('ui-grid/selectionSelectAllButtons', + "
    " + ); + + + $templateCache.put('ui-grid/treeBaseExpandAllButtons', + "
    " + ); + + + $templateCache.put('ui-grid/treeBaseHeaderCell', + "
    " + ); + + + $templateCache.put('ui-grid/treeBaseRowHeader', + "
    " + ); + + + $templateCache.put('ui-grid/treeBaseRowHeaderButtons', + "
    -1 }\" ng-click=\"treeButtonClick(row, $event)\">  
    " + ); + + + $templateCache.put('ui-grid/cellTitleValidator', + "
    {{COL_FIELD CUSTOM_FILTERS}}
    " + ); + + + $templateCache.put('ui-grid/cellTooltipValidator', + "
    {{COL_FIELD CUSTOM_FILTERS}}
    " + ); + +}]); diff --git a/release/4.4.11/ui-grid.min.css b/release/4.4.11/ui-grid.min.css new file mode 100644 index 000000000..c6df1a1ac --- /dev/null +++ b/release/4.4.11/ui-grid.min.css @@ -0,0 +1,4 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */@media screen and (max-width:767px){}@media (min-width:768px){}.ui-grid{border:1px solid #d4d4d4;box-sizing:content-box;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-transform:translateZ(0);-moz-transform:translateZ(0);-o-transform:translateZ(0);-ms-transform:translateZ(0);transform:translateZ(0)}.ui-grid-vertical-bar{position:absolute;right:0;width:0}.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar,.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{width:1px}.ui-grid-scrollbar-placeholder{background-color:transparent}.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#d4d4d4}.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#d4d4d4}.ui-grid-header-cell:last-child .ui-grid-vertical-bar{right:-1px;width:1px;background-color:#d4d4d4}.ui-grid-clearfix:before,.ui-grid-clearfix:after{content:"";display:table}.ui-grid-clearfix:after{clear:both}.ui-grid-invisible{visibility:hidden}.ui-grid-contents-wrapper{position:relative;height:100%;width:100%}.ui-grid-sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.ui-grid-icon-button{background-color:transparent;border:none;padding:0}.ui-grid-top-panel-background{background-color:#f3f3f3}.ui-grid-header{border-bottom:1px solid #d4d4d4;box-sizing:border-box}.ui-grid-top-panel{position:relative;overflow:hidden;font-weight:bold;background-color:#f3f3f3;-webkit-border-top-right-radius:-1px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:-1px;-moz-border-radius-topright:-1px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:-1px;border-top-right-radius:-1px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:-1px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.ui-grid-header-viewport{overflow:hidden}.ui-grid-header-canvas:before,.ui-grid-header-canvas:after{content:"";display:table;line-height:0}.ui-grid-header-canvas:after{clear:both}.ui-grid-header-cell-wrapper{position:relative;display:table;box-sizing:border-box;height:100%}.ui-grid-header-cell-row{display:table-row}.ui-grid-header-cell{position:relative;box-sizing:border-box;background-color:inherit;border-right:1px solid;border-color:#d4d4d4;display:table-cell;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:0}.ui-grid-header-cell:last-child{border-right:0}.ui-grid-header-cell .sortable{cursor:pointer}.ui-grid-header-cell .ui-grid-sort-priority-number{margin-left:-8px}.ui-grid-header .ui-grid-vertical-bar{top:0;bottom:0}.ui-grid-column-menu-button{position:absolute;right:1px;top:0}.ui-grid-column-menu-button .ui-grid-icon-angle-down{vertical-align:sub}.ui-grid-header-cell-last-col .ui-grid-cell-contents,.ui-grid-header-cell-last-col .ui-grid-filter-container,.ui-grid-header-cell-last-col .ui-grid-column-menu-button,.ui-grid-header-cell-last-col+.ui-grid-column-resizer.right{margin-right:13px}.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-cell-contents,.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-filter-container,.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-column-menu-button,.ui-grid-render-container-right .ui-grid-header-cell-last-col+.ui-grid-column-resizer.right{margin-right:28px}.ui-grid-column-menu{position:absolute}.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove{-webkit-transition:all .04s linear;-moz-transition:all .04s linear;-o-transition:all .04s linear;transition:all .04s linear;display:block !important}.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add.ng-hide-add-active,.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove{-webkit-transform:translateY(-100%);-moz-transform:translateY(-100%);-o-transform:translateY(-100%);-ms-transform:translateY(-100%);transform:translateY(-100%)}.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove.ng-hide-remove-active{-webkit-transform:translateY(0);-moz-transform:translateY(0);-o-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove{-webkit-transition:all .04s linear;-moz-transition:all .04s linear;-o-transition:all .04s linear;transition:all .04s linear;display:block !important}.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add.ng-hide-add-active,.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove{-webkit-transform:translateY(-100%);-moz-transform:translateY(-100%);-o-transform:translateY(-100%);-ms-transform:translateY(-100%);transform:translateY(-100%)}.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove.ng-hide-remove-active{-webkit-transform:translateY(0);-moz-transform:translateY(0);-o-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.ui-grid-filter-container{padding:4px 10px;position:relative}.ui-grid-filter-container .ui-grid-filter-button{position:absolute;top:0;bottom:0;right:0}.ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"]{position:absolute;top:50%;line-height:32px;margin-top:-16px;right:10px;opacity:.66}.ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"]:hover{opacity:1}.ui-grid-filter-container .ui-grid-filter-button-select{position:absolute;top:0;bottom:0;right:0}.ui-grid-filter-container .ui-grid-filter-button-select [class^="ui-grid-icon"]{position:absolute;top:50%;line-height:32px;margin-top:-16px;right:0;opacity:.66}.ui-grid-filter-container .ui-grid-filter-button-select [class^="ui-grid-icon"]:hover{opacity:1}input[type="text"].ui-grid-filter-input{box-sizing:border-box;padding:0 18px 0 0;margin:0;border:0;width:100%;border:1px solid #d4d4d4;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}input[type="text"].ui-grid-filter-input:hover{border:1px solid #d4d4d4}select.ui-grid-filter-select{padding:0;margin:0;border:0;width:90%;border:1px solid #d4d4d4;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}select.ui-grid-filter-select:hover{border:1px solid #d4d4d4}.ui-grid-filter-cancel-button-hidden select.ui-grid-filter-select{width:100%}.ui-grid-render-container{position:inherit;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.ui-grid-render-container:focus{outline:none}.ui-grid-viewport{min-height:20px;position:relative;overflow-y:scroll;-webkit-overflow-scrolling:touch}.ui-grid-viewport:focus{outline:none !important}.ui-grid-canvas{position:relative;padding-top:1px}.ui-grid-row{clear:both}.ui-grid-row:nth-child(odd) .ui-grid-cell{background-color:#fdfdfd}.ui-grid-row:nth-child(even) .ui-grid-cell{background-color:#f3f3f3}.ui-grid-row:last-child .ui-grid-cell{border-bottom-color:#d4d4d4;border-bottom-style:solid}.ui-grid-no-row-overlay{position:absolute;top:0;bottom:0;left:0;right:0;margin:10%;background-color:#f3f3f3;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #d4d4d4;font-size:2em;text-align:center}.ui-grid-no-row-overlay>*{position:absolute;display:table;margin:auto 0;width:100%;top:0;bottom:0;left:0;right:0;opacity:.66}.ui-grid-cell{overflow:hidden;float:left;background-color:inherit;border-right:1px solid;border-color:#d4d4d4;box-sizing:border-box}.ui-grid-cell:last-child{border-right:0}.ui-grid-cell-contents{padding:5px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;white-space:nowrap;-ms-text-overflow:ellipsis;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;height:100%}.ui-grid-cell-contents-hidden{visibility:hidden;width:0;height:0;display:none}.ui-grid-row .ui-grid-cell.ui-grid-row-header-cell{background-color:#F0F0EE;border-bottom:solid 1px #d4d4d4}.ui-grid-cell-empty{display:inline-block;width:10px;height:10px}.ui-grid-footer-info{padding:5px 10px}.ui-grid-footer-panel-background{background-color:#f3f3f3}.ui-grid-footer-panel{position:relative;border-bottom:1px solid #d4d4d4;border-top:1px solid #d4d4d4;overflow:hidden;font-weight:bold;background-color:#f3f3f3;-webkit-border-top-right-radius:-1px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:-1px;-moz-border-radius-topright:-1px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:-1px;border-top-right-radius:-1px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:-1px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.ui-grid-grid-footer{float:left;width:100%}.ui-grid-footer-viewport,.ui-grid-footer-canvas{display:flex;flex:1 1 auto;height:100%}.ui-grid-footer-viewport{overflow:hidden}.ui-grid-footer-canvas{position:relative}.ui-grid-footer-canvas:before,.ui-grid-footer-canvas:after{content:"";display:table;line-height:0}.ui-grid-footer-canvas:after{clear:both}.ui-grid-footer-cell-wrapper{position:relative;display:table;box-sizing:border-box;height:100%}.ui-grid-footer-cell-row{display:table-row}.ui-grid-footer-cell{overflow:hidden;background-color:inherit;border-right:1px solid;border-color:#d4d4d4;box-sizing:border-box;display:table-cell}.ui-grid-footer-cell:last-child{border-right:0}.ui-grid-menu-button{z-index:2;position:absolute;right:0;top:0;background:#f3f3f3;border:0;border-left:1px solid #d4d4d4;border-bottom:1px solid #d4d4d4;cursor:pointer;height:32px;font-weight:normal}.ui-grid-menu-button .ui-grid-icon-container{margin-top:5px;margin-left:2px}.ui-grid-menu-button .ui-grid-menu{right:0}.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid{overflow:scroll}.ui-grid-menu{overflow:hidden;max-width:320px;z-index:2;position:absolute;right:100%;padding:0 10px 20px 10px;cursor:pointer;box-sizing:border-box}.ui-grid-menu-item{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ui-grid-menu .ui-grid-menu-inner{background:#fff;border:1px solid #d4d4d4;position:relative;white-space:nowrap;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.ui-grid-menu .ui-grid-menu-inner ul{margin:0;padding:0;list-style-type:none}.ui-grid-menu .ui-grid-menu-inner ul li{padding:0}.ui-grid-menu .ui-grid-menu-inner ul li .ui-grid-menu-item{color:#000;min-width:100%;padding:8px;text-align:left;background:transparent;border:none;cursor:default}.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item{cursor:pointer}.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item:hover,.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item:focus{background-color:#b3c4c7}.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item.ui-grid-menu-item-active{background-color:#9cb2b6}.ui-grid-menu .ui-grid-menu-inner ul li:not(:last-child)>.ui-grid-menu-item{border-bottom:1px solid #d4d4d4}.ui-grid-sortarrow{right:5px;position:absolute;width:20px;top:0;bottom:0;background-position:center}.ui-grid-sortarrow.down{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-o-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}@font-face{font-family:'ui-grid';src:url('ui-grid.eot');src:url('ui-grid.eot#iefix') format('embedded-opentype'),url('ui-grid.woff') format('woff'),url('ui-grid.ttf') format('truetype'),url('ui-grid.svg?#ui-grid') format('svg');font-weight:normal;font-style:normal}[class^="ui-grid-icon"]:before,[class*=" ui-grid-icon"]:before{font-family:"ui-grid";font-style:normal;font-weight:normal;speak:none;display:inline-block;text-decoration:inherit;width:1em;margin-right:.2em;text-align:center;font-variant:normal;text-transform:none;line-height:1em;margin-left:.2em}.ui-grid-icon-blank::before{width:1em;content:' '}.ui-grid-icon-plus-squared:before{content:'\c350'}.ui-grid-icon-minus-squared:before{content:'\c351'}.ui-grid-icon-search:before{content:'\c352'}.ui-grid-icon-cancel:before{content:'\c353'}.ui-grid-icon-info-circled:before{content:'\c354'}.ui-grid-icon-lock:before{content:'\c355'}.ui-grid-icon-lock-open:before{content:'\c356'}.ui-grid-icon-pencil:before{content:'\c357'}.ui-grid-icon-down-dir:before{content:'\c358'}.ui-grid-icon-up-dir:before{content:'\c359'}.ui-grid-icon-left-dir:before{content:'\c35a'}.ui-grid-icon-right-dir:before{content:'\c35b'}.ui-grid-icon-left-open:before{content:'\c35c'}.ui-grid-icon-right-open:before{content:'\c35d'}.ui-grid-icon-angle-down:before{content:'\c35e'}.ui-grid-icon-filter:before{content:'\c35f'}.ui-grid-icon-sort-alt-up:before{content:'\c360'}.ui-grid-icon-sort-alt-down:before{content:'\c361'}.ui-grid-icon-ok:before{content:'\c362'}.ui-grid-icon-menu:before{content:'\c363'}.ui-grid-icon-indent-left:before{content:'\e800'}.ui-grid-icon-indent-right:before{content:'\e801'}.ui-grid-icon-spin5:before{content:'\ea61'}.ui-grid[dir=rtl] .ui-grid-header-cell,.ui-grid[dir=rtl] .ui-grid-footer-cell,.ui-grid[dir=rtl] .ui-grid-cell{float:right !important}.ui-grid[dir=rtl] .ui-grid-column-menu-button{position:absolute;left:1px;top:0;right:inherit}.ui-grid[dir=rtl] .ui-grid-cell:first-child,.ui-grid[dir=rtl] .ui-grid-header-cell:first-child,.ui-grid[dir=rtl] .ui-grid-footer-cell:first-child{border-right:0}.ui-grid[dir=rtl] .ui-grid-cell:last-child,.ui-grid[dir=rtl] .ui-grid-header-cell:last-child{border-right:1px solid #d4d4d4;border-left:0}.ui-grid[dir=rtl] .ui-grid-header-cell:first-child .ui-grid-vertical-bar,.ui-grid[dir=rtl] .ui-grid-footer-cell:first-child .ui-grid-vertical-bar,.ui-grid[dir=rtl] .ui-grid-cell:first-child .ui-grid-vertical-bar{width:0}.ui-grid[dir=rtl] .ui-grid-menu-button{z-index:2;position:absolute;left:0;right:auto;background:#f3f3f3;border:1px solid #d4d4d4;cursor:pointer;min-height:27px;font-weight:normal}.ui-grid[dir=rtl] .ui-grid-menu-button .ui-grid-menu{left:0;right:auto}.ui-grid[dir=rtl] .ui-grid-filter-container .ui-grid-filter-button{right:initial;left:0}.ui-grid[dir=rtl] .ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"]{right:initial;left:10px}.ui-grid-animate-spin{-moz-animation:ui-grid-spin 2s infinite linear;-o-animation:ui-grid-spin 2s infinite linear;-webkit-animation:ui-grid-spin 2s infinite linear;animation:ui-grid-spin 2s infinite linear;display:inline-block}@-moz-keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@-webkit-keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@-o-keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@-ms-keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@media screen and (max-width:767px){}@media (min-width:768px){}.ui-grid-cell-focus{outline:0;background-color:#b3c4c7}.ui-grid-focuser{position:absolute;left:0;top:0;z-index:-1;width:100%;height:100%}.ui-grid-focuser:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6)}.ui-grid-offscreen{display:block;position:absolute;left:-10000px;top:-10000px;clip:rect(0, 0, 0, 0)}.ui-grid-cell input{border-radius:inherit;padding:0;width:100%;color:inherit;height:auto;font:inherit;outline:none}.ui-grid-cell input:focus{color:inherit;outline:none}.ui-grid-cell input[type="checkbox"]{margin:9px 0 0 6px;width:auto}.ui-grid-cell input.ng-invalid{border:1px solid #fc8f8f}.ui-grid-cell input.ng-valid{border:1px solid #d4d4d4}.ui-grid-viewport .ui-grid-empty-base-layer-container{position:absolute;overflow:hidden;pointer-events:none;z-index:-1}.expandableRow .ui-grid-row:nth-child(odd) .ui-grid-cell{background-color:#fdfdfd}.expandableRow .ui-grid-row:nth-child(even) .ui-grid-cell{background-color:#f3f3f3}.ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell{pointer-events:none}.ui-grid-expandable-buttons-cell i{pointer-events:all}.scrollFiller{float:left;border:1px solid #d4d4d4}.ui-grid-tree-header-row{font-weight:bold !important}.movingColumn{position:absolute;top:0;border:1px solid #d4d4d4;box-shadow:inset 0 0 14px rgba(0,0,0,0.2)}.movingColumn .ui-grid-icon-angle-down{display:none}@media screen and (max-width:767px){}@media (min-width:768px){}.ui-grid-pager-panel{display:flex;justify-content:space-between;align-items:center;position:absolute;left:0;bottom:0;width:100%;padding-top:3px;padding-bottom:3px;box-sizing:content-box}.ui-grid-pager-container{float:left}.ui-grid-pager-control{padding:5px 0;display:flex;flex-flow:row nowrap;align-items:center;margin-right:10px;margin-left:10px;min-width:135px;float:left}.ui-grid-pager-control button,.ui-grid-pager-control span,.ui-grid-pager-control input{margin-right:4px}.ui-grid-pager-control button{height:25px;min-width:26px;display:inline-block;margin-bottom:0;font-weight:normal;text-align:center;vertical-align:middle;touch-action:manipulation;cursor:pointer;background-image:none;border:1px solid transparent;white-space:nowrap;padding:6px 12px;font-size:14px;line-height:1.42857143;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:#eee;background-color:#f3f3f3;border-color:#ccc}.ui-grid-pager-control button:focus,.ui-grid-pager-control button:active:focus,.ui-grid-pager-control button.active:focus,.ui-grid-pager-control button.focus,.ui-grid-pager-control button:active.focus,.ui-grid-pager-control button.active.focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.ui-grid-pager-control button:hover,.ui-grid-pager-control button:focus,.ui-grid-pager-control button.focus{color:#333;text-decoration:none}.ui-grid-pager-control button:active,.ui-grid-pager-control button.active{outline:0;background-image:none;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.ui-grid-pager-control button.disabled,.ui-grid-pager-control button[disabled],fieldset[disabled] .ui-grid-pager-control button{cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}a.ui-grid-pager-control button.disabled,fieldset[disabled] a.ui-grid-pager-control button{pointer-events:none}.ui-grid-pager-control button:focus,.ui-grid-pager-control button.focus{color:#eee;background-color:#dadada;border-color:#8c8c8c}.ui-grid-pager-control button:hover{color:#eee;background-color:#dadada;border-color:#adadad}.ui-grid-pager-control button:active,.ui-grid-pager-control button.active,.open>.dropdown-toggle.ui-grid-pager-control button{color:#eee;background-color:#dadada;border-color:#adadad}.ui-grid-pager-control button:active:hover,.ui-grid-pager-control button.active:hover,.open>.dropdown-toggle.ui-grid-pager-control button:hover,.ui-grid-pager-control button:active:focus,.ui-grid-pager-control button.active:focus,.open>.dropdown-toggle.ui-grid-pager-control button:focus,.ui-grid-pager-control button:active.focus,.ui-grid-pager-control button.active.focus,.open>.dropdown-toggle.ui-grid-pager-control button.focus{color:#eee;background-color:#c8c8c8;border-color:#8c8c8c}.ui-grid-pager-control button:active,.ui-grid-pager-control button.active,.open>.dropdown-toggle.ui-grid-pager-control button{background-image:none}.ui-grid-pager-control button.disabled:hover,.ui-grid-pager-control button[disabled]:hover,fieldset[disabled] .ui-grid-pager-control button:hover,.ui-grid-pager-control button.disabled:focus,.ui-grid-pager-control button[disabled]:focus,fieldset[disabled] .ui-grid-pager-control button:focus,.ui-grid-pager-control button.disabled.focus,.ui-grid-pager-control button[disabled].focus,fieldset[disabled] .ui-grid-pager-control button.focus{background-color:#f3f3f3;border-color:#ccc}.ui-grid-pager-control button .badge{color:#f3f3f3;background-color:#eee}.ui-grid-pager-control input{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px;display:inline;height:26px;width:50px;vertical-align:top}.ui-grid-pager-control input:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6)}.ui-grid-pager-control input::-moz-placeholder{color:#999;opacity:1}.ui-grid-pager-control input:-ms-input-placeholder{color:#999}.ui-grid-pager-control input::-webkit-input-placeholder{color:#999}.ui-grid-pager-control input::-ms-expand{border:0;background-color:transparent}.ui-grid-pager-control input[disabled],.ui-grid-pager-control input[readonly],fieldset[disabled] .ui-grid-pager-control input{background-color:#eee;opacity:1}.ui-grid-pager-control input[disabled],fieldset[disabled] .ui-grid-pager-control input{cursor:not-allowed}textarea.ui-grid-pager-control input{height:auto}select.ui-grid-pager-control input{height:30px;line-height:30px}textarea.ui-grid-pager-control input,select[multiple].ui-grid-pager-control input{height:auto}.ui-grid-pager-control .ui-grid-pager-max-pages-number{vertical-align:bottom}.ui-grid-pager-control .ui-grid-pager-max-pages-number>*{vertical-align:bottom}.ui-grid-pager-control .ui-grid-pager-max-pages-number abbr{border-bottom:none;text-decoration:none}.ui-grid-pager-control .first-bar{width:10px;border-left:2px solid #4d4d4d;margin-top:-6px;height:12px;margin-left:-3px}.ui-grid-pager-control .first-bar-rtl{width:10px;border-left:2px solid #4d4d4d;margin-top:-6px;height:12px;margin-right:-7px}.ui-grid-pager-control .first-triangle{width:0;height:0;border-style:solid;border-width:5px 8.7px 5px 0;border-color:transparent #4d4d4d transparent transparent;margin-left:2px}.ui-grid-pager-control .next-triangle{margin-left:1px}.ui-grid-pager-control .prev-triangle{margin-left:0}.ui-grid-pager-control .last-triangle{width:0;height:0;border-style:solid;border-width:5px 0 5px 8.7px;border-color:transparent transparent transparent #4d4d4d;margin-left:-1px}.ui-grid-pager-control .last-bar{width:10px;border-left:2px solid #4d4d4d;margin-top:-6px;height:12px;margin-left:1px}.ui-grid-pager-control .last-bar-rtl{width:10px;border-left:2px solid #4d4d4d;margin-top:-6px;height:12px;margin-right:-11px}.ui-grid-pager-row-count-picker{float:left;padding:5px 10px}.ui-grid-pager-row-count-picker select{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px;height:25px;width:67px;display:inline;vertical-align:middle}.ui-grid-pager-row-count-picker select:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6)}.ui-grid-pager-row-count-picker select::-moz-placeholder{color:#999;opacity:1}.ui-grid-pager-row-count-picker select:-ms-input-placeholder{color:#999}.ui-grid-pager-row-count-picker select::-webkit-input-placeholder{color:#999}.ui-grid-pager-row-count-picker select::-ms-expand{border:0;background-color:transparent}.ui-grid-pager-row-count-picker select[disabled],.ui-grid-pager-row-count-picker select[readonly],fieldset[disabled] .ui-grid-pager-row-count-picker select{background-color:#eee;opacity:1}.ui-grid-pager-row-count-picker select[disabled],fieldset[disabled] .ui-grid-pager-row-count-picker select{cursor:not-allowed}textarea.ui-grid-pager-row-count-picker select{height:auto}select.ui-grid-pager-row-count-picker select{height:30px;line-height:30px}textarea.ui-grid-pager-row-count-picker select,select[multiple].ui-grid-pager-row-count-picker select{height:auto}.ui-grid-pager-row-count-picker .ui-grid-pager-row-count-label{margin-top:3px}.ui-grid-pager-count-container{float:right;margin-top:4px;min-width:50px}.ui-grid-pager-count-container .ui-grid-pager-count{margin-right:10px;margin-left:10px;float:right}.ui-grid-pager-count-container .ui-grid-pager-count abbr{border-bottom:none;text-decoration:none}.ui-grid-pinned-container{position:absolute;display:inline;top:0}.ui-grid-pinned-container.ui-grid-pinned-container-left{float:left;left:0}.ui-grid-pinned-container.ui-grid-pinned-container-right{float:right;right:0}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:last-child{box-sizing:border-box;border-right:1px solid;border-width:1px;border-right-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-cell:last-child{box-sizing:border-box;border-right:1px solid;border-width:1px;border-right-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar,.ui-grid-pinned-container .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{width:1px}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#d4d4d4}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:last-child .ui-grid-vertical-bar{right:-1px;width:1px;background-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:first-child{box-sizing:border-box;border-left:1px solid;border-width:1px;border-left-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-cell:first-child{box-sizing:border-box;border-left:1px solid;border-width:1px;border-left-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar,.ui-grid-pinned-container .ui-grid-cell:not(:first-child) .ui-grid-vertical-bar{width:1px}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar{background-color:#d4d4d4}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-first .ui-grid-header-cell:first-child .ui-grid-vertical-bar{left:-1px;width:1px;background-color:#aeaeae}.ui-grid-column-resizer{top:0;bottom:0;width:5px;position:absolute;cursor:col-resize}.ui-grid-column-resizer.left{left:0}.ui-grid-column-resizer.right{right:0}.ui-grid-header-cell:last-child .ui-grid-column-resizer.right{border-right:1px solid #d4d4d4}.ui-grid[dir=rtl] .ui-grid-header-cell:last-child .ui-grid-column-resizer.right{border-right:0}.ui-grid[dir=rtl] .ui-grid-header-cell:last-child .ui-grid-column-resizer.left{border-left:1px solid #d4d4d4}.ui-grid.column-resizing{cursor:col-resize;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ui-grid.column-resizing .ui-grid-resize-overlay{position:absolute;top:0;height:100%;width:1px;background-color:#aeaeae}.ui-grid-row-saving .ui-grid-cell{color:#848484 !important}.ui-grid-row-dirty .ui-grid-cell{color:#610B38}.ui-grid-row-error .ui-grid-cell{color:#FF0000 !important}.ui-grid-row.ui-grid-row-selected>[ui-grid-row]>.ui-grid-cell{background-color:#C9DDE1}.ui-grid-disable-selection{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.ui-grid-selection-row-header-buttons{display:flex;align-items:center;height:100%;cursor:pointer}.ui-grid-selection-row-header-buttons::before{opacity:.1}.ui-grid-selection-row-header-buttons.ui-grid-row-selected::before,.ui-grid-selection-row-header-buttons.ui-grid-all-selected::before{opacity:1}.ui-grid-tree-row-header-buttons.ui-grid-tree-header{cursor:pointer;opacity:1}.ui-grid-tree-header-row{font-weight:bold !important}.ui-grid-tree-header-row .ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell{pointer-events:all}.ui-grid-cell-contents.invalid{border:1px solid #fc8f8f} \ No newline at end of file diff --git a/release/4.4.11/ui-grid.min.js b/release/4.4.11/ui-grid.min.js new file mode 100644 index 000000000..a110b2d84 --- /dev/null +++ b/release/4.4.11/ui-grid.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";angular.module("ui.grid.i18n",[]),angular.module("ui.grid",["ui.grid.i18n"])}(),function(){"use strict";angular.module("ui.grid").constant("uiGridConstants",{LOG_DEBUG_MESSAGES:!0,LOG_WARN_MESSAGES:!0,LOG_ERROR_MESSAGES:!0,CUSTOM_FILTERS:/CUSTOM_FILTERS/g,COL_FIELD:/COL_FIELD/g,MODEL_COL_FIELD:/MODEL_COL_FIELD/g,TOOLTIP:/title=\"TOOLTIP\"/g,DISPLAY_CELL_TEMPLATE:/DISPLAY_CELL_TEMPLATE/g,TEMPLATE_REGEXP:/<.+>/,FUNC_REGEXP:/(\([^)]*\))?$/,DOT_REGEXP:/\./g,APOS_REGEXP:/'/g,BRACKET_REGEXP:/^(.*)((?:\s*\[\s*\d+\s*\]\s*)|(?:\s*\[\s*"(?:[^"\\]|\\.)*"\s*\]\s*)|(?:\s*\[\s*'(?:[^'\\]|\\.)*'\s*\]\s*))(.*)$/,COL_CLASS_PREFIX:"ui-grid-col",ENTITY_BINDING:"$$this",events:{GRID_SCROLL:"uiGridScroll",COLUMN_MENU_SHOWN:"uiGridColMenuShown",ITEM_DRAGGING:"uiGridItemDragStart",COLUMN_HEADER_CLICK:"uiGridColumnHeaderClick"},keymap:{TAB:9,STRG:17,CAPSLOCK:20,CTRL:17,CTRLRIGHT:18,CTRLR:18,SHIFT:16,RETURN:13,ENTER:13,BACKSPACE:8,BCKSP:8,ALT:18,ALTR:17,ALTRIGHT:17,SPACE:32,WIN:91,MAC:91,FN:null,PG_UP:33,PG_DOWN:34,UP:38,DOWN:40,LEFT:37,RIGHT:39,ESC:27,DEL:46,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123},ASC:"asc",DESC:"desc",filter:{STARTS_WITH:2,ENDS_WITH:4,EXACT:8,CONTAINS:16,GREATER_THAN:32,GREATER_THAN_OR_EQUAL:64,LESS_THAN:128,LESS_THAN_OR_EQUAL:256,NOT_EQUAL:512,SELECT:"select",INPUT:"input"},aggregationTypes:{sum:2,count:4,avg:8,min:16,max:32},CURRENCY_SYMBOLS:["¤","؋","Ar","Ƀ","฿","B/.","Br","Bs.","Bs.F.","GH₵","¢","c","Ch.","₡","C$","D","ден","دج",".د.ب","د.ع","JD","د.ك","ل.د","дин","د.ت","د.م.","د.إ","Db","$","₫","Esc","€","ƒ","Ft","FBu","FCFA","CFA","Fr","FRw","G","gr","₲","h","₴","₭","Kč","kr","kn","MK","ZK","Kz","K","L","Le","лв","E","lp","M","KM","MT","₥","Nfk","₦","Nu.","UM","T$","MOP$","₱","Pt.","£","ج.م.","LL","LS","P","Q","q","R","R$","ر.ع.","ر.ق","ر.س","៛","RM","p","Rf.","₹","₨","SRe","Rp","₪","Ksh","Sh.So.","USh","S/","SDR","сом","৳\t","WS$","₮","VT","₩","¥","zł"],scrollDirection:{UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",NONE:"none"},dataChange:{ALL:"all",EDIT:"edit",ROW:"row",COLUMN:"column",OPTIONS:"options"},scrollbars:{NEVER:0,ALWAYS:1,WHEN_NEEDED:2}})}(),angular.module("ui.grid").directive("uiGridCell",["$compile","$parse","gridUtil","uiGridConstants",function(a,e,l,u){return{priority:0,scope:!1,require:"?^uiGrid",compile:function(){return{pre:function(t,r,e,i){if(i&&t.col.compiledElementFn)(0,t.col.compiledElementFn)(t,function(e,t){r.append(e)});else if(i&&!t.col.compiledElementFn)t.col.getCompiledElementFn().then(function(e){e(t,function(e,t){r.append(e)})}).catch(angular.noop);else{var n=t.col.cellTemplate.replace(u.MODEL_COL_FIELD,"row.entity."+l.preEval(t.col.field)).replace(u.COL_FIELD,"grid.getCellValue(row, col)"),o=a(n)(t);r.append(o)}},post:function(i,n,e,t){var o,a=i.col.getColClass(!1);n.addClass(a);var l=function(e){var t=n;o&&(t.removeClass(o),o=null),o=angular.isFunction(i.col.cellClass)?i.col.cellClass(i.grid,i.row,i.col,i.rowRenderIndex,i.colRenderIndex):i.col.cellClass,t.addClass(o)};i.col.cellClass&&l();var r=i.grid.registerDataChangeCallback(l,[u.dataChange.COLUMN,u.dataChange.EDIT]),s=i.$watch("row",function(e,t){if(e!==t){(o||i.col.cellClass)&&l();var r=i.col.getColClass(!1);r!==a&&(n.removeClass(a),n.addClass(r),a=r)}}),d=function(){r(),s()};i.$on("$destroy",d),n.on("$destroy",d)}}}}}]),angular.module("ui.grid").service("uiGridColumnMenuService",["i18nService","uiGridConstants","gridUtil",function(e,r,g){var i={initialize:function(e,t){e.grid=t.grid,(t.columnMenuScope=e).menuShown=!1},setColMenuItemWatch:function(t){var e=t.$watch("col.menuItems",function(e){void 0!==e&&e&&angular.isArray(e)?(e.forEach(function(e){void 0!==e.context&&e.context||(e.context={}),e.context.col=t.col}),t.menuItems=t.defaultMenuItems.concat(e)):t.menuItems=t.defaultMenuItems});t.$on("$destroy",e)},sortable:function(e){return!!(e.grid.options.enableSorting&&void 0!==e.col&&e.col&&e.col.enableSorting)},isActiveSort:function(e,t){return void 0!==e.col&&void 0!==e.col.sort&&void 0!==e.col.sort.direction&&e.col.sort.direction===t},suppressRemoveSort:function(e){return!(!e.col||!e.col.suppressRemoveSort)},hideable:function(e){return void 0===e.col||!e.col||!e.col.colDef||!1!==e.col.colDef.enableHiding},getDefaultMenuItems:function(t){return[{title:function(){return e.getSafeText("sort.ascending")},icon:"ui-grid-icon-sort-alt-up",action:function(e){e.stopPropagation(),t.sortColumn(e,r.ASC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.ASC)}},{title:function(){return e.getSafeText("sort.descending")},icon:"ui-grid-icon-sort-alt-down",action:function(e){e.stopPropagation(),t.sortColumn(e,r.DESC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.DESC)}},{title:function(){return e.getSafeText("sort.remove")},icon:"ui-grid-icon-cancel",action:function(e){e.stopPropagation(),t.unsortColumn()},shown:function(){return i.sortable(t)&&void 0!==t.col&&void 0!==t.col.sort&&void 0!==t.col.sort.direction&&null!==t.col.sort.direction&&!i.suppressRemoveSort(t)}},{title:function(){return e.getSafeText("column.hide")},icon:"ui-grid-icon-cancel",shown:function(){return i.hideable(t)},action:function(e){e.stopPropagation(),t.hideColumn()}}]},getColumnElementPosition:function(e,t,r){var i={};return i.left=r[0].offsetLeft,i.top=r[0].offsetTop,i.parentLeft=r[0].offsetParent.offsetLeft,i.offset=0,t.grid.options.offsetLeft&&(i.offset=t.grid.options.offsetLeft),i.height=g.elementHeight(r,!0),i.width=g.elementWidth(r,!0),i},repositionMenu:function(e,t,r,i,n){var o=i[0].querySelectorAll(".ui-grid-menu"),a=g.closestElm(n,".ui-grid-render-container"),l=a.getBoundingClientRect().left-e.grid.element[0].getBoundingClientRect().left,s=a.querySelectorAll(".ui-grid-viewport")[0].scrollLeft,d=g.elementWidth(o,!0),u=t.lastMenuPaddingRight?t.lastMenuPaddingRight:e.lastMenuPaddingRight?e.lastMenuPaddingRight:10;0!==o.length&&0!==o[0].querySelectorAll(".ui-grid-menu-mid").length&&(u=parseInt(g.getStyles(angular.element(o)[0]).paddingRight,10),e.lastMenuPaddingRight=u,t.lastMenuPaddingRight=u);var c=r.left+l-s+r.parentLeft+r.width+u;c(u.grid.rowHeaderColumns?u.grid.rowHeaderColumns.length:0);!r&&!n.uiGridColumns&&0===u.grid.options.columnDefs.length&&0
    ',scope:{side:"=uiGridPinnedContainer"},require:"^uiGrid",compile:function(){return{post:function(n,t,e,r){var o=r.grid,i=0;function a(){if("left"===n.side||"right"===n.side){for(var e=o.renderContainers[n.side].visibleColumnCache,t=0,r=0;r=t&&(t=e.sort.priority+1)}),t},e.prototype.resetColumnSorting=function(t){this.columns.forEach(function(e){e===t||e.suppressRemoveSort||(e.sort={})})},e.prototype.getColumnSorting=function(){var t=[];return this.columns.slice(0).sort(p.prioritySort).forEach(function(e){e.sort&&void 0!==e.sort.direction&&e.sort.direction&&(e.sort.direction===s.ASC||e.sort.direction===s.DESC)&&t.push(e)}),t},e.prototype.sortColumn=function(e,t,r){var i=this,n=null;if(void 0===e||!e)throw new Error("No column parameter provided");if("boolean"==typeof t?r=t:n=t,r?void 0===e.sort.priority&&(e.sort.priority=i.getNextColumnSortPriority()):(i.resetColumnSorting(e),e.sort.priority=void 0,e.sort.priority=i.getNextColumnSortPriority()),n)e.sort.direction=n;else{var o=e.sortDirectionCycle.indexOf(e.sort.direction?e.sort.direction:null);o=(o+1)%e.sortDirectionCycle.length,e.colDef&&e.suppressRemoveSort&&!e.sortDirectionCycle[o]&&(o=(o+1)%e.sortDirectionCycle.length),e.sortDirectionCycle[o]?e.sort.direction=e.sortDirectionCycle[o]:a(e,i)}return i.api.core.raise.sortChanged(i,i.getColumnSorting()),S.when(e)};var a=function(t,e){e.columns.forEach(function(e){e.sort&&void 0!==e.sort.priority&&e.sort.priority>t.sort.priority&&(e.sort.priority-=1)}),t.sort={}};function n(e,t){var r=e/t;return r<=1?r:1}function E(e,t,r){if(n(e,t)!==r)return{percentage:n(e,t)}}function A(e,t,r){var i=e/t;if((i=1Math.ceil(s)&&(u=p-s+r.renderContainers.body.prevScrollTop,i.y=E(u,g,r.renderContainers.body.prevScrolltopPercentage))}if(null!==t){for(var f=o.indexOf(t),m=r.renderContainers.body.getCanvasWidth()-r.renderContainers.body.getViewportWidth(),h=0,v=0;vt&&(e.sort.priority-=1)}),this.sort={},this.grid.api.core.raise.sortChanged(this.grid,this.grid.getColumnSorting())},t.prototype.getColClass=function(e){var t=u.COL_CLASS_PREFIX+this.uid;return e?"."+t:t},t.prototype.isPinnedLeft=function(){return"left"===this.renderContainer},t.prototype.isPinnedRight=function(){return"right"===this.renderContainer},t.prototype.getColClassDefinition=function(){return" .grid"+this.grid.id+" "+this.getColClass(!0)+" { min-width: "+this.drawnWidth+"px; max-width: "+this.drawnWidth+"px; }"},t.prototype.getRenderContainer=function(){var e=this.renderContainer;return null!==e&&""!==e&&void 0!==e||(e="body"),this.grid.renderContainers[e]},t.prototype.showColumn=function(){this.colDef.visible=!0},t.prototype.getAggregationText=function(){if(this.colDef.aggregationHideLabel)return"";if(this.colDef.aggregationLabel)return this.colDef.aggregationLabel;switch(this.colDef.aggregationType){case u.aggregationTypes.count:return e.getSafeText("aggregation.count");case u.aggregationTypes.sum:return e.getSafeText("aggregation.sum");case u.aggregationTypes.avg:return e.getSafeText("aggregation.avg");case u.aggregationTypes.min:return e.getSafeText("aggregation.min");case u.aggregationTypes.max:return e.getSafeText("aggregation.max");default:return""}},t.prototype.getCellTemplate=function(){return this.cellTemplatePromise},t.prototype.getCompiledElementFn=function(){return this.compiledElementFnDefer.promise},t}]),angular.module("ui.grid").factory("GridOptions",["gridUtil","uiGridConstants",function(t,r){return{initialize:function(e){return e.onRegisterApi=e.onRegisterApi||angular.noop(),e.data=e.data||[],e.columnDefs=e.columnDefs||[],e.excludeProperties=e.excludeProperties||["$$hashKey"],e.enableRowHashing=!1!==e.enableRowHashing,e.rowIdentity=e.rowIdentity||function(e){return t.hashKey(e)},e.getRowIdentity=e.getRowIdentity||function(e){return e.$$hashKey},e.flatEntityAccess=!0===e.flatEntityAccess,e.showHeader=void 0===e.showHeader||e.showHeader,e.showHeader?e.headerRowHeight=void 0!==e.headerRowHeight?e.headerRowHeight:30:e.headerRowHeight=0,"string"==typeof e.rowHeight?e.rowHeight=parseInt(e.rowHeight)||30:e.rowHeight=e.rowHeight||30,e.minRowsToShow=void 0!==e.minRowsToShow?e.minRowsToShow:10,e.showGridFooter=!0===e.showGridFooter,e.showColumnFooter=!0===e.showColumnFooter,e.columnFooterHeight=void 0!==e.columnFooterHeight?e.columnFooterHeight:30,e.gridFooterHeight=void 0!==e.gridFooterHeight?e.gridFooterHeight:30,e.columnWidth=void 0!==e.columnWidth?e.columnWidth:50,e.maxVisibleColumnCount=void 0!==e.maxVisibleColumnCount?e.maxVisibleColumnCount:200,e.virtualizationThreshold=void 0!==e.virtualizationThreshold?e.virtualizationThreshold:20,e.columnVirtualizationThreshold=void 0!==e.columnVirtualizationThreshold?e.columnVirtualizationThreshold:10,e.excessRows=void 0!==e.excessRows?e.excessRows:4,e.scrollThreshold=void 0!==e.scrollThreshold?e.scrollThreshold:4,e.excessColumns=void 0!==e.excessColumns?e.excessColumns:4,e.horizontalScrollThreshold=void 0!==e.horizontalScrollThreshold?e.horizontalScrollThreshold:2,e.aggregationCalcThrottle=void 0!==e.aggregationCalcThrottle?e.aggregationCalcThrottle:500,e.wheelScrollThrottle=void 0!==e.wheelScrollThrottle?e.wheelScrollThrottle:70,e.scrollDebounce=void 0!==e.scrollDebounce?e.scrollDebounce:300,e.enableSorting=!1!==e.enableSorting,e.enableFiltering=!0===e.enableFiltering,e.enableColumnMenus=!1!==e.enableColumnMenus,e.enableVerticalScrollbar=void 0!==e.enableVerticalScrollbar?e.enableVerticalScrollbar:r.scrollbars.ALWAYS,e.enableHorizontalScrollbar=void 0!==e.enableHorizontalScrollbar?e.enableHorizontalScrollbar:r.scrollbars.ALWAYS,e.enableMinHeightCheck=!1!==e.enableMinHeightCheck,e.minimumColumnSize=void 0!==e.minimumColumnSize?e.minimumColumnSize:30,e.rowEquality=e.rowEquality||function(e,t){return e===t},e.headerTemplate=e.headerTemplate||null,e.footerTemplate=e.footerTemplate||"ui-grid/ui-grid-footer",e.gridFooterTemplate=e.gridFooterTemplate||"ui-grid/ui-grid-grid-footer",e.rowTemplate=e.rowTemplate||"ui-grid/ui-grid-row",e.gridMenuTemplate=e.gridMenuTemplate||"ui-grid/uiGridMenu",e.appScopeProvider=e.appScopeProvider||null,e}}}]),angular.module("ui.grid").factory("GridRenderContainer",["gridUtil","uiGridConstants",function(b,n){function e(e,t,r){var i=this;i.name=e,i.grid=t,i.visibleRowCache=[],i.visibleColumnCache=[],i.renderedRows=[],i.renderedColumns=[],i.prevScrollTop=0,i.prevScrolltopPercentage=0,i.prevRowScrollIndex=0,i.prevScrollLeft=0,i.prevScrollleftPercentage=0,i.prevColumnScrollIndex=0,i.columnStyles="",i.viewportAdjusters=[],i.hasHScrollbar=!1,i.hasVScrollbar=!1,i.canvasHeightShouldUpdate=!0,i.$$canvasHeight=0,r&&angular.isObject(r)&&angular.extend(i,r),t.registerStyleComputation({priority:5,func:function(){return i.updateColumnWidths(),i.columnStyles}})}return e.prototype.reset=function(){this.visibleColumnCache.length=0,this.visibleRowCache.length=0,this.renderedRows.length=0,this.renderedColumns.length=0},e.prototype.containsColumn=function(e){return-1!==this.visibleColumnCache.indexOf(e)},e.prototype.minRowsToRender=function(){for(var e=0,t=0,r=this.getViewportHeight(),i=this.visibleRowCache.length-1;ti.grid.options.virtualizationThreshold){if(null!=e){if(!i.grid.suppressParentScrollDown&&i.prevScrollTope&&l>i.prevRowScrollIndex-i.grid.options.scrollThreshold&&lr.grid.options.columnVirtualizationThreshold&&r.getCanvasWidth()>r.getViewportWidth())l=[Math.max(0,a-r.grid.options.excessColumns),Math.min(n.length,a+i+r.grid.options.excessColumns)];else{var s=r.visibleColumnCache.length;l=[0,Math.max(s,i+r.grid.options.excessColumns)]}r.updateViewableColumnRange(l),r.prevColumnScrollIndex=a},e.prototype.updateViewableRowRange=function(e){var t=this.visibleRowCache.slice(e[0],e[1]);this.currentTopRow=e[0],this.setRenderedRows(t)},e.prototype.updateViewableColumnRange=function(e){var t=this.visibleColumnCache.slice(e[0],e[1]);this.currentFirstColumn=e[0],this.setRenderedColumns(t)},e.prototype.headerCellWrapperStyle=function(){if(0!==this.currentFirstColumn){var e=this.columnOffset;return this.grid.isRTL()?{"margin-right":e+"px"}:{"margin-left":e+"px"}}return null},e.prototype.updateColumnWidths=function(){var i=this,n=[],o=0,a=0,t="",l=!1,s=[],d=[],u=0,c=i.grid.getViewportWidth()-i.grid.scrollbarWidth,r=[];angular.forEach(i.grid.renderContainers,function(e){r=r.concat(e.visibleColumnCache)}),r.forEach(function(e){var t=0;if(e.visible)if(l&&(c+=i.grid.scrollbarWidth),!l&&e.colDef.pinnedRight&&(l=!0),angular.isNumber(e.width))t=parseInt(e.width,10),a+=t,e.drawnWidth=t,s.push(e);else if(b.endsWith(e.width,"%")){var r=parseInt(e.width.replace(/%/g,""),10);(t=parseInt(r/100*c))>e.maxWidth&&(t=e.maxWidth),te.maxWidth&&(t=e.maxWidth),te.minWidth&&0e.offsetWidth)},e.prototype.getViewportStyle=function(){var e=this,t={},r={};return r[n.scrollbars.ALWAYS]="scroll",r[n.scrollbars.WHEN_NEEDED]="auto",e.hasHScrollbar=!1,e.hasVScrollbar=!1,e.grid.disableScrolling?(t["overflow-x"]="hidden",t["overflow-y"]="hidden"):("body"===e.name?(e.hasHScrollbar=e.grid.options.enableHorizontalScrollbar!==n.scrollbars.NEVER,e.grid.isRTL()?e.grid.hasLeftContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER):e.grid.hasRightContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER)):"left"===e.name?e.hasVScrollbar=!!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER:e.hasVScrollbar=!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER,t["overflow-x"]=e.hasHScrollbar?r[e.grid.options.enableHorizontalScrollbar]:"hidden",t["overflow-y"]=e.hasVScrollbar?r[e.grid.options.enableVerticalScrollbar]:"hidden"),t},e}]),angular.module("ui.grid").factory("GridRow",["gridUtil","uiGridConstants",function(i,t){function e(e,t,r){this.grid=r,this.entity=e,this.uid=i.nextUid(),this.visible=!0,this.isSelected=!1,this.$$height=r.options.rowHeight}return Object.defineProperty(e.prototype,"height",{get:function(){return this.$$height},set:function(e){e!==this.$$height&&(this.grid.updateCanvasHeight(),this.$$height=e)}}),e.prototype.getQualifiedColField=function(e){return"row."+this.getEntityQualifiedColField(e)},e.prototype.getEntityQualifiedColField=function(e){return e.field===t.ENTITY_BINDING?"entity":i.preEval("entity."+e.field)},e.prototype.setRowInvisible=function(e){e&&e.setThisRowInvisible&&e.setThisRowInvisible("user")},e.prototype.clearRowInvisible=function(e){e&&e.clearThisRowInvisible&&e.clearThisRowInvisible("user")},e.prototype.setThisRowInvisible=function(e,t){this.invisibleReason||(this.invisibleReason={}),this.invisibleReason[e]=!0,this.evaluateRowVisibility(t)},e.prototype.clearThisRowInvisible=function(e,t){void 0!==this.invisibleReason&&delete this.invisibleReason[e],this.evaluateRowVisibility(t)},e.prototype.evaluateRowVisibility=function(e){var r=!0;void 0!==this.invisibleReason&&angular.forEach(this.invisibleReason,function(e,t){e&&(r=!1)}),void 0!==this.visible&&this.visible===r||(this.visible=r,e||(this.grid.queueGridRefresh(),this.grid.api.core.raise.rowsVisibleChanged(this)))},e}]),function(){"use strict";angular.module("ui.grid").factory("GridRowColumn",["$parse","$filter",function(e,t){var r=function e(t,r){if(!(this instanceof e))throw"Using GridRowColumn as a function insead of as a constructor. Must be called with `new` keyword";this.row=t,this.col=r};return r.prototype.getIntersectionValueRaw=function(){return e(this.row.getEntityQualifiedColField(this.col))(this.row)},r}])}(),angular.module("ui.grid").factory("ScrollEvent",["gridUtil",function(a){function e(e,t,r,i){var n=this;if(!e)throw new Error("grid argument is required");n.grid=e,n.source=i,n.withDelay=!0,n.sourceRowContainer=t,n.sourceColContainer=r,n.newScrollLeft=null,n.newScrollTop=null,n.x=null,n.y=null,n.verticalScrollLength=-9999999,n.horizontalScrollLength=-999999,n.fireThrottledScrollingEvent=a.throttle(function(e){n.grid.scrollContainers(e,n)},n.grid.options.wheelScrollThrottle,{trailing:!0})}return e.prototype.getNewScrollLeft=function(e,t){var r=this;if(!r.newScrollLeft){var i,n=e.getCanvasWidth()-e.getViewportWidth(),o=a.normalizeScrollLeft(t,r.grid);if(void 0!==r.x.percentage&&void 0!==r.x.percentage)i=r.x.percentage;else{if(void 0===r.x.pixels||void 0===r.x.pixels)throw new Error("No percentage or pixel value provided for scroll event X axis");i=r.x.percentage=(o+r.x.pixels)/n}return Math.max(0,i*n)}return r.newScrollLeft},e.prototype.getNewScrollTop=function(e,t){var r=this;if(!r.newScrollTop){var i,n=e.getVerticalScrollLength(),o=t[0].scrollTop;if(void 0!==r.y.percentage&&void 0!==r.y.percentage)i=r.y.percentage;else{if(void 0===r.y.pixels||void 0===r.y.pixels)throw new Error("No percentage or pixel value provided for scroll event Y axis");i=r.y.percentage=(o+r.y.pixels)/n}return Math.max(0,i*n)}return r.newScrollTop},e.prototype.atTop=function(e){return this.y&&(0===this.y.percentage||this.verticalScrollLength<0)&&0===e},e.prototype.atBottom=function(e){return this.y&&(1===this.y.percentage||0===this.verticalScrollLength)&&0A')[0],r="reverse";return document.body.appendChild(t),0=i.length-a?new l(i[i.length-1],r[n]):new l(i[o+a],r[n])},n.prototype.getRowColUp=function(e,t){var r=this.getFocusableCols(),i=this.getFocusableRows(),n=r.indexOf(t),o=i.indexOf(e);return-1===n&&(n=0),new l(0===o?e:i[o-1],r[n])},n.prototype.getRowColPageUp=function(e,t){var r=this.getFocusableCols(),i=this.getFocusableRows(),n=r.indexOf(t),o=i.indexOf(e);-1===n&&(n=0);var a=this.bodyContainer.minRowsToRender();return new l(o-a<0?i[0]:i[o-a],r[n])},n}]),e.service("uiGridCellNavService",["gridUtil","uiGridConstants","uiGridCellNavConstants","$q","uiGridCellNavFactory","GridRowColumn","ScrollEvent",function(e,t,r,i,n,o,a){var l={initializeGrid:function(i){i.registerColumnBuilder(l.cellNavColumnBuilder),i.cellNav={},i.cellNav.lastRowCol=null,i.cellNav.focusedCells=[],l.defaultGridOptions(i.options);var e={events:{cellNav:{navigate:function(e,t){},viewPortKeyDown:function(e,t){},viewPortKeyPress:function(e,t){}}},methods:{cellNav:{scrollToFocus:function(e,t){return l.scrollToFocus(i,e,t)},getFocusedCell:function(){return i.cellNav.lastRowCol},getCurrentSelection:function(){return i.cellNav.focusedCells},rowColSelectIndex:function(e){for(var t=-1,r=0;r ',g=a(n)(e),t.prepend(g),e.$on(u.CELL_NAV_EVENT,function(e,t,r,i){if(!i||"focus"!==i.type){for(var n,o,a=[],l=p.api.cellNav.getCurrentSelection(),s=0;s')(e);t.append(d),d.on("focus",function(e){e.uiGridTargetRenderContainerId=l;var t=n.grid.api.cellNav.getFocusedCell();null===t&&(t=n.grid.renderContainers[l].cellNav.getNextRowCol(m.direction.DOWN,null,null)).row&&t.col&&n.cellNav.broadcastCellNav(t)}),a.setAriaActivedescendant=function(e){t.attr("aria-activedescendant",e)},a.removeAriaActivedescendant=function(e){t.attr("aria-activedescendant")===e&&t.attr("aria-activedescendant","")},n.focus=function(){g.focus.byElement(d[0])};var u=null;d.on("keydown",function(r){r.uiGridTargetRenderContainerId=l;var e=n.grid.api.cellNav.getFocusedCell();null===(n.grid.options.keyDownOverrides.some(function(t){return Object.keys(t).every(function(e){return t[e]===r[e]})})?null:n.cellNav.handleKeyDown(r))&&(n.grid.api.cellNav.raise.viewPortKeyDown(r,e,n.cellNav.handleKeyDown),u=e)}),d.on("keypress",function(e){u&&(c(function(){n.grid.api.cellNav.raise.viewPortKeyPress(e,u)},4),u=null)}),e.$on("$destroy",function(){d.off()})}}}}}}}]),e.directive("uiGridViewport",["$timeout","$document","gridUtil","uiGridConstants","uiGridCellNavService","uiGridCellNavConstants","$log","$compile",function(e,t,r,i,n,o,a,l){return{replace:!0,priority:-99999,require:["^uiGrid","^uiGridRenderContainer","?^uiGridCellnav"],scope:!1,compile:function(){return{pre:function(e,t,r,i){},post:function(e,t,r,i){var n=i[0],o=i[1];if(n.grid.api.cellNav&&"body"===o.containerId){var a=n.grid;a.api.core.on.scrollBegin(e,function(e){var t=n.grid.api.cellNav.getFocusedCell();null!==t&&o.colContainer.containsColumn(t.col)&&n.cellNav.clearFocus()}),a.api.core.on.scrollEnd(e,function(e){var t=n.grid.api.cellNav.getFocusedCell();null!==t&&o.colContainer.containsColumn(t.col)&&n.cellNav.broadcastCellNav(t)}),a.api.cellNav.on.navigate(e,function(){n.focus()})}}}}}}]),e.directive("uiGridCell",["$timeout","$document","uiGridCellNavService","gridUtil","uiGridCellNavConstants","uiGridConstants","GridRowColumn",function(e,t,r,i,c,g,p){return{priority:-150,restrict:"A",require:["^uiGrid","?^uiGridCellnav"],scope:!1,link:function(r,t,e,i){var n=i[0],o=i[1];if(n.grid.api.cellNav&&r.col.colDef.allowCellFocus){var a=n.grid;r.focused=!1,t.attr("tabindex",-1),t.find("div").on("click",function(e){n.cellNav.broadcastCellNav(new p(r.row,r.col),e.ctrlKey||e.metaKey,e),e.stopPropagation(),r.$apply()}),t.on("mousedown",s),n.grid.api.edit&&(n.grid.api.edit.on.beginCellEdit(r,function(){t.off("mousedown",s)}),n.grid.api.edit.on.afterCellEdit(r,function(){t.on("mousedown",s)}),n.grid.api.edit.on.cancelCellEdit(r,function(){t.on("mousedown",s)})),d(),t.on("focus",function(e){n.cellNav.broadcastCellNav(new p(r.row,r.col),!1,e),e.stopPropagation(),r.$apply()}),r.$on(c.CELL_NAV_EVENT,d);var l=n.grid.registerDataChangeCallback(function(e){u(),r.$applyAsync(d)},[g.dataChange.ROW]);r.$on("$destroy",function(){l(),t.find("div").off(),t.off()})}function s(e){e.preventDefault()}function d(){a.cellNav.focusedCells.some(function(e,t){return e.row===r.row&&e.col===r.col})?function(){if(!r.focused){var e=t.find("div");e.addClass("ui-grid-cell-focus"),t.attr("aria-selected",!0),o.setAriaActivedescendant(t.attr("id")),r.focused=!0}}():u()}function u(){r.focused&&(t.find("div").removeClass("ui-grid-cell-focus"),t.attr("aria-selected",!1),o.removeAriaActivedescendant(t.attr("id")),r.focused=!1)}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.edit",["ui.grid"]);e.constant("uiGridEditConstants",{EDITABLE_CELL_TEMPLATE:/EDITABLE_CELL_TEMPLATE/g,EDITABLE_CELL_DIRECTIVE:/editable_cell_directive/g,events:{BEGIN_CELL_EDIT:"uiGridEventBeginCellEdit",END_CELL_EDIT:"uiGridEventEndCellEdit",CANCEL_CELL_EDIT:"uiGridEventCancelCellEdit"}}),e.service("uiGridEditService",["$q","uiGridConstants","gridUtil",function(n,t,o){var r={initializeGrid:function(e){r.defaultGridOptions(e.options),e.registerColumnBuilder(r.editColumnBuilder),e.edit={};e.api.registerEventsFromObject({edit:{afterCellEdit:function(e,t,r,i){},beginCellEdit:function(e,t,r){},cancelCellEdit:function(e,t){}}})},defaultGridOptions:function(e){e.cellEditableCondition=void 0===e.cellEditableCondition||e.cellEditableCondition,e.enableCellEditOnFocus=void 0!==e.enableCellEditOnFocus&&e.enableCellEditOnFocus},editColumnBuilder:function(t,r,e){var i=[];return t.enableCellEdit=void 0===t.enableCellEdit?void 0===e.enableCellEdit?"object"!==t.type:e.enableCellEdit:t.enableCellEdit,t.cellEditableCondition=void 0===t.cellEditableCondition?e.cellEditableCondition:t.cellEditableCondition,t.enableCellEdit&&(t.editableCellTemplate=t.editableCellTemplate||e.editableCellTemplate||"ui-grid/cellEditor",i.push(o.getTemplate(t.editableCellTemplate).then(function(e){r.editableCellTemplate=e},function(e){throw new Error("Couldn't fetch/use colDef.editableCellTemplate '"+t.editableCellTemplate+"'")}))),t.enableCellEditOnFocus=void 0===t.enableCellEditOnFocus?e.enableCellEditOnFocus:t.enableCellEditOnFocus,n.all(i)},isStartEditKey:function(e){return!(e.metaKey||e.keyCode===t.keymap.ESC||e.keyCode===t.keymap.SHIFT||e.keyCode===t.keymap.CTRL||e.keyCode===t.keymap.ALT||e.keyCode===t.keymap.WIN||e.keyCode===t.keymap.CAPSLOCK||e.keyCode===t.keymap.LEFT||e.keyCode===t.keymap.TAB&&e.shiftKey||e.keyCode===t.keymap.RIGHT||e.keyCode===t.keymap.TAB||e.keyCode===t.keymap.UP||e.keyCode===t.keymap.ENTER&&e.shiftKey||e.keyCode===t.keymap.DOWN||e.keyCode===t.keymap.ENTER)}};return r}]),e.directive("uiGridEdit",["gridUtil","uiGridEditService",function(e,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(i.grid)},post:function(e,t,r,i){}}}}}]),e.directive("uiGridViewport",["uiGridEditConstants",function(o){return{replace:!0,priority:-99998,require:["^uiGrid","^uiGridRenderContainer"],scope:!1,compile:function(){return{post:function(e,t,r,i){var n=i[0];n.grid.api.edit&&n.grid.api.cellNav&&("body"===i[1].containerId&&(e.$on(o.events.CANCEL_CELL_EDIT,function(){n.focus()}),e.$on(o.events.END_CELL_EDIT,function(){n.focus()})))}}}}}]),e.directive("uiGridCell",["$compile","$injector","$timeout","uiGridConstants","uiGridEditConstants","gridUtil","$parse","uiGridEditService","$rootScope","$q",function(S,e,x,E,A,R,T,g,F,P){var D=500;if(e.has("uiGridCellNavService"))e.get("uiGridCellNavService");return{priority:-100,restrict:"A",scope:!1,require:"?^uiGrid",link:function(p,f,e,i){var m,h,v,t,C,w=!1;if(p.col.colDef.enableCellEdit){var r=function(){},n=function(){},o=function(){p.col.colDef.enableCellEdit&&!1!==p.row.enableCellEdit?p.beginEditEventsWired||l():p.beginEditEventsWired&&b()};o();var a=p.$watch("row",function(e,t){e!==t&&o()});p.$on("$destroy",function(){a(),f.off()})}function l(){f.on("dblclick",c),f.on("touchstart",s),i&&i.grid.api.cellNav&&(n=i.grid.api.cellNav.on.viewPortKeyDown(p,function(e,t){null!==t&&(t.row!==p.row||t.col!==p.col||p.col.colDef.enableCellEditOnFocus||u(e))}),r=i.grid.api.cellNav.on.navigate(p,function(e,t,r){p.col.colDef.enableCellEditOnFocus&&(e.row!==p.row||e.col!==p.col||null!==r&&(!r||"click"!==r.type&&"keydown"!==r.type)||x(function(){c(r)}))})),p.beginEditEventsWired=!0}function s(e){void 0!==e.originalEvent&&void 0!==e.originalEvent&&(e=e.originalEvent),f.on("touchend",d),(t=x(function(){},D)).then(function(){setTimeout(c,0),f.off("touchend",d)})}function d(e){x.cancel(t),f.off("touchend",d)}function b(){f.off("dblclick",c),f.off("keydown",u),f.off("touchstart",s),r(),n(),p.beginEditEventsWired=!1}function u(e){g.isStartEditKey(e)&&c(e)}function c(e){p.grid.api.core.scrollToIfNecessary(p.row,p.col).then(function(){!function(e){if(w)return;if(t=p.col,r=p.row,i=e,r.isSaving||(angular.isFunction(t.colDef.cellEditableCondition)?!t.colDef.cellEditableCondition(p,i):!t.colDef.cellEditableCondition))return;var t,r,i;var n=p.row.getQualifiedColField(p.col);p.col.colDef.editModelField&&(n=R.preEval("row.entity."+p.col.colDef.editModelField));v=T(n),h=v(p),m=(m=(m=p.col.editableCellTemplate).replace(E.MODEL_COL_FIELD,n)).replace(E.COL_FIELD,"grid.getCellValue(row, col)");var o=p.col.colDef.editDropdownFilter?"|"+p.col.colDef.editDropdownFilter:"";m=m.replace(E.CUSTOM_FILTERS,o);var a="text";switch(p.col.colDef.type){case"boolean":a="checkbox";break;case"number":a="number";break;case"date":a="date"}m=m.replace("INPUT_TYPE",a);var l=p.col.colDef.editDropdownOptionsFunction;if(l)P.when(l(p.row.entity,p.col.colDef)).then(function(e){p.editDropdownOptionsArray=e});else{var s=p.col.colDef.editDropdownRowEntityOptionsArrayPath;p.editDropdownOptionsArray=s?function(e,t){var r=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split(".");for(;r.length;){var i=r.shift();if(!(i in e))return;e=e[i]}return e}(p.row.entity,s):p.col.colDef.editDropdownOptionsArray}p.editDropdownIdLabel=p.col.colDef.editDropdownIdLabel?p.col.colDef.editDropdownIdLabel:"id",p.editDropdownValueLabel=p.col.colDef.editDropdownValueLabel?p.col.colDef.editDropdownValueLabel:"value";var d=function(){w=!0,b();var e=angular.element(m);f.append(e),C=p.$new(),S(e)(C);var t=angular.element(f.children()[0]);t.addClass("ui-grid-cell-contents-hidden")};F.$$phase?d():p.$apply(d);var u=p.col.grid.api.core.on.scrollBegin(p,function(){p.grid.disableScrolling||(y(),p.grid.api.edit.raise.afterCellEdit(p.row.entity,p.col.colDef,v(p),h),u(),c(),g())}),c=p.$on(A.events.END_CELL_EDIT,function(){y(),p.grid.api.edit.raise.afterCellEdit(p.row.entity,p.col.colDef,v(p),h),c(),u(),g()}),g=p.$on(A.events.CANCEL_CELL_EDIT,function(){!function(){if(p.grid.disableScrolling=!1,!w)return;v.assign(p,h),p.$apply(),p.grid.api.edit.raise.cancelCellEdit(p.row.entity,p.col.colDef),y()}(),g(),u(),c()});p.$broadcast(A.events.BEGIN_CELL_EDIT,e),x(function(){p.grid.api.edit.raise.beginCellEdit(p.row.entity,p.col.colDef,e)})}(e)})}function y(){if(p.grid.disableScrolling=!1,w){i&&i.grid.api.cellNav&&i.focus();var e=angular.element(f.children()[0]);C.$destroy();for(var t=f.children(),r=1;r 1 or < 1 file choosers within the menu item, error, cannot continue"):o[0].addEventListener("change",function(e){var t=e.srcElement||e.target;if(t&&t.files&&1===t.files.length){var r=t.files[0];void 0!==i&&i?(n=i.grid,a.importThisFile(n,r),t.form.reset()):l.logError("Could not import file because UI Grid was not found.")}},!1)}}}])}(),function(){"use strict";var e=angular.module("ui.grid.infiniteScroll",["ui.grid"]);e.service("uiGridInfiniteScrollService",["gridUtil","$compile","$rootScope","uiGridConstants","ScrollEvent","$q",function(e,t,l,s,a,r){var d={initializeGrid:function(r,e){if(d.defaultGridOptions(r.options),r.options.enableInfiniteScroll){r.infiniteScroll={dataLoading:!1},d.setScrollDirections(r,r.options.infiniteScrollUp,r.options.infiniteScrollDown),r.api.core.on.scrollEnd(e,d.handleScroll);var t={events:{infiniteScroll:{needLoadMoreData:function(e,t){},needLoadMoreDataTop:function(e,t){}}},methods:{infiniteScroll:{dataLoaded:function(e,t){return d.setScrollDirections(r,e,t),d.adjustScroll(r).then(function(){r.infiniteScroll.dataLoading=!1})},resetScroll:function(e,t){d.setScrollDirections(r,e,t),d.adjustInfiniteScrollPosition(r,0)},saveScrollPercentage:function(){r.infiniteScroll.prevScrollTop=r.renderContainers.body.prevScrollTop,r.infiniteScroll.previousVisibleRows=r.getVisibleRowCount()},dataRemovedTop:function(e,t){d.dataRemovedTop(r,e,t)},dataRemovedBottom:function(e,t){d.dataRemovedBottom(r,e,t)},setScrollDirections:function(e,t){d.setScrollDirections(r,e,t)}}}};r.api.registerEventsFromObject(t.events),r.api.registerMethodsFromObject(t.methods)}},defaultGridOptions:function(e){e.enableInfiniteScroll=!1!==e.enableInfiniteScroll,e.infiniteScrollRowsFromEnd=e.infiniteScrollRowsFromEnd||20,e.infiniteScrollUp=!0===e.infiniteScrollUp,e.infiniteScrollDown=!1!==e.infiniteScrollDown},setScrollDirections:function(e,t,r){e.infiniteScroll.scrollUp=!0===t,e.suppressParentScrollUp=!0===t,e.infiniteScroll.scrollDown=!1!==r,e.suppressParentScrollDown=!1!==r},handleScroll:function(e){if(!(e.grid.infiniteScroll&&e.grid.infiniteScroll.dataLoading||"ui.grid.adjustInfiniteScrollPosition"===e.source)&&e.y)if(0===e.y.percentage)e.grid.scrollDirection=s.scrollDirection.UP,d.loadData(e.grid);else if(1===e.y.percentage)e.grid.scrollDirection=s.scrollDirection.DOWN,d.loadData(e.grid);else{var t=e.grid.options.infiniteScrollRowsFromEnd/e.grid.renderContainers.body.visibleRowCache.length;e.grid.scrollDirection===s.scrollDirection.UP?e.y.percentage<=t&&d.loadData(e.grid):e.grid.scrollDirection===s.scrollDirection.DOWN&&1-e.y.percentage<=t&&d.loadData(e.grid)}},loadData:function(e){e.infiniteScroll.previousVisibleRows=e.renderContainers.body.visibleRowCache.length,e.infiniteScroll.direction=e.scrollDirection,delete e.infiniteScroll.prevScrollTop,e.scrollDirection===s.scrollDirection.UP&&e.infiniteScroll.scrollUp?(e.infiniteScroll.dataLoading=!0,e.api.infiniteScroll.raise.needLoadMoreDataTop()):e.scrollDirection===s.scrollDirection.DOWN&&e.infiniteScroll.scrollDown&&(e.infiniteScroll.dataLoading=!0,e.api.infiniteScroll.raise.needLoadMoreData())},adjustScroll:function(o){var a=r.defer();return l.$applyAsync(function(){var e,t,r,i;e=o.getViewportHeight()+o.headerHeight-o.renderContainers.body.headerHeight-o.scrollbarHeight,t=o.options.rowHeight,void 0===o.infiniteScroll.direction&&d.adjustInfiniteScrollPosition(o,0);var n=t*(r=o.getVisibleRowCount());o.infiniteScroll.scrollDown&&n=i.length-r||t>=i.length-r)s.logError("MoveColumn: Invalid values for originalPosition, finalPosition");else{var o=function(e){for(var t=e,r=0;r<=t;r++)angular.isDefined(i[r])&&(angular.isDefined(i[r].colDef.visible)&&!1===i[r].colDef.visible||!0===i[r].isRowHeader)&&t++;return t};l.redrawColumnAtPosition(a,o(e),o(t))}}else s.logError("MoveColumn: Please provide valid values for originalPosition and finalPosition")}}}};a.api.registerEventsFromObject(e.events),a.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enableColumnMoving=!1!==e.enableColumnMoving},movableColumnBuilder:function(e,t,r){return e.enableColumnMoving=void 0===e.enableColumnMoving?r.enableColumnMoving:e.enableColumnMoving,i.all([])},updateColumnCache:function(e){e.moveColumns.orderCache=e.getOnlyDataColumns()},verifyColumnOrder:function(i){var n,o=i.rowHeaderColumns.length;angular.forEach(i.moveColumns.orderCache,function(e,t){if(-1!==(n=i.columns.indexOf(e))&&n-o!==t){var r=i.columns.splice(n,1)[0];i.columns.splice(t+o,0,r)}})},redrawColumnAtPosition:function(e,t,r){var i=e.columns;if(t!==r){for(var n=tMath.max(n,r))){var a=i[t];if(a.colDef.enableColumnMoving){if(rMath.abs(p)){b.redrawColumnAtPosition(u.grid,i,o-1);break}}else for(o=i-1;0<=o;o--)if((angular.isUndefined(r[o].colDef.visible)||!0===r[o].colDef.visible)&&(a+=r[o].drawnWidth||r[o].width||r[o].colDef.width)>Math.abs(p)){b.redrawColumnAtPosition(u.grid,i,o+1);break}aMath.ceil(c.grid.gridWidth)){e*=8;var l=new S(u.col.grid,null,null,"uiGridHeaderCell.moveElement");l.x={pixels:e},l.grid.scrollContainers("",l)}for(var s=0,d=0;dr.length&&(i=((o.options.paginationCurrentPage=1)-1)*t),r.slice(i,n+1)},900)},defaultGridOptions:function(e){e.enablePagination=!1!==e.enablePagination,e.enablePaginationControls=!1!==e.enablePaginationControls,e.useExternalPagination=!0===e.useExternalPagination,e.useCustomPagination=!0===e.useCustomPagination,t.isNullOrUndefined(e.totalItems)&&(e.totalItems=0),t.isNullOrUndefined(e.paginationPageSizes)&&(e.paginationPageSizes=[250,500,1e3]),t.isNullOrUndefined(e.paginationPageSize)&&(0r.paginationApi.getTotalPages()?o.paginationCurrentPage=r.paginationApi.getTotalPages():d.onPaginationChanged(r.grid,o.paginationCurrentPage,o.paginationPageSize))});r.$on("$destroy",function(){l()}),r.cantPageForward=function(){return r.paginationApi.getTotalPages()?r.cantPageToLast():o.data.length<1},r.cantPageToLast=function(){var e=r.paginationApi.getTotalPages();return!e||o.paginationCurrentPage>=e},r.cantPageBackward=function(){return o.paginationCurrentPage<=1};var s=function(e){e&&c.focus.bySelector(t,".ui-grid-pager-control-input")};r.pageFirstPageClick=function(){r.paginationApi.seek(1),s(r.cantPageBackward())},r.pagePreviousPageClick=function(){r.paginationApi.previousPage(),s(r.cantPageBackward())},r.pageNextPageClick=function(){r.paginationApi.nextPage(),s(r.cantPageForward())},r.pageLastPageClick=function(){r.paginationApi.seek(r.paginationApi.getTotalPages()),s(r.cantPageToLast())}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.pinning",["ui.grid"]);e.constant("uiGridPinningConstants",{container:{LEFT:"left",RIGHT:"right",NONE:""}}),e.service("uiGridPinningService",["gridUtil","GridRenderContainer","i18nService","uiGridPinningConstants",function(a,e,l,s){var d={initializeGrid:function(r){d.defaultGridOptions(r.options),r.registerColumnBuilder(d.pinningColumnBuilder);var e={events:{pinning:{columnPinned:function(e,t){}}},methods:{pinning:{pinColumn:function(e,t){d.pinColumn(r,e,t)}}}};r.api.registerEventsFromObject(e.events),r.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enablePinning=!1!==e.enablePinning,e.hidePinLeft=e.enablePinning&&e.hidePinLeft,e.hidePinRight=e.enablePinning&&e.hidePinRight},pinningColumnBuilder:function(e,t,r){if(e.enablePinning=void 0===e.enablePinning?r.enablePinning:e.enablePinning,e.hidePinLeft=void 0===e.hidePinLeft?r.hidePinLeft:e.hidePinLeft,e.hidePinRight=void 0===e.hidePinRight?r.hidePinRight:e.hidePinRight,e.pinnedLeft?(t.renderContainer="left",t.grid.createLeftContainer()):e.pinnedRight&&(t.renderContainer="right",t.grid.createRightContainer()),e.enablePinning){var i={name:"ui.grid.pinning.pinLeft",title:l.get().pinning.pinLeft,icon:"ui-grid-icon-left-open",shown:function(){return void 0===this.context.col.renderContainer||!this.context.col.renderContainer||"left"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.LEFT)}},n={name:"ui.grid.pinning.pinRight",title:l.get().pinning.pinRight,icon:"ui-grid-icon-right-open",shown:function(){return void 0===this.context.col.renderContainer||!this.context.col.renderContainer||"right"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.RIGHT)}},o={name:"ui.grid.pinning.unpin",title:l.get().pinning.unpin,icon:"ui-grid-icon-cancel",shown:function(){return void 0!==this.context.col.renderContainer&&null!==this.context.col.renderContainer&&"body"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.NONE)}};e.hidePinLeft||a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.pinLeft")||t.menuItems.push(i),e.hidePinRight||a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.pinRight")||t.menuItems.push(n),a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.unpin")||t.menuItems.push(o)}},pinColumn:function(e,t,r){r===s.container.NONE?(t.renderContainer=null,t.colDef.pinnedLeft=t.colDef.pinnedRight=!1):(t.renderContainer=r)===s.container.LEFT?e.createLeftContainer():r===s.container.RIGHT&&e.createRightContainer(),e.refresh().then(function(){e.api.pinning.raise.columnPinned(t.colDef,r)})}};return d}]),e.directive("uiGridPinning",["gridUtil","uiGridPinningService",function(e,n){return{require:"uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(i.grid)},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.resizeColumns",["ui.grid"]);e.service("uiGridResizeColumnsService",["gridUtil","$q","$rootScope",function(i,n,o){return{defaultGridOptions:function(e){e.enableColumnResizing=!1!==e.enableColumnResizing,!1===e.enableColumnResize&&(e.enableColumnResizing=!1)},colResizerColumnBuilder:function(e,t,r){return e.enableColumnResizing=void 0===e.enableColumnResizing?r.enableColumnResizing:e.enableColumnResizing,!1===e.enableColumnResize&&(e.enableColumnResizing=!1),n.all([])},registerPublicApi:function(e){e.api.registerEventsFromObject({colResizable:{columnSizeChanged:function(e,t){}}})},fireColumnSizeChanged:function(e,t,r){o.$applyAsync(function(){e.api.colResizable?e.api.colResizable.raise.columnSizeChanged(t,r):i.logError("The resizeable api is not registered, this may indicate that you've included the module but not added the 'ui-grid-resize-columns' directive to your grid definition. Cannot raise any events.")})},findTargetCol:function(e,t,r){var i=e.getRenderContainer();if("left"===t){var n=i.visibleColumnCache.indexOf(e);return i.visibleColumnCache[n-1*r]}return e}}}]),e.directive("uiGridResizeColumns",["gridUtil","uiGridResizeColumnsService",function(e,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.defaultGridOptions(i.grid.options),i.grid.registerColumnBuilder(n.colResizerColumnBuilder),n.registerPublicApi(i.grid)},post:function(e,t,r,i){}}}}}]),e.directive("uiGridHeaderCell",["gridUtil","$templateCache","$compile","$q","uiGridResizeColumnsService","uiGridConstants",function(e,o,u,t,c,g){return{priority:-10,require:"^uiGrid",compile:function(){return{post:function(a,l,e,t){var r=t.grid;if(r.options.enableColumnResizing){var s=o.get("ui-grid/columnResizer"),d=1;r.isRTL()&&(a.position="left",d=-1);var i=function(){for(var e=l[0].getElementsByClassName("ui-grid-column-resizer"),t=0;t');return{priority:0,scope:{col:"=",position:"@",renderIndex:"="},require:"?^uiGrid",link:function(l,s,e,d){var o=0,a=0,u=0,c=1;function g(e){d.grid.refreshCanvas(!0).then(function(){d.grid.queueGridRefresh()})}function p(e,t){var r=t;return e.minWidth&&re.maxWidth&&(r=e.maxWidth),r}function r(e,t){e.originalEvent&&(e=e.originalEvent),e.preventDefault(),(a=(e.targetTouches?e.targetTouches[0]:e).clientX-u)<0?a=0:a>d.grid.gridWidth&&(a=d.grid.gridWidth);var r=w.findTargetCol(l.col,l.position,c);if(!1!==r.colDef.enableColumnResizing){d.grid.element.hasClass("column-resizing")||d.grid.element.addClass("column-resizing");var i=a-o,n=parseInt(r.drawnWidth+i*c,10);a+=(p(r,n)-n)*c,b.css({left:a+"px"}),d.fireEvent(C.events.ITEM_DRAGGING)}}function i(e,t){e.originalEvent&&(e=e.originalEvent),e.preventDefault(),d.grid.element.removeClass("column-resizing"),b.remove();var r=(a=(e.changedTouches?e.changedTouches[0]:e).clientX-u)-o;if(0===r)return m(),void f();var i=w.findTargetCol(l.col,l.position,c);if(!1!==i.colDef.enableColumnResizing){var n=parseInt(i.drawnWidth+r*c,10);i.width=p(i,n),i.hasCustomWidth=!0,g(),w.fireColumnSizeChanged(d.grid,i.colDef,r),m(),f()}}d.grid.isRTL()&&(l.position="left",c=-1),"left"===l.position?s.addClass("left"):"right"===l.position&&s.addClass("right");var n=function(e,t){e.originalEvent&&(e=e.originalEvent),e.stopPropagation(),u=d.grid.element[0].getBoundingClientRect().left,o=(e.targetTouches?e.targetTouches[0]:e).clientX-u,d.grid.element.append(b),b.css({left:o}),"touchstart"===e.type?(h.on("touchend",i),h.on("touchmove",r),s.off("mousedown",n)):(h.on("mouseup",i),h.on("mousemove",r),s.off("touchstart",n))},f=function(){s.on("mousedown",n),s.on("touchstart",n)},m=function(){h.off("mouseup",i),h.off("touchend",i),h.off("mousemove",r),h.off("touchmove",r),s.off("mousedown",n),s.off("touchstart",n)};f();var t=function(e,t){e.stopPropagation();var r=w.findTargetCol(l.col,l.position,c);if(!1!==r.colDef.enableColumnResizing){var i,n=0,o=v.closestElm(s,".ui-grid-render-container").querySelectorAll("."+C.COL_CLASS_PREFIX+r.uid+" .ui-grid-cell-contents");Array.prototype.forEach.call(o,function(e){var i;angular.element(e).parent().hasClass("ui-grid-header-cell")&&(i=angular.element(e).parent()[0].querySelectorAll(".ui-grid-column-menu-button")),v.fakeElement(e,{},function(e){var t=angular.element(e);t.attr("style","float: left");var r=v.elementWidth(t);i&&(r+=v.elementWidth(i));ne.value||null===e.value)&&(e.value=t)}},avg:{label:n.get().aggregation.avg,menuTitle:n.get().grouping.aggregate_avg,aggregationFn:function(e,t,r){void 0===e.count?e.count=1:e.count++,isNaN(r)||(void 0===e.value||void 0===e.sum?(e.value=r,e.sum=r):(e.sum+=r,e.value=e.sum/e.count))}}}},finaliseAggregation:function(e,t){t.col.treeAggregationUpdateEntity&&void 0!==e&&void 0!==e.entity["$$"+t.col.uid]&&angular.extend(t,e.entity["$$"+t.col.uid]),"function"==typeof t.col.treeAggregationFinalizerFn&&t.col.treeAggregationFinalizerFn(t),"function"==typeof t.col.customTreeAggregationFinalizerFn&&t.col.customTreeAggregationFinalizerFn(t),void 0===t.rendered&&(t.rendered=t.label?t.label+t.value:t.value)},finaliseAggregations:function(e){null!=e&&void 0!==e.treeNode.aggregations&&e.treeNode.aggregations.forEach(function(r){if(s.finaliseAggregation(e,r),r.col.treeAggregationUpdateEntity){var i={};angular.forEach(r,function(e,t){r.hasOwnProperty(t)&&"col"!==t&&(i[t]=e)}),e.entity["$$"+r.col.uid]=i}})},treeFooterAggregationType:function(e,t){return s.finaliseAggregation(void 0,t.treeFooterAggregation),void 0===t.treeFooterAggregation.value||null===t.treeFooterAggregation.rendered?"":t.treeFooterAggregation.rendered}};return s}]),e.directive("uiGridTreeBaseRowHeaderButtons",["$templateCache","uiGridTreeBaseService",function(e,o){return{replace:!0,restrict:"E",template:e.get("ui-grid/treeBaseRowHeaderButtons"),scope:!0,require:"^uiGrid",link:function(e,t,r,i){var n=i.grid;e.treeButtonClass=function(e){if(n.options.showTreeExpandNoChildren&&-1 -1}":"{'ui-grid-tree-header-row': row.treeLevel > -1}",r.attr("ng-class",n),{pre:function(e,t,r,i){},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.treeView",["ui.grid","ui.grid.treeBase"]);e.constant("uiGridTreeViewConstants",{featureName:"treeView",rowHeaderColName:"treeBaseRowHeaderCol",EXPANDED:"expanded",COLLAPSED:"collapsed",aggregation:{COUNT:"count",SUM:"sum",MAX:"max",MIN:"min",AVG:"avg"}}),e.service("uiGridTreeViewService",["$q","uiGridTreeViewConstants","uiGridTreeBaseConstants","uiGridTreeBaseService","gridUtil","GridRow","gridClassFactory","i18nService","uiGridConstants",function(e,t,r,n,i,o,a,l,s){var d={initializeGrid:function(e,t){n.initializeGrid(e,t),e.treeView={},e.registerRowsProcessor(d.adjustSorting,60);var r={treeView:{}},i={treeView:{}};e.api.registerEventsFromObject(r),e.api.registerMethodsFromObject(i)},defaultGridOptions:function(e){e.enableTreeView=!1!==e.enableTreeView},adjustSorting:function(e){return this.columns.forEach(function(e){e.sort&&(e.sort.ignoreSort=!0)}),e}};return d}]),e.directive("uiGridTreeView",["uiGridTreeViewConstants","uiGridTreeViewService","$templateCache",function(e,n,t){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){!1!==i.grid.options.enableTreeView&&n.initializeGrid(i.grid,e)},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.validate",["ui.grid"]);e.service("uiGridValidateService",["$sce","$q","$http","i18nService","uiGridConstants",function(n,u,e,o,t){var c={validatorFactories:{},setExternalFactoryFunction:function(e){c.externalFactoryFunction=e},clearExternalFactory:function(){delete c.externalFactoryFunction},getValidatorFromExternalFactory:function(e,t){return c.externalFactoryFunction(e,t).validatorFactory(t)},getMessageFromExternalFactory:function(e,t){return c.externalFactoryFunction(e,t).messageFunction(t)},setValidator:function(e,t,r){c.validatorFactories[e]={validatorFactory:t,messageFunction:r}},getValidator:function(e,t){if(c.externalFactoryFunction){var r=c.getValidatorFromExternalFactory(e,t);if(r)return r}if(!c.validatorFactories[e])throw"Invalid validator name: "+e;return c.validatorFactories[e].validatorFactory(t)},getMessage:function(e,t){if(c.externalFactoryFunction){var r=c.getMessageFromExternalFactory(e,t);if(r)return r}return c.validatorFactories[e].messageFunction(t)},isInvalid:function(e,t){return e["$$invalid"+t.name]},setInvalid:function(e,t){e["$$invalid"+t.name]=!0},setValid:function(e,t){delete e["$$invalid"+t.name]},setError:function(e,t,r){e["$$errors"+t.name]||(e["$$errors"+t.name]={}),e["$$errors"+t.name][r]=!0},clearError:function(e,t,r){e["$$errors"+t.name]&&r in e["$$errors"+t.name]&&delete e["$$errors"+t.name][r]},getErrorMessages:function(e,t){var r=[];return e["$$errors"+t.name]&&0!==Object.keys(e["$$errors"+t.name]).length&&Object.keys(e["$$errors"+t.name]).sort().forEach(function(e){r.push(c.getMessage(e,t.validators[e]))}),r},getFormattedErrors:function(e,t){var r="",i=c.getErrorMessages(e,t);if(i.length)return i.forEach(function(e){r+=e+"
    "}),n.trustAsHtml("

    "+o.getSafeText("validate.error")+"

    "+r)},getTitleFormattedErrors:function(e,t){var r="",i=c.getErrorMessages(e,t);if(i.length)return i.forEach(function(e){r+=e+"\n"}),n.trustAsHtml(o.getSafeText("validate.error")+"\n"+r)},runValidators:function(e,t,n,o,a){if(n!==o){if(void 0===t.name||!t.name)throw new Error("colDef.name is required to perform validation");c.setValid(e,t);var r=function(t,r,i){return function(e){e||(c.setInvalid(t,r),c.setError(t,r,i),a&&a.api.validate.raise.validationFailed(t,r,n,o))}},i=[];for(var l in t.validators){c.clearError(e,t,l);var s=c.getValidator(l,t.validators[l]),d=u.when(s(o,n,e,t)).then(r(e,t,l));i.push(d)}return u.all(i)}},createDefaultValidators:function(){c.setValidator("minLength",function(n){return function(e,t,r,i){return null==t||""===t||t.length>=n}},function(e){return o.getSafeText("validate.minLength").replace("THRESHOLD",e)}),c.setValidator("maxLength",function(n){return function(e,t,r,i){return null==t||""===t||t.length<=n}},function(e){return o.getSafeText("validate.maxLength").replace("THRESHOLD",e)}),c.setValidator("required",function(n){return function(e,t,r,i){return!n||!(null==t||""===t)}},function(e){return o.getSafeText("validate.required")})},initializeGrid:function(e,n){n.validate={isInvalid:c.isInvalid,getFormattedErrors:c.getFormattedErrors,getTitleFormattedErrors:c.getTitleFormattedErrors,runValidators:c.runValidators};var t={events:{validate:{validationFailed:function(e,t,r,i){}}},methods:{validate:{isInvalid:function(e,t){return n.validate.isInvalid(e,t)},getErrorMessages:function(e,t){return n.validate.getErrorMessages(e,t)},getFormattedErrors:function(e,t){return n.validate.getFormattedErrors(e,t)},getTitleFormattedErrors:function(e,t){return n.validate.getTitleFormattedErrors(e,t)}}}};n.api.registerEventsFromObject(t.events),n.api.registerMethodsFromObject(t.methods),n.edit&&n.api.edit.on.afterCellEdit(e,function(e,t,r,i){n.validate.runValidators(e,t,r,i,n)}),c.createDefaultValidators()}};return c}]),e.directive("uiGridValidate",["gridUtil","uiGridValidateService",function(e,n){return{priority:0,replace:!0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(e,i.grid)},post:function(e,t,r,i){}}}}}])}(),angular.module("ui.grid").run(["$templateCache",function(e){"use strict";e.put("ui-grid/ui-grid-filter",'
     
     
    '),e.put("ui-grid/ui-grid-footer",''),e.put("ui-grid/ui-grid-grid-footer",''),e.put("ui-grid/ui-grid-header",'
    \x3c!-- theader --\x3e
    '),e.put("ui-grid/ui-grid-menu-button",'
     
    '),e.put("ui-grid/ui-grid-menu-header-item",'
  • '),e.put("ui-grid/ui-grid-no-header",'
    '),e.put("ui-grid/ui-grid-row","
    "),e.put("ui-grid/ui-grid",'
    \x3c!-- TODO (c0bra): add "scoped" attr here, eventually? --\x3e
    '),e.put("ui-grid/uiGridCell",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/uiGridColumnMenu",'
    \x3c!--
    \n
    \n
      \n
      \n
    • Sort Ascending
    • \n
    • Sort Descending
    • \n
    • Remove Sort
    • \n
      \n
    \n
    \n
    --\x3e
    '),e.put("ui-grid/uiGridFooterCell",'
    {{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}
    '),e.put("ui-grid/uiGridHeaderCell",'
    {{ col.displayName CUSTOM_FILTERS }} {{col.sort.priority + 1}}
    '),e.put("ui-grid/uiGridMenu",'
    '),e.put("ui-grid/uiGridMenuItem",''),e.put("ui-grid/uiGridRenderContainer","
    \x3c!-- All of these dom elements are replaced in place --\x3e
    "),e.put("ui-grid/uiGridViewport",'
    \x3c!-- tbody --\x3e
    '),e.put("ui-grid/cellEditor",'
    '),e.put("ui-grid/dropdownEditor",'
    '),e.put("ui-grid/fileChooserEditor",'
    '),e.put("ui-grid/emptyBaseLayerContainer",'
    '),e.put("ui-grid/expandableRow",'
    '),e.put("ui-grid/expandableRowHeader",'
    '),e.put("ui-grid/expandableScrollFiller","
    "),e.put("ui-grid/expandableTopRowHeader",'
    '),e.put("ui-grid/csvLink",'LINK_LABEL'),e.put("ui-grid/importerMenuItem",'
  • '),e.put("ui-grid/importerMenuItemContainer","
    "),e.put("ui-grid/pagination",'
    {{ 1 + paginationApi.getFirstRowIndex() }} - {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
    '),e.put("ui-grid/columnResizer",'
    '),e.put("ui-grid/gridFooterSelectedItems",'({{"search.selectedItems" | t}} {{grid.selection.selectedCount}})'),e.put("ui-grid/selectionHeaderCell",'
    \x3c!--
     
    --\x3e
    '),e.put("ui-grid/selectionRowHeader",'
    '),e.put("ui-grid/selectionRowHeaderButtons",''),e.put("ui-grid/selectionSelectAllButtons",'
    '),e.put("ui-grid/treeBaseExpandAllButtons",'
    '),e.put("ui-grid/treeBaseHeaderCell",'
    '),e.put("ui-grid/treeBaseRowHeader",'
    '),e.put("ui-grid/treeBaseRowHeaderButtons",'
     
    '),e.put("ui-grid/cellTitleValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/cellTooltipValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    ')}]); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.move-columns.js b/release/4.4.11/ui-grid.move-columns.js new file mode 100644 index 000000000..f65537c47 --- /dev/null +++ b/release/4.4.11/ui-grid.move-columns.js @@ -0,0 +1,581 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.moveColumns + * @description + * + * # ui.grid.moveColumns + * + * + * + * This module provides column moving capability to ui.grid. It enables to change the position of columns. + *
    + */ + var module = angular.module('ui.grid.moveColumns', ['ui.grid']); + + /** + * @ngdoc service + * @name ui.grid.moveColumns.service:uiGridMoveColumnService + * @description Service for column moving feature. + */ + module.service('uiGridMoveColumnService', ['$q', '$rootScope', '$log', 'ScrollEvent', 'uiGridConstants', 'gridUtil', function ($q, $rootScope, $log, ScrollEvent, uiGridConstants, gridUtil) { + + var service = { + initializeGrid: function (grid) { + var self = this; + this.registerPublicApi(grid); + this.defaultGridOptions(grid.options); + grid.moveColumns = {orderCache: []}; // Used to cache the order before columns are rebuilt + grid.registerColumnBuilder(self.movableColumnBuilder); + grid.registerDataChangeCallback(self.verifyColumnOrder, [uiGridConstants.dataChange.COLUMN]); + }, + registerPublicApi: function (grid) { + var self = this; + /** + * @ngdoc object + * @name ui.grid.moveColumns.api:PublicApi + * @description Public Api for column moving feature. + */ + var publicApi = { + events: { + /** + * @ngdoc event + * @name columnPositionChanged + * @eventOf ui.grid.moveColumns.api:PublicApi + * @description raised when column is moved + *
    +             *      gridApi.colMovable.on.columnPositionChanged(scope,function(colDef, originalPosition, newPosition){})
    +             * 
    + * @param {object} colDef the column that was moved + * @param {integer} originalPosition of the column + * @param {integer} finalPosition of the column + */ + colMovable: { + columnPositionChanged: function (colDef, originalPosition, newPosition) { + } + } + }, + methods: { + /** + * @ngdoc method + * @name moveColumn + * @methodOf ui.grid.moveColumns.api:PublicApi + * @description Method can be used to change column position. + *
    +             *      gridApi.colMovable.moveColumn(oldPosition, newPosition)
    +             * 
    + * @param {integer} originalPosition of the column + * @param {integer} finalPosition of the column + */ + colMovable: { + moveColumn: function (originalPosition, finalPosition) { + var columns = grid.columns; + if (!angular.isNumber(originalPosition) || !angular.isNumber(finalPosition)) { + gridUtil.logError('MoveColumn: Please provide valid values for originalPosition and finalPosition'); + return; + } + var nonMovableColumns = 0; + for (var i = 0; i < columns.length; i++) { + if ((angular.isDefined(columns[i].colDef.visible) && columns[i].colDef.visible === false) || columns[i].isRowHeader === true) { + nonMovableColumns++; + } + } + if (originalPosition >= (columns.length - nonMovableColumns) || finalPosition >= (columns.length - nonMovableColumns)) { + gridUtil.logError('MoveColumn: Invalid values for originalPosition, finalPosition'); + return; + } + var findPositionForRenderIndex = function (index) { + var position = index; + for (var i = 0; i <= position; i++) { + if (angular.isDefined(columns[i]) && ((angular.isDefined(columns[i].colDef.visible) && columns[i].colDef.visible === false) || columns[i].isRowHeader === true)) { + position++; + } + } + return position; + }; + self.redrawColumnAtPosition(grid, findPositionForRenderIndex(originalPosition), findPositionForRenderIndex(finalPosition)); + } + } + } + }; + grid.api.registerEventsFromObject(publicApi.events); + grid.api.registerMethodsFromObject(publicApi.methods); + }, + defaultGridOptions: function (gridOptions) { + /** + * @ngdoc object + * @name ui.grid.moveColumns.api:GridOptions + * + * @description Options for configuring the move column feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + /** + * @ngdoc object + * @name enableColumnMoving + * @propertyOf ui.grid.moveColumns.api:GridOptions + * @description If defined, sets the default value for the colMovable flag on each individual colDefs + * if their individual enableColumnMoving configuration is not defined. Defaults to true. + */ + gridOptions.enableColumnMoving = gridOptions.enableColumnMoving !== false; + }, + movableColumnBuilder: function (colDef, col, gridOptions) { + var promises = []; + /** + * @ngdoc object + * @name ui.grid.moveColumns.api:ColumnDef + * + * @description Column Definition for move column feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs} + */ + /** + * @ngdoc object + * @name enableColumnMoving + * @propertyOf ui.grid.moveColumns.api:ColumnDef + * @description Enable column moving for the column. + */ + colDef.enableColumnMoving = colDef.enableColumnMoving === undefined ? gridOptions.enableColumnMoving + : colDef.enableColumnMoving; + return $q.all(promises); + }, + /** + * @ngdoc method + * @name updateColumnCache + * @methodOf ui.grid.moveColumns + * @description Cache the current order of columns, so we can restore them after new columnDefs are defined + */ + updateColumnCache: function(grid){ + grid.moveColumns.orderCache = grid.getOnlyDataColumns(); + }, + /** + * @ngdoc method + * @name verifyColumnOrder + * @methodOf ui.grid.moveColumns + * @description dataChangeCallback which uses the cached column order to restore the column order + * when it is reset by altering the columnDefs array. + */ + verifyColumnOrder: function(grid){ + var headerRowOffset = grid.rowHeaderColumns.length; + var newIndex; + + angular.forEach(grid.moveColumns.orderCache, function(cacheCol, cacheIndex){ + newIndex = grid.columns.indexOf(cacheCol); + if ( newIndex !== -1 && newIndex - headerRowOffset !== cacheIndex ){ + var column = grid.columns.splice(newIndex, 1)[0]; + grid.columns.splice(cacheIndex + headerRowOffset, 0, column); + } + }); + }, + redrawColumnAtPosition: function (grid, originalPosition, newPosition) { + var columns = grid.columns; + + if (originalPosition === newPosition) { + return; + } + + //check columns in between move-range to make sure they are visible columns + var pos = (originalPosition < newPosition) ? originalPosition + 1 : originalPosition - 1; + var i0 = Math.min(pos, newPosition); + for (i0; i0 <= Math.max(pos, newPosition); i0++) { + if (columns[i0].visible) { + break; + } + } + if (i0 > Math.max(pos, newPosition)) { + //no visible column found, column did not visibly move + return; + } + + var originalColumn = columns[originalPosition]; + if (originalColumn.colDef.enableColumnMoving) { + if (originalPosition > newPosition) { + for (var i1 = originalPosition; i1 > newPosition; i1--) { + columns[i1] = columns[i1 - 1]; + } + } + else if (newPosition > originalPosition) { + for (var i2 = originalPosition; i2 < newPosition; i2++) { + columns[i2] = columns[i2 + 1]; + } + } + columns[newPosition] = originalColumn; + service.updateColumnCache(grid); + grid.queueGridRefresh(); + $rootScope.$applyAsync(function () { + grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN ); + grid.api.colMovable.raise.columnPositionChanged(originalColumn.colDef, originalPosition, newPosition); + }); + } + } + }; + return service; + }]); + + /** + * @ngdoc directive + * @name ui.grid.moveColumns.directive:uiGridMoveColumns + * @element div + * @restrict A + * @description Adds column moving features to the ui-grid directive. + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.moveColumns']); + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO', age: 45 }, + { name: 'Frank', title: 'Lowly Developer', age: 25 }, + { name: 'Jenny', title: 'Highly Developer', age: 35 } + ]; + $scope.columnDefs = [ + {name: 'name'}, + {name: 'title'}, + {name: 'age'} + ]; + }]); + + + .grid { + width: 100%; + height: 150px; + } + + +
    +
    +
    +
    +
    + */ + module.directive('uiGridMoveColumns', ['uiGridMoveColumnService', function (uiGridMoveColumnService) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridMoveColumnService.initializeGrid(uiGridCtrl.grid); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.moveColumns.directive:uiGridHeaderCell + * @element div + * @restrict A + * + * @description Stacks on top of ui.grid.uiGridHeaderCell to provide capability to be able to move it to reposition column. + * + * On receiving mouseDown event headerCell is cloned, now as the mouse moves the cloned header cell also moved in the grid. + * In case the moving cloned header cell reaches the left or right extreme of grid, grid scrolling is triggered (if horizontal scroll exists). + * On mouseUp event column is repositioned at position where mouse is released and cloned header cell is removed. + * + * Events that invoke cloning of header cell: + * - mousedown + * + * Events that invoke movement of cloned header cell: + * - mousemove + * + * Events that invoke repositioning of column: + * - mouseup + */ + module.directive('uiGridHeaderCell', ['$q', 'gridUtil', 'uiGridMoveColumnService', '$document', '$log', 'uiGridConstants', 'ScrollEvent', + function ($q, gridUtil, uiGridMoveColumnService, $document, $log, uiGridConstants, ScrollEvent) { + return { + priority: -10, + require: '^uiGrid', + compile: function () { + return { + post: function ($scope, $elm, $attrs, uiGridCtrl) { + + if ($scope.col.colDef.enableColumnMoving) { + + /* + * Our general approach to column move is that we listen to a touchstart or mousedown + * event over the column header. When we hear one, then we wait for a move of the same type + * - if we are a touchstart then we listen for a touchmove, if we are a mousedown we listen for + * a mousemove (i.e. a drag) before we decide that there's a move underway. If there's never a move, + * and we instead get a mouseup or a touchend, then we just drop out again and do nothing. + * + */ + var $contentsElm = angular.element( $elm[0].querySelectorAll('.ui-grid-cell-contents') ); + + var gridLeft; + var previousMouseX; + var totalMouseMovement; + var rightMoveLimit; + var elmCloned = false; + var movingElm; + var reducedWidth; + var moveOccurred = false; + + var downFn = function( event ){ + //Setting some variables required for calculations. + gridLeft = $scope.grid.element[0].getBoundingClientRect().left; + if ( $scope.grid.hasLeftContainer() ){ + gridLeft += $scope.grid.renderContainers.left.header[0].getBoundingClientRect().width; + } + + previousMouseX = event.pageX || (event.originalEvent ? event.originalEvent.pageX : 0); + totalMouseMovement = 0; + rightMoveLimit = gridLeft + $scope.grid.getViewportWidth(); + + if ( event.type === 'mousedown' ){ + $document.on('mousemove', moveFn); + $document.on('mouseup', upFn); + } else if ( event.type === 'touchstart' ){ + $document.on('touchmove', moveFn); + $document.on('touchend', upFn); + } + }; + + var moveFn = function( event ) { + var pageX = event.pageX || (event.originalEvent ? event.originalEvent.pageX : 0); + var changeValue = pageX - previousMouseX; + if ( changeValue === 0 ){ return; } + //Disable text selection in Chrome during column move + document.onselectstart = function() { return false; }; + + moveOccurred = true; + + if (!elmCloned) { + cloneElement(); + } + else if (elmCloned) { + moveElement(changeValue); + previousMouseX = pageX; + } + }; + + var upFn = function( event ){ + //Re-enable text selection after column move + document.onselectstart = null; + + //Remove the cloned element on mouse up. + if (movingElm) { + movingElm.remove(); + elmCloned = false; + } + + offAllEvents(); + onDownEvents(); + + if (!moveOccurred){ + return; + } + + var columns = $scope.grid.columns; + var columnIndex = 0; + for (var i = 0; i < columns.length; i++) { + if (columns[i].colDef.name !== $scope.col.colDef.name) { + columnIndex++; + } + else { + break; + } + } + + var targetIndex; + + //Case where column should be moved to a position on its left + if (totalMouseMovement < 0) { + var totalColumnsLeftWidth = 0; + var il; + if ( $scope.grid.isRTL() ){ + for (il = columnIndex + 1; il < columns.length; il++) { + if (angular.isUndefined(columns[il].colDef.visible) || columns[il].colDef.visible === true) { + totalColumnsLeftWidth += columns[il].drawnWidth || columns[il].width || columns[il].colDef.width; + if (totalColumnsLeftWidth > Math.abs(totalMouseMovement)) { + uiGridMoveColumnService.redrawColumnAtPosition + ($scope.grid, columnIndex, il - 1); + break; + } + } + } + } + else { + for (il = columnIndex - 1; il >= 0; il--) { + if (angular.isUndefined(columns[il].colDef.visible) || columns[il].colDef.visible === true) { + totalColumnsLeftWidth += columns[il].drawnWidth || columns[il].width || columns[il].colDef.width; + if (totalColumnsLeftWidth > Math.abs(totalMouseMovement)) { + uiGridMoveColumnService.redrawColumnAtPosition + ($scope.grid, columnIndex, il + 1); + break; + } + } + } + } + + //Case where column should be moved to beginning (or end in RTL) of the grid. + if (totalColumnsLeftWidth < Math.abs(totalMouseMovement)) { + targetIndex = 0; + if ( $scope.grid.isRTL() ){ + targetIndex = columns.length - 1; + } + uiGridMoveColumnService.redrawColumnAtPosition + ($scope.grid, columnIndex, targetIndex); + } + } + + //Case where column should be moved to a position on its right + else if (totalMouseMovement > 0) { + var totalColumnsRightWidth = 0; + var ir; + if ( $scope.grid.isRTL() ){ + for (ir = columnIndex - 1; ir > 0; ir--) { + if (angular.isUndefined(columns[ir].colDef.visible) || columns[ir].colDef.visible === true) { + totalColumnsRightWidth += columns[ir].drawnWidth || columns[ir].width || columns[ir].colDef.width; + if (totalColumnsRightWidth > totalMouseMovement) { + uiGridMoveColumnService.redrawColumnAtPosition + ($scope.grid, columnIndex, ir); + break; + } + } + } + } + else { + for (ir = columnIndex + 1; ir < columns.length; ir++) { + if (angular.isUndefined(columns[ir].colDef.visible) || columns[ir].colDef.visible === true) { + totalColumnsRightWidth += columns[ir].drawnWidth || columns[ir].width || columns[ir].colDef.width; + if (totalColumnsRightWidth > totalMouseMovement) { + uiGridMoveColumnService.redrawColumnAtPosition + ($scope.grid, columnIndex, ir - 1); + break; + } + } + } + } + + + //Case where column should be moved to end (or beginning in RTL) of the grid. + if (totalColumnsRightWidth < totalMouseMovement) { + targetIndex = columns.length - 1; + if ( $scope.grid.isRTL() ){ + targetIndex = 0; + } + uiGridMoveColumnService.redrawColumnAtPosition + ($scope.grid, columnIndex, targetIndex); + } + } + + + + }; + + var onDownEvents = function(){ + $contentsElm.on('touchstart', downFn); + $contentsElm.on('mousedown', downFn); + }; + + var offAllEvents = function() { + $contentsElm.off('touchstart', downFn); + $contentsElm.off('mousedown', downFn); + + $document.off('mousemove', moveFn); + $document.off('touchmove', moveFn); + + $document.off('mouseup', upFn); + $document.off('touchend', upFn); + }; + + onDownEvents(); + + + var cloneElement = function () { + elmCloned = true; + + //Cloning header cell and appending to current header cell. + movingElm = $elm.clone(); + $elm.parent().append(movingElm); + + //Left of cloned element should be aligned to original header cell. + movingElm.addClass('movingColumn'); + var movingElementStyles = {}; + movingElementStyles.left = $elm[0].offsetLeft + 'px'; + var gridRight = $scope.grid.element[0].getBoundingClientRect().right; + var elmRight = $elm[0].getBoundingClientRect().right; + if (elmRight > gridRight) { + reducedWidth = $scope.col.drawnWidth + (gridRight - elmRight); + movingElementStyles.width = reducedWidth + 'px'; + } + movingElm.css(movingElementStyles); + }; + + var moveElement = function (changeValue) { + //Calculate total column width + var columns = $scope.grid.columns; + var totalColumnWidth = 0; + for (var i = 0; i < columns.length; i++) { + if (angular.isUndefined(columns[i].colDef.visible) || columns[i].colDef.visible === true) { + totalColumnWidth += columns[i].drawnWidth || columns[i].width || columns[i].colDef.width; + } + } + + //Calculate new position of left of column + var currentElmLeft = movingElm[0].getBoundingClientRect().left - 1; + var currentElmRight = movingElm[0].getBoundingClientRect().right; + var newElementLeft; + + newElementLeft = currentElmLeft - gridLeft + changeValue; + newElementLeft = newElementLeft < rightMoveLimit ? newElementLeft : rightMoveLimit; + + //Update css of moving column to adjust to new left value or fire scroll in case column has reached edge of grid + if ((currentElmLeft >= gridLeft || changeValue > 0) && (currentElmRight <= rightMoveLimit || changeValue < 0)) { + movingElm.css({visibility: 'visible', 'left': (movingElm[0].offsetLeft + + (newElementLeft < rightMoveLimit ? changeValue : (rightMoveLimit - currentElmLeft))) + 'px'}); + } + else if (totalColumnWidth > Math.ceil(uiGridCtrl.grid.gridWidth)) { + changeValue *= 8; + var scrollEvent = new ScrollEvent($scope.col.grid, null, null, 'uiGridHeaderCell.moveElement'); + scrollEvent.x = {pixels: changeValue}; + scrollEvent.grid.scrollContainers('',scrollEvent); + } + + //Calculate total width of columns on the left of the moving column and the mouse movement + var totalColumnsLeftWidth = 0; + for (var il = 0; il < columns.length; il++) { + if (angular.isUndefined(columns[il].colDef.visible) || columns[il].colDef.visible === true) { + if (columns[il].colDef.name !== $scope.col.colDef.name) { + totalColumnsLeftWidth += columns[il].drawnWidth || columns[il].width || columns[il].colDef.width; + } + else { + break; + } + } + } + if ($scope.newScrollLeft === undefined) { + totalMouseMovement += changeValue; + } + else { + totalMouseMovement = $scope.newScrollLeft + newElementLeft - totalColumnsLeftWidth; + } + + //Increase width of moving column, in case the rightmost column was moved and its width was + //decreased because of overflow + if (reducedWidth < $scope.col.drawnWidth) { + reducedWidth += Math.abs(changeValue); + movingElm.css({'width': reducedWidth + 'px'}); + } + }; + + $scope.$on('$destroy', offAllEvents); + } + } + }; + } + }; + }]); +})(); diff --git a/release/4.4.11/ui-grid.move-columns.min.js b/release/4.4.11/ui-grid.move-columns.min.js new file mode 100644 index 000000000..a61601ffc --- /dev/null +++ b/release/4.4.11/ui-grid.move-columns.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.moveColumns",["ui.grid"]);e.service("uiGridMoveColumnService",["$q","$rootScope","$log","ScrollEvent","uiGridConstants","gridUtil",function(o,d,e,i,s,u){var f={initializeGrid:function(e){this.registerPublicApi(e),this.defaultGridOptions(e.options),e.moveColumns={orderCache:[]},e.registerColumnBuilder(this.movableColumnBuilder),e.registerDataChangeCallback(this.verifyColumnOrder,[s.dataChange.COLUMN])},registerPublicApi:function(t){var a=this,e={events:{colMovable:{columnPositionChanged:function(e,i,n){}}},methods:{colMovable:{moveColumn:function(e,i){var o=t.columns;if(angular.isNumber(e)&&angular.isNumber(i)){for(var n=0,r=0;r=o.length-n||i>=o.length-n)u.logError("MoveColumn: Invalid values for originalPosition, finalPosition");else{var l=function(e){for(var i=e,n=0;n<=i;n++)angular.isDefined(o[n])&&(angular.isDefined(o[n].colDef.visible)&&!1===o[n].colDef.visible||!0===o[n].isRowHeader)&&i++;return i};a.redrawColumnAtPosition(t,l(e),l(i))}}else u.logError("MoveColumn: Please provide valid values for originalPosition and finalPosition")}}}};t.api.registerEventsFromObject(e.events),t.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enableColumnMoving=!1!==e.enableColumnMoving},movableColumnBuilder:function(e,i,n){return e.enableColumnMoving=void 0===e.enableColumnMoving?n.enableColumnMoving:e.enableColumnMoving,o.all([])},updateColumnCache:function(e){e.moveColumns.orderCache=e.getOnlyDataColumns()},verifyColumnOrder:function(o){var r,l=o.rowHeaderColumns.length;angular.forEach(o.moveColumns.orderCache,function(e,i){if(-1!==(r=o.columns.indexOf(e))&&r-l!==i){var n=o.columns.splice(r,1)[0];o.columns.splice(i+l,0,n)}})},redrawColumnAtPosition:function(e,i,n){var o=e.columns;if(i!==n){for(var r=iMath.max(r,n))){var t=o[i];if(t.colDef.enableColumnMoving){if(nMath.abs(g)){w.redrawColumnAtPosition(s.grid,o,l-1);break}}else for(l=o-1;0<=l;l--)if((angular.isUndefined(n[l].colDef.visible)||!0===n[l].colDef.visible)&&(t+=n[l].drawnWidth||n[l].width||n[l].colDef.width)>Math.abs(g)){w.redrawColumnAtPosition(s.grid,o,l+1);break}tMath.ceil(f.grid.gridWidth)){e*=8;var a=new M(s.col.grid,null,null,"uiGridHeaderCell.moveElement");a.x={pixels:e},a.grid.scrollContainers("",a)}for(var u=0,d=0;dAlpha This feature is in development. There will almost certainly be breaking api changes, or there are major outstanding bugs. + * + * This module provides pagination support to ui-grid + */ + var module = angular.module('ui.grid.pagination', ['ng', 'ui.grid']); + + /** + * @ngdoc service + * @name ui.grid.pagination.service:uiGridPaginationService + * + * @description Service for the pagination feature + */ + module.service('uiGridPaginationService', ['gridUtil', + function (gridUtil) { + var service = { + /** + * @ngdoc method + * @name initializeGrid + * @methodOf ui.grid.pagination.service:uiGridPaginationService + * @description Attaches the service to a certain grid + * @param {Grid} grid The grid we want to work with + */ + initializeGrid: function (grid) { + service.defaultGridOptions(grid.options); + + /** + * @ngdoc object + * @name ui.grid.pagination.api:PublicAPI + * + * @description Public API for the pagination feature + */ + var publicApi = { + events: { + pagination: { + /** + * @ngdoc event + * @name paginationChanged + * @eventOf ui.grid.pagination.api:PublicAPI + * @description This event fires when the pageSize or currentPage changes + * @param {int} currentPage requested page number + * @param {int} pageSize requested page size + */ + paginationChanged: function (currentPage, pageSize) { } + } + }, + methods: { + pagination: { + /** + * @ngdoc method + * @name getPage + * @methodOf ui.grid.pagination.api:PublicAPI + * @description Returns the number of the current page + */ + getPage: function () { + return grid.options.enablePagination ? grid.options.paginationCurrentPage : null; + }, + /** + * @ngdoc method + * @name getFirstRowIndex + * @methodOf ui.grid.pagination.api:PublicAPI + * @description Returns the index of the first row of the current page. + */ + getFirstRowIndex: function () { + if (grid.options.useCustomPagination) { + return grid.options.paginationPageSizes.reduce(function(result, size, index) { + return index < grid.options.paginationCurrentPage - 1 ? result + size : result; + }, 0); + } + return ((grid.options.paginationCurrentPage - 1) * grid.options.paginationPageSize); + }, + /** + * @ngdoc method + * @name getLastRowIndex + * @methodOf ui.grid.pagination.api:PublicAPI + * @description Returns the index of the last row of the current page. + */ + getLastRowIndex: function () { + if (grid.options.useCustomPagination) { + return publicApi.methods.pagination.getFirstRowIndex() + grid.options.paginationPageSizes[grid.options.paginationCurrentPage - 1] - 1; + } + return Math.min(grid.options.paginationCurrentPage * grid.options.paginationPageSize, grid.options.totalItems) - 1; + }, + /** + * @ngdoc method + * @name getTotalPages + * @methodOf ui.grid.pagination.api:PublicAPI + * @description Returns the total number of pages + */ + getTotalPages: function () { + if (!grid.options.enablePagination) { + return null; + } + + if (grid.options.useCustomPagination) { + return grid.options.paginationPageSizes.length; + } + + return (grid.options.totalItems === 0) ? 1 : Math.ceil(grid.options.totalItems / grid.options.paginationPageSize); + }, + /** + * @ngdoc method + * @name nextPage + * @methodOf ui.grid.pagination.api:PublicAPI + * @description Moves to the next page, if possible + */ + nextPage: function () { + if (!grid.options.enablePagination) { + return; + } + + if (grid.options.totalItems > 0) { + grid.options.paginationCurrentPage = Math.min( + grid.options.paginationCurrentPage + 1, + publicApi.methods.pagination.getTotalPages() + ); + } else { + grid.options.paginationCurrentPage++; + } + }, + /** + * @ngdoc method + * @name previousPage + * @methodOf ui.grid.pagination.api:PublicAPI + * @description Moves to the previous page, if we're not on the first page + */ + previousPage: function () { + if (!grid.options.enablePagination) { + return; + } + + grid.options.paginationCurrentPage = Math.max(grid.options.paginationCurrentPage - 1, 1); + }, + /** + * @ngdoc method + * @name seek + * @methodOf ui.grid.pagination.api:PublicAPI + * @description Moves to the requested page + * @param {int} page The number of the page that should be displayed + */ + seek: function (page) { + if (!grid.options.enablePagination) { + return; + } + if (!angular.isNumber(page) || page < 1) { + throw 'Invalid page number: ' + page; + } + + grid.options.paginationCurrentPage = Math.min(page, publicApi.methods.pagination.getTotalPages()); + } + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + grid.api.registerMethodsFromObject(publicApi.methods); + + var processPagination = function( renderableRows ){ + if (grid.options.useExternalPagination || !grid.options.enablePagination) { + return renderableRows; + } + //client side pagination + var pageSize = parseInt(grid.options.paginationPageSize, 10); + var currentPage = parseInt(grid.options.paginationCurrentPage, 10); + + var visibleRows = renderableRows.filter(function (row) { return row.visible; }); + grid.options.totalItems = visibleRows.length; + + var firstRow = publicApi.methods.pagination.getFirstRowIndex(); + var lastRow = publicApi.methods.pagination.getLastRowIndex(); + + if (firstRow > visibleRows.length) { + currentPage = grid.options.paginationCurrentPage = 1; + firstRow = (currentPage - 1) * pageSize; + } + return visibleRows.slice(firstRow, lastRow + 1); + }; + + grid.registerRowsProcessor(processPagination, 900 ); + + }, + defaultGridOptions: function (gridOptions) { + /** + * @ngdoc object + * @name ui.grid.pagination.api:GridOptions + * + * @description GridOptions for the pagination feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc property + * @name enablePagination + * @propertyOf ui.grid.pagination.api:GridOptions + * @description Enables pagination. Defaults to true. + */ + gridOptions.enablePagination = gridOptions.enablePagination !== false; + /** + * @ngdoc property + * @name enablePaginationControls + * @propertyOf ui.grid.pagination.api:GridOptions + * @description Enables the paginator at the bottom of the grid. Turn this off if you want to implement your + * own controls outside the grid. + */ + gridOptions.enablePaginationControls = gridOptions.enablePaginationControls !== false; + /** + * @ngdoc property + * @name useExternalPagination + * @propertyOf ui.grid.pagination.api:GridOptions + * @description Disables client side pagination. When true, handle the paginationChanged event and set data + * and totalItems. Defaults to `false` + */ + gridOptions.useExternalPagination = gridOptions.useExternalPagination === true; + + /** + * @ngdoc property + * @name useCustomPagination + * @propertyOf ui.grid.pagination.api:GridOptions + * @description Disables client-side pagination. When true, handle the `paginationChanged` event and set `data`, + * `firstRowIndex`, `lastRowIndex`, and `totalItems`. Defaults to `false`. + */ + gridOptions.useCustomPagination = gridOptions.useCustomPagination === true; + + /** + * @ngdoc property + * @name totalItems + * @propertyOf ui.grid.pagination.api:GridOptions + * @description Total number of items, set automatically when using client side pagination, but needs set by user + * for server side pagination + */ + if (gridUtil.isNullOrUndefined(gridOptions.totalItems)) { + gridOptions.totalItems = 0; + } + /** + * @ngdoc property + * @name paginationPageSizes + * @propertyOf ui.grid.pagination.api:GridOptions + * @description Array of page sizes, defaults to `[250, 500, 1000]` + */ + if (gridUtil.isNullOrUndefined(gridOptions.paginationPageSizes)) { + gridOptions.paginationPageSizes = [250, 500, 1000]; + } + /** + * @ngdoc property + * @name paginationPageSize + * @propertyOf ui.grid.pagination.api:GridOptions + * @description Page size, defaults to the first item in paginationPageSizes, or 0 if paginationPageSizes is empty + */ + if (gridUtil.isNullOrUndefined(gridOptions.paginationPageSize)) { + if (gridOptions.paginationPageSizes.length > 0) { + gridOptions.paginationPageSize = gridOptions.paginationPageSizes[0]; + } else { + gridOptions.paginationPageSize = 0; + } + } + /** + * @ngdoc property + * @name paginationCurrentPage + * @propertyOf ui.grid.pagination.api:GridOptions + * @description Current page number, defaults to 1 + */ + if (gridUtil.isNullOrUndefined(gridOptions.paginationCurrentPage)) { + gridOptions.paginationCurrentPage = 1; + } + + /** + * @ngdoc property + * @name paginationTemplate + * @propertyOf ui.grid.pagination.api:GridOptions + * @description A custom template for the pager, defaults to `ui-grid/pagination` + */ + if (gridUtil.isNullOrUndefined(gridOptions.paginationTemplate)) { + gridOptions.paginationTemplate = 'ui-grid/pagination'; + } + }, + /** + * @ngdoc method + * @methodOf ui.grid.pagination.service:uiGridPaginationService + * @name uiGridPaginationService + * @description Raises paginationChanged and calls refresh for client side pagination + * @param {Grid} grid the grid for which the pagination changed + * @param {int} currentPage requested page number + * @param {int} pageSize requested page size + */ + onPaginationChanged: function (grid, currentPage, pageSize) { + grid.api.pagination.raise.paginationChanged(currentPage, pageSize); + if (!grid.options.useExternalPagination) { + grid.queueGridRefresh(); //client side pagination + } + } + }; + + return service; + } + ]); + /** + * @ngdoc directive + * @name ui.grid.pagination.directive:uiGridPagination + * @element div + * @restrict A + * + * @description Adds pagination features to grid + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.pagination']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Alex', car: 'Toyota' }, + { name: 'Sam', car: 'Lexus' }, + { name: 'Joe', car: 'Dodge' }, + { name: 'Bob', car: 'Buick' }, + { name: 'Cindy', car: 'Ford' }, + { name: 'Brian', car: 'Audi' }, + { name: 'Malcom', car: 'Mercedes Benz' }, + { name: 'Dave', car: 'Ford' }, + { name: 'Stacey', car: 'Audi' }, + { name: 'Amy', car: 'Acura' }, + { name: 'Scott', car: 'Toyota' }, + { name: 'Ryan', car: 'BMW' }, + ]; + + $scope.gridOptions = { + data: 'data', + paginationPageSizes: [5, 10, 25], + paginationPageSize: 5, + columnDefs: [ + {name: 'name'}, + {name: 'car'} + ] + } + }]); + + +
    +
    +
    +
    +
    + */ + module.directive('uiGridPagination', ['gridUtil', 'uiGridPaginationService', + function (gridUtil, uiGridPaginationService) { + return { + priority: -200, + scope: false, + require: 'uiGrid', + link: { + pre: function ($scope, $elm, $attr, uiGridCtrl) { + uiGridPaginationService.initializeGrid(uiGridCtrl.grid); + + gridUtil.getTemplate(uiGridCtrl.grid.options.paginationTemplate) + .then(function (contents) { + var template = angular.element(contents); + $elm.append(template); + uiGridCtrl.innerCompile(template); + }); + } + } + }; + } + ]); + + /** + * @ngdoc directive + * @name ui.grid.pagination.directive:uiGridPager + * @element div + * + * @description Panel for handling pagination + */ + module.directive('uiGridPager', ['uiGridPaginationService', 'uiGridConstants', 'gridUtil', 'i18nService', 'i18nConstants', + function (uiGridPaginationService, uiGridConstants, gridUtil, i18nService, i18nConstants) { + return { + priority: -200, + scope: true, + require: '^uiGrid', + link: function ($scope, $elm, $attr, uiGridCtrl) { + var defaultFocusElementSelector = '.ui-grid-pager-control-input'; + $scope.aria = i18nService.getSafeText('pagination.aria'); //Returns an object with all of the aria labels + + var updateLabels = function(){ + $scope.paginationApi = uiGridCtrl.grid.api.pagination; + $scope.sizesLabel = i18nService.getSafeText('pagination.sizes'); + $scope.totalItemsLabel = i18nService.getSafeText('pagination.totalItems'); + $scope.paginationOf = i18nService.getSafeText('pagination.of'); + $scope.paginationThrough = i18nService.getSafeText('pagination.through'); + }; + + + updateLabels(); + + $scope.$on(i18nConstants.UPDATE_EVENT, updateLabels); + + var options = uiGridCtrl.grid.options; + + + uiGridCtrl.grid.renderContainers.body.registerViewportAdjuster(function (adjustment) { + if (options.enablePaginationControls) { + adjustment.height = adjustment.height - gridUtil.elementHeight($elm, "padding"); + } + return adjustment; + }); + + var dataChangeDereg = uiGridCtrl.grid.registerDataChangeCallback(function (grid) { + if (!grid.options.useExternalPagination) { + grid.options.totalItems = grid.rows.length; + } + }, [uiGridConstants.dataChange.ROW]); + + $scope.$on('$destroy', dataChangeDereg); + + var deregP = $scope.$watch('grid.options.paginationCurrentPage + grid.options.paginationPageSize', function (newValues, oldValues) { + if (newValues === oldValues || oldValues === undefined) { + return; + } + + if (!angular.isNumber(options.paginationCurrentPage) || options.paginationCurrentPage < 1) { + options.paginationCurrentPage = 1; + return; + } + + if (options.totalItems > 0 && options.paginationCurrentPage > $scope.paginationApi.getTotalPages()) { + options.paginationCurrentPage = $scope.paginationApi.getTotalPages(); + return; + } + + uiGridPaginationService.onPaginationChanged($scope.grid, options.paginationCurrentPage, options.paginationPageSize); + } + ); + + $scope.$on('$destroy', function() { + deregP(); + }); + + $scope.cantPageForward = function () { + if ($scope.paginationApi.getTotalPages()) { + return $scope.cantPageToLast(); + } else { + return options.data.length < 1; + } + }; + + $scope.cantPageToLast = function () { + var totalPages = $scope.paginationApi.getTotalPages(); + return !totalPages || options.paginationCurrentPage >= totalPages; + }; + + $scope.cantPageBackward = function () { + return options.paginationCurrentPage <= 1; + }; + + var focusToInputIf = function(condition){ + if (condition){ + gridUtil.focus.bySelector($elm, defaultFocusElementSelector); + } + }; + + //Takes care of setting focus to the middle element when focus is lost + $scope.pageFirstPageClick = function () { + $scope.paginationApi.seek(1); + focusToInputIf($scope.cantPageBackward()); + }; + + $scope.pagePreviousPageClick = function () { + $scope.paginationApi.previousPage(); + focusToInputIf($scope.cantPageBackward()); + }; + + $scope.pageNextPageClick = function () { + $scope.paginationApi.nextPage(); + focusToInputIf($scope.cantPageForward()); + }; + + $scope.pageLastPageClick = function () { + $scope.paginationApi.seek($scope.paginationApi.getTotalPages()); + focusToInputIf($scope.cantPageToLast()); + }; + + } + }; + } + ]); +})(); diff --git a/release/4.4.11/ui-grid.pagination.min.js b/release/4.4.11/ui-grid.pagination.min.js new file mode 100644 index 000000000..a7fa280a0 --- /dev/null +++ b/release/4.4.11/ui-grid.pagination.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var n=angular.module("ui.grid.pagination",["ng","ui.grid"]);n.service("uiGridPaginationService",["gridUtil",function(i){var n={initializeGrid:function(o){n.defaultGridOptions(o.options);var g={events:{pagination:{paginationChanged:function(n,i){}}},methods:{pagination:{getPage:function(){return o.options.enablePagination?o.options.paginationCurrentPage:null},getFirstRowIndex:function(){return o.options.useCustomPagination?o.options.paginationPageSizes.reduce(function(n,i,a){return aa.length&&(t=((o.options.paginationCurrentPage=1)-1)*i),a.slice(t,e+1)},900)},defaultGridOptions:function(n){n.enablePagination=!1!==n.enablePagination,n.enablePaginationControls=!1!==n.enablePaginationControls,n.useExternalPagination=!0===n.useExternalPagination,n.useCustomPagination=!0===n.useCustomPagination,i.isNullOrUndefined(n.totalItems)&&(n.totalItems=0),i.isNullOrUndefined(n.paginationPageSizes)&&(n.paginationPageSizes=[250,500,1e3]),i.isNullOrUndefined(n.paginationPageSize)&&(0a.paginationApi.getTotalPages()?o.paginationCurrentPage=a.paginationApi.getTotalPages():s.onPaginationChanged(a.grid,o.paginationCurrentPage,o.paginationPageSize))});a.$on("$destroy",function(){r()}),a.cantPageForward=function(){return a.paginationApi.getTotalPages()?a.cantPageToLast():o.data.length<1},a.cantPageToLast=function(){var n=a.paginationApi.getTotalPages();return!n||o.paginationCurrentPage>=n},a.cantPageBackward=function(){return o.paginationCurrentPage<=1};var p=function(n){n&&P.focus.bySelector(i,".ui-grid-pager-control-input")};a.pageFirstPageClick=function(){a.paginationApi.seek(1),p(a.cantPageBackward())},a.pagePreviousPageClick=function(){a.paginationApi.previousPage(),p(a.cantPageBackward())},a.pageNextPageClick=function(){a.paginationApi.nextPage(),p(a.cantPageForward())},a.pageLastPageClick=function(){a.paginationApi.seek(a.paginationApi.getTotalPages()),p(a.cantPageToLast())}}}}])}(); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.pinning.js b/release/4.4.11/ui-grid.pinning.js new file mode 100644 index 000000000..79007c198 --- /dev/null +++ b/release/4.4.11/ui-grid.pinning.js @@ -0,0 +1,282 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.pinning + * @description + * + * # ui.grid.pinning + * + * + * + * This module provides column pinning to the end user via menu options in the column header + * + *
    + */ + + var module = angular.module('ui.grid.pinning', ['ui.grid']); + + module.constant('uiGridPinningConstants', { + container: { + LEFT: 'left', + RIGHT: 'right', + NONE: '' + } + }); + + module.service('uiGridPinningService', ['gridUtil', 'GridRenderContainer', 'i18nService', 'uiGridPinningConstants', function (gridUtil, GridRenderContainer, i18nService, uiGridPinningConstants) { + var service = { + + initializeGrid: function (grid) { + service.defaultGridOptions(grid.options); + + // Register a column builder to add new menu items for pinning left and right + grid.registerColumnBuilder(service.pinningColumnBuilder); + + /** + * @ngdoc object + * @name ui.grid.pinning.api:PublicApi + * + * @description Public Api for pinning feature + */ + var publicApi = { + events: { + pinning: { + /** + * @ngdoc event + * @name columnPin + * @eventOf ui.grid.pinning.api:PublicApi + * @description raised when column pin state has changed + *
    +               *   gridApi.pinning.on.columnPinned(scope, function(colDef){})
    +               * 
    + * @param {object} colDef the column that was changed + * @param {string} container the render container the column is in ('left', 'right', '') + */ + columnPinned: function(colDef, container) { + } + } + }, + methods: { + pinning: { + /** + * @ngdoc function + * @name pinColumn + * @methodOf ui.grid.pinning.api:PublicApi + * @description pin column left, right, or none + *
    +               *   gridApi.pinning.pinColumn(col, uiGridPinningConstants.container.LEFT)
    +               * 
    + * @param {gridColumn} col the column being pinned + * @param {string} container one of the recognised types + * from uiGridPinningConstants + */ + pinColumn: function(col, container) { + service.pinColumn(grid, col, container); + } + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + grid.api.registerMethodsFromObject(publicApi.methods); + }, + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.pinning.api:GridOptions + * + * @description GridOptions for pinning feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc object + * @name enablePinning + * @propertyOf ui.grid.pinning.api:GridOptions + * @description Enable pinning for the entire grid. + *
    Defaults to true + */ + gridOptions.enablePinning = gridOptions.enablePinning !== false; + /** + * @ngdoc object + * @name hidePinLeft + * @propertyOf ui.grid.pinning.api:GridOptions + * @description Hide Pin Left for the entire grid. + *
    Defaults to false + */ + gridOptions.hidePinLeft = gridOptions.enablePinning && gridOptions.hidePinLeft; + /** + * @ngdoc object + * @name hidePinRight + * @propertyOf ui.grid.pinning.api:GridOptions + * @description Hide Pin Right pinning for the entire grid. + *
    Defaults to false + */ + gridOptions.hidePinRight = gridOptions.enablePinning && gridOptions.hidePinRight; + }, + + pinningColumnBuilder: function (colDef, col, gridOptions) { + //default to true unless gridOptions or colDef is explicitly false + + /** + * @ngdoc object + * @name ui.grid.pinning.api:ColumnDef + * + * @description ColumnDef for pinning feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs} + */ + + /** + * @ngdoc object + * @name enablePinning + * @propertyOf ui.grid.pinning.api:ColumnDef + * @description Enable pinning for the individual column. + *
    Defaults to true + */ + colDef.enablePinning = colDef.enablePinning === undefined ? gridOptions.enablePinning : colDef.enablePinning; + /** + * @ngdoc object + * @name hidePinLeft + * @propertyOf ui.grid.pinning.api:ColumnDef + * @description Hide Pin Left for the individual column. + *
    Defaults to false + */ + colDef.hidePinLeft = colDef.hidePinLeft === undefined ? gridOptions.hidePinLeft : colDef.hidePinLeft; + /** + * @ngdoc object + * @name hidePinRight + * @propertyOf ui.grid.pinning.api:ColumnDef + * @description Hide Pin Right for the individual column. + *
    Defaults to false + */ + colDef.hidePinRight = colDef.hidePinRight === undefined ? gridOptions.hidePinRight : colDef.hidePinRight; + + /** + * @ngdoc object + * @name pinnedLeft + * @propertyOf ui.grid.pinning.api:ColumnDef + * @description Column is pinned left when grid is rendered + *
    Defaults to false + */ + + /** + * @ngdoc object + * @name pinnedRight + * @propertyOf ui.grid.pinning.api:ColumnDef + * @description Column is pinned right when grid is rendered + *
    Defaults to false + */ + if (colDef.pinnedLeft) { + col.renderContainer = 'left'; + col.grid.createLeftContainer(); + } + else if (colDef.pinnedRight) { + col.renderContainer = 'right'; + col.grid.createRightContainer(); + } + + if (!colDef.enablePinning) { + return; + } + + var pinColumnLeftAction = { + name: 'ui.grid.pinning.pinLeft', + title: i18nService.get().pinning.pinLeft, + icon: 'ui-grid-icon-left-open', + shown: function () { + return typeof(this.context.col.renderContainer) === 'undefined' || !this.context.col.renderContainer || this.context.col.renderContainer !== 'left'; + }, + action: function () { + service.pinColumn(this.context.col.grid, this.context.col, uiGridPinningConstants.container.LEFT); + } + }; + + var pinColumnRightAction = { + name: 'ui.grid.pinning.pinRight', + title: i18nService.get().pinning.pinRight, + icon: 'ui-grid-icon-right-open', + shown: function () { + return typeof(this.context.col.renderContainer) === 'undefined' || !this.context.col.renderContainer || this.context.col.renderContainer !== 'right'; + }, + action: function () { + service.pinColumn(this.context.col.grid, this.context.col, uiGridPinningConstants.container.RIGHT); + } + }; + + var removePinAction = { + name: 'ui.grid.pinning.unpin', + title: i18nService.get().pinning.unpin, + icon: 'ui-grid-icon-cancel', + shown: function () { + return typeof(this.context.col.renderContainer) !== 'undefined' && this.context.col.renderContainer !== null && this.context.col.renderContainer !== 'body'; + }, + action: function () { + service.pinColumn(this.context.col.grid, this.context.col, uiGridPinningConstants.container.NONE); + } + }; + + //// Skip from menu if hidePinLeft or hidePinRight is true + if (!colDef.hidePinLeft && !gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.pinning.pinLeft')) { + col.menuItems.push(pinColumnLeftAction); + } + if (!colDef.hidePinRight && !gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.pinning.pinRight')) { + col.menuItems.push(pinColumnRightAction); + } + if (!gridUtil.arrayContainsObjectWithProperty(col.menuItems, 'name', 'ui.grid.pinning.unpin')) { + col.menuItems.push(removePinAction); + } + }, + + pinColumn: function(grid, col, container) { + if (container === uiGridPinningConstants.container.NONE) { + col.renderContainer = null; + col.colDef.pinnedLeft = col.colDef.pinnedRight = false; + } + else { + col.renderContainer = container; + if (container === uiGridPinningConstants.container.LEFT) { + grid.createLeftContainer(); + } + else if (container === uiGridPinningConstants.container.RIGHT) { + grid.createRightContainer(); + } + } + + grid.refresh() + .then(function() { + grid.api.pinning.raise.columnPinned( col.colDef, container ); + }); + } + }; + + return service; + }]); + + module.directive('uiGridPinning', ['gridUtil', 'uiGridPinningService', + function (gridUtil, uiGridPinningService) { + return { + require: 'uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridPinningService.initializeGrid(uiGridCtrl.grid); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + } + }; + } + }; + }]); + + +})(); diff --git a/release/4.4.11/ui-grid.pinning.min.js b/release/4.4.11/ui-grid.pinning.min.js new file mode 100644 index 000000000..ea3df2511 --- /dev/null +++ b/release/4.4.11/ui-grid.pinning.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var n=angular.module("ui.grid.pinning",["ui.grid"]);n.constant("uiGridPinningConstants",{container:{LEFT:"left",RIGHT:"right",NONE:""}}),n.service("uiGridPinningService",["gridUtil","GridRenderContainer","i18nService","uiGridPinningConstants",function(c,n,d,u){var a={initializeGrid:function(e){a.defaultGridOptions(e.options),e.registerColumnBuilder(a.pinningColumnBuilder);var n={events:{pinning:{columnPinned:function(n,i){}}},methods:{pinning:{pinColumn:function(n,i){a.pinColumn(e,n,i)}}}};e.api.registerEventsFromObject(n.events),e.api.registerMethodsFromObject(n.methods)},defaultGridOptions:function(n){n.enablePinning=!1!==n.enablePinning,n.hidePinLeft=n.enablePinning&&n.hidePinLeft,n.hidePinRight=n.enablePinning&&n.hidePinRight},pinningColumnBuilder:function(n,i,e){if(n.enablePinning=void 0===n.enablePinning?e.enablePinning:n.enablePinning,n.hidePinLeft=void 0===n.hidePinLeft?e.hidePinLeft:n.hidePinLeft,n.hidePinRight=void 0===n.hidePinRight?e.hidePinRight:n.hidePinRight,n.pinnedLeft?(i.renderContainer="left",i.grid.createLeftContainer()):n.pinnedRight&&(i.renderContainer="right",i.grid.createRightContainer()),n.enablePinning){var t={name:"ui.grid.pinning.pinLeft",title:d.get().pinning.pinLeft,icon:"ui-grid-icon-left-open",shown:function(){return void 0===this.context.col.renderContainer||!this.context.col.renderContainer||"left"!==this.context.col.renderContainer},action:function(){a.pinColumn(this.context.col.grid,this.context.col,u.container.LEFT)}},r={name:"ui.grid.pinning.pinRight",title:d.get().pinning.pinRight,icon:"ui-grid-icon-right-open",shown:function(){return void 0===this.context.col.renderContainer||!this.context.col.renderContainer||"right"!==this.context.col.renderContainer},action:function(){a.pinColumn(this.context.col.grid,this.context.col,u.container.RIGHT)}},o={name:"ui.grid.pinning.unpin",title:d.get().pinning.unpin,icon:"ui-grid-icon-cancel",shown:function(){return void 0!==this.context.col.renderContainer&&null!==this.context.col.renderContainer&&"body"!==this.context.col.renderContainer},action:function(){a.pinColumn(this.context.col.grid,this.context.col,u.container.NONE)}};n.hidePinLeft||c.arrayContainsObjectWithProperty(i.menuItems,"name","ui.grid.pinning.pinLeft")||i.menuItems.push(t),n.hidePinRight||c.arrayContainsObjectWithProperty(i.menuItems,"name","ui.grid.pinning.pinRight")||i.menuItems.push(r),c.arrayContainsObjectWithProperty(i.menuItems,"name","ui.grid.pinning.unpin")||i.menuItems.push(o)}},pinColumn:function(n,i,e){e===u.container.NONE?(i.renderContainer=null,i.colDef.pinnedLeft=i.colDef.pinnedRight=!1):(i.renderContainer=e)===u.container.LEFT?n.createLeftContainer():e===u.container.RIGHT&&n.createRightContainer(),n.refresh().then(function(){n.api.pinning.raise.columnPinned(i.colDef,e)})}};return a}]),n.directive("uiGridPinning",["gridUtil","uiGridPinningService",function(n,r){return{require:"uiGrid",scope:!1,compile:function(){return{pre:function(n,i,e,t){r.initializeGrid(t.grid)},post:function(n,i,e,t){}}}}}])}(); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.resize-columns.js b/release/4.4.11/ui-grid.resize-columns.js new file mode 100644 index 000000000..5b748b42b --- /dev/null +++ b/release/4.4.11/ui-grid.resize-columns.js @@ -0,0 +1,569 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function(){ + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.resizeColumns + * @description + * + * # ui.grid.resizeColumns + * + * + * + * This module allows columns to be resized. + */ + var module = angular.module('ui.grid.resizeColumns', ['ui.grid']); + + module.service('uiGridResizeColumnsService', ['gridUtil', '$q', '$rootScope', + function (gridUtil, $q, $rootScope) { + + var service = { + defaultGridOptions: function(gridOptions){ + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.resizeColumns.api:GridOptions + * + * @description GridOptions for resizeColumns feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc object + * @name enableColumnResizing + * @propertyOf ui.grid.resizeColumns.api:GridOptions + * @description Enable column resizing on the entire grid + *
    Defaults to true + */ + gridOptions.enableColumnResizing = gridOptions.enableColumnResizing !== false; + + //legacy support + //use old name if it is explicitly false + if (gridOptions.enableColumnResize === false){ + gridOptions.enableColumnResizing = false; + } + }, + + colResizerColumnBuilder: function (colDef, col, gridOptions) { + + var promises = []; + /** + * @ngdoc object + * @name ui.grid.resizeColumns.api:ColumnDef + * + * @description ColumnDef for resizeColumns feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs} + */ + + /** + * @ngdoc object + * @name enableColumnResizing + * @propertyOf ui.grid.resizeColumns.api:ColumnDef + * @description Enable column resizing on an individual column + *
    Defaults to GridOptions.enableColumnResizing + */ + //default to true unless gridOptions or colDef is explicitly false + colDef.enableColumnResizing = colDef.enableColumnResizing === undefined ? gridOptions.enableColumnResizing : colDef.enableColumnResizing; + + + //legacy support of old option name + if (colDef.enableColumnResize === false){ + colDef.enableColumnResizing = false; + } + + return $q.all(promises); + }, + + registerPublicApi: function (grid) { + /** + * @ngdoc object + * @name ui.grid.resizeColumns.api:PublicApi + * @description Public Api for column resize feature. + */ + var publicApi = { + events: { + /** + * @ngdoc event + * @name columnSizeChanged + * @eventOf ui.grid.resizeColumns.api:PublicApi + * @description raised when column is resized + *
    +                 *      gridApi.colResizable.on.columnSizeChanged(scope,function(colDef, deltaChange){})
    +                 * 
    + * @param {object} colDef the column that was resized + * @param {integer} delta of the column size change + */ + colResizable: { + columnSizeChanged: function (colDef, deltaChange) { + } + } + } + }; + grid.api.registerEventsFromObject(publicApi.events); + }, + + fireColumnSizeChanged: function (grid, colDef, deltaChange) { + $rootScope.$applyAsync(function () { + if ( grid.api.colResizable ){ + grid.api.colResizable.raise.columnSizeChanged(colDef, deltaChange); + } else { + gridUtil.logError("The resizeable api is not registered, this may indicate that you've included the module but not added the 'ui-grid-resize-columns' directive to your grid definition. Cannot raise any events."); + } + }); + }, + + // get either this column, or the column next to this column, to resize, + // returns the column we're going to resize + findTargetCol: function(col, position, rtlMultiplier){ + var renderContainer = col.getRenderContainer(); + + if (position === 'left') { + // Get the column to the left of this one + var colIndex = renderContainer.visibleColumnCache.indexOf(col); + return renderContainer.visibleColumnCache[colIndex - 1 * rtlMultiplier]; + } else { + return col; + } + } + + }; + + return service; + + }]); + + + /** + * @ngdoc directive + * @name ui.grid.resizeColumns.directive:uiGridResizeColumns + * @element div + * @restrict A + * @description + * Enables resizing for all columns on the grid. If, for some reason, you want to use the ui-grid-resize-columns directive, but not allow column resizing, you can explicitly set the + * option to false. This prevents resizing for the entire grid, regardless of individual columnDef options. + * + * @example + + + + +
    +
    +
    +
    + + + +
    + */ + module.directive('uiGridResizeColumns', ['gridUtil', 'uiGridResizeColumnsService', function (gridUtil, uiGridResizeColumnsService) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridResizeColumnsService.defaultGridOptions(uiGridCtrl.grid.options); + uiGridCtrl.grid.registerColumnBuilder( uiGridResizeColumnsService.colResizerColumnBuilder); + uiGridResizeColumnsService.registerPublicApi(uiGridCtrl.grid); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + } + }; + } + }; + }]); + + // Extend the uiGridHeaderCell directive + module.directive('uiGridHeaderCell', ['gridUtil', '$templateCache', '$compile', '$q', 'uiGridResizeColumnsService', 'uiGridConstants', function (gridUtil, $templateCache, $compile, $q, uiGridResizeColumnsService, uiGridConstants) { + return { + // Run after the original uiGridHeaderCell + priority: -10, + require: '^uiGrid', + // scope: false, + compile: function() { + return { + post: function ($scope, $elm, $attrs, uiGridCtrl) { + var grid = uiGridCtrl.grid; + + if (grid.options.enableColumnResizing) { + var columnResizerElm = $templateCache.get('ui-grid/columnResizer'); + + var rtlMultiplier = 1; + //when in RTL mode reverse the direction using the rtlMultiplier and change the position to left + if (grid.isRTL()) { + $scope.position = 'left'; + rtlMultiplier = -1; + } + + var displayResizers = function(){ + + // remove any existing resizers. + var resizers = $elm[0].getElementsByClassName('ui-grid-column-resizer'); + for ( var i = 0; i < resizers.length; i++ ){ + angular.element(resizers[i]).remove(); + } + + // get the target column for the left resizer + var otherCol = uiGridResizeColumnsService.findTargetCol($scope.col, 'left', rtlMultiplier); + var renderContainer = $scope.col.getRenderContainer(); + + // Don't append the left resizer if this is the first column or the column to the left of this one has resizing disabled + if (otherCol && renderContainer.visibleColumnCache.indexOf($scope.col) !== 0 && otherCol.colDef.enableColumnResizing !== false) { + var resizerLeft = angular.element(columnResizerElm).clone(); + resizerLeft.attr('position', 'left'); + + $elm.prepend(resizerLeft); + $compile(resizerLeft)($scope); + } + + // Don't append the right resizer if this column has resizing disabled + if ($scope.col.colDef.enableColumnResizing !== false) { + var resizerRight = angular.element(columnResizerElm).clone(); + resizerRight.attr('position', 'right'); + + $elm.append(resizerRight); + $compile(resizerRight)($scope); + } + }; + + displayResizers(); + + var waitDisplay = function() { + $scope.$applyAsync(displayResizers); + }; + + var dataChangeDereg = grid.registerDataChangeCallback( waitDisplay, [uiGridConstants.dataChange.COLUMN] ); + + $scope.$on( '$destroy', dataChangeDereg ); + } + } + }; + } + }; + }]); + + + + /** + * @ngdoc directive + * @name ui.grid.resizeColumns.directive:uiGridColumnResizer + * @element div + * @restrict A + * + * @description + * Draggable handle that controls column resizing. + * + * @example + + + + +
    +
    +
    +
    + + // TODO: e2e specs? + + // TODO: post-resize a horizontal scroll event should be fired + +
    + */ + module.directive('uiGridColumnResizer', ['$document', 'gridUtil', 'uiGridConstants', 'uiGridResizeColumnsService', function ($document, gridUtil, uiGridConstants, uiGridResizeColumnsService) { + var resizeOverlay = angular.element('
    '); + + var resizer = { + priority: 0, + scope: { + col: '=', + position: '@', + renderIndex: '=' + }, + require: '?^uiGrid', + link: function ($scope, $elm, $attrs, uiGridCtrl) { + var startX = 0, + x = 0, + gridLeft = 0, + rtlMultiplier = 1; + + //when in RTL mode reverse the direction using the rtlMultiplier and change the position to left + if (uiGridCtrl.grid.isRTL()) { + $scope.position = 'left'; + rtlMultiplier = -1; + } + + if ($scope.position === 'left') { + $elm.addClass('left'); + } + else if ($scope.position === 'right') { + $elm.addClass('right'); + } + + // Refresh the grid canvas + // takes an argument representing the diff along the X-axis that the resize had + function refreshCanvas(xDiff) { + // Then refresh the grid canvas, rebuilding the styles so that the scrollbar updates its size + uiGridCtrl.grid.refreshCanvas(true).then( function() { + uiGridCtrl.grid.queueGridRefresh(); + }); + } + + // Check that the requested width isn't wider than the maxWidth, or narrower than the minWidth + // Returns the new recommended with, after constraints applied + function constrainWidth(col, width){ + var newWidth = width; + + // If the new width would be less than the column's allowably minimum width, don't allow it + if (col.minWidth && newWidth < col.minWidth) { + newWidth = col.minWidth; + } + else if (col.maxWidth && newWidth > col.maxWidth) { + newWidth = col.maxWidth; + } + + return newWidth; + } + + + /* + * Our approach to event handling aims to deal with both touch devices and mouse devices + * We register down handlers on both touch and mouse. When a touchstart or mousedown event + * occurs, we register the corresponding touchmove/touchend, or mousemove/mouseend events. + * + * This way we can listen for both without worrying about the fact many touch devices also emulate + * mouse events - basically whichever one we hear first is what we'll go with. + */ + function moveFunction(event, args) { + if (event.originalEvent) { event = event.originalEvent; } + event.preventDefault(); + + x = (event.targetTouches ? event.targetTouches[0] : event).clientX - gridLeft; + + if (x < 0) { x = 0; } + else if (x > uiGridCtrl.grid.gridWidth) { x = uiGridCtrl.grid.gridWidth; } + + var col = uiGridResizeColumnsService.findTargetCol($scope.col, $scope.position, rtlMultiplier); + + // Don't resize if it's disabled on this column + if (col.colDef.enableColumnResizing === false) { + return; + } + + if (!uiGridCtrl.grid.element.hasClass('column-resizing')) { + uiGridCtrl.grid.element.addClass('column-resizing'); + } + + // Get the diff along the X axis + var xDiff = x - startX; + + // Get the width that this mouse would give the column + var newWidth = parseInt(col.drawnWidth + xDiff * rtlMultiplier, 10); + + // check we're not outside the allowable bounds for this column + x = x + ( constrainWidth(col, newWidth) - newWidth ) * rtlMultiplier; + + resizeOverlay.css({ left: x + 'px' }); + + uiGridCtrl.fireEvent(uiGridConstants.events.ITEM_DRAGGING); + } + + + function upFunction(event, args) { + if (event.originalEvent) { event = event.originalEvent; } + event.preventDefault(); + + uiGridCtrl.grid.element.removeClass('column-resizing'); + + resizeOverlay.remove(); + + // Resize the column + x = (event.changedTouches ? event.changedTouches[0] : event).clientX - gridLeft; + var xDiff = x - startX; + + if (xDiff === 0) { + // no movement, so just reset event handlers, including turning back on both + // down events - we turned one off when this event started + offAllEvents(); + onDownEvents(); + return; + } + + var col = uiGridResizeColumnsService.findTargetCol($scope.col, $scope.position, rtlMultiplier); + + // Don't resize if it's disabled on this column + if (col.colDef.enableColumnResizing === false) { + return; + } + + // Get the new width + var newWidth = parseInt(col.drawnWidth + xDiff * rtlMultiplier, 10); + + // check we're not outside the allowable bounds for this column + col.width = constrainWidth(col, newWidth); + col.hasCustomWidth = true; + + refreshCanvas(xDiff); + + uiGridResizeColumnsService.fireColumnSizeChanged(uiGridCtrl.grid, col.colDef, xDiff); + + // stop listening of up and move events - wait for next down + // reset the down events - we will have turned one off when this event started + offAllEvents(); + onDownEvents(); + } + + + var downFunction = function(event, args) { + if (event.originalEvent) { event = event.originalEvent; } + event.stopPropagation(); + + // Get the left offset of the grid + // gridLeft = uiGridCtrl.grid.element[0].offsetLeft; + gridLeft = uiGridCtrl.grid.element[0].getBoundingClientRect().left; + + // Get the starting X position, which is the X coordinate of the click minus the grid's offset + startX = (event.targetTouches ? event.targetTouches[0] : event).clientX - gridLeft; + + // Append the resizer overlay + uiGridCtrl.grid.element.append(resizeOverlay); + + // Place the resizer overlay at the start position + resizeOverlay.css({ left: startX }); + + // Add handlers for move and up events - if we were mousedown then we listen for mousemove and mouseup, if + // we were touchdown then we listen for touchmove and touchup. Also remove the handler for the equivalent + // down event - so if we're touchdown, then remove the mousedown handler until this event is over, if we're + // mousedown then remove the touchdown handler until this event is over, this avoids processing duplicate events + if ( event.type === 'touchstart' ){ + $document.on('touchend', upFunction); + $document.on('touchmove', moveFunction); + $elm.off('mousedown', downFunction); + } else { + $document.on('mouseup', upFunction); + $document.on('mousemove', moveFunction); + $elm.off('touchstart', downFunction); + } + }; + + var onDownEvents = function() { + $elm.on('mousedown', downFunction); + $elm.on('touchstart', downFunction); + }; + + var offAllEvents = function() { + $document.off('mouseup', upFunction); + $document.off('touchend', upFunction); + $document.off('mousemove', moveFunction); + $document.off('touchmove', moveFunction); + $elm.off('mousedown', downFunction); + $elm.off('touchstart', downFunction); + }; + + onDownEvents(); + + + // On doubleclick, resize to fit all rendered cells + var dblClickFn = function(event, args){ + event.stopPropagation(); + + var col = uiGridResizeColumnsService.findTargetCol($scope.col, $scope.position, rtlMultiplier); + + // Don't resize if it's disabled on this column + if (col.colDef.enableColumnResizing === false) { + return; + } + + // Go through the rendered rows and find out the max size for the data in this column + var maxWidth = 0; + var xDiff = 0; + + // Get the parent render container element + var renderContainerElm = gridUtil.closestElm($elm, '.ui-grid-render-container'); + + // Get the cell contents so we measure correctly. For the header cell we have to account for the sort icon and the menu buttons, if present + var cells = renderContainerElm.querySelectorAll('.' + uiGridConstants.COL_CLASS_PREFIX + col.uid + ' .ui-grid-cell-contents'); + Array.prototype.forEach.call(cells, function (cell) { + // Get the cell width + // gridUtil.logDebug('width', gridUtil.elementWidth(cell)); + + // Account for the menu button if it exists + var menuButton; + if (angular.element(cell).parent().hasClass('ui-grid-header-cell')) { + menuButton = angular.element(cell).parent()[0].querySelectorAll('.ui-grid-column-menu-button'); + } + + gridUtil.fakeElement(cell, {}, function(newElm) { + // Make the element float since it's a div and can expand to fill its container + var e = angular.element(newElm); + e.attr('style', 'float: left'); + + var width = gridUtil.elementWidth(e); + + if (menuButton) { + var menuButtonWidth = gridUtil.elementWidth(menuButton); + width = width + menuButtonWidth; + } + + if (width > maxWidth) { + maxWidth = width; + } + }); + }); + + // check we're not outside the allowable bounds for this column + var newWidth = constrainWidth(col, maxWidth); + xDiff = newWidth - col.drawnWidth; + col.width = newWidth; + col.hasCustomWidth = true; + + refreshCanvas(xDiff); + + uiGridResizeColumnsService.fireColumnSizeChanged(uiGridCtrl.grid, col.colDef, xDiff); }; + $elm.on('dblclick', dblClickFn); + + $elm.on('$destroy', function() { + $elm.off('dblclick', dblClickFn); + offAllEvents(); + }); + } + }; + + return resizer; + }]); + +})(); diff --git a/release/4.4.11/ui-grid.resize-columns.min.js b/release/4.4.11/ui-grid.resize-columns.min.js new file mode 100644 index 000000000..1b1398048 --- /dev/null +++ b/release/4.4.11/ui-grid.resize-columns.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.resizeColumns",["ui.grid"]);e.service("uiGridResizeColumnsService",["gridUtil","$q","$rootScope",function(t,o,r){return{defaultGridOptions:function(e){e.enableColumnResizing=!1!==e.enableColumnResizing,!1===e.enableColumnResize&&(e.enableColumnResizing=!1)},colResizerColumnBuilder:function(e,i,n){return e.enableColumnResizing=void 0===e.enableColumnResizing?n.enableColumnResizing:e.enableColumnResizing,!1===e.enableColumnResize&&(e.enableColumnResizing=!1),o.all([])},registerPublicApi:function(e){e.api.registerEventsFromObject({colResizable:{columnSizeChanged:function(e,i){}}})},fireColumnSizeChanged:function(e,i,n){r.$applyAsync(function(){e.api.colResizable?e.api.colResizable.raise.columnSizeChanged(i,n):t.logError("The resizeable api is not registered, this may indicate that you've included the module but not added the 'ui-grid-resize-columns' directive to your grid definition. Cannot raise any events.")})},findTargetCol:function(e,i,n){var t=e.getRenderContainer();if("left"===i){var o=t.visibleColumnCache.indexOf(e);return t.visibleColumnCache[o-1*n]}return e}}}]),e.directive("uiGridResizeColumns",["gridUtil","uiGridResizeColumnsService",function(e,o){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,i,n,t){o.defaultGridOptions(t.grid.options),t.grid.registerColumnBuilder(o.colResizerColumnBuilder),o.registerPublicApi(t.grid)},post:function(e,i,n,t){}}}}}]),e.directive("uiGridHeaderCell",["gridUtil","$templateCache","$compile","$q","uiGridResizeColumnsService","uiGridConstants",function(e,r,d,i,c,g){return{priority:-10,require:"^uiGrid",compile:function(){return{post:function(l,a,e,i){var n=i.grid;if(n.options.enableColumnResizing){var u=r.get("ui-grid/columnResizer"),s=1;n.isRTL()&&(l.position="left",s=-1);var t=function(){for(var e=a[0].getElementsByClassName("ui-grid-column-resizer"),i=0;i');return{priority:0,scope:{col:"=",position:"@",renderIndex:"="},require:"?^uiGrid",link:function(a,u,e,s){var r=0,l=0,d=0,c=1;function g(e){s.grid.refreshCanvas(!0).then(function(){s.grid.queueGridRefresh()})}function f(e,i){var n=i;return e.minWidth&&ne.maxWidth&&(n=e.maxWidth),n}function n(e,i){e.originalEvent&&(e=e.originalEvent),e.preventDefault(),(l=(e.targetTouches?e.targetTouches[0]:e).clientX-d)<0?l=0:l>s.grid.gridWidth&&(l=s.grid.gridWidth);var n=z.findTargetCol(a.col,a.position,c);if(!1!==n.colDef.enableColumnResizing){s.grid.element.hasClass("column-resizing")||s.grid.element.addClass("column-resizing");var t=l-r,o=parseInt(n.drawnWidth+t*c,10);l+=(f(n,o)-o)*c,R.css({left:l+"px"}),s.fireEvent(p.events.ITEM_DRAGGING)}}function t(e,i){e.originalEvent&&(e=e.originalEvent),e.preventDefault(),s.grid.element.removeClass("column-resizing"),R.remove();var n=(l=(e.changedTouches?e.changedTouches[0]:e).clientX-d)-r;if(0===n)return C(),void m();var t=z.findTargetCol(a.col,a.position,c);if(!1!==t.colDef.enableColumnResizing){var o=parseInt(t.drawnWidth+n*c,10);t.width=f(t,o),t.hasCustomWidth=!0,g(),z.fireColumnSizeChanged(s.grid,t.colDef,n),C(),m()}}s.grid.isRTL()&&(a.position="left",c=-1),"left"===a.position?u.addClass("left"):"right"===a.position&&u.addClass("right");var o=function(e,i){e.originalEvent&&(e=e.originalEvent),e.stopPropagation(),d=s.grid.element[0].getBoundingClientRect().left,r=(e.targetTouches?e.targetTouches[0]:e).clientX-d,s.grid.element.append(R),R.css({left:r}),"touchstart"===e.type?(v.on("touchend",t),v.on("touchmove",n),u.off("mousedown",o)):(v.on("mouseup",t),v.on("mousemove",n),u.off("touchstart",o))},m=function(){u.on("mousedown",o),u.on("touchstart",o)},C=function(){v.off("mouseup",t),v.off("touchend",t),v.off("mousemove",n),v.off("touchmove",n),u.off("mousedown",o),u.off("touchstart",o)};m();var i=function(e,i){e.stopPropagation();var n=z.findTargetCol(a.col,a.position,c);if(!1!==n.colDef.enableColumnResizing){var t,o=0,r=h.closestElm(u,".ui-grid-render-container").querySelectorAll("."+p.COL_CLASS_PREFIX+n.uid+" .ui-grid-cell-contents");Array.prototype.forEach.call(r,function(e){var t;angular.element(e).parent().hasClass("ui-grid-header-cell")&&(t=angular.element(e).parent()[0].querySelectorAll(".ui-grid-column-menu-button")),h.fakeElement(e,{},function(e){var i=angular.element(e);i.attr("style","float: left");var n=h.elementWidth(i);t&&(n+=h.elementWidth(t));oStable This feature is stable. There should no longer be breaking api changes without a deprecation warning. + * + * This module extends the edit feature to provide tracking and saving of rows + * of data. The tutorial provides more information on how this feature is best + * used {@link tutorial/205_row_editable here}. + *
    + * This feature depends on usage of the ui-grid-edit feature, and also benefits + * from use of ui-grid-cellNav to provide the full spreadsheet-like editing + * experience + * + */ + + var module = angular.module('ui.grid.rowEdit', ['ui.grid', 'ui.grid.edit', 'ui.grid.cellNav']); + + /** + * @ngdoc object + * @name ui.grid.rowEdit.constant:uiGridRowEditConstants + * + * @description constants available in row edit module + */ + module.constant('uiGridRowEditConstants', { + }); + + /** + * @ngdoc service + * @name ui.grid.rowEdit.service:uiGridRowEditService + * + * @description Services for row editing features + */ + module.service('uiGridRowEditService', ['$interval', '$q', 'uiGridConstants', 'uiGridRowEditConstants', 'gridUtil', + function ($interval, $q, uiGridConstants, uiGridRowEditConstants, gridUtil) { + + var service = { + + initializeGrid: function (scope, grid) { + /** + * @ngdoc object + * @name ui.grid.rowEdit.api:PublicApi + * + * @description Public Api for rowEdit feature + */ + + grid.rowEdit = {}; + + var publicApi = { + events: { + rowEdit: { + /** + * @ngdoc event + * @eventOf ui.grid.rowEdit.api:PublicApi + * @name saveRow + * @description raised when a row is ready for saving. Once your + * row has saved you may need to use angular.extend to update the + * data entity with any changed data from your save (for example, + * lock version information if you're using optimistic locking, + * or last update time/user information). + * + * Your method should call setSavePromise somewhere in the body before + * returning control. The feature will then wait, with the gridRow greyed out + * whilst this promise is being resolved. + * + *
    +                 *      gridApi.rowEdit.on.saveRow(scope,function(rowEntity){})
    +                 * 
    + * and somewhere within the event handler: + *
    +                 *      gridApi.rowEdit.setSavePromise( rowEntity, savePromise)
    +                 * 
    + * @param {object} rowEntity the options.data element that was edited + * @returns {promise} Your saveRow method should return a promise, the + * promise should either be resolved (implying successful save), or + * rejected (implying an error). + */ + saveRow: function (rowEntity) { + } + } + }, + methods: { + rowEdit: { + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.api:PublicApi + * @name setSavePromise + * @description Sets the promise associated with the row save, mandatory that + * the saveRow event handler calls this method somewhere before returning. + *
    +                 *      gridApi.rowEdit.setSavePromise(rowEntity, savePromise)
    +                 * 
    + * @param {object} rowEntity a data row from the grid for which a save has + * been initiated + * @param {promise} savePromise the promise that will be resolved when the + * save is successful, or rejected if the save fails + * + */ + setSavePromise: function ( rowEntity, savePromise) { + service.setSavePromise(grid, rowEntity, savePromise); + }, + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.api:PublicApi + * @name getDirtyRows + * @description Returns all currently dirty rows + *
    +                 *      gridApi.rowEdit.getDirtyRows(grid)
    +                 * 
    + * @returns {array} An array of gridRows that are currently dirty + * + */ + getDirtyRows: function () { + return grid.rowEdit.dirtyRows ? grid.rowEdit.dirtyRows : []; + }, + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.api:PublicApi + * @name getErrorRows + * @description Returns all currently errored rows + *
    +                 *      gridApi.rowEdit.getErrorRows(grid)
    +                 * 
    + * @returns {array} An array of gridRows that are currently in error + * + */ + getErrorRows: function () { + return grid.rowEdit.errorRows ? grid.rowEdit.errorRows : []; + }, + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.api:PublicApi + * @name flushDirtyRows + * @description Triggers a save event for all currently dirty rows, could + * be used where user presses a save button or navigates away from the page + *
    +                 *      gridApi.rowEdit.flushDirtyRows(grid)
    +                 * 
    + * @returns {promise} a promise that represents the aggregate of all + * of the individual save promises - i.e. it will be resolved when all + * the individual save promises have been resolved. + * + */ + flushDirtyRows: function () { + return service.flushDirtyRows(grid); + }, + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.api:PublicApi + * @name setRowsDirty + * @description Sets each of the rows passed in dataRows + * to be dirty. note that if you have only just inserted the + * rows into your data you will need to wait for a $digest cycle + * before the gridRows are present - so often you would wrap this + * call in a $interval or $timeout + *
    +                 *      $interval( function() {
    +                 *        gridApi.rowEdit.setRowsDirty(myDataRows);
    +                 *      }, 0, 1);
    +                 * 
    + * @param {array} dataRows the data entities for which the gridRows + * should be set dirty. + * + */ + setRowsDirty: function ( dataRows) { + service.setRowsDirty(grid, dataRows); + }, + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.api:PublicApi + * @name setRowsClean + * @description Sets each of the rows passed in dataRows + * to be clean, removing them from the dirty cache and the error cache, + * and clearing the error flag and the dirty flag + *
    +                 *      var gridRows = $scope.gridApi.rowEdit.getDirtyRows();
    +                 *      var dataRows = gridRows.map( function( gridRow ) { return gridRow.entity; });
    +                 *      $scope.gridApi.rowEdit.setRowsClean( dataRows );
    +                 * 
    + * @param {array} dataRows the data entities for which the gridRows + * should be set clean. + * + */ + setRowsClean: function ( dataRows) { + service.setRowsClean(grid, dataRows); + } + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + grid.api.registerMethodsFromObject(publicApi.methods); + + grid.api.core.on.renderingComplete( scope, function ( gridApi ) { + grid.api.edit.on.afterCellEdit( scope, service.endEditCell ); + grid.api.edit.on.beginCellEdit( scope, service.beginEditCell ); + grid.api.edit.on.cancelCellEdit( scope, service.cancelEditCell ); + + if ( grid.api.cellNav ) { + grid.api.cellNav.on.navigate( scope, service.navigate ); + } + }); + + }, + + defaultGridOptions: function (gridOptions) { + + /** + * @ngdoc object + * @name ui.grid.rowEdit.api:GridOptions + * + * @description Options for configuring the rowEdit feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name saveRow + * @description Returns a function that saves the specified row from the grid, + * and returns a promise + * @param {object} grid the grid for which dirty rows should be flushed + * @param {GridRow} gridRow the row that should be saved + * @returns {function} the saveRow function returns a function. That function + * in turn, when called, returns a promise relating to the save callback + */ + saveRow: function ( grid, gridRow ) { + var self = this; + + return function() { + gridRow.isSaving = true; + + if ( gridRow.rowEditSavePromise ){ + // don't save the row again if it's already saving - that causes stale object exceptions + return gridRow.rowEditSavePromise; + } + + var promise = grid.api.rowEdit.raise.saveRow( gridRow.entity ); + + if ( gridRow.rowEditSavePromise ){ + gridRow.rowEditSavePromise.then( self.processSuccessPromise( grid, gridRow ), self.processErrorPromise( grid, gridRow )); + } else { + gridUtil.logError( 'A promise was not returned when saveRow event was raised, either nobody is listening to event, or event handler did not return a promise' ); + } + return promise; + }; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name setSavePromise + * @description Sets the promise associated with the row save, mandatory that + * the saveRow event handler calls this method somewhere before returning. + *
    +         *      gridApi.rowEdit.setSavePromise(grid, rowEntity)
    +         * 
    + * @param {object} grid the grid for which dirty rows should be returned + * @param {object} rowEntity a data row from the grid for which a save has + * been initiated + * @param {promise} savePromise the promise that will be resolved when the + * save is successful, or rejected if the save fails + * + */ + setSavePromise: function (grid, rowEntity, savePromise) { + var gridRow = grid.getRow( rowEntity ); + gridRow.rowEditSavePromise = savePromise; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name processSuccessPromise + * @description Returns a function that processes the successful + * resolution of a save promise + * @param {object} grid the grid for which the promise should be processed + * @param {GridRow} gridRow the row that has been saved + * @returns {function} the success handling function + */ + processSuccessPromise: function ( grid, gridRow ) { + var self = this; + + return function() { + delete gridRow.isSaving; + delete gridRow.isDirty; + delete gridRow.isError; + delete gridRow.rowEditSaveTimer; + delete gridRow.rowEditSavePromise; + self.removeRow( grid.rowEdit.errorRows, gridRow ); + self.removeRow( grid.rowEdit.dirtyRows, gridRow ); + }; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name processErrorPromise + * @description Returns a function that processes the failed + * resolution of a save promise + * @param {object} grid the grid for which the promise should be processed + * @param {GridRow} gridRow the row that is now in error + * @returns {function} the error handling function + */ + processErrorPromise: function ( grid, gridRow ) { + return function() { + delete gridRow.isSaving; + delete gridRow.rowEditSaveTimer; + delete gridRow.rowEditSavePromise; + + gridRow.isError = true; + + if (!grid.rowEdit.errorRows){ + grid.rowEdit.errorRows = []; + } + if (!service.isRowPresent( grid.rowEdit.errorRows, gridRow ) ){ + grid.rowEdit.errorRows.push( gridRow ); + } + }; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name removeRow + * @description Removes a row from a cache of rows - either + * grid.rowEdit.errorRows or grid.rowEdit.dirtyRows. If the row + * is not present silently does nothing. + * @param {array} rowArray the array from which to remove the row + * @param {GridRow} gridRow the row that should be removed + */ + removeRow: function( rowArray, removeGridRow ){ + if (typeof(rowArray) === 'undefined' || rowArray === null){ + return; + } + + rowArray.forEach( function( gridRow, index ){ + if ( gridRow.uid === removeGridRow.uid ){ + rowArray.splice( index, 1); + } + }); + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name isRowPresent + * @description Checks whether a row is already present + * in the given array + * @param {array} rowArray the array in which to look for the row + * @param {GridRow} gridRow the row that should be looked for + */ + isRowPresent: function( rowArray, removeGridRow ){ + var present = false; + rowArray.forEach( function( gridRow, index ){ + if ( gridRow.uid === removeGridRow.uid ){ + present = true; + } + }); + return present; + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name flushDirtyRows + * @description Triggers a save event for all currently dirty rows, could + * be used where user presses a save button or navigates away from the page + *
    +         *      gridApi.rowEdit.flushDirtyRows(grid)
    +         * 
    + * @param {object} grid the grid for which dirty rows should be flushed + * @returns {promise} a promise that represents the aggregate of all + * of the individual save promises - i.e. it will be resolved when all + * the individual save promises have been resolved. + * + */ + flushDirtyRows: function(grid){ + var promises = []; + grid.api.rowEdit.getDirtyRows().forEach( function( gridRow ){ + service.cancelTimer( grid, gridRow ); + service.saveRow( grid, gridRow )(); + promises.push( gridRow.rowEditSavePromise ); + }); + + return $q.all( promises ); + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name endEditCell + * @description Receives an afterCellEdit event from the edit function, + * and sets flags as appropriate. Only the rowEntity parameter + * is processed, although other params are available. Grid + * is automatically provided by the gridApi. + * @param {object} rowEntity the data entity for which the cell + * was edited + */ + endEditCell: function( rowEntity, colDef, newValue, previousValue ){ + var grid = this.grid; + var gridRow = grid.getRow( rowEntity ); + if ( !gridRow ){ gridUtil.logError( 'Unable to find rowEntity in grid data, dirty flag cannot be set' ); return; } + + if ( newValue !== previousValue || gridRow.isDirty ){ + if ( !grid.rowEdit.dirtyRows ){ + grid.rowEdit.dirtyRows = []; + } + + if ( !gridRow.isDirty ){ + gridRow.isDirty = true; + grid.rowEdit.dirtyRows.push( gridRow ); + } + + delete gridRow.isError; + + service.considerSetTimer( grid, gridRow ); + } + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name beginEditCell + * @description Receives a beginCellEdit event from the edit function, + * and cancels any rowEditSaveTimers if present, as the user is still editing + * this row. Only the rowEntity parameter + * is processed, although other params are available. Grid + * is automatically provided by the gridApi. + * @param {object} rowEntity the data entity for which the cell + * editing has commenced + */ + beginEditCell: function( rowEntity, colDef ){ + var grid = this.grid; + var gridRow = grid.getRow( rowEntity ); + if ( !gridRow ){ gridUtil.logError( 'Unable to find rowEntity in grid data, timer cannot be cancelled' ); return; } + + service.cancelTimer( grid, gridRow ); + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name cancelEditCell + * @description Receives a cancelCellEdit event from the edit function, + * and if the row was already dirty, restarts the save timer. If the row + * was not already dirty, then it's not dirty now either and does nothing. + * + * Only the rowEntity parameter + * is processed, although other params are available. Grid + * is automatically provided by the gridApi. + * + * @param {object} rowEntity the data entity for which the cell + * editing was cancelled + */ + cancelEditCell: function( rowEntity, colDef ){ + var grid = this.grid; + var gridRow = grid.getRow( rowEntity ); + if ( !gridRow ){ gridUtil.logError( 'Unable to find rowEntity in grid data, timer cannot be set' ); return; } + + service.considerSetTimer( grid, gridRow ); + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name navigate + * @description cellNav tells us that the selected cell has changed. If + * the new row had a timer running, then stop it similar to in a beginCellEdit + * call. If the old row is dirty and not the same as the new row, then + * start a timer on it. + * @param {object} newRowCol the row and column that were selected + * @param {object} oldRowCol the row and column that was left + * + */ + navigate: function( newRowCol, oldRowCol ){ + var grid = this.grid; + if ( newRowCol.row.rowEditSaveTimer ){ + service.cancelTimer( grid, newRowCol.row ); + } + + if ( oldRowCol && oldRowCol.row && oldRowCol.row !== newRowCol.row ){ + service.considerSetTimer( grid, oldRowCol.row ); + } + }, + + + /** + * @ngdoc property + * @propertyOf ui.grid.rowEdit.api:GridOptions + * @name rowEditWaitInterval + * @description How long the grid should wait for another change on this row + * before triggering a save (in milliseconds). If set to -1, then saves are + * never triggered by timer (implying that the user will call flushDirtyRows() + * manually) + * + * @example + * Setting the wait interval to 4 seconds + *
    +         *   $scope.gridOptions = { rowEditWaitInterval: 4000 }
    +         * 
    + * + */ + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name considerSetTimer + * @description Consider setting a timer on this row (if it is dirty). if there is a timer running + * on the row and the row isn't currently saving, cancel it, using cancelTimer, then if the row is + * dirty and not currently saving then set a new timer + * @param {object} grid the grid for which we are processing + * @param {GridRow} gridRow the row for which the timer should be adjusted + * + */ + considerSetTimer: function( grid, gridRow ){ + service.cancelTimer( grid, gridRow ); + + if ( gridRow.isDirty && !gridRow.isSaving ){ + if ( grid.options.rowEditWaitInterval !== -1 ){ + var waitTime = grid.options.rowEditWaitInterval ? grid.options.rowEditWaitInterval : 2000; + gridRow.rowEditSaveTimer = $interval( service.saveRow( grid, gridRow ), waitTime, 1); + } + } + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name cancelTimer + * @description cancel the $interval for any timer running on this row + * then delete the timer itself + * @param {object} grid the grid for which we are processing + * @param {GridRow} gridRow the row for which the timer should be adjusted + * + */ + cancelTimer: function( grid, gridRow ){ + if ( gridRow.rowEditSaveTimer && !gridRow.isSaving ){ + $interval.cancel(gridRow.rowEditSaveTimer); + delete gridRow.rowEditSaveTimer; + } + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name setRowsDirty + * @description Sets each of the rows passed in dataRows + * to be dirty. note that if you have only just inserted the + * rows into your data you will need to wait for a $digest cycle + * before the gridRows are present - so often you would wrap this + * call in a $interval or $timeout + *
    +         *      $interval( function() {
    +         *        gridApi.rowEdit.setRowsDirty( myDataRows);
    +         *      }, 0, 1);
    +         * 
    + * @param {object} grid the grid for which rows should be set dirty + * @param {array} dataRows the data entities for which the gridRows + * should be set dirty. + * + */ + setRowsDirty: function( grid, myDataRows ) { + var gridRow; + myDataRows.forEach( function( value, index ){ + gridRow = grid.getRow( value ); + if ( gridRow ){ + if ( !grid.rowEdit.dirtyRows ){ + grid.rowEdit.dirtyRows = []; + } + + if ( !gridRow.isDirty ){ + gridRow.isDirty = true; + grid.rowEdit.dirtyRows.push( gridRow ); + } + + delete gridRow.isError; + + service.considerSetTimer( grid, gridRow ); + } else { + gridUtil.logError( "requested row not found in rowEdit.setRowsDirty, row was: " + value ); + } + }); + }, + + + /** + * @ngdoc method + * @methodOf ui.grid.rowEdit.service:uiGridRowEditService + * @name setRowsClean + * @description Sets each of the rows passed in dataRows + * to be clean, clearing the dirty flag and the error flag, and removing + * the rows from the dirty and error caches. + * @param {object} grid the grid for which rows should be set clean + * @param {array} dataRows the data entities for which the gridRows + * should be set clean. + * + */ + setRowsClean: function( grid, myDataRows ) { + var gridRow; + + myDataRows.forEach( function( value, index ){ + gridRow = grid.getRow( value ); + if ( gridRow ){ + delete gridRow.isDirty; + service.removeRow( grid.rowEdit.dirtyRows, gridRow ); + service.cancelTimer( grid, gridRow ); + + delete gridRow.isError; + service.removeRow( grid.rowEdit.errorRows, gridRow ); + } else { + gridUtil.logError( "requested row not found in rowEdit.setRowsClean, row was: " + value ); + } + }); + } + + }; + + return service; + + }]); + + /** + * @ngdoc directive + * @name ui.grid.rowEdit.directive:uiGridEdit + * @element div + * @restrict A + * + * @description Adds row editing features to the ui-grid-edit directive. + * + */ + module.directive('uiGridRowEdit', ['gridUtil', 'uiGridRowEditService', 'uiGridEditConstants', + function (gridUtil, uiGridRowEditService, uiGridEditConstants) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridRowEditService.initializeGrid($scope, uiGridCtrl.grid); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + } + }; + } + }; + }]); + + + /** + * @ngdoc directive + * @name ui.grid.rowEdit.directive:uiGridViewport + * @element div + * + * @description Stacks on top of ui.grid.uiGridViewport to alter the attributes used + * for the grid row to allow coloring of saving and error rows + */ + module.directive('uiGridViewport', + ['$compile', 'uiGridConstants', 'gridUtil', '$parse', + function ($compile, uiGridConstants, gridUtil, $parse) { + return { + priority: -200, // run after default directive + scope: false, + compile: function ($elm, $attrs) { + var rowRepeatDiv = angular.element($elm.children().children()[0]); + + var existingNgClass = rowRepeatDiv.attr("ng-class"); + var newNgClass = ''; + if ( existingNgClass ) { + newNgClass = existingNgClass.slice(0, -1) + ", 'ui-grid-row-dirty': row.isDirty, 'ui-grid-row-saving': row.isSaving, 'ui-grid-row-error': row.isError}"; + } else { + newNgClass = "{'ui-grid-row-dirty': row.isDirty, 'ui-grid-row-saving': row.isSaving, 'ui-grid-row-error': row.isError}"; + } + rowRepeatDiv.attr("ng-class", newNgClass); + + return { + pre: function ($scope, $elm, $attrs, controllers) { + + }, + post: function ($scope, $elm, $attrs, controllers) { + } + }; + } + }; + }]); + +})(); diff --git a/release/4.4.11/ui-grid.row-edit.min.js b/release/4.4.11/ui-grid.row-edit.min.js new file mode 100644 index 000000000..27a9ef4f6 --- /dev/null +++ b/release/4.4.11/ui-grid.row-edit.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var r=angular.module("ui.grid.rowEdit",["ui.grid","ui.grid.edit","ui.grid.cellNav"]);r.constant("uiGridRowEditConstants",{}),r.service("uiGridRowEditService",["$interval","$q","uiGridConstants","uiGridRowEditConstants","gridUtil",function(t,r,i,e,s){var d={initializeGrid:function(i,e){e.rowEdit={};var r={events:{rowEdit:{saveRow:function(r){}}},methods:{rowEdit:{setSavePromise:function(r,i){d.setSavePromise(e,r,i)},getDirtyRows:function(){return e.rowEdit.dirtyRows?e.rowEdit.dirtyRows:[]},getErrorRows:function(){return e.rowEdit.errorRows?e.rowEdit.errorRows:[]},flushDirtyRows:function(){return d.flushDirtyRows(e)},setRowsDirty:function(r){d.setRowsDirty(e,r)},setRowsClean:function(r){d.setRowsClean(e,r)}}}};e.api.registerEventsFromObject(r.events),e.api.registerMethodsFromObject(r.methods),e.api.core.on.renderingComplete(i,function(r){e.api.edit.on.afterCellEdit(i,d.endEditCell),e.api.edit.on.beginCellEdit(i,d.beginEditCell),e.api.edit.on.cancelCellEdit(i,d.cancelEditCell),e.api.cellNav&&e.api.cellNav.on.navigate(i,d.navigate)})},defaultGridOptions:function(r){},saveRow:function(i,e){var t=this;return function(){if(e.isSaving=!0,e.rowEditSavePromise)return e.rowEditSavePromise;var r=i.api.rowEdit.raise.saveRow(e.entity);return e.rowEditSavePromise?e.rowEditSavePromise.then(t.processSuccessPromise(i,e),t.processErrorPromise(i,e)):s.logError("A promise was not returned when saveRow event was raised, either nobody is listening to event, or event handler did not return a promise"),r}},setSavePromise:function(r,i,e){r.getRow(i).rowEditSavePromise=e},processSuccessPromise:function(r,i){var e=this;return function(){delete i.isSaving,delete i.isDirty,delete i.isError,delete i.rowEditSaveTimer,delete i.rowEditSavePromise,e.removeRow(r.rowEdit.errorRows,i),e.removeRow(r.rowEdit.dirtyRows,i)}},processErrorPromise:function(r,i){return function(){delete i.isSaving,delete i.rowEditSaveTimer,delete i.rowEditSavePromise,i.isError=!0,r.rowEdit.errorRows||(r.rowEdit.errorRows=[]),d.isRowPresent(r.rowEdit.errorRows,i)||r.rowEdit.errorRows.push(i)}},removeRow:function(e,t){null!=e&&e.forEach(function(r,i){r.uid===t.uid&&e.splice(i,1)})},isRowPresent:function(r,e){var t=!1;return r.forEach(function(r,i){r.uid===e.uid&&(t=!0)}),t},flushDirtyRows:function(i){var e=[];return i.api.rowEdit.getDirtyRows().forEach(function(r){d.cancelTimer(i,r),d.saveRow(i,r)(),e.push(r.rowEditSavePromise)}),r.all(e)},endEditCell:function(r,i,e,t){var o=this.grid,n=o.getRow(r);n?(e!==t||n.isDirty)&&(o.rowEdit.dirtyRows||(o.rowEdit.dirtyRows=[]),n.isDirty||(n.isDirty=!0,o.rowEdit.dirtyRows.push(n)),delete n.isError,d.considerSetTimer(o,n)):s.logError("Unable to find rowEntity in grid data, dirty flag cannot be set")},beginEditCell:function(r,i){var e=this.grid,t=e.getRow(r);t?d.cancelTimer(e,t):s.logError("Unable to find rowEntity in grid data, timer cannot be cancelled")},cancelEditCell:function(r,i){var e=this.grid,t=e.getRow(r);t?d.considerSetTimer(e,t):s.logError("Unable to find rowEntity in grid data, timer cannot be set")},navigate:function(r,i){var e=this.grid;r.row.rowEditSaveTimer&&d.cancelTimer(e,r.row),i&&i.row&&i.row!==r.row&&d.considerSetTimer(e,i.row)},considerSetTimer:function(r,i){if(d.cancelTimer(r,i),i.isDirty&&!i.isSaving&&-1!==r.options.rowEditWaitInterval){var e=r.options.rowEditWaitInterval?r.options.rowEditWaitInterval:2e3;i.rowEditSaveTimer=t(d.saveRow(r,i),e,1)}},cancelTimer:function(r,i){i.rowEditSaveTimer&&!i.isSaving&&(t.cancel(i.rowEditSaveTimer),delete i.rowEditSaveTimer)},setRowsDirty:function(e,r){var t;r.forEach(function(r,i){(t=e.getRow(r))?(e.rowEdit.dirtyRows||(e.rowEdit.dirtyRows=[]),t.isDirty||(t.isDirty=!0,e.rowEdit.dirtyRows.push(t)),delete t.isError,d.considerSetTimer(e,t)):s.logError("requested row not found in rowEdit.setRowsDirty, row was: "+r)})},setRowsClean:function(e,r){var t;r.forEach(function(r,i){(t=e.getRow(r))?(delete t.isDirty,d.removeRow(e.rowEdit.dirtyRows,t),d.cancelTimer(e,t),delete t.isError,d.removeRow(e.rowEdit.errorRows,t)):s.logError("requested row not found in rowEdit.setRowsClean, row was: "+r)})}};return d}]),r.directive("uiGridRowEdit",["gridUtil","uiGridRowEditService","uiGridEditConstants",function(r,o,i){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(r,i,e,t){o.initializeGrid(r,t.grid)},post:function(r,i,e,t){}}}}}]),r.directive("uiGridViewport",["$compile","uiGridConstants","gridUtil","$parse",function(r,i,e,t){return{priority:-200,scope:!1,compile:function(r,i){var e=angular.element(r.children().children()[0]),t=e.attr("ng-class"),o="";return o=t?t.slice(0,-1)+", 'ui-grid-row-dirty': row.isDirty, 'ui-grid-row-saving': row.isSaving, 'ui-grid-row-error': row.isError}":"{'ui-grid-row-dirty': row.isDirty, 'ui-grid-row-saving': row.isSaving, 'ui-grid-row-error': row.isError}",e.attr("ng-class",o),{pre:function(r,i,e,t){},post:function(r,i,e,t){}}}}}])}(); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.saveState.js b/release/4.4.11/ui-grid.saveState.js new file mode 100644 index 000000000..1c0d05bea --- /dev/null +++ b/release/4.4.11/ui-grid.saveState.js @@ -0,0 +1,836 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.saveState + * @description + * + * # ui.grid.saveState + * + * + * + * This module provides the ability to save the grid state, and restore + * it when the user returns to the page. + * + * No UI is provided, the caller should provide their own UI/buttons + * as appropriate. Usually the navigate events would be used to save + * the grid state and restore it. + * + *
    + *
    + * + *
    + */ + + var module = angular.module('ui.grid.saveState', ['ui.grid', 'ui.grid.selection', 'ui.grid.cellNav', 'ui.grid.grouping', 'ui.grid.pinning', 'ui.grid.treeView']); + + /** + * @ngdoc object + * @name ui.grid.saveState.constant:uiGridSaveStateConstants + * + * @description constants available in save state module + */ + + module.constant('uiGridSaveStateConstants', { + featureName: 'saveState' + }); + + /** + * @ngdoc service + * @name ui.grid.saveState.service:uiGridSaveStateService + * + * @description Services for saveState feature + */ + module.service('uiGridSaveStateService', ['$q', 'uiGridSaveStateConstants', 'gridUtil', '$compile', '$interval', 'uiGridConstants', + function ($q, uiGridSaveStateConstants, gridUtil, $compile, $interval, uiGridConstants ) { + + var service = { + + initializeGrid: function (grid) { + + //add feature namespace and any properties to grid for needed state + grid.saveState = {}; + this.defaultGridOptions(grid.options); + + /** + * @ngdoc object + * @name ui.grid.saveState.api:PublicApi + * + * @description Public Api for saveState feature + */ + var publicApi = { + events: { + saveState: { + } + }, + methods: { + saveState: { + /** + * @ngdoc function + * @name save + * @methodOf ui.grid.saveState.api:PublicApi + * @description Packages the current state of the grid into + * an object, and provides it to the user for saving + * @returns {object} the state as a javascript object that can be saved + */ + save: function () { + return service.save(grid); + }, + /** + * @ngdoc function + * @name restore + * @methodOf ui.grid.saveState.api:PublicApi + * @description Restores the provided state into the grid + * @param {scope} $scope a scope that we can broadcast on + * @param {object} state the state that should be restored into the grid + * @returns {object} the promise created by refresh + */ + restore: function ( $scope, state) { + return service.restore(grid, $scope, state); + } + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + + grid.api.registerMethodsFromObject(publicApi.methods); + + }, + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.saveState.api:GridOptions + * + * @description GridOptions for saveState feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + /** + * @ngdoc object + * @name saveWidths + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the current column widths. Note that unless + * you've provided the user with some way to resize their columns (say + * the resize columns feature), then this makes little sense. + *
    Defaults to true + */ + gridOptions.saveWidths = gridOptions.saveWidths !== false; + /** + * @ngdoc object + * @name saveOrder + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Restore the current column order. Note that unless + * you've provided the user with some way to reorder their columns (for + * example the move columns feature), this makes little sense. + *
    Defaults to true + */ + gridOptions.saveOrder = gridOptions.saveOrder !== false; + /** + * @ngdoc object + * @name saveScroll + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the current scroll position. Note that this + * is saved as the percentage of the grid scrolled - so if your + * user returns to a grid with a significantly different number of + * rows (perhaps some data has been deleted) then the scroll won't + * actually show the same rows as before. If you want to scroll to + * a specific row then you should instead use the saveFocus option, which + * is the default. + * + * Note that this element will only be saved if the cellNav feature is + * enabled + *
    Defaults to false + */ + gridOptions.saveScroll = gridOptions.saveScroll === true; + /** + * @ngdoc object + * @name saveFocus + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the current focused cell. On returning + * to this focused cell we'll also scroll. This option is + * preferred to the saveScroll option, so is set to true by + * default. If saveScroll is set to true then this option will + * be disabled. + * + * By default this option saves the current row number and column + * number, and returns to that row and column. However, if you define + * a saveRowIdentity function, then it will return you to the currently + * selected column within that row (in a business sense - so if some + * rows have been deleted, it will still find the same data, presuming it + * still exists in the list. If it isn't in the list then it will instead + * return to the same row number - i.e. scroll percentage) + * + * Note that this option will do nothing if the cellNav + * feature is not enabled. + * + *
    Defaults to true (unless saveScroll is true) + */ + gridOptions.saveFocus = gridOptions.saveScroll !== true && gridOptions.saveFocus !== false; + /** + * @ngdoc object + * @name saveRowIdentity + * @propertyOf ui.grid.saveState.api:GridOptions + * @description A function that can be called, passing in a rowEntity, + * and that will return a unique id for that row. This might simply + * return the `id` field from that row (if you have one), or it might + * concatenate some fields within the row to make a unique value. + * + * This value will be used to find the same row again and set the focus + * to it, if it exists when we return. + * + *
    Defaults to undefined + */ + /** + * @ngdoc object + * @name saveVisible + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save whether or not columns are visible. + * + *
    Defaults to true + */ + gridOptions.saveVisible = gridOptions.saveVisible !== false; + /** + * @ngdoc object + * @name saveSort + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the current sort state for each column + * + *
    Defaults to true + */ + gridOptions.saveSort = gridOptions.saveSort !== false; + /** + * @ngdoc object + * @name saveFilter + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the current filter state for each column + * + *
    Defaults to true + */ + gridOptions.saveFilter = gridOptions.saveFilter !== false; + /** + * @ngdoc object + * @name saveSelection + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the currently selected rows. If the `saveRowIdentity` callback + * is defined, then it will save the id of the row and select that. If not, then + * it will attempt to select the rows by row number, which will give the wrong results + * if the data set has changed in the mean-time. + * + * Note that this option only does anything + * if the selection feature is enabled. + * + *
    Defaults to true + */ + gridOptions.saveSelection = gridOptions.saveSelection !== false; + /** + * @ngdoc object + * @name saveGrouping + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the grouping configuration. If set to true and the + * grouping feature is not enabled then does nothing. + * + *
    Defaults to true + */ + gridOptions.saveGrouping = gridOptions.saveGrouping !== false; + /** + * @ngdoc object + * @name saveGroupingExpandedStates + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the grouping row expanded states. If set to true and the + * grouping feature is not enabled then does nothing. + * + * This can be quite a bit of data, in many cases you wouldn't want to save this + * information. + * + *
    Defaults to false + */ + gridOptions.saveGroupingExpandedStates = gridOptions.saveGroupingExpandedStates === true; + /** + * @ngdoc object + * @name savePinning + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save pinning state for columns. + * + *
    Defaults to true + */ + gridOptions.savePinning = gridOptions.savePinning !== false; + /** + * @ngdoc object + * @name saveTreeView + * @propertyOf ui.grid.saveState.api:GridOptions + * @description Save the treeView configuration. If set to true and the + * treeView feature is not enabled then does nothing. + * + *
    Defaults to true + */ + gridOptions.saveTreeView = gridOptions.saveTreeView !== false; + }, + + + + /** + * @ngdoc function + * @name save + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Saves the current grid state into an object, and + * passes that object back to the caller + * @param {Grid} grid the grid whose state we'd like to save + * @returns {object} the state ready to be saved + */ + save: function (grid) { + var savedState = {}; + + savedState.columns = service.saveColumns( grid ); + savedState.scrollFocus = service.saveScrollFocus( grid ); + savedState.selection = service.saveSelection( grid ); + savedState.grouping = service.saveGrouping( grid ); + savedState.treeView = service.saveTreeView( grid ); + savedState.pagination = service.savePagination( grid ); + + return savedState; + }, + + + /** + * @ngdoc function + * @name restore + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Applies the provided state to the grid + * + * @param {Grid} grid the grid whose state we'd like to restore + * @param {scope} $scope a scope that we can broadcast on + * @param {object} state the state we'd like to restore + * @returns {object} the promise created by refresh + */ + restore: function( grid, $scope, state ){ + if ( state.columns ) { + service.restoreColumns( grid, state.columns ); + } + + if ( state.scrollFocus ){ + service.restoreScrollFocus( grid, $scope, state.scrollFocus ); + } + + if ( state.selection ){ + service.restoreSelection( grid, state.selection ); + } + + if ( state.grouping ){ + service.restoreGrouping( grid, state.grouping ); + } + + if ( state.treeView ){ + service.restoreTreeView( grid, state.treeView ); + } + + if ( state.pagination ){ + service.restorePagination( grid, state.pagination ); + } + + return grid.refresh(); + }, + + + /** + * @ngdoc function + * @name saveColumns + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Saves the column setup, including sort, filters, ordering, + * pinning and column widths. + * + * Works through the current columns, storing them in order. Stores the + * column name, then the visible flag, width, sort and filters for each column. + * + * @param {Grid} grid the grid whose state we'd like to save + * @returns {array} the columns state ready to be saved + */ + saveColumns: function( grid ) { + var columns = []; + grid.getOnlyDataColumns().forEach( function( column ) { + var savedColumn = {}; + savedColumn.name = column.name; + + if ( grid.options.saveVisible ){ + savedColumn.visible = column.visible; + } + + if ( grid.options.saveWidths ){ + savedColumn.width = column.width; + } + + // these two must be copied, not just pointed too - otherwise our saved state is pointing to the same object as current state + if ( grid.options.saveSort ){ + savedColumn.sort = angular.copy( column.sort ); + } + + if ( grid.options.saveFilter ){ + savedColumn.filters = []; + column.filters.forEach( function( filter ){ + var copiedFilter = {}; + angular.forEach( filter, function( value, key) { + if ( key !== 'condition' && key !== '$$hashKey' && key !== 'placeholder'){ + copiedFilter[key] = value; + } + }); + savedColumn.filters.push(copiedFilter); + }); + } + + if ( !!grid.api.pinning && grid.options.savePinning ){ + savedColumn.pinned = column.renderContainer ? column.renderContainer : ''; + } + + columns.push( savedColumn ); + }); + + return columns; + }, + + + /** + * @ngdoc function + * @name saveScrollFocus + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Saves the currently scroll or focus. + * + * If cellNav isn't present then does nothing - we can't return + * to the scroll position without cellNav anyway. + * + * If the cellNav module is present, and saveFocus is true, then + * it saves the currently focused cell. If rowIdentity is present + * then saves using rowIdentity, otherwise saves visibleRowNum. + * + * If the cellNav module is not present, and saveScroll is true, then + * it approximates the current scroll row and column, and saves that. + * + * @param {Grid} grid the grid whose state we'd like to save + * @returns {object} the selection state ready to be saved + */ + saveScrollFocus: function( grid ){ + if ( !grid.api.cellNav ){ + return {}; + } + + var scrollFocus = {}; + if ( grid.options.saveFocus ){ + scrollFocus.focus = true; + var rowCol = grid.api.cellNav.getFocusedCell(); + if ( rowCol !== null ) { + if ( rowCol.col !== null ){ + scrollFocus.colName = rowCol.col.colDef.name; + } + if ( rowCol.row !== null ){ + scrollFocus.rowVal = service.getRowVal( grid, rowCol.row ); + } + } + } + + if ( grid.options.saveScroll || grid.options.saveFocus && !scrollFocus.colName && !scrollFocus.rowVal ) { + scrollFocus.focus = false; + if ( grid.renderContainers.body.prevRowScrollIndex ){ + scrollFocus.rowVal = service.getRowVal( grid, grid.renderContainers.body.visibleRowCache[ grid.renderContainers.body.prevRowScrollIndex ]); + } + + if ( grid.renderContainers.body.prevColScrollIndex ){ + scrollFocus.colName = grid.renderContainers.body.visibleColumnCache[ grid.renderContainers.body.prevColScrollIndex ].name; + } + } + + return scrollFocus; + }, + + + /** + * @ngdoc function + * @name saveSelection + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Saves the currently selected rows, if the selection feature is enabled + * @param {Grid} grid the grid whose state we'd like to save + * @returns {array} the selection state ready to be saved + */ + saveSelection: function( grid ){ + if ( !grid.api.selection || !grid.options.saveSelection ){ + return []; + } + + var selection = grid.api.selection.getSelectedGridRows().map( function( gridRow ) { + return service.getRowVal( grid, gridRow ); + }); + + return selection; + }, + + + /** + * @ngdoc function + * @name saveGrouping + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Saves the grouping state, if the grouping feature is enabled + * @param {Grid} grid the grid whose state we'd like to save + * @returns {object} the grouping state ready to be saved + */ + saveGrouping: function( grid ){ + if ( !grid.api.grouping || !grid.options.saveGrouping ){ + return {}; + } + + return grid.api.grouping.getGrouping( grid.options.saveGroupingExpandedStates ); + }, + + + /** + * @ngdoc function + * @name savePagination + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Saves the pagination state, if the pagination feature is enabled + * @param {Grid} grid the grid whose state we'd like to save + * @returns {object} the pagination state ready to be saved + */ + savePagination: function( grid ) { + if ( !grid.api.pagination || !grid.options.paginationPageSize ){ + return {}; + } + + return { + paginationCurrentPage: grid.options.paginationCurrentPage, + paginationPageSize: grid.options.paginationPageSize + }; + }, + + + /** + * @ngdoc function + * @name saveTreeView + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Saves the tree view state, if the tree feature is enabled + * @param {Grid} grid the grid whose state we'd like to save + * @returns {object} the tree view state ready to be saved + */ + saveTreeView: function( grid ){ + if ( !grid.api.treeView || !grid.options.saveTreeView ){ + return {}; + } + + return grid.api.treeView.getTreeView(); + }, + + + /** + * @ngdoc function + * @name getRowVal + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Helper function that gets either the rowNum or + * the saveRowIdentity, given a gridRow + * @param {Grid} grid the grid the row is in + * @param {GridRow} gridRow the row we want the rowNum for + * @returns {object} an object containing { identity: true/false, row: rowNumber/rowIdentity } + * + */ + getRowVal: function( grid, gridRow ){ + if ( !gridRow ) { + return null; + } + + var rowVal = {}; + if ( grid.options.saveRowIdentity ){ + rowVal.identity = true; + rowVal.row = grid.options.saveRowIdentity( gridRow.entity ); + } else { + rowVal.identity = false; + rowVal.row = grid.renderContainers.body.visibleRowCache.indexOf( gridRow ); + } + return rowVal; + }, + + + /** + * @ngdoc function + * @name restoreColumns + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Restores the columns, including order, visible, width, + * pinning, sort and filters. + * + * @param {Grid} grid the grid whose state we'd like to restore + * @param {object} columnsState the list of columns we had before, with their state + */ + restoreColumns: function( grid, columnsState ){ + var isSortChanged = false; + + columnsState.forEach( function( columnState, index ) { + var currentCol = grid.getColumn( columnState.name ); + + if ( currentCol && !grid.isRowHeaderColumn(currentCol) ){ + if ( grid.options.saveVisible && + ( currentCol.visible !== columnState.visible || + currentCol.colDef.visible !== columnState.visible ) ){ + currentCol.visible = columnState.visible; + currentCol.colDef.visible = columnState.visible; + grid.api.core.raise.columnVisibilityChanged(currentCol); + } + + if ( grid.options.saveWidths && currentCol.width !== columnState.width){ + currentCol.width = columnState.width; + currentCol.hasCustomWidth = true; + } + + if ( grid.options.saveSort && + !angular.equals(currentCol.sort, columnState.sort) && + !( currentCol.sort === undefined && angular.isEmpty(columnState.sort) ) ){ + currentCol.sort = angular.copy( columnState.sort ); + isSortChanged = true; + } + + if ( grid.options.saveFilter && + !angular.equals(currentCol.filters, columnState.filters ) ){ + columnState.filters.forEach( function( filter, index ){ + angular.extend( currentCol.filters[index], filter ); + if ( typeof(filter.term) === 'undefined' || filter.term === null ){ + delete currentCol.filters[index].term; + } + }); + grid.api.core.raise.filterChanged(); + } + + if ( !!grid.api.pinning && grid.options.savePinning && currentCol.renderContainer !== columnState.pinned ){ + grid.api.pinning.pinColumn(currentCol, columnState.pinned); + } + + var currentIndex = grid.getOnlyDataColumns().indexOf( currentCol ); + if (currentIndex !== -1) { + if (grid.options.saveOrder && currentIndex !== index) { + var column = grid.columns.splice(currentIndex + grid.rowHeaderColumns.length, 1)[0]; + grid.columns.splice(index + grid.rowHeaderColumns.length, 0, column); + } + } + } + }); + + if ( isSortChanged ) { + grid.api.core.raise.sortChanged( grid, grid.getColumnSorting() ); + } + }, + + + /** + * @ngdoc function + * @name restoreScrollFocus + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Scrolls to the position that was saved. If focus is true, then + * sets focus to the specified row/col. If focus is false, then scrolls to the + * specified row/col. + * + * @param {Grid} grid the grid whose state we'd like to restore + * @param {scope} $scope a scope that we can broadcast on + * @param {object} scrollFocusState the scroll/focus state ready to be restored + */ + restoreScrollFocus: function( grid, $scope, scrollFocusState ){ + if ( !grid.api.cellNav ){ + return; + } + + var colDef, row; + if ( scrollFocusState.colName ){ + var colDefs = grid.options.columnDefs.filter( function( colDef ) { return colDef.name === scrollFocusState.colName; }); + if ( colDefs.length > 0 ){ + colDef = colDefs[0]; + } + } + + if ( scrollFocusState.rowVal && scrollFocusState.rowVal.row ){ + if ( scrollFocusState.rowVal.identity ){ + row = service.findRowByIdentity( grid, scrollFocusState.rowVal ); + } else { + row = grid.renderContainers.body.visibleRowCache[ scrollFocusState.rowVal.row ]; + } + } + + var entity = row && row.entity ? row.entity : null ; + + if ( colDef || entity ) { + if (scrollFocusState.focus ){ + grid.api.cellNav.scrollToFocus( entity, colDef ); + } else { + grid.scrollTo( entity, colDef ); + } + } + }, + + + /** + * @ngdoc function + * @name restoreSelection + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Selects the rows that are provided in the selection + * state. If you are using `saveRowIdentity` and more than one row matches the identity + * function then only the first is selected. + * @param {Grid} grid the grid whose state we'd like to restore + * @param {object} selectionState the selection state ready to be restored + */ + restoreSelection: function( grid, selectionState ){ + if ( !grid.api.selection ){ + return; + } + + grid.api.selection.clearSelectedRows(); + + selectionState.forEach( function( rowVal ) { + if ( rowVal.identity ){ + var foundRow = service.findRowByIdentity( grid, rowVal ); + + if ( foundRow ){ + grid.api.selection.selectRow( foundRow.entity ); + } + + } else { + grid.api.selection.selectRowByVisibleIndex( rowVal.row ); + } + }); + }, + + + /** + * @ngdoc function + * @name restoreGrouping + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Restores the grouping configuration, if the grouping feature + * is enabled. + * @param {Grid} grid the grid whose state we'd like to restore + * @param {object} groupingState the grouping state ready to be restored + */ + restoreGrouping: function( grid, groupingState ){ + if ( !grid.api.grouping || typeof(groupingState) === 'undefined' || groupingState === null || angular.equals(groupingState, {}) ){ + return; + } + + grid.api.grouping.setGrouping( groupingState ); + }, + + /** + * @ngdoc function + * @name restoreTreeView + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Restores the tree view configuration, if the tree view feature + * is enabled. + * @param {Grid} grid the grid whose state we'd like to restore + * @param {object} treeViewState the tree view state ready to be restored + */ + restoreTreeView: function( grid, treeViewState ){ + if ( !grid.api.treeView || typeof(treeViewState) === 'undefined' || treeViewState === null || angular.equals(treeViewState, {}) ){ + return; + } + + grid.api.treeView.setTreeView( treeViewState ); + }, + + /** + * @ngdoc function + * @name restorePagination + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Restores the pagination information, if pagination is enabled. + * @param {Grid} grid the grid whose state we'd like to restore + * @param {object} pagination the pagination object to be restored + * @param {number} pagination.paginationCurrentPage the page number to restore + * @param {number} pagination.paginationPageSize the number of items displayed per page + */ + restorePagination: function( grid, pagination ){ + if ( !grid.api.pagination || !grid.options.paginationPageSize ){ + return; + } + + grid.options.paginationCurrentPage = pagination.paginationCurrentPage; + grid.options.paginationPageSize = pagination.paginationPageSize; + }, + + /** + * @ngdoc function + * @name findRowByIdentity + * @methodOf ui.grid.saveState.service:uiGridSaveStateService + * @description Finds a row given it's identity value, returns the first found row + * if any are found, otherwise returns null if no rows are found. + * @param {Grid} grid the grid whose state we'd like to restore + * @param {object} rowVal the row we'd like to find + * @returns {gridRow} the found row, or null if none found + */ + findRowByIdentity: function( grid, rowVal ){ + if ( !grid.options.saveRowIdentity ){ + return null; + } + + var filteredRows = grid.rows.filter( function( gridRow ) { + if ( grid.options.saveRowIdentity( gridRow.entity ) === rowVal.row ){ + return true; + } else { + return false; + } + }); + + if ( filteredRows.length > 0 ){ + return filteredRows[0]; + } else { + return null; + } + } + }; + + return service; + + } + ]); + + /** + * @ngdoc directive + * @name ui.grid.saveState.directive:uiGridSaveState + * @element div + * @restrict A + * + * @description Adds saveState features to grid + * + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.saveState']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + + $scope.gridOptions = { + columnDefs: [ + {name: 'name'}, + {name: 'title', enableCellEdit: true} + ], + data: $scope.data + }; + }]); + + +
    +
    +
    +
    +
    + */ + module.directive('uiGridSaveState', ['uiGridSaveStateConstants', 'uiGridSaveStateService', 'gridUtil', '$compile', + function (uiGridSaveStateConstants, uiGridSaveStateService, gridUtil, $compile) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + link: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridSaveStateService.initializeGrid(uiGridCtrl.grid); + } + }; + } + ]); +})(); diff --git a/release/4.4.11/ui-grid.saveState.min.js b/release/4.4.11/ui-grid.saveState.min.js new file mode 100644 index 000000000..51484c9c6 --- /dev/null +++ b/release/4.4.11/ui-grid.saveState.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.saveState",["ui.grid","ui.grid.selection","ui.grid.cellNav","ui.grid.grouping","ui.grid.pinning","ui.grid.treeView"]);e.constant("uiGridSaveStateConstants",{featureName:"saveState"}),e.service("uiGridSaveStateService",["$q","uiGridSaveStateConstants","gridUtil","$compile","$interval","uiGridConstants",function(e,i,n,o,t,r){var s={initializeGrid:function(n){n.saveState={},this.defaultGridOptions(n.options);var e={events:{saveState:{}},methods:{saveState:{save:function(){return s.save(n)},restore:function(e,i){return s.restore(n,e,i)}}}};n.api.registerEventsFromObject(e.events),n.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.saveWidths=!1!==e.saveWidths,e.saveOrder=!1!==e.saveOrder,e.saveScroll=!0===e.saveScroll,e.saveFocus=!0!==e.saveScroll&&!1!==e.saveFocus,e.saveVisible=!1!==e.saveVisible,e.saveSort=!1!==e.saveSort,e.saveFilter=!1!==e.saveFilter,e.saveSelection=!1!==e.saveSelection,e.saveGrouping=!1!==e.saveGrouping,e.saveGroupingExpandedStates=!0===e.saveGroupingExpandedStates,e.savePinning=!1!==e.savePinning,e.saveTreeView=!1!==e.saveTreeView},save:function(e){var i={};return i.columns=s.saveColumns(e),i.scrollFocus=s.saveScrollFocus(e),i.selection=s.saveSelection(e),i.grouping=s.saveGrouping(e),i.treeView=s.saveTreeView(e),i.pagination=s.savePagination(e),i},restore:function(e,i,n){return n.columns&&s.restoreColumns(e,n.columns),n.scrollFocus&&s.restoreScrollFocus(e,i,n.scrollFocus),n.selection&&s.restoreSelection(e,n.selection),n.grouping&&s.restoreGrouping(e,n.grouping),n.treeView&&s.restoreTreeView(e,n.treeView),n.pagination&&s.restorePagination(e,n.pagination),e.refresh()},saveColumns:function(n){var o=[];return n.getOnlyDataColumns().forEach(function(e){var i={};i.name=e.name,n.options.saveVisible&&(i.visible=e.visible),n.options.saveWidths&&(i.width=e.width),n.options.saveSort&&(i.sort=angular.copy(e.sort)),n.options.saveFilter&&(i.filters=[],e.filters.forEach(function(e){var n={};angular.forEach(e,function(e,i){"condition"!==i&&"$$hashKey"!==i&&"placeholder"!==i&&(n[i]=e)}),i.filters.push(n)})),n.api.pinning&&n.options.savePinning&&(i.pinned=e.renderContainer?e.renderContainer:""),o.push(i)}),o},saveScrollFocus:function(e){if(!e.api.cellNav)return{};var i={};if(e.options.saveFocus){i.focus=!0;var n=e.api.cellNav.getFocusedCell();null!==n&&(null!==n.col&&(i.colName=n.col.colDef.name),null!==n.row&&(i.rowVal=s.getRowVal(e,n.row)))}return(e.options.saveScroll||e.options.saveFocus&&!i.colName&&!i.rowVal)&&(i.focus=!1,e.renderContainers.body.prevRowScrollIndex&&(i.rowVal=s.getRowVal(e,e.renderContainers.body.visibleRowCache[e.renderContainers.body.prevRowScrollIndex])),e.renderContainers.body.prevColScrollIndex&&(i.colName=e.renderContainers.body.visibleColumnCache[e.renderContainers.body.prevColScrollIndex].name)),i},saveSelection:function(i){return i.api.selection&&i.options.saveSelection?i.api.selection.getSelectedGridRows().map(function(e){return s.getRowVal(i,e)}):[]},saveGrouping:function(e){return e.api.grouping&&e.options.saveGrouping?e.api.grouping.getGrouping(e.options.saveGroupingExpandedStates):{}},savePagination:function(e){return e.api.pagination&&e.options.paginationPageSize?{paginationCurrentPage:e.options.paginationCurrentPage,paginationPageSize:e.options.paginationPageSize}:{}},saveTreeView:function(e){return e.api.treeView&&e.options.saveTreeView?e.api.treeView.getTreeView():{}},getRowVal:function(e,i){if(!i)return null;var n={};return e.options.saveRowIdentity?(n.identity=!0,n.row=e.options.saveRowIdentity(i.entity)):(n.identity=!1,n.row=e.renderContainers.body.visibleRowCache.indexOf(i)),n},restoreColumns:function(r,e){var a=!1;e.forEach(function(e,i){var n=r.getColumn(e.name);if(n&&!r.isRowHeaderColumn(n)){!r.options.saveVisible||n.visible===e.visible&&n.colDef.visible===e.visible||(n.visible=e.visible,n.colDef.visible=e.visible,r.api.core.raise.columnVisibilityChanged(n)),r.options.saveWidths&&n.width!==e.width&&(n.width=e.width,n.hasCustomWidth=!0),!r.options.saveSort||angular.equals(n.sort,e.sort)||void 0===n.sort&&angular.isEmpty(e.sort)||(n.sort=angular.copy(e.sort),a=!0),r.options.saveFilter&&!angular.equals(n.filters,e.filters)&&(e.filters.forEach(function(e,i){angular.extend(n.filters[i],e),void 0!==e.term&&null!==e.term||delete n.filters[i].term}),r.api.core.raise.filterChanged()),r.api.pinning&&r.options.savePinning&&n.renderContainer!==e.pinned&&r.api.pinning.pinColumn(n,e.pinned);var o=r.getOnlyDataColumns().indexOf(n);if(-1!==o&&r.options.saveOrder&&o!==i){var t=r.columns.splice(o+r.rowHeaderColumns.length,1)[0];r.columns.splice(i+r.rowHeaderColumns.length,0,t)}}}),a&&r.api.core.raise.sortChanged(r,r.getColumnSorting())},restoreScrollFocus:function(e,i,n){if(e.api.cellNav){var o,t;if(n.colName){var r=e.options.columnDefs.filter(function(e){return e.name===n.colName});0Stable This feature is stable. There should no longer be breaking api changes without a deprecation warning. + * + *
    + */ + + var module = angular.module('ui.grid.selection', ['ui.grid']); + + /** + * @ngdoc object + * @name ui.grid.selection.constant:uiGridSelectionConstants + * + * @description constants available in selection module + */ + module.constant('uiGridSelectionConstants', { + featureName: "selection", + selectionRowHeaderColName: 'selectionRowHeaderCol' + }); + + //add methods to GridRow + angular.module('ui.grid').config(['$provide', function ($provide) { + $provide.decorator('GridRow', ['$delegate', function ($delegate) { + + /** + * @ngdoc object + * @name ui.grid.selection.api:GridRow + * + * @description GridRow prototype functions added for selection + */ + + /** + * @ngdoc object + * @name enableSelection + * @propertyOf ui.grid.selection.api:GridRow + * @description Enable row selection for this row, only settable by internal code. + * + * The grouping feature, for example, might set group header rows to not be selectable. + *
    Defaults to true + */ + + /** + * @ngdoc object + * @name isSelected + * @propertyOf ui.grid.selection.api:GridRow + * @description Selected state of row. Should be readonly. Make any changes to selected state using setSelected(). + *
    Defaults to false + */ + + + /** + * @ngdoc function + * @name setSelected + * @methodOf ui.grid.selection.api:GridRow + * @description Sets the isSelected property and updates the selectedCount + * Changes to isSelected state should only be made via this function + * @param {bool} selected value to set + */ + $delegate.prototype.setSelected = function (selected) { + if (selected !== this.isSelected) { + this.isSelected = selected; + this.grid.selection.selectedCount += selected ? 1 : -1; + } + }; + + return $delegate; + }]); + }]); + + /** + * @ngdoc service + * @name ui.grid.selection.service:uiGridSelectionService + * + * @description Services for selection features + */ + module.service('uiGridSelectionService', ['$q', '$templateCache', 'uiGridSelectionConstants', 'gridUtil', + function ($q, $templateCache, uiGridSelectionConstants, gridUtil) { + + var service = { + + initializeGrid: function (grid) { + + //add feature namespace and any properties to grid for needed + /** + * @ngdoc object + * @name ui.grid.selection.grid:selection + * + * @description Grid properties and functions added for selection + */ + grid.selection = {}; + grid.selection.lastSelectedRow = null; + grid.selection.selectAll = false; + + + /** + * @ngdoc object + * @name selectedCount + * @propertyOf ui.grid.selection.grid:selection + * @description Current count of selected rows + * @example + * var count = grid.selection.selectedCount + */ + grid.selection.selectedCount = 0; + + service.defaultGridOptions(grid.options); + + /** + * @ngdoc object + * @name ui.grid.selection.api:PublicApi + * + * @description Public Api for selection feature + */ + var publicApi = { + events: { + selection: { + /** + * @ngdoc event + * @name rowSelectionChanged + * @eventOf ui.grid.selection.api:PublicApi + * @description is raised after the row.isSelected state is changed + * @param {object} scope the scope associated with the grid + * @param {GridRow} row the row that was selected/deselected + * @param {Event} evt object if raised from an event + */ + rowSelectionChanged: function (scope, row, evt) { + }, + /** + * @ngdoc event + * @name rowSelectionChangedBatch + * @eventOf ui.grid.selection.api:PublicApi + * @description is raised after the row.isSelected state is changed + * in bulk, if the `enableSelectionBatchEvent` option is set to true + * (which it is by default). This allows more efficient processing + * of bulk events. + * @param {object} scope the scope associated with the grid + * @param {array} rows the rows that were selected/deselected + * @param {Event} evt object if raised from an event + */ + rowSelectionChangedBatch: function (scope, rows, evt) { + } + } + }, + methods: { + selection: { + /** + * @ngdoc function + * @name toggleRowSelection + * @methodOf ui.grid.selection.api:PublicApi + * @description Toggles data row as selected or unselected + * @param {object} rowEntity gridOptions.data[] array instance + * @param {Event} evt object if raised from an event + */ + toggleRowSelection: function (rowEntity, evt) { + var row = grid.getRow(rowEntity); + if (row !== null) { + service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect); + } + }, + /** + * @ngdoc function + * @name selectRow + * @methodOf ui.grid.selection.api:PublicApi + * @description Select the data row + * @param {object} rowEntity gridOptions.data[] array instance + * @param {Event} evt object if raised from an event + */ + selectRow: function (rowEntity, evt) { + var row = grid.getRow(rowEntity); + if (row !== null && !row.isSelected) { + service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect); + } + }, + /** + * @ngdoc function + * @name selectRowByVisibleIndex + * @methodOf ui.grid.selection.api:PublicApi + * @description Select the specified row by visible index (i.e. if you + * specify row 0 you'll get the first visible row selected). In this context + * visible means of those rows that are theoretically visible (i.e. not filtered), + * rather than rows currently rendered on the screen. + * @param {number} rowNum index within the rowsVisible array + * @param {Event} evt object if raised from an event + */ + selectRowByVisibleIndex: function (rowNum, evt) { + var row = grid.renderContainers.body.visibleRowCache[rowNum]; + if (row !== null && typeof (row) !== 'undefined' && !row.isSelected) { + service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect); + } + }, + /** + * @ngdoc function + * @name unSelectRow + * @methodOf ui.grid.selection.api:PublicApi + * @description UnSelect the data row + * @param {object} rowEntity gridOptions.data[] array instance + * @param {Event} evt object if raised from an event + */ + unSelectRow: function (rowEntity, evt) { + var row = grid.getRow(rowEntity); + if (row !== null && row.isSelected) { + service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect); + } + }, + /** + * @ngdoc function + * @name unSelectRowByVisibleIndex + * @methodOf ui.grid.selection.api:PublicApi + * @description Unselect the specified row by visible index (i.e. if you + * specify row 0 you'll get the first visible row unselected). In this context + * visible means of those rows that are theoretically visible (i.e. not filtered), + * rather than rows currently rendered on the screen. + * @param {number} rowNum index within the rowsVisible array + * @param {Event} evt object if raised from an event + */ + unSelectRowByVisibleIndex: function (rowNum, evt) { + var row = grid.renderContainers.body.visibleRowCache[rowNum]; + if (row !== null && typeof (row) !== 'undefined' && row.isSelected) { + service.toggleRowSelection(grid, row, evt, grid.options.multiSelect, grid.options.noUnselect); + } + }, + /** + * @ngdoc function + * @name selectAllRows + * @methodOf ui.grid.selection.api:PublicApi + * @description Selects all rows. Does nothing if multiSelect = false + * @param {Event} evt object if raised from an event + */ + selectAllRows: function (evt) { + if (grid.options.multiSelect !== false) { + var changedRows = []; + grid.rows.forEach(function (row) { + if (!row.isSelected && row.enableSelection !== false && grid.options.isRowSelectable(row) !== false) { + row.setSelected(true); + service.decideRaiseSelectionEvent(grid, row, changedRows, evt); + } + }); + grid.selection.selectAll = true; + service.decideRaiseSelectionBatchEvent(grid, changedRows, evt); + } + }, + /** + * @ngdoc function + * @name selectAllVisibleRows + * @methodOf ui.grid.selection.api:PublicApi + * @description Selects all visible rows. Does nothing if multiSelect = false + * @param {Event} evt object if raised from an event + */ + selectAllVisibleRows: function (evt) { + if (grid.options.multiSelect !== false) { + var changedRows = []; + grid.rows.forEach(function(row) { + if (row.visible) { + if (!row.isSelected && row.enableSelection !== false && grid.options.isRowSelectable(row) !== false) { + row.setSelected(true); + service.decideRaiseSelectionEvent(grid, row, changedRows, evt); + } + } else if (row.isSelected) { + row.setSelected(false); + service.decideRaiseSelectionEvent(grid, row, changedRows, evt); + } + }); + grid.selection.selectAll = true; + service.decideRaiseSelectionBatchEvent(grid, changedRows, evt); + } + }, + /** + * @ngdoc function + * @name clearSelectedRows + * @methodOf ui.grid.selection.api:PublicApi + * @description Unselects all rows + * @param {Event} evt object if raised from an event + */ + clearSelectedRows: function (evt) { + service.clearSelectedRows(grid, evt); + }, + /** + * @ngdoc function + * @name getSelectedRows + * @methodOf ui.grid.selection.api:PublicApi + * @description returns all selectedRow's entity references + */ + getSelectedRows: function () { + return service.getSelectedRows(grid).map(function (gridRow) { + return gridRow.entity; + }).filter(function (entity) { + return entity.hasOwnProperty('$$hashKey') || !angular.isObject(entity); + }); + }, + /** + * @ngdoc function + * @name getSelectedGridRows + * @methodOf ui.grid.selection.api:PublicApi + * @description returns all selectedRow's as gridRows + */ + getSelectedGridRows: function () { + return service.getSelectedRows(grid); + }, + /** + * @ngdoc function + * @name getSelectedCount + * @methodOf ui.grid.selection.api:PublicApi + * @description returns the number of rows selected + */ + getSelectedCount: function () { + return grid.selection.selectedCount; + }, + /** + * @ngdoc function + * @name setMultiSelect + * @methodOf ui.grid.selection.api:PublicApi + * @description Sets the current gridOption.multiSelect to true or false + * @param {bool} multiSelect true to allow multiple rows + */ + setMultiSelect: function (multiSelect) { + grid.options.multiSelect = multiSelect; + }, + /** + * @ngdoc function + * @name setModifierKeysToMultiSelect + * @methodOf ui.grid.selection.api:PublicApi + * @description Sets the current gridOption.modifierKeysToMultiSelect to true or false + * @param {bool} modifierKeysToMultiSelect true to only allow multiple rows when using ctrlKey or shiftKey is used + */ + setModifierKeysToMultiSelect: function (modifierKeysToMultiSelect) { + grid.options.modifierKeysToMultiSelect = modifierKeysToMultiSelect; + }, + /** + * @ngdoc function + * @name getSelectAllState + * @methodOf ui.grid.selection.api:PublicApi + * @description Returns whether or not the selectAll checkbox is currently ticked. The + * grid doesn't automatically select rows when you add extra data - so when you add data + * you need to explicitly check whether the selectAll is set, and then call setVisible rows + * if it is + */ + getSelectAllState: function () { + return grid.selection.selectAll; + } + + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + + grid.api.registerMethodsFromObject(publicApi.methods); + + }, + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.selection.api:GridOptions + * + * @description GridOptions for selection feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc object + * @name enableRowSelection + * @propertyOf ui.grid.selection.api:GridOptions + * @description Enable row selection for entire grid. + *
    Defaults to true + */ + gridOptions.enableRowSelection = gridOptions.enableRowSelection !== false; + /** + * @ngdoc object + * @name multiSelect + * @propertyOf ui.grid.selection.api:GridOptions + * @description Enable multiple row selection for entire grid + *
    Defaults to true + */ + gridOptions.multiSelect = gridOptions.multiSelect !== false; + /** + * @ngdoc object + * @name noUnselect + * @propertyOf ui.grid.selection.api:GridOptions + * @description Prevent a row from being unselected. Works in conjunction + * with `multiselect = false` and `gridApi.selection.selectRow()` to allow + * you to create a single selection only grid - a row is always selected, you + * can only select different rows, you can't unselect the row. + *
    Defaults to false + */ + gridOptions.noUnselect = gridOptions.noUnselect === true; + /** + * @ngdoc object + * @name modifierKeysToMultiSelect + * @propertyOf ui.grid.selection.api:GridOptions + * @description Enable multiple row selection only when using the ctrlKey or shiftKey. Requires multiSelect to be true. + *
    Defaults to false + */ + gridOptions.modifierKeysToMultiSelect = gridOptions.modifierKeysToMultiSelect === true; + /** + * @ngdoc object + * @name enableRowHeaderSelection + * @propertyOf ui.grid.selection.api:GridOptions + * @description Enable a row header to be used for selection + *
    Defaults to true + */ + gridOptions.enableRowHeaderSelection = gridOptions.enableRowHeaderSelection !== false; + /** + * @ngdoc object + * @name enableFullRowSelection + * @propertyOf ui.grid.selection.api:GridOptions + * @description Enable selection by clicking anywhere on the row. Defaults to + * false if `enableRowHeaderSelection` is true, otherwise defaults to false. + */ + if (typeof (gridOptions.enableFullRowSelection) === 'undefined') { + gridOptions.enableFullRowSelection = !gridOptions.enableRowHeaderSelection; + } + /** + * @ngdoc object + * @name enableSelectAll + * @propertyOf ui.grid.selection.api:GridOptions + * @description Enable the select all checkbox at the top of the selectionRowHeader + *
    Defaults to true + */ + gridOptions.enableSelectAll = gridOptions.enableSelectAll !== false; + /** + * @ngdoc object + * @name enableSelectionBatchEvent + * @propertyOf ui.grid.selection.api:GridOptions + * @description If selected rows are changed in bulk, either via the API or + * via the selectAll checkbox, then a separate event is fired. Setting this + * option to false will cause the rowSelectionChanged event to be called multiple times + * instead + *
    Defaults to true + */ + gridOptions.enableSelectionBatchEvent = gridOptions.enableSelectionBatchEvent !== false; + /** + * @ngdoc object + * @name selectionRowHeaderWidth + * @propertyOf ui.grid.selection.api:GridOptions + * @description can be used to set a custom width for the row header selection column + *
    Defaults to 30px + */ + gridOptions.selectionRowHeaderWidth = angular.isDefined(gridOptions.selectionRowHeaderWidth) ? gridOptions.selectionRowHeaderWidth : 30; + + /** + * @ngdoc object + * @name enableFooterTotalSelected + * @propertyOf ui.grid.selection.api:GridOptions + * @description Shows the total number of selected items in footer if true. + *
    Defaults to true. + *
    GridOptions.showGridFooter must also be set to true. + */ + gridOptions.enableFooterTotalSelected = gridOptions.enableFooterTotalSelected !== false; + + /** + * @ngdoc object + * @name isRowSelectable + * @propertyOf ui.grid.selection.api:GridOptions + * @description Makes it possible to specify a method that evaluates for each row and sets its "enableSelection" property. + */ + + gridOptions.isRowSelectable = angular.isDefined(gridOptions.isRowSelectable) ? gridOptions.isRowSelectable : angular.noop; + }, + + /** + * @ngdoc function + * @name toggleRowSelection + * @methodOf ui.grid.selection.service:uiGridSelectionService + * @description Toggles row as selected or unselected + * @param {Grid} grid grid object + * @param {GridRow} row row to select or deselect + * @param {Event} evt object if resulting from event + * @param {bool} multiSelect if false, only one row at time can be selected + * @param {bool} noUnselect if true then rows cannot be unselected + */ + toggleRowSelection: function (grid, row, evt, multiSelect, noUnselect) { + var selected = row.isSelected; + + if (row.enableSelection === false) { + return; + } + + var selectedRows; + if (!multiSelect && !selected) { + service.clearSelectedRows(grid, evt); + } else if (!multiSelect && selected) { + selectedRows = service.getSelectedRows(grid); + if (selectedRows.length > 1) { + selected = false; // Enable reselect of the row + service.clearSelectedRows(grid, evt); + } + } + + if (selected && noUnselect) { + // don't deselect the row + } else { + row.setSelected(!selected); + if (row.isSelected === true) { + grid.selection.lastSelectedRow = row; + } + + selectedRows = service.getSelectedRows(grid); + grid.selection.selectAll = grid.rows.length === selectedRows.length; + + grid.api.selection.raise.rowSelectionChanged(row, evt); + } + }, + /** + * @ngdoc function + * @name shiftSelect + * @methodOf ui.grid.selection.service:uiGridSelectionService + * @description selects a group of rows from the last selected row using the shift key + * @param {Grid} grid grid object + * @param {GridRow} row clicked row + * @param {Event} evt object if raised from an event + * @param {bool} multiSelect if false, does nothing this is for multiSelect only + */ + shiftSelect: function (grid, row, evt, multiSelect) { + if (!multiSelect) { + return; + } + var selectedRows = service.getSelectedRows(grid); + var fromRow = selectedRows.length > 0 ? grid.renderContainers.body.visibleRowCache.indexOf(grid.selection.lastSelectedRow) : 0; + var toRow = grid.renderContainers.body.visibleRowCache.indexOf(row); + //reverse select direction + if (fromRow > toRow) { + var tmp = fromRow; + fromRow = toRow; + toRow = tmp; + } + + var changedRows = []; + for (var i = fromRow; i <= toRow; i++) { + var rowToSelect = grid.renderContainers.body.visibleRowCache[i]; + if (rowToSelect) { + if (!rowToSelect.isSelected && rowToSelect.enableSelection !== false) { + rowToSelect.setSelected(true); + grid.selection.lastSelectedRow = rowToSelect; + service.decideRaiseSelectionEvent(grid, rowToSelect, changedRows, evt); + } + } + } + service.decideRaiseSelectionBatchEvent(grid, changedRows, evt); + }, + /** + * @ngdoc function + * @name getSelectedRows + * @methodOf ui.grid.selection.service:uiGridSelectionService + * @description Returns all the selected rows + * @param {Grid} grid grid object + */ + getSelectedRows: function (grid) { + return grid.rows.filter(function (row) { + return row.isSelected; + }); + }, + + /** + * @ngdoc function + * @name clearSelectedRows + * @methodOf ui.grid.selection.service:uiGridSelectionService + * @description Clears all selected rows + * @param {Grid} grid grid object + * @param {Event} evt object if raised from an event + */ + clearSelectedRows: function (grid, evt) { + var changedRows = []; + service.getSelectedRows(grid).forEach(function (row) { + if (row.isSelected) { + row.setSelected(false); + service.decideRaiseSelectionEvent(grid, row, changedRows, evt); + } + }); + grid.selection.selectAll = false; + grid.selection.selectedCount = 0; + service.decideRaiseSelectionBatchEvent(grid, changedRows, evt); + }, + + /** + * @ngdoc function + * @name decideRaiseSelectionEvent + * @methodOf ui.grid.selection.service:uiGridSelectionService + * @description Decides whether to raise a single event or a batch event + * @param {Grid} grid grid object + * @param {GridRow} row row that has changed + * @param {array} changedRows an array to which we can append the changed + * @param {Event} evt object if raised from an event + * row if we're doing batch events + */ + decideRaiseSelectionEvent: function (grid, row, changedRows, evt) { + if (!grid.options.enableSelectionBatchEvent) { + grid.api.selection.raise.rowSelectionChanged(row, evt); + } else { + changedRows.push(row); + } + }, + + /** + * @ngdoc function + * @name raiseSelectionEvent + * @methodOf ui.grid.selection.service:uiGridSelectionService + * @description Decides whether we need to raise a batch event, and + * raises it if we do. + * @param {Grid} grid grid object + * @param {array} changedRows an array of changed rows, only populated + * @param {Event} evt object if raised from an event + * if we're doing batch events + */ + decideRaiseSelectionBatchEvent: function (grid, changedRows, evt) { + if (changedRows.length > 0) { + grid.api.selection.raise.rowSelectionChangedBatch(changedRows, evt); + } + } + }; + + return service; + + }]); + + /** + * @ngdoc directive + * @name ui.grid.selection.directive:uiGridSelection + * @element div + * @restrict A + * + * @description Adds selection features to grid + * + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.selection']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + + $scope.columnDefs = [ + {name: 'name', enableCellEdit: true}, + {name: 'title', enableCellEdit: true} + ]; + }]); + + +
    +
    +
    +
    +
    + */ + module.directive('uiGridSelection', ['uiGridSelectionConstants', 'uiGridSelectionService', '$templateCache', 'uiGridConstants', + function (uiGridSelectionConstants, uiGridSelectionService, $templateCache, uiGridConstants) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridSelectionService.initializeGrid(uiGridCtrl.grid); + if (uiGridCtrl.grid.options.enableRowHeaderSelection) { + var selectionRowHeaderDef = { + name: uiGridSelectionConstants.selectionRowHeaderColName, + displayName: '', + width: uiGridCtrl.grid.options.selectionRowHeaderWidth, + minWidth: 10, + cellTemplate: 'ui-grid/selectionRowHeader', + headerCellTemplate: 'ui-grid/selectionHeaderCell', + enableColumnResizing: false, + enableColumnMenu: false, + exporterSuppressExport: true, + allowCellFocus: true + }; + + uiGridCtrl.grid.addRowHeaderColumn(selectionRowHeaderDef, 0); + } + + var processorSet = false; + + var processSelectableRows = function (rows) { + rows.forEach(function (row) { + row.enableSelection = uiGridCtrl.grid.options.isRowSelectable(row); + }); + return rows; + }; + + var updateOptions = function () { + if (uiGridCtrl.grid.options.isRowSelectable !== angular.noop && processorSet !== true) { + uiGridCtrl.grid.registerRowsProcessor(processSelectableRows, 500); + processorSet = true; + } + }; + + updateOptions(); + + var dataChangeDereg = uiGridCtrl.grid.registerDataChangeCallback(updateOptions, [uiGridConstants.dataChange.OPTIONS]); + + $scope.$on('$destroy', dataChangeDereg); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + + } + }; + } + }; + }]); + + module.directive('uiGridSelectionRowHeaderButtons', ['$templateCache', 'uiGridSelectionService', 'gridUtil', + function ($templateCache, uiGridSelectionService, gridUtil) { + return { + replace: true, + restrict: 'E', + template: $templateCache.get('ui-grid/selectionRowHeaderButtons'), + scope: true, + require: '^uiGrid', + link: function ($scope, $elm, $attrs, uiGridCtrl) { + var self = uiGridCtrl.grid; + $scope.selectButtonClick = selectButtonClick; + $scope.selectButtonKeyDown = selectButtonKeyDown; + + // On IE, prevent mousedowns on the select button from starting a selection. + // If this is not done and you shift+click on another row, the browser will select a big chunk of text + if (gridUtil.detectBrowser() === 'ie') { + $elm.on('mousedown', selectButtonMouseDown); + } + + function selectButtonKeyDown(row, evt) { + if (evt.keyCode === 32) { + evt.preventDefault(); + selectButtonClick(row, evt); + } + } + + function selectButtonClick(row, evt) { + evt.stopPropagation(); + + if (evt.shiftKey) { + uiGridSelectionService.shiftSelect(self, row, evt, self.options.multiSelect); + } + else if (evt.ctrlKey || evt.metaKey) { + uiGridSelectionService.toggleRowSelection(self, row, evt, self.options.multiSelect, self.options.noUnselect); + } + else if (row.groupHeader) { + uiGridSelectionService.toggleRowSelection(self, row, evt, self.options.multiSelect, self.options.noUnselect); + for (var i = 0; i < row.treeNode.children.length; i++) { + uiGridSelectionService.toggleRowSelection(self, row.treeNode.children[i].row, evt, self.options.multiSelect, self.options.noUnselect); + } + } + else { + uiGridSelectionService.toggleRowSelection(self, row, evt, (self.options.multiSelect && !self.options.modifierKeysToMultiSelect), self.options.noUnselect); + } + } + + function selectButtonMouseDown(evt) { + if (evt.ctrlKey || evt.shiftKey) { + evt.target.onselectstart = function () { return false; }; + window.setTimeout(function () { evt.target.onselectstart = null; }, 0); + } + } + + $scope.$on('$destroy', function unbindEvents() { + $elm.off(); + }); + } + }; + }]); + + module.directive('uiGridSelectionSelectAllButtons', ['$templateCache', 'uiGridSelectionService', + function ($templateCache, uiGridSelectionService) { + return { + replace: true, + restrict: 'E', + template: $templateCache.get('ui-grid/selectionSelectAllButtons'), + scope: false, + link: function ($scope, $elm, $attrs, uiGridCtrl) { + var self = $scope.col.grid; + + $scope.headerButtonKeyDown = function (evt) { + if (evt.keyCode === 32 || evt.keyCode === 13) { + evt.preventDefault(); + $scope.headerButtonClick(evt); + } + }; + + $scope.headerButtonClick = function (evt) { + if (self.selection.selectAll) { + uiGridSelectionService.clearSelectedRows(self, evt); + if (self.options.noUnselect) { + self.api.selection.selectRowByVisibleIndex(0, evt); + } + self.selection.selectAll = false; + } else if (self.options.multiSelect) { + self.api.selection.selectAllVisibleRows(evt); + self.selection.selectAll = true; + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.selection.directive:uiGridViewport + * @element div + * + * @description Stacks on top of ui.grid.uiGridViewport to alter the attributes used + * for the grid row + */ + module.directive('uiGridViewport', + ['$compile', 'uiGridConstants', 'uiGridSelectionConstants', 'gridUtil', '$parse', 'uiGridSelectionService', + function ($compile, uiGridConstants, uiGridSelectionConstants, gridUtil, $parse, uiGridSelectionService) { + return { + priority: -200, // run after default directive + scope: false, + compile: function ($elm, $attrs) { + var rowRepeatDiv = angular.element($elm[0].querySelector('.ui-grid-canvas:not(.ui-grid-empty-base-layer-container)').children[0]); + + var existingNgClass = rowRepeatDiv.attr("ng-class"); + var newNgClass = ''; + if (existingNgClass) { + newNgClass = existingNgClass.slice(0, -1) + ",'ui-grid-row-selected': row.isSelected}"; + } else { + newNgClass = "{'ui-grid-row-selected': row.isSelected}"; + } + rowRepeatDiv.attr("ng-class", newNgClass); + + return { + pre: function ($scope, $elm, $attrs, controllers) { + + }, + post: function ($scope, $elm, $attrs, controllers) { + } + }; + } + }; + }]); + + /** + * @ngdoc directive + * @name ui.grid.selection.directive:uiGridCell + * @element div + * @restrict A + * + * @description Stacks on top of ui.grid.uiGridCell to provide selection feature + */ + module.directive('uiGridCell', + ['$compile', 'uiGridConstants', 'uiGridSelectionConstants', 'gridUtil', '$parse', 'uiGridSelectionService', '$timeout', + function ($compile, uiGridConstants, uiGridSelectionConstants, gridUtil, $parse, uiGridSelectionService, $timeout) { + return { + priority: -200, // run after default uiGridCell directive + restrict: 'A', + require: '?^uiGrid', + scope: false, + link: function ($scope, $elm, $attrs, uiGridCtrl) { + + var touchStartTime = 0; + var touchTimeout = 300; + + // Bind to keydown events in the render container + if (uiGridCtrl.grid.api.cellNav) { + + uiGridCtrl.grid.api.cellNav.on.viewPortKeyDown($scope, function (evt, rowCol) { + if (rowCol === null || + rowCol.row !== $scope.row || + rowCol.col !== $scope.col) { + return; + } + + if (evt.keyCode === 32 && $scope.col.colDef.name === "selectionRowHeaderCol") { + evt.preventDefault(); + uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect); + $scope.$apply(); + } + + // uiGridCellNavService.scrollToIfNecessary(uiGridCtrl.grid, rowCol.row, rowCol.col); + }); + } + + //$elm.bind('keydown', function (evt) { + // if (evt.keyCode === 32 && $scope.col.colDef.name === "selectionRowHeaderCol") { + // uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect); + // $scope.$apply(); + // } + //}); + + var selectCells = function (evt) { + // if you click on expandable icon doesn't trigger selection + if (evt.target.className === "ui-grid-icon-minus-squared" || evt.target.className === "ui-grid-icon-plus-squared") { + return; + } + + // if we get a click, then stop listening for touchend + $elm.off('touchend', touchEnd); + + if (evt.shiftKey) { + uiGridSelectionService.shiftSelect($scope.grid, $scope.row, evt, $scope.grid.options.multiSelect); + } + else if (evt.ctrlKey || evt.metaKey) { + uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, $scope.grid.options.multiSelect, $scope.grid.options.noUnselect); + } + else { + uiGridSelectionService.toggleRowSelection($scope.grid, $scope.row, evt, ($scope.grid.options.multiSelect && !$scope.grid.options.modifierKeysToMultiSelect), $scope.grid.options.noUnselect); + } + $scope.$apply(); + + // don't re-enable the touchend handler for a little while - some devices generate both, and it will + // take a little while to move your hand from the mouse to the screen if you have both modes of input + $timeout(function () { + $elm.on('touchend', touchEnd); + }, touchTimeout); + }; + + var touchStart = function (evt) { + touchStartTime = (new Date()).getTime(); + + // if we get a touch event, then stop listening for click + $elm.off('click', selectCells); + }; + + var touchEnd = function (evt) { + var touchEndTime = (new Date()).getTime(); + var touchTime = touchEndTime - touchStartTime; + + if (touchTime < touchTimeout) { + // short touch + selectCells(evt); + } + + // don't re-enable the click handler for a little while - some devices generate both, and it will + // take a little while to move your hand from the screen to the mouse if you have both modes of input + $timeout(function () { + $elm.on('click', selectCells); + }, touchTimeout); + }; + + function registerRowSelectionEvents() { + if ($scope.grid.options.enableRowSelection && $scope.grid.options.enableFullRowSelection && $scope.col.colDef.name !== 'selectionRowHeaderCol') { + $elm.addClass('ui-grid-disable-selection'); + $elm.on('touchstart', touchStart); + $elm.on('touchend', touchEnd); + $elm.on('click', selectCells); + + $scope.registered = true; + } + } + + function deregisterRowSelectionEvents() { + if ($scope.registered) { + $elm.removeClass('ui-grid-disable-selection'); + + $elm.off('touchstart', touchStart); + $elm.off('touchend', touchEnd); + $elm.off('click', selectCells); + + $scope.registered = false; + } + } + + registerRowSelectionEvents(); + // register a dataChange callback so that we can change the selection configuration dynamically + // if the user changes the options + var dataChangeDereg = $scope.grid.registerDataChangeCallback(function () { + if ($scope.grid.options.enableRowSelection && $scope.grid.options.enableFullRowSelection && + !$scope.registered) { + registerRowSelectionEvents(); + } else if ((!$scope.grid.options.enableRowSelection || !$scope.grid.options.enableFullRowSelection) && + $scope.registered) { + deregisterRowSelectionEvents(); + } + }, [uiGridConstants.dataChange.OPTIONS]); + + $elm.on('$destroy', dataChangeDereg); + } + }; + }]); + + module.directive('uiGridGridFooter', ['$compile', 'uiGridConstants', 'gridUtil', function ($compile, uiGridConstants, gridUtil) { + return { + restrict: 'EA', + replace: true, + priority: -1000, + require: '^uiGrid', + scope: true, + compile: function ($elm, $attrs) { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + + if (!uiGridCtrl.grid.options.showGridFooter) { + return; + } + + + gridUtil.getTemplate('ui-grid/gridFooterSelectedItems') + .then(function (contents) { + var template = angular.element(contents); + + var newElm = $compile(template)($scope); + + angular.element($elm[0].getElementsByClassName('ui-grid-grid-footer')[0]).append(newElm); + }); + }, + + post: function ($scope, $elm, $attrs, controllers) { + + } + }; + } + }; + }]); + +})(); diff --git a/release/4.4.11/ui-grid.selection.min.js b/release/4.4.11/ui-grid.selection.min.js new file mode 100644 index 000000000..c018be7fe --- /dev/null +++ b/release/4.4.11/ui-grid.selection.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.selection",["ui.grid"]);e.constant("uiGridSelectionConstants",{featureName:"selection",selectionRowHeaderColName:"selectionRowHeaderCol"}),angular.module("ui.grid").config(["$provide",function(e){e.decorator("GridRow",["$delegate",function(e){return e.prototype.setSelected=function(e){e!==this.isSelected&&(this.isSelected=e,this.grid.selection.selectedCount+=e?1:-1)},e}])}]),e.service("uiGridSelectionService",["$q","$templateCache","uiGridSelectionConstants","gridUtil",function(e,t,i,o){var d={initializeGrid:function(o){o.selection={},o.selection.lastSelectedRow=null,o.selection.selectAll=!1,o.selection.selectedCount=0,d.defaultGridOptions(o.options);var e={events:{selection:{rowSelectionChanged:function(e,t,i){},rowSelectionChangedBatch:function(e,t,i){}}},methods:{selection:{toggleRowSelection:function(e,t){var i=o.getRow(e);null!==i&&d.toggleRowSelection(o,i,t,o.options.multiSelect,o.options.noUnselect)},selectRow:function(e,t){var i=o.getRow(e);null===i||i.isSelected||d.toggleRowSelection(o,i,t,o.options.multiSelect,o.options.noUnselect)},selectRowByVisibleIndex:function(e,t){var i=o.renderContainers.body.visibleRowCache[e];null==i||i.isSelected||d.toggleRowSelection(o,i,t,o.options.multiSelect,o.options.noUnselect)},unSelectRow:function(e,t){var i=o.getRow(e);null!==i&&i.isSelected&&d.toggleRowSelection(o,i,t,o.options.multiSelect,o.options.noUnselect)},unSelectRowByVisibleIndex:function(e,t){var i=o.renderContainers.body.visibleRowCache[e];null!=i&&i.isSelected&&d.toggleRowSelection(o,i,t,o.options.multiSelect,o.options.noUnselect)},selectAllRows:function(t){if(!1!==o.options.multiSelect){var i=[];o.rows.forEach(function(e){e.isSelected||!1===e.enableSelection||!1===o.options.isRowSelectable(e)||(e.setSelected(!0),d.decideRaiseSelectionEvent(o,e,i,t))}),o.selection.selectAll=!0,d.decideRaiseSelectionBatchEvent(o,i,t)}},selectAllVisibleRows:function(t){if(!1!==o.options.multiSelect){var i=[];o.rows.forEach(function(e){e.visible?e.isSelected||!1===e.enableSelection||!1===o.options.isRowSelectable(e)||(e.setSelected(!0),d.decideRaiseSelectionEvent(o,e,i,t)):e.isSelected&&(e.setSelected(!1),d.decideRaiseSelectionEvent(o,e,i,t))}),o.selection.selectAll=!0,d.decideRaiseSelectionBatchEvent(o,i,t)}},clearSelectedRows:function(e){d.clearSelectedRows(o,e)},getSelectedRows:function(){return d.getSelectedRows(o).map(function(e){return e.entity}).filter(function(e){return e.hasOwnProperty("$$hashKey")||!angular.isObject(e)})},getSelectedGridRows:function(){return d.getSelectedRows(o)},getSelectedCount:function(){return o.selection.selectedCount},setMultiSelect:function(e){o.options.multiSelect=e},setModifierKeysToMultiSelect:function(e){o.options.modifierKeysToMultiSelect=e},getSelectAllState:function(){return o.selection.selectAll}}}};o.api.registerEventsFromObject(e.events),o.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enableRowSelection=!1!==e.enableRowSelection,e.multiSelect=!1!==e.multiSelect,e.noUnselect=!0===e.noUnselect,e.modifierKeysToMultiSelect=!0===e.modifierKeysToMultiSelect,e.enableRowHeaderSelection=!1!==e.enableRowHeaderSelection,void 0===e.enableFullRowSelection&&(e.enableFullRowSelection=!e.enableRowHeaderSelection),e.enableSelectAll=!1!==e.enableSelectAll,e.enableSelectionBatchEvent=!1!==e.enableSelectionBatchEvent,e.selectionRowHeaderWidth=angular.isDefined(e.selectionRowHeaderWidth)?e.selectionRowHeaderWidth:30,e.enableFooterTotalSelected=!1!==e.enableFooterTotalSelected,e.isRowSelectable=angular.isDefined(e.isRowSelectable)?e.isRowSelectable:angular.noop},toggleRowSelection:function(e,t,i,o,n){var l,c=t.isSelected;!1!==t.enableSelection&&(o||c?!o&&c&&1<(l=d.getSelectedRows(e)).length&&(c=!1,d.clearSelectedRows(e,i)):d.clearSelectedRows(e,i),c&&n||(t.setSelected(!c),!0===t.isSelected&&(e.selection.lastSelectedRow=t),l=d.getSelectedRows(e),e.selection.selectAll=e.rows.length===l.length,e.api.selection.raise.rowSelectionChanged(t,i)))},shiftSelect:function(e,t,i,o){if(o){var n=0 + + +Copyright (C) 2016 by original authors @ fontello.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/release/4.4.11/ui-grid.tree-base.js b/release/4.4.11/ui-grid.tree-base.js new file mode 100644 index 000000000..2baed26a2 --- /dev/null +++ b/release/4.4.11/ui-grid.tree-base.js @@ -0,0 +1,1675 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.treeBase + * @description + * + * # ui.grid.treeBase + * + * + * + * This module provides base tree handling functions that are shared by other features, notably grouping + * and treeView. It provides a tree view of the data, with nodes in that + * tree and leaves. + * + * Design information: + * ------------------- + * + * The raw data that is provided must come with a $$treeLevel on any non-leaf node. Grouping will create + * these on all the group header rows, treeView will expect these to be set in the raw data by the user. + * TreeBase will run a rowsProcessor that: + * - builds `treeBase.tree` out of the provided rows + * - permits a recursive sort of the tree + * - maintains the expand/collapse state of each node + * - provides the expand/collapse all button and the expand/collapse buttons + * - maintains the count of children for each node + * + * Each row is updated with a link to the tree node that represents it. Refer {@link ui.grid.treeBase.grid:treeBase.tree tree documentation} + * for information. + * + * TreeBase adds information to the rows + * - treeLevel: if present and > -1 tells us the level (level 0 is the top level) + * - treeNode: pointer to the node in the grid.treeBase.tree that refers + * to this row, allowing us to manipulate the state + * + * Since the logic is baked into the rowsProcessors, it should get triggered whenever + * row order or filtering or anything like that is changed. We recall the expanded state + * across invocations of the rowsProcessors by the reference to the treeNode on the individual + * rows. We rebuild the tree itself quite frequently, when we do this we use the saved treeNodes to + * get the state, but we overwrite the other data in that treeNode. + * + * By default rows are collapsed, which means all data rows have their visible property + * set to false, and only level 0 group rows are set to visible. + * + * We rely on the rowsProcessors to do the actual expanding and collapsing, so we set the flags we want into + * grid.treeBase.tree, then call refresh. This is because we can't easily change the visible + * row cache without calling the processors, and once we've built the logic into the rowProcessors we may as + * well use it all the time. + * + * Tree base provides sorting (on non-grouped columns). + * + * Sorting works in two passes. The standard sorting is performed for any columns that are important to building + * the tree (for example, any grouped columns). Then after the tree is built, a recursive tree sort is performed + * for the remaining sort columns (including the original sort) - these columns are sorted within each tree level + * (so all the level 1 nodes are sorted, then all the level 2 nodes within each level 1 node etc). + * + * To achieve this we make use of the `ignoreSort` property on the sort configuration. The parent feature (treeView or grouping) + * must provide a rowsProcessor that runs with very low priority (typically in the 60-65 range), and that sets + * the `ignoreSort`on any sort that it wants to run on the tree. TreeBase will clear the ignoreSort on all sorts - so it + * will turn on any sorts that haven't run. It will then call a recursive sort on the tree. + * + * Tree base provides treeAggregation. It checks the treeAggregation configuration on each column, and aggregates based on + * the logic provided as it builds the tree. Footer aggregation from the uiGrid core should not be used with treeBase aggregation, + * since it operates on all visible rows, as opposed to to leaf nodes only. Setting `showColumnFooter: true` will show the + * treeAggregations in the column footer. Aggregation information will be collected in the format: + * + * ``` + * { + * type: 'count', + * value: 4, + * label: 'count: ', + * rendered: 'count: 4' + * } + * ``` + * + * A callback is provided to format the value once it is finalised (aka a valueFilter). + * + *
    + *
    + * + *
    + */ + + var module = angular.module('ui.grid.treeBase', ['ui.grid']); + + /** + * @ngdoc object + * @name ui.grid.treeBase.constant:uiGridTreeBaseConstants + * + * @description constants available in treeBase module. + * + * These constants are manually copied into grouping and treeView, + * as I haven't found a way to simply include them, and it's not worth + * investing time in for something that changes very infrequently. + * + */ + module.constant('uiGridTreeBaseConstants', { + featureName: "treeBase", + rowHeaderColName: 'treeBaseRowHeaderCol', + EXPANDED: 'expanded', + COLLAPSED: 'collapsed', + aggregation: { + COUNT: 'count', + SUM: 'sum', + MAX: 'max', + MIN: 'min', + AVG: 'avg' + } + }); + + /** + * @ngdoc service + * @name ui.grid.treeBase.service:uiGridTreeBaseService + * + * @description Services for treeBase feature + */ + /** + * @ngdoc object + * @name ui.grid.treeBase.api:ColumnDef + * + * @description ColumnDef for tree feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions.columnDef gridOptions.columnDefs} + */ + + module.service('uiGridTreeBaseService', ['$q', 'uiGridTreeBaseConstants', 'gridUtil', 'GridRow', 'gridClassFactory', 'i18nService', 'uiGridConstants', 'rowSorter', + function ($q, uiGridTreeBaseConstants, gridUtil, GridRow, gridClassFactory, i18nService, uiGridConstants, rowSorter) { + + var service = { + + initializeGrid: function (grid, $scope) { + + //add feature namespace and any properties to grid for needed + /** + * @ngdoc object + * @name ui.grid.treeBase.grid:treeBase + * + * @description Grid properties and functions added for treeBase + */ + grid.treeBase = {}; + + /** + * @ngdoc property + * @propertyOf ui.grid.treeBase.grid:treeBase + * @name numberLevels + * + * @description Total number of tree levels currently used, calculated by the rowsProcessor by + * retaining the highest tree level it sees + */ + grid.treeBase.numberLevels = 0; + + /** + * @ngdoc property + * @propertyOf ui.grid.treeBase.grid:treeBase + * @name expandAll + * + * @description Whether or not the expandAll box is selected + */ + grid.treeBase.expandAll = false; + + /** + * @ngdoc property + * @propertyOf ui.grid.treeBase.grid:treeBase + * @name tree + * + * @description Tree represented as a nested array that holds the state of each node, along with a + * pointer to the row. The array order is material - we will display the children in the order + * they are stored in the array + * + * Each node stores: + * + * - the state of this node + * - an array of children of this node + * - a pointer to the parent of this node (reverse pointer, allowing us to walk up the tree) + * - the number of children of this node + * - aggregation information calculated from the nodes + * + * ``` + * [{ + * state: 'expanded', + * row: , + * parentRow: null, + * aggregations: [{ + * type: 'count', + * col: , + * value: 2, + * label: 'count: ', + * rendered: 'count: 2' + * }], + * children: [ + * { + * state: 'expanded', + * row: , + * parentRow: , + * aggregations: [{ + * type: 'count', + * col: ', + * value: 4, + * label: 'count: ', + * rendered: 'count: 4' + * }], + * children: [ + * { state: 'expanded', row: , parentRow: }, + * { state: 'collapsed', row: , parentRow: }, + * { state: 'expanded', row: , parentRow: }, + * { state: 'collapsed', row: , parentRow: } + * ] + * }, + * { + * state: 'collapsed', + * row: , + * parentRow: , + * aggregations: [{ + * type: 'count', + * col: , + * value: 3, + * label: 'count: ', + * rendered: 'count: 3' + * }], + * children: [ + * { state: 'expanded', row: , parentRow: }, + * { state: 'collapsed', row: , parentRow: }, + * { state: 'expanded', row: , parentRow: } + * ] + * } + * ] + * }, {} ] + * ``` + * Missing state values are false - meaning they aren't expanded. + * + * This is used because the rowProcessors run every time the grid is refreshed, so + * we'd lose the expanded state every time the grid was refreshed. This instead gives + * us a reliable lookup that persists across rowProcessors. + * + * This tree is rebuilt every time we run the rowsProcessors. Since each row holds a pointer + * to it's tree node we can persist expand/collapse state across calls to rowsProcessor, we discard + * all transient information on the tree (children, childCount) and recalculate it + * + */ + grid.treeBase.tree = []; + + service.defaultGridOptions(grid.options); + + grid.registerRowsProcessor(service.treeRows, 410); + + grid.registerColumnBuilder( service.treeBaseColumnBuilder ); + + service.createRowHeader( grid ); + + /** + * @ngdoc object + * @name ui.grid.treeBase.api:PublicApi + * + * @description Public Api for treeBase feature + */ + var publicApi = { + events: { + treeBase: { + /** + * @ngdoc event + * @eventOf ui.grid.treeBase.api:PublicApi + * @name rowExpanded + * @description raised whenever a row is expanded. If you are dynamically + * rendering your tree you can listen to this event, and then retrieve + * the children of this row and load them into the grid data. + * + * When the data is loaded the grid will automatically refresh to show these new rows + * + *
    +               *      gridApi.treeBase.on.rowExpanded(scope,function(row){})
    +               * 
    + * @param {gridRow} row the row that was expanded. You can also + * retrieve the grid from this row with row.grid + */ + rowExpanded: {}, + + /** + * @ngdoc event + * @eventOf ui.grid.treeBase.api:PublicApi + * @name rowCollapsed + * @description raised whenever a row is collapsed. Doesn't really have + * a purpose at the moment, included for symmetry + * + *
    +               *      gridApi.treeBase.on.rowCollapsed(scope,function(row){})
    +               * 
    + * @param {gridRow} row the row that was collapsed. You can also + * retrieve the grid from this row with row.grid + */ + rowCollapsed: {} + } + }, + + methods: { + treeBase: { + /** + * @ngdoc function + * @name expandAllRows + * @methodOf ui.grid.treeBase.api:PublicApi + * @description Expands all tree rows + */ + expandAllRows: function () { + service.expandAllRows(grid); + }, + + /** + * @ngdoc function + * @name collapseAllRows + * @methodOf ui.grid.treeBase.api:PublicApi + * @description collapse all tree rows + */ + collapseAllRows: function () { + service.collapseAllRows(grid); + }, + + /** + * @ngdoc function + * @name toggleRowTreeState + * @methodOf ui.grid.treeBase.api:PublicApi + * @description call expand if the row is collapsed, collapse if it is expanded + * @param {gridRow} row the row you wish to toggle + */ + toggleRowTreeState: function (row) { + service.toggleRowTreeState(grid, row); + }, + + /** + * @ngdoc function + * @name expandRow + * @methodOf ui.grid.treeBase.api:PublicApi + * @description expand the immediate children of the specified row + * @param {gridRow} row the row you wish to expand + * @param {boolean} recursive true if you wish to expand the row's ancients + */ + expandRow: function (row, recursive) { + service.expandRow(grid, row, recursive); + }, + + /** + * @ngdoc function + * @name expandRowChildren + * @methodOf ui.grid.treeBase.api:PublicApi + * @description expand all children of the specified row + * @param {gridRow} row the row you wish to expand + */ + expandRowChildren: function (row) { + service.expandRowChildren(grid, row); + }, + + /** + * @ngdoc function + * @name collapseRow + * @methodOf ui.grid.treeBase.api:PublicApi + * @description collapse the specified row. When + * you expand the row again, all grandchildren will retain their state + * @param {gridRow} row the row you wish to collapse + */ + collapseRow: function ( row ) { + service.collapseRow(grid, row); + }, + + /** + * @ngdoc function + * @name collapseRowChildren + * @methodOf ui.grid.treeBase.api:PublicApi + * @description collapse all children of the specified row. When + * you expand the row again, all grandchildren will be collapsed + * @param {gridRow} row the row you wish to collapse children for + */ + collapseRowChildren: function ( row ) { + service.collapseRowChildren(grid, row); + }, + + /** + * @ngdoc function + * @name getTreeState + * @methodOf ui.grid.treeBase.api:PublicApi + * @description Get the tree state for this grid, + * used by the saveState feature + * Returned treeState as an object + * `{ expandedState: { uid: 'expanded', uid: 'collapsed' } }` + * where expandedState is a hash of row uid and the current expanded state + * + * @returns {object} tree state + * + * TODO - this needs work - we need an identifier that persists across instantiations, + * not uid. This really means we need a row identity defined, but that won't work for + * grouping. Perhaps this needs to be moved up to treeView and grouping, rather than + * being in base. + */ + getTreeExpandedState: function () { + return { expandedState: service.getTreeState(grid) }; + }, + + /** + * @ngdoc function + * @name setTreeState + * @methodOf ui.grid.treeBase.api:PublicApi + * @description Set the expanded states of the tree + * @param {object} config the config you want to apply, in the format + * provided by getTreeState + */ + setTreeState: function ( config ) { + service.setTreeState( grid, config ); + }, + + /** + * @ngdoc function + * @name getRowChildren + * @methodOf ui.grid.treeBase.api:PublicApi + * @description Get the children of the specified row + * @param {GridRow} row the row you want the children of + * @returns {Array} array of children of this row, the children + * are all gridRows + */ + getRowChildren: function ( row ){ + return row.treeNode.children.map( function( childNode ){ + return childNode.row; + }); + } + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + + grid.api.registerMethodsFromObject(publicApi.methods); + }, + + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.treeBase.api:GridOptions + * + * @description GridOptions for treeBase feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + */ + + /** + * @ngdoc object + * @name treeRowHeaderBaseWidth + * @propertyOf ui.grid.treeBase.api:GridOptions + * @description Base width of the tree header, provides for a single level of tree. This + * is incremented by `treeIndent` for each extra level + *
    Defaults to 30 + */ + gridOptions.treeRowHeaderBaseWidth = gridOptions.treeRowHeaderBaseWidth || 30; + + /** + * @ngdoc object + * @name treeIndent + * @propertyOf ui.grid.treeBase.api:GridOptions + * @description Number of pixels of indent for the icon at each tree level, wider indents are visually more pleasing, + * but will make the tree row header wider + *
    Defaults to 10 + */ + gridOptions.treeIndent = (gridOptions.treeIndent != null) ? gridOptions.treeIndent : 10; + + /** + * @ngdoc object + * @name showTreeRowHeader + * @propertyOf ui.grid.treeBase.api:GridOptions + * @description If set to false, don't create the row header. You'll need to programmatically control the expand + * states + *
    Defaults to true + */ + gridOptions.showTreeRowHeader = gridOptions.showTreeRowHeader !== false; + + /** + * @ngdoc object + * @name showTreeExpandNoChildren + * @propertyOf ui.grid.treeBase.api:GridOptions + * @description If set to true, show the expand/collapse button even if there are no + * children of a node. You'd use this if you're planning to dynamically load the children + * + *
    Defaults to true, grouping overrides to false + */ + gridOptions.showTreeExpandNoChildren = gridOptions.showTreeExpandNoChildren !== false; + + /** + * @ngdoc object + * @name treeRowHeaderAlwaysVisible + * @propertyOf ui.grid.treeBase.api:GridOptions + * @description If set to true, row header even if there are no tree nodes + * + *
    Defaults to true + */ + gridOptions.treeRowHeaderAlwaysVisible = gridOptions.treeRowHeaderAlwaysVisible !== false; + + /** + * @ngdoc object + * @name treeCustomAggregations + * @propertyOf ui.grid.treeBase.api:GridOptions + * @description Define custom aggregation functions. The properties of this object will be + * aggregation types available for use on columnDef with {@link ui.grid.treeBase.api:ColumnDef treeAggregationType} or through the column menu. + * If a function defined here uses the same name as one of the native aggregations, this one will take precedence. + * The object format is: + * + *
    +         *    {
    +         *      aggregationName: {
    +         *        label: (optional) string,
    +         *        aggregationFn: function( aggregation, fieldValue, numValue, row ){...},
    +         *        finalizerFn: (optional) function( aggregation ){...}
    +         *      },
    +         *      mean: {
    +         *        label: 'mean',
    +         *        aggregationFn: function( aggregation, fieldValue, numValue ){
    +         *          aggregation.count = (aggregation.count || 1) + 1;
    +         *          aggregation.sum = (aggregation.sum || 0) + numValue;
    +         *        },
    +         *        finalizerFn: function( aggregation ){
    +         *          aggregation.value = aggregation.sum / aggregation.count
    +         *        }
    +         *      }
    +         *    }
    +         *  
    + * + *
    The `finalizerFn` may be used to manipulate the value before rendering, or to + * apply a custom rendered value. If `aggregation.rendered` is left undefined, the value will be + * rendered. Note that the native aggregation functions use an `finalizerFn` to concatenate + * the label and the value. + * + *
    Defaults to {} + */ + gridOptions.treeCustomAggregations = gridOptions.treeCustomAggregations || {}; + + /** + * @ngdoc object + * @name enableExpandAll + * @propertyOf ui.grid.treeBase.api:GridOptions + * @description Enable the expand all button at the top of the row header + * + *
    Defaults to true + */ + gridOptions.enableExpandAll = gridOptions.enableExpandAll !== false; + }, + + + /** + * @ngdoc function + * @name treeBaseColumnBuilder + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Sets the tree defaults based on the columnDefs + * + * @param {object} colDef columnDef we're basing on + * @param {GridColumn} col the column we're to update + * @param {object} gridOptions the options we should use + * @returns {promise} promise for the builder - actually we do it all inline so it's immediately resolved + */ + treeBaseColumnBuilder: function (colDef, col, gridOptions) { + + + /** + * @ngdoc object + * @name customTreeAggregationFn + * @propertyOf ui.grid.treeBase.api:ColumnDef + * @description A custom function that aggregates rows into some form of + * total. Aggregations run row-by-row, the function needs to be capable of + * creating a running total. + * + * The function will be provided the aggregation item (in which you can store running + * totals), the row value that is to be aggregated, and that same row value converted to + * a number (most aggregations work on numbers) + * @example + *
    +         *    customTreeAggregationFn = function ( aggregation, fieldValue, numValue, row ){
    +         *      // calculates the average of the squares of the values
    +         *      if ( typeof(aggregation.count) === 'undefined' ){
    +         *        aggregation.count = 0;
    +         *      }
    +         *      aggregation.count++;
    +         *
    +         *      if ( !isNaN(numValue) ){
    +         *        if ( typeof(aggregation.total) === 'undefined' ){
    +         *          aggregation.total = 0;
    +         *        }
    +         *        aggregation.total = aggregation.total + numValue * numValue;
    +         *      }
    +         *
    +         *      aggregation.value = aggregation.total / aggregation.count;
    +         *    }
    +         *  
    + *
    Defaults to undefined. May be overwritten by treeAggregationType, the two options should not be used together. + */ + if ( typeof(colDef.customTreeAggregationFn) !== 'undefined' ){ + col.treeAggregationFn = colDef.customTreeAggregationFn; + } + + /** + * @ngdoc object + * @name treeAggregationType + * @propertyOf ui.grid.treeBase.api:ColumnDef + * @description Use one of the native or grid-level aggregation methods for calculating aggregations on this column. + * Native method are in the constants file and include: SUM, COUNT, MIN, MAX, AVG. This may also be the property the + * name of an aggregation function defined with {@link ui.grid.treeBase.api:GridOptions treeCustomAggregations}. + * + *
    +         *      treeAggregationType = uiGridTreeBaseConstants.aggregation.SUM,
    +         *    }
    +         *  
    + * + * If you are using aggregations you should either: + * + * - also use grouping, in which case the aggregations are displayed in the group header, OR + * - use treeView, in which case you can set `treeAggregationUpdateEntity: true` in the colDef, and + * treeBase will store the aggregation information in the entity, or you can set `treeAggregationUpdateEntity: false` + * in the colDef, and you need to manual retrieve the calculated aggregations from the row.treeNode.aggregations + * + *
    Takes precendence over a treeAggregationFn, the two options should not be used together. + *
    Defaults to undefined. + */ + if ( typeof(colDef.treeAggregationType) !== 'undefined' ){ + col.treeAggregation = { type: colDef.treeAggregationType }; + if ( typeof(gridOptions.treeCustomAggregations[colDef.treeAggregationType]) !== 'undefined' ){ + col.treeAggregationFn = gridOptions.treeCustomAggregations[colDef.treeAggregationType].aggregationFn; + col.treeAggregationFinalizerFn = gridOptions.treeCustomAggregations[colDef.treeAggregationType].finalizerFn; + col.treeAggregation.label = gridOptions.treeCustomAggregations[colDef.treeAggregationType].label; + } else if ( typeof(service.nativeAggregations()[colDef.treeAggregationType]) !== 'undefined' ){ + col.treeAggregationFn = service.nativeAggregations()[colDef.treeAggregationType].aggregationFn; + col.treeAggregation.label = service.nativeAggregations()[colDef.treeAggregationType].label; + } + } + + /** + * @ngdoc object + * @name treeAggregationLabel + * @propertyOf ui.grid.treeBase.api:ColumnDef + * @description A custom label to use for this aggregation. If provided we don't use native i18n. + */ + if ( typeof(colDef.treeAggregationLabel) !== 'undefined' ){ + if (typeof(col.treeAggregation) === 'undefined' ){ + col.treeAggregation = {}; + } + col.treeAggregation.label = colDef.treeAggregationLabel; + } + + /** + * @ngdoc object + * @name treeAggregationUpdateEntity + * @propertyOf ui.grid.treeBase.api:ColumnDef + * @description Store calculated aggregations into the entity, allowing them + * to be displayed in the grid using a standard cellTemplate. This defaults to true, + * if you are using grouping then you shouldn't set it to false, as then the aggregations won't + * display. + * + * If you are using treeView in most cases you'll want to set this to true. This will result in + * getCellValue returning the aggregation rather than whatever was stored in the cell attribute on + * the entity. If you want to render the underlying entity value (and do something else with the aggregation) + * then you could use a custom cellTemplate to display `row.entity.myAttribute`, rather than using getCellValue. + * + *
    Defaults to true + * + * @example + *
    +         *    gridOptions.columns = [{
    +         *      name: 'myCol',
    +         *      treeAggregation: { type: uiGridTreeBaseConstants.aggregation.SUM },
    +         *      treeAggregationUpdateEntity: true
    +         *      cellTemplate: '
    {{row.entity.myCol + " " + row.treeNode.aggregations[0].rendered}}
    ' + * }]; + *
    + */ + col.treeAggregationUpdateEntity = colDef.treeAggregationUpdateEntity !== false; + + /** + * @ngdoc object + * @name customTreeAggregationFinalizerFn + * @propertyOf ui.grid.treeBase.api:ColumnDef + * @description A custom function that populates aggregation.rendered, this is called when + * a particular aggregation has been fully calculated, and we want to render the value. + * + * With the native aggregation options we just concatenate `aggregation.label` and + * `aggregation.value`, but if you wanted to apply a filter or otherwise manipulate the label + * or the value, you can do so with this function. This function will be called after the + * the default `finalizerFn`. + * + * @example + *
    +         *    customTreeAggregationFinalizerFn = function ( aggregation ){
    +         *      aggregation.rendered = aggregation.label + aggregation.value / 100 + '%';
    +         *    }
    +         *  
    + *
    Defaults to undefined. + */ + if ( typeof(col.customTreeAggregationFinalizerFn) === 'undefined' ){ + col.customTreeAggregationFinalizerFn = colDef.customTreeAggregationFinalizerFn; + } + + }, + + + /** + * @ngdoc function + * @name createRowHeader + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Create the rowHeader. If treeRowHeaderAlwaysVisible then + * set it to visible, otherwise set it to invisible + * + * @param {Grid} grid grid object + */ + createRowHeader: function( grid ){ + var rowHeaderColumnDef = { + name: uiGridTreeBaseConstants.rowHeaderColName, + displayName: '', + width: grid.options.treeRowHeaderBaseWidth, + minWidth: 10, + cellTemplate: 'ui-grid/treeBaseRowHeader', + headerCellTemplate: 'ui-grid/treeBaseHeaderCell', + enableColumnResizing: false, + enableColumnMenu: false, + exporterSuppressExport: true, + allowCellFocus: true + }; + + rowHeaderColumnDef.visible = grid.options.treeRowHeaderAlwaysVisible; + grid.addRowHeaderColumn(rowHeaderColumnDef, -100); + }, + + + /** + * @ngdoc function + * @name expandAllRows + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Expands all nodes in the tree + * + * @param {Grid} grid grid object + */ + expandAllRows: function (grid) { + grid.treeBase.tree.forEach( function( node ) { + service.setAllNodes( grid, node, uiGridTreeBaseConstants.EXPANDED); + }); + grid.treeBase.expandAll = true; + grid.queueGridRefresh(); + }, + + + /** + * @ngdoc function + * @name collapseAllRows + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Collapses all nodes in the tree + * + * @param {Grid} grid grid object + */ + collapseAllRows: function (grid) { + grid.treeBase.tree.forEach( function( node ) { + service.setAllNodes( grid, node, uiGridTreeBaseConstants.COLLAPSED); + }); + grid.treeBase.expandAll = false; + grid.queueGridRefresh(); + }, + + + /** + * @ngdoc function + * @name setAllNodes + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Works through a subset of grid.treeBase.rowExpandedStates, setting + * all child nodes (and their descendents) of the provided node to the given state. + * + * Calls itself recursively on all nodes so as to achieve this. + * + * @param {Grid} grid the grid we're operating on (so we can raise events) + * @param {object} treeNode a node in the tree that we want to update + * @param {string} targetState the state we want to set it to + */ + setAllNodes: function (grid, treeNode, targetState) { + if ( typeof(treeNode.state) !== 'undefined' && treeNode.state !== targetState ){ + treeNode.state = targetState; + + if ( targetState === uiGridTreeBaseConstants.EXPANDED ){ + grid.api.treeBase.raise.rowExpanded(treeNode.row); + } else { + grid.api.treeBase.raise.rowCollapsed(treeNode.row); + } + } + + // set all child nodes + if ( treeNode.children ){ + treeNode.children.forEach(function( childNode ){ + service.setAllNodes(grid, childNode, targetState); + }); + } + }, + + + /** + * @ngdoc function + * @name toggleRowTreeState + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Toggles the expand or collapse state of this grouped row, if + * it's a parent row + * + * @param {Grid} grid grid object + * @param {GridRow} row the row we want to toggle + */ + toggleRowTreeState: function ( grid, row ){ + if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){ + return; + } + + if (row.treeNode.state === uiGridTreeBaseConstants.EXPANDED){ + service.collapseRow(grid, row); + } else { + service.expandRow(grid, row, false); + } + + grid.queueGridRefresh(); + }, + + + /** + * @ngdoc function + * @name expandRow + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Expands this specific row, showing only immediate children. + * + * @param {Grid} grid grid object + * @param {GridRow} row the row we want to expand + * @param {boolean} recursive true if you wish to expand the row's ancients + */ + expandRow: function ( grid, row, recursive ){ + if ( recursive ){ + var parents = []; + while ( row && typeof(row.treeLevel) !== 'undefined' && row.treeLevel !== null && row.treeLevel >= 0 && row.treeNode.state !== uiGridTreeBaseConstants.EXPANDED ){ + parents.push(row); + row = row.treeNode.parentRow; + } + + if ( parents.length > 0 ){ + row = parents.pop(); + while ( row ){ + row.treeNode.state = uiGridTreeBaseConstants.EXPANDED; + grid.api.treeBase.raise.rowExpanded(row); + row = parents.pop(); + } + + grid.treeBase.expandAll = service.allExpanded(grid.treeBase.tree); + grid.queueGridRefresh(); + } + } else { + if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){ + return; + } + + if ( row.treeNode.state !== uiGridTreeBaseConstants.EXPANDED ){ + row.treeNode.state = uiGridTreeBaseConstants.EXPANDED; + grid.api.treeBase.raise.rowExpanded(row); + grid.treeBase.expandAll = service.allExpanded(grid.treeBase.tree); + grid.queueGridRefresh(); + } + } + }, + + + /** + * @ngdoc function + * @name expandRowChildren + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Expands this specific row, showing all children. + * + * @param {Grid} grid grid object + * @param {GridRow} row the row we want to expand + */ + expandRowChildren: function ( grid, row ){ + if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){ + return; + } + + service.setAllNodes(grid, row.treeNode, uiGridTreeBaseConstants.EXPANDED); + grid.treeBase.expandAll = service.allExpanded(grid.treeBase.tree); + grid.queueGridRefresh(); + }, + + + /** + * @ngdoc function + * @name collapseRow + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Collapses this specific row + * + * @param {Grid} grid grid object + * @param {GridRow} row the row we want to collapse + */ + collapseRow: function( grid, row ){ + if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){ + return; + } + + if ( row.treeNode.state !== uiGridTreeBaseConstants.COLLAPSED ){ + row.treeNode.state = uiGridTreeBaseConstants.COLLAPSED; + grid.treeBase.expandAll = false; + grid.api.treeBase.raise.rowCollapsed(row); + grid.queueGridRefresh(); + } + }, + + + /** + * @ngdoc function + * @name collapseRowChildren + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Collapses this specific row and all children + * + * @param {Grid} grid grid object + * @param {GridRow} row the row we want to collapse + */ + collapseRowChildren: function( grid, row ){ + if ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ){ + return; + } + + service.setAllNodes(grid, row.treeNode, uiGridTreeBaseConstants.COLLAPSED); + grid.treeBase.expandAll = false; + grid.queueGridRefresh(); + }, + + + /** + * @ngdoc function + * @name allExpanded + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Returns true if all rows are expanded, false + * if they're not. Walks the tree to determine this. Used + * to set the expandAll state. + * + * If the node has no children, then return true (it's immaterial + * whether it is expanded). If the node has children, then return + * false if this node is collapsed, or if any child node is not all expanded + * + * @param {object} tree the grid to check + * @returns {boolean} whether or not the tree is all expanded + */ + allExpanded: function( tree ){ + var allExpanded = true; + tree.forEach( function( node ){ + if ( !service.allExpandedInternal( node ) ){ + allExpanded = false; + } + }); + return allExpanded; + }, + + allExpandedInternal: function( treeNode ){ + if ( treeNode.children && treeNode.children.length > 0 ){ + if ( treeNode.state === uiGridTreeBaseConstants.COLLAPSED ){ + return false; + } + var allExpanded = true; + treeNode.children.forEach( function( node ){ + if ( !service.allExpandedInternal( node ) ){ + allExpanded = false; + } + }); + return allExpanded; + } else { + return true; + } + }, + + + /** + * @ngdoc function + * @name treeRows + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description The rowProcessor that adds the nodes to the tree, and sets the visible + * state of each row based on it's parent state + * + * Assumes it is always called after the sorting processor, and the grouping processor if there is one. + * Performs any tree sorts itself after having built the tree + * + * Processes all the rows in order, setting the group level based on the $$treeLevel in the associated + * entity, and setting the visible state based on the parent's state. + * + * Calculates the deepest level of tree whilst it goes, and updates that so that the header column can be correctly + * sized. + * + * Aggregates if necessary along the way. + * + * @param {array} renderableRows the rows we want to process, usually the output from the previous rowProcessor + * @returns {array} the updated rows + */ + treeRows: function( renderableRows ) { + var grid = this; + + if (renderableRows.length === 0) { + service.updateRowHeaderWidth( grid ); + return renderableRows; + } + + grid.treeBase.tree = service.createTree( grid, renderableRows ); + service.updateRowHeaderWidth( grid ); + + service.sortTree( grid ); + service.fixFilter( grid ); + + return service.renderTree( grid.treeBase.tree ); + }, + + + /** + * @ngdoc function + * @name createOrUpdateRowHeaderWidth + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Calculates the rowHeader width. + * + * If rowHeader is always present, updates the width. + * + * If rowHeader is only sometimes present (`treeRowHeaderAlwaysVisible: false`), determines whether there + * should be one, then creates or removes it as appropriate, with the created rowHeader having the + * right width. + * + * If there's never a rowHeader then never creates one: `showTreeRowHeader: false` + * + * @param {Grid} grid the grid we want to set the row header on + */ + updateRowHeaderWidth: function( grid ){ + var rowHeader = grid.getColumn(uiGridTreeBaseConstants.rowHeaderColName); + + var newWidth = grid.options.treeRowHeaderBaseWidth + grid.options.treeIndent * Math.max(grid.treeBase.numberLevels - 1, 0); + if ( rowHeader && newWidth !== rowHeader.width ){ + rowHeader.width = newWidth; + grid.queueRefresh(); + } + + var newVisibility = true; + if ( grid.options.showTreeRowHeader === false ){ + newVisibility = false; + } + if ( grid.options.treeRowHeaderAlwaysVisible === false && grid.treeBase.numberLevels <= 0 ){ + newVisibility = false; + } + if ( rowHeader && rowHeader.visible !== newVisibility ) { + rowHeader.visible = newVisibility; + rowHeader.colDef.visible = newVisibility; + grid.queueGridRefresh(); + } + }, + + + /** + * @ngdoc function + * @name renderTree + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Creates an array of rows based on the tree, exporting only + * the visible nodes and leaves + * + * @param {array} nodeList The list of nodes - can be grid.treeBase.tree, or can be node.children when + * we're calling recursively + * @returns {array} renderable rows + */ + renderTree: function( nodeList ){ + var renderableRows = []; + + nodeList.forEach( function ( node ){ + if ( node.row.visible ){ + renderableRows.push( node.row ); + } + if ( node.state === uiGridTreeBaseConstants.EXPANDED && node.children && node.children.length > 0 ){ + renderableRows = renderableRows.concat( service.renderTree( node.children ) ); + } + }); + return renderableRows; + }, + + + /** + * @ngdoc function + * @name createTree + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Creates a tree from the renderableRows + * + * @param {Grid} grid The grid + * @param {array} renderableRows The rows we want to create a tree from + * @returns {object} The tree we've build + */ + createTree: function( grid, renderableRows ) { + var currentLevel = -1; + var parents = []; + var currentState; + grid.treeBase.tree = []; + grid.treeBase.numberLevels = 0; + var aggregations = service.getAggregations( grid ); + + var createNode = function( row ){ + if ( typeof(row.entity.$$treeLevel) !== 'undefined' && row.treeLevel !== row.entity.$$treeLevel ){ + row.treeLevel = row.entity.$$treeLevel; + } + + if ( row.treeLevel <= currentLevel ){ + // pop any levels that aren't parents of this level, formatting the aggregation at the same time + while ( row.treeLevel <= currentLevel ){ + var lastParent = parents.pop(); + service.finaliseAggregations( lastParent ); + currentLevel--; + } + + // reset our current state based on the new parent, set to expanded if this is a level 0 node + if ( parents.length > 0 ){ + currentState = service.setCurrentState(parents); + } else { + currentState = uiGridTreeBaseConstants.EXPANDED; + } + } + + // aggregate if this is a leaf node + if ( ( typeof(row.treeLevel) === 'undefined' || row.treeLevel === null || row.treeLevel < 0 ) && row.visible ){ + service.aggregate( grid, row, parents ); + } + + // add this node to the tree + service.addOrUseNode(grid, row, parents, aggregations); + + if ( typeof(row.treeLevel) !== 'undefined' && row.treeLevel !== null && row.treeLevel >= 0 ){ + parents.push(row); + currentLevel++; + currentState = service.setCurrentState(parents); + } + + // update the tree number of levels, so we can set header width if we need to + if ( grid.treeBase.numberLevels < row.treeLevel + 1){ + grid.treeBase.numberLevels = row.treeLevel + 1; + } + }; + + renderableRows.forEach( createNode ); + + // finalise remaining aggregations + while ( parents.length > 0 ){ + var lastParent = parents.pop(); + service.finaliseAggregations( lastParent ); + } + + return grid.treeBase.tree; + }, + + + /** + * @ngdoc function + * @name addOrUseNode + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Creates a tree node for this row. If this row already has a treeNode + * recorded against it, preserves the state, but otherwise overwrites the data. + * + * @param {grid} grid The grid we're operating on + * @param {gridRow} row The row we want to set + * @param {array} parents An array of the parents this row should have + * @param {array} aggregationBase Empty aggregation information + * @returns {undefined} Updates the parents array, updates the row to have a treeNode, and updates the + * grid.treeBase.tree + */ + addOrUseNode: function( grid, row, parents, aggregationBase ){ + var newAggregations = []; + aggregationBase.forEach( function(aggregation){ + newAggregations.push(service.buildAggregationObject(aggregation.col)); + }); + + var newNode = { state: uiGridTreeBaseConstants.COLLAPSED, row: row, parentRow: null, aggregations: newAggregations, children: [] }; + if ( row.treeNode ){ + newNode.state = row.treeNode.state; + } + if ( parents.length > 0 ){ + newNode.parentRow = parents[parents.length - 1]; + } + row.treeNode = newNode; + + if ( parents.length === 0 ){ + grid.treeBase.tree.push( newNode ); + } else { + parents[parents.length - 1].treeNode.children.push( newNode ); + } + }, + + + /** + * @ngdoc function + * @name setCurrentState + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Looks at the parents array to determine our current state. + * If any node in the hierarchy is collapsed, then return collapsed, otherwise return + * expanded. + * + * @param {array} parents An array of the parents this row should have + * @returns {string} The state we should be setting to any nodes we see + */ + setCurrentState: function( parents ){ + var currentState = uiGridTreeBaseConstants.EXPANDED; + parents.forEach( function(parent){ + if ( parent.treeNode.state === uiGridTreeBaseConstants.COLLAPSED ){ + currentState = uiGridTreeBaseConstants.COLLAPSED; + } + }); + return currentState; + }, + + + /** + * @ngdoc function + * @name sortTree + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Performs a recursive sort on the tree nodes, sorting the + * children of each node and putting them back into the children array. + * + * Before doing this it turns back on all the sortIgnore - things that were previously + * ignored we process now. Since we're sorting within the nodes, presumably anything + * that was already sorted is how we derived the nodes, we can keep those sorts too. + * + * We only sort tree nodes that are expanded - no point in wasting effort sorting collapsed + * nodes + * + * @param {Grid} grid The grid to get the aggregation information from + * @returns {array} The aggregation information + */ + sortTree: function( grid ){ + grid.columns.forEach( function( column ) { + if ( column.sort && column.sort.ignoreSort ){ + delete column.sort.ignoreSort; + } + }); + + grid.treeBase.tree = service.sortInternal( grid, grid.treeBase.tree ); + }, + + sortInternal: function( grid, treeList ){ + var rows = treeList.map( function( node ){ + return node.row; + }); + + rows = rowSorter.sort( grid, rows, grid.columns ); + + var treeNodes = rows.map( function( row ){ + return row.treeNode; + }); + + treeNodes.forEach( function( node ){ + if ( node.state === uiGridTreeBaseConstants.EXPANDED && node.children && node.children.length > 0 ){ + node.children = service.sortInternal( grid, node.children ); + } + }); + + return treeNodes; + }, + + /** + * @ngdoc function + * @name fixFilter + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description After filtering has run, we need to go back through the tree + * and make sure the parent rows are always visible if any of the child rows + * are visible (filtering may make a child visible, but the parent may not + * match the filter criteria) + * + * This has a risk of being computationally expensive, we do it by walking + * the tree and remembering whether there are any invisible nodes on the + * way down. + * + * @param {Grid} grid the grid to fix filters on + */ + fixFilter: function( grid ){ + var parentsVisible; + + grid.treeBase.tree.forEach( function( node ){ + if ( node.children && node.children.length > 0 ){ + parentsVisible = node.row.visible; + service.fixFilterInternal( node.children, parentsVisible ); + } + }); + }, + + fixFilterInternal: function( nodes, parentsVisible) { + nodes.forEach( function( node ){ + if ( node.row.visible && !parentsVisible ){ + service.setParentsVisible( node ); + parentsVisible = true; + } + + if ( node.children && node.children.length > 0 ){ + if ( service.fixFilterInternal( node.children, ( parentsVisible && node.row.visible ) ) ) { + parentsVisible = true; + } + } + }); + + return parentsVisible; + }, + + setParentsVisible: function( node ){ + while ( node.parentRow ){ + node.parentRow.visible = true; + node = node.parentRow.treeNode; + } + }, + + /** + * @ngdoc function + * @name buildAggregationObject + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Build the object which is stored on the column for holding meta-data about the aggregation. + * This method should only be called with columns which have an aggregation. + * + * @param {GridColumn} column The column which this object relates to + * @returns {object} {col: GridColumn object, label: string, type: string (optional)} + */ + buildAggregationObject: function( column ){ + var newAggregation = { col: column }; + + if ( column.treeAggregation && column.treeAggregation.type ){ + newAggregation.type = column.treeAggregation.type; + } + + if ( column.treeAggregation && column.treeAggregation.label ){ + newAggregation.label = column.treeAggregation.label; + } + + return newAggregation; + }, + + /** + * @ngdoc function + * @name getAggregations + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Looks through the grid columns to find those with aggregations, + * and collates the aggregation information into an array, returns that array + * + * @param {Grid} grid the grid to get the aggregation information from + * @returns {array} the aggregation information + */ + getAggregations: function( grid ){ + var aggregateArray = []; + + grid.columns.forEach( function(column){ + if ( typeof(column.treeAggregationFn) !== 'undefined' ){ + aggregateArray.push( service.buildAggregationObject(column) ); + + if ( grid.options.showColumnFooter && typeof(column.colDef.aggregationType) === 'undefined' && column.treeAggregation ){ + // Add aggregation object for footer + column.treeFooterAggregation = service.buildAggregationObject(column); + column.aggregationType = service.treeFooterAggregationType; + } + } + }); + return aggregateArray; + }, + + + /** + * @ngdoc function + * @name aggregate + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Accumulate the data from this row onto the aggregations for each parent + * + * Iterate over the parents, then iterate over the aggregations for each of those parents, + * and perform the aggregation for each individual aggregation + * + * @param {Grid} grid grid object + * @param {GridRow} row the row we want to set grouping visibility on + * @param {array} parents the parents that we would want to aggregate onto + */ + aggregate: function( grid, row, parents ){ + if ( parents.length === 0 && row.treeNode && row.treeNode.aggregations ){ + row.treeNode.aggregations.forEach(function(aggregation){ + // Calculate aggregations for footer even if there are no grouped rows + if ( typeof(aggregation.col.treeFooterAggregation) !== 'undefined' ) { + var fieldValue = grid.getCellValue(row, aggregation.col); + var numValue = Number(fieldValue); + aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row); + } + }); + } + + parents.forEach( function( parent, index ){ + if ( parent.treeNode.aggregations ){ + parent.treeNode.aggregations.forEach( function( aggregation ){ + var fieldValue = grid.getCellValue(row, aggregation.col); + var numValue = Number(fieldValue); + aggregation.col.treeAggregationFn(aggregation, fieldValue, numValue, row); + + if ( index === 0 && typeof(aggregation.col.treeFooterAggregation) !== 'undefined' ){ + aggregation.col.treeAggregationFn(aggregation.col.treeFooterAggregation, fieldValue, numValue, row); + } + }); + } + }); + }, + + + // Aggregation routines - no doco needed as self evident + nativeAggregations: function() { + var nativeAggregations = { + count: { + label: i18nService.get().aggregation.count, + menuTitle: i18nService.get().grouping.aggregate_count, + aggregationFn: function (aggregation, fieldValue, numValue) { + if (typeof(aggregation.value) === 'undefined') { + aggregation.value = 1; + } else { + aggregation.value++; + } + } + }, + + sum: { + label: i18nService.get().aggregation.sum, + menuTitle: i18nService.get().grouping.aggregate_sum, + aggregationFn: function( aggregation, fieldValue, numValue ) { + if (!isNaN(numValue)) { + if (typeof(aggregation.value) === 'undefined') { + aggregation.value = numValue; + } else { + aggregation.value += numValue; + } + } + } + }, + + min: { + label: i18nService.get().aggregation.min, + menuTitle: i18nService.get().grouping.aggregate_min, + aggregationFn: function( aggregation, fieldValue, numValue ) { + if (typeof(aggregation.value) === 'undefined') { + aggregation.value = fieldValue; + } else { + if (typeof(fieldValue) !== 'undefined' && fieldValue !== null && (fieldValue < aggregation.value || aggregation.value === null)) { + aggregation.value = fieldValue; + } + } + } + }, + + max: { + label: i18nService.get().aggregation.max, + menuTitle: i18nService.get().grouping.aggregate_max, + aggregationFn: function( aggregation, fieldValue, numValue ){ + if ( typeof(aggregation.value) === 'undefined' ){ + aggregation.value = fieldValue; + } else { + if ( typeof(fieldValue) !== 'undefined' && fieldValue !== null && (fieldValue > aggregation.value || aggregation.value === null)){ + aggregation.value = fieldValue; + } + } + } + }, + + avg: { + label: i18nService.get().aggregation.avg, + menuTitle: i18nService.get().grouping.aggregate_avg, + aggregationFn: function( aggregation, fieldValue, numValue ){ + if ( typeof(aggregation.count) === 'undefined' ){ + aggregation.count = 1; + } else { + aggregation.count++; + } + + if ( isNaN(numValue) ){ + return; + } + + if ( typeof(aggregation.value) === 'undefined' || typeof(aggregation.sum) === 'undefined' ){ + aggregation.value = numValue; + aggregation.sum = numValue; + } else { + aggregation.sum += numValue; + aggregation.value = aggregation.sum / aggregation.count; + } + } + } + }; + return nativeAggregations; + }, + + /** + * @ngdoc function + * @name finaliseAggregation + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Helper function used to finalize aggregation nodes and footer cells + * + * @param {gridRow} row The parent we're finalising + * @param {aggregation} aggregation The aggregation object manipulated by the aggregationFn + */ + finaliseAggregation: function(row, aggregation){ + if ( aggregation.col.treeAggregationUpdateEntity && typeof(row) !== 'undefined' && typeof(row.entity[ '$$' + aggregation.col.uid ]) !== 'undefined' ){ + angular.extend( aggregation, row.entity[ '$$' + aggregation.col.uid ]); + } + + if ( typeof(aggregation.col.treeAggregationFinalizerFn) === 'function' ){ + aggregation.col.treeAggregationFinalizerFn( aggregation ); + } + if ( typeof(aggregation.col.customTreeAggregationFinalizerFn) === 'function' ){ + aggregation.col.customTreeAggregationFinalizerFn( aggregation ); + } + if ( typeof(aggregation.rendered) === 'undefined' ){ + aggregation.rendered = aggregation.label ? aggregation.label + aggregation.value : aggregation.value; + } + }, + + /** + * @ngdoc function + * @name finaliseAggregations + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Format the data from the aggregation into the rendered text + * e.g. if we had label: 'sum: ' and value: 25, we'd create 'sum: 25'. + * + * As part of this we call any formatting callback routines we've been provided. + * + * We write our aggregation out to the row.entity if treeAggregationUpdateEntity is + * set on the column - we don't overwrite any information that's already there, we append + * to it so that grouping can have set the groupVal beforehand without us overwriting it. + * + * We need to copy the data from the row.entity first before we finalise the aggregation, + * we need that information for the finaliserFn + * + * @param {gridRow} row the parent we're finalising + */ + finaliseAggregations: function( row ){ + if ( row == null || typeof(row.treeNode.aggregations) === 'undefined' ){ + return; + } + + row.treeNode.aggregations.forEach( function( aggregation ) { + service.finaliseAggregation(row, aggregation); + + if ( aggregation.col.treeAggregationUpdateEntity ){ + var aggregationCopy = {}; + angular.forEach( aggregation, function( value, key ){ + if ( aggregation.hasOwnProperty(key) && key !== 'col' ){ + aggregationCopy[key] = value; + } + }); + + row.entity[ '$$' + aggregation.col.uid ] = aggregationCopy; + } + }); + }, + + /** + * @ngdoc function + * @name treeFooterAggregationType + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Uses the tree aggregation functions and finalizers to set the + * column footer aggregations. + * + * @param {rows} rows The visible rows. not used, but accepted to match signature of GridColumn.aggregationType + * @param {GridColumn} column The column we are finalizing + */ + treeFooterAggregationType: function( rows, column ) { + service.finaliseAggregation(undefined, column.treeFooterAggregation); + if ( typeof(column.treeFooterAggregation.value) === 'undefined' || column.treeFooterAggregation.rendered === null ){ + // The was apparently no aggregation performed (perhaps this is a grouped column + return ''; + } + return column.treeFooterAggregation.rendered; + } + }; + + return service; + + }]); + + + /** + * @ngdoc directive + * @name ui.grid.treeBase.directive:uiGridTreeRowHeaderButtons + * @element div + * + * @description Provides the expand/collapse button on rows + */ + module.directive('uiGridTreeBaseRowHeaderButtons', ['$templateCache', 'uiGridTreeBaseService', + function ($templateCache, uiGridTreeBaseService) { + return { + replace: true, + restrict: 'E', + template: $templateCache.get('ui-grid/treeBaseRowHeaderButtons'), + scope: true, + require: '^uiGrid', + link: function($scope, $elm, $attrs, uiGridCtrl) { + var self = uiGridCtrl.grid; + $scope.treeButtonClass = function(row) { + if ( ( self.options.showTreeExpandNoChildren && row.treeLevel > -1 ) || ( row.treeNode.children && row.treeNode.children.length > 0 ) ) { + if (row.treeNode.state === 'expanded' ) { + return 'ui-grid-icon-minus-squared'; + } + if (row.treeNode.state === 'collapsed' ) { + return 'ui-grid-icon-plus-squared'; + } + } + }; + $scope.treeButtonClick = function(row, evt) { + evt.stopPropagation(); + uiGridTreeBaseService.toggleRowTreeState(self, row, evt); + }; + } + }; + }]); + + + /** + * @ngdoc directive + * @name ui.grid.treeBase.directive:uiGridTreeBaseExpandAllButtons + * @element div + * + * @description Provides the expand/collapse all button + */ + module.directive('uiGridTreeBaseExpandAllButtons', ['$templateCache', 'uiGridTreeBaseService', + function ($templateCache, uiGridTreeBaseService) { + return { + replace: true, + restrict: 'E', + template: $templateCache.get('ui-grid/treeBaseExpandAllButtons'), + scope: false, + link: function($scope, $elm, $attrs, uiGridCtrl) { + var self = $scope.col.grid; + $scope.headerButtonClass = function() { + if (self.treeBase.numberLevels > 0 && self.treeBase.expandAll) { + return 'ui-grid-icon-minus-squared'; + } + if (self.treeBase.numberLevels > 0 && !self.treeBase.expandAll) { + return 'ui-grid-icon-plus-squared'; + } + }; + $scope.headerButtonClick = function(row, evt) { + if ( self.treeBase.expandAll ){ + uiGridTreeBaseService.collapseAllRows(self, evt); + } else { + uiGridTreeBaseService.expandAllRows(self, evt); + } + }; + } + }; + }]); + + + /** + * @ngdoc directive + * @name ui.grid.treeBase.directive:uiGridViewport + * @element div + * + * @description Stacks on top of ui.grid.uiGridViewport to set formatting on a tree header row + */ + module.directive('uiGridViewport', + ['$compile', 'uiGridConstants', 'gridUtil', '$parse', + function ($compile, uiGridConstants, gridUtil, $parse) { + return { + priority: -200, // run after default directive + scope: false, + compile: function ($elm, $attrs) { + var rowRepeatDiv = angular.element($elm.children().children()[0]); + + var existingNgClass = rowRepeatDiv.attr("ng-class"); + var newNgClass = ''; + if ( existingNgClass ) { + newNgClass = existingNgClass.slice(0, -1) + ",'ui-grid-tree-header-row': row.treeLevel > -1}"; + } else { + newNgClass = "{'ui-grid-tree-header-row': row.treeLevel > -1}"; + } + rowRepeatDiv.attr("ng-class", newNgClass); + + return { + pre: function ($scope, $elm, $attrs, controllers) { + + }, + post: function ($scope, $elm, $attrs, controllers) { + } + }; + } + }; + }]); +})(); diff --git a/release/4.4.11/ui-grid.tree-base.min.js b/release/4.4.11/ui-grid.tree-base.min.js new file mode 100644 index 000000000..bb41e74ec --- /dev/null +++ b/release/4.4.11/ui-grid.tree-base.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.treeBase",["ui.grid"]);e.constant("uiGridTreeBaseConstants",{featureName:"treeBase",rowHeaderColName:"treeBaseRowHeaderCol",EXPANDED:"expanded",COLLAPSED:"collapsed",aggregation:{COUNT:"count",SUM:"sum",MAX:"max",MIN:"min",AVG:"avg"}}),e.service("uiGridTreeBaseService",["$q","uiGridTreeBaseConstants","gridUtil","GridRow","gridClassFactory","i18nService","uiGridConstants","rowSorter",function(e,i,t,r,n,o,a,l){var g={initializeGrid:function(r,e){r.treeBase={},r.treeBase.numberLevels=0,r.treeBase.expandAll=!1,r.treeBase.tree=[],g.defaultGridOptions(r.options),r.registerRowsProcessor(g.treeRows,410),r.registerColumnBuilder(g.treeBaseColumnBuilder),g.createRowHeader(r);var t={events:{treeBase:{rowExpanded:{},rowCollapsed:{}}},methods:{treeBase:{expandAllRows:function(){g.expandAllRows(r)},collapseAllRows:function(){g.collapseAllRows(r)},toggleRowTreeState:function(e){g.toggleRowTreeState(r,e)},expandRow:function(e,t){g.expandRow(r,e,t)},expandRowChildren:function(e){g.expandRowChildren(r,e)},collapseRow:function(e){g.collapseRow(r,e)},collapseRowChildren:function(e){g.collapseRowChildren(r,e)},getTreeExpandedState:function(){return{expandedState:g.getTreeState(r)}},setTreeState:function(e){g.setTreeState(r,e)},getRowChildren:function(e){return e.treeNode.children.map(function(e){return e.row})}}}};r.api.registerEventsFromObject(t.events),r.api.registerMethodsFromObject(t.methods)},defaultGridOptions:function(e){e.treeRowHeaderBaseWidth=e.treeRowHeaderBaseWidth||30,e.treeIndent=null!=e.treeIndent?e.treeIndent:10,e.showTreeRowHeader=!1!==e.showTreeRowHeader,e.showTreeExpandNoChildren=!1!==e.showTreeExpandNoChildren,e.treeRowHeaderAlwaysVisible=!1!==e.treeRowHeaderAlwaysVisible,e.treeCustomAggregations=e.treeCustomAggregations||{},e.enableExpandAll=!1!==e.enableExpandAll},treeBaseColumnBuilder:function(e,t,r){void 0!==e.customTreeAggregationFn&&(t.treeAggregationFn=e.customTreeAggregationFn),void 0!==e.treeAggregationType&&(t.treeAggregation={type:e.treeAggregationType},void 0!==r.treeCustomAggregations[e.treeAggregationType]?(t.treeAggregationFn=r.treeCustomAggregations[e.treeAggregationType].aggregationFn,t.treeAggregationFinalizerFn=r.treeCustomAggregations[e.treeAggregationType].finalizerFn,t.treeAggregation.label=r.treeCustomAggregations[e.treeAggregationType].label):void 0!==g.nativeAggregations()[e.treeAggregationType]&&(t.treeAggregationFn=g.nativeAggregations()[e.treeAggregationType].aggregationFn,t.treeAggregation.label=g.nativeAggregations()[e.treeAggregationType].label)),void 0!==e.treeAggregationLabel&&(void 0===t.treeAggregation&&(t.treeAggregation={}),t.treeAggregation.label=e.treeAggregationLabel),t.treeAggregationUpdateEntity=!1!==e.treeAggregationUpdateEntity,void 0===t.customTreeAggregationFinalizerFn&&(t.customTreeAggregationFinalizerFn=e.customTreeAggregationFinalizerFn)},createRowHeader:function(e){var t={name:i.rowHeaderColName,displayName:"",width:e.options.treeRowHeaderBaseWidth,minWidth:10,cellTemplate:"ui-grid/treeBaseRowHeader",headerCellTemplate:"ui-grid/treeBaseHeaderCell",enableColumnResizing:!1,enableColumnMenu:!1,exporterSuppressExport:!0,allowCellFocus:!0};t.visible=e.options.treeRowHeaderAlwaysVisible,e.addRowHeaderColumn(t,-100)},expandAllRows:function(t){t.treeBase.tree.forEach(function(e){g.setAllNodes(t,e,i.EXPANDED)}),t.treeBase.expandAll=!0,t.queueGridRefresh()},collapseAllRows:function(t){t.treeBase.tree.forEach(function(e){g.setAllNodes(t,e,i.COLLAPSED)}),t.treeBase.expandAll=!1,t.queueGridRefresh()},setAllNodes:function(t,e,r){void 0!==e.state&&e.state!==r&&((e.state=r)===i.EXPANDED?t.api.treeBase.raise.rowExpanded(e.row):t.api.treeBase.raise.rowCollapsed(e.row)),e.children&&e.children.forEach(function(e){g.setAllNodes(t,e,r)})},toggleRowTreeState:function(e,t){void 0===t.treeLevel||null===t.treeLevel||t.treeLevel<0||(t.treeNode.state===i.EXPANDED?g.collapseRow(e,t):g.expandRow(e,t,!1),e.queueGridRefresh())},expandRow:function(e,t,r){if(r){for(var n=[];t&&void 0!==t.treeLevel&&null!==t.treeLevel&&0<=t.treeLevel&&t.treeNode.state!==i.EXPANDED;)n.push(t),t=t.treeNode.parentRow;if(0e.value||null===e.value)&&(e.value=t)}},avg:{label:o.get().aggregation.avg,menuTitle:o.get().grouping.aggregate_avg,aggregationFn:function(e,t,r){void 0===e.count?e.count=1:e.count++,isNaN(r)||(void 0===e.value||void 0===e.sum?(e.value=r,e.sum=r):(e.sum+=r,e.value=e.sum/e.count))}}}},finaliseAggregation:function(e,t){t.col.treeAggregationUpdateEntity&&void 0!==e&&void 0!==e.entity["$$"+t.col.uid]&&angular.extend(t,e.entity["$$"+t.col.uid]),"function"==typeof t.col.treeAggregationFinalizerFn&&t.col.treeAggregationFinalizerFn(t),"function"==typeof t.col.customTreeAggregationFinalizerFn&&t.col.customTreeAggregationFinalizerFn(t),void 0===t.rendered&&(t.rendered=t.label?t.label+t.value:t.value)},finaliseAggregations:function(e){null!=e&&void 0!==e.treeNode.aggregations&&e.treeNode.aggregations.forEach(function(r){if(g.finaliseAggregation(e,r),r.col.treeAggregationUpdateEntity){var n={};angular.forEach(r,function(e,t){r.hasOwnProperty(t)&&"col"!==t&&(n[t]=e)}),e.entity["$$"+r.col.uid]=n}})},treeFooterAggregationType:function(e,t){return g.finaliseAggregation(void 0,t.treeFooterAggregation),void 0===t.treeFooterAggregation.value||null===t.treeFooterAggregation.rendered?"":t.treeFooterAggregation.rendered}};return g}]),e.directive("uiGridTreeBaseRowHeaderButtons",["$templateCache","uiGridTreeBaseService",function(e,a){return{replace:!0,restrict:"E",template:e.get("ui-grid/treeBaseRowHeaderButtons"),scope:!0,require:"^uiGrid",link:function(e,t,r,n){var o=n.grid;e.treeButtonClass=function(e){if(o.options.showTreeExpandNoChildren&&-1 -1}":"{'ui-grid-tree-header-row': row.treeLevel > -1}",r.attr("ng-class",o),{pre:function(e,t,r,n){},post:function(e,t,r,n){}}}}}])}(); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.tree-view.js b/release/4.4.11/ui-grid.tree-view.js new file mode 100644 index 000000000..7da3f2dcd --- /dev/null +++ b/release/4.4.11/ui-grid.tree-view.js @@ -0,0 +1,219 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.treeView + * @description + * + * # ui.grid.treeView + * + * + * + * This module provides a tree view of the data that it is provided, with nodes in that + * tree and leaves. Unlike grouping, the tree is an inherent property of the data and must + * be provided with your data array. + * + * Design information: + * ------------------- + * + * TreeView uses treeBase for the underlying functionality, and is a very thin wrapper around + * that logic. Most of the design information has now moved to treebase. + *
    + *
    + * + *
    + */ + + var module = angular.module('ui.grid.treeView', ['ui.grid', 'ui.grid.treeBase']); + + /** + * @ngdoc object + * @name ui.grid.treeView.constant:uiGridTreeViewConstants + * + * @description constants available in treeView module, this includes + * all the constants declared in the treeBase module (these are manually copied + * as there isn't an easy way to include constants in another constants file, and + * we don't want to make users include treeBase) + * + */ + module.constant('uiGridTreeViewConstants', { + featureName: "treeView", + rowHeaderColName: 'treeBaseRowHeaderCol', + EXPANDED: 'expanded', + COLLAPSED: 'collapsed', + aggregation: { + COUNT: 'count', + SUM: 'sum', + MAX: 'max', + MIN: 'min', + AVG: 'avg' + } + }); + + /** + * @ngdoc service + * @name ui.grid.treeView.service:uiGridTreeViewService + * + * @description Services for treeView features + */ + module.service('uiGridTreeViewService', ['$q', 'uiGridTreeViewConstants', 'uiGridTreeBaseConstants', 'uiGridTreeBaseService', 'gridUtil', 'GridRow', 'gridClassFactory', 'i18nService', 'uiGridConstants', + function ($q, uiGridTreeViewConstants, uiGridTreeBaseConstants, uiGridTreeBaseService, gridUtil, GridRow, gridClassFactory, i18nService, uiGridConstants) { + + var service = { + + initializeGrid: function (grid, $scope) { + uiGridTreeBaseService.initializeGrid( grid, $scope ); + + /** + * @ngdoc object + * @name ui.grid.treeView.grid:treeView + * + * @description Grid properties and functions added for treeView + */ + grid.treeView = {}; + + grid.registerRowsProcessor(service.adjustSorting, 60); + + /** + * @ngdoc object + * @name ui.grid.treeView.api:PublicApi + * + * @description Public Api for treeView feature + */ + var publicApi = { + events: { + treeView: { + } + }, + methods: { + treeView: { + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + + grid.api.registerMethodsFromObject(publicApi.methods); + + }, + + defaultGridOptions: function (gridOptions) { + //default option to true unless it was explicitly set to false + /** + * @ngdoc object + * @name ui.grid.treeView.api:GridOptions + * + * @description GridOptions for treeView feature, these are available to be + * set using the ui-grid {@link ui.grid.class:GridOptions gridOptions} + * + * Many tree options are set on treeBase, make sure to look at that feature in + * conjunction with these options. + */ + + /** + * @ngdoc object + * @name enableTreeView + * @propertyOf ui.grid.treeView.api:GridOptions + * @description Enable row tree view for entire grid. + *
    Defaults to true + */ + gridOptions.enableTreeView = gridOptions.enableTreeView !== false; + + }, + + + /** + * @ngdoc function + * @name adjustSorting + * @methodOf ui.grid.treeBase.service:uiGridTreeBaseService + * @description Trees cannot be sorted the same as flat lists of rows - + * trees are sorted recursively within each level - so the children of each + * node are sorted, but not the full set of rows. + * + * To achieve this, we suppress the normal sorting by setting ignoreSort on + * each of the sort columns. When the treeBase rowsProcessor runs it will then + * unignore these, and will perform a recursive sort against the tree that it builds. + * + * @param {array} renderableRows the rows that we need to pass on through + * @returns {array} renderableRows that we passed on through + */ + adjustSorting: function( renderableRows ) { + var grid = this; + + grid.columns.forEach( function( column ){ + if ( column.sort ){ + column.sort.ignoreSort = true; + } + }); + + return renderableRows; + } + + }; + + return service; + + }]); + + /** + * @ngdoc directive + * @name ui.grid.treeView.directive:uiGridTreeView + * @element div + * @restrict A + * + * @description Adds treeView features to grid + * + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.treeView']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + + $scope.columnDefs = [ + {name: 'name', enableCellEdit: true}, + {name: 'title', enableCellEdit: true} + ]; + + $scope.gridOptions = { columnDefs: $scope.columnDefs, data: $scope.data }; + }]); + + +
    +
    +
    +
    +
    + */ + module.directive('uiGridTreeView', ['uiGridTreeViewConstants', 'uiGridTreeViewService', '$templateCache', + function (uiGridTreeViewConstants, uiGridTreeViewService, $templateCache) { + return { + replace: true, + priority: 0, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + if (uiGridCtrl.grid.options.enableTreeView !== false){ + uiGridTreeViewService.initializeGrid(uiGridCtrl.grid, $scope); + } + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + + } + }; + } + }; + }]); +})(); diff --git a/release/4.4.11/ui-grid.tree-view.min.js b/release/4.4.11/ui-grid.tree-view.min.js new file mode 100644 index 000000000..2b161a073 --- /dev/null +++ b/release/4.4.11/ui-grid.tree-view.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var e=angular.module("ui.grid.treeView",["ui.grid","ui.grid.treeBase"]);e.constant("uiGridTreeViewConstants",{featureName:"treeView",rowHeaderColName:"treeBaseRowHeaderCol",EXPANDED:"expanded",COLLAPSED:"collapsed",aggregation:{COUNT:"count",SUM:"sum",MAX:"max",MIN:"min",AVG:"avg"}}),e.service("uiGridTreeViewService",["$q","uiGridTreeViewConstants","uiGridTreeBaseConstants","uiGridTreeBaseService","gridUtil","GridRow","gridClassFactory","i18nService","uiGridConstants",function(e,i,r,n,t,o,a,s,u){var d={initializeGrid:function(e,i){n.initializeGrid(e,i),e.treeView={},e.registerRowsProcessor(d.adjustSorting,60);var r={treeView:{}},t={treeView:{}};e.api.registerEventsFromObject(r),e.api.registerMethodsFromObject(t)},defaultGridOptions:function(e){e.enableTreeView=!1!==e.enableTreeView},adjustSorting:function(e){return this.columns.forEach(function(e){e.sort&&(e.sort.ignoreSort=!0)}),e}};return d}]),e.directive("uiGridTreeView",["uiGridTreeViewConstants","uiGridTreeViewService","$templateCache",function(e,n,i){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,i,r,t){!1!==t.grid.options.enableTreeView&&n.initializeGrid(t.grid,e)},post:function(e,i,r,t){}}}}}])}(); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.ttf b/release/4.4.11/ui-grid.ttf new file mode 100644 index 0000000000000000000000000000000000000000..f33fd255081402cae6128a8d846cfcb0601ab365 GIT binary patch literal 10156 zcmd^FeQ;FQb-(w%kKKJM?Mi4rzyk54ha^C|l8}%@K;T7-v|zvyLf~Btco%6U1gn)I z34i3nlZI)Ust$HN9@ovMoj{Ulr!!CBB-E4Ew4!NZcVeean>6lZ(m&df-KLr8q@9Ms zs=ssJu7vn#(&W#sb>BVr+;h)8_jk`d_q>N0XN>vTN14JV6NiuVn9tNd1D!;P&i;Stq8C%tSI-42x{_yEfG8Ur#&eLGHx|CtGucN); z^!Ut^`v({Q9qk3Q)47SEO!HSaonkD!7wxw3%#)LRrtCM+{xI5RJ~N*E%*+0hXnzLw z{n_Ni^i1OO9skJK18LYCnViZ_{?qQJZ!p%l0rDSbw048FvRzE%GBbJR+tYVokUhY# zBKf2K+i9K~8_h5`xYWbZN4*>z&VY);RV@A-(=h)B1!iK;I5qz<+rkC7OjE$U$FF~+ zcbLWI``^nb1B++aF=c?g2r-(;`9UXkiLnR@=EW>d-z>O9MNk`(uQFf&tK685%?~Z` z_cDu%p!ye>L!p;6yIC_p9rtcnF#kcC(n;d+RA|5Fk2wW9#^xV&3igi8A9o6NkqT=r?mdlxorL629J;`)cKhV)(wTG+?mRnof#5=Y& zxGX#xtvcNml#f8Dt34P9?ci;lT^;RhomG_q-BnxH&{4Uyv#Yi(B;E-4uY`OFe}G>` z3HdHNjVr#;g_H4H@5WD_jEivmB;UT*7vfi>$d!O!HhiIw?@E9_cx$2OBv0=atEs{& zm)GTI>)E>41K3+-f_8p_alt2;5F;HO4ehG7+OfHo%!Q@3_qMN4Ca2{;yQfW#G50Wo ziN(dmGs-JUIsBuRHN`fr=bZU~t4PQQp|Uh=QUq7hFsWSZ3tNGzRhqV@iEnM@dLXom z^MGF0!gZ^zS?p44L^$9Ihs62k-+mr{ye6_e@cQtF`ky}?6WzHB7cbL z#fxveq(4*m)Vj^V*L!!JdF~4r^4ry(krxksX!vzFggga{KNa5-A7>j_O{}_ZO@&Kk zf+t`c6BDqLjRe*P0t8Wgz|YAF7d;xbKFAyC(b=}1chMt+ZW#4F|AC4~#l?$w9H^ig zRjKXwU%cp_3{@QP`!8Mc-!15GCIO}_-hw|q27jzU>xE)0Jc{)pZ~kYG`PvY_KekwyvojPT9mO=~1VzP^Rp{CSO;xop*vG?K@h~;wFooMYwsy9KT*3CX&=tOJ@bN*;-!?A+Uy1E{$A2#{9ySH~LemShum z3#MWSyS3)(aE0IFh8cRmr3IV9U5!|DkZ-l>TwD(Z+S|H#XJeRK9UKRw(K#w_ww-U^ z%O5M#)WUbwa!uteO3gx{bwN28II(adup@Ln;A%hL-klJ7nOgX36;Ix*eqf={@-F|> zy5Na-j|YS25ya*Bg#&f-pWx02#{$?p&J*-RoMR&$0ilJOXkzEgcD7Tf-C^ADuJzvV zhI|yt__uwa@wYYvjhr$Nv4ejb`YL0-B~8IL(o`SN8*A&DxpVBHDd4A|D9UaaHO39& z51}nkEf|6}~RD2kB+ugQ>tE6r4jbb=~*Ya$@^vL0BSBqq!%oifN$ke5^^4;Pi zu+8{7tuMfVxU)RENp|7Z3h~{vyif?k41SWQ8) zU@>QtXqWMQ)iKY~%2Tg~!(^#PP=wR#8WH=jr844)3x)6VO@?s-Mix$az5H{);e;Xn zpzwpj_a$lY&!gs_^LkGhH4Y|=*ThV5e$Ov8|Jqe@{^A~Xd1UbIYzrggiZhsYt@i|` z-dOm7oCK2@e5{ahtm2#aMn`}IOa7AN|BQTKO)TV>1_;7II!quOP_!^0h40Fh-X7pZ zQZL-pD%8SFU0;i6{LVk1u~z3_cWH(HMkvt0TdV8uyhGiz*2SOWjII{*z-BLzud1XZn=&)puM5b;!>o~Yu>^aB9gn3B?JH9ZvHN|(?b)(PAlq1jtX{><#&u2S z+Bh;ax69)`iKwgNQcE+#5J@i=qHHe$8%wH)gXL`Bk;4b~_r}AxMH&LuhCmrzBc%h? zxdWF89&MpuCE~4y*k>WBLF|(!O}R(A7#rmv>c>qaFUU9q2&&o>$_lh`Z zxC^axbMUv_2H1s9%SKiMT?Q}H ziE$fyC7%A3c&=3pbs0|&?gXwTkQwS+SNIA%6$eihc&aM!go7n$yCXoeds!jo{j z9f$kjTYraK721?Umhh(b?f8o?FT+y!+1=RkCnR_!1Xm!tjQN@+%pSZ8+P9Ya`2F$3 zx^Z=05-;J*Aq#cR9Fi1mE=1e>)R?MhY8qn5I7J#ZFg_@Eh{D5xh7SDKPFFd> zP4G4%qo5p}+!f(pw!_6X!AqW$8l2RY?xNyqyNauC zysb^Er8c2M{dBETo6so9|DEC2UeWO9H0Rt$mW&NNM7p};u5c&n36{$X<+LXXXutYv}<=Upxi2rTAI!(X>Q%Jq?%a4 zk_D|>R!m0&TepPon2djiUi$hpmrHw9S07b`)~y=iQ6bcwywH!QD$w$1vQ|V^6`#c` zf~9!W&vJBG%FVajiUsk{VVF~kzf@hi_H|9ywVN%Z_-jOphh0h?GK6J8aqF9kaI^?R zm1=eVmMWYn4QFblFzZsJIjTn-M~v!zmQ?nUN@W1k6z6K;I$7Y%pm~IasjQM(X|4W6 zzO)c@>~!h+PUu`-^1tX%>*$7uVFroI@9Rr|kOg>Sdz40(V9`Iwm%*U>zl zBor1 z(zO6RvJ_{@F`E_mUVcru#WC?CMOPxqpz^r#HRV6mh?>^inyoG959|Nty5PYVLuut| z_6~im!%yH{b1Rz$b=5m5IrvDcGe zr0EOq@gi-oCN@;0z4*R&0arIy@qLk@3(gO6FBCUXKEYd3Ijv}qG5RVsW z9sE?0HrP=B`O`9=u zWFkM4&E+PVhbG3)jYUVN#)b#7qvvv&sbZ^G9nDTnk4@ywEzPY(P9mGnPGx4Y!=!oo z@zJ)KnGthjYGT~%E9x{SrzXy1hh~~j&&*72Z)v%GE@=HUCff+^ zCe&^CaK43gf;t5W6OxY97|XK^%Yl<&=P=^5?3qS8hBAUy9^5P>a-f?5{{+JRIm{5n z9He8I4WNG%yc~2)-O;yF@+c&y;4))UuL+CjgZ@gH1Z473E+c0ih8>R0)9i7~(+2Jg zEFw+fDI8a$=tc===2B9Wu~&j<>O=d<(593 z%}foQ)`v3rp=_>fEI%?49U7Y&%4LUD{Oi$K4?Ut2li9qEGBlQR4^KRij}DJb>E|Y? za_6!mGemf#Yf4J8XpG_TB$>&N=CV;5t&fc5X0lV>>4~YCXeKukJvUjtM3aD+IIE6l z^XI%{`QdDSCQABXnxv&hZF+Jn@0@P>N`mk5cl=f}`5(nNDmIIlHan8+O_}EYtIT(3 zzpWoWmbAB4+Z$8q5p(uP(iZiZKc;^G8XB@rRoB+qEM>E}wdXQUdpz9}wRyxg(<4z^ zM9g8+zSeK64aY8TrZA=si>_)%wE%0 z>oYJ&i}xpO&FZmrs|V(%Y@UwVYQ%zF=J1?$s>h@rXL5R?zjw%1HrIk5H)qXR=$>oU z>anat$#j2pW+0WcQs|8xPNJ)t7FC=%YHJbO6>qu>SC!D{Xj(lMAhvokwm3Cn^C9TB zwaro66*0+3Z+z&g%1%K9X2#Mf5=rloM!F-HU0xRN?b%$r1hyx#5`4qa!kb`194k(n zy|Y$^HbNrBstHZotcH;#D{ZCT%ItBb@ZM)QeQmNacxh?34=N*{v3f3h4W&0(TW!^* zHrGb&^2nSJz4mZsPt^8BumIDv%i<5wx8By^eda1Q^*WdY*2&30WzW-Ps-D#GTN=p9VjeyhjqwY_jk0~4ov%rvI|YDEQZ zNY>Lco1R;xH`!B7)pdX=fVEXMMeSf@j#C{1&QymZa|+d~BXcU%Ya(+R)el7GbgHW( zb1tgaM&{g9uZzrisIG}HyS(XFFl0Rpseu9$hEQD#L#VEUAyiv1gz612gz9=2LUjWS zp}G-rP4;FSmk2yH0hhYxd9gCv zEQ(eCs|5TdYDbs$fQRhJW}63FCCbgWqq4HAC1Q3+J6j>cd+$E3hywRCi});r|9=6$ zJ-e)Jb1giGm2APfVdy=Fq~W!hZBe@|(j4xN+U>tc6dpDN@vYbj7OFR!%>A!XWW zI?S;{$t%KC%<3zmL3tq6Ljlf>P>K04qt%C_gGB62I*Xqk`tF|yhAJ&CR&H{b+m;{DUBvf&_fxQMtLfpQ?5@^g|aJ@7F zPh2Au!j|WPmvj*ZCT7qC*tjO_-o9|R}jK;$x)oP!`F=V6lRLD&09hKPQWA>t6p z5HUb9yFeT!86pNrhKM61L&Q;%iGg^8WQa(T3=t`kA>tUx#6dhtGDI9F86r-Q3=tibSU(S3IgHWkx+swmWMp z8~UH5t0u~jWPfV_2?)P{pzNg8lXFb#!Rpy&BCZ&MyB!MuvPqQQ^P0GZZVzZz&uc8^ z&Y&ym-exF@)3!B1n!?SIPu0+kBNT{-&*d5*NiD G#{LJK{N5!1 literal 0 HcmV?d00001 diff --git a/release/4.4.11/ui-grid.validate.js b/release/4.4.11/ui-grid.validate.js new file mode 100644 index 000000000..b1fde4fef --- /dev/null +++ b/release/4.4.11/ui-grid.validate.js @@ -0,0 +1,589 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + +(function () { + 'use strict'; + + /** + * @ngdoc overview + * @name ui.grid.validate + * @description + * + * # ui.grid.validate + * + * + * + * This module provides the ability to validate cells upon change. + * + * Design information: + * ------------------- + * + * Validation is not based on angularjs validation, since it would work only when editing the field. + * + * Instead it adds custom properties to any field considered as invalid. + * + *
    + *
    + * + *
    + */ + + var module = angular.module('ui.grid.validate', ['ui.grid']); + + + /** + * @ngdoc service + * @name ui.grid.validate.service:uiGridValidateService + * + * @description Services for validation features + */ + module.service('uiGridValidateService', ['$sce', '$q', '$http', 'i18nService', 'uiGridConstants', function ($sce, $q, $http, i18nService, uiGridConstants) { + + var service = { + + /** + * @ngdoc object + * @name validatorFactories + * @propertyOf ui.grid.validate.service:uiGridValidateService + * @description object containing all the factories used to validate data.
    + * These factories will be in the form
    + * ``` + * { + * validatorFactory: function(argument) { + * return function(newValue, oldValue, rowEntity, colDef) { + * return true || false || promise + * } + * }, + * messageFunction: function(argument) { + * return string + * } + * } + * ``` + * + * Promises should return true or false as result according to the result of validation. + */ + validatorFactories: {}, + + + /** + * @ngdoc service + * @name setExternalFactoryFunction + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Adds a way to retrieve validators from an external service + *

    Validators from this external service have a higher priority than default + * ones + * @param {function} externalFactoryFunction a function that accepts name and argument to pass to a + * validator factory and that returns an object with the same properties as + * you can see in {@link ui.grid.validate.service:uiGridValidateService#properties_validatorFactories validatorFactories} + */ + setExternalFactoryFunction: function(externalFactoryFunction) { + service.externalFactoryFunction = externalFactoryFunction; + }, + + /** + * @ngdoc service + * @name clearExternalFactory + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Removes any link to external factory from this service + */ + clearExternalFactory: function() { + delete service.externalFactoryFunction; + }, + + /** + * @ngdoc service + * @name getValidatorFromExternalFactory + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Retrieves a validator by executing a validatorFactory + * stored in an external service. + * @param {string} name the name of the validator to retrieve + * @param {object} argument an argument to pass to the validator factory + */ + getValidatorFromExternalFactory: function(name, argument) { + return service.externalFactoryFunction(name, argument).validatorFactory(argument); + }, + + /** + * @ngdoc service + * @name getMessageFromExternalFactory + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Retrieves a message stored in an external service. + * @param {string} name the name of the validator + * @param {object} argument an argument to pass to the message function + */ + getMessageFromExternalFactory: function(name, argument) { + return service.externalFactoryFunction(name, argument).messageFunction(argument); + }, + + /** + * @ngdoc service + * @name setValidator + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Adds a new validator to the service + * @param {string} name the name of the validator, must be unique + * @param {function} validatorFactory a factory that return a validatorFunction + * @param {function} messageFunction a function that return the error message + */ + setValidator: function(name, validatorFactory, messageFunction) { + service.validatorFactories[name] = { + validatorFactory: validatorFactory, + messageFunction: messageFunction + }; + }, + + /** + * @ngdoc service + * @name getValidator + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Returns a validator registered to the service + * or retrieved from the external factory + * @param {string} name the name of the validator to retrieve + * @param {object} argument an argument to pass to the validator factory + * @returns {object} the validator function + */ + getValidator: function(name, argument) { + if (service.externalFactoryFunction) { + var validator = service.getValidatorFromExternalFactory(name, argument); + if (validator) { + return validator; + } + } + if (!service.validatorFactories[name]) { + throw ("Invalid validator name: " + name); + } + return service.validatorFactories[name].validatorFactory(argument); + }, + + /** + * @ngdoc service + * @name getMessage + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Returns the error message related to the validator + * @param {string} name the name of the validator + * @param {object} argument an argument to pass to the message function + * @returns {string} the error message related to the validator + */ + getMessage: function(name, argument) { + if (service.externalFactoryFunction) { + var message = service.getMessageFromExternalFactory(name, argument); + if (message) { + return message; + } + } + return service.validatorFactories[name].messageFunction(argument); + }, + + /** + * @ngdoc service + * @name isInvalid + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Returns true if the cell (identified by rowEntity, colDef) is invalid + * @param {object} rowEntity the row entity of the cell + * @param {object} colDef the colDef of the cell + * @returns {boolean} true if the cell is invalid + */ + isInvalid: function (rowEntity, colDef) { + return rowEntity['$$invalid'+colDef.name]; + }, + + /** + * @ngdoc service + * @name setInvalid + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Makes the cell invalid by adding the proper field to the entity + * @param {object} rowEntity the row entity of the cell + * @param {object} colDef the colDef of the cell + */ + setInvalid: function (rowEntity, colDef) { + rowEntity['$$invalid'+colDef.name] = true; + }, + + /** + * @ngdoc service + * @name setValid + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Makes the cell valid by removing the proper error field from the entity + * @param {object} rowEntity the row entity of the cell + * @param {object} colDef the colDef of the cell + */ + setValid: function (rowEntity, colDef) { + delete rowEntity['$$invalid'+colDef.name]; + }, + + /** + * @ngdoc service + * @name setError + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Adds the proper error to the entity errors field + * @param {object} rowEntity the row entity of the cell + * @param {object} colDef the colDef of the cell + * @param {string} validatorName the name of the validator that is failing + */ + setError: function(rowEntity, colDef, validatorName) { + if (!rowEntity['$$errors'+colDef.name]) { + rowEntity['$$errors'+colDef.name] = {}; + } + rowEntity['$$errors'+colDef.name][validatorName] = true; + }, + + /** + * @ngdoc service + * @name clearError + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Removes the proper error from the entity errors field + * @param {object} rowEntity the row entity of the cell + * @param {object} colDef the colDef of the cell + * @param {string} validatorName the name of the validator that is failing + */ + clearError: function(rowEntity, colDef, validatorName) { + if (!rowEntity['$$errors'+colDef.name]) { + return; + } + if (validatorName in rowEntity['$$errors'+colDef.name]) { + delete rowEntity['$$errors'+colDef.name][validatorName]; + } + }, + + /** + * @ngdoc function + * @name getErrorMessages + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description returns an array of i18n-ed error messages. + * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for + * @param {object} colDef the column whose errors we are looking for + * @returns {array} An array of strings containing all the error messages for the cell + */ + getErrorMessages: function(rowEntity, colDef) { + var errors = []; + + if (!rowEntity['$$errors'+colDef.name] || Object.keys(rowEntity['$$errors'+colDef.name]).length === 0) { + return errors; + } + + Object.keys(rowEntity['$$errors'+colDef.name]).sort().forEach(function(validatorName) { + errors.push(service.getMessage(validatorName, colDef.validators[validatorName])); + }); + + return errors; + }, + + /** + * @ngdoc function + * @name getFormattedErrors + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description returns the error i18n-ed and formatted in html to be shown inside the page. + * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for + * @param {object} colDef the column whose errors we are looking for + * @returns {object} An object that can be used in a template (like a cellTemplate) to display the + * message inside the page (i.e. inside a div) + */ + getFormattedErrors: function(rowEntity, colDef) { + + var msgString = ""; + + var errors = service.getErrorMessages(rowEntity, colDef); + + if (!errors.length) { + return; + } + + errors.forEach(function(errorMsg) { + msgString += errorMsg + "
    "; + }); + + return $sce.trustAsHtml('

    ' + i18nService.getSafeText('validate.error') + '

    ' + msgString ); + }, + + /** + * @ngdoc function + * @name getTitleFormattedErrors + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description returns the error i18n-ed and formatted in javaScript to be shown inside an html + * title attribute. + * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for + * @param {object} colDef the column whose errors we are looking for + * @returns {object} An object that can be used in a template (like a cellTemplate) to display the + * message inside an html title attribute + */ + getTitleFormattedErrors: function(rowEntity, colDef) { + + var newLine = "\n"; + + var msgString = ""; + + var errors = service.getErrorMessages(rowEntity, colDef); + + if (!errors.length) { + return; + } + + errors.forEach(function(errorMsg) { + msgString += errorMsg + newLine; + }); + + return $sce.trustAsHtml(i18nService.getSafeText('validate.error') + newLine + msgString); + }, + + /** + * @ngdoc function + * @name getTitleFormattedErrors + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description Executes all validators on a cell (identified by row entity and column definition) and sets or clears errors + * @param {object} rowEntity the row entity of the cell we want to run the validators on + * @param {object} colDef the column definition of the cell we want to run the validators on + * @param {object} newValue the value the user just entered + * @param {object} oldValue the value the field had before + */ + runValidators: function(rowEntity, colDef, newValue, oldValue, grid) { + + if (newValue === oldValue) { + // If the value has not changed we perform no validation + return; + } + + if (typeof(colDef.name) === 'undefined' || !colDef.name) { + throw new Error('colDef.name is required to perform validation'); + } + + service.setValid(rowEntity, colDef); + + var validateClosureFactory = function(rowEntity, colDef, validatorName) { + return function(value) { + if (!value) { + service.setInvalid(rowEntity, colDef); + service.setError(rowEntity, colDef, validatorName); + if (grid) { + grid.api.validate.raise.validationFailed(rowEntity, colDef, newValue, oldValue); + } + } + }; + }; + + var promises = []; + + for (var validatorName in colDef.validators) { + service.clearError(rowEntity, colDef, validatorName); + var msg; + var validatorFunction = service.getValidator(validatorName, colDef.validators[validatorName]); + // We pass the arguments as oldValue, newValue so they are in the same order + // as ng-model validators (modelValue, viewValue) + var promise = $q + .when(validatorFunction(oldValue, newValue, rowEntity, colDef)) + .then(validateClosureFactory(rowEntity, colDef, validatorName)); + promises.push(promise); + } + + return $q.all(promises); + }, + + /** + * @ngdoc function + * @name createDefaultValidators + * @methodOf ui.grid.validate.service:uiGridValidateService + * @description adds the basic validators to the list of service validators + */ + createDefaultValidators: function() { + service.setValidator('minLength', + function (argument) { + return function (oldValue, newValue, rowEntity, colDef) { + if (newValue === undefined || newValue === null || newValue === '') { + return true; + } + return newValue.length >= argument; + }; + }, + function(argument) { + return i18nService.getSafeText('validate.minLength').replace('THRESHOLD', argument); + }); + + service.setValidator('maxLength', + function (argument) { + return function (oldValue, newValue, rowEntity, colDef) { + if (newValue === undefined || newValue === null || newValue === '') { + return true; + } + return newValue.length <= argument; + }; + }, + function(threshold) { + return i18nService.getSafeText('validate.maxLength').replace('THRESHOLD', threshold); + }); + + service.setValidator('required', + function (argument) { + return function (oldValue, newValue, rowEntity, colDef) { + if (argument) { + return !(newValue === undefined || newValue === null || newValue === ''); + } + return true; + }; + }, + function(argument) { + return i18nService.getSafeText('validate.required'); + }); + }, + + initializeGrid: function (scope, grid) { + grid.validate = { + + isInvalid: service.isInvalid, + + getFormattedErrors: service.getFormattedErrors, + + getTitleFormattedErrors: service.getTitleFormattedErrors, + + runValidators: service.runValidators + }; + + /** + * @ngdoc object + * @name ui.grid.validate.api:PublicApi + * + * @description Public Api for validation feature + */ + var publicApi = { + events: { + validate: { + /** + * @ngdoc event + * @name validationFailed + * @eventOf ui.grid.validate.api:PublicApi + * @description raised when one or more failure happened during validation + *
    +               *      gridApi.validate.on.validationFailed(scope, function(rowEntity, colDef, newValue, oldValue){...})
    +               * 
    + * @param {object} rowEntity the options.data element whose validation failed + * @param {object} colDef the column whose validation failed + * @param {object} newValue new value + * @param {object} oldValue old value + */ + validationFailed: function (rowEntity, colDef, newValue, oldValue) { + } + } + }, + methods: { + validate: { + /** + * @ngdoc function + * @name isInvalid + * @methodOf ui.grid.validate.api:PublicApi + * @description checks if a cell (identified by rowEntity, colDef) is invalid + * @param {object} rowEntity gridOptions.data[] array instance we want to check + * @param {object} colDef the column whose errors we want to check + * @returns {boolean} true if the cell value is not valid + */ + isInvalid: function(rowEntity, colDef) { + return grid.validate.isInvalid(rowEntity, colDef); + }, + /** + * @ngdoc function + * @name getErrorMessages + * @methodOf ui.grid.validate.api:PublicApi + * @description returns an array of i18n-ed error messages. + * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for + * @param {object} colDef the column whose errors we are looking for + * @returns {array} An array of strings containing all the error messages for the cell + */ + getErrorMessages: function (rowEntity, colDef) { + return grid.validate.getErrorMessages(rowEntity, colDef); + }, + /** + * @ngdoc function + * @name getFormattedErrors + * @methodOf ui.grid.validate.api:PublicApi + * @description returns the error i18n-ed and formatted in html to be shown inside the page. + * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for + * @param {object} colDef the column whose errors we are looking for + * @returns {object} An object that can be used in a template (like a cellTemplate) to display the + * message inside the page (i.e. inside a div) + */ + getFormattedErrors: function (rowEntity, colDef) { + return grid.validate.getFormattedErrors(rowEntity, colDef); + }, + /** + * @ngdoc function + * @name getTitleFormattedErrors + * @methodOf ui.grid.validate.api:PublicApi + * @description returns the error i18n-ed and formatted in javaScript to be shown inside an html + * title attribute. + * @param {object} rowEntity gridOptions.data[] array instance whose errors we are looking for + * @param {object} colDef the column whose errors we are looking for + * @returns {object} An object that can be used in a template (like a cellTemplate) to display the + * message inside an html title attribute + */ + getTitleFormattedErrors: function (rowEntity, colDef) { + return grid.validate.getTitleFormattedErrors(rowEntity, colDef); + } + } + } + }; + + grid.api.registerEventsFromObject(publicApi.events); + grid.api.registerMethodsFromObject(publicApi.methods); + + if (grid.edit) { + grid.api.edit.on.afterCellEdit(scope, function(rowEntity, colDef, newValue, oldValue) { + grid.validate.runValidators(rowEntity, colDef, newValue, oldValue, grid); + }); + } + + service.createDefaultValidators(); + } + + }; + + return service; + }]); + + + /** + * @ngdoc directive + * @name ui.grid.validate.directive:uiGridValidate + * @element div + * @restrict A + * @description Adds validating features to the ui-grid directive. + * @example + + + var app = angular.module('app', ['ui.grid', 'ui.grid.edit', 'ui.grid.validate']); + + app.controller('MainCtrl', ['$scope', function ($scope) { + $scope.data = [ + { name: 'Bob', title: 'CEO' }, + { name: 'Frank', title: 'Lowly Developer' } + ]; + + $scope.columnDefs = [ + {name: 'name', enableCellEdit: true, validators: {minLength: 3, maxLength: 9}, cellTemplate: 'ui-grid/cellTitleValidator'}, + {name: 'title', enableCellEdit: true, validators: {required: true}, cellTemplate: 'ui-grid/cellTitleValidator'} + ]; + }]); + + +
    +
    +
    +
    +
    + */ + + module.directive('uiGridValidate', ['gridUtil', 'uiGridValidateService', function (gridUtil, uiGridValidateService) { + return { + priority: 0, + replace: true, + require: '^uiGrid', + scope: false, + compile: function () { + return { + pre: function ($scope, $elm, $attrs, uiGridCtrl) { + uiGridValidateService.initializeGrid($scope, uiGridCtrl.grid); + }, + post: function ($scope, $elm, $attrs, uiGridCtrl) { + } + }; + } + }; + }]); +})(); diff --git a/release/4.4.11/ui-grid.validate.min.js b/release/4.4.11/ui-grid.validate.min.js new file mode 100644 index 000000000..3f9e6c2ea --- /dev/null +++ b/release/4.4.11/ui-grid.validate.min.js @@ -0,0 +1,7 @@ +/*! + * ui-grid - v4.4.11 - 2018-05-16 + * Copyright (c) 2018 ; License: MIT + */ + + +!function(){"use strict";var r=angular.module("ui.grid.validate",["ui.grid"]);r.service("uiGridValidateService",["$sce","$q","$http","i18nService","uiGridConstants",function(n,c,r,i,t){var d={validatorFactories:{},setExternalFactoryFunction:function(r){d.externalFactoryFunction=r},clearExternalFactory:function(){delete d.externalFactoryFunction},getValidatorFromExternalFactory:function(r,t){return d.externalFactoryFunction(r,t).validatorFactory(t)},getMessageFromExternalFactory:function(r,t){return d.externalFactoryFunction(r,t).messageFunction(t)},setValidator:function(r,t,e){d.validatorFactories[r]={validatorFactory:t,messageFunction:e}},getValidator:function(r,t){if(d.externalFactoryFunction){var e=d.getValidatorFromExternalFactory(r,t);if(e)return e}if(!d.validatorFactories[r])throw"Invalid validator name: "+r;return d.validatorFactories[r].validatorFactory(t)},getMessage:function(r,t){if(d.externalFactoryFunction){var e=d.getMessageFromExternalFactory(r,t);if(e)return e}return d.validatorFactories[r].messageFunction(t)},isInvalid:function(r,t){return r["$$invalid"+t.name]},setInvalid:function(r,t){r["$$invalid"+t.name]=!0},setValid:function(r,t){delete r["$$invalid"+t.name]},setError:function(r,t,e){r["$$errors"+t.name]||(r["$$errors"+t.name]={}),r["$$errors"+t.name][e]=!0},clearError:function(r,t,e){r["$$errors"+t.name]&&e in r["$$errors"+t.name]&&delete r["$$errors"+t.name][e]},getErrorMessages:function(r,t){var e=[];return r["$$errors"+t.name]&&0!==Object.keys(r["$$errors"+t.name]).length&&Object.keys(r["$$errors"+t.name]).sort().forEach(function(r){e.push(d.getMessage(r,t.validators[r]))}),e},getFormattedErrors:function(r,t){var e="",a=d.getErrorMessages(r,t);if(a.length)return a.forEach(function(r){e+=r+"
    "}),n.trustAsHtml("

    "+i.getSafeText("validate.error")+"

    "+e)},getTitleFormattedErrors:function(r,t){var e="",a=d.getErrorMessages(r,t);if(a.length)return a.forEach(function(r){e+=r+"\n"}),n.trustAsHtml(i.getSafeText("validate.error")+"\n"+e)},runValidators:function(r,t,n,i,o){if(n!==i){if(void 0===t.name||!t.name)throw new Error("colDef.name is required to perform validation");d.setValid(r,t);var e=function(t,e,a){return function(r){r||(d.setInvalid(t,e),d.setError(t,e,a),o&&o.api.validate.raise.validationFailed(t,e,n,i))}},a=[];for(var l in t.validators){d.clearError(r,t,l);var u=d.getValidator(l,t.validators[l]),s=c.when(u(i,n,r,t)).then(e(r,t,l));a.push(s)}return c.all(a)}},createDefaultValidators:function(){d.setValidator("minLength",function(n){return function(r,t,e,a){return null==t||""===t||t.length>=n}},function(r){return i.getSafeText("validate.minLength").replace("THRESHOLD",r)}),d.setValidator("maxLength",function(n){return function(r,t,e,a){return null==t||""===t||t.length<=n}},function(r){return i.getSafeText("validate.maxLength").replace("THRESHOLD",r)}),d.setValidator("required",function(n){return function(r,t,e,a){return!n||!(null==t||""===t)}},function(r){return i.getSafeText("validate.required")})},initializeGrid:function(r,n){n.validate={isInvalid:d.isInvalid,getFormattedErrors:d.getFormattedErrors,getTitleFormattedErrors:d.getTitleFormattedErrors,runValidators:d.runValidators};var t={events:{validate:{validationFailed:function(r,t,e,a){}}},methods:{validate:{isInvalid:function(r,t){return n.validate.isInvalid(r,t)},getErrorMessages:function(r,t){return n.validate.getErrorMessages(r,t)},getFormattedErrors:function(r,t){return n.validate.getFormattedErrors(r,t)},getTitleFormattedErrors:function(r,t){return n.validate.getTitleFormattedErrors(r,t)}}}};n.api.registerEventsFromObject(t.events),n.api.registerMethodsFromObject(t.methods),n.edit&&n.api.edit.on.afterCellEdit(r,function(r,t,e,a){n.validate.runValidators(r,t,e,a,n)}),d.createDefaultValidators()}};return d}]),r.directive("uiGridValidate",["gridUtil","uiGridValidateService",function(r,n){return{priority:0,replace:!0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(r,t,e,a){n.initializeGrid(r,a.grid)},post:function(r,t,e,a){}}}}}])}(); \ No newline at end of file diff --git a/release/4.4.11/ui-grid.woff b/release/4.4.11/ui-grid.woff new file mode 100644 index 0000000000000000000000000000000000000000..426c611501c28990525a6bd9b9beaad51eaf42a6 GIT binary patch literal 5728 zcmY*dWmuF^w;dQ58c}LUL0XBSI|h(W2?>Q6I)-jUx};IML_iuOC6pMD?nXemrMu@F z@BQwNd!A=K?_TTdefHVsd4DZ0O$7x21^~S%V1P&ezHH_H%m2mye<|wd$pQcv2540r z4PAy979UL=9zL{|gywQ+=uzs<8 z1y`J1Ezz~)>uAjvjqnZVi=WuPO9PQvVfA4ErX&a!(P!*`{H@(7Ln6O4*YO54 zSb}v`z%IKY(11)JGF_kSD^}__b0h`j`p_iB1#-V=+gN1AJFzrPJd zWlZac-W#8Lc*%KuDI2{&iRpSZ<4t{blshl|v3#$13M1W?n#J?Q{T@OucV1BhGv5}S zY@1N6dU-~@N6HmEl-B_3*_NCYG6KC*e2T<#P6@7UmvMd$R&kcfs**twD2~gv{Cgi6 z;1iNw+B0c_P>d%C;2-q775cVb6AEN>KFV34oGb)fcJN=nY^xMl5y(J1XpK3;+pLP@ z+-NfKoz~+IOUtIG7ISXf!v02wG(5}+bz9CEpYpx7hNcGREuR>DoF(|1n3T!WH95^1 zyC;FS6Rtj>?Z+MsL~>hbzQ%W;P*B5C`8Qy`zz**6)2fc($tf!^(Z{Tew?9%lm4Q|8=ZHN<+J%& z`c^b8li}<~#i?WJ8 z$xr|`yx?mYje(W;g^|3F{xbN$XvmeNdHqo_->4>$6#CavV^38oXnHM@!(|9;IQnM{ z@A2gQM}ESKG%5PK<3)}X0#ZzG+5ulhmMmOS4!E0u@*Kn!#$p-$yyUzxO=QEv=$CPa z|Nh)q>afk4mY11?@gq88QSH8Cn^#5YYT0wjL-`y;c}ec9-h`?iutwN_U`4YK=I+H?hobHLo2WC=e!)8FU2m7Zlir-Jm z9~EHS(u~q;PI2I=g{A35>dTl_*c+zwO_fuW^iF!oW$3q-Phds4(o*)c#<<*@^7E&p zJ!xI~Fj33IE$OzeiaSB;m+2vyF;mjzis54Aqfum-a`;!E=LDF&X_zy!gR5#>l+P(W zX&bbmC`M=Q10~3CUqU8CL)I~g6Cj~qfpP{W!Hk^bgzzR@IRgqf?f?t8j%dPj5NxGF zCEo7psUv!l%@3x!x&{PiG)iFx?EN(eXX|I7@nYHGcDc!NgNQ+iy1yO+8J|1vg?VKu zwC=Bj$*2hyLNpAO4fmJJr)K7B7Q{nbMMyc7d4*4J^sk;V)sFio8usVJ`_VgN$EaA& z+5s!bfBt6UeU!e)Jc8w7tSzK8H#>~=fr$1r(C0K8ixs|GO0=%A5>9l54R=KPu)WFi z&F73bc)54VUT|kzv?_m5Y!lO7`ZS^FL3Us9%i>c3Y{UUmfJYCtqGC~HH?w{@FZ9C3T$qLu5b2e9lz)r1g(3D8O@_^&g;96lDx+dWTw_0xUlGW~x1fo3 zhjH2b5BVxaJ8NLqGU=cCm`xo({&kF~RQuK-eAI$CgliKrYc)*WPV5HW75Md-AGZw90(i0yPp`hM z?@+y5ppK@&Lg%WMj%Dvd9A)@@3v}=S$x!%EymOIoL&`&VZXJ?#6Ae|n*PF;@JQp?r z?;e79&mW;hwKnj8C8#aNFBKmr=`BKP>+r+nqxmkGCIAKi1BC)S^3MAD+8#kWMc%sA zYUSzK^0(gF8c{WK5!XTkxvDqGH0$}z%tAw&Sy;m1`5{)7bfTMQPPQcXC`2h&Dk&G2 z5kFX{g6LJ5ia;T@UNO``UiDStXrAmB>6P!mARq{J{i&*?j5_sZUm3_cTEIB$hl|A6;uGj5gD^M`rGd?P7yF|tyQmm)j^V^#RNulqV%|CjUZ(6i*D9%!_#S6oV^Ea!^EnQ~7 zF^2_uyRx{3moF4{l^h=MJ8&~uw%a)|@M}ZIKfK}2-pG62zMv&P=j`L>FP|Cqh&!4C z;6?=wt*or1hqD<{@hSsthn>oR4BG3-6u62aSusqk3PG_<1$=XdzMht0BvV79zcI%> zZvcpNJM5jWMmA41U(E=;iJ+HsS;2Z>@EJP4*pa*3mpWX?Q$IQyp|--@mo#3}$~lbK)UN zk(n9&XQ#OD&Tnr#wwj_osA`JbVMo$5!5ak-n*ci*RUIPyNeD#q-`d%=(_n_-rv z?UKLVQ`>vE+z zba%%S$B%N^R>It`j^Q4Vurx|ZA1HC@tHMtaEh!XfU-{Njb9GDQbEx|CZZ`^_ zG=63w$CLdkm2i3B14!=hcU` zmmzjbIa61oHv2(XwAio7LIgvQyH;-5Z|UL^dp$)6w8YP183PH$0o3jr?jQKUUl);&d zm@H$(g6tr~siClSJqO4zc)-JWc*^kQ04i7D)dW&Sh5P z5pL|$8JzvbaFJwp;UHb8`eYLlOjS?@1_+gOZ@*`cr!Fq`$OBnb+9@1Y0YMO+y?2#n zC}$}-EOPHns%)+e36)g^p9W2uU6@UwN^~nLp>h|)$TsN*q*v9_{TWSmK@Pyf1J#^$hdpSA4#MW21>b%<Zvts)8%$TQxwEn|bG!E&9e2wEfGr)PrJ7$%IpRs&0 z(AdZfwRObvEGu^U1$XP$`d@44?K$3%n&9J<5SqlU(gp|;+l5Z)P0j$n<+XZCH5YP> zeGw4+%{P%?7qmQ^U&z2Q-up4RE~Wf)DOMUGkD*O&DA7Ug(lg6ch06<_!-?Xxbzc`j+e#utsNS^(q^?LT4D&9Zs4VE;X!BVM!SaUZE(CHgo5jaDvg>6iReECX?bM-{ zA{fPRKi>)WruG5XZ)@H)+zFpg20vXU&moRbtYGH&-BxBJeOA3Uqib{9GQBG>um@{?-ep_@N#@Ed^j5%Y^Z;a3CpMQ=l zE&t94s2tb^I1|QT099$kQlsUJy4a(`Rv+HQ!GD#nrJzh+T9Qlt9sexaxV>~>#OWtN z8wS?x{-%A9%T@j@dJo{D9Pa)Jvnh;rFy8OGbO&eism>%}z3EF{pq|b%5q+Tq+2Ax* zMl)(gH^SP=UwJ|roYBM)LF2t9Y6y!orq`AQsLc_ggCFpQXgy|!cd?%G$%*4ZySqrU zV7Z7-k>+`%X}3Q?*|%rP=BbI%P1@207UjbBd=ea*j1dHdhC(IL_z&B;mNyQiuI<=w zWLA{9Xs0_qa?AVrzEO9vN$loeq>#l^nC!=|meMKJrV#l%@v8t1m3K5;9JEI8e-<2E z{p%NA#R}koS+hg=W`D5}T&?%AZS}H&W+8t%*lKnPCA*4dJ31AQ=j$v@EuXP-viQGf zI8y)owx|oW{K|19N1f2o%rpCRSJ2h-jqLt)d}ooA8zM(4&YJkg=<*=^Q`p8vTh2i)u}_CQU2yb2bMqA!w&6X%DS($ z+h+#Sm)9DJ#5GEdG%@9Fh&YOYJG2iYrLPus3xq!r_`=95)ARNmaSsK3esP=no2EKa z#KSqRY<9Gun&-G1H1k_F(E3yC^T4>5d)cTiZZjuc1-rg_3vnvuhV=;icb*Xb$v<=(H|+& zAphl(+vWDz_T;ZGy2AsE2R6;J^~!&j1WSc47X+wXb{SUO;Xlh7DNDfe)nRt_nr0C* zI28#K_73}YdKH#ac_uoVr8x6*A&T=2Hf`=0Pft`dE7DI@GUn%Ibj!ZV<3WvYS>1M# z-#xve9lh1xpY1;mXUs{x(^q)O)39BUbh5vE*psM}Br9u5B{{gGbM;}lnj`?Fed?Ckz7vCV%HeV=a>{zn41R%E9h3P1| z5L*!m`A4gd|4LTs9%w)RjUk{@7iM~;;sS$)7UR%N+SQ%(RBc9%J1Uj9SN^zr#Bo99 zK_F>o(#kV~tBrdU?Ld?{&UzT;!Ivbdypa)s-{V1@gLJuigta#qRJz5>rv z*RCB}`JDON08x-Ped)%ad=%>LbJyKRQQY1Q7!30RCLkc1nEwB2h;Ke)Gn?L_u2F2K zs-Rq4e6;yg--46-Z{Hu;-cF0xMeu;KrogI3p)Bn%j~Q3hrWx)~(&o>BKwSRpV6y~j zBuY9RYSj+u&7zcXYflTp0EjhE{queR00f{4@PMI&(T<6WX@t251OYjLx9g`z=^}7MCW6m0S3$i{y9`=lL^2K5CFKLqecR>r}S@5j|8L&+Q$h; zRp^Zc<6tA_bLw8I&C5te;(WdjK7pD5>k#+FE1JE_;5;!7JN-=sP)`BF+f zqkqbt!dH66%{ui)-)=X#Hd^2UdT_sMCvta9p=ev(K}`&za`m=3DwIGBj?p)vEm183)n$o~ZxY^O1%Uf5tOxkZ z;hCU|wm6$AxoAld$I&l6fsaY87FLNbz1uP3y*v0#j-r?rXUP!C&)$(kl!9vzT0&aFK5QB)gKQyQ2%k+5II}4YEXu$s1%gBm*-}nm/,FUNC_REGEXP:/(\([^)]*\))?$/,DOT_REGEXP:/\./g,APOS_REGEXP:/'/g,BRACKET_REGEXP:/^(.*)((?:\s*\[\s*\d+\s*\]\s*)|(?:\s*\[\s*"(?:[^"\\]|\\.)*"\s*\]\s*)|(?:\s*\[\s*'(?:[^'\\]|\\.)*'\s*\]\s*))(.*)$/,COL_CLASS_PREFIX:"ui-grid-col",ENTITY_BINDING:"$$this",events:{GRID_SCROLL:"uiGridScroll",COLUMN_MENU_SHOWN:"uiGridColMenuShown",ITEM_DRAGGING:"uiGridItemDragStart",COLUMN_HEADER_CLICK:"uiGridColumnHeaderClick"},keymap:{TAB:9,STRG:17,CAPSLOCK:20,CTRL:17,CTRLRIGHT:18,CTRLR:18,SHIFT:16,RETURN:13,ENTER:13,BACKSPACE:8,BCKSP:8,ALT:18,ALTR:17,ALTRIGHT:17,SPACE:32,WIN:91,MAC:91,FN:null,PG_UP:33,PG_DOWN:34,UP:38,DOWN:40,LEFT:37,RIGHT:39,ESC:27,DEL:46,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123},ASC:"asc",DESC:"desc",filter:{STARTS_WITH:2,ENDS_WITH:4,EXACT:8,CONTAINS:16,GREATER_THAN:32,GREATER_THAN_OR_EQUAL:64,LESS_THAN:128,LESS_THAN_OR_EQUAL:256,NOT_EQUAL:512,SELECT:"select",INPUT:"input"},aggregationTypes:{sum:2,count:4,avg:8,min:16,max:32},CURRENCY_SYMBOLS:["¤","؋","Ar","Ƀ","฿","B/.","Br","Bs.","Bs.F.","GH₵","¢","c","Ch.","₡","C$","D","ден","دج",".د.ب","د.ع","JD","د.ك","ل.د","дин","د.ت","د.م.","د.إ","Db","$","₫","Esc","€","ƒ","Ft","FBu","FCFA","CFA","Fr","FRw","G","gr","₲","h","₴","₭","Kč","kr","kn","MK","ZK","Kz","K","L","Le","лв","E","lp","M","KM","MT","₥","Nfk","₦","Nu.","UM","T$","MOP$","₱","Pt.","£","ج.م.","LL","LS","P","Q","q","R","R$","ر.ع.","ر.ق","ر.س","៛","RM","p","Rf.","₹","₨","SRe","Rp","₪","Ksh","Sh.So.","USh","S/","SDR","сом","৳\t","WS$","₮","VT","₩","¥","zł"],scrollDirection:{UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",NONE:"none"},dataChange:{ALL:"all",EDIT:"edit",ROW:"row",COLUMN:"column",OPTIONS:"options"},scrollbars:{NEVER:0,ALWAYS:1,WHEN_NEEDED:2}})}(),angular.module("ui.grid").directive("uiGridCell",["$compile","$parse","gridUtil","uiGridConstants",function(l,e,a,c){return{priority:0,scope:!1,require:"?^uiGrid",compile:function(){return{pre:function(t,r,e,i){if(i&&t.col.compiledElementFn)(0,t.col.compiledElementFn)(t,function(e,t){r.append(e)});else if(i&&!t.col.compiledElementFn)t.col.getCompiledElementFn().then(function(e){e(t,function(e,t){r.append(e)})}).catch(angular.noop);else{var n=t.col.cellTemplate.replace(c.MODEL_COL_FIELD,"row.entity."+a.preEval(t.col.field)).replace(c.COL_FIELD,"grid.getCellValue(row, col)"),o=l(n)(t);r.append(o)}},post:function(i,n,e,t){var o,l=i.col.getColClass(!1);n.addClass(l);var a=function(e){var t=n;o&&(t.removeClass(o),o=null),o=angular.isFunction(i.col.cellClass)?i.col.cellClass(i.grid,i.row,i.col,i.rowRenderIndex,i.colRenderIndex):i.col.cellClass,t.addClass(o)};i.col.cellClass&&a();var r=i.grid.registerDataChangeCallback(a,[c.dataChange.COLUMN,c.dataChange.EDIT]),s=i.$watch("row",function(e,t){if(e!==t){(o||i.col.cellClass)&&a();var r=i.col.getColClass(!1);r!==l&&(n.removeClass(l),n.addClass(r),l=r)}}),d=function(){r(),s()};i.$on("$destroy",d),n.on("$destroy",d)}}}}}]),angular.module("ui.grid").service("uiGridColumnMenuService",["i18nService","uiGridConstants","gridUtil",function(e,r,g){var i={initialize:function(e,t){e.grid=t.grid,(t.columnMenuScope=e).menuShown=!1},setColMenuItemWatch:function(t){var e=t.$watch("col.menuItems",function(e){void 0!==e&&e&&angular.isArray(e)?(e.forEach(function(e){void 0!==e.context&&e.context||(e.context={}),e.context.col=t.col}),t.menuItems=t.defaultMenuItems.concat(e)):t.menuItems=t.defaultMenuItems});t.$on("$destroy",e)},sortable:function(e){return!!(e.grid.options.enableSorting&&void 0!==e.col&&e.col&&e.col.enableSorting)},isActiveSort:function(e,t){return void 0!==e.col&&void 0!==e.col.sort&&void 0!==e.col.sort.direction&&e.col.sort.direction===t},suppressRemoveSort:function(e){return!(!e.col||!e.col.suppressRemoveSort)},hideable:function(e){return void 0===e.col||!e.col||!e.col.colDef||!1!==e.col.colDef.enableHiding},getDefaultMenuItems:function(t){return[{title:function(){return e.getSafeText("sort.ascending")},icon:"ui-grid-icon-sort-alt-up",action:function(e){e.stopPropagation(),t.sortColumn(e,r.ASC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.ASC)}},{title:function(){return e.getSafeText("sort.descending")},icon:"ui-grid-icon-sort-alt-down",action:function(e){e.stopPropagation(),t.sortColumn(e,r.DESC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.DESC)}},{title:function(){return e.getSafeText("sort.remove")},icon:"ui-grid-icon-cancel",action:function(e){e.stopPropagation(),t.unsortColumn()},shown:function(){return i.sortable(t)&&void 0!==t.col&&void 0!==t.col.sort&&void 0!==t.col.sort.direction&&null!==t.col.sort.direction&&!i.suppressRemoveSort(t)}},{title:function(){return e.getSafeText("column.hide")},icon:"ui-grid-icon-cancel",shown:function(){return i.hideable(t)},action:function(e){e.stopPropagation(),t.hideColumn()}}]},getColumnElementPosition:function(e,t,r){var i={};return i.left=r[0].offsetLeft,i.top=r[0].offsetTop,i.parentLeft=r[0].offsetParent.offsetLeft,i.offset=0,t.grid.options.offsetLeft&&(i.offset=t.grid.options.offsetLeft),i.height=g.elementHeight(r,!0),i.width=g.elementWidth(r,!0),i},repositionMenu:function(e,t,r,i,n){var o=i[0].querySelectorAll(".ui-grid-menu"),l=g.closestElm(n,".ui-grid-render-container"),a=l.getBoundingClientRect().left-e.grid.element[0].getBoundingClientRect().left,s=l.querySelectorAll(".ui-grid-viewport")[0].scrollLeft,d=g.elementWidth(o,!0),c=t.lastMenuPaddingRight?t.lastMenuPaddingRight:e.lastMenuPaddingRight?e.lastMenuPaddingRight:10;0!==o.length&&0!==o[0].querySelectorAll(".ui-grid-menu-mid").length&&(c=parseInt(g.getStyles(angular.element(o)[0]).paddingRight,10),e.lastMenuPaddingRight=c,t.lastMenuPaddingRight=c);var u=r.left+a-s+r.parentLeft+r.width+c;u(c.grid.rowHeaderColumns?c.grid.rowHeaderColumns.length:0);!r&&!n.uiGridColumns&&0===c.grid.options.columnDefs.length&&0
    ',scope:{side:"=uiGridPinnedContainer"},require:"^uiGrid",compile:function(){return{post:function(n,t,e,r){var o=r.grid,i=0;function l(){if("left"===n.side||"right"===n.side){for(var e=o.renderContainers[n.side].visibleColumnCache,t=0,r=0;r=t&&(t=e.sort.priority+1)}),t},e.prototype.resetColumnSorting=function(t){this.columns.forEach(function(e){e===t||e.suppressRemoveSort||(e.sort={})})},e.prototype.getColumnSorting=function(){var t=[];return this.columns.slice(0).sort(h.prioritySort).forEach(function(e){e.sort&&void 0!==e.sort.direction&&e.sort.direction&&(e.sort.direction===s.ASC||e.sort.direction===s.DESC)&&t.push(e)}),t},e.prototype.sortColumn=function(e,t,r){var i=this,n=null;if(void 0===e||!e)throw new Error("No column parameter provided");if("boolean"==typeof t?r=t:n=t,r?void 0===e.sort.priority&&(e.sort.priority=i.getNextColumnSortPriority()):(i.resetColumnSorting(e),e.sort.priority=void 0,e.sort.priority=i.getNextColumnSortPriority()),n)e.sort.direction=n;else{var o=e.sortDirectionCycle.indexOf(e.sort.direction?e.sort.direction:null);o=(o+1)%e.sortDirectionCycle.length,e.colDef&&e.suppressRemoveSort&&!e.sortDirectionCycle[o]&&(o=(o+1)%e.sortDirectionCycle.length),e.sortDirectionCycle[o]?e.sort.direction=e.sortDirectionCycle[o]:l(e,i)}return i.api.core.raise.sortChanged(i,i.getColumnSorting()),S.when(e)};var l=function(t,e){e.columns.forEach(function(e){e.sort&&void 0!==e.sort.priority&&e.sort.priority>t.sort.priority&&(e.sort.priority-=1)}),t.sort={}};function n(e,t){var r=e/t;return r<=1?r:1}function T(e,t,r){if(n(e,t)!==r)return{percentage:n(e,t)}}function R(e,t,r){var i=e/t;if((i=1Math.ceil(s)&&(c=h-s+r.renderContainers.body.prevScrollTop,i.y=T(c,g,r.renderContainers.body.prevScrolltopPercentage))}if(null!==t){for(var p=o.indexOf(t),f=r.renderContainers.body.getCanvasWidth()-r.renderContainers.body.getViewportWidth(),m=0,v=0;vt&&(e.sort.priority-=1)}),this.sort={},this.grid.api.core.raise.sortChanged(this.grid,this.grid.getColumnSorting())},t.prototype.getColClass=function(e){var t=c.COL_CLASS_PREFIX+this.uid;return e?"."+t:t},t.prototype.isPinnedLeft=function(){return"left"===this.renderContainer},t.prototype.isPinnedRight=function(){return"right"===this.renderContainer},t.prototype.getColClassDefinition=function(){return" .grid"+this.grid.id+" "+this.getColClass(!0)+" { min-width: "+this.drawnWidth+"px; max-width: "+this.drawnWidth+"px; }"},t.prototype.getRenderContainer=function(){var e=this.renderContainer;return null!==e&&""!==e&&void 0!==e||(e="body"),this.grid.renderContainers[e]},t.prototype.showColumn=function(){this.colDef.visible=!0},t.prototype.getAggregationText=function(){if(this.colDef.aggregationHideLabel)return"";if(this.colDef.aggregationLabel)return this.colDef.aggregationLabel;switch(this.colDef.aggregationType){case c.aggregationTypes.count:return e.getSafeText("aggregation.count");case c.aggregationTypes.sum:return e.getSafeText("aggregation.sum");case c.aggregationTypes.avg:return e.getSafeText("aggregation.avg");case c.aggregationTypes.min:return e.getSafeText("aggregation.min");case c.aggregationTypes.max:return e.getSafeText("aggregation.max");default:return""}},t.prototype.getCellTemplate=function(){return this.cellTemplatePromise},t.prototype.getCompiledElementFn=function(){return this.compiledElementFnDefer.promise},t}]),angular.module("ui.grid").factory("GridOptions",["gridUtil","uiGridConstants",function(t,r){return{initialize:function(e){return e.onRegisterApi=e.onRegisterApi||angular.noop(),e.data=e.data||[],e.columnDefs=e.columnDefs||[],e.excludeProperties=e.excludeProperties||["$$hashKey"],e.enableRowHashing=!1!==e.enableRowHashing,e.rowIdentity=e.rowIdentity||function(e){return t.hashKey(e)},e.getRowIdentity=e.getRowIdentity||function(e){return e.$$hashKey},e.flatEntityAccess=!0===e.flatEntityAccess,e.showHeader=void 0===e.showHeader||e.showHeader,e.showHeader?e.headerRowHeight=void 0!==e.headerRowHeight?e.headerRowHeight:30:e.headerRowHeight=0,"string"==typeof e.rowHeight?e.rowHeight=parseInt(e.rowHeight)||30:e.rowHeight=e.rowHeight||30,e.minRowsToShow=void 0!==e.minRowsToShow?e.minRowsToShow:10,e.showGridFooter=!0===e.showGridFooter,e.showColumnFooter=!0===e.showColumnFooter,e.columnFooterHeight=void 0!==e.columnFooterHeight?e.columnFooterHeight:30,e.gridFooterHeight=void 0!==e.gridFooterHeight?e.gridFooterHeight:30,e.columnWidth=void 0!==e.columnWidth?e.columnWidth:50,e.maxVisibleColumnCount=void 0!==e.maxVisibleColumnCount?e.maxVisibleColumnCount:200,e.virtualizationThreshold=void 0!==e.virtualizationThreshold?e.virtualizationThreshold:20,e.columnVirtualizationThreshold=void 0!==e.columnVirtualizationThreshold?e.columnVirtualizationThreshold:10,e.excessRows=void 0!==e.excessRows?e.excessRows:4,e.scrollThreshold=void 0!==e.scrollThreshold?e.scrollThreshold:4,e.excessColumns=void 0!==e.excessColumns?e.excessColumns:4,e.horizontalScrollThreshold=void 0!==e.horizontalScrollThreshold?e.horizontalScrollThreshold:2,e.aggregationCalcThrottle=void 0!==e.aggregationCalcThrottle?e.aggregationCalcThrottle:500,e.wheelScrollThrottle=void 0!==e.wheelScrollThrottle?e.wheelScrollThrottle:70,e.scrollDebounce=void 0!==e.scrollDebounce?e.scrollDebounce:300,e.enableSorting=!1!==e.enableSorting,e.enableFiltering=!0===e.enableFiltering,e.enableColumnMenus=!1!==e.enableColumnMenus,e.enableVerticalScrollbar=void 0!==e.enableVerticalScrollbar?e.enableVerticalScrollbar:r.scrollbars.ALWAYS,e.enableHorizontalScrollbar=void 0!==e.enableHorizontalScrollbar?e.enableHorizontalScrollbar:r.scrollbars.ALWAYS,e.enableMinHeightCheck=!1!==e.enableMinHeightCheck,e.minimumColumnSize=void 0!==e.minimumColumnSize?e.minimumColumnSize:30,e.rowEquality=e.rowEquality||function(e,t){return e===t},e.headerTemplate=e.headerTemplate||null,e.footerTemplate=e.footerTemplate||"ui-grid/ui-grid-footer",e.gridFooterTemplate=e.gridFooterTemplate||"ui-grid/ui-grid-grid-footer",e.rowTemplate=e.rowTemplate||"ui-grid/ui-grid-row",e.gridMenuTemplate=e.gridMenuTemplate||"ui-grid/uiGridMenu",e.appScopeProvider=e.appScopeProvider||null,e}}}]),angular.module("ui.grid").factory("GridRenderContainer",["gridUtil","uiGridConstants",function(y,n){function e(e,t,r){var i=this;i.name=e,i.grid=t,i.visibleRowCache=[],i.visibleColumnCache=[],i.renderedRows=[],i.renderedColumns=[],i.prevScrollTop=0,i.prevScrolltopPercentage=0,i.prevRowScrollIndex=0,i.prevScrollLeft=0,i.prevScrollleftPercentage=0,i.prevColumnScrollIndex=0,i.columnStyles="",i.viewportAdjusters=[],i.hasHScrollbar=!1,i.hasVScrollbar=!1,i.canvasHeightShouldUpdate=!0,i.$$canvasHeight=0,r&&angular.isObject(r)&&angular.extend(i,r),t.registerStyleComputation({priority:5,func:function(){return i.updateColumnWidths(),i.columnStyles}})}return e.prototype.reset=function(){this.visibleColumnCache.length=0,this.visibleRowCache.length=0,this.renderedRows.length=0,this.renderedColumns.length=0},e.prototype.containsColumn=function(e){return-1!==this.visibleColumnCache.indexOf(e)},e.prototype.minRowsToRender=function(){for(var e=0,t=0,r=this.getViewportHeight(),i=this.visibleRowCache.length-1;ti.grid.options.virtualizationThreshold){if(null!=e){if(!i.grid.suppressParentScrollDown&&i.prevScrollTope&&a>i.prevRowScrollIndex-i.grid.options.scrollThreshold&&ar.grid.options.columnVirtualizationThreshold&&r.getCanvasWidth()>r.getViewportWidth())a=[Math.max(0,l-r.grid.options.excessColumns),Math.min(n.length,l+i+r.grid.options.excessColumns)];else{var s=r.visibleColumnCache.length;a=[0,Math.max(s,i+r.grid.options.excessColumns)]}r.updateViewableColumnRange(a),r.prevColumnScrollIndex=l},e.prototype.updateViewableRowRange=function(e){var t=this.visibleRowCache.slice(e[0],e[1]);this.currentTopRow=e[0],this.setRenderedRows(t)},e.prototype.updateViewableColumnRange=function(e){var t=this.visibleColumnCache.slice(e[0],e[1]);this.currentFirstColumn=e[0],this.setRenderedColumns(t)},e.prototype.headerCellWrapperStyle=function(){if(0!==this.currentFirstColumn){var e=this.columnOffset;return this.grid.isRTL()?{"margin-right":e+"px"}:{"margin-left":e+"px"}}return null},e.prototype.updateColumnWidths=function(){var i=this,n=[],o=0,l=0,t="",a=!1,s=[],d=[],c=0,u=i.grid.getViewportWidth()-i.grid.scrollbarWidth,r=[];angular.forEach(i.grid.renderContainers,function(e){r=r.concat(e.visibleColumnCache)}),r.forEach(function(e){var t=0;if(e.visible)if(a&&(u+=i.grid.scrollbarWidth),!a&&e.colDef.pinnedRight&&(a=!0),angular.isNumber(e.width))t=parseInt(e.width,10),l+=t,e.drawnWidth=t,s.push(e);else if(y.endsWith(e.width,"%")){var r=parseInt(e.width.replace(/%/g,""),10);(t=parseInt(r/100*u))>e.maxWidth&&(t=e.maxWidth),te.maxWidth&&(t=e.maxWidth),te.minWidth&&0e.offsetWidth)},e.prototype.getViewportStyle=function(){var e=this,t={},r={};return r[n.scrollbars.ALWAYS]="scroll",r[n.scrollbars.WHEN_NEEDED]="auto",e.hasHScrollbar=!1,e.hasVScrollbar=!1,e.grid.disableScrolling?(t["overflow-x"]="hidden",t["overflow-y"]="hidden"):("body"===e.name?(e.hasHScrollbar=e.grid.options.enableHorizontalScrollbar!==n.scrollbars.NEVER,e.grid.isRTL()?e.grid.hasLeftContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER):e.grid.hasRightContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER)):"left"===e.name?e.hasVScrollbar=!!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER:e.hasVScrollbar=!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER,t["overflow-x"]=e.hasHScrollbar?r[e.grid.options.enableHorizontalScrollbar]:"hidden",t["overflow-y"]=e.hasVScrollbar?r[e.grid.options.enableVerticalScrollbar]:"hidden"),t},e}]),angular.module("ui.grid").factory("GridRow",["gridUtil","uiGridConstants",function(i,t){function e(e,t,r){this.grid=r,this.entity=e,this.uid=i.nextUid(),this.visible=!0,this.isSelected=!1,this.$$height=r.options.rowHeight}return Object.defineProperty(e.prototype,"height",{get:function(){return this.$$height},set:function(e){e!==this.$$height&&(this.grid.updateCanvasHeight(),this.$$height=e)}}),e.prototype.getQualifiedColField=function(e){return"row."+this.getEntityQualifiedColField(e)},e.prototype.getEntityQualifiedColField=function(e){return e.field===t.ENTITY_BINDING?"entity":i.preEval("entity."+e.field)},e.prototype.setRowInvisible=function(e){e&&e.setThisRowInvisible&&e.setThisRowInvisible("user")},e.prototype.clearRowInvisible=function(e){e&&e.clearThisRowInvisible&&e.clearThisRowInvisible("user")},e.prototype.setThisRowInvisible=function(e,t){this.invisibleReason||(this.invisibleReason={}),this.invisibleReason[e]=!0,this.evaluateRowVisibility(t)},e.prototype.clearThisRowInvisible=function(e,t){void 0!==this.invisibleReason&&delete this.invisibleReason[e],this.evaluateRowVisibility(t)},e.prototype.evaluateRowVisibility=function(e){var r=!0;void 0!==this.invisibleReason&&angular.forEach(this.invisibleReason,function(e,t){e&&(r=!1)}),void 0!==this.visible&&this.visible===r||(this.visible=r,e||(this.grid.queueGridRefresh(),this.grid.api.core.raise.rowsVisibleChanged(this)))},e}]),function(){"use strict";angular.module("ui.grid").factory("GridRowColumn",["$parse","$filter",function(e,t){var r=function e(t,r){if(!(this instanceof e))throw"Using GridRowColumn as a function insead of as a constructor. Must be called with `new` keyword";this.row=t,this.col=r};return r.prototype.getIntersectionValueRaw=function(){return e(this.row.getEntityQualifiedColField(this.col))(this.row)},r}])}(),angular.module("ui.grid").factory("ScrollEvent",["gridUtil",function(l){function e(e,t,r,i){var n=this;if(!e)throw new Error("grid argument is required");n.grid=e,n.source=i,n.withDelay=!0,n.sourceRowContainer=t,n.sourceColContainer=r,n.newScrollLeft=null,n.newScrollTop=null,n.x=null,n.y=null,n.verticalScrollLength=-9999999,n.horizontalScrollLength=-999999,n.fireThrottledScrollingEvent=l.throttle(function(e){n.grid.scrollContainers(e,n)},n.grid.options.wheelScrollThrottle,{trailing:!0})}return e.prototype.getNewScrollLeft=function(e,t){var r=this;if(!r.newScrollLeft){var i,n=e.getCanvasWidth()-e.getViewportWidth(),o=l.normalizeScrollLeft(t,r.grid);if(void 0!==r.x.percentage&&void 0!==r.x.percentage)i=r.x.percentage;else{if(void 0===r.x.pixels||void 0===r.x.pixels)throw new Error("No percentage or pixel value provided for scroll event X axis");i=r.x.percentage=(o+r.x.pixels)/n}return Math.max(0,i*n)}return r.newScrollLeft},e.prototype.getNewScrollTop=function(e,t){var r=this;if(!r.newScrollTop){var i,n=e.getVerticalScrollLength(),o=t[0].scrollTop;if(void 0!==r.y.percentage&&void 0!==r.y.percentage)i=r.y.percentage;else{if(void 0===r.y.pixels||void 0===r.y.pixels)throw new Error("No percentage or pixel value provided for scroll event Y axis");i=r.y.percentage=(o+r.y.pixels)/n}return Math.max(0,i*n)}return r.newScrollTop},e.prototype.atTop=function(e){return this.y&&(0===this.y.percentage||this.verticalScrollLength<0)&&0===e},e.prototype.atBottom=function(e){return this.y&&(1===this.y.percentage||0===this.verticalScrollLength)&&0A')[0],r="reverse";return document.body.appendChild(t),0
     
     
    '),e.put("ui-grid/ui-grid-footer",''),e.put("ui-grid/ui-grid-grid-footer",''),e.put("ui-grid/ui-grid-header",'
    \x3c!-- theader --\x3e
    '),e.put("ui-grid/ui-grid-menu-button",'
     
    '),e.put("ui-grid/ui-grid-menu-header-item",'
  • '),e.put("ui-grid/ui-grid-no-header",'
    '),e.put("ui-grid/ui-grid-row","
    "),e.put("ui-grid/ui-grid",'
    \x3c!-- TODO (c0bra): add "scoped" attr here, eventually? --\x3e
    '),e.put("ui-grid/uiGridCell",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/uiGridColumnMenu",'
    \x3c!--
    \n
    \n
      \n
      \n
    • Sort Ascending
    • \n
    • Sort Descending
    • \n
    • Remove Sort
    • \n
      \n
    \n
    \n
    --\x3e
    '),e.put("ui-grid/uiGridFooterCell",'
    {{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}
    '),e.put("ui-grid/uiGridHeaderCell",'
    {{ col.displayName CUSTOM_FILTERS }} {{col.sort.priority + 1}}
    '),e.put("ui-grid/uiGridMenu",'
    '),e.put("ui-grid/uiGridMenuItem",''),e.put("ui-grid/uiGridRenderContainer","
    \x3c!-- All of these dom elements are replaced in place --\x3e
    "),e.put("ui-grid/uiGridViewport",'
    \x3c!-- tbody --\x3e
    '),e.put("ui-grid/cellEditor",'
    '),e.put("ui-grid/dropdownEditor",'
    '),e.put("ui-grid/fileChooserEditor",'
    '),e.put("ui-grid/emptyBaseLayerContainer",'
    '),e.put("ui-grid/expandableRow",'
    '),e.put("ui-grid/expandableRowHeader",'
    '),e.put("ui-grid/expandableScrollFiller","
    "),e.put("ui-grid/expandableTopRowHeader",'
    '),e.put("ui-grid/csvLink",'LINK_LABEL'),e.put("ui-grid/importerMenuItem",'
  • '),e.put("ui-grid/importerMenuItemContainer","
    "),e.put("ui-grid/pagination",'
    {{ 1 + paginationApi.getFirstRowIndex() }} - {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
    '),e.put("ui-grid/columnResizer",'
    '),e.put("ui-grid/gridFooterSelectedItems",'({{"search.selectedItems" | t}} {{grid.selection.selectedCount}})'),e.put("ui-grid/selectionHeaderCell",'
    \x3c!--
     
    --\x3e
    '),e.put("ui-grid/selectionRowHeader",'
    '),e.put("ui-grid/selectionRowHeaderButtons",''),e.put("ui-grid/selectionSelectAllButtons",'
    '),e.put("ui-grid/treeBaseExpandAllButtons",'
    '),e.put("ui-grid/treeBaseHeaderCell",'
    '),e.put("ui-grid/treeBaseRowHeader",'
    '),e.put("ui-grid/treeBaseRowHeaderButtons",'
     
    '),e.put("ui-grid/cellTitleValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/cellTooltipValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    ')}]); \ No newline at end of file +!function(){"use strict";angular.module("ui.grid.i18n",[]),angular.module("ui.grid",["ui.grid.i18n"])}(),function(){"use strict";angular.module("ui.grid").constant("uiGridConstants",{LOG_DEBUG_MESSAGES:!0,LOG_WARN_MESSAGES:!0,LOG_ERROR_MESSAGES:!0,CUSTOM_FILTERS:/CUSTOM_FILTERS/g,COL_FIELD:/COL_FIELD/g,MODEL_COL_FIELD:/MODEL_COL_FIELD/g,TOOLTIP:/title=\"TOOLTIP\"/g,DISPLAY_CELL_TEMPLATE:/DISPLAY_CELL_TEMPLATE/g,TEMPLATE_REGEXP:/<.+>/,FUNC_REGEXP:/(\([^)]*\))?$/,DOT_REGEXP:/\./g,APOS_REGEXP:/'/g,BRACKET_REGEXP:/^(.*)((?:\s*\[\s*\d+\s*\]\s*)|(?:\s*\[\s*"(?:[^"\\]|\\.)*"\s*\]\s*)|(?:\s*\[\s*'(?:[^'\\]|\\.)*'\s*\]\s*))(.*)$/,COL_CLASS_PREFIX:"ui-grid-col",ENTITY_BINDING:"$$this",events:{GRID_SCROLL:"uiGridScroll",COLUMN_MENU_SHOWN:"uiGridColMenuShown",ITEM_DRAGGING:"uiGridItemDragStart",COLUMN_HEADER_CLICK:"uiGridColumnHeaderClick"},keymap:{TAB:9,STRG:17,CAPSLOCK:20,CTRL:17,CTRLRIGHT:18,CTRLR:18,SHIFT:16,RETURN:13,ENTER:13,BACKSPACE:8,BCKSP:8,ALT:18,ALTR:17,ALTRIGHT:17,SPACE:32,WIN:91,MAC:91,FN:null,PG_UP:33,PG_DOWN:34,UP:38,DOWN:40,LEFT:37,RIGHT:39,ESC:27,DEL:46,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123},ASC:"asc",DESC:"desc",filter:{STARTS_WITH:2,ENDS_WITH:4,EXACT:8,CONTAINS:16,GREATER_THAN:32,GREATER_THAN_OR_EQUAL:64,LESS_THAN:128,LESS_THAN_OR_EQUAL:256,NOT_EQUAL:512,SELECT:"select",INPUT:"input"},aggregationTypes:{sum:2,count:4,avg:8,min:16,max:32},CURRENCY_SYMBOLS:["¤","؋","Ar","Ƀ","฿","B/.","Br","Bs.","Bs.F.","GH₵","¢","c","Ch.","₡","C$","D","ден","دج",".د.ب","د.ع","JD","د.ك","ل.د","дин","د.ت","د.م.","د.إ","Db","$","₫","Esc","€","ƒ","Ft","FBu","FCFA","CFA","Fr","FRw","G","gr","₲","h","₴","₭","Kč","kr","kn","MK","ZK","Kz","K","L","Le","лв","E","lp","M","KM","MT","₥","Nfk","₦","Nu.","UM","T$","MOP$","₱","Pt.","£","ج.م.","LL","LS","P","Q","q","R","R$","ر.ع.","ر.ق","ر.س","៛","RM","p","Rf.","₹","₨","SRe","Rp","₪","Ksh","Sh.So.","USh","S/","SDR","сом","৳\t","WS$","₮","VT","₩","¥","zł"],scrollDirection:{UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",NONE:"none"},dataChange:{ALL:"all",EDIT:"edit",ROW:"row",COLUMN:"column",OPTIONS:"options"},scrollbars:{NEVER:0,ALWAYS:1,WHEN_NEEDED:2}})}(),angular.module("ui.grid").directive("uiGridCell",["$compile","$parse","gridUtil","uiGridConstants",function(l,e,a,c){return{priority:0,scope:!1,require:"?^uiGrid",compile:function(){return{pre:function(t,r,e,i){if(i&&t.col.compiledElementFn)(0,t.col.compiledElementFn)(t,function(e,t){r.append(e)});else if(i&&!t.col.compiledElementFn)t.col.getCompiledElementFn().then(function(e){e(t,function(e,t){r.append(e)})}).catch(angular.noop);else{var n=t.col.cellTemplate.replace(c.MODEL_COL_FIELD,"row.entity."+a.preEval(t.col.field)).replace(c.COL_FIELD,"grid.getCellValue(row, col)"),o=l(n)(t);r.append(o)}},post:function(i,n,e,t){var o,l=i.col.getColClass(!1);n.addClass(l);var a=function(e){var t=n;o&&(t.removeClass(o),o=null),o=angular.isFunction(i.col.cellClass)?i.col.cellClass(i.grid,i.row,i.col,i.rowRenderIndex,i.colRenderIndex):i.col.cellClass,t.addClass(o)};i.col.cellClass&&a();var r=i.grid.registerDataChangeCallback(a,[c.dataChange.COLUMN,c.dataChange.EDIT]),s=i.$watch("row",function(e,t){if(e!==t){(o||i.col.cellClass)&&a();var r=i.col.getColClass(!1);r!==l&&(n.removeClass(l),n.addClass(r),l=r)}}),d=function(){r(),s()};i.$on("$destroy",d),n.on("$destroy",d)}}}}}]),angular.module("ui.grid").service("uiGridColumnMenuService",["i18nService","uiGridConstants","gridUtil",function(e,r,g){var i={initialize:function(e,t){e.grid=t.grid,(t.columnMenuScope=e).menuShown=!1},setColMenuItemWatch:function(t){var e=t.$watch("col.menuItems",function(e){void 0!==e&&e&&angular.isArray(e)?(e.forEach(function(e){void 0!==e.context&&e.context||(e.context={}),e.context.col=t.col}),t.menuItems=t.defaultMenuItems.concat(e)):t.menuItems=t.defaultMenuItems});t.$on("$destroy",e)},sortable:function(e){return!!(e.grid.options.enableSorting&&void 0!==e.col&&e.col&&e.col.enableSorting)},isActiveSort:function(e,t){return void 0!==e.col&&void 0!==e.col.sort&&void 0!==e.col.sort.direction&&e.col.sort.direction===t},suppressRemoveSort:function(e){return!(!e.col||!e.col.suppressRemoveSort)},hideable:function(e){return void 0===e.col||!e.col||!e.col.colDef||!1!==e.col.colDef.enableHiding},getDefaultMenuItems:function(t){return[{title:function(){return e.getSafeText("sort.ascending")},icon:"ui-grid-icon-sort-alt-up",action:function(e){e.stopPropagation(),t.sortColumn(e,r.ASC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.ASC)}},{title:function(){return e.getSafeText("sort.descending")},icon:"ui-grid-icon-sort-alt-down",action:function(e){e.stopPropagation(),t.sortColumn(e,r.DESC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.DESC)}},{title:function(){return e.getSafeText("sort.remove")},icon:"ui-grid-icon-cancel",action:function(e){e.stopPropagation(),t.unsortColumn()},shown:function(){return i.sortable(t)&&void 0!==t.col&&void 0!==t.col.sort&&void 0!==t.col.sort.direction&&null!==t.col.sort.direction&&!i.suppressRemoveSort(t)}},{title:function(){return e.getSafeText("column.hide")},icon:"ui-grid-icon-cancel",shown:function(){return i.hideable(t)},action:function(e){e.stopPropagation(),t.hideColumn()}}]},getColumnElementPosition:function(e,t,r){var i={};return i.left=r[0].offsetLeft,i.top=r[0].offsetTop,i.parentLeft=r[0].offsetParent.offsetLeft,i.offset=0,t.grid.options.offsetLeft&&(i.offset=t.grid.options.offsetLeft),i.height=g.elementHeight(r,!0),i.width=g.elementWidth(r,!0),i},repositionMenu:function(e,t,r,i,n){var o=i[0].querySelectorAll(".ui-grid-menu"),l=g.closestElm(n,".ui-grid-render-container"),a=l.getBoundingClientRect().left-e.grid.element[0].getBoundingClientRect().left,s=l.querySelectorAll(".ui-grid-viewport")[0].scrollLeft,d=g.elementWidth(o,!0),c=t.lastMenuPaddingRight?t.lastMenuPaddingRight:e.lastMenuPaddingRight?e.lastMenuPaddingRight:10;0!==o.length&&0!==o[0].querySelectorAll(".ui-grid-menu-mid").length&&(c=parseInt(g.getStyles(angular.element(o)[0]).paddingRight,10),e.lastMenuPaddingRight=c,t.lastMenuPaddingRight=c);var u=r.left+a-s+r.parentLeft+r.width+c;u(c.grid.rowHeaderColumns?c.grid.rowHeaderColumns.length:0);!r&&!n.uiGridColumns&&0===c.grid.options.columnDefs.length&&0
    ',scope:{side:"=uiGridPinnedContainer"},require:"^uiGrid",compile:function(){return{post:function(n,t,e,r){var o=r.grid,i=0;function l(){if("left"===n.side||"right"===n.side){for(var e=o.renderContainers[n.side].visibleColumnCache,t=0,r=0;r=t&&(t=e.sort.priority+1)}),t},e.prototype.resetColumnSorting=function(t){this.columns.forEach(function(e){e===t||e.suppressRemoveSort||(e.sort={})})},e.prototype.getColumnSorting=function(){var t=[];return this.columns.slice(0).sort(h.prioritySort).forEach(function(e){e.sort&&void 0!==e.sort.direction&&e.sort.direction&&(e.sort.direction===s.ASC||e.sort.direction===s.DESC)&&t.push(e)}),t},e.prototype.sortColumn=function(e,t,r){var i=this,n=null;if(void 0===e||!e)throw new Error("No column parameter provided");if("boolean"==typeof t?r=t:n=t,r?void 0===e.sort.priority&&(e.sort.priority=i.getNextColumnSortPriority()):(i.resetColumnSorting(e),e.sort.priority=void 0,e.sort.priority=i.getNextColumnSortPriority()),n)e.sort.direction=n;else{var o=e.sortDirectionCycle.indexOf(e.sort.direction?e.sort.direction:null);o=(o+1)%e.sortDirectionCycle.length,e.colDef&&e.suppressRemoveSort&&!e.sortDirectionCycle[o]&&(o=(o+1)%e.sortDirectionCycle.length),e.sortDirectionCycle[o]?e.sort.direction=e.sortDirectionCycle[o]:l(e,i)}return i.api.core.raise.sortChanged(i,i.getColumnSorting()),S.when(e)};var l=function(t,e){e.columns.forEach(function(e){e.sort&&void 0!==e.sort.priority&&e.sort.priority>t.sort.priority&&(e.sort.priority-=1)}),t.sort={}};function n(e,t){var r=e/t;return r<=1?r:1}function T(e,t,r){if(n(e,t)!==r)return{percentage:n(e,t)}}function R(e,t,r){var i=e/t;if((i=1Math.ceil(s)&&(c=h-s+r.renderContainers.body.prevScrollTop,i.y=T(c,g,r.renderContainers.body.prevScrolltopPercentage))}if(null!==t){for(var p=o.indexOf(t),f=r.renderContainers.body.getCanvasWidth()-r.renderContainers.body.getViewportWidth(),m=0,v=0;vt&&(e.sort.priority-=1)}),this.sort={},this.grid.api.core.raise.sortChanged(this.grid,this.grid.getColumnSorting())},t.prototype.getColClass=function(e){var t=c.COL_CLASS_PREFIX+this.uid;return e?"."+t:t},t.prototype.isPinnedLeft=function(){return"left"===this.renderContainer},t.prototype.isPinnedRight=function(){return"right"===this.renderContainer},t.prototype.getColClassDefinition=function(){return" .grid"+this.grid.id+" "+this.getColClass(!0)+" { min-width: "+this.drawnWidth+"px; max-width: "+this.drawnWidth+"px; }"},t.prototype.getRenderContainer=function(){var e=this.renderContainer;return null!==e&&""!==e&&void 0!==e||(e="body"),this.grid.renderContainers[e]},t.prototype.showColumn=function(){this.colDef.visible=!0},t.prototype.getAggregationText=function(){if(this.colDef.aggregationHideLabel)return"";if(this.colDef.aggregationLabel)return this.colDef.aggregationLabel;switch(this.colDef.aggregationType){case c.aggregationTypes.count:return e.getSafeText("aggregation.count");case c.aggregationTypes.sum:return e.getSafeText("aggregation.sum");case c.aggregationTypes.avg:return e.getSafeText("aggregation.avg");case c.aggregationTypes.min:return e.getSafeText("aggregation.min");case c.aggregationTypes.max:return e.getSafeText("aggregation.max");default:return""}},t.prototype.getCellTemplate=function(){return this.cellTemplatePromise},t.prototype.getCompiledElementFn=function(){return this.compiledElementFnDefer.promise},t}]),angular.module("ui.grid").factory("GridOptions",["gridUtil","uiGridConstants",function(t,r){return{initialize:function(e){return e.onRegisterApi=e.onRegisterApi||angular.noop(),e.data=e.data||[],e.columnDefs=e.columnDefs||[],e.excludeProperties=e.excludeProperties||["$$hashKey"],e.enableRowHashing=!1!==e.enableRowHashing,e.rowIdentity=e.rowIdentity||function(e){return t.hashKey(e)},e.getRowIdentity=e.getRowIdentity||function(e){return e.$$hashKey},e.flatEntityAccess=!0===e.flatEntityAccess,e.showHeader=void 0===e.showHeader||e.showHeader,e.showHeader?e.headerRowHeight=void 0!==e.headerRowHeight?e.headerRowHeight:30:e.headerRowHeight=0,"string"==typeof e.rowHeight?e.rowHeight=parseInt(e.rowHeight)||30:e.rowHeight=e.rowHeight||30,e.minRowsToShow=void 0!==e.minRowsToShow?e.minRowsToShow:10,e.showGridFooter=!0===e.showGridFooter,e.showColumnFooter=!0===e.showColumnFooter,e.columnFooterHeight=void 0!==e.columnFooterHeight?e.columnFooterHeight:30,e.gridFooterHeight=void 0!==e.gridFooterHeight?e.gridFooterHeight:30,e.columnWidth=void 0!==e.columnWidth?e.columnWidth:50,e.maxVisibleColumnCount=void 0!==e.maxVisibleColumnCount?e.maxVisibleColumnCount:200,e.virtualizationThreshold=void 0!==e.virtualizationThreshold?e.virtualizationThreshold:20,e.columnVirtualizationThreshold=void 0!==e.columnVirtualizationThreshold?e.columnVirtualizationThreshold:10,e.excessRows=void 0!==e.excessRows?e.excessRows:4,e.scrollThreshold=void 0!==e.scrollThreshold?e.scrollThreshold:4,e.excessColumns=void 0!==e.excessColumns?e.excessColumns:4,e.horizontalScrollThreshold=void 0!==e.horizontalScrollThreshold?e.horizontalScrollThreshold:2,e.aggregationCalcThrottle=void 0!==e.aggregationCalcThrottle?e.aggregationCalcThrottle:500,e.wheelScrollThrottle=void 0!==e.wheelScrollThrottle?e.wheelScrollThrottle:70,e.scrollDebounce=void 0!==e.scrollDebounce?e.scrollDebounce:300,e.enableSorting=!1!==e.enableSorting,e.enableFiltering=!0===e.enableFiltering,e.enableColumnMenus=!1!==e.enableColumnMenus,e.enableVerticalScrollbar=void 0!==e.enableVerticalScrollbar?e.enableVerticalScrollbar:r.scrollbars.ALWAYS,e.enableHorizontalScrollbar=void 0!==e.enableHorizontalScrollbar?e.enableHorizontalScrollbar:r.scrollbars.ALWAYS,e.enableMinHeightCheck=!1!==e.enableMinHeightCheck,e.minimumColumnSize=void 0!==e.minimumColumnSize?e.minimumColumnSize:30,e.rowEquality=e.rowEquality||function(e,t){return e===t},e.headerTemplate=e.headerTemplate||null,e.footerTemplate=e.footerTemplate||"ui-grid/ui-grid-footer",e.gridFooterTemplate=e.gridFooterTemplate||"ui-grid/ui-grid-grid-footer",e.rowTemplate=e.rowTemplate||"ui-grid/ui-grid-row",e.gridMenuTemplate=e.gridMenuTemplate||"ui-grid/uiGridMenu",e.appScopeProvider=e.appScopeProvider||null,e}}}]),angular.module("ui.grid").factory("GridRenderContainer",["gridUtil","uiGridConstants",function(y,n){function e(e,t,r){var i=this;i.name=e,i.grid=t,i.visibleRowCache=[],i.visibleColumnCache=[],i.renderedRows=[],i.renderedColumns=[],i.prevScrollTop=0,i.prevScrolltopPercentage=0,i.prevRowScrollIndex=0,i.prevScrollLeft=0,i.prevScrollleftPercentage=0,i.prevColumnScrollIndex=0,i.columnStyles="",i.viewportAdjusters=[],i.hasHScrollbar=!1,i.hasVScrollbar=!1,i.canvasHeightShouldUpdate=!0,i.$$canvasHeight=0,r&&angular.isObject(r)&&angular.extend(i,r),t.registerStyleComputation({priority:5,func:function(){return i.updateColumnWidths(),i.columnStyles}})}return e.prototype.reset=function(){this.visibleColumnCache.length=0,this.visibleRowCache.length=0,this.renderedRows.length=0,this.renderedColumns.length=0},e.prototype.containsColumn=function(e){return-1!==this.visibleColumnCache.indexOf(e)},e.prototype.minRowsToRender=function(){for(var e=0,t=0,r=this.getViewportHeight(),i=this.visibleRowCache.length-1;ti.grid.options.virtualizationThreshold){if(null!=e){if(!i.grid.suppressParentScrollDown&&i.prevScrollTope&&a>i.prevRowScrollIndex-i.grid.options.scrollThreshold&&ar.grid.options.columnVirtualizationThreshold&&r.getCanvasWidth()>r.getViewportWidth())a=[Math.max(0,l-r.grid.options.excessColumns),Math.min(n.length,l+i+r.grid.options.excessColumns)];else{var s=r.visibleColumnCache.length;a=[0,Math.max(s,i+r.grid.options.excessColumns)]}r.updateViewableColumnRange(a),r.prevColumnScrollIndex=l},e.prototype.updateViewableRowRange=function(e){var t=this.visibleRowCache.slice(e[0],e[1]);this.currentTopRow=e[0],this.setRenderedRows(t)},e.prototype.updateViewableColumnRange=function(e){var t=this.visibleColumnCache.slice(e[0],e[1]);this.currentFirstColumn=e[0],this.setRenderedColumns(t)},e.prototype.headerCellWrapperStyle=function(){if(0!==this.currentFirstColumn){var e=this.columnOffset;return this.grid.isRTL()?{"margin-right":e+"px"}:{"margin-left":e+"px"}}return null},e.prototype.updateColumnWidths=function(){var i=this,n=[],o=0,l=0,t="",a=!1,s=[],d=[],c=0,u=i.grid.getViewportWidth()-i.grid.scrollbarWidth,r=[];angular.forEach(i.grid.renderContainers,function(e){r=r.concat(e.visibleColumnCache)}),r.forEach(function(e){var t=0;if(e.visible)if(a&&(u+=i.grid.scrollbarWidth),!a&&e.colDef.pinnedRight&&(a=!0),angular.isNumber(e.width))t=parseInt(e.width,10),l+=t,e.drawnWidth=t,s.push(e);else if(y.endsWith(e.width,"%")){var r=parseInt(e.width.replace(/%/g,""),10);(t=parseInt(r/100*u))>e.maxWidth&&(t=e.maxWidth),te.maxWidth&&(t=e.maxWidth),te.minWidth&&0e.offsetWidth)},e.prototype.getViewportStyle=function(){var e=this,t={},r={};return r[n.scrollbars.ALWAYS]="scroll",r[n.scrollbars.WHEN_NEEDED]="auto",e.hasHScrollbar=!1,e.hasVScrollbar=!1,e.grid.disableScrolling?(t["overflow-x"]="hidden",t["overflow-y"]="hidden"):("body"===e.name?(e.hasHScrollbar=e.grid.options.enableHorizontalScrollbar!==n.scrollbars.NEVER,e.grid.isRTL()?e.grid.hasLeftContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER):e.grid.hasRightContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER)):"left"===e.name?e.hasVScrollbar=!!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER:e.hasVScrollbar=!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER,t["overflow-x"]=e.hasHScrollbar?r[e.grid.options.enableHorizontalScrollbar]:"hidden",t["overflow-y"]=e.hasVScrollbar?r[e.grid.options.enableVerticalScrollbar]:"hidden"),t},e}]),angular.module("ui.grid").factory("GridRow",["gridUtil","uiGridConstants",function(i,t){function e(e,t,r){this.grid=r,this.entity=e,this.uid=i.nextUid(),this.visible=!0,this.isSelected=!1,this.$$height=r.options.rowHeight}return Object.defineProperty(e.prototype,"height",{get:function(){return this.$$height},set:function(e){e!==this.$$height&&(this.grid.updateCanvasHeight(),this.$$height=e)}}),e.prototype.getQualifiedColField=function(e){return"row."+this.getEntityQualifiedColField(e)},e.prototype.getEntityQualifiedColField=function(e){return e.field===t.ENTITY_BINDING?"entity":i.preEval("entity."+e.field)},e.prototype.setRowInvisible=function(e){e&&e.setThisRowInvisible&&e.setThisRowInvisible("user")},e.prototype.clearRowInvisible=function(e){e&&e.clearThisRowInvisible&&e.clearThisRowInvisible("user")},e.prototype.setThisRowInvisible=function(e,t){this.invisibleReason||(this.invisibleReason={}),this.invisibleReason[e]=!0,this.evaluateRowVisibility(t)},e.prototype.clearThisRowInvisible=function(e,t){void 0!==this.invisibleReason&&delete this.invisibleReason[e],this.evaluateRowVisibility(t)},e.prototype.evaluateRowVisibility=function(e){var r=!0;void 0!==this.invisibleReason&&angular.forEach(this.invisibleReason,function(e,t){e&&(r=!1)}),void 0!==this.visible&&this.visible===r||(this.visible=r,e||(this.grid.queueGridRefresh(),this.grid.api.core.raise.rowsVisibleChanged(this)))},e}]),function(){"use strict";angular.module("ui.grid").factory("GridRowColumn",["$parse","$filter",function(e,t){var r=function e(t,r){if(!(this instanceof e))throw"Using GridRowColumn as a function insead of as a constructor. Must be called with `new` keyword";this.row=t,this.col=r};return r.prototype.getIntersectionValueRaw=function(){return e(this.row.getEntityQualifiedColField(this.col))(this.row)},r}])}(),angular.module("ui.grid").factory("ScrollEvent",["gridUtil",function(l){function e(e,t,r,i){var n=this;if(!e)throw new Error("grid argument is required");n.grid=e,n.source=i,n.withDelay=!0,n.sourceRowContainer=t,n.sourceColContainer=r,n.newScrollLeft=null,n.newScrollTop=null,n.x=null,n.y=null,n.verticalScrollLength=-9999999,n.horizontalScrollLength=-999999,n.fireThrottledScrollingEvent=l.throttle(function(e){n.grid.scrollContainers(e,n)},n.grid.options.wheelScrollThrottle,{trailing:!0})}return e.prototype.getNewScrollLeft=function(e,t){var r=this;if(!r.newScrollLeft){var i,n=e.getCanvasWidth()-e.getViewportWidth(),o=l.normalizeScrollLeft(t,r.grid);if(void 0!==r.x.percentage&&void 0!==r.x.percentage)i=r.x.percentage;else{if(void 0===r.x.pixels||void 0===r.x.pixels)throw new Error("No percentage or pixel value provided for scroll event X axis");i=r.x.percentage=(o+r.x.pixels)/n}return Math.max(0,i*n)}return r.newScrollLeft},e.prototype.getNewScrollTop=function(e,t){var r=this;if(!r.newScrollTop){var i,n=e.getVerticalScrollLength(),o=t[0].scrollTop;if(void 0!==r.y.percentage&&void 0!==r.y.percentage)i=r.y.percentage;else{if(void 0===r.y.pixels||void 0===r.y.pixels)throw new Error("No percentage or pixel value provided for scroll event Y axis");i=r.y.percentage=(o+r.y.pixels)/n}return Math.max(0,i*n)}return r.newScrollTop},e.prototype.atTop=function(e){return this.y&&(0===this.y.percentage||this.verticalScrollLength<0)&&0===e},e.prototype.atBottom=function(e){return this.y&&(1===this.y.percentage||0===this.verticalScrollLength)&&0A')[0],r="reverse";return document.body.appendChild(t),0
     
     
    '),e.put("ui-grid/ui-grid-footer",''),e.put("ui-grid/ui-grid-grid-footer",''),e.put("ui-grid/ui-grid-header",'
    \x3c!-- theader --\x3e
    '),e.put("ui-grid/ui-grid-menu-button",'
     
    '),e.put("ui-grid/ui-grid-menu-header-item",'
  • '),e.put("ui-grid/ui-grid-no-header",'
    '),e.put("ui-grid/ui-grid-row","
    "),e.put("ui-grid/ui-grid",'
    \x3c!-- TODO (c0bra): add "scoped" attr here, eventually? --\x3e
    '),e.put("ui-grid/uiGridCell",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/uiGridColumnMenu",'
    \x3c!--
    \n
    \n
      \n
      \n
    • Sort Ascending
    • \n
    • Sort Descending
    • \n
    • Remove Sort
    • \n
      \n
    \n
    \n
    --\x3e
    '),e.put("ui-grid/uiGridFooterCell",'
    {{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}
    '),e.put("ui-grid/uiGridHeaderCell",'
    {{ col.displayName CUSTOM_FILTERS }} {{col.sort.priority + 1}}
    '),e.put("ui-grid/uiGridMenu",'
    '),e.put("ui-grid/uiGridMenuItem",''),e.put("ui-grid/uiGridRenderContainer","
    \x3c!-- All of these dom elements are replaced in place --\x3e
    "),e.put("ui-grid/uiGridViewport",'
    \x3c!-- tbody --\x3e
    '),e.put("ui-grid/cellEditor",'
    '),e.put("ui-grid/dropdownEditor",'
    '),e.put("ui-grid/fileChooserEditor",'
    '),e.put("ui-grid/emptyBaseLayerContainer",'
    '),e.put("ui-grid/expandableRow",'
    '),e.put("ui-grid/expandableRowHeader",'
    '),e.put("ui-grid/expandableScrollFiller","
    "),e.put("ui-grid/expandableTopRowHeader",'
    '),e.put("ui-grid/csvLink",'LINK_LABEL'),e.put("ui-grid/importerMenuItem",'
  • '),e.put("ui-grid/importerMenuItemContainer","
    "),e.put("ui-grid/pagination",'
    {{ 1 + paginationApi.getFirstRowIndex() }} - {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
    '),e.put("ui-grid/columnResizer",'
    '),e.put("ui-grid/gridFooterSelectedItems",'({{"search.selectedItems" | t}} {{grid.selection.selectedCount}})'),e.put("ui-grid/selectionHeaderCell",'
    \x3c!--
     
    --\x3e
    '),e.put("ui-grid/selectionRowHeader",'
    '),e.put("ui-grid/selectionRowHeaderButtons",''),e.put("ui-grid/selectionSelectAllButtons",'
    '),e.put("ui-grid/treeBaseExpandAllButtons",'
    '),e.put("ui-grid/treeBaseHeaderCell",'
    '),e.put("ui-grid/treeBaseRowHeader",'
    '),e.put("ui-grid/treeBaseRowHeaderButtons",'
     
    '),e.put("ui-grid/cellTitleValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/cellTooltipValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    ')}]); \ No newline at end of file diff --git a/release/ui-grid.css b/release/ui-grid.css index d16b01ac4..87e7ef1d4 100644 --- a/release/ui-grid.css +++ b/release/ui-grid.css @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ @media screen and (max-width: 767px) { diff --git a/release/ui-grid.edit.js b/release/ui-grid.edit.js index 55af10b64..587a70be5 100644 --- a/release/ui-grid.edit.js +++ b/release/ui-grid.edit.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.edit.min.js b/release/ui-grid.edit.min.js index 715c4cf80..9521a3326 100644 --- a/release/ui-grid.edit.min.js +++ b/release/ui-grid.edit.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.empty-base-layer.js b/release/ui-grid.empty-base-layer.js index 267e4535e..fa98b3cb8 100644 --- a/release/ui-grid.empty-base-layer.js +++ b/release/ui-grid.empty-base-layer.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.empty-base-layer.min.js b/release/ui-grid.empty-base-layer.min.js index 64a5a5d51..b2fd2cbbc 100644 --- a/release/ui-grid.empty-base-layer.min.js +++ b/release/ui-grid.empty-base-layer.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.expandable.js b/release/ui-grid.expandable.js index a03944e73..0e9191696 100644 --- a/release/ui-grid.expandable.js +++ b/release/ui-grid.expandable.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.expandable.min.js b/release/ui-grid.expandable.min.js index 6b226f5c6..7bceaef08 100644 --- a/release/ui-grid.expandable.min.js +++ b/release/ui-grid.expandable.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.exporter.js b/release/ui-grid.exporter.js index 15b37c9aa..cb4c03133 100644 --- a/release/ui-grid.exporter.js +++ b/release/ui-grid.exporter.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.exporter.min.js b/release/ui-grid.exporter.min.js index ab40a515a..b19dec1d9 100644 --- a/release/ui-grid.exporter.min.js +++ b/release/ui-grid.exporter.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.grouping.js b/release/ui-grid.grouping.js index c0cc5b96b..8b0de146f 100644 --- a/release/ui-grid.grouping.js +++ b/release/ui-grid.grouping.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.grouping.min.js b/release/ui-grid.grouping.min.js index 8846d33d5..8bc3661b1 100644 --- a/release/ui-grid.grouping.min.js +++ b/release/ui-grid.grouping.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.importer.js b/release/ui-grid.importer.js index bbd902598..490936c02 100644 --- a/release/ui-grid.importer.js +++ b/release/ui-grid.importer.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.importer.min.js b/release/ui-grid.importer.min.js index 20bc8d1b1..260481f7f 100644 --- a/release/ui-grid.importer.min.js +++ b/release/ui-grid.importer.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.infinite-scroll.js b/release/ui-grid.infinite-scroll.js index 7c0e24d90..14082ec65 100644 --- a/release/ui-grid.infinite-scroll.js +++ b/release/ui-grid.infinite-scroll.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.infinite-scroll.min.js b/release/ui-grid.infinite-scroll.min.js index 9ad5d8735..3bfdac98e 100644 --- a/release/ui-grid.infinite-scroll.min.js +++ b/release/ui-grid.infinite-scroll.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.js b/release/ui-grid.js index 8e88433dd..aabf46da3 100644 --- a/release/ui-grid.js +++ b/release/ui-grid.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ @@ -11691,7 +11691,8 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC ['width', 'height'].forEach(function (name) { - var capsName = angular.uppercase(name.charAt(0)) + name.substr(1); + var capsName = name.charAt(0).toUpperCase() + name.substr(1); + s['element' + capsName] = function (elem, extra) { var e = elem; if (e && typeof(e.length) !== 'undefined' && e.length) { @@ -11701,12 +11702,11 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC if (e && e !== null) { var styles = getStyles(e); return e.offsetWidth === 0 && rdisplayswap.test(styles.display) ? - s.swap(e, cssShow, function() { - return getWidthOrHeight(e, name, extra ); - }) : - getWidthOrHeight( e, name, extra ); - } - else { + s.swap(e, cssShow, function() { + return getWidthOrHeight(e, name, extra ); + }) : + getWidthOrHeight( e, name, extra ); + } else { return null; } }; diff --git a/release/ui-grid.min.css b/release/ui-grid.min.css index 305169252..c6df1a1ac 100644 --- a/release/ui-grid.min.css +++ b/release/ui-grid.min.css @@ -1,4 +1,4 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */@media screen and (max-width:767px){}@media (min-width:768px){}.ui-grid{border:1px solid #d4d4d4;box-sizing:content-box;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-transform:translateZ(0);-moz-transform:translateZ(0);-o-transform:translateZ(0);-ms-transform:translateZ(0);transform:translateZ(0)}.ui-grid-vertical-bar{position:absolute;right:0;width:0}.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar,.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{width:1px}.ui-grid-scrollbar-placeholder{background-color:transparent}.ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#d4d4d4}.ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#d4d4d4}.ui-grid-header-cell:last-child .ui-grid-vertical-bar{right:-1px;width:1px;background-color:#d4d4d4}.ui-grid-clearfix:before,.ui-grid-clearfix:after{content:"";display:table}.ui-grid-clearfix:after{clear:both}.ui-grid-invisible{visibility:hidden}.ui-grid-contents-wrapper{position:relative;height:100%;width:100%}.ui-grid-sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.ui-grid-icon-button{background-color:transparent;border:none;padding:0}.ui-grid-top-panel-background{background-color:#f3f3f3}.ui-grid-header{border-bottom:1px solid #d4d4d4;box-sizing:border-box}.ui-grid-top-panel{position:relative;overflow:hidden;font-weight:bold;background-color:#f3f3f3;-webkit-border-top-right-radius:-1px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:-1px;-moz-border-radius-topright:-1px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:-1px;border-top-right-radius:-1px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:-1px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.ui-grid-header-viewport{overflow:hidden}.ui-grid-header-canvas:before,.ui-grid-header-canvas:after{content:"";display:table;line-height:0}.ui-grid-header-canvas:after{clear:both}.ui-grid-header-cell-wrapper{position:relative;display:table;box-sizing:border-box;height:100%}.ui-grid-header-cell-row{display:table-row}.ui-grid-header-cell{position:relative;box-sizing:border-box;background-color:inherit;border-right:1px solid;border-color:#d4d4d4;display:table-cell;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:0}.ui-grid-header-cell:last-child{border-right:0}.ui-grid-header-cell .sortable{cursor:pointer}.ui-grid-header-cell .ui-grid-sort-priority-number{margin-left:-8px}.ui-grid-header .ui-grid-vertical-bar{top:0;bottom:0}.ui-grid-column-menu-button{position:absolute;right:1px;top:0}.ui-grid-column-menu-button .ui-grid-icon-angle-down{vertical-align:sub}.ui-grid-header-cell-last-col .ui-grid-cell-contents,.ui-grid-header-cell-last-col .ui-grid-filter-container,.ui-grid-header-cell-last-col .ui-grid-column-menu-button,.ui-grid-header-cell-last-col+.ui-grid-column-resizer.right{margin-right:13px}.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-cell-contents,.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-filter-container,.ui-grid-render-container-right .ui-grid-header-cell-last-col .ui-grid-column-menu-button,.ui-grid-render-container-right .ui-grid-header-cell-last-col+.ui-grid-column-resizer.right{margin-right:28px}.ui-grid-column-menu{position:absolute}.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove{-webkit-transition:all .04s linear;-moz-transition:all .04s linear;-o-transition:all .04s linear;transition:all .04s linear;display:block !important}.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add.ng-hide-add-active,.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove{-webkit-transform:translateY(-100%);-moz-transform:translateY(-100%);-o-transform:translateY(-100%);-ms-transform:translateY(-100%);transform:translateY(-100%)}.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,.ui-grid-column-menu .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove.ng-hide-remove-active{-webkit-transform:translateY(0);-moz-transform:translateY(0);-o-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove{-webkit-transition:all .04s linear;-moz-transition:all .04s linear;-o-transition:all .04s linear;transition:all .04s linear;display:block !important}.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add.ng-hide-add-active,.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove{-webkit-transform:translateY(-100%);-moz-transform:translateY(-100%);-o-transform:translateY(-100%);-ms-transform:translateY(-100%);transform:translateY(-100%)}.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-add,.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid.ng-hide-remove.ng-hide-remove-active{-webkit-transform:translateY(0);-moz-transform:translateY(0);-o-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.ui-grid-filter-container{padding:4px 10px;position:relative}.ui-grid-filter-container .ui-grid-filter-button{position:absolute;top:0;bottom:0;right:0}.ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"]{position:absolute;top:50%;line-height:32px;margin-top:-16px;right:10px;opacity:.66}.ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"]:hover{opacity:1}.ui-grid-filter-container .ui-grid-filter-button-select{position:absolute;top:0;bottom:0;right:0}.ui-grid-filter-container .ui-grid-filter-button-select [class^="ui-grid-icon"]{position:absolute;top:50%;line-height:32px;margin-top:-16px;right:0;opacity:.66}.ui-grid-filter-container .ui-grid-filter-button-select [class^="ui-grid-icon"]:hover{opacity:1}input[type="text"].ui-grid-filter-input{box-sizing:border-box;padding:0 18px 0 0;margin:0;border:0;width:100%;border:1px solid #d4d4d4;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}input[type="text"].ui-grid-filter-input:hover{border:1px solid #d4d4d4}select.ui-grid-filter-select{padding:0;margin:0;border:0;width:90%;border:1px solid #d4d4d4;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}select.ui-grid-filter-select:hover{border:1px solid #d4d4d4}.ui-grid-filter-cancel-button-hidden select.ui-grid-filter-select{width:100%}.ui-grid-render-container{position:inherit;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.ui-grid-render-container:focus{outline:none}.ui-grid-viewport{min-height:20px;position:relative;overflow-y:scroll;-webkit-overflow-scrolling:touch}.ui-grid-viewport:focus{outline:none !important}.ui-grid-canvas{position:relative;padding-top:1px}.ui-grid-row{clear:both}.ui-grid-row:nth-child(odd) .ui-grid-cell{background-color:#fdfdfd}.ui-grid-row:nth-child(even) .ui-grid-cell{background-color:#f3f3f3}.ui-grid-row:last-child .ui-grid-cell{border-bottom-color:#d4d4d4;border-bottom-style:solid}.ui-grid-no-row-overlay{position:absolute;top:0;bottom:0;left:0;right:0;margin:10%;background-color:#f3f3f3;-webkit-border-top-right-radius:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:0;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #d4d4d4;font-size:2em;text-align:center}.ui-grid-no-row-overlay>*{position:absolute;display:table;margin:auto 0;width:100%;top:0;bottom:0;left:0;right:0;opacity:.66}.ui-grid-cell{overflow:hidden;float:left;background-color:inherit;border-right:1px solid;border-color:#d4d4d4;box-sizing:border-box}.ui-grid-cell:last-child{border-right:0}.ui-grid-cell-contents{padding:5px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;white-space:nowrap;-ms-text-overflow:ellipsis;-o-text-overflow:ellipsis;text-overflow:ellipsis;overflow:hidden;height:100%}.ui-grid-cell-contents-hidden{visibility:hidden;width:0;height:0;display:none}.ui-grid-row .ui-grid-cell.ui-grid-row-header-cell{background-color:#F0F0EE;border-bottom:solid 1px #d4d4d4}.ui-grid-cell-empty{display:inline-block;width:10px;height:10px}.ui-grid-footer-info{padding:5px 10px}.ui-grid-footer-panel-background{background-color:#f3f3f3}.ui-grid-footer-panel{position:relative;border-bottom:1px solid #d4d4d4;border-top:1px solid #d4d4d4;overflow:hidden;font-weight:bold;background-color:#f3f3f3;-webkit-border-top-right-radius:-1px;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-webkit-border-top-left-radius:-1px;-moz-border-radius-topright:-1px;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;-moz-border-radius-topleft:-1px;border-top-right-radius:-1px;border-bottom-right-radius:0;border-bottom-left-radius:0;border-top-left-radius:-1px;-moz-background-clip:padding-box;-webkit-background-clip:padding-box;background-clip:padding-box}.ui-grid-grid-footer{float:left;width:100%}.ui-grid-footer-viewport,.ui-grid-footer-canvas{display:flex;flex:1 1 auto;height:100%}.ui-grid-footer-viewport{overflow:hidden}.ui-grid-footer-canvas{position:relative}.ui-grid-footer-canvas:before,.ui-grid-footer-canvas:after{content:"";display:table;line-height:0}.ui-grid-footer-canvas:after{clear:both}.ui-grid-footer-cell-wrapper{position:relative;display:table;box-sizing:border-box;height:100%}.ui-grid-footer-cell-row{display:table-row}.ui-grid-footer-cell{overflow:hidden;background-color:inherit;border-right:1px solid;border-color:#d4d4d4;box-sizing:border-box;display:table-cell}.ui-grid-footer-cell:last-child{border-right:0}.ui-grid-menu-button{z-index:2;position:absolute;right:0;top:0;background:#f3f3f3;border:0;border-left:1px solid #d4d4d4;border-bottom:1px solid #d4d4d4;cursor:pointer;height:32px;font-weight:normal}.ui-grid-menu-button .ui-grid-icon-container{margin-top:5px;margin-left:2px}.ui-grid-menu-button .ui-grid-menu{right:0}.ui-grid-menu-button .ui-grid-menu .ui-grid-menu-mid{overflow:scroll}.ui-grid-menu{overflow:hidden;max-width:320px;z-index:2;position:absolute;right:100%;padding:0 10px 20px 10px;cursor:pointer;box-sizing:border-box}.ui-grid-menu-item{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ui-grid-menu .ui-grid-menu-inner{background:#fff;border:1px solid #d4d4d4;position:relative;white-space:nowrap;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.ui-grid-menu .ui-grid-menu-inner ul{margin:0;padding:0;list-style-type:none}.ui-grid-menu .ui-grid-menu-inner ul li{padding:0}.ui-grid-menu .ui-grid-menu-inner ul li .ui-grid-menu-item{color:#000;min-width:100%;padding:8px;text-align:left;background:transparent;border:none;cursor:default}.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item{cursor:pointer}.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item:hover,.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item:focus{background-color:#b3c4c7}.ui-grid-menu .ui-grid-menu-inner ul li button.ui-grid-menu-item.ui-grid-menu-item-active{background-color:#9cb2b6}.ui-grid-menu .ui-grid-menu-inner ul li:not(:last-child)>.ui-grid-menu-item{border-bottom:1px solid #d4d4d4}.ui-grid-sortarrow{right:5px;position:absolute;width:20px;top:0;bottom:0;background-position:center}.ui-grid-sortarrow.down{-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-o-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}@font-face{font-family:'ui-grid';src:url('ui-grid.eot');src:url('ui-grid.eot#iefix') format('embedded-opentype'),url('ui-grid.woff') format('woff'),url('ui-grid.ttf') format('truetype'),url('ui-grid.svg?#ui-grid') format('svg');font-weight:normal;font-style:normal}[class^="ui-grid-icon"]:before,[class*=" ui-grid-icon"]:before{font-family:"ui-grid";font-style:normal;font-weight:normal;speak:none;display:inline-block;text-decoration:inherit;width:1em;margin-right:.2em;text-align:center;font-variant:normal;text-transform:none;line-height:1em;margin-left:.2em}.ui-grid-icon-blank::before{width:1em;content:' '}.ui-grid-icon-plus-squared:before{content:'\c350'}.ui-grid-icon-minus-squared:before{content:'\c351'}.ui-grid-icon-search:before{content:'\c352'}.ui-grid-icon-cancel:before{content:'\c353'}.ui-grid-icon-info-circled:before{content:'\c354'}.ui-grid-icon-lock:before{content:'\c355'}.ui-grid-icon-lock-open:before{content:'\c356'}.ui-grid-icon-pencil:before{content:'\c357'}.ui-grid-icon-down-dir:before{content:'\c358'}.ui-grid-icon-up-dir:before{content:'\c359'}.ui-grid-icon-left-dir:before{content:'\c35a'}.ui-grid-icon-right-dir:before{content:'\c35b'}.ui-grid-icon-left-open:before{content:'\c35c'}.ui-grid-icon-right-open:before{content:'\c35d'}.ui-grid-icon-angle-down:before{content:'\c35e'}.ui-grid-icon-filter:before{content:'\c35f'}.ui-grid-icon-sort-alt-up:before{content:'\c360'}.ui-grid-icon-sort-alt-down:before{content:'\c361'}.ui-grid-icon-ok:before{content:'\c362'}.ui-grid-icon-menu:before{content:'\c363'}.ui-grid-icon-indent-left:before{content:'\e800'}.ui-grid-icon-indent-right:before{content:'\e801'}.ui-grid-icon-spin5:before{content:'\ea61'}.ui-grid[dir=rtl] .ui-grid-header-cell,.ui-grid[dir=rtl] .ui-grid-footer-cell,.ui-grid[dir=rtl] .ui-grid-cell{float:right !important}.ui-grid[dir=rtl] .ui-grid-column-menu-button{position:absolute;left:1px;top:0;right:inherit}.ui-grid[dir=rtl] .ui-grid-cell:first-child,.ui-grid[dir=rtl] .ui-grid-header-cell:first-child,.ui-grid[dir=rtl] .ui-grid-footer-cell:first-child{border-right:0}.ui-grid[dir=rtl] .ui-grid-cell:last-child,.ui-grid[dir=rtl] .ui-grid-header-cell:last-child{border-right:1px solid #d4d4d4;border-left:0}.ui-grid[dir=rtl] .ui-grid-header-cell:first-child .ui-grid-vertical-bar,.ui-grid[dir=rtl] .ui-grid-footer-cell:first-child .ui-grid-vertical-bar,.ui-grid[dir=rtl] .ui-grid-cell:first-child .ui-grid-vertical-bar{width:0}.ui-grid[dir=rtl] .ui-grid-menu-button{z-index:2;position:absolute;left:0;right:auto;background:#f3f3f3;border:1px solid #d4d4d4;cursor:pointer;min-height:27px;font-weight:normal}.ui-grid[dir=rtl] .ui-grid-menu-button .ui-grid-menu{left:0;right:auto}.ui-grid[dir=rtl] .ui-grid-filter-container .ui-grid-filter-button{right:initial;left:0}.ui-grid[dir=rtl] .ui-grid-filter-container .ui-grid-filter-button [class^="ui-grid-icon"]{right:initial;left:10px}.ui-grid-animate-spin{-moz-animation:ui-grid-spin 2s infinite linear;-o-animation:ui-grid-spin 2s infinite linear;-webkit-animation:ui-grid-spin 2s infinite linear;animation:ui-grid-spin 2s infinite linear;display:inline-block}@-moz-keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@-webkit-keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@-o-keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@-ms-keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes ui-grid-spin{0%{-moz-transform:rotate(0deg);-o-transform:rotate(0deg);-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-moz-transform:rotate(359deg);-o-transform:rotate(359deg);-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@media screen and (max-width:767px){}@media (min-width:768px){}.ui-grid-cell-focus{outline:0;background-color:#b3c4c7}.ui-grid-focuser{position:absolute;left:0;top:0;z-index:-1;width:100%;height:100%}.ui-grid-focuser:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6)}.ui-grid-offscreen{display:block;position:absolute;left:-10000px;top:-10000px;clip:rect(0, 0, 0, 0)}.ui-grid-cell input{border-radius:inherit;padding:0;width:100%;color:inherit;height:auto;font:inherit;outline:none}.ui-grid-cell input:focus{color:inherit;outline:none}.ui-grid-cell input[type="checkbox"]{margin:9px 0 0 6px;width:auto}.ui-grid-cell input.ng-invalid{border:1px solid #fc8f8f}.ui-grid-cell input.ng-valid{border:1px solid #d4d4d4}.ui-grid-viewport .ui-grid-empty-base-layer-container{position:absolute;overflow:hidden;pointer-events:none;z-index:-1}.expandableRow .ui-grid-row:nth-child(odd) .ui-grid-cell{background-color:#fdfdfd}.expandableRow .ui-grid-row:nth-child(even) .ui-grid-cell{background-color:#f3f3f3}.ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell{pointer-events:none}.ui-grid-expandable-buttons-cell i{pointer-events:all}.scrollFiller{float:left;border:1px solid #d4d4d4}.ui-grid-tree-header-row{font-weight:bold !important}.movingColumn{position:absolute;top:0;border:1px solid #d4d4d4;box-shadow:inset 0 0 14px rgba(0,0,0,0.2)}.movingColumn .ui-grid-icon-angle-down{display:none}@media screen and (max-width:767px){}@media (min-width:768px){}.ui-grid-pager-panel{display:flex;justify-content:space-between;align-items:center;position:absolute;left:0;bottom:0;width:100%;padding-top:3px;padding-bottom:3px;box-sizing:content-box}.ui-grid-pager-container{float:left}.ui-grid-pager-control{padding:5px 0;display:flex;flex-flow:row nowrap;align-items:center;margin-right:10px;margin-left:10px;min-width:135px;float:left}.ui-grid-pager-control button,.ui-grid-pager-control span,.ui-grid-pager-control input{margin-right:4px}.ui-grid-pager-control button{height:25px;min-width:26px;display:inline-block;margin-bottom:0;font-weight:normal;text-align:center;vertical-align:middle;touch-action:manipulation;cursor:pointer;background-image:none;border:1px solid transparent;white-space:nowrap;padding:6px 12px;font-size:14px;line-height:1.42857143;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:#eee;background-color:#f3f3f3;border-color:#ccc}.ui-grid-pager-control button:focus,.ui-grid-pager-control button:active:focus,.ui-grid-pager-control button.active:focus,.ui-grid-pager-control button.focus,.ui-grid-pager-control button:active.focus,.ui-grid-pager-control button.active.focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.ui-grid-pager-control button:hover,.ui-grid-pager-control button:focus,.ui-grid-pager-control button.focus{color:#333;text-decoration:none}.ui-grid-pager-control button:active,.ui-grid-pager-control button.active{outline:0;background-image:none;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.ui-grid-pager-control button.disabled,.ui-grid-pager-control button[disabled],fieldset[disabled] .ui-grid-pager-control button{cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}a.ui-grid-pager-control button.disabled,fieldset[disabled] a.ui-grid-pager-control button{pointer-events:none}.ui-grid-pager-control button:focus,.ui-grid-pager-control button.focus{color:#eee;background-color:#dadada;border-color:#8c8c8c}.ui-grid-pager-control button:hover{color:#eee;background-color:#dadada;border-color:#adadad}.ui-grid-pager-control button:active,.ui-grid-pager-control button.active,.open>.dropdown-toggle.ui-grid-pager-control button{color:#eee;background-color:#dadada;border-color:#adadad}.ui-grid-pager-control button:active:hover,.ui-grid-pager-control button.active:hover,.open>.dropdown-toggle.ui-grid-pager-control button:hover,.ui-grid-pager-control button:active:focus,.ui-grid-pager-control button.active:focus,.open>.dropdown-toggle.ui-grid-pager-control button:focus,.ui-grid-pager-control button:active.focus,.ui-grid-pager-control button.active.focus,.open>.dropdown-toggle.ui-grid-pager-control button.focus{color:#eee;background-color:#c8c8c8;border-color:#8c8c8c}.ui-grid-pager-control button:active,.ui-grid-pager-control button.active,.open>.dropdown-toggle.ui-grid-pager-control button{background-image:none}.ui-grid-pager-control button.disabled:hover,.ui-grid-pager-control button[disabled]:hover,fieldset[disabled] .ui-grid-pager-control button:hover,.ui-grid-pager-control button.disabled:focus,.ui-grid-pager-control button[disabled]:focus,fieldset[disabled] .ui-grid-pager-control button:focus,.ui-grid-pager-control button.disabled.focus,.ui-grid-pager-control button[disabled].focus,fieldset[disabled] .ui-grid-pager-control button.focus{background-color:#f3f3f3;border-color:#ccc}.ui-grid-pager-control button .badge{color:#f3f3f3;background-color:#eee}.ui-grid-pager-control input{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px;display:inline;height:26px;width:50px;vertical-align:top}.ui-grid-pager-control input:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6)}.ui-grid-pager-control input::-moz-placeholder{color:#999;opacity:1}.ui-grid-pager-control input:-ms-input-placeholder{color:#999}.ui-grid-pager-control input::-webkit-input-placeholder{color:#999}.ui-grid-pager-control input::-ms-expand{border:0;background-color:transparent}.ui-grid-pager-control input[disabled],.ui-grid-pager-control input[readonly],fieldset[disabled] .ui-grid-pager-control input{background-color:#eee;opacity:1}.ui-grid-pager-control input[disabled],fieldset[disabled] .ui-grid-pager-control input{cursor:not-allowed}textarea.ui-grid-pager-control input{height:auto}select.ui-grid-pager-control input{height:30px;line-height:30px}textarea.ui-grid-pager-control input,select[multiple].ui-grid-pager-control input{height:auto}.ui-grid-pager-control .ui-grid-pager-max-pages-number{vertical-align:bottom}.ui-grid-pager-control .ui-grid-pager-max-pages-number>*{vertical-align:bottom}.ui-grid-pager-control .ui-grid-pager-max-pages-number abbr{border-bottom:none;text-decoration:none}.ui-grid-pager-control .first-bar{width:10px;border-left:2px solid #4d4d4d;margin-top:-6px;height:12px;margin-left:-3px}.ui-grid-pager-control .first-bar-rtl{width:10px;border-left:2px solid #4d4d4d;margin-top:-6px;height:12px;margin-right:-7px}.ui-grid-pager-control .first-triangle{width:0;height:0;border-style:solid;border-width:5px 8.7px 5px 0;border-color:transparent #4d4d4d transparent transparent;margin-left:2px}.ui-grid-pager-control .next-triangle{margin-left:1px}.ui-grid-pager-control .prev-triangle{margin-left:0}.ui-grid-pager-control .last-triangle{width:0;height:0;border-style:solid;border-width:5px 0 5px 8.7px;border-color:transparent transparent transparent #4d4d4d;margin-left:-1px}.ui-grid-pager-control .last-bar{width:10px;border-left:2px solid #4d4d4d;margin-top:-6px;height:12px;margin-left:1px}.ui-grid-pager-control .last-bar-rtl{width:10px;border-left:2px solid #4d4d4d;margin-top:-6px;height:12px;margin-right:-11px}.ui-grid-pager-row-count-picker{float:left;padding:5px 10px}.ui-grid-pager-row-count-picker select{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s, box-shadow ease-in-out .15s;height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px;height:25px;width:67px;display:inline;vertical-align:middle}.ui-grid-pager-row-count-picker select:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6)}.ui-grid-pager-row-count-picker select::-moz-placeholder{color:#999;opacity:1}.ui-grid-pager-row-count-picker select:-ms-input-placeholder{color:#999}.ui-grid-pager-row-count-picker select::-webkit-input-placeholder{color:#999}.ui-grid-pager-row-count-picker select::-ms-expand{border:0;background-color:transparent}.ui-grid-pager-row-count-picker select[disabled],.ui-grid-pager-row-count-picker select[readonly],fieldset[disabled] .ui-grid-pager-row-count-picker select{background-color:#eee;opacity:1}.ui-grid-pager-row-count-picker select[disabled],fieldset[disabled] .ui-grid-pager-row-count-picker select{cursor:not-allowed}textarea.ui-grid-pager-row-count-picker select{height:auto}select.ui-grid-pager-row-count-picker select{height:30px;line-height:30px}textarea.ui-grid-pager-row-count-picker select,select[multiple].ui-grid-pager-row-count-picker select{height:auto}.ui-grid-pager-row-count-picker .ui-grid-pager-row-count-label{margin-top:3px}.ui-grid-pager-count-container{float:right;margin-top:4px;min-width:50px}.ui-grid-pager-count-container .ui-grid-pager-count{margin-right:10px;margin-left:10px;float:right}.ui-grid-pager-count-container .ui-grid-pager-count abbr{border-bottom:none;text-decoration:none}.ui-grid-pinned-container{position:absolute;display:inline;top:0}.ui-grid-pinned-container.ui-grid-pinned-container-left{float:left;left:0}.ui-grid-pinned-container.ui-grid-pinned-container-right{float:right;right:0}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:last-child{box-sizing:border-box;border-right:1px solid;border-width:1px;border-right-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-cell:last-child{box-sizing:border-box;border-right:1px solid;border-width:1px;border-right-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar,.ui-grid-pinned-container .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{width:1px}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#d4d4d4}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-left .ui-grid-header-cell:last-child .ui-grid-vertical-bar{right:-1px;width:1px;background-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:first-child{box-sizing:border-box;border-left:1px solid;border-width:1px;border-left-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-cell:first-child{box-sizing:border-box;border-left:1px solid;border-width:1px;border-left-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar,.ui-grid-pinned-container .ui-grid-cell:not(:first-child) .ui-grid-vertical-bar{width:1px}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-header-cell:not(:first-child) .ui-grid-vertical-bar{background-color:#d4d4d4}.ui-grid-pinned-container.ui-grid-pinned-container-right .ui-grid-cell:not(:last-child) .ui-grid-vertical-bar{background-color:#aeaeae}.ui-grid-pinned-container.ui-grid-pinned-container-first .ui-grid-header-cell:first-child .ui-grid-vertical-bar{left:-1px;width:1px;background-color:#aeaeae}.ui-grid-column-resizer{top:0;bottom:0;width:5px;position:absolute;cursor:col-resize}.ui-grid-column-resizer.left{left:0}.ui-grid-column-resizer.right{right:0}.ui-grid-header-cell:last-child .ui-grid-column-resizer.right{border-right:1px solid #d4d4d4}.ui-grid[dir=rtl] .ui-grid-header-cell:last-child .ui-grid-column-resizer.right{border-right:0}.ui-grid[dir=rtl] .ui-grid-header-cell:last-child .ui-grid-column-resizer.left{border-left:1px solid #d4d4d4}.ui-grid.column-resizing{cursor:col-resize;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ui-grid.column-resizing .ui-grid-resize-overlay{position:absolute;top:0;height:100%;width:1px;background-color:#aeaeae}.ui-grid-row-saving .ui-grid-cell{color:#848484 !important}.ui-grid-row-dirty .ui-grid-cell{color:#610B38}.ui-grid-row-error .ui-grid-cell{color:#FF0000 !important}.ui-grid-row.ui-grid-row-selected>[ui-grid-row]>.ui-grid-cell{background-color:#C9DDE1}.ui-grid-disable-selection{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.ui-grid-selection-row-header-buttons{display:flex;align-items:center;height:100%;cursor:pointer}.ui-grid-selection-row-header-buttons::before{opacity:.1}.ui-grid-selection-row-header-buttons.ui-grid-row-selected::before,.ui-grid-selection-row-header-buttons.ui-grid-all-selected::before{opacity:1}.ui-grid-tree-row-header-buttons.ui-grid-tree-header{cursor:pointer;opacity:1}.ui-grid-tree-header-row{font-weight:bold !important}.ui-grid-tree-header-row .ui-grid-cell.ui-grid-disable-selection.ui-grid-row-header-cell{pointer-events:all}.ui-grid-cell-contents.invalid{border:1px solid #fc8f8f} \ No newline at end of file diff --git a/release/ui-grid.min.js b/release/ui-grid.min.js index 3c1a3afd6..a110b2d84 100644 --- a/release/ui-grid.min.js +++ b/release/ui-grid.min.js @@ -1,7 +1,7 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ -!function(){"use strict";angular.module("ui.grid.i18n",[]),angular.module("ui.grid",["ui.grid.i18n"])}(),function(){"use strict";angular.module("ui.grid").constant("uiGridConstants",{LOG_DEBUG_MESSAGES:!0,LOG_WARN_MESSAGES:!0,LOG_ERROR_MESSAGES:!0,CUSTOM_FILTERS:/CUSTOM_FILTERS/g,COL_FIELD:/COL_FIELD/g,MODEL_COL_FIELD:/MODEL_COL_FIELD/g,TOOLTIP:/title=\"TOOLTIP\"/g,DISPLAY_CELL_TEMPLATE:/DISPLAY_CELL_TEMPLATE/g,TEMPLATE_REGEXP:/<.+>/,FUNC_REGEXP:/(\([^)]*\))?$/,DOT_REGEXP:/\./g,APOS_REGEXP:/'/g,BRACKET_REGEXP:/^(.*)((?:\s*\[\s*\d+\s*\]\s*)|(?:\s*\[\s*"(?:[^"\\]|\\.)*"\s*\]\s*)|(?:\s*\[\s*'(?:[^'\\]|\\.)*'\s*\]\s*))(.*)$/,COL_CLASS_PREFIX:"ui-grid-col",ENTITY_BINDING:"$$this",events:{GRID_SCROLL:"uiGridScroll",COLUMN_MENU_SHOWN:"uiGridColMenuShown",ITEM_DRAGGING:"uiGridItemDragStart",COLUMN_HEADER_CLICK:"uiGridColumnHeaderClick"},keymap:{TAB:9,STRG:17,CAPSLOCK:20,CTRL:17,CTRLRIGHT:18,CTRLR:18,SHIFT:16,RETURN:13,ENTER:13,BACKSPACE:8,BCKSP:8,ALT:18,ALTR:17,ALTRIGHT:17,SPACE:32,WIN:91,MAC:91,FN:null,PG_UP:33,PG_DOWN:34,UP:38,DOWN:40,LEFT:37,RIGHT:39,ESC:27,DEL:46,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123},ASC:"asc",DESC:"desc",filter:{STARTS_WITH:2,ENDS_WITH:4,EXACT:8,CONTAINS:16,GREATER_THAN:32,GREATER_THAN_OR_EQUAL:64,LESS_THAN:128,LESS_THAN_OR_EQUAL:256,NOT_EQUAL:512,SELECT:"select",INPUT:"input"},aggregationTypes:{sum:2,count:4,avg:8,min:16,max:32},CURRENCY_SYMBOLS:["¤","؋","Ar","Ƀ","฿","B/.","Br","Bs.","Bs.F.","GH₵","¢","c","Ch.","₡","C$","D","ден","دج",".د.ب","د.ع","JD","د.ك","ل.د","дин","د.ت","د.م.","د.إ","Db","$","₫","Esc","€","ƒ","Ft","FBu","FCFA","CFA","Fr","FRw","G","gr","₲","h","₴","₭","Kč","kr","kn","MK","ZK","Kz","K","L","Le","лв","E","lp","M","KM","MT","₥","Nfk","₦","Nu.","UM","T$","MOP$","₱","Pt.","£","ج.م.","LL","LS","P","Q","q","R","R$","ر.ع.","ر.ق","ر.س","៛","RM","p","Rf.","₹","₨","SRe","Rp","₪","Ksh","Sh.So.","USh","S/","SDR","сом","৳\t","WS$","₮","VT","₩","¥","zł"],scrollDirection:{UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",NONE:"none"},dataChange:{ALL:"all",EDIT:"edit",ROW:"row",COLUMN:"column",OPTIONS:"options"},scrollbars:{NEVER:0,ALWAYS:1,WHEN_NEEDED:2}})}(),angular.module("ui.grid").directive("uiGridCell",["$compile","$parse","gridUtil","uiGridConstants",function(a,e,l,u){return{priority:0,scope:!1,require:"?^uiGrid",compile:function(){return{pre:function(t,r,e,i){if(i&&t.col.compiledElementFn)(0,t.col.compiledElementFn)(t,function(e,t){r.append(e)});else if(i&&!t.col.compiledElementFn)t.col.getCompiledElementFn().then(function(e){e(t,function(e,t){r.append(e)})}).catch(angular.noop);else{var n=t.col.cellTemplate.replace(u.MODEL_COL_FIELD,"row.entity."+l.preEval(t.col.field)).replace(u.COL_FIELD,"grid.getCellValue(row, col)"),o=a(n)(t);r.append(o)}},post:function(i,n,e,t){var o,a=i.col.getColClass(!1);n.addClass(a);var l=function(e){var t=n;o&&(t.removeClass(o),o=null),o=angular.isFunction(i.col.cellClass)?i.col.cellClass(i.grid,i.row,i.col,i.rowRenderIndex,i.colRenderIndex):i.col.cellClass,t.addClass(o)};i.col.cellClass&&l();var r=i.grid.registerDataChangeCallback(l,[u.dataChange.COLUMN,u.dataChange.EDIT]),s=i.$watch("row",function(e,t){if(e!==t){(o||i.col.cellClass)&&l();var r=i.col.getColClass(!1);r!==a&&(n.removeClass(a),n.addClass(r),a=r)}}),d=function(){r(),s()};i.$on("$destroy",d),n.on("$destroy",d)}}}}}]),angular.module("ui.grid").service("uiGridColumnMenuService",["i18nService","uiGridConstants","gridUtil",function(e,r,g){var i={initialize:function(e,t){e.grid=t.grid,(t.columnMenuScope=e).menuShown=!1},setColMenuItemWatch:function(t){var e=t.$watch("col.menuItems",function(e){void 0!==e&&e&&angular.isArray(e)?(e.forEach(function(e){void 0!==e.context&&e.context||(e.context={}),e.context.col=t.col}),t.menuItems=t.defaultMenuItems.concat(e)):t.menuItems=t.defaultMenuItems});t.$on("$destroy",e)},sortable:function(e){return!!(e.grid.options.enableSorting&&void 0!==e.col&&e.col&&e.col.enableSorting)},isActiveSort:function(e,t){return void 0!==e.col&&void 0!==e.col.sort&&void 0!==e.col.sort.direction&&e.col.sort.direction===t},suppressRemoveSort:function(e){return!(!e.col||!e.col.suppressRemoveSort)},hideable:function(e){return void 0===e.col||!e.col||!e.col.colDef||!1!==e.col.colDef.enableHiding},getDefaultMenuItems:function(t){return[{title:function(){return e.getSafeText("sort.ascending")},icon:"ui-grid-icon-sort-alt-up",action:function(e){e.stopPropagation(),t.sortColumn(e,r.ASC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.ASC)}},{title:function(){return e.getSafeText("sort.descending")},icon:"ui-grid-icon-sort-alt-down",action:function(e){e.stopPropagation(),t.sortColumn(e,r.DESC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.DESC)}},{title:function(){return e.getSafeText("sort.remove")},icon:"ui-grid-icon-cancel",action:function(e){e.stopPropagation(),t.unsortColumn()},shown:function(){return i.sortable(t)&&void 0!==t.col&&void 0!==t.col.sort&&void 0!==t.col.sort.direction&&null!==t.col.sort.direction&&!i.suppressRemoveSort(t)}},{title:function(){return e.getSafeText("column.hide")},icon:"ui-grid-icon-cancel",shown:function(){return i.hideable(t)},action:function(e){e.stopPropagation(),t.hideColumn()}}]},getColumnElementPosition:function(e,t,r){var i={};return i.left=r[0].offsetLeft,i.top=r[0].offsetTop,i.parentLeft=r[0].offsetParent.offsetLeft,i.offset=0,t.grid.options.offsetLeft&&(i.offset=t.grid.options.offsetLeft),i.height=g.elementHeight(r,!0),i.width=g.elementWidth(r,!0),i},repositionMenu:function(e,t,r,i,n){var o=i[0].querySelectorAll(".ui-grid-menu"),a=g.closestElm(n,".ui-grid-render-container"),l=a.getBoundingClientRect().left-e.grid.element[0].getBoundingClientRect().left,s=a.querySelectorAll(".ui-grid-viewport")[0].scrollLeft,d=g.elementWidth(o,!0),u=t.lastMenuPaddingRight?t.lastMenuPaddingRight:e.lastMenuPaddingRight?e.lastMenuPaddingRight:10;0!==o.length&&0!==o[0].querySelectorAll(".ui-grid-menu-mid").length&&(u=parseInt(g.getStyles(angular.element(o)[0]).paddingRight,10),e.lastMenuPaddingRight=u,t.lastMenuPaddingRight=u);var c=r.left+l-s+r.parentLeft+r.width+u;c(u.grid.rowHeaderColumns?u.grid.rowHeaderColumns.length:0);!r&&!n.uiGridColumns&&0===u.grid.options.columnDefs.length&&0
    ',scope:{side:"=uiGridPinnedContainer"},require:"^uiGrid",compile:function(){return{post:function(n,t,e,r){var o=r.grid,i=0;function a(){if("left"===n.side||"right"===n.side){for(var e=o.renderContainers[n.side].visibleColumnCache,t=0,r=0;r=t&&(t=e.sort.priority+1)}),t},e.prototype.resetColumnSorting=function(t){this.columns.forEach(function(e){e===t||e.suppressRemoveSort||(e.sort={})})},e.prototype.getColumnSorting=function(){var t=[];return this.columns.slice(0).sort(p.prioritySort).forEach(function(e){e.sort&&void 0!==e.sort.direction&&e.sort.direction&&(e.sort.direction===s.ASC||e.sort.direction===s.DESC)&&t.push(e)}),t},e.prototype.sortColumn=function(e,t,r){var i=this,n=null;if(void 0===e||!e)throw new Error("No column parameter provided");if("boolean"==typeof t?r=t:n=t,r?void 0===e.sort.priority&&(e.sort.priority=i.getNextColumnSortPriority()):(i.resetColumnSorting(e),e.sort.priority=void 0,e.sort.priority=i.getNextColumnSortPriority()),n)e.sort.direction=n;else{var o=e.sortDirectionCycle.indexOf(e.sort.direction?e.sort.direction:null);o=(o+1)%e.sortDirectionCycle.length,e.colDef&&e.suppressRemoveSort&&!e.sortDirectionCycle[o]&&(o=(o+1)%e.sortDirectionCycle.length),e.sortDirectionCycle[o]?e.sort.direction=e.sortDirectionCycle[o]:a(e,i)}return i.api.core.raise.sortChanged(i,i.getColumnSorting()),S.when(e)};var a=function(t,e){e.columns.forEach(function(e){e.sort&&void 0!==e.sort.priority&&e.sort.priority>t.sort.priority&&(e.sort.priority-=1)}),t.sort={}};function n(e,t){var r=e/t;return r<=1?r:1}function E(e,t,r){if(n(e,t)!==r)return{percentage:n(e,t)}}function A(e,t,r){var i=e/t;if((i=1Math.ceil(s)&&(u=p-s+r.renderContainers.body.prevScrollTop,i.y=E(u,g,r.renderContainers.body.prevScrolltopPercentage))}if(null!==t){for(var f=o.indexOf(t),m=r.renderContainers.body.getCanvasWidth()-r.renderContainers.body.getViewportWidth(),h=0,v=0;vt&&(e.sort.priority-=1)}),this.sort={},this.grid.api.core.raise.sortChanged(this.grid,this.grid.getColumnSorting())},t.prototype.getColClass=function(e){var t=u.COL_CLASS_PREFIX+this.uid;return e?"."+t:t},t.prototype.isPinnedLeft=function(){return"left"===this.renderContainer},t.prototype.isPinnedRight=function(){return"right"===this.renderContainer},t.prototype.getColClassDefinition=function(){return" .grid"+this.grid.id+" "+this.getColClass(!0)+" { min-width: "+this.drawnWidth+"px; max-width: "+this.drawnWidth+"px; }"},t.prototype.getRenderContainer=function(){var e=this.renderContainer;return null!==e&&""!==e&&void 0!==e||(e="body"),this.grid.renderContainers[e]},t.prototype.showColumn=function(){this.colDef.visible=!0},t.prototype.getAggregationText=function(){if(this.colDef.aggregationHideLabel)return"";if(this.colDef.aggregationLabel)return this.colDef.aggregationLabel;switch(this.colDef.aggregationType){case u.aggregationTypes.count:return e.getSafeText("aggregation.count");case u.aggregationTypes.sum:return e.getSafeText("aggregation.sum");case u.aggregationTypes.avg:return e.getSafeText("aggregation.avg");case u.aggregationTypes.min:return e.getSafeText("aggregation.min");case u.aggregationTypes.max:return e.getSafeText("aggregation.max");default:return""}},t.prototype.getCellTemplate=function(){return this.cellTemplatePromise},t.prototype.getCompiledElementFn=function(){return this.compiledElementFnDefer.promise},t}]),angular.module("ui.grid").factory("GridOptions",["gridUtil","uiGridConstants",function(t,r){return{initialize:function(e){return e.onRegisterApi=e.onRegisterApi||angular.noop(),e.data=e.data||[],e.columnDefs=e.columnDefs||[],e.excludeProperties=e.excludeProperties||["$$hashKey"],e.enableRowHashing=!1!==e.enableRowHashing,e.rowIdentity=e.rowIdentity||function(e){return t.hashKey(e)},e.getRowIdentity=e.getRowIdentity||function(e){return e.$$hashKey},e.flatEntityAccess=!0===e.flatEntityAccess,e.showHeader=void 0===e.showHeader||e.showHeader,e.showHeader?e.headerRowHeight=void 0!==e.headerRowHeight?e.headerRowHeight:30:e.headerRowHeight=0,"string"==typeof e.rowHeight?e.rowHeight=parseInt(e.rowHeight)||30:e.rowHeight=e.rowHeight||30,e.minRowsToShow=void 0!==e.minRowsToShow?e.minRowsToShow:10,e.showGridFooter=!0===e.showGridFooter,e.showColumnFooter=!0===e.showColumnFooter,e.columnFooterHeight=void 0!==e.columnFooterHeight?e.columnFooterHeight:30,e.gridFooterHeight=void 0!==e.gridFooterHeight?e.gridFooterHeight:30,e.columnWidth=void 0!==e.columnWidth?e.columnWidth:50,e.maxVisibleColumnCount=void 0!==e.maxVisibleColumnCount?e.maxVisibleColumnCount:200,e.virtualizationThreshold=void 0!==e.virtualizationThreshold?e.virtualizationThreshold:20,e.columnVirtualizationThreshold=void 0!==e.columnVirtualizationThreshold?e.columnVirtualizationThreshold:10,e.excessRows=void 0!==e.excessRows?e.excessRows:4,e.scrollThreshold=void 0!==e.scrollThreshold?e.scrollThreshold:4,e.excessColumns=void 0!==e.excessColumns?e.excessColumns:4,e.horizontalScrollThreshold=void 0!==e.horizontalScrollThreshold?e.horizontalScrollThreshold:2,e.aggregationCalcThrottle=void 0!==e.aggregationCalcThrottle?e.aggregationCalcThrottle:500,e.wheelScrollThrottle=void 0!==e.wheelScrollThrottle?e.wheelScrollThrottle:70,e.scrollDebounce=void 0!==e.scrollDebounce?e.scrollDebounce:300,e.enableSorting=!1!==e.enableSorting,e.enableFiltering=!0===e.enableFiltering,e.enableColumnMenus=!1!==e.enableColumnMenus,e.enableVerticalScrollbar=void 0!==e.enableVerticalScrollbar?e.enableVerticalScrollbar:r.scrollbars.ALWAYS,e.enableHorizontalScrollbar=void 0!==e.enableHorizontalScrollbar?e.enableHorizontalScrollbar:r.scrollbars.ALWAYS,e.enableMinHeightCheck=!1!==e.enableMinHeightCheck,e.minimumColumnSize=void 0!==e.minimumColumnSize?e.minimumColumnSize:30,e.rowEquality=e.rowEquality||function(e,t){return e===t},e.headerTemplate=e.headerTemplate||null,e.footerTemplate=e.footerTemplate||"ui-grid/ui-grid-footer",e.gridFooterTemplate=e.gridFooterTemplate||"ui-grid/ui-grid-grid-footer",e.rowTemplate=e.rowTemplate||"ui-grid/ui-grid-row",e.gridMenuTemplate=e.gridMenuTemplate||"ui-grid/uiGridMenu",e.appScopeProvider=e.appScopeProvider||null,e}}}]),angular.module("ui.grid").factory("GridRenderContainer",["gridUtil","uiGridConstants",function(b,n){function e(e,t,r){var i=this;i.name=e,i.grid=t,i.visibleRowCache=[],i.visibleColumnCache=[],i.renderedRows=[],i.renderedColumns=[],i.prevScrollTop=0,i.prevScrolltopPercentage=0,i.prevRowScrollIndex=0,i.prevScrollLeft=0,i.prevScrollleftPercentage=0,i.prevColumnScrollIndex=0,i.columnStyles="",i.viewportAdjusters=[],i.hasHScrollbar=!1,i.hasVScrollbar=!1,i.canvasHeightShouldUpdate=!0,i.$$canvasHeight=0,r&&angular.isObject(r)&&angular.extend(i,r),t.registerStyleComputation({priority:5,func:function(){return i.updateColumnWidths(),i.columnStyles}})}return e.prototype.reset=function(){this.visibleColumnCache.length=0,this.visibleRowCache.length=0,this.renderedRows.length=0,this.renderedColumns.length=0},e.prototype.containsColumn=function(e){return-1!==this.visibleColumnCache.indexOf(e)},e.prototype.minRowsToRender=function(){for(var e=0,t=0,r=this.getViewportHeight(),i=this.visibleRowCache.length-1;ti.grid.options.virtualizationThreshold){if(null!=e){if(!i.grid.suppressParentScrollDown&&i.prevScrollTope&&l>i.prevRowScrollIndex-i.grid.options.scrollThreshold&&lr.grid.options.columnVirtualizationThreshold&&r.getCanvasWidth()>r.getViewportWidth())l=[Math.max(0,a-r.grid.options.excessColumns),Math.min(n.length,a+i+r.grid.options.excessColumns)];else{var s=r.visibleColumnCache.length;l=[0,Math.max(s,i+r.grid.options.excessColumns)]}r.updateViewableColumnRange(l),r.prevColumnScrollIndex=a},e.prototype.updateViewableRowRange=function(e){var t=this.visibleRowCache.slice(e[0],e[1]);this.currentTopRow=e[0],this.setRenderedRows(t)},e.prototype.updateViewableColumnRange=function(e){var t=this.visibleColumnCache.slice(e[0],e[1]);this.currentFirstColumn=e[0],this.setRenderedColumns(t)},e.prototype.headerCellWrapperStyle=function(){if(0!==this.currentFirstColumn){var e=this.columnOffset;return this.grid.isRTL()?{"margin-right":e+"px"}:{"margin-left":e+"px"}}return null},e.prototype.updateColumnWidths=function(){var i=this,n=[],o=0,a=0,t="",l=!1,s=[],d=[],u=0,c=i.grid.getViewportWidth()-i.grid.scrollbarWidth,r=[];angular.forEach(i.grid.renderContainers,function(e){r=r.concat(e.visibleColumnCache)}),r.forEach(function(e){var t=0;if(e.visible)if(l&&(c+=i.grid.scrollbarWidth),!l&&e.colDef.pinnedRight&&(l=!0),angular.isNumber(e.width))t=parseInt(e.width,10),a+=t,e.drawnWidth=t,s.push(e);else if(b.endsWith(e.width,"%")){var r=parseInt(e.width.replace(/%/g,""),10);(t=parseInt(r/100*c))>e.maxWidth&&(t=e.maxWidth),te.maxWidth&&(t=e.maxWidth),te.minWidth&&0e.offsetWidth)},e.prototype.getViewportStyle=function(){var e=this,t={},r={};return r[n.scrollbars.ALWAYS]="scroll",r[n.scrollbars.WHEN_NEEDED]="auto",e.hasHScrollbar=!1,e.hasVScrollbar=!1,e.grid.disableScrolling?(t["overflow-x"]="hidden",t["overflow-y"]="hidden"):("body"===e.name?(e.hasHScrollbar=e.grid.options.enableHorizontalScrollbar!==n.scrollbars.NEVER,e.grid.isRTL()?e.grid.hasLeftContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER):e.grid.hasRightContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER)):"left"===e.name?e.hasVScrollbar=!!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER:e.hasVScrollbar=!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER,t["overflow-x"]=e.hasHScrollbar?r[e.grid.options.enableHorizontalScrollbar]:"hidden",t["overflow-y"]=e.hasVScrollbar?r[e.grid.options.enableVerticalScrollbar]:"hidden"),t},e}]),angular.module("ui.grid").factory("GridRow",["gridUtil","uiGridConstants",function(i,t){function e(e,t,r){this.grid=r,this.entity=e,this.uid=i.nextUid(),this.visible=!0,this.isSelected=!1,this.$$height=r.options.rowHeight}return Object.defineProperty(e.prototype,"height",{get:function(){return this.$$height},set:function(e){e!==this.$$height&&(this.grid.updateCanvasHeight(),this.$$height=e)}}),e.prototype.getQualifiedColField=function(e){return"row."+this.getEntityQualifiedColField(e)},e.prototype.getEntityQualifiedColField=function(e){return e.field===t.ENTITY_BINDING?"entity":i.preEval("entity."+e.field)},e.prototype.setRowInvisible=function(e){e&&e.setThisRowInvisible&&e.setThisRowInvisible("user")},e.prototype.clearRowInvisible=function(e){e&&e.clearThisRowInvisible&&e.clearThisRowInvisible("user")},e.prototype.setThisRowInvisible=function(e,t){this.invisibleReason||(this.invisibleReason={}),this.invisibleReason[e]=!0,this.evaluateRowVisibility(t)},e.prototype.clearThisRowInvisible=function(e,t){void 0!==this.invisibleReason&&delete this.invisibleReason[e],this.evaluateRowVisibility(t)},e.prototype.evaluateRowVisibility=function(e){var r=!0;void 0!==this.invisibleReason&&angular.forEach(this.invisibleReason,function(e,t){e&&(r=!1)}),void 0!==this.visible&&this.visible===r||(this.visible=r,e||(this.grid.queueGridRefresh(),this.grid.api.core.raise.rowsVisibleChanged(this)))},e}]),function(){"use strict";angular.module("ui.grid").factory("GridRowColumn",["$parse","$filter",function(e,t){var r=function e(t,r){if(!(this instanceof e))throw"Using GridRowColumn as a function insead of as a constructor. Must be called with `new` keyword";this.row=t,this.col=r};return r.prototype.getIntersectionValueRaw=function(){return e(this.row.getEntityQualifiedColField(this.col))(this.row)},r}])}(),angular.module("ui.grid").factory("ScrollEvent",["gridUtil",function(a){function e(e,t,r,i){var n=this;if(!e)throw new Error("grid argument is required");n.grid=e,n.source=i,n.withDelay=!0,n.sourceRowContainer=t,n.sourceColContainer=r,n.newScrollLeft=null,n.newScrollTop=null,n.x=null,n.y=null,n.verticalScrollLength=-9999999,n.horizontalScrollLength=-999999,n.fireThrottledScrollingEvent=a.throttle(function(e){n.grid.scrollContainers(e,n)},n.grid.options.wheelScrollThrottle,{trailing:!0})}return e.prototype.getNewScrollLeft=function(e,t){var r=this;if(!r.newScrollLeft){var i,n=e.getCanvasWidth()-e.getViewportWidth(),o=a.normalizeScrollLeft(t,r.grid);if(void 0!==r.x.percentage&&void 0!==r.x.percentage)i=r.x.percentage;else{if(void 0===r.x.pixels||void 0===r.x.pixels)throw new Error("No percentage or pixel value provided for scroll event X axis");i=r.x.percentage=(o+r.x.pixels)/n}return Math.max(0,i*n)}return r.newScrollLeft},e.prototype.getNewScrollTop=function(e,t){var r=this;if(!r.newScrollTop){var i,n=e.getVerticalScrollLength(),o=t[0].scrollTop;if(void 0!==r.y.percentage&&void 0!==r.y.percentage)i=r.y.percentage;else{if(void 0===r.y.pixels||void 0===r.y.pixels)throw new Error("No percentage or pixel value provided for scroll event Y axis");i=r.y.percentage=(o+r.y.pixels)/n}return Math.max(0,i*n)}return r.newScrollTop},e.prototype.atTop=function(e){return this.y&&(0===this.y.percentage||this.verticalScrollLength<0)&&0===e},e.prototype.atBottom=function(e){return this.y&&(1===this.y.percentage||0===this.verticalScrollLength)&&0A')[0],r="reverse";return document.body.appendChild(t),0=i.length-a?new l(i[i.length-1],r[n]):new l(i[o+a],r[n])},n.prototype.getRowColUp=function(e,t){var r=this.getFocusableCols(),i=this.getFocusableRows(),n=r.indexOf(t),o=i.indexOf(e);return-1===n&&(n=0),new l(0===o?e:i[o-1],r[n])},n.prototype.getRowColPageUp=function(e,t){var r=this.getFocusableCols(),i=this.getFocusableRows(),n=r.indexOf(t),o=i.indexOf(e);-1===n&&(n=0);var a=this.bodyContainer.minRowsToRender();return new l(o-a<0?i[0]:i[o-a],r[n])},n}]),e.service("uiGridCellNavService",["gridUtil","uiGridConstants","uiGridCellNavConstants","$q","uiGridCellNavFactory","GridRowColumn","ScrollEvent",function(e,t,r,i,n,o,a){var l={initializeGrid:function(i){i.registerColumnBuilder(l.cellNavColumnBuilder),i.cellNav={},i.cellNav.lastRowCol=null,i.cellNav.focusedCells=[],l.defaultGridOptions(i.options);var e={events:{cellNav:{navigate:function(e,t){},viewPortKeyDown:function(e,t){},viewPortKeyPress:function(e,t){}}},methods:{cellNav:{scrollToFocus:function(e,t){return l.scrollToFocus(i,e,t)},getFocusedCell:function(){return i.cellNav.lastRowCol},getCurrentSelection:function(){return i.cellNav.focusedCells},rowColSelectIndex:function(e){for(var t=-1,r=0;r ',g=a(n)(e),t.prepend(g),e.$on(u.CELL_NAV_EVENT,function(e,t,r,i){if(!i||"focus"!==i.type){for(var n,o,a=[],l=p.api.cellNav.getCurrentSelection(),s=0;s')(e);t.append(d),d.on("focus",function(e){e.uiGridTargetRenderContainerId=l;var t=n.grid.api.cellNav.getFocusedCell();null===t&&(t=n.grid.renderContainers[l].cellNav.getNextRowCol(m.direction.DOWN,null,null)).row&&t.col&&n.cellNav.broadcastCellNav(t)}),a.setAriaActivedescendant=function(e){t.attr("aria-activedescendant",e)},a.removeAriaActivedescendant=function(e){t.attr("aria-activedescendant")===e&&t.attr("aria-activedescendant","")},n.focus=function(){g.focus.byElement(d[0])};var u=null;d.on("keydown",function(r){r.uiGridTargetRenderContainerId=l;var e=n.grid.api.cellNav.getFocusedCell();null===(n.grid.options.keyDownOverrides.some(function(t){return Object.keys(t).every(function(e){return t[e]===r[e]})})?null:n.cellNav.handleKeyDown(r))&&(n.grid.api.cellNav.raise.viewPortKeyDown(r,e,n.cellNav.handleKeyDown),u=e)}),d.on("keypress",function(e){u&&(c(function(){n.grid.api.cellNav.raise.viewPortKeyPress(e,u)},4),u=null)}),e.$on("$destroy",function(){d.off()})}}}}}}}]),e.directive("uiGridViewport",["$timeout","$document","gridUtil","uiGridConstants","uiGridCellNavService","uiGridCellNavConstants","$log","$compile",function(e,t,r,i,n,o,a,l){return{replace:!0,priority:-99999,require:["^uiGrid","^uiGridRenderContainer","?^uiGridCellnav"],scope:!1,compile:function(){return{pre:function(e,t,r,i){},post:function(e,t,r,i){var n=i[0],o=i[1];if(n.grid.api.cellNav&&"body"===o.containerId){var a=n.grid;a.api.core.on.scrollBegin(e,function(e){var t=n.grid.api.cellNav.getFocusedCell();null!==t&&o.colContainer.containsColumn(t.col)&&n.cellNav.clearFocus()}),a.api.core.on.scrollEnd(e,function(e){var t=n.grid.api.cellNav.getFocusedCell();null!==t&&o.colContainer.containsColumn(t.col)&&n.cellNav.broadcastCellNav(t)}),a.api.cellNav.on.navigate(e,function(){n.focus()})}}}}}}]),e.directive("uiGridCell",["$timeout","$document","uiGridCellNavService","gridUtil","uiGridCellNavConstants","uiGridConstants","GridRowColumn",function(e,t,r,i,c,g,p){return{priority:-150,restrict:"A",require:["^uiGrid","?^uiGridCellnav"],scope:!1,link:function(r,t,e,i){var n=i[0],o=i[1];if(n.grid.api.cellNav&&r.col.colDef.allowCellFocus){var a=n.grid;r.focused=!1,t.attr("tabindex",-1),t.find("div").on("click",function(e){n.cellNav.broadcastCellNav(new p(r.row,r.col),e.ctrlKey||e.metaKey,e),e.stopPropagation(),r.$apply()}),t.on("mousedown",s),n.grid.api.edit&&(n.grid.api.edit.on.beginCellEdit(r,function(){t.off("mousedown",s)}),n.grid.api.edit.on.afterCellEdit(r,function(){t.on("mousedown",s)}),n.grid.api.edit.on.cancelCellEdit(r,function(){t.on("mousedown",s)})),d(),t.on("focus",function(e){n.cellNav.broadcastCellNav(new p(r.row,r.col),!1,e),e.stopPropagation(),r.$apply()}),r.$on(c.CELL_NAV_EVENT,d);var l=n.grid.registerDataChangeCallback(function(e){u(),r.$applyAsync(d)},[g.dataChange.ROW]);r.$on("$destroy",function(){l(),t.find("div").off(),t.off()})}function s(e){e.preventDefault()}function d(){a.cellNav.focusedCells.some(function(e,t){return e.row===r.row&&e.col===r.col})?function(){if(!r.focused){var e=t.find("div");e.addClass("ui-grid-cell-focus"),t.attr("aria-selected",!0),o.setAriaActivedescendant(t.attr("id")),r.focused=!0}}():u()}function u(){r.focused&&(t.find("div").removeClass("ui-grid-cell-focus"),t.attr("aria-selected",!1),o.removeAriaActivedescendant(t.attr("id")),r.focused=!1)}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.edit",["ui.grid"]);e.constant("uiGridEditConstants",{EDITABLE_CELL_TEMPLATE:/EDITABLE_CELL_TEMPLATE/g,EDITABLE_CELL_DIRECTIVE:/editable_cell_directive/g,events:{BEGIN_CELL_EDIT:"uiGridEventBeginCellEdit",END_CELL_EDIT:"uiGridEventEndCellEdit",CANCEL_CELL_EDIT:"uiGridEventCancelCellEdit"}}),e.service("uiGridEditService",["$q","uiGridConstants","gridUtil",function(n,t,o){var r={initializeGrid:function(e){r.defaultGridOptions(e.options),e.registerColumnBuilder(r.editColumnBuilder),e.edit={};e.api.registerEventsFromObject({edit:{afterCellEdit:function(e,t,r,i){},beginCellEdit:function(e,t,r){},cancelCellEdit:function(e,t){}}})},defaultGridOptions:function(e){e.cellEditableCondition=void 0===e.cellEditableCondition||e.cellEditableCondition,e.enableCellEditOnFocus=void 0!==e.enableCellEditOnFocus&&e.enableCellEditOnFocus},editColumnBuilder:function(t,r,e){var i=[];return t.enableCellEdit=void 0===t.enableCellEdit?void 0===e.enableCellEdit?"object"!==t.type:e.enableCellEdit:t.enableCellEdit,t.cellEditableCondition=void 0===t.cellEditableCondition?e.cellEditableCondition:t.cellEditableCondition,t.enableCellEdit&&(t.editableCellTemplate=t.editableCellTemplate||e.editableCellTemplate||"ui-grid/cellEditor",i.push(o.getTemplate(t.editableCellTemplate).then(function(e){r.editableCellTemplate=e},function(e){throw new Error("Couldn't fetch/use colDef.editableCellTemplate '"+t.editableCellTemplate+"'")}))),t.enableCellEditOnFocus=void 0===t.enableCellEditOnFocus?e.enableCellEditOnFocus:t.enableCellEditOnFocus,n.all(i)},isStartEditKey:function(e){return!(e.metaKey||e.keyCode===t.keymap.ESC||e.keyCode===t.keymap.SHIFT||e.keyCode===t.keymap.CTRL||e.keyCode===t.keymap.ALT||e.keyCode===t.keymap.WIN||e.keyCode===t.keymap.CAPSLOCK||e.keyCode===t.keymap.LEFT||e.keyCode===t.keymap.TAB&&e.shiftKey||e.keyCode===t.keymap.RIGHT||e.keyCode===t.keymap.TAB||e.keyCode===t.keymap.UP||e.keyCode===t.keymap.ENTER&&e.shiftKey||e.keyCode===t.keymap.DOWN||e.keyCode===t.keymap.ENTER)}};return r}]),e.directive("uiGridEdit",["gridUtil","uiGridEditService",function(e,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(i.grid)},post:function(e,t,r,i){}}}}}]),e.directive("uiGridViewport",["uiGridEditConstants",function(o){return{replace:!0,priority:-99998,require:["^uiGrid","^uiGridRenderContainer"],scope:!1,compile:function(){return{post:function(e,t,r,i){var n=i[0];n.grid.api.edit&&n.grid.api.cellNav&&("body"===i[1].containerId&&(e.$on(o.events.CANCEL_CELL_EDIT,function(){n.focus()}),e.$on(o.events.END_CELL_EDIT,function(){n.focus()})))}}}}}]),e.directive("uiGridCell",["$compile","$injector","$timeout","uiGridConstants","uiGridEditConstants","gridUtil","$parse","uiGridEditService","$rootScope","$q",function(S,e,x,E,A,R,T,g,F,P){var D=500;if(e.has("uiGridCellNavService"))e.get("uiGridCellNavService");return{priority:-100,restrict:"A",scope:!1,require:"?^uiGrid",link:function(p,f,e,i){var m,h,v,t,C,w=!1;if(p.col.colDef.enableCellEdit){var r=function(){},n=function(){},o=function(){p.col.colDef.enableCellEdit&&!1!==p.row.enableCellEdit?p.beginEditEventsWired||l():p.beginEditEventsWired&&b()};o();var a=p.$watch("row",function(e,t){e!==t&&o()});p.$on("$destroy",function(){a(),f.off()})}function l(){f.on("dblclick",c),f.on("touchstart",s),i&&i.grid.api.cellNav&&(n=i.grid.api.cellNav.on.viewPortKeyDown(p,function(e,t){null!==t&&(t.row!==p.row||t.col!==p.col||p.col.colDef.enableCellEditOnFocus||u(e))}),r=i.grid.api.cellNav.on.navigate(p,function(e,t,r){p.col.colDef.enableCellEditOnFocus&&(e.row!==p.row||e.col!==p.col||null!==r&&(!r||"click"!==r.type&&"keydown"!==r.type)||x(function(){c(r)}))})),p.beginEditEventsWired=!0}function s(e){void 0!==e.originalEvent&&void 0!==e.originalEvent&&(e=e.originalEvent),f.on("touchend",d),(t=x(function(){},D)).then(function(){setTimeout(c,0),f.off("touchend",d)})}function d(e){x.cancel(t),f.off("touchend",d)}function b(){f.off("dblclick",c),f.off("keydown",u),f.off("touchstart",s),r(),n(),p.beginEditEventsWired=!1}function u(e){g.isStartEditKey(e)&&c(e)}function c(e){p.grid.api.core.scrollToIfNecessary(p.row,p.col).then(function(){!function(e){if(w)return;if(t=p.col,r=p.row,i=e,r.isSaving||(angular.isFunction(t.colDef.cellEditableCondition)?!t.colDef.cellEditableCondition(p,i):!t.colDef.cellEditableCondition))return;var t,r,i;var n=p.row.getQualifiedColField(p.col);p.col.colDef.editModelField&&(n=R.preEval("row.entity."+p.col.colDef.editModelField));v=T(n),h=v(p),m=(m=(m=p.col.editableCellTemplate).replace(E.MODEL_COL_FIELD,n)).replace(E.COL_FIELD,"grid.getCellValue(row, col)");var o=p.col.colDef.editDropdownFilter?"|"+p.col.colDef.editDropdownFilter:"";m=m.replace(E.CUSTOM_FILTERS,o);var a="text";switch(p.col.colDef.type){case"boolean":a="checkbox";break;case"number":a="number";break;case"date":a="date"}m=m.replace("INPUT_TYPE",a);var l=p.col.colDef.editDropdownOptionsFunction;if(l)P.when(l(p.row.entity,p.col.colDef)).then(function(e){p.editDropdownOptionsArray=e});else{var s=p.col.colDef.editDropdownRowEntityOptionsArrayPath;p.editDropdownOptionsArray=s?function(e,t){var r=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split(".");for(;r.length;){var i=r.shift();if(!(i in e))return;e=e[i]}return e}(p.row.entity,s):p.col.colDef.editDropdownOptionsArray}p.editDropdownIdLabel=p.col.colDef.editDropdownIdLabel?p.col.colDef.editDropdownIdLabel:"id",p.editDropdownValueLabel=p.col.colDef.editDropdownValueLabel?p.col.colDef.editDropdownValueLabel:"value";var d=function(){w=!0,b();var e=angular.element(m);f.append(e),C=p.$new(),S(e)(C);var t=angular.element(f.children()[0]);t.addClass("ui-grid-cell-contents-hidden")};F.$$phase?d():p.$apply(d);var u=p.col.grid.api.core.on.scrollBegin(p,function(){p.grid.disableScrolling||(y(),p.grid.api.edit.raise.afterCellEdit(p.row.entity,p.col.colDef,v(p),h),u(),c(),g())}),c=p.$on(A.events.END_CELL_EDIT,function(){y(),p.grid.api.edit.raise.afterCellEdit(p.row.entity,p.col.colDef,v(p),h),c(),u(),g()}),g=p.$on(A.events.CANCEL_CELL_EDIT,function(){!function(){if(p.grid.disableScrolling=!1,!w)return;v.assign(p,h),p.$apply(),p.grid.api.edit.raise.cancelCellEdit(p.row.entity,p.col.colDef),y()}(),g(),u(),c()});p.$broadcast(A.events.BEGIN_CELL_EDIT,e),x(function(){p.grid.api.edit.raise.beginCellEdit(p.row.entity,p.col.colDef,e)})}(e)})}function y(){if(p.grid.disableScrolling=!1,w){i&&i.grid.api.cellNav&&i.focus();var e=angular.element(f.children()[0]);C.$destroy();for(var t=f.children(),r=1;r 1 or < 1 file choosers within the menu item, error, cannot continue"):o[0].addEventListener("change",function(e){var t=e.srcElement||e.target;if(t&&t.files&&1===t.files.length){var r=t.files[0];void 0!==i&&i?(n=i.grid,a.importThisFile(n,r),t.form.reset()):l.logError("Could not import file because UI Grid was not found.")}},!1)}}}])}(),function(){"use strict";var e=angular.module("ui.grid.infiniteScroll",["ui.grid"]);e.service("uiGridInfiniteScrollService",["gridUtil","$compile","$rootScope","uiGridConstants","ScrollEvent","$q",function(e,t,l,s,a,r){var d={initializeGrid:function(r,e){if(d.defaultGridOptions(r.options),r.options.enableInfiniteScroll){r.infiniteScroll={dataLoading:!1},d.setScrollDirections(r,r.options.infiniteScrollUp,r.options.infiniteScrollDown),r.api.core.on.scrollEnd(e,d.handleScroll);var t={events:{infiniteScroll:{needLoadMoreData:function(e,t){},needLoadMoreDataTop:function(e,t){}}},methods:{infiniteScroll:{dataLoaded:function(e,t){return d.setScrollDirections(r,e,t),d.adjustScroll(r).then(function(){r.infiniteScroll.dataLoading=!1})},resetScroll:function(e,t){d.setScrollDirections(r,e,t),d.adjustInfiniteScrollPosition(r,0)},saveScrollPercentage:function(){r.infiniteScroll.prevScrollTop=r.renderContainers.body.prevScrollTop,r.infiniteScroll.previousVisibleRows=r.getVisibleRowCount()},dataRemovedTop:function(e,t){d.dataRemovedTop(r,e,t)},dataRemovedBottom:function(e,t){d.dataRemovedBottom(r,e,t)},setScrollDirections:function(e,t){d.setScrollDirections(r,e,t)}}}};r.api.registerEventsFromObject(t.events),r.api.registerMethodsFromObject(t.methods)}},defaultGridOptions:function(e){e.enableInfiniteScroll=!1!==e.enableInfiniteScroll,e.infiniteScrollRowsFromEnd=e.infiniteScrollRowsFromEnd||20,e.infiniteScrollUp=!0===e.infiniteScrollUp,e.infiniteScrollDown=!1!==e.infiniteScrollDown},setScrollDirections:function(e,t,r){e.infiniteScroll.scrollUp=!0===t,e.suppressParentScrollUp=!0===t,e.infiniteScroll.scrollDown=!1!==r,e.suppressParentScrollDown=!1!==r},handleScroll:function(e){if(!(e.grid.infiniteScroll&&e.grid.infiniteScroll.dataLoading||"ui.grid.adjustInfiniteScrollPosition"===e.source)&&e.y)if(0===e.y.percentage)e.grid.scrollDirection=s.scrollDirection.UP,d.loadData(e.grid);else if(1===e.y.percentage)e.grid.scrollDirection=s.scrollDirection.DOWN,d.loadData(e.grid);else{var t=e.grid.options.infiniteScrollRowsFromEnd/e.grid.renderContainers.body.visibleRowCache.length;e.grid.scrollDirection===s.scrollDirection.UP?e.y.percentage<=t&&d.loadData(e.grid):e.grid.scrollDirection===s.scrollDirection.DOWN&&1-e.y.percentage<=t&&d.loadData(e.grid)}},loadData:function(e){e.infiniteScroll.previousVisibleRows=e.renderContainers.body.visibleRowCache.length,e.infiniteScroll.direction=e.scrollDirection,delete e.infiniteScroll.prevScrollTop,e.scrollDirection===s.scrollDirection.UP&&e.infiniteScroll.scrollUp?(e.infiniteScroll.dataLoading=!0,e.api.infiniteScroll.raise.needLoadMoreDataTop()):e.scrollDirection===s.scrollDirection.DOWN&&e.infiniteScroll.scrollDown&&(e.infiniteScroll.dataLoading=!0,e.api.infiniteScroll.raise.needLoadMoreData())},adjustScroll:function(o){var a=r.defer();return l.$applyAsync(function(){var e,t,r,i;e=o.getViewportHeight()+o.headerHeight-o.renderContainers.body.headerHeight-o.scrollbarHeight,t=o.options.rowHeight,void 0===o.infiniteScroll.direction&&d.adjustInfiniteScrollPosition(o,0);var n=t*(r=o.getVisibleRowCount());o.infiniteScroll.scrollDown&&n=i.length-r||t>=i.length-r)s.logError("MoveColumn: Invalid values for originalPosition, finalPosition");else{var o=function(e){for(var t=e,r=0;r<=t;r++)angular.isDefined(i[r])&&(angular.isDefined(i[r].colDef.visible)&&!1===i[r].colDef.visible||!0===i[r].isRowHeader)&&t++;return t};l.redrawColumnAtPosition(a,o(e),o(t))}}else s.logError("MoveColumn: Please provide valid values for originalPosition and finalPosition")}}}};a.api.registerEventsFromObject(e.events),a.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enableColumnMoving=!1!==e.enableColumnMoving},movableColumnBuilder:function(e,t,r){return e.enableColumnMoving=void 0===e.enableColumnMoving?r.enableColumnMoving:e.enableColumnMoving,i.all([])},updateColumnCache:function(e){e.moveColumns.orderCache=e.getOnlyDataColumns()},verifyColumnOrder:function(i){var n,o=i.rowHeaderColumns.length;angular.forEach(i.moveColumns.orderCache,function(e,t){if(-1!==(n=i.columns.indexOf(e))&&n-o!==t){var r=i.columns.splice(n,1)[0];i.columns.splice(t+o,0,r)}})},redrawColumnAtPosition:function(e,t,r){var i=e.columns;if(t!==r){for(var n=tMath.max(n,r))){var a=i[t];if(a.colDef.enableColumnMoving){if(rMath.abs(p)){b.redrawColumnAtPosition(u.grid,i,o-1);break}}else for(o=i-1;0<=o;o--)if((angular.isUndefined(r[o].colDef.visible)||!0===r[o].colDef.visible)&&(a+=r[o].drawnWidth||r[o].width||r[o].colDef.width)>Math.abs(p)){b.redrawColumnAtPosition(u.grid,i,o+1);break}aMath.ceil(c.grid.gridWidth)){e*=8;var l=new S(u.col.grid,null,null,"uiGridHeaderCell.moveElement");l.x={pixels:e},l.grid.scrollContainers("",l)}for(var s=0,d=0;dr.length&&(i=((o.options.paginationCurrentPage=1)-1)*t),r.slice(i,n+1)},900)},defaultGridOptions:function(e){e.enablePagination=!1!==e.enablePagination,e.enablePaginationControls=!1!==e.enablePaginationControls,e.useExternalPagination=!0===e.useExternalPagination,e.useCustomPagination=!0===e.useCustomPagination,t.isNullOrUndefined(e.totalItems)&&(e.totalItems=0),t.isNullOrUndefined(e.paginationPageSizes)&&(e.paginationPageSizes=[250,500,1e3]),t.isNullOrUndefined(e.paginationPageSize)&&(0r.paginationApi.getTotalPages()?o.paginationCurrentPage=r.paginationApi.getTotalPages():d.onPaginationChanged(r.grid,o.paginationCurrentPage,o.paginationPageSize))});r.$on("$destroy",function(){l()}),r.cantPageForward=function(){return r.paginationApi.getTotalPages()?r.cantPageToLast():o.data.length<1},r.cantPageToLast=function(){var e=r.paginationApi.getTotalPages();return!e||o.paginationCurrentPage>=e},r.cantPageBackward=function(){return o.paginationCurrentPage<=1};var s=function(e){e&&c.focus.bySelector(t,".ui-grid-pager-control-input")};r.pageFirstPageClick=function(){r.paginationApi.seek(1),s(r.cantPageBackward())},r.pagePreviousPageClick=function(){r.paginationApi.previousPage(),s(r.cantPageBackward())},r.pageNextPageClick=function(){r.paginationApi.nextPage(),s(r.cantPageForward())},r.pageLastPageClick=function(){r.paginationApi.seek(r.paginationApi.getTotalPages()),s(r.cantPageToLast())}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.pinning",["ui.grid"]);e.constant("uiGridPinningConstants",{container:{LEFT:"left",RIGHT:"right",NONE:""}}),e.service("uiGridPinningService",["gridUtil","GridRenderContainer","i18nService","uiGridPinningConstants",function(a,e,l,s){var d={initializeGrid:function(r){d.defaultGridOptions(r.options),r.registerColumnBuilder(d.pinningColumnBuilder);var e={events:{pinning:{columnPinned:function(e,t){}}},methods:{pinning:{pinColumn:function(e,t){d.pinColumn(r,e,t)}}}};r.api.registerEventsFromObject(e.events),r.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enablePinning=!1!==e.enablePinning,e.hidePinLeft=e.enablePinning&&e.hidePinLeft,e.hidePinRight=e.enablePinning&&e.hidePinRight},pinningColumnBuilder:function(e,t,r){if(e.enablePinning=void 0===e.enablePinning?r.enablePinning:e.enablePinning,e.hidePinLeft=void 0===e.hidePinLeft?r.hidePinLeft:e.hidePinLeft,e.hidePinRight=void 0===e.hidePinRight?r.hidePinRight:e.hidePinRight,e.pinnedLeft?(t.renderContainer="left",t.grid.createLeftContainer()):e.pinnedRight&&(t.renderContainer="right",t.grid.createRightContainer()),e.enablePinning){var i={name:"ui.grid.pinning.pinLeft",title:l.get().pinning.pinLeft,icon:"ui-grid-icon-left-open",shown:function(){return void 0===this.context.col.renderContainer||!this.context.col.renderContainer||"left"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.LEFT)}},n={name:"ui.grid.pinning.pinRight",title:l.get().pinning.pinRight,icon:"ui-grid-icon-right-open",shown:function(){return void 0===this.context.col.renderContainer||!this.context.col.renderContainer||"right"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.RIGHT)}},o={name:"ui.grid.pinning.unpin",title:l.get().pinning.unpin,icon:"ui-grid-icon-cancel",shown:function(){return void 0!==this.context.col.renderContainer&&null!==this.context.col.renderContainer&&"body"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.NONE)}};e.hidePinLeft||a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.pinLeft")||t.menuItems.push(i),e.hidePinRight||a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.pinRight")||t.menuItems.push(n),a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.unpin")||t.menuItems.push(o)}},pinColumn:function(e,t,r){r===s.container.NONE?(t.renderContainer=null,t.colDef.pinnedLeft=t.colDef.pinnedRight=!1):(t.renderContainer=r)===s.container.LEFT?e.createLeftContainer():r===s.container.RIGHT&&e.createRightContainer(),e.refresh().then(function(){e.api.pinning.raise.columnPinned(t.colDef,r)})}};return d}]),e.directive("uiGridPinning",["gridUtil","uiGridPinningService",function(e,n){return{require:"uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(i.grid)},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.resizeColumns",["ui.grid"]);e.service("uiGridResizeColumnsService",["gridUtil","$q","$rootScope",function(i,n,o){return{defaultGridOptions:function(e){e.enableColumnResizing=!1!==e.enableColumnResizing,!1===e.enableColumnResize&&(e.enableColumnResizing=!1)},colResizerColumnBuilder:function(e,t,r){return e.enableColumnResizing=void 0===e.enableColumnResizing?r.enableColumnResizing:e.enableColumnResizing,!1===e.enableColumnResize&&(e.enableColumnResizing=!1),n.all([])},registerPublicApi:function(e){e.api.registerEventsFromObject({colResizable:{columnSizeChanged:function(e,t){}}})},fireColumnSizeChanged:function(e,t,r){o.$applyAsync(function(){e.api.colResizable?e.api.colResizable.raise.columnSizeChanged(t,r):i.logError("The resizeable api is not registered, this may indicate that you've included the module but not added the 'ui-grid-resize-columns' directive to your grid definition. Cannot raise any events.")})},findTargetCol:function(e,t,r){var i=e.getRenderContainer();if("left"===t){var n=i.visibleColumnCache.indexOf(e);return i.visibleColumnCache[n-1*r]}return e}}}]),e.directive("uiGridResizeColumns",["gridUtil","uiGridResizeColumnsService",function(e,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.defaultGridOptions(i.grid.options),i.grid.registerColumnBuilder(n.colResizerColumnBuilder),n.registerPublicApi(i.grid)},post:function(e,t,r,i){}}}}}]),e.directive("uiGridHeaderCell",["gridUtil","$templateCache","$compile","$q","uiGridResizeColumnsService","uiGridConstants",function(e,o,u,t,c,g){return{priority:-10,require:"^uiGrid",compile:function(){return{post:function(a,l,e,t){var r=t.grid;if(r.options.enableColumnResizing){var s=o.get("ui-grid/columnResizer"),d=1;r.isRTL()&&(a.position="left",d=-1);var i=function(){for(var e=l[0].getElementsByClassName("ui-grid-column-resizer"),t=0;t');return{priority:0,scope:{col:"=",position:"@",renderIndex:"="},require:"?^uiGrid",link:function(l,s,e,d){var o=0,a=0,u=0,c=1;function g(e){d.grid.refreshCanvas(!0).then(function(){d.grid.queueGridRefresh()})}function p(e,t){var r=t;return e.minWidth&&re.maxWidth&&(r=e.maxWidth),r}function r(e,t){e.originalEvent&&(e=e.originalEvent),e.preventDefault(),(a=(e.targetTouches?e.targetTouches[0]:e).clientX-u)<0?a=0:a>d.grid.gridWidth&&(a=d.grid.gridWidth);var r=w.findTargetCol(l.col,l.position,c);if(!1!==r.colDef.enableColumnResizing){d.grid.element.hasClass("column-resizing")||d.grid.element.addClass("column-resizing");var i=a-o,n=parseInt(r.drawnWidth+i*c,10);a+=(p(r,n)-n)*c,b.css({left:a+"px"}),d.fireEvent(C.events.ITEM_DRAGGING)}}function i(e,t){e.originalEvent&&(e=e.originalEvent),e.preventDefault(),d.grid.element.removeClass("column-resizing"),b.remove();var r=(a=(e.changedTouches?e.changedTouches[0]:e).clientX-u)-o;if(0===r)return m(),void f();var i=w.findTargetCol(l.col,l.position,c);if(!1!==i.colDef.enableColumnResizing){var n=parseInt(i.drawnWidth+r*c,10);i.width=p(i,n),i.hasCustomWidth=!0,g(),w.fireColumnSizeChanged(d.grid,i.colDef,r),m(),f()}}d.grid.isRTL()&&(l.position="left",c=-1),"left"===l.position?s.addClass("left"):"right"===l.position&&s.addClass("right");var n=function(e,t){e.originalEvent&&(e=e.originalEvent),e.stopPropagation(),u=d.grid.element[0].getBoundingClientRect().left,o=(e.targetTouches?e.targetTouches[0]:e).clientX-u,d.grid.element.append(b),b.css({left:o}),"touchstart"===e.type?(h.on("touchend",i),h.on("touchmove",r),s.off("mousedown",n)):(h.on("mouseup",i),h.on("mousemove",r),s.off("touchstart",n))},f=function(){s.on("mousedown",n),s.on("touchstart",n)},m=function(){h.off("mouseup",i),h.off("touchend",i),h.off("mousemove",r),h.off("touchmove",r),s.off("mousedown",n),s.off("touchstart",n)};f();var t=function(e,t){e.stopPropagation();var r=w.findTargetCol(l.col,l.position,c);if(!1!==r.colDef.enableColumnResizing){var i,n=0,o=v.closestElm(s,".ui-grid-render-container").querySelectorAll("."+C.COL_CLASS_PREFIX+r.uid+" .ui-grid-cell-contents");Array.prototype.forEach.call(o,function(e){var i;angular.element(e).parent().hasClass("ui-grid-header-cell")&&(i=angular.element(e).parent()[0].querySelectorAll(".ui-grid-column-menu-button")),v.fakeElement(e,{},function(e){var t=angular.element(e);t.attr("style","float: left");var r=v.elementWidth(t);i&&(r+=v.elementWidth(i));ne.value||null===e.value)&&(e.value=t)}},avg:{label:n.get().aggregation.avg,menuTitle:n.get().grouping.aggregate_avg,aggregationFn:function(e,t,r){void 0===e.count?e.count=1:e.count++,isNaN(r)||(void 0===e.value||void 0===e.sum?(e.value=r,e.sum=r):(e.sum+=r,e.value=e.sum/e.count))}}}},finaliseAggregation:function(e,t){t.col.treeAggregationUpdateEntity&&void 0!==e&&void 0!==e.entity["$$"+t.col.uid]&&angular.extend(t,e.entity["$$"+t.col.uid]),"function"==typeof t.col.treeAggregationFinalizerFn&&t.col.treeAggregationFinalizerFn(t),"function"==typeof t.col.customTreeAggregationFinalizerFn&&t.col.customTreeAggregationFinalizerFn(t),void 0===t.rendered&&(t.rendered=t.label?t.label+t.value:t.value)},finaliseAggregations:function(e){null!=e&&void 0!==e.treeNode.aggregations&&e.treeNode.aggregations.forEach(function(r){if(s.finaliseAggregation(e,r),r.col.treeAggregationUpdateEntity){var i={};angular.forEach(r,function(e,t){r.hasOwnProperty(t)&&"col"!==t&&(i[t]=e)}),e.entity["$$"+r.col.uid]=i}})},treeFooterAggregationType:function(e,t){return s.finaliseAggregation(void 0,t.treeFooterAggregation),void 0===t.treeFooterAggregation.value||null===t.treeFooterAggregation.rendered?"":t.treeFooterAggregation.rendered}};return s}]),e.directive("uiGridTreeBaseRowHeaderButtons",["$templateCache","uiGridTreeBaseService",function(e,o){return{replace:!0,restrict:"E",template:e.get("ui-grid/treeBaseRowHeaderButtons"),scope:!0,require:"^uiGrid",link:function(e,t,r,i){var n=i.grid;e.treeButtonClass=function(e){if(n.options.showTreeExpandNoChildren&&-1 -1}":"{'ui-grid-tree-header-row': row.treeLevel > -1}",r.attr("ng-class",n),{pre:function(e,t,r,i){},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.treeView",["ui.grid","ui.grid.treeBase"]);e.constant("uiGridTreeViewConstants",{featureName:"treeView",rowHeaderColName:"treeBaseRowHeaderCol",EXPANDED:"expanded",COLLAPSED:"collapsed",aggregation:{COUNT:"count",SUM:"sum",MAX:"max",MIN:"min",AVG:"avg"}}),e.service("uiGridTreeViewService",["$q","uiGridTreeViewConstants","uiGridTreeBaseConstants","uiGridTreeBaseService","gridUtil","GridRow","gridClassFactory","i18nService","uiGridConstants",function(e,t,r,n,i,o,a,l,s){var d={initializeGrid:function(e,t){n.initializeGrid(e,t),e.treeView={},e.registerRowsProcessor(d.adjustSorting,60);var r={treeView:{}},i={treeView:{}};e.api.registerEventsFromObject(r),e.api.registerMethodsFromObject(i)},defaultGridOptions:function(e){e.enableTreeView=!1!==e.enableTreeView},adjustSorting:function(e){return this.columns.forEach(function(e){e.sort&&(e.sort.ignoreSort=!0)}),e}};return d}]),e.directive("uiGridTreeView",["uiGridTreeViewConstants","uiGridTreeViewService","$templateCache",function(e,n,t){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){!1!==i.grid.options.enableTreeView&&n.initializeGrid(i.grid,e)},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.validate",["ui.grid"]);e.service("uiGridValidateService",["$sce","$q","$http","i18nService","uiGridConstants",function(n,u,e,o,t){var c={validatorFactories:{},setExternalFactoryFunction:function(e){c.externalFactoryFunction=e},clearExternalFactory:function(){delete c.externalFactoryFunction},getValidatorFromExternalFactory:function(e,t){return c.externalFactoryFunction(e,t).validatorFactory(t)},getMessageFromExternalFactory:function(e,t){return c.externalFactoryFunction(e,t).messageFunction(t)},setValidator:function(e,t,r){c.validatorFactories[e]={validatorFactory:t,messageFunction:r}},getValidator:function(e,t){if(c.externalFactoryFunction){var r=c.getValidatorFromExternalFactory(e,t);if(r)return r}if(!c.validatorFactories[e])throw"Invalid validator name: "+e;return c.validatorFactories[e].validatorFactory(t)},getMessage:function(e,t){if(c.externalFactoryFunction){var r=c.getMessageFromExternalFactory(e,t);if(r)return r}return c.validatorFactories[e].messageFunction(t)},isInvalid:function(e,t){return e["$$invalid"+t.name]},setInvalid:function(e,t){e["$$invalid"+t.name]=!0},setValid:function(e,t){delete e["$$invalid"+t.name]},setError:function(e,t,r){e["$$errors"+t.name]||(e["$$errors"+t.name]={}),e["$$errors"+t.name][r]=!0},clearError:function(e,t,r){e["$$errors"+t.name]&&r in e["$$errors"+t.name]&&delete e["$$errors"+t.name][r]},getErrorMessages:function(e,t){var r=[];return e["$$errors"+t.name]&&0!==Object.keys(e["$$errors"+t.name]).length&&Object.keys(e["$$errors"+t.name]).sort().forEach(function(e){r.push(c.getMessage(e,t.validators[e]))}),r},getFormattedErrors:function(e,t){var r="",i=c.getErrorMessages(e,t);if(i.length)return i.forEach(function(e){r+=e+"
    "}),n.trustAsHtml("

    "+o.getSafeText("validate.error")+"

    "+r)},getTitleFormattedErrors:function(e,t){var r="",i=c.getErrorMessages(e,t);if(i.length)return i.forEach(function(e){r+=e+"\n"}),n.trustAsHtml(o.getSafeText("validate.error")+"\n"+r)},runValidators:function(e,t,n,o,a){if(n!==o){if(void 0===t.name||!t.name)throw new Error("colDef.name is required to perform validation");c.setValid(e,t);var r=function(t,r,i){return function(e){e||(c.setInvalid(t,r),c.setError(t,r,i),a&&a.api.validate.raise.validationFailed(t,r,n,o))}},i=[];for(var l in t.validators){c.clearError(e,t,l);var s=c.getValidator(l,t.validators[l]),d=u.when(s(o,n,e,t)).then(r(e,t,l));i.push(d)}return u.all(i)}},createDefaultValidators:function(){c.setValidator("minLength",function(n){return function(e,t,r,i){return null==t||""===t||t.length>=n}},function(e){return o.getSafeText("validate.minLength").replace("THRESHOLD",e)}),c.setValidator("maxLength",function(n){return function(e,t,r,i){return null==t||""===t||t.length<=n}},function(e){return o.getSafeText("validate.maxLength").replace("THRESHOLD",e)}),c.setValidator("required",function(n){return function(e,t,r,i){return!n||!(null==t||""===t)}},function(e){return o.getSafeText("validate.required")})},initializeGrid:function(e,n){n.validate={isInvalid:c.isInvalid,getFormattedErrors:c.getFormattedErrors,getTitleFormattedErrors:c.getTitleFormattedErrors,runValidators:c.runValidators};var t={events:{validate:{validationFailed:function(e,t,r,i){}}},methods:{validate:{isInvalid:function(e,t){return n.validate.isInvalid(e,t)},getErrorMessages:function(e,t){return n.validate.getErrorMessages(e,t)},getFormattedErrors:function(e,t){return n.validate.getFormattedErrors(e,t)},getTitleFormattedErrors:function(e,t){return n.validate.getTitleFormattedErrors(e,t)}}}};n.api.registerEventsFromObject(t.events),n.api.registerMethodsFromObject(t.methods),n.edit&&n.api.edit.on.afterCellEdit(e,function(e,t,r,i){n.validate.runValidators(e,t,r,i,n)}),c.createDefaultValidators()}};return c}]),e.directive("uiGridValidate",["gridUtil","uiGridValidateService",function(e,n){return{priority:0,replace:!0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(e,i.grid)},post:function(e,t,r,i){}}}}}])}(),angular.module("ui.grid").run(["$templateCache",function(e){"use strict";e.put("ui-grid/ui-grid-filter",'
     
     
    '),e.put("ui-grid/ui-grid-footer",''),e.put("ui-grid/ui-grid-grid-footer",''),e.put("ui-grid/ui-grid-header",'
    \x3c!-- theader --\x3e
    '),e.put("ui-grid/ui-grid-menu-button",'
     
    '),e.put("ui-grid/ui-grid-menu-header-item",'
  • '),e.put("ui-grid/ui-grid-no-header",'
    '),e.put("ui-grid/ui-grid-row","
    "),e.put("ui-grid/ui-grid",'
    \x3c!-- TODO (c0bra): add "scoped" attr here, eventually? --\x3e
    '),e.put("ui-grid/uiGridCell",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/uiGridColumnMenu",'
    \x3c!--
    \n
    \n
      \n
      \n
    • Sort Ascending
    • \n
    • Sort Descending
    • \n
    • Remove Sort
    • \n
      \n
    \n
    \n
    --\x3e
    '),e.put("ui-grid/uiGridFooterCell",'
    {{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}
    '),e.put("ui-grid/uiGridHeaderCell",'
    {{ col.displayName CUSTOM_FILTERS }} {{col.sort.priority + 1}}
    '),e.put("ui-grid/uiGridMenu",'
    '),e.put("ui-grid/uiGridMenuItem",''),e.put("ui-grid/uiGridRenderContainer","
    \x3c!-- All of these dom elements are replaced in place --\x3e
    "),e.put("ui-grid/uiGridViewport",'
    \x3c!-- tbody --\x3e
    '),e.put("ui-grid/cellEditor",'
    '),e.put("ui-grid/dropdownEditor",'
    '),e.put("ui-grid/fileChooserEditor",'
    '),e.put("ui-grid/emptyBaseLayerContainer",'
    '),e.put("ui-grid/expandableRow",'
    '),e.put("ui-grid/expandableRowHeader",'
    '),e.put("ui-grid/expandableScrollFiller","
    "),e.put("ui-grid/expandableTopRowHeader",'
    '),e.put("ui-grid/csvLink",'LINK_LABEL'),e.put("ui-grid/importerMenuItem",'
  • '),e.put("ui-grid/importerMenuItemContainer","
    "),e.put("ui-grid/pagination",'
    {{ 1 + paginationApi.getFirstRowIndex() }} - {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
    '),e.put("ui-grid/columnResizer",'
    '),e.put("ui-grid/gridFooterSelectedItems",'({{"search.selectedItems" | t}} {{grid.selection.selectedCount}})'),e.put("ui-grid/selectionHeaderCell",'
    \x3c!--
     
    --\x3e
    '),e.put("ui-grid/selectionRowHeader",'
    '),e.put("ui-grid/selectionRowHeaderButtons",''),e.put("ui-grid/selectionSelectAllButtons",'
    '),e.put("ui-grid/treeBaseExpandAllButtons",'
    '),e.put("ui-grid/treeBaseHeaderCell",'
    '),e.put("ui-grid/treeBaseRowHeader",'
    '),e.put("ui-grid/treeBaseRowHeaderButtons",'
     
    '),e.put("ui-grid/cellTitleValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/cellTooltipValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    ')}]); \ No newline at end of file +!function(){"use strict";angular.module("ui.grid.i18n",[]),angular.module("ui.grid",["ui.grid.i18n"])}(),function(){"use strict";angular.module("ui.grid").constant("uiGridConstants",{LOG_DEBUG_MESSAGES:!0,LOG_WARN_MESSAGES:!0,LOG_ERROR_MESSAGES:!0,CUSTOM_FILTERS:/CUSTOM_FILTERS/g,COL_FIELD:/COL_FIELD/g,MODEL_COL_FIELD:/MODEL_COL_FIELD/g,TOOLTIP:/title=\"TOOLTIP\"/g,DISPLAY_CELL_TEMPLATE:/DISPLAY_CELL_TEMPLATE/g,TEMPLATE_REGEXP:/<.+>/,FUNC_REGEXP:/(\([^)]*\))?$/,DOT_REGEXP:/\./g,APOS_REGEXP:/'/g,BRACKET_REGEXP:/^(.*)((?:\s*\[\s*\d+\s*\]\s*)|(?:\s*\[\s*"(?:[^"\\]|\\.)*"\s*\]\s*)|(?:\s*\[\s*'(?:[^'\\]|\\.)*'\s*\]\s*))(.*)$/,COL_CLASS_PREFIX:"ui-grid-col",ENTITY_BINDING:"$$this",events:{GRID_SCROLL:"uiGridScroll",COLUMN_MENU_SHOWN:"uiGridColMenuShown",ITEM_DRAGGING:"uiGridItemDragStart",COLUMN_HEADER_CLICK:"uiGridColumnHeaderClick"},keymap:{TAB:9,STRG:17,CAPSLOCK:20,CTRL:17,CTRLRIGHT:18,CTRLR:18,SHIFT:16,RETURN:13,ENTER:13,BACKSPACE:8,BCKSP:8,ALT:18,ALTR:17,ALTRIGHT:17,SPACE:32,WIN:91,MAC:91,FN:null,PG_UP:33,PG_DOWN:34,UP:38,DOWN:40,LEFT:37,RIGHT:39,ESC:27,DEL:46,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123},ASC:"asc",DESC:"desc",filter:{STARTS_WITH:2,ENDS_WITH:4,EXACT:8,CONTAINS:16,GREATER_THAN:32,GREATER_THAN_OR_EQUAL:64,LESS_THAN:128,LESS_THAN_OR_EQUAL:256,NOT_EQUAL:512,SELECT:"select",INPUT:"input"},aggregationTypes:{sum:2,count:4,avg:8,min:16,max:32},CURRENCY_SYMBOLS:["¤","؋","Ar","Ƀ","฿","B/.","Br","Bs.","Bs.F.","GH₵","¢","c","Ch.","₡","C$","D","ден","دج",".د.ب","د.ع","JD","د.ك","ل.د","дин","د.ت","د.م.","د.إ","Db","$","₫","Esc","€","ƒ","Ft","FBu","FCFA","CFA","Fr","FRw","G","gr","₲","h","₴","₭","Kč","kr","kn","MK","ZK","Kz","K","L","Le","лв","E","lp","M","KM","MT","₥","Nfk","₦","Nu.","UM","T$","MOP$","₱","Pt.","£","ج.م.","LL","LS","P","Q","q","R","R$","ر.ع.","ر.ق","ر.س","៛","RM","p","Rf.","₹","₨","SRe","Rp","₪","Ksh","Sh.So.","USh","S/","SDR","сом","৳\t","WS$","₮","VT","₩","¥","zł"],scrollDirection:{UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",NONE:"none"},dataChange:{ALL:"all",EDIT:"edit",ROW:"row",COLUMN:"column",OPTIONS:"options"},scrollbars:{NEVER:0,ALWAYS:1,WHEN_NEEDED:2}})}(),angular.module("ui.grid").directive("uiGridCell",["$compile","$parse","gridUtil","uiGridConstants",function(a,e,l,u){return{priority:0,scope:!1,require:"?^uiGrid",compile:function(){return{pre:function(t,r,e,i){if(i&&t.col.compiledElementFn)(0,t.col.compiledElementFn)(t,function(e,t){r.append(e)});else if(i&&!t.col.compiledElementFn)t.col.getCompiledElementFn().then(function(e){e(t,function(e,t){r.append(e)})}).catch(angular.noop);else{var n=t.col.cellTemplate.replace(u.MODEL_COL_FIELD,"row.entity."+l.preEval(t.col.field)).replace(u.COL_FIELD,"grid.getCellValue(row, col)"),o=a(n)(t);r.append(o)}},post:function(i,n,e,t){var o,a=i.col.getColClass(!1);n.addClass(a);var l=function(e){var t=n;o&&(t.removeClass(o),o=null),o=angular.isFunction(i.col.cellClass)?i.col.cellClass(i.grid,i.row,i.col,i.rowRenderIndex,i.colRenderIndex):i.col.cellClass,t.addClass(o)};i.col.cellClass&&l();var r=i.grid.registerDataChangeCallback(l,[u.dataChange.COLUMN,u.dataChange.EDIT]),s=i.$watch("row",function(e,t){if(e!==t){(o||i.col.cellClass)&&l();var r=i.col.getColClass(!1);r!==a&&(n.removeClass(a),n.addClass(r),a=r)}}),d=function(){r(),s()};i.$on("$destroy",d),n.on("$destroy",d)}}}}}]),angular.module("ui.grid").service("uiGridColumnMenuService",["i18nService","uiGridConstants","gridUtil",function(e,r,g){var i={initialize:function(e,t){e.grid=t.grid,(t.columnMenuScope=e).menuShown=!1},setColMenuItemWatch:function(t){var e=t.$watch("col.menuItems",function(e){void 0!==e&&e&&angular.isArray(e)?(e.forEach(function(e){void 0!==e.context&&e.context||(e.context={}),e.context.col=t.col}),t.menuItems=t.defaultMenuItems.concat(e)):t.menuItems=t.defaultMenuItems});t.$on("$destroy",e)},sortable:function(e){return!!(e.grid.options.enableSorting&&void 0!==e.col&&e.col&&e.col.enableSorting)},isActiveSort:function(e,t){return void 0!==e.col&&void 0!==e.col.sort&&void 0!==e.col.sort.direction&&e.col.sort.direction===t},suppressRemoveSort:function(e){return!(!e.col||!e.col.suppressRemoveSort)},hideable:function(e){return void 0===e.col||!e.col||!e.col.colDef||!1!==e.col.colDef.enableHiding},getDefaultMenuItems:function(t){return[{title:function(){return e.getSafeText("sort.ascending")},icon:"ui-grid-icon-sort-alt-up",action:function(e){e.stopPropagation(),t.sortColumn(e,r.ASC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.ASC)}},{title:function(){return e.getSafeText("sort.descending")},icon:"ui-grid-icon-sort-alt-down",action:function(e){e.stopPropagation(),t.sortColumn(e,r.DESC)},shown:function(){return i.sortable(t)},active:function(){return i.isActiveSort(t,r.DESC)}},{title:function(){return e.getSafeText("sort.remove")},icon:"ui-grid-icon-cancel",action:function(e){e.stopPropagation(),t.unsortColumn()},shown:function(){return i.sortable(t)&&void 0!==t.col&&void 0!==t.col.sort&&void 0!==t.col.sort.direction&&null!==t.col.sort.direction&&!i.suppressRemoveSort(t)}},{title:function(){return e.getSafeText("column.hide")},icon:"ui-grid-icon-cancel",shown:function(){return i.hideable(t)},action:function(e){e.stopPropagation(),t.hideColumn()}}]},getColumnElementPosition:function(e,t,r){var i={};return i.left=r[0].offsetLeft,i.top=r[0].offsetTop,i.parentLeft=r[0].offsetParent.offsetLeft,i.offset=0,t.grid.options.offsetLeft&&(i.offset=t.grid.options.offsetLeft),i.height=g.elementHeight(r,!0),i.width=g.elementWidth(r,!0),i},repositionMenu:function(e,t,r,i,n){var o=i[0].querySelectorAll(".ui-grid-menu"),a=g.closestElm(n,".ui-grid-render-container"),l=a.getBoundingClientRect().left-e.grid.element[0].getBoundingClientRect().left,s=a.querySelectorAll(".ui-grid-viewport")[0].scrollLeft,d=g.elementWidth(o,!0),u=t.lastMenuPaddingRight?t.lastMenuPaddingRight:e.lastMenuPaddingRight?e.lastMenuPaddingRight:10;0!==o.length&&0!==o[0].querySelectorAll(".ui-grid-menu-mid").length&&(u=parseInt(g.getStyles(angular.element(o)[0]).paddingRight,10),e.lastMenuPaddingRight=u,t.lastMenuPaddingRight=u);var c=r.left+l-s+r.parentLeft+r.width+u;c(u.grid.rowHeaderColumns?u.grid.rowHeaderColumns.length:0);!r&&!n.uiGridColumns&&0===u.grid.options.columnDefs.length&&0
    ',scope:{side:"=uiGridPinnedContainer"},require:"^uiGrid",compile:function(){return{post:function(n,t,e,r){var o=r.grid,i=0;function a(){if("left"===n.side||"right"===n.side){for(var e=o.renderContainers[n.side].visibleColumnCache,t=0,r=0;r=t&&(t=e.sort.priority+1)}),t},e.prototype.resetColumnSorting=function(t){this.columns.forEach(function(e){e===t||e.suppressRemoveSort||(e.sort={})})},e.prototype.getColumnSorting=function(){var t=[];return this.columns.slice(0).sort(p.prioritySort).forEach(function(e){e.sort&&void 0!==e.sort.direction&&e.sort.direction&&(e.sort.direction===s.ASC||e.sort.direction===s.DESC)&&t.push(e)}),t},e.prototype.sortColumn=function(e,t,r){var i=this,n=null;if(void 0===e||!e)throw new Error("No column parameter provided");if("boolean"==typeof t?r=t:n=t,r?void 0===e.sort.priority&&(e.sort.priority=i.getNextColumnSortPriority()):(i.resetColumnSorting(e),e.sort.priority=void 0,e.sort.priority=i.getNextColumnSortPriority()),n)e.sort.direction=n;else{var o=e.sortDirectionCycle.indexOf(e.sort.direction?e.sort.direction:null);o=(o+1)%e.sortDirectionCycle.length,e.colDef&&e.suppressRemoveSort&&!e.sortDirectionCycle[o]&&(o=(o+1)%e.sortDirectionCycle.length),e.sortDirectionCycle[o]?e.sort.direction=e.sortDirectionCycle[o]:a(e,i)}return i.api.core.raise.sortChanged(i,i.getColumnSorting()),S.when(e)};var a=function(t,e){e.columns.forEach(function(e){e.sort&&void 0!==e.sort.priority&&e.sort.priority>t.sort.priority&&(e.sort.priority-=1)}),t.sort={}};function n(e,t){var r=e/t;return r<=1?r:1}function E(e,t,r){if(n(e,t)!==r)return{percentage:n(e,t)}}function A(e,t,r){var i=e/t;if((i=1Math.ceil(s)&&(u=p-s+r.renderContainers.body.prevScrollTop,i.y=E(u,g,r.renderContainers.body.prevScrolltopPercentage))}if(null!==t){for(var f=o.indexOf(t),m=r.renderContainers.body.getCanvasWidth()-r.renderContainers.body.getViewportWidth(),h=0,v=0;vt&&(e.sort.priority-=1)}),this.sort={},this.grid.api.core.raise.sortChanged(this.grid,this.grid.getColumnSorting())},t.prototype.getColClass=function(e){var t=u.COL_CLASS_PREFIX+this.uid;return e?"."+t:t},t.prototype.isPinnedLeft=function(){return"left"===this.renderContainer},t.prototype.isPinnedRight=function(){return"right"===this.renderContainer},t.prototype.getColClassDefinition=function(){return" .grid"+this.grid.id+" "+this.getColClass(!0)+" { min-width: "+this.drawnWidth+"px; max-width: "+this.drawnWidth+"px; }"},t.prototype.getRenderContainer=function(){var e=this.renderContainer;return null!==e&&""!==e&&void 0!==e||(e="body"),this.grid.renderContainers[e]},t.prototype.showColumn=function(){this.colDef.visible=!0},t.prototype.getAggregationText=function(){if(this.colDef.aggregationHideLabel)return"";if(this.colDef.aggregationLabel)return this.colDef.aggregationLabel;switch(this.colDef.aggregationType){case u.aggregationTypes.count:return e.getSafeText("aggregation.count");case u.aggregationTypes.sum:return e.getSafeText("aggregation.sum");case u.aggregationTypes.avg:return e.getSafeText("aggregation.avg");case u.aggregationTypes.min:return e.getSafeText("aggregation.min");case u.aggregationTypes.max:return e.getSafeText("aggregation.max");default:return""}},t.prototype.getCellTemplate=function(){return this.cellTemplatePromise},t.prototype.getCompiledElementFn=function(){return this.compiledElementFnDefer.promise},t}]),angular.module("ui.grid").factory("GridOptions",["gridUtil","uiGridConstants",function(t,r){return{initialize:function(e){return e.onRegisterApi=e.onRegisterApi||angular.noop(),e.data=e.data||[],e.columnDefs=e.columnDefs||[],e.excludeProperties=e.excludeProperties||["$$hashKey"],e.enableRowHashing=!1!==e.enableRowHashing,e.rowIdentity=e.rowIdentity||function(e){return t.hashKey(e)},e.getRowIdentity=e.getRowIdentity||function(e){return e.$$hashKey},e.flatEntityAccess=!0===e.flatEntityAccess,e.showHeader=void 0===e.showHeader||e.showHeader,e.showHeader?e.headerRowHeight=void 0!==e.headerRowHeight?e.headerRowHeight:30:e.headerRowHeight=0,"string"==typeof e.rowHeight?e.rowHeight=parseInt(e.rowHeight)||30:e.rowHeight=e.rowHeight||30,e.minRowsToShow=void 0!==e.minRowsToShow?e.minRowsToShow:10,e.showGridFooter=!0===e.showGridFooter,e.showColumnFooter=!0===e.showColumnFooter,e.columnFooterHeight=void 0!==e.columnFooterHeight?e.columnFooterHeight:30,e.gridFooterHeight=void 0!==e.gridFooterHeight?e.gridFooterHeight:30,e.columnWidth=void 0!==e.columnWidth?e.columnWidth:50,e.maxVisibleColumnCount=void 0!==e.maxVisibleColumnCount?e.maxVisibleColumnCount:200,e.virtualizationThreshold=void 0!==e.virtualizationThreshold?e.virtualizationThreshold:20,e.columnVirtualizationThreshold=void 0!==e.columnVirtualizationThreshold?e.columnVirtualizationThreshold:10,e.excessRows=void 0!==e.excessRows?e.excessRows:4,e.scrollThreshold=void 0!==e.scrollThreshold?e.scrollThreshold:4,e.excessColumns=void 0!==e.excessColumns?e.excessColumns:4,e.horizontalScrollThreshold=void 0!==e.horizontalScrollThreshold?e.horizontalScrollThreshold:2,e.aggregationCalcThrottle=void 0!==e.aggregationCalcThrottle?e.aggregationCalcThrottle:500,e.wheelScrollThrottle=void 0!==e.wheelScrollThrottle?e.wheelScrollThrottle:70,e.scrollDebounce=void 0!==e.scrollDebounce?e.scrollDebounce:300,e.enableSorting=!1!==e.enableSorting,e.enableFiltering=!0===e.enableFiltering,e.enableColumnMenus=!1!==e.enableColumnMenus,e.enableVerticalScrollbar=void 0!==e.enableVerticalScrollbar?e.enableVerticalScrollbar:r.scrollbars.ALWAYS,e.enableHorizontalScrollbar=void 0!==e.enableHorizontalScrollbar?e.enableHorizontalScrollbar:r.scrollbars.ALWAYS,e.enableMinHeightCheck=!1!==e.enableMinHeightCheck,e.minimumColumnSize=void 0!==e.minimumColumnSize?e.minimumColumnSize:30,e.rowEquality=e.rowEquality||function(e,t){return e===t},e.headerTemplate=e.headerTemplate||null,e.footerTemplate=e.footerTemplate||"ui-grid/ui-grid-footer",e.gridFooterTemplate=e.gridFooterTemplate||"ui-grid/ui-grid-grid-footer",e.rowTemplate=e.rowTemplate||"ui-grid/ui-grid-row",e.gridMenuTemplate=e.gridMenuTemplate||"ui-grid/uiGridMenu",e.appScopeProvider=e.appScopeProvider||null,e}}}]),angular.module("ui.grid").factory("GridRenderContainer",["gridUtil","uiGridConstants",function(b,n){function e(e,t,r){var i=this;i.name=e,i.grid=t,i.visibleRowCache=[],i.visibleColumnCache=[],i.renderedRows=[],i.renderedColumns=[],i.prevScrollTop=0,i.prevScrolltopPercentage=0,i.prevRowScrollIndex=0,i.prevScrollLeft=0,i.prevScrollleftPercentage=0,i.prevColumnScrollIndex=0,i.columnStyles="",i.viewportAdjusters=[],i.hasHScrollbar=!1,i.hasVScrollbar=!1,i.canvasHeightShouldUpdate=!0,i.$$canvasHeight=0,r&&angular.isObject(r)&&angular.extend(i,r),t.registerStyleComputation({priority:5,func:function(){return i.updateColumnWidths(),i.columnStyles}})}return e.prototype.reset=function(){this.visibleColumnCache.length=0,this.visibleRowCache.length=0,this.renderedRows.length=0,this.renderedColumns.length=0},e.prototype.containsColumn=function(e){return-1!==this.visibleColumnCache.indexOf(e)},e.prototype.minRowsToRender=function(){for(var e=0,t=0,r=this.getViewportHeight(),i=this.visibleRowCache.length-1;ti.grid.options.virtualizationThreshold){if(null!=e){if(!i.grid.suppressParentScrollDown&&i.prevScrollTope&&l>i.prevRowScrollIndex-i.grid.options.scrollThreshold&&lr.grid.options.columnVirtualizationThreshold&&r.getCanvasWidth()>r.getViewportWidth())l=[Math.max(0,a-r.grid.options.excessColumns),Math.min(n.length,a+i+r.grid.options.excessColumns)];else{var s=r.visibleColumnCache.length;l=[0,Math.max(s,i+r.grid.options.excessColumns)]}r.updateViewableColumnRange(l),r.prevColumnScrollIndex=a},e.prototype.updateViewableRowRange=function(e){var t=this.visibleRowCache.slice(e[0],e[1]);this.currentTopRow=e[0],this.setRenderedRows(t)},e.prototype.updateViewableColumnRange=function(e){var t=this.visibleColumnCache.slice(e[0],e[1]);this.currentFirstColumn=e[0],this.setRenderedColumns(t)},e.prototype.headerCellWrapperStyle=function(){if(0!==this.currentFirstColumn){var e=this.columnOffset;return this.grid.isRTL()?{"margin-right":e+"px"}:{"margin-left":e+"px"}}return null},e.prototype.updateColumnWidths=function(){var i=this,n=[],o=0,a=0,t="",l=!1,s=[],d=[],u=0,c=i.grid.getViewportWidth()-i.grid.scrollbarWidth,r=[];angular.forEach(i.grid.renderContainers,function(e){r=r.concat(e.visibleColumnCache)}),r.forEach(function(e){var t=0;if(e.visible)if(l&&(c+=i.grid.scrollbarWidth),!l&&e.colDef.pinnedRight&&(l=!0),angular.isNumber(e.width))t=parseInt(e.width,10),a+=t,e.drawnWidth=t,s.push(e);else if(b.endsWith(e.width,"%")){var r=parseInt(e.width.replace(/%/g,""),10);(t=parseInt(r/100*c))>e.maxWidth&&(t=e.maxWidth),te.maxWidth&&(t=e.maxWidth),te.minWidth&&0e.offsetWidth)},e.prototype.getViewportStyle=function(){var e=this,t={},r={};return r[n.scrollbars.ALWAYS]="scroll",r[n.scrollbars.WHEN_NEEDED]="auto",e.hasHScrollbar=!1,e.hasVScrollbar=!1,e.grid.disableScrolling?(t["overflow-x"]="hidden",t["overflow-y"]="hidden"):("body"===e.name?(e.hasHScrollbar=e.grid.options.enableHorizontalScrollbar!==n.scrollbars.NEVER,e.grid.isRTL()?e.grid.hasLeftContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER):e.grid.hasRightContainerColumns()||(e.hasVScrollbar=e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER)):"left"===e.name?e.hasVScrollbar=!!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER:e.hasVScrollbar=!e.grid.isRTL()&&e.grid.options.enableVerticalScrollbar!==n.scrollbars.NEVER,t["overflow-x"]=e.hasHScrollbar?r[e.grid.options.enableHorizontalScrollbar]:"hidden",t["overflow-y"]=e.hasVScrollbar?r[e.grid.options.enableVerticalScrollbar]:"hidden"),t},e}]),angular.module("ui.grid").factory("GridRow",["gridUtil","uiGridConstants",function(i,t){function e(e,t,r){this.grid=r,this.entity=e,this.uid=i.nextUid(),this.visible=!0,this.isSelected=!1,this.$$height=r.options.rowHeight}return Object.defineProperty(e.prototype,"height",{get:function(){return this.$$height},set:function(e){e!==this.$$height&&(this.grid.updateCanvasHeight(),this.$$height=e)}}),e.prototype.getQualifiedColField=function(e){return"row."+this.getEntityQualifiedColField(e)},e.prototype.getEntityQualifiedColField=function(e){return e.field===t.ENTITY_BINDING?"entity":i.preEval("entity."+e.field)},e.prototype.setRowInvisible=function(e){e&&e.setThisRowInvisible&&e.setThisRowInvisible("user")},e.prototype.clearRowInvisible=function(e){e&&e.clearThisRowInvisible&&e.clearThisRowInvisible("user")},e.prototype.setThisRowInvisible=function(e,t){this.invisibleReason||(this.invisibleReason={}),this.invisibleReason[e]=!0,this.evaluateRowVisibility(t)},e.prototype.clearThisRowInvisible=function(e,t){void 0!==this.invisibleReason&&delete this.invisibleReason[e],this.evaluateRowVisibility(t)},e.prototype.evaluateRowVisibility=function(e){var r=!0;void 0!==this.invisibleReason&&angular.forEach(this.invisibleReason,function(e,t){e&&(r=!1)}),void 0!==this.visible&&this.visible===r||(this.visible=r,e||(this.grid.queueGridRefresh(),this.grid.api.core.raise.rowsVisibleChanged(this)))},e}]),function(){"use strict";angular.module("ui.grid").factory("GridRowColumn",["$parse","$filter",function(e,t){var r=function e(t,r){if(!(this instanceof e))throw"Using GridRowColumn as a function insead of as a constructor. Must be called with `new` keyword";this.row=t,this.col=r};return r.prototype.getIntersectionValueRaw=function(){return e(this.row.getEntityQualifiedColField(this.col))(this.row)},r}])}(),angular.module("ui.grid").factory("ScrollEvent",["gridUtil",function(a){function e(e,t,r,i){var n=this;if(!e)throw new Error("grid argument is required");n.grid=e,n.source=i,n.withDelay=!0,n.sourceRowContainer=t,n.sourceColContainer=r,n.newScrollLeft=null,n.newScrollTop=null,n.x=null,n.y=null,n.verticalScrollLength=-9999999,n.horizontalScrollLength=-999999,n.fireThrottledScrollingEvent=a.throttle(function(e){n.grid.scrollContainers(e,n)},n.grid.options.wheelScrollThrottle,{trailing:!0})}return e.prototype.getNewScrollLeft=function(e,t){var r=this;if(!r.newScrollLeft){var i,n=e.getCanvasWidth()-e.getViewportWidth(),o=a.normalizeScrollLeft(t,r.grid);if(void 0!==r.x.percentage&&void 0!==r.x.percentage)i=r.x.percentage;else{if(void 0===r.x.pixels||void 0===r.x.pixels)throw new Error("No percentage or pixel value provided for scroll event X axis");i=r.x.percentage=(o+r.x.pixels)/n}return Math.max(0,i*n)}return r.newScrollLeft},e.prototype.getNewScrollTop=function(e,t){var r=this;if(!r.newScrollTop){var i,n=e.getVerticalScrollLength(),o=t[0].scrollTop;if(void 0!==r.y.percentage&&void 0!==r.y.percentage)i=r.y.percentage;else{if(void 0===r.y.pixels||void 0===r.y.pixels)throw new Error("No percentage or pixel value provided for scroll event Y axis");i=r.y.percentage=(o+r.y.pixels)/n}return Math.max(0,i*n)}return r.newScrollTop},e.prototype.atTop=function(e){return this.y&&(0===this.y.percentage||this.verticalScrollLength<0)&&0===e},e.prototype.atBottom=function(e){return this.y&&(1===this.y.percentage||0===this.verticalScrollLength)&&0A')[0],r="reverse";return document.body.appendChild(t),0=i.length-a?new l(i[i.length-1],r[n]):new l(i[o+a],r[n])},n.prototype.getRowColUp=function(e,t){var r=this.getFocusableCols(),i=this.getFocusableRows(),n=r.indexOf(t),o=i.indexOf(e);return-1===n&&(n=0),new l(0===o?e:i[o-1],r[n])},n.prototype.getRowColPageUp=function(e,t){var r=this.getFocusableCols(),i=this.getFocusableRows(),n=r.indexOf(t),o=i.indexOf(e);-1===n&&(n=0);var a=this.bodyContainer.minRowsToRender();return new l(o-a<0?i[0]:i[o-a],r[n])},n}]),e.service("uiGridCellNavService",["gridUtil","uiGridConstants","uiGridCellNavConstants","$q","uiGridCellNavFactory","GridRowColumn","ScrollEvent",function(e,t,r,i,n,o,a){var l={initializeGrid:function(i){i.registerColumnBuilder(l.cellNavColumnBuilder),i.cellNav={},i.cellNav.lastRowCol=null,i.cellNav.focusedCells=[],l.defaultGridOptions(i.options);var e={events:{cellNav:{navigate:function(e,t){},viewPortKeyDown:function(e,t){},viewPortKeyPress:function(e,t){}}},methods:{cellNav:{scrollToFocus:function(e,t){return l.scrollToFocus(i,e,t)},getFocusedCell:function(){return i.cellNav.lastRowCol},getCurrentSelection:function(){return i.cellNav.focusedCells},rowColSelectIndex:function(e){for(var t=-1,r=0;r ',g=a(n)(e),t.prepend(g),e.$on(u.CELL_NAV_EVENT,function(e,t,r,i){if(!i||"focus"!==i.type){for(var n,o,a=[],l=p.api.cellNav.getCurrentSelection(),s=0;s')(e);t.append(d),d.on("focus",function(e){e.uiGridTargetRenderContainerId=l;var t=n.grid.api.cellNav.getFocusedCell();null===t&&(t=n.grid.renderContainers[l].cellNav.getNextRowCol(m.direction.DOWN,null,null)).row&&t.col&&n.cellNav.broadcastCellNav(t)}),a.setAriaActivedescendant=function(e){t.attr("aria-activedescendant",e)},a.removeAriaActivedescendant=function(e){t.attr("aria-activedescendant")===e&&t.attr("aria-activedescendant","")},n.focus=function(){g.focus.byElement(d[0])};var u=null;d.on("keydown",function(r){r.uiGridTargetRenderContainerId=l;var e=n.grid.api.cellNav.getFocusedCell();null===(n.grid.options.keyDownOverrides.some(function(t){return Object.keys(t).every(function(e){return t[e]===r[e]})})?null:n.cellNav.handleKeyDown(r))&&(n.grid.api.cellNav.raise.viewPortKeyDown(r,e,n.cellNav.handleKeyDown),u=e)}),d.on("keypress",function(e){u&&(c(function(){n.grid.api.cellNav.raise.viewPortKeyPress(e,u)},4),u=null)}),e.$on("$destroy",function(){d.off()})}}}}}}}]),e.directive("uiGridViewport",["$timeout","$document","gridUtil","uiGridConstants","uiGridCellNavService","uiGridCellNavConstants","$log","$compile",function(e,t,r,i,n,o,a,l){return{replace:!0,priority:-99999,require:["^uiGrid","^uiGridRenderContainer","?^uiGridCellnav"],scope:!1,compile:function(){return{pre:function(e,t,r,i){},post:function(e,t,r,i){var n=i[0],o=i[1];if(n.grid.api.cellNav&&"body"===o.containerId){var a=n.grid;a.api.core.on.scrollBegin(e,function(e){var t=n.grid.api.cellNav.getFocusedCell();null!==t&&o.colContainer.containsColumn(t.col)&&n.cellNav.clearFocus()}),a.api.core.on.scrollEnd(e,function(e){var t=n.grid.api.cellNav.getFocusedCell();null!==t&&o.colContainer.containsColumn(t.col)&&n.cellNav.broadcastCellNav(t)}),a.api.cellNav.on.navigate(e,function(){n.focus()})}}}}}}]),e.directive("uiGridCell",["$timeout","$document","uiGridCellNavService","gridUtil","uiGridCellNavConstants","uiGridConstants","GridRowColumn",function(e,t,r,i,c,g,p){return{priority:-150,restrict:"A",require:["^uiGrid","?^uiGridCellnav"],scope:!1,link:function(r,t,e,i){var n=i[0],o=i[1];if(n.grid.api.cellNav&&r.col.colDef.allowCellFocus){var a=n.grid;r.focused=!1,t.attr("tabindex",-1),t.find("div").on("click",function(e){n.cellNav.broadcastCellNav(new p(r.row,r.col),e.ctrlKey||e.metaKey,e),e.stopPropagation(),r.$apply()}),t.on("mousedown",s),n.grid.api.edit&&(n.grid.api.edit.on.beginCellEdit(r,function(){t.off("mousedown",s)}),n.grid.api.edit.on.afterCellEdit(r,function(){t.on("mousedown",s)}),n.grid.api.edit.on.cancelCellEdit(r,function(){t.on("mousedown",s)})),d(),t.on("focus",function(e){n.cellNav.broadcastCellNav(new p(r.row,r.col),!1,e),e.stopPropagation(),r.$apply()}),r.$on(c.CELL_NAV_EVENT,d);var l=n.grid.registerDataChangeCallback(function(e){u(),r.$applyAsync(d)},[g.dataChange.ROW]);r.$on("$destroy",function(){l(),t.find("div").off(),t.off()})}function s(e){e.preventDefault()}function d(){a.cellNav.focusedCells.some(function(e,t){return e.row===r.row&&e.col===r.col})?function(){if(!r.focused){var e=t.find("div");e.addClass("ui-grid-cell-focus"),t.attr("aria-selected",!0),o.setAriaActivedescendant(t.attr("id")),r.focused=!0}}():u()}function u(){r.focused&&(t.find("div").removeClass("ui-grid-cell-focus"),t.attr("aria-selected",!1),o.removeAriaActivedescendant(t.attr("id")),r.focused=!1)}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.edit",["ui.grid"]);e.constant("uiGridEditConstants",{EDITABLE_CELL_TEMPLATE:/EDITABLE_CELL_TEMPLATE/g,EDITABLE_CELL_DIRECTIVE:/editable_cell_directive/g,events:{BEGIN_CELL_EDIT:"uiGridEventBeginCellEdit",END_CELL_EDIT:"uiGridEventEndCellEdit",CANCEL_CELL_EDIT:"uiGridEventCancelCellEdit"}}),e.service("uiGridEditService",["$q","uiGridConstants","gridUtil",function(n,t,o){var r={initializeGrid:function(e){r.defaultGridOptions(e.options),e.registerColumnBuilder(r.editColumnBuilder),e.edit={};e.api.registerEventsFromObject({edit:{afterCellEdit:function(e,t,r,i){},beginCellEdit:function(e,t,r){},cancelCellEdit:function(e,t){}}})},defaultGridOptions:function(e){e.cellEditableCondition=void 0===e.cellEditableCondition||e.cellEditableCondition,e.enableCellEditOnFocus=void 0!==e.enableCellEditOnFocus&&e.enableCellEditOnFocus},editColumnBuilder:function(t,r,e){var i=[];return t.enableCellEdit=void 0===t.enableCellEdit?void 0===e.enableCellEdit?"object"!==t.type:e.enableCellEdit:t.enableCellEdit,t.cellEditableCondition=void 0===t.cellEditableCondition?e.cellEditableCondition:t.cellEditableCondition,t.enableCellEdit&&(t.editableCellTemplate=t.editableCellTemplate||e.editableCellTemplate||"ui-grid/cellEditor",i.push(o.getTemplate(t.editableCellTemplate).then(function(e){r.editableCellTemplate=e},function(e){throw new Error("Couldn't fetch/use colDef.editableCellTemplate '"+t.editableCellTemplate+"'")}))),t.enableCellEditOnFocus=void 0===t.enableCellEditOnFocus?e.enableCellEditOnFocus:t.enableCellEditOnFocus,n.all(i)},isStartEditKey:function(e){return!(e.metaKey||e.keyCode===t.keymap.ESC||e.keyCode===t.keymap.SHIFT||e.keyCode===t.keymap.CTRL||e.keyCode===t.keymap.ALT||e.keyCode===t.keymap.WIN||e.keyCode===t.keymap.CAPSLOCK||e.keyCode===t.keymap.LEFT||e.keyCode===t.keymap.TAB&&e.shiftKey||e.keyCode===t.keymap.RIGHT||e.keyCode===t.keymap.TAB||e.keyCode===t.keymap.UP||e.keyCode===t.keymap.ENTER&&e.shiftKey||e.keyCode===t.keymap.DOWN||e.keyCode===t.keymap.ENTER)}};return r}]),e.directive("uiGridEdit",["gridUtil","uiGridEditService",function(e,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(i.grid)},post:function(e,t,r,i){}}}}}]),e.directive("uiGridViewport",["uiGridEditConstants",function(o){return{replace:!0,priority:-99998,require:["^uiGrid","^uiGridRenderContainer"],scope:!1,compile:function(){return{post:function(e,t,r,i){var n=i[0];n.grid.api.edit&&n.grid.api.cellNav&&("body"===i[1].containerId&&(e.$on(o.events.CANCEL_CELL_EDIT,function(){n.focus()}),e.$on(o.events.END_CELL_EDIT,function(){n.focus()})))}}}}}]),e.directive("uiGridCell",["$compile","$injector","$timeout","uiGridConstants","uiGridEditConstants","gridUtil","$parse","uiGridEditService","$rootScope","$q",function(S,e,x,E,A,R,T,g,F,P){var D=500;if(e.has("uiGridCellNavService"))e.get("uiGridCellNavService");return{priority:-100,restrict:"A",scope:!1,require:"?^uiGrid",link:function(p,f,e,i){var m,h,v,t,C,w=!1;if(p.col.colDef.enableCellEdit){var r=function(){},n=function(){},o=function(){p.col.colDef.enableCellEdit&&!1!==p.row.enableCellEdit?p.beginEditEventsWired||l():p.beginEditEventsWired&&b()};o();var a=p.$watch("row",function(e,t){e!==t&&o()});p.$on("$destroy",function(){a(),f.off()})}function l(){f.on("dblclick",c),f.on("touchstart",s),i&&i.grid.api.cellNav&&(n=i.grid.api.cellNav.on.viewPortKeyDown(p,function(e,t){null!==t&&(t.row!==p.row||t.col!==p.col||p.col.colDef.enableCellEditOnFocus||u(e))}),r=i.grid.api.cellNav.on.navigate(p,function(e,t,r){p.col.colDef.enableCellEditOnFocus&&(e.row!==p.row||e.col!==p.col||null!==r&&(!r||"click"!==r.type&&"keydown"!==r.type)||x(function(){c(r)}))})),p.beginEditEventsWired=!0}function s(e){void 0!==e.originalEvent&&void 0!==e.originalEvent&&(e=e.originalEvent),f.on("touchend",d),(t=x(function(){},D)).then(function(){setTimeout(c,0),f.off("touchend",d)})}function d(e){x.cancel(t),f.off("touchend",d)}function b(){f.off("dblclick",c),f.off("keydown",u),f.off("touchstart",s),r(),n(),p.beginEditEventsWired=!1}function u(e){g.isStartEditKey(e)&&c(e)}function c(e){p.grid.api.core.scrollToIfNecessary(p.row,p.col).then(function(){!function(e){if(w)return;if(t=p.col,r=p.row,i=e,r.isSaving||(angular.isFunction(t.colDef.cellEditableCondition)?!t.colDef.cellEditableCondition(p,i):!t.colDef.cellEditableCondition))return;var t,r,i;var n=p.row.getQualifiedColField(p.col);p.col.colDef.editModelField&&(n=R.preEval("row.entity."+p.col.colDef.editModelField));v=T(n),h=v(p),m=(m=(m=p.col.editableCellTemplate).replace(E.MODEL_COL_FIELD,n)).replace(E.COL_FIELD,"grid.getCellValue(row, col)");var o=p.col.colDef.editDropdownFilter?"|"+p.col.colDef.editDropdownFilter:"";m=m.replace(E.CUSTOM_FILTERS,o);var a="text";switch(p.col.colDef.type){case"boolean":a="checkbox";break;case"number":a="number";break;case"date":a="date"}m=m.replace("INPUT_TYPE",a);var l=p.col.colDef.editDropdownOptionsFunction;if(l)P.when(l(p.row.entity,p.col.colDef)).then(function(e){p.editDropdownOptionsArray=e});else{var s=p.col.colDef.editDropdownRowEntityOptionsArrayPath;p.editDropdownOptionsArray=s?function(e,t){var r=(t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split(".");for(;r.length;){var i=r.shift();if(!(i in e))return;e=e[i]}return e}(p.row.entity,s):p.col.colDef.editDropdownOptionsArray}p.editDropdownIdLabel=p.col.colDef.editDropdownIdLabel?p.col.colDef.editDropdownIdLabel:"id",p.editDropdownValueLabel=p.col.colDef.editDropdownValueLabel?p.col.colDef.editDropdownValueLabel:"value";var d=function(){w=!0,b();var e=angular.element(m);f.append(e),C=p.$new(),S(e)(C);var t=angular.element(f.children()[0]);t.addClass("ui-grid-cell-contents-hidden")};F.$$phase?d():p.$apply(d);var u=p.col.grid.api.core.on.scrollBegin(p,function(){p.grid.disableScrolling||(y(),p.grid.api.edit.raise.afterCellEdit(p.row.entity,p.col.colDef,v(p),h),u(),c(),g())}),c=p.$on(A.events.END_CELL_EDIT,function(){y(),p.grid.api.edit.raise.afterCellEdit(p.row.entity,p.col.colDef,v(p),h),c(),u(),g()}),g=p.$on(A.events.CANCEL_CELL_EDIT,function(){!function(){if(p.grid.disableScrolling=!1,!w)return;v.assign(p,h),p.$apply(),p.grid.api.edit.raise.cancelCellEdit(p.row.entity,p.col.colDef),y()}(),g(),u(),c()});p.$broadcast(A.events.BEGIN_CELL_EDIT,e),x(function(){p.grid.api.edit.raise.beginCellEdit(p.row.entity,p.col.colDef,e)})}(e)})}function y(){if(p.grid.disableScrolling=!1,w){i&&i.grid.api.cellNav&&i.focus();var e=angular.element(f.children()[0]);C.$destroy();for(var t=f.children(),r=1;r 1 or < 1 file choosers within the menu item, error, cannot continue"):o[0].addEventListener("change",function(e){var t=e.srcElement||e.target;if(t&&t.files&&1===t.files.length){var r=t.files[0];void 0!==i&&i?(n=i.grid,a.importThisFile(n,r),t.form.reset()):l.logError("Could not import file because UI Grid was not found.")}},!1)}}}])}(),function(){"use strict";var e=angular.module("ui.grid.infiniteScroll",["ui.grid"]);e.service("uiGridInfiniteScrollService",["gridUtil","$compile","$rootScope","uiGridConstants","ScrollEvent","$q",function(e,t,l,s,a,r){var d={initializeGrid:function(r,e){if(d.defaultGridOptions(r.options),r.options.enableInfiniteScroll){r.infiniteScroll={dataLoading:!1},d.setScrollDirections(r,r.options.infiniteScrollUp,r.options.infiniteScrollDown),r.api.core.on.scrollEnd(e,d.handleScroll);var t={events:{infiniteScroll:{needLoadMoreData:function(e,t){},needLoadMoreDataTop:function(e,t){}}},methods:{infiniteScroll:{dataLoaded:function(e,t){return d.setScrollDirections(r,e,t),d.adjustScroll(r).then(function(){r.infiniteScroll.dataLoading=!1})},resetScroll:function(e,t){d.setScrollDirections(r,e,t),d.adjustInfiniteScrollPosition(r,0)},saveScrollPercentage:function(){r.infiniteScroll.prevScrollTop=r.renderContainers.body.prevScrollTop,r.infiniteScroll.previousVisibleRows=r.getVisibleRowCount()},dataRemovedTop:function(e,t){d.dataRemovedTop(r,e,t)},dataRemovedBottom:function(e,t){d.dataRemovedBottom(r,e,t)},setScrollDirections:function(e,t){d.setScrollDirections(r,e,t)}}}};r.api.registerEventsFromObject(t.events),r.api.registerMethodsFromObject(t.methods)}},defaultGridOptions:function(e){e.enableInfiniteScroll=!1!==e.enableInfiniteScroll,e.infiniteScrollRowsFromEnd=e.infiniteScrollRowsFromEnd||20,e.infiniteScrollUp=!0===e.infiniteScrollUp,e.infiniteScrollDown=!1!==e.infiniteScrollDown},setScrollDirections:function(e,t,r){e.infiniteScroll.scrollUp=!0===t,e.suppressParentScrollUp=!0===t,e.infiniteScroll.scrollDown=!1!==r,e.suppressParentScrollDown=!1!==r},handleScroll:function(e){if(!(e.grid.infiniteScroll&&e.grid.infiniteScroll.dataLoading||"ui.grid.adjustInfiniteScrollPosition"===e.source)&&e.y)if(0===e.y.percentage)e.grid.scrollDirection=s.scrollDirection.UP,d.loadData(e.grid);else if(1===e.y.percentage)e.grid.scrollDirection=s.scrollDirection.DOWN,d.loadData(e.grid);else{var t=e.grid.options.infiniteScrollRowsFromEnd/e.grid.renderContainers.body.visibleRowCache.length;e.grid.scrollDirection===s.scrollDirection.UP?e.y.percentage<=t&&d.loadData(e.grid):e.grid.scrollDirection===s.scrollDirection.DOWN&&1-e.y.percentage<=t&&d.loadData(e.grid)}},loadData:function(e){e.infiniteScroll.previousVisibleRows=e.renderContainers.body.visibleRowCache.length,e.infiniteScroll.direction=e.scrollDirection,delete e.infiniteScroll.prevScrollTop,e.scrollDirection===s.scrollDirection.UP&&e.infiniteScroll.scrollUp?(e.infiniteScroll.dataLoading=!0,e.api.infiniteScroll.raise.needLoadMoreDataTop()):e.scrollDirection===s.scrollDirection.DOWN&&e.infiniteScroll.scrollDown&&(e.infiniteScroll.dataLoading=!0,e.api.infiniteScroll.raise.needLoadMoreData())},adjustScroll:function(o){var a=r.defer();return l.$applyAsync(function(){var e,t,r,i;e=o.getViewportHeight()+o.headerHeight-o.renderContainers.body.headerHeight-o.scrollbarHeight,t=o.options.rowHeight,void 0===o.infiniteScroll.direction&&d.adjustInfiniteScrollPosition(o,0);var n=t*(r=o.getVisibleRowCount());o.infiniteScroll.scrollDown&&n=i.length-r||t>=i.length-r)s.logError("MoveColumn: Invalid values for originalPosition, finalPosition");else{var o=function(e){for(var t=e,r=0;r<=t;r++)angular.isDefined(i[r])&&(angular.isDefined(i[r].colDef.visible)&&!1===i[r].colDef.visible||!0===i[r].isRowHeader)&&t++;return t};l.redrawColumnAtPosition(a,o(e),o(t))}}else s.logError("MoveColumn: Please provide valid values for originalPosition and finalPosition")}}}};a.api.registerEventsFromObject(e.events),a.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enableColumnMoving=!1!==e.enableColumnMoving},movableColumnBuilder:function(e,t,r){return e.enableColumnMoving=void 0===e.enableColumnMoving?r.enableColumnMoving:e.enableColumnMoving,i.all([])},updateColumnCache:function(e){e.moveColumns.orderCache=e.getOnlyDataColumns()},verifyColumnOrder:function(i){var n,o=i.rowHeaderColumns.length;angular.forEach(i.moveColumns.orderCache,function(e,t){if(-1!==(n=i.columns.indexOf(e))&&n-o!==t){var r=i.columns.splice(n,1)[0];i.columns.splice(t+o,0,r)}})},redrawColumnAtPosition:function(e,t,r){var i=e.columns;if(t!==r){for(var n=tMath.max(n,r))){var a=i[t];if(a.colDef.enableColumnMoving){if(rMath.abs(p)){b.redrawColumnAtPosition(u.grid,i,o-1);break}}else for(o=i-1;0<=o;o--)if((angular.isUndefined(r[o].colDef.visible)||!0===r[o].colDef.visible)&&(a+=r[o].drawnWidth||r[o].width||r[o].colDef.width)>Math.abs(p)){b.redrawColumnAtPosition(u.grid,i,o+1);break}aMath.ceil(c.grid.gridWidth)){e*=8;var l=new S(u.col.grid,null,null,"uiGridHeaderCell.moveElement");l.x={pixels:e},l.grid.scrollContainers("",l)}for(var s=0,d=0;dr.length&&(i=((o.options.paginationCurrentPage=1)-1)*t),r.slice(i,n+1)},900)},defaultGridOptions:function(e){e.enablePagination=!1!==e.enablePagination,e.enablePaginationControls=!1!==e.enablePaginationControls,e.useExternalPagination=!0===e.useExternalPagination,e.useCustomPagination=!0===e.useCustomPagination,t.isNullOrUndefined(e.totalItems)&&(e.totalItems=0),t.isNullOrUndefined(e.paginationPageSizes)&&(e.paginationPageSizes=[250,500,1e3]),t.isNullOrUndefined(e.paginationPageSize)&&(0r.paginationApi.getTotalPages()?o.paginationCurrentPage=r.paginationApi.getTotalPages():d.onPaginationChanged(r.grid,o.paginationCurrentPage,o.paginationPageSize))});r.$on("$destroy",function(){l()}),r.cantPageForward=function(){return r.paginationApi.getTotalPages()?r.cantPageToLast():o.data.length<1},r.cantPageToLast=function(){var e=r.paginationApi.getTotalPages();return!e||o.paginationCurrentPage>=e},r.cantPageBackward=function(){return o.paginationCurrentPage<=1};var s=function(e){e&&c.focus.bySelector(t,".ui-grid-pager-control-input")};r.pageFirstPageClick=function(){r.paginationApi.seek(1),s(r.cantPageBackward())},r.pagePreviousPageClick=function(){r.paginationApi.previousPage(),s(r.cantPageBackward())},r.pageNextPageClick=function(){r.paginationApi.nextPage(),s(r.cantPageForward())},r.pageLastPageClick=function(){r.paginationApi.seek(r.paginationApi.getTotalPages()),s(r.cantPageToLast())}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.pinning",["ui.grid"]);e.constant("uiGridPinningConstants",{container:{LEFT:"left",RIGHT:"right",NONE:""}}),e.service("uiGridPinningService",["gridUtil","GridRenderContainer","i18nService","uiGridPinningConstants",function(a,e,l,s){var d={initializeGrid:function(r){d.defaultGridOptions(r.options),r.registerColumnBuilder(d.pinningColumnBuilder);var e={events:{pinning:{columnPinned:function(e,t){}}},methods:{pinning:{pinColumn:function(e,t){d.pinColumn(r,e,t)}}}};r.api.registerEventsFromObject(e.events),r.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enablePinning=!1!==e.enablePinning,e.hidePinLeft=e.enablePinning&&e.hidePinLeft,e.hidePinRight=e.enablePinning&&e.hidePinRight},pinningColumnBuilder:function(e,t,r){if(e.enablePinning=void 0===e.enablePinning?r.enablePinning:e.enablePinning,e.hidePinLeft=void 0===e.hidePinLeft?r.hidePinLeft:e.hidePinLeft,e.hidePinRight=void 0===e.hidePinRight?r.hidePinRight:e.hidePinRight,e.pinnedLeft?(t.renderContainer="left",t.grid.createLeftContainer()):e.pinnedRight&&(t.renderContainer="right",t.grid.createRightContainer()),e.enablePinning){var i={name:"ui.grid.pinning.pinLeft",title:l.get().pinning.pinLeft,icon:"ui-grid-icon-left-open",shown:function(){return void 0===this.context.col.renderContainer||!this.context.col.renderContainer||"left"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.LEFT)}},n={name:"ui.grid.pinning.pinRight",title:l.get().pinning.pinRight,icon:"ui-grid-icon-right-open",shown:function(){return void 0===this.context.col.renderContainer||!this.context.col.renderContainer||"right"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.RIGHT)}},o={name:"ui.grid.pinning.unpin",title:l.get().pinning.unpin,icon:"ui-grid-icon-cancel",shown:function(){return void 0!==this.context.col.renderContainer&&null!==this.context.col.renderContainer&&"body"!==this.context.col.renderContainer},action:function(){d.pinColumn(this.context.col.grid,this.context.col,s.container.NONE)}};e.hidePinLeft||a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.pinLeft")||t.menuItems.push(i),e.hidePinRight||a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.pinRight")||t.menuItems.push(n),a.arrayContainsObjectWithProperty(t.menuItems,"name","ui.grid.pinning.unpin")||t.menuItems.push(o)}},pinColumn:function(e,t,r){r===s.container.NONE?(t.renderContainer=null,t.colDef.pinnedLeft=t.colDef.pinnedRight=!1):(t.renderContainer=r)===s.container.LEFT?e.createLeftContainer():r===s.container.RIGHT&&e.createRightContainer(),e.refresh().then(function(){e.api.pinning.raise.columnPinned(t.colDef,r)})}};return d}]),e.directive("uiGridPinning",["gridUtil","uiGridPinningService",function(e,n){return{require:"uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(i.grid)},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.resizeColumns",["ui.grid"]);e.service("uiGridResizeColumnsService",["gridUtil","$q","$rootScope",function(i,n,o){return{defaultGridOptions:function(e){e.enableColumnResizing=!1!==e.enableColumnResizing,!1===e.enableColumnResize&&(e.enableColumnResizing=!1)},colResizerColumnBuilder:function(e,t,r){return e.enableColumnResizing=void 0===e.enableColumnResizing?r.enableColumnResizing:e.enableColumnResizing,!1===e.enableColumnResize&&(e.enableColumnResizing=!1),n.all([])},registerPublicApi:function(e){e.api.registerEventsFromObject({colResizable:{columnSizeChanged:function(e,t){}}})},fireColumnSizeChanged:function(e,t,r){o.$applyAsync(function(){e.api.colResizable?e.api.colResizable.raise.columnSizeChanged(t,r):i.logError("The resizeable api is not registered, this may indicate that you've included the module but not added the 'ui-grid-resize-columns' directive to your grid definition. Cannot raise any events.")})},findTargetCol:function(e,t,r){var i=e.getRenderContainer();if("left"===t){var n=i.visibleColumnCache.indexOf(e);return i.visibleColumnCache[n-1*r]}return e}}}]),e.directive("uiGridResizeColumns",["gridUtil","uiGridResizeColumnsService",function(e,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.defaultGridOptions(i.grid.options),i.grid.registerColumnBuilder(n.colResizerColumnBuilder),n.registerPublicApi(i.grid)},post:function(e,t,r,i){}}}}}]),e.directive("uiGridHeaderCell",["gridUtil","$templateCache","$compile","$q","uiGridResizeColumnsService","uiGridConstants",function(e,o,u,t,c,g){return{priority:-10,require:"^uiGrid",compile:function(){return{post:function(a,l,e,t){var r=t.grid;if(r.options.enableColumnResizing){var s=o.get("ui-grid/columnResizer"),d=1;r.isRTL()&&(a.position="left",d=-1);var i=function(){for(var e=l[0].getElementsByClassName("ui-grid-column-resizer"),t=0;t');return{priority:0,scope:{col:"=",position:"@",renderIndex:"="},require:"?^uiGrid",link:function(l,s,e,d){var o=0,a=0,u=0,c=1;function g(e){d.grid.refreshCanvas(!0).then(function(){d.grid.queueGridRefresh()})}function p(e,t){var r=t;return e.minWidth&&re.maxWidth&&(r=e.maxWidth),r}function r(e,t){e.originalEvent&&(e=e.originalEvent),e.preventDefault(),(a=(e.targetTouches?e.targetTouches[0]:e).clientX-u)<0?a=0:a>d.grid.gridWidth&&(a=d.grid.gridWidth);var r=w.findTargetCol(l.col,l.position,c);if(!1!==r.colDef.enableColumnResizing){d.grid.element.hasClass("column-resizing")||d.grid.element.addClass("column-resizing");var i=a-o,n=parseInt(r.drawnWidth+i*c,10);a+=(p(r,n)-n)*c,b.css({left:a+"px"}),d.fireEvent(C.events.ITEM_DRAGGING)}}function i(e,t){e.originalEvent&&(e=e.originalEvent),e.preventDefault(),d.grid.element.removeClass("column-resizing"),b.remove();var r=(a=(e.changedTouches?e.changedTouches[0]:e).clientX-u)-o;if(0===r)return m(),void f();var i=w.findTargetCol(l.col,l.position,c);if(!1!==i.colDef.enableColumnResizing){var n=parseInt(i.drawnWidth+r*c,10);i.width=p(i,n),i.hasCustomWidth=!0,g(),w.fireColumnSizeChanged(d.grid,i.colDef,r),m(),f()}}d.grid.isRTL()&&(l.position="left",c=-1),"left"===l.position?s.addClass("left"):"right"===l.position&&s.addClass("right");var n=function(e,t){e.originalEvent&&(e=e.originalEvent),e.stopPropagation(),u=d.grid.element[0].getBoundingClientRect().left,o=(e.targetTouches?e.targetTouches[0]:e).clientX-u,d.grid.element.append(b),b.css({left:o}),"touchstart"===e.type?(h.on("touchend",i),h.on("touchmove",r),s.off("mousedown",n)):(h.on("mouseup",i),h.on("mousemove",r),s.off("touchstart",n))},f=function(){s.on("mousedown",n),s.on("touchstart",n)},m=function(){h.off("mouseup",i),h.off("touchend",i),h.off("mousemove",r),h.off("touchmove",r),s.off("mousedown",n),s.off("touchstart",n)};f();var t=function(e,t){e.stopPropagation();var r=w.findTargetCol(l.col,l.position,c);if(!1!==r.colDef.enableColumnResizing){var i,n=0,o=v.closestElm(s,".ui-grid-render-container").querySelectorAll("."+C.COL_CLASS_PREFIX+r.uid+" .ui-grid-cell-contents");Array.prototype.forEach.call(o,function(e){var i;angular.element(e).parent().hasClass("ui-grid-header-cell")&&(i=angular.element(e).parent()[0].querySelectorAll(".ui-grid-column-menu-button")),v.fakeElement(e,{},function(e){var t=angular.element(e);t.attr("style","float: left");var r=v.elementWidth(t);i&&(r+=v.elementWidth(i));ne.value||null===e.value)&&(e.value=t)}},avg:{label:n.get().aggregation.avg,menuTitle:n.get().grouping.aggregate_avg,aggregationFn:function(e,t,r){void 0===e.count?e.count=1:e.count++,isNaN(r)||(void 0===e.value||void 0===e.sum?(e.value=r,e.sum=r):(e.sum+=r,e.value=e.sum/e.count))}}}},finaliseAggregation:function(e,t){t.col.treeAggregationUpdateEntity&&void 0!==e&&void 0!==e.entity["$$"+t.col.uid]&&angular.extend(t,e.entity["$$"+t.col.uid]),"function"==typeof t.col.treeAggregationFinalizerFn&&t.col.treeAggregationFinalizerFn(t),"function"==typeof t.col.customTreeAggregationFinalizerFn&&t.col.customTreeAggregationFinalizerFn(t),void 0===t.rendered&&(t.rendered=t.label?t.label+t.value:t.value)},finaliseAggregations:function(e){null!=e&&void 0!==e.treeNode.aggregations&&e.treeNode.aggregations.forEach(function(r){if(s.finaliseAggregation(e,r),r.col.treeAggregationUpdateEntity){var i={};angular.forEach(r,function(e,t){r.hasOwnProperty(t)&&"col"!==t&&(i[t]=e)}),e.entity["$$"+r.col.uid]=i}})},treeFooterAggregationType:function(e,t){return s.finaliseAggregation(void 0,t.treeFooterAggregation),void 0===t.treeFooterAggregation.value||null===t.treeFooterAggregation.rendered?"":t.treeFooterAggregation.rendered}};return s}]),e.directive("uiGridTreeBaseRowHeaderButtons",["$templateCache","uiGridTreeBaseService",function(e,o){return{replace:!0,restrict:"E",template:e.get("ui-grid/treeBaseRowHeaderButtons"),scope:!0,require:"^uiGrid",link:function(e,t,r,i){var n=i.grid;e.treeButtonClass=function(e){if(n.options.showTreeExpandNoChildren&&-1 -1}":"{'ui-grid-tree-header-row': row.treeLevel > -1}",r.attr("ng-class",n),{pre:function(e,t,r,i){},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.treeView",["ui.grid","ui.grid.treeBase"]);e.constant("uiGridTreeViewConstants",{featureName:"treeView",rowHeaderColName:"treeBaseRowHeaderCol",EXPANDED:"expanded",COLLAPSED:"collapsed",aggregation:{COUNT:"count",SUM:"sum",MAX:"max",MIN:"min",AVG:"avg"}}),e.service("uiGridTreeViewService",["$q","uiGridTreeViewConstants","uiGridTreeBaseConstants","uiGridTreeBaseService","gridUtil","GridRow","gridClassFactory","i18nService","uiGridConstants",function(e,t,r,n,i,o,a,l,s){var d={initializeGrid:function(e,t){n.initializeGrid(e,t),e.treeView={},e.registerRowsProcessor(d.adjustSorting,60);var r={treeView:{}},i={treeView:{}};e.api.registerEventsFromObject(r),e.api.registerMethodsFromObject(i)},defaultGridOptions:function(e){e.enableTreeView=!1!==e.enableTreeView},adjustSorting:function(e){return this.columns.forEach(function(e){e.sort&&(e.sort.ignoreSort=!0)}),e}};return d}]),e.directive("uiGridTreeView",["uiGridTreeViewConstants","uiGridTreeViewService","$templateCache",function(e,n,t){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){!1!==i.grid.options.enableTreeView&&n.initializeGrid(i.grid,e)},post:function(e,t,r,i){}}}}}])}(),function(){"use strict";var e=angular.module("ui.grid.validate",["ui.grid"]);e.service("uiGridValidateService",["$sce","$q","$http","i18nService","uiGridConstants",function(n,u,e,o,t){var c={validatorFactories:{},setExternalFactoryFunction:function(e){c.externalFactoryFunction=e},clearExternalFactory:function(){delete c.externalFactoryFunction},getValidatorFromExternalFactory:function(e,t){return c.externalFactoryFunction(e,t).validatorFactory(t)},getMessageFromExternalFactory:function(e,t){return c.externalFactoryFunction(e,t).messageFunction(t)},setValidator:function(e,t,r){c.validatorFactories[e]={validatorFactory:t,messageFunction:r}},getValidator:function(e,t){if(c.externalFactoryFunction){var r=c.getValidatorFromExternalFactory(e,t);if(r)return r}if(!c.validatorFactories[e])throw"Invalid validator name: "+e;return c.validatorFactories[e].validatorFactory(t)},getMessage:function(e,t){if(c.externalFactoryFunction){var r=c.getMessageFromExternalFactory(e,t);if(r)return r}return c.validatorFactories[e].messageFunction(t)},isInvalid:function(e,t){return e["$$invalid"+t.name]},setInvalid:function(e,t){e["$$invalid"+t.name]=!0},setValid:function(e,t){delete e["$$invalid"+t.name]},setError:function(e,t,r){e["$$errors"+t.name]||(e["$$errors"+t.name]={}),e["$$errors"+t.name][r]=!0},clearError:function(e,t,r){e["$$errors"+t.name]&&r in e["$$errors"+t.name]&&delete e["$$errors"+t.name][r]},getErrorMessages:function(e,t){var r=[];return e["$$errors"+t.name]&&0!==Object.keys(e["$$errors"+t.name]).length&&Object.keys(e["$$errors"+t.name]).sort().forEach(function(e){r.push(c.getMessage(e,t.validators[e]))}),r},getFormattedErrors:function(e,t){var r="",i=c.getErrorMessages(e,t);if(i.length)return i.forEach(function(e){r+=e+"
    "}),n.trustAsHtml("

    "+o.getSafeText("validate.error")+"

    "+r)},getTitleFormattedErrors:function(e,t){var r="",i=c.getErrorMessages(e,t);if(i.length)return i.forEach(function(e){r+=e+"\n"}),n.trustAsHtml(o.getSafeText("validate.error")+"\n"+r)},runValidators:function(e,t,n,o,a){if(n!==o){if(void 0===t.name||!t.name)throw new Error("colDef.name is required to perform validation");c.setValid(e,t);var r=function(t,r,i){return function(e){e||(c.setInvalid(t,r),c.setError(t,r,i),a&&a.api.validate.raise.validationFailed(t,r,n,o))}},i=[];for(var l in t.validators){c.clearError(e,t,l);var s=c.getValidator(l,t.validators[l]),d=u.when(s(o,n,e,t)).then(r(e,t,l));i.push(d)}return u.all(i)}},createDefaultValidators:function(){c.setValidator("minLength",function(n){return function(e,t,r,i){return null==t||""===t||t.length>=n}},function(e){return o.getSafeText("validate.minLength").replace("THRESHOLD",e)}),c.setValidator("maxLength",function(n){return function(e,t,r,i){return null==t||""===t||t.length<=n}},function(e){return o.getSafeText("validate.maxLength").replace("THRESHOLD",e)}),c.setValidator("required",function(n){return function(e,t,r,i){return!n||!(null==t||""===t)}},function(e){return o.getSafeText("validate.required")})},initializeGrid:function(e,n){n.validate={isInvalid:c.isInvalid,getFormattedErrors:c.getFormattedErrors,getTitleFormattedErrors:c.getTitleFormattedErrors,runValidators:c.runValidators};var t={events:{validate:{validationFailed:function(e,t,r,i){}}},methods:{validate:{isInvalid:function(e,t){return n.validate.isInvalid(e,t)},getErrorMessages:function(e,t){return n.validate.getErrorMessages(e,t)},getFormattedErrors:function(e,t){return n.validate.getFormattedErrors(e,t)},getTitleFormattedErrors:function(e,t){return n.validate.getTitleFormattedErrors(e,t)}}}};n.api.registerEventsFromObject(t.events),n.api.registerMethodsFromObject(t.methods),n.edit&&n.api.edit.on.afterCellEdit(e,function(e,t,r,i){n.validate.runValidators(e,t,r,i,n)}),c.createDefaultValidators()}};return c}]),e.directive("uiGridValidate",["gridUtil","uiGridValidateService",function(e,n){return{priority:0,replace:!0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,t,r,i){n.initializeGrid(e,i.grid)},post:function(e,t,r,i){}}}}}])}(),angular.module("ui.grid").run(["$templateCache",function(e){"use strict";e.put("ui-grid/ui-grid-filter",'
     
     
    '),e.put("ui-grid/ui-grid-footer",''),e.put("ui-grid/ui-grid-grid-footer",''),e.put("ui-grid/ui-grid-header",'
    \x3c!-- theader --\x3e
    '),e.put("ui-grid/ui-grid-menu-button",'
     
    '),e.put("ui-grid/ui-grid-menu-header-item",'
  • '),e.put("ui-grid/ui-grid-no-header",'
    '),e.put("ui-grid/ui-grid-row","
    "),e.put("ui-grid/ui-grid",'
    \x3c!-- TODO (c0bra): add "scoped" attr here, eventually? --\x3e
    '),e.put("ui-grid/uiGridCell",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/uiGridColumnMenu",'
    \x3c!--
    \n
    \n
      \n
      \n
    • Sort Ascending
    • \n
    • Sort Descending
    • \n
    • Remove Sort
    • \n
      \n
    \n
    \n
    --\x3e
    '),e.put("ui-grid/uiGridFooterCell",'
    {{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}
    '),e.put("ui-grid/uiGridHeaderCell",'
    {{ col.displayName CUSTOM_FILTERS }} {{col.sort.priority + 1}}
    '),e.put("ui-grid/uiGridMenu",'
    '),e.put("ui-grid/uiGridMenuItem",''),e.put("ui-grid/uiGridRenderContainer","
    \x3c!-- All of these dom elements are replaced in place --\x3e
    "),e.put("ui-grid/uiGridViewport",'
    \x3c!-- tbody --\x3e
    '),e.put("ui-grid/cellEditor",'
    '),e.put("ui-grid/dropdownEditor",'
    '),e.put("ui-grid/fileChooserEditor",'
    '),e.put("ui-grid/emptyBaseLayerContainer",'
    '),e.put("ui-grid/expandableRow",'
    '),e.put("ui-grid/expandableRowHeader",'
    '),e.put("ui-grid/expandableScrollFiller","
    "),e.put("ui-grid/expandableTopRowHeader",'
    '),e.put("ui-grid/csvLink",'LINK_LABEL'),e.put("ui-grid/importerMenuItem",'
  • '),e.put("ui-grid/importerMenuItemContainer","
    "),e.put("ui-grid/pagination",'
    {{ 1 + paginationApi.getFirstRowIndex() }} - {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}
    '),e.put("ui-grid/columnResizer",'
    '),e.put("ui-grid/gridFooterSelectedItems",'({{"search.selectedItems" | t}} {{grid.selection.selectedCount}})'),e.put("ui-grid/selectionHeaderCell",'
    \x3c!--
     
    --\x3e
    '),e.put("ui-grid/selectionRowHeader",'
    '),e.put("ui-grid/selectionRowHeaderButtons",''),e.put("ui-grid/selectionSelectAllButtons",'
    '),e.put("ui-grid/treeBaseExpandAllButtons",'
    '),e.put("ui-grid/treeBaseHeaderCell",'
    '),e.put("ui-grid/treeBaseRowHeader",'
    '),e.put("ui-grid/treeBaseRowHeaderButtons",'
     
    '),e.put("ui-grid/cellTitleValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    '),e.put("ui-grid/cellTooltipValidator",'
    {{COL_FIELD CUSTOM_FILTERS}}
    ')}]); \ No newline at end of file diff --git a/release/ui-grid.move-columns.js b/release/ui-grid.move-columns.js index 75f5f953d..f65537c47 100644 --- a/release/ui-grid.move-columns.js +++ b/release/ui-grid.move-columns.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.move-columns.min.js b/release/ui-grid.move-columns.min.js index 66e6b6ea5..a61601ffc 100644 --- a/release/ui-grid.move-columns.min.js +++ b/release/ui-grid.move-columns.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.pagination.js b/release/ui-grid.pagination.js index d1ae79dc5..e1f0a6289 100644 --- a/release/ui-grid.pagination.js +++ b/release/ui-grid.pagination.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.pagination.min.js b/release/ui-grid.pagination.min.js index 337588c89..a7fa280a0 100644 --- a/release/ui-grid.pagination.min.js +++ b/release/ui-grid.pagination.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.pinning.js b/release/ui-grid.pinning.js index 3f2760900..79007c198 100644 --- a/release/ui-grid.pinning.js +++ b/release/ui-grid.pinning.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.pinning.min.js b/release/ui-grid.pinning.min.js index 59e442ad6..ea3df2511 100644 --- a/release/ui-grid.pinning.min.js +++ b/release/ui-grid.pinning.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.resize-columns.js b/release/ui-grid.resize-columns.js index 978eef6d4..5b748b42b 100644 --- a/release/ui-grid.resize-columns.js +++ b/release/ui-grid.resize-columns.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.resize-columns.min.js b/release/ui-grid.resize-columns.min.js index d4182ce14..1b1398048 100644 --- a/release/ui-grid.resize-columns.min.js +++ b/release/ui-grid.resize-columns.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.row-edit.js b/release/ui-grid.row-edit.js index 545fd5e27..afcf06ed5 100644 --- a/release/ui-grid.row-edit.js +++ b/release/ui-grid.row-edit.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.row-edit.min.js b/release/ui-grid.row-edit.min.js index 6c9303269..27a9ef4f6 100644 --- a/release/ui-grid.row-edit.min.js +++ b/release/ui-grid.row-edit.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.saveState.js b/release/ui-grid.saveState.js index b3dac23d4..1c0d05bea 100644 --- a/release/ui-grid.saveState.js +++ b/release/ui-grid.saveState.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.saveState.min.js b/release/ui-grid.saveState.min.js index 67c63b272..51484c9c6 100644 --- a/release/ui-grid.saveState.min.js +++ b/release/ui-grid.saveState.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.selection.js b/release/ui-grid.selection.js index 81209d8cb..7b9770e51 100644 --- a/release/ui-grid.selection.js +++ b/release/ui-grid.selection.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.selection.min.js b/release/ui-grid.selection.min.js index f1af0593f..c018be7fe 100644 --- a/release/ui-grid.selection.min.js +++ b/release/ui-grid.selection.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.tree-base.js b/release/ui-grid.tree-base.js index 1304d9da4..2baed26a2 100644 --- a/release/ui-grid.tree-base.js +++ b/release/ui-grid.tree-base.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.tree-base.min.js b/release/ui-grid.tree-base.min.js index a6fe15db3..bb41e74ec 100644 --- a/release/ui-grid.tree-base.min.js +++ b/release/ui-grid.tree-base.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.tree-view.js b/release/ui-grid.tree-view.js index 31ead0abb..7da3f2dcd 100644 --- a/release/ui-grid.tree-view.js +++ b/release/ui-grid.tree-view.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.tree-view.min.js b/release/ui-grid.tree-view.min.js index 31656aff9..2b161a073 100644 --- a/release/ui-grid.tree-view.min.js +++ b/release/ui-grid.tree-view.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.validate.js b/release/ui-grid.validate.js index bb0fcbe80..b1fde4fef 100644 --- a/release/ui-grid.validate.js +++ b/release/ui-grid.validate.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */ diff --git a/release/ui-grid.validate.min.js b/release/ui-grid.validate.min.js index 56a81d37e..3f9e6c2ea 100644 --- a/release/ui-grid.validate.min.js +++ b/release/ui-grid.validate.min.js @@ -1,5 +1,5 @@ /*! - * ui-grid - v4.4.10 - 2018-05-15 + * ui-grid - v4.4.11 - 2018-05-16 * Copyright (c) 2018 ; License: MIT */