@easyquery/ui 7.2.3 → 7.2.4-beta03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/dist/browser/eq.community.css.map +1 -1
  2. package/dist/browser/eq.community.js +32587 -34147
  3. package/dist/browser/eq.community.js.map +1 -1
  4. package/dist/browser/eq.community.min.js +1 -9
  5. package/dist/browser/eq.community.min.js.map +1 -1
  6. package/dist/browser/eq.core.css +17 -112
  7. package/dist/browser/eq.core.min.css +3 -10
  8. package/dist/browser/eq.view.css +1 -1
  9. package/dist/browser/eq.view.css.map +1 -1
  10. package/dist/browser/eq.view.min.css +1 -10
  11. package/dist/bundles/easyquery.ui.js +23032 -22870
  12. package/dist/bundles/easyquery.ui.js.map +1 -1
  13. package/dist/bundles/easyquery.ui.min.js +1 -1
  14. package/dist/bundles/easyquery.ui.min.js.map +1 -1
  15. package/dist/lib/dialog/aggr_settings_dialog.d.ts +12 -12
  16. package/dist/lib/dialog/aggr_settings_dialog.js +106 -106
  17. package/dist/lib/dialog/export_dialog.d.ts +7 -7
  18. package/dist/lib/dialog/export_dialog.js +63 -63
  19. package/dist/lib/extensions.d.ts +7 -7
  20. package/dist/lib/extensions.js +13 -13
  21. package/dist/lib/facets/chart_facet.d.ts +21 -21
  22. package/dist/lib/facets/chart_facet.js +240 -238
  23. package/dist/lib/facets/chart_facet.js.map +1 -1
  24. package/dist/lib/facets/datatable_facet.d.ts +15 -15
  25. package/dist/lib/facets/datatable_facet.js +71 -69
  26. package/dist/lib/facets/datatable_facet.js.map +1 -1
  27. package/dist/lib/facets/pivot_table_facet.d.ts +51 -51
  28. package/dist/lib/facets/pivot_table_facet.js +698 -696
  29. package/dist/lib/facets/pivot_table_facet.js.map +1 -1
  30. package/dist/lib/facets/result_facet.d.ts +40 -40
  31. package/dist/lib/facets/result_facet.js +246 -246
  32. package/dist/lib/facets/result_facet.js.map +1 -1
  33. package/dist/lib/i18n/text_resources.d.ts +1 -1
  34. package/dist/lib/i18n/text_resources.js +260 -259
  35. package/dist/lib/i18n/text_resources.js.map +1 -1
  36. package/dist/lib/public_api.d.ts +61 -61
  37. package/dist/lib/public_api.js +92 -90
  38. package/dist/lib/public_api.js.map +1 -1
  39. package/dist/lib/types/facet_type.d.ts +5 -5
  40. package/dist/lib/types/facet_type.js +6 -6
  41. package/dist/lib/types/qp_editable_part.d.ts +15 -15
  42. package/dist/lib/types/qp_editable_part.js +16 -16
  43. package/dist/lib/utils/browser_utils.d.ts +8 -8
  44. package/dist/lib/utils/browser_utils.js +58 -58
  45. package/dist/lib/utils/display_format_parser.d.ts +11 -11
  46. package/dist/lib/utils/display_format_parser.js +61 -61
  47. package/dist/lib/utils/dropdown.d.ts +11 -11
  48. package/dist/lib/utils/dropdown.js +57 -55
  49. package/dist/lib/utils/dropdown.js.map +1 -1
  50. package/dist/lib/utils/popup_menu.d.ts +163 -163
  51. package/dist/lib/utils/popup_menu.js +1259 -1260
  52. package/dist/lib/utils/popup_menu.js.map +1 -1
  53. package/dist/lib/utils/utils.d.ts +9 -9
  54. package/dist/lib/utils/utils.js +46 -46
  55. package/dist/lib/utils/utils.js.map +1 -1
  56. package/dist/lib/views/adv_search_view.d.ts +95 -95
  57. package/dist/lib/views/adv_search_view.js +712 -710
  58. package/dist/lib/views/adv_search_view.js.map +1 -1
  59. package/dist/lib/views/data_filter_view.d.ts +17 -17
  60. package/dist/lib/views/data_filter_view.js +79 -77
  61. package/dist/lib/views/data_filter_view.js.map +1 -1
  62. package/dist/lib/views/html_data_filter_view.d.ts +19 -19
  63. package/dist/lib/views/html_data_filter_view.js +44 -42
  64. package/dist/lib/views/html_data_filter_view.js.map +1 -1
  65. package/dist/lib/views/report_view.d.ts +173 -173
  66. package/dist/lib/views/report_view.js +733 -731
  67. package/dist/lib/views/report_view.js.map +1 -1
  68. package/dist/lib/views/view.d.ts +149 -149
  69. package/dist/lib/views/view.js +538 -538
  70. package/dist/lib/views/view.js.map +1 -1
  71. package/dist/lib/views/view_options.d.ts +113 -113
  72. package/dist/lib/views/view_options.js +1 -0
  73. package/dist/lib/widgets/aggregation_bar.d.ts +30 -30
  74. package/dist/lib/widgets/aggregation_bar.js +145 -143
  75. package/dist/lib/widgets/aggregation_bar.js.map +1 -1
  76. package/dist/lib/widgets/charts/chart_type.d.ts +14 -14
  77. package/dist/lib/widgets/charts/chart_type.js +15 -15
  78. package/dist/lib/widgets/charts/chart_widget.d.ts +92 -92
  79. package/dist/lib/widgets/charts/chart_widget.js +384 -382
  80. package/dist/lib/widgets/charts/chart_widget.js.map +1 -1
  81. package/dist/lib/widgets/charts/chart_widget_chartjs.d.ts +23 -23
  82. package/dist/lib/widgets/charts/chart_widget_chartjs.js +186 -184
  83. package/dist/lib/widgets/charts/chart_widget_chartjs.js.map +1 -1
  84. package/dist/lib/widgets/charts/chart_widget_google.d.ts +23 -23
  85. package/dist/lib/widgets/charts/chart_widget_google.js +165 -163
  86. package/dist/lib/widgets/charts/chart_widget_google.js.map +1 -1
  87. package/dist/lib/widgets/columns_bar.d.ts +64 -64
  88. package/dist/lib/widgets/columns_bar.js +722 -721
  89. package/dist/lib/widgets/columns_bar.js.map +1 -1
  90. package/dist/lib/widgets/columns_panel.d.ts +64 -62
  91. package/dist/lib/widgets/columns_panel.js +739 -721
  92. package/dist/lib/widgets/columns_panel.js.map +1 -1
  93. package/dist/lib/widgets/easy_grid_widget.d.ts +38 -38
  94. package/dist/lib/widgets/easy_grid_widget.js +229 -227
  95. package/dist/lib/widgets/easy_grid_widget.js.map +1 -1
  96. package/dist/lib/widgets/entities_panel.d.ts +49 -49
  97. package/dist/lib/widgets/entities_panel.js +627 -625
  98. package/dist/lib/widgets/entities_panel.js.map +1 -1
  99. package/dist/lib/widgets/eq_result_html_grid.d.ts +32 -32
  100. package/dist/lib/widgets/eq_result_html_grid.js +185 -183
  101. package/dist/lib/widgets/eq_result_html_grid.js.map +1 -1
  102. package/dist/lib/widgets/export_widget.d.ts +10 -10
  103. package/dist/lib/widgets/export_widget.js +57 -55
  104. package/dist/lib/widgets/export_widget.js.map +1 -1
  105. package/dist/lib/widgets/facet_container.d.ts +12 -12
  106. package/dist/lib/widgets/facet_container.js +53 -51
  107. package/dist/lib/widgets/facet_container.js.map +1 -1
  108. package/dist/lib/widgets/filter_bar.d.ts +38 -38
  109. package/dist/lib/widgets/filter_bar.js +259 -257
  110. package/dist/lib/widgets/filter_bar.js.map +1 -1
  111. package/dist/lib/widgets/grid.d.ts +35 -35
  112. package/dist/lib/widgets/grid.js +79 -77
  113. package/dist/lib/widgets/grid.js.map +1 -1
  114. package/dist/lib/widgets/html_content_widget.d.ts +35 -35
  115. package/dist/lib/widgets/html_content_widget.js +71 -69
  116. package/dist/lib/widgets/html_content_widget.js.map +1 -1
  117. package/dist/lib/widgets/locale_widget.d.ts +16 -16
  118. package/dist/lib/widgets/locale_widget.js +79 -77
  119. package/dist/lib/widgets/locale_widget.js.map +1 -1
  120. package/dist/lib/widgets/manage_drilldown_widget.d.ts +18 -18
  121. package/dist/lib/widgets/manage_drilldown_widget.js +154 -152
  122. package/dist/lib/widgets/manage_drilldown_widget.js.map +1 -1
  123. package/dist/lib/widgets/process_widget.d.ts +21 -21
  124. package/dist/lib/widgets/process_widget.js +50 -48
  125. package/dist/lib/widgets/process_widget.js.map +1 -1
  126. package/dist/lib/widgets/query_panel.d.ts +62 -58
  127. package/dist/lib/widgets/query_panel.js +675 -653
  128. package/dist/lib/widgets/query_panel.js.map +1 -1
  129. package/dist/lib/widgets/queryname_widget.d.ts +27 -27
  130. package/dist/lib/widgets/queryname_widget.js +109 -107
  131. package/dist/lib/widgets/queryname_widget.js.map +1 -1
  132. package/dist/lib/widgets/renderers/aggr_settings/aggr_settings_renderer.d.ts +54 -54
  133. package/dist/lib/widgets/renderers/aggr_settings/aggr_settings_renderer.js +429 -429
  134. package/dist/lib/widgets/renderers/aggr_settings/aggr_settings_renderer.js.map +1 -1
  135. package/dist/lib/widgets/renderers/base_element_renderer.d.ts +15 -15
  136. package/dist/lib/widgets/renderers/base_element_renderer.js +63 -63
  137. package/dist/lib/widgets/renderers/columnsbar/aggrfunc_column_renderer.d.ts +11 -11
  138. package/dist/lib/widgets/renderers/columnsbar/aggrfunc_column_renderer.js +62 -60
  139. package/dist/lib/widgets/renderers/columnsbar/aggrfunc_column_renderer.js.map +1 -1
  140. package/dist/lib/widgets/renderers/columnsbar/column_renderer_cb.d.ts +53 -53
  141. package/dist/lib/widgets/renderers/columnsbar/column_renderer_cb.js +550 -550
  142. package/dist/lib/widgets/renderers/columnsbar/column_renderer_cb.js.map +1 -1
  143. package/dist/lib/widgets/renderers/columnsbar/simple_column_renderer.d.ts +9 -9
  144. package/dist/lib/widgets/renderers/columnsbar/simple_column_renderer.js +79 -77
  145. package/dist/lib/widgets/renderers/columnsbar/simple_column_renderer.js.map +1 -1
  146. package/dist/lib/widgets/renderers/columnspanel/aggrfunc_column_renderer.d.ts +17 -17
  147. package/dist/lib/widgets/renderers/columnspanel/aggrfunc_column_renderer.js +180 -178
  148. package/dist/lib/widgets/renderers/columnspanel/aggrfunc_column_renderer.js.map +1 -1
  149. package/dist/lib/widgets/renderers/columnspanel/column_renderer_cp.d.ts +72 -72
  150. package/dist/lib/widgets/renderers/columnspanel/column_renderer_cp.js +819 -817
  151. package/dist/lib/widgets/renderers/columnspanel/column_renderer_cp.js.map +1 -1
  152. package/dist/lib/widgets/renderers/columnspanel/customsql_column_renderer.d.ts +22 -18
  153. package/dist/lib/widgets/renderers/columnspanel/customsql_column_renderer.js +245 -214
  154. package/dist/lib/widgets/renderers/columnspanel/customsql_column_renderer.js.map +1 -1
  155. package/dist/lib/widgets/renderers/columnspanel/simple_column_renderer.d.ts +13 -13
  156. package/dist/lib/widgets/renderers/columnspanel/simple_column_renderer.js +180 -178
  157. package/dist/lib/widgets/renderers/columnspanel/simple_column_renderer.js.map +1 -1
  158. package/dist/lib/widgets/renderers/dropdown_renderer.d.ts +9 -9
  159. package/dist/lib/widgets/renderers/dropdown_renderer.js +42 -40
  160. package/dist/lib/widgets/renderers/dropdown_renderer.js.map +1 -1
  161. package/dist/lib/widgets/renderers/querypanel/addrow_renderer.d.ts +16 -16
  162. package/dist/lib/widgets/renderers/querypanel/addrow_renderer.js +87 -85
  163. package/dist/lib/widgets/renderers/querypanel/addrow_renderer.js.map +1 -1
  164. package/dist/lib/widgets/renderers/querypanel/attribute_expression_renderer.d.ts +14 -14
  165. package/dist/lib/widgets/renderers/querypanel/attribute_expression_renderer.js +71 -69
  166. package/dist/lib/widgets/renderers/querypanel/attribute_expression_renderer.js.map +1 -1
  167. package/dist/lib/widgets/renderers/querypanel/bind_to_parent_column_expression_renderer.d.ts +7 -7
  168. package/dist/lib/widgets/renderers/querypanel/bind_to_parent_column_expression_renderer.js +41 -39
  169. package/dist/lib/widgets/renderers/querypanel/bind_to_parent_column_expression_renderer.js.map +1 -1
  170. package/dist/lib/widgets/renderers/querypanel/condition_group_renderer.d.ts +27 -27
  171. package/dist/lib/widgets/renderers/querypanel/condition_group_renderer.js +231 -229
  172. package/dist/lib/widgets/renderers/querypanel/condition_group_renderer.js.map +1 -1
  173. package/dist/lib/widgets/renderers/querypanel/condition_renderer.d.ts +48 -48
  174. package/dist/lib/widgets/renderers/querypanel/condition_renderer.js +509 -507
  175. package/dist/lib/widgets/renderers/querypanel/condition_renderer.js.map +1 -1
  176. package/dist/lib/widgets/renderers/querypanel/datetime_expression_render.d.ts +13 -13
  177. package/dist/lib/widgets/renderers/querypanel/datetime_expression_render.js +108 -106
  178. package/dist/lib/widgets/renderers/querypanel/datetime_expression_render.js.map +1 -1
  179. package/dist/lib/widgets/renderers/querypanel/expression_renderer.d.ts +28 -28
  180. package/dist/lib/widgets/renderers/querypanel/expression_renderer.js +91 -89
  181. package/dist/lib/widgets/renderers/querypanel/expression_renderer.js.map +1 -1
  182. package/dist/lib/widgets/renderers/querypanel/input_expression_renderer.d.ts +14 -14
  183. package/dist/lib/widgets/renderers/querypanel/input_expression_renderer.js +165 -163
  184. package/dist/lib/widgets/renderers/querypanel/input_expression_renderer.js.map +1 -1
  185. package/dist/lib/widgets/renderers/querypanel/list_expression_renderer.d.ts +35 -35
  186. package/dist/lib/widgets/renderers/querypanel/list_expression_renderer.js +317 -315
  187. package/dist/lib/widgets/renderers/querypanel/list_expression_renderer.js.map +1 -1
  188. package/dist/lib/widgets/renderers/querypanel/operator_renderer.d.ts +19 -19
  189. package/dist/lib/widgets/renderers/querypanel/operator_renderer.js +95 -93
  190. package/dist/lib/widgets/renderers/querypanel/operator_renderer.js.map +1 -1
  191. package/dist/lib/widgets/renderers/querypanel/subquery_expression_renderer.d.ts +27 -27
  192. package/dist/lib/widgets/renderers/querypanel/subquery_expression_renderer.js +237 -235
  193. package/dist/lib/widgets/renderers/querypanel/subquery_expression_renderer.js.map +1 -1
  194. package/dist/lib/widgets/renderers/querypanel/text_renderer.d.ts +11 -11
  195. package/dist/lib/widgets/renderers/querypanel/text_renderer.js +36 -36
  196. package/dist/lib/widgets/renderers/querypanel/text_renderer.js.map +1 -1
  197. package/dist/lib/widgets/renderers/sortingbar/column_renderer_sp.d.ts +26 -26
  198. package/dist/lib/widgets/renderers/sortingbar/column_renderer_sp.js +163 -163
  199. package/dist/lib/widgets/renderers/sortingbar/column_renderer_sp.js.map +1 -1
  200. package/dist/lib/widgets/result_facets_panel.d.ts +64 -64
  201. package/dist/lib/widgets/result_facets_panel.js +503 -501
  202. package/dist/lib/widgets/result_facets_panel.js.map +1 -1
  203. package/dist/lib/widgets/sorting_bar.d.ts +34 -34
  204. package/dist/lib/widgets/sorting_bar.js +330 -328
  205. package/dist/lib/widgets/sorting_bar.js.map +1 -1
  206. package/dist/lib/widgets/statement_panel.d.ts +21 -21
  207. package/dist/lib/widgets/statement_panel.js +60 -58
  208. package/dist/lib/widgets/statement_panel.js.map +1 -1
  209. package/dist/lib/widgets/widget_options.d.ts +433 -429
  210. package/dist/lib/widgets/widget_options.js +1 -0
  211. package/package.json +25 -25
  212. package/webpack.config.js +31 -24
  213. package/dist/browser/eq.community.min.css.map +0 -1
  214. package/dist/browser/eq.view.min.css.map +0 -1
@@ -1,502 +1,504 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- extendStatics(d, b);
10
- function __() { this.constructor = d; }
11
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
- };
13
- })();
14
- import { WidgetGroup, QueryChangePart, QueryChangeAction, } from '@easyquery/core';
15
- import { i18n, utils as dataUtils } from '@easydata/core';
16
- import { domel } from '@easydata/ui';
17
- import { FacetType } from '../types/facet_type';
18
- import { browserUtils } from '../utils/browser_utils';
19
- import { PopupMenu } from '../utils/popup_menu';
20
- import { eqCssPrefix } from '../utils/utils';
21
- import { ExportDialog } from '../dialog/export_dialog';
22
- import { FacetContainer } from './facet_container';
23
- var ResultFacetsPanel = /** @class */ (function (_super) {
24
- __extends(ResultFacetsPanel, _super);
25
- function ResultFacetsPanel(slot) {
26
- var _this = _super.call(this, slot) || this;
27
- _this.activeFacetIndex = -1;
28
- _this.firstRender = true;
29
- _this.options = {
30
- showExportButton: true,
31
- showRefreshButton: true,
32
- showMaximizeButton: true,
33
- maximize2Window: false,
34
- showProcessIndicator: true,
35
- facetTypes: [FacetType.DataGrid, FacetType.Chart, FacetType.PivotTable]
36
- };
37
- _this.menuItems = [
38
- { id: FacetType.DataGrid, text: i18n.getText('Facets', 'AddMenuItems', 'DataTable') },
39
- { id: FacetType.Chart, text: i18n.getText('Facets', 'AddMenuItems', 'Chart') },
40
- { id: FacetType.PivotTable, text: i18n.getText('Facets', 'AddMenuItems', 'Pivot') }
41
- ];
42
- _this.menuItemsFilter = function (item) {
43
- if (_this.options.facetTypes.indexOf(item.id) < 0)
44
- return false;
45
- if (item.id === FacetType.DataGrid) {
46
- return _this.facets.filter(function (facet) { return facet.getType() == FacetType.DataGrid; }).length === 0;
47
- }
48
- return true;
49
- };
50
- if (!_this.slot.classList.contains(_this.cssPrefix + "-panel")) {
51
- _this.slot.classList.add(_this.cssPrefix + "-panel");
52
- }
53
- _this.renderProcessBlock();
54
- return _this;
55
- }
56
- Object.defineProperty(ResultFacetsPanel.prototype, "cssPrefix", {
57
- get: function () {
58
- return 'eqjs-facets';
59
- },
60
- enumerable: true,
61
- configurable: true
62
- });
63
- ResultFacetsPanel.prototype.getWidgetType = function () {
64
- return 'facetsPanel';
65
- };
66
- /**
67
- * Initialize widget.
68
- * @param context The context.
69
- * @param options The options.
70
- */
71
- ResultFacetsPanel.prototype.init = function (context, options) {
72
- _super.prototype.init.call(this, context, options);
73
- this.setOptions(options);
74
- this.destroyCore();
75
- this.attachQueryObserver();
76
- this.loadFacets();
77
- };
78
- ResultFacetsPanel.prototype.attachQueryObserver = function () {
79
- var _this = this;
80
- var query = this.getQuery();
81
- if (this.queryEventCallbackId) {
82
- query.removeChangedCallback(this.queryEventCallbackId);
83
- }
84
- this.queryEventCallbackId = query.addChangedCallback(function (event) {
85
- //if something has changed, and that change is related to columns
86
- var edata = event.data;
87
- if (edata.part != QueryChangePart.All) {
88
- return;
89
- }
90
- if (edata.source == _this) {
91
- return;
92
- }
93
- _this.reloadFacets();
94
- _this.refreshCore(true);
95
- });
96
- };
97
- ResultFacetsPanel.prototype.refreshCore = function (force) {
98
- if (force === void 0) { force = false; }
99
- if (this.firstRender || force) {
100
- this.clear();
101
- this.createAddMenu();
102
- this.render();
103
- }
104
- this.validateAddFacetButton();
105
- this.renderActiveFacet();
106
- this.updateTotalRecords();
107
- };
108
- ResultFacetsPanel.prototype.createAddMenu = function () {
109
- this.addMenu = new PopupMenu({
110
- items: this.menuItems,
111
- id: "FacetType-List"
112
- });
113
- };
114
- ResultFacetsPanel.prototype.updateTotalRecords = function () {
115
- var context = this.getContext();
116
- var total = context.resultTable.getTotal();
117
- this.recordsDiv.innerHTML = i18n.getText('Facets', 'TotalRecordsLabel') + ' ' + total;
118
- if (total == 0) {
119
- domel(this.exportDiv).hide();
120
- }
121
- else {
122
- domel(this.exportDiv).show();
123
- }
124
- };
125
- ResultFacetsPanel.prototype.renderProcessBlock = function () {
126
- var html = '<div class="wBall" id="wBall_1"><div class="wInnerBall"></div></div><div class="wBall" id="wBall_2"><div class="wInnerBall"></div></div><div class="wBall" id="wBall_3"><div class="wInnerBall"></div></div><div class="wBall" id="wBall_4"><div class="wInnerBall"></div></div><div class="wBall" id="wBall_5"><div class="wInnerBall"></div></div>';
127
- ;
128
- this._processBlock = domel('div')
129
- .addClass(this.cssPrefix + "-spinner")
130
- .addChild('div', function (b) { return b
131
- .addClass(eqCssPrefix + "-progress-win8", browserUtils.getMobileCssClass())
132
- .addHtml(html); })
133
- .toDOM();
134
- };
135
- ResultFacetsPanel.prototype.onProcessStartCore = function () {
136
- if (this.options.showProcessIndicator) {
137
- // FacetsPanel might be not rendered yet, so
138
- // it has no body
139
- if (!this._processBlock.parentNode && this.bodyDiv) {
140
- this.bodyDiv.childNodes.forEach(function (el) {
141
- domel(el).hide();
142
- });
143
- this.bodyDiv.appendChild(this._processBlock);
144
- }
145
- }
146
- };
147
- ResultFacetsPanel.prototype.onProcessEndCore = function () {
148
- if (this.options.showProcessIndicator) {
149
- if (this._processBlock.parentNode) {
150
- try {
151
- this._processBlock.parentNode
152
- .removeChild(this._processBlock);
153
- }
154
- catch (e) {
155
- }
156
- finally {
157
- this.renderActiveFacet(false);
158
- }
159
- }
160
- }
161
- };
162
- ResultFacetsPanel.prototype.render = function () {
163
- var _this = this;
164
- this.firstRender = false;
165
- this.headerDiv = domel('div', this.slot)
166
- .addClass(this.cssPrefix + "-header")
167
- .toDOM();
168
- this.tabsDiv =
169
- domel('div', this.headerDiv)
170
- .addClass(this.cssPrefix + "-tabs")
171
- .toDOM();
172
- this.tabsUl = domel('ul', this.tabsDiv)
173
- .addClass(this.cssPrefix + "-nav-tabs")
174
- .toDOM();
175
- this.bodyDiv =
176
- domel('div', this.slot)
177
- .addClass(this.cssPrefix + "-body")
178
- .toDOM();
179
- for (var _i = 0, _a = this.facets; _i < _a.length; _i++) {
180
- var facet = _a[_i];
181
- this.renderFacet(facet);
182
- }
183
- domel(this.tabsDiv)
184
- .addChild('div', function (b) { return _this.addFacetButton = b
185
- .addClass(_this.cssPrefix + "-add-button")
186
- .title(i18n.getText('Facets', 'NewFacetTitle'))
187
- .addChild('a', function (b) { return b
188
- .attr('href', 'javascript:void(0)'); })
189
- .on('click', function (e) { return _this.addClickHandler(e); })
190
- .toDOM(); });
191
- var manageDiv = domel('div', this.headerDiv)
192
- .addClass(this.cssPrefix + "-manage")
193
- .toDOM();
194
- this.recordsDiv = domel('div', manageDiv)
195
- .addClass(this.cssPrefix + "-total-recs")
196
- .toDOM();
197
- if (this.options.showRefreshButton || this.options.showExportButton || this.options.showMaximizeButton) {
198
- var bdb = domel('div', manageDiv)
199
- .addClass(this.cssPrefix + "-total-buttons")
200
- .toDOM();
201
- if (this.options.showExportButton) {
202
- this.exportDiv = domel('button', bdb)
203
- .on('click', function () { return _this.exportHandler(); })
204
- .addClass(this.cssPrefix + "-button")
205
- .addClass(this.cssPrefix + "-button-export")
206
- .title(i18n.getText('Facets', 'ExportBtnTitle'))
207
- .toDOM();
208
- }
209
- if (this.options.showRefreshButton) {
210
- domel('button', bdb)
211
- .on('click', function () { return _this.refreshHandler(); })
212
- .addClass(this.cssPrefix + "-button")
213
- .addClass(this.cssPrefix + "-button-refresh")
214
- .title(i18n.getText('Facets', 'RefreshBtnTitle'));
215
- }
216
- if (this.options.showMaximizeButton) {
217
- this.maximizeButton = domel('button', bdb)
218
- .on('click', function () { return _this.options.maximize2Window ? _this.maximizeHandler(true) : _this.maximizeHandler(); })
219
- .addClass(this.cssPrefix + "-button")
220
- .addClass(this.cssPrefix + "-button-maximize")
221
- .title(i18n.getText('Facets', 'MaximizeBtnTitle'))
222
- .toDOM();
223
- }
224
- }
225
- };
226
- ResultFacetsPanel.prototype.refreshHandler = function () {
227
- var context = this.getContext();
228
- context.fetchData({
229
- success: function () {
230
- // possibly we should move this logic to context
231
- context.refreshWidgets(WidgetGroup.Result);
232
- }
233
- });
234
- };
235
- ResultFacetsPanel.prototype.exportHandler = function () {
236
- var context = this.getContext();
237
- new ExportDialog(context)
238
- .show();
239
- };
240
- ResultFacetsPanel.prototype.maximizeHandler = function (toWindow) {
241
- var b = domel(this.slot);
242
- if (toWindow) {
243
- b.toggleClass(eqCssPrefix + "-maximized-2window");
244
- if (this.slot.classList.contains(eqCssPrefix + "-maximized-2window")) {
245
- this.maximizeButton.title = i18n.getText('Facets', 'RestoreBtnTitle');
246
- this.maximizeButton.classList.toggle(this.cssPrefix + "-button-maximize", false);
247
- this.maximizeButton.classList.toggle(this.cssPrefix + "-button-restore", true);
248
- }
249
- else {
250
- this.maximizeButton.title = i18n.getText('Facets', 'MaximizeBtnTitle');
251
- this.maximizeButton.classList.toggle(this.cssPrefix + "-button-restore", false);
252
- this.maximizeButton.classList.toggle(this.cssPrefix + "-button-maximize", true);
253
- }
254
- }
255
- else {
256
- var isMaximized_1 = !this.slot.hasAttribute('data-is-maximized');
257
- if (isMaximized_1) {
258
- this.slot.setAttribute('data-is-maximized', '');
259
- this.maximizeButton.title = i18n.getText('Facets', 'RestoreBtnTitle');
260
- this.maximizeButton.classList.toggle(this.cssPrefix + "-button-maximize", false);
261
- this.maximizeButton.classList.toggle(this.cssPrefix + "-button-restore", true);
262
- }
263
- else {
264
- this.slot.removeAttribute('data-is-maximized');
265
- this.maximizeButton.title = i18n.getText('Facets', 'MaximizeBtnTitle');
266
- this.maximizeButton.classList.toggle(this.cssPrefix + "-button-restore", false);
267
- this.maximizeButton.classList.toggle(this.cssPrefix + "-button-maximize", true);
268
- }
269
- var arrToHide = document.querySelectorAll('[data-hide-on-max]');
270
- arrToHide.forEach(function (el) {
271
- if (isMaximized_1) {
272
- el.setAttribute('style', 'display: none;');
273
- }
274
- else {
275
- el.removeAttribute('style');
276
- }
277
- });
278
- }
279
- this.facets.forEach(function (facetTab) { return facetTab.onResize(); });
280
- };
281
- ResultFacetsPanel.prototype.renderActiveFacet = function (refresh) {
282
- var _this = this;
283
- if (refresh === void 0) { refresh = true; }
284
- this.tabsUl.querySelectorAll('li') //`.${this.cssPrefix}-header-item.${this.cssPrefix}-facet`)
285
- .forEach(function (el, index) {
286
- if (el.classList.contains('active')) {
287
- el.classList.remove('active');
288
- }
289
- if (_this.activeFacetIndex === index) {
290
- el.classList.add('active');
291
- }
292
- });
293
- this.bodyDiv.querySelectorAll("." + eqCssPrefix + "-facet")
294
- .forEach(function (el, index) {
295
- domel(el).hide();
296
- if (_this.activeFacetIndex === index) {
297
- domel(el).show();
298
- if (refresh) {
299
- _this.facets[index].refresh();
300
- }
301
- }
302
- });
303
- };
304
- ResultFacetsPanel.prototype.renderFacet = function (facet) {
305
- this.renderFacetTab(facet);
306
- var body = this.renderFacetSlot(facet);
307
- facet.init(body);
308
- };
309
- ResultFacetsPanel.prototype.renderFacetTab = function (facet) {
310
- var _this = this;
311
- return domel('li', this.tabsUl)
312
- //.addClass(`${this.cssPrefix}-header-item`, `${this.cssPrefix}-facet`)
313
- //facet settings button
314
- .addChild('span', function (b) { return b
315
- .addClass(eqCssPrefix + "-facet-settings")
316
- .on('click', function (e) {
317
- e.stopPropagation();
318
- _this.settingsClickHandler(facet);
319
- }); })
320
- .addChild('a', function (b) { return b
321
- .addText(facet.title)
322
- .attr('href', 'javascript:void(0)'); })
323
- //facet close button
324
- .addChild('span', function (b) { return b
325
- .addClass(eqCssPrefix + "-facet-close")
326
- .on('click', function (e) {
327
- e.stopPropagation();
328
- _this.closeClickHandler(facet);
329
- }); })
330
- .on('click', function (e) { return _this.selectClickHandler(facet); })
331
- .toDOM();
332
- };
333
- ResultFacetsPanel.prototype.renderFacetSlot = function (facet) {
334
- var element = domel('div', this.bodyDiv)
335
- .addClass(eqCssPrefix + "-facet")
336
- .hide()
337
- .toDOM();
338
- return element;
339
- };
340
- ResultFacetsPanel.prototype.refreshFacetTabs = function () {
341
- var _this = this;
342
- this.tabsUl.querySelectorAll('li') //`.${this.cssPrefix}-header-item.${this.cssPrefix}-facet`)
343
- .forEach(function (item) {
344
- _this.tabsUl.removeChild(item);
345
- });
346
- for (var _i = 0, _a = this.facets; _i < _a.length; _i++) {
347
- var facet = _a[_i];
348
- this.renderFacetTab(facet);
349
- }
350
- };
351
- ResultFacetsPanel.prototype.removeFacet = function (facet) {
352
- var index = this.facets.indexOf(facet);
353
- if (index >= 0) {
354
- this.facets.splice(index, 1);
355
- var header = this.tabsUl.childNodes[index];
356
- this.tabsUl.removeChild(header);
357
- var body = this.bodyDiv.childNodes[index];
358
- this.bodyDiv.removeChild(body);
359
- if (this.facets.length > 0) {
360
- this.activeFacetIndex =
361
- index < this.facets.length
362
- ? index
363
- : this.facets.length - 1;
364
- }
365
- else {
366
- this.activeFacetIndex = -1;
367
- }
368
- this.renderActiveFacet();
369
- this.validateAddFacetButton();
370
- }
371
- };
372
- ResultFacetsPanel.prototype.addClickHandler = function (ev) {
373
- var _this = this;
374
- this.addMenu.showMenu({
375
- anchor: ev.target,
376
- itemFilterCallback: this.menuItemsFilter,
377
- itemSelectedCallback: function (data) {
378
- var facet = _this.createFacetTab(data.id);
379
- var facetSlot = _this.renderFacetSlot(facet);
380
- facet.init(facetSlot);
381
- facet.showSettingsDialog()
382
- .then(function (submited) {
383
- if (submited) {
384
- _this.facets.push(facet);
385
- _this.activeFacetIndex = _this.facets.length - 1;
386
- _this.renderFacetTab(facet);
387
- _this.renderActiveFacet();
388
- _this.saveFacets();
389
- }
390
- else {
391
- _this.bodyDiv.removeChild(facetSlot);
392
- }
393
- //this.validateAddFacetButton();
394
- })
395
- .catch(function (error) { return console.error(error); });
396
- }
397
- });
398
- };
399
- ResultFacetsPanel.prototype.selectClickHandler = function (facet) {
400
- var index = this.facets.indexOf(facet);
401
- this.setActiveFacet(index);
402
- };
403
- ResultFacetsPanel.prototype.settingsClickHandler = function (facet) {
404
- var _this = this;
405
- facet.showSettingsDialog()
406
- .then(function (submited) {
407
- if (submited) {
408
- _this.refreshFacetTabs();
409
- _this.renderActiveFacet();
410
- _this.saveFacets();
411
- }
412
- })
413
- .catch(function (error) { return console.error(error); });
414
- };
415
- ResultFacetsPanel.prototype.closeClickHandler = function (facet) {
416
- var _this = this;
417
- var ds = this.getDialogService();
418
- ds.openConfirm(i18n.getText('Facets', 'RemoveFacetDlgTitle'), i18n.getText('Facets', 'RemoveFacetDlgContent')
419
- .replace('{facetTitle}', facet.title))
420
- .then(function (confirmed) {
421
- if (confirmed) {
422
- _this.removeFacet(facet);
423
- _this.saveFacets();
424
- }
425
- })
426
- .catch(function (error) { return console.error(error); });
427
- };
428
- ResultFacetsPanel.prototype.clear = function () {
429
- this.firstRender = true;
430
- this.slot.innerHTML = "";
431
- };
432
- ResultFacetsPanel.prototype.createDefaultFacetIfNotExist = function () {
433
- if (this.facets.length === 0) {
434
- var facet = this.createFacetTab(FacetType.DataGrid);
435
- this.facets.push(facet);
436
- this.activeFacetIndex = 0;
437
- }
438
- };
439
- ResultFacetsPanel.prototype.validateAddFacetButton = function () {
440
- this.addFacetButton.hidden = this.addMenu.getItems()
441
- .filter(this.menuItemsFilter).length == 0;
442
- };
443
- ResultFacetsPanel.prototype.setActiveFacet = function (index) {
444
- if (this.activeFacetIndex != index) {
445
- this.activeFacetIndex = index;
446
- this.renderActiveFacet();
447
- this.saveFacets(true);
448
- }
449
- };
450
- ResultFacetsPanel.prototype.setOptions = function (options) {
451
- dataUtils.assignDeep(this.options, options);
452
- };
453
- ResultFacetsPanel.prototype.getDialogService = function () {
454
- return this.getContext()
455
- .getServices()
456
- .getDialogService();
457
- };
458
- ResultFacetsPanel.prototype.saveFacets = function (isActivate) {
459
- if (isActivate === void 0) { isActivate = false; }
460
- var query = this.getQuery();
461
- query.innerData = query.innerData || {};
462
- query.innerData.facets = {
463
- active: this.activeFacetIndex,
464
- items: this.facets.map(function (f) { return f.saveToData(); })
465
- };
466
- query.fireChangedEvent({
467
- part: QueryChangePart.Facets,
468
- action: isActivate ? QueryChangeAction.Activate : QueryChangeAction.All,
469
- source: this
470
- });
471
- };
472
- ResultFacetsPanel.prototype.reloadFacets = function () {
473
- for (var _i = 0, _a = this.facets; _i < _a.length; _i++) {
474
- var facet = _a[_i];
475
- facet.destroy();
476
- }
477
- this.loadFacets();
478
- };
479
- ResultFacetsPanel.prototype.loadFacets = function () {
480
- var query = this.getQuery();
481
- this.facets = [];
482
- if (query.innerData && query.innerData.facets) {
483
- var items = query.innerData.facets.items;
484
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
485
- var fd = items_1[_i];
486
- var facet = this.createFacetTab(fd.type);
487
- facet.loadFromData(fd);
488
- this.facets.push(facet);
489
- }
490
- var active = query.innerData.facets.active;
491
- this.activeFacetIndex = (active >= 0)
492
- ? active
493
- : this.facets.length - 1;
494
- }
495
- else {
496
- this.createDefaultFacetIfNotExist();
497
- }
498
- };
499
- return ResultFacetsPanel;
500
- }(FacetContainer));
501
- export { ResultFacetsPanel };
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { WidgetGroup, QueryChangePart, QueryChangeAction, } from '@easyquery/core';
17
+ import { i18n, utils as dataUtils } from '@easydata/core';
18
+ import { domel } from '@easydata/ui';
19
+ import { FacetType } from '../types/facet_type';
20
+ import { browserUtils } from '../utils/browser_utils';
21
+ import { PopupMenu } from '../utils/popup_menu';
22
+ import { eqCssPrefix } from '../utils/utils';
23
+ import { ExportDialog } from '../dialog/export_dialog';
24
+ import { FacetContainer } from './facet_container';
25
+ var ResultFacetsPanel = /** @class */ (function (_super) {
26
+ __extends(ResultFacetsPanel, _super);
27
+ function ResultFacetsPanel(slot) {
28
+ var _this = _super.call(this, slot) || this;
29
+ _this.activeFacetIndex = -1;
30
+ _this.firstRender = true;
31
+ _this.options = {
32
+ showExportButton: true,
33
+ showRefreshButton: true,
34
+ showMaximizeButton: true,
35
+ maximize2Window: false,
36
+ showProcessIndicator: true,
37
+ facetTypes: [FacetType.DataGrid, FacetType.Chart, FacetType.PivotTable]
38
+ };
39
+ _this.menuItems = [
40
+ { id: FacetType.DataGrid, text: i18n.getText('Facets', 'AddMenuItems', 'DataTable') },
41
+ { id: FacetType.Chart, text: i18n.getText('Facets', 'AddMenuItems', 'Chart') },
42
+ { id: FacetType.PivotTable, text: i18n.getText('Facets', 'AddMenuItems', 'Pivot') }
43
+ ];
44
+ _this.menuItemsFilter = function (item) {
45
+ if (_this.options.facetTypes.indexOf(item.id) < 0)
46
+ return false;
47
+ if (item.id === FacetType.DataGrid) {
48
+ return _this.facets.filter(function (facet) { return facet.getType() == FacetType.DataGrid; }).length === 0;
49
+ }
50
+ return true;
51
+ };
52
+ if (!_this.slot.classList.contains("".concat(_this.cssPrefix, "-panel"))) {
53
+ _this.slot.classList.add("".concat(_this.cssPrefix, "-panel"));
54
+ }
55
+ _this.renderProcessBlock();
56
+ return _this;
57
+ }
58
+ Object.defineProperty(ResultFacetsPanel.prototype, "cssPrefix", {
59
+ get: function () {
60
+ return 'eqjs-facets';
61
+ },
62
+ enumerable: false,
63
+ configurable: true
64
+ });
65
+ ResultFacetsPanel.prototype.getWidgetType = function () {
66
+ return 'facetsPanel';
67
+ };
68
+ /**
69
+ * Initialize widget.
70
+ * @param context The context.
71
+ * @param options The options.
72
+ */
73
+ ResultFacetsPanel.prototype.init = function (context, options) {
74
+ _super.prototype.init.call(this, context, options);
75
+ this.setOptions(options);
76
+ this.destroyCore();
77
+ this.attachQueryObserver();
78
+ this.loadFacets();
79
+ };
80
+ ResultFacetsPanel.prototype.attachQueryObserver = function () {
81
+ var _this = this;
82
+ var query = this.getQuery();
83
+ if (this.queryEventCallbackId) {
84
+ query.removeChangedCallback(this.queryEventCallbackId);
85
+ }
86
+ this.queryEventCallbackId = query.addChangedCallback(function (event) {
87
+ //if something has changed, and that change is related to columns
88
+ var edata = event.data;
89
+ if (edata.part != QueryChangePart.All) {
90
+ return;
91
+ }
92
+ if (edata.source == _this) {
93
+ return;
94
+ }
95
+ _this.reloadFacets();
96
+ _this.refreshCore(true);
97
+ });
98
+ };
99
+ ResultFacetsPanel.prototype.refreshCore = function (force) {
100
+ if (force === void 0) { force = false; }
101
+ if (this.firstRender || force) {
102
+ this.clear();
103
+ this.createAddMenu();
104
+ this.render();
105
+ }
106
+ this.validateAddFacetButton();
107
+ this.renderActiveFacet();
108
+ this.updateTotalRecords();
109
+ };
110
+ ResultFacetsPanel.prototype.createAddMenu = function () {
111
+ this.addMenu = new PopupMenu({
112
+ items: this.menuItems,
113
+ id: "FacetType-List"
114
+ });
115
+ };
116
+ ResultFacetsPanel.prototype.updateTotalRecords = function () {
117
+ var context = this.getContext();
118
+ var total = context.resultTable.getTotal();
119
+ this.recordsDiv.innerHTML = i18n.getText('Facets', 'TotalRecordsLabel') + ' ' + total;
120
+ if (total == 0) {
121
+ domel(this.exportDiv).hide();
122
+ }
123
+ else {
124
+ domel(this.exportDiv).show();
125
+ }
126
+ };
127
+ ResultFacetsPanel.prototype.renderProcessBlock = function () {
128
+ var html = '<div class="wBall" id="wBall_1"><div class="wInnerBall"></div></div><div class="wBall" id="wBall_2"><div class="wInnerBall"></div></div><div class="wBall" id="wBall_3"><div class="wInnerBall"></div></div><div class="wBall" id="wBall_4"><div class="wInnerBall"></div></div><div class="wBall" id="wBall_5"><div class="wInnerBall"></div></div>';
129
+ ;
130
+ this._processBlock = domel('div')
131
+ .addClass("".concat(this.cssPrefix, "-spinner"))
132
+ .addChild('div', function (b) { return b
133
+ .addClass("".concat(eqCssPrefix, "-progress-win8"), browserUtils.getMobileCssClass())
134
+ .addHtml(html); })
135
+ .toDOM();
136
+ };
137
+ ResultFacetsPanel.prototype.onProcessStartCore = function () {
138
+ if (this.options.showProcessIndicator) {
139
+ // FacetsPanel might be not rendered yet, so
140
+ // it has no body
141
+ if (!this._processBlock.parentNode && this.bodyDiv) {
142
+ this.bodyDiv.childNodes.forEach(function (el) {
143
+ domel(el).hide();
144
+ });
145
+ this.bodyDiv.appendChild(this._processBlock);
146
+ }
147
+ }
148
+ };
149
+ ResultFacetsPanel.prototype.onProcessEndCore = function () {
150
+ if (this.options.showProcessIndicator) {
151
+ if (this._processBlock.parentNode) {
152
+ try {
153
+ this._processBlock.parentNode
154
+ .removeChild(this._processBlock);
155
+ }
156
+ catch (e) {
157
+ }
158
+ finally {
159
+ this.renderActiveFacet(false);
160
+ }
161
+ }
162
+ }
163
+ };
164
+ ResultFacetsPanel.prototype.render = function () {
165
+ var _this = this;
166
+ this.firstRender = false;
167
+ this.headerDiv = domel('div', this.slot)
168
+ .addClass("".concat(this.cssPrefix, "-header"))
169
+ .toDOM();
170
+ this.tabsDiv =
171
+ domel('div', this.headerDiv)
172
+ .addClass("".concat(this.cssPrefix, "-tabs"))
173
+ .toDOM();
174
+ this.tabsUl = domel('ul', this.tabsDiv)
175
+ .addClass("".concat(this.cssPrefix, "-nav-tabs"))
176
+ .toDOM();
177
+ this.bodyDiv =
178
+ domel('div', this.slot)
179
+ .addClass("".concat(this.cssPrefix, "-body"))
180
+ .toDOM();
181
+ for (var _i = 0, _a = this.facets; _i < _a.length; _i++) {
182
+ var facet = _a[_i];
183
+ this.renderFacet(facet);
184
+ }
185
+ domel(this.tabsDiv)
186
+ .addChild('div', function (b) { return _this.addFacetButton = b
187
+ .addClass("".concat(_this.cssPrefix, "-add-button"))
188
+ .title(i18n.getText('Facets', 'NewFacetTitle'))
189
+ .addChild('a', function (b) { return b
190
+ .attr('href', 'javascript:void(0)'); })
191
+ .on('click', function (e) { return _this.addClickHandler(e); })
192
+ .toDOM(); });
193
+ var manageDiv = domel('div', this.headerDiv)
194
+ .addClass("".concat(this.cssPrefix, "-manage"))
195
+ .toDOM();
196
+ this.recordsDiv = domel('div', manageDiv)
197
+ .addClass("".concat(this.cssPrefix, "-total-recs"))
198
+ .toDOM();
199
+ if (this.options.showRefreshButton || this.options.showExportButton || this.options.showMaximizeButton) {
200
+ var bdb = domel('div', manageDiv)
201
+ .addClass("".concat(this.cssPrefix, "-total-buttons"))
202
+ .toDOM();
203
+ if (this.options.showExportButton) {
204
+ this.exportDiv = domel('button', bdb)
205
+ .on('click', function () { return _this.exportHandler(); })
206
+ .addClass("".concat(this.cssPrefix, "-button"))
207
+ .addClass("".concat(this.cssPrefix, "-button-export"))
208
+ .title(i18n.getText('Facets', 'ExportBtnTitle'))
209
+ .toDOM();
210
+ }
211
+ if (this.options.showRefreshButton) {
212
+ domel('button', bdb)
213
+ .on('click', function () { return _this.refreshHandler(); })
214
+ .addClass("".concat(this.cssPrefix, "-button"))
215
+ .addClass("".concat(this.cssPrefix, "-button-refresh"))
216
+ .title(i18n.getText('Facets', 'RefreshBtnTitle'));
217
+ }
218
+ if (this.options.showMaximizeButton) {
219
+ this.maximizeButton = domel('button', bdb)
220
+ .on('click', function () { return _this.options.maximize2Window ? _this.maximizeHandler(true) : _this.maximizeHandler(); })
221
+ .addClass("".concat(this.cssPrefix, "-button"))
222
+ .addClass("".concat(this.cssPrefix, "-button-maximize"))
223
+ .title(i18n.getText('Facets', 'MaximizeBtnTitle'))
224
+ .toDOM();
225
+ }
226
+ }
227
+ };
228
+ ResultFacetsPanel.prototype.refreshHandler = function () {
229
+ var context = this.getContext();
230
+ context.fetchData({
231
+ success: function () {
232
+ // possibly we should move this logic to context
233
+ context.refreshWidgets(WidgetGroup.Result);
234
+ }
235
+ });
236
+ };
237
+ ResultFacetsPanel.prototype.exportHandler = function () {
238
+ var context = this.getContext();
239
+ new ExportDialog(context)
240
+ .show();
241
+ };
242
+ ResultFacetsPanel.prototype.maximizeHandler = function (toWindow) {
243
+ var b = domel(this.slot);
244
+ if (toWindow) {
245
+ b.toggleClass("".concat(eqCssPrefix, "-maximized-2window"));
246
+ if (this.slot.classList.contains("".concat(eqCssPrefix, "-maximized-2window"))) {
247
+ this.maximizeButton.title = i18n.getText('Facets', 'RestoreBtnTitle');
248
+ this.maximizeButton.classList.toggle("".concat(this.cssPrefix, "-button-maximize"), false);
249
+ this.maximizeButton.classList.toggle("".concat(this.cssPrefix, "-button-restore"), true);
250
+ }
251
+ else {
252
+ this.maximizeButton.title = i18n.getText('Facets', 'MaximizeBtnTitle');
253
+ this.maximizeButton.classList.toggle("".concat(this.cssPrefix, "-button-restore"), false);
254
+ this.maximizeButton.classList.toggle("".concat(this.cssPrefix, "-button-maximize"), true);
255
+ }
256
+ }
257
+ else {
258
+ var isMaximized_1 = !this.slot.hasAttribute('data-is-maximized');
259
+ if (isMaximized_1) {
260
+ this.slot.setAttribute('data-is-maximized', '');
261
+ this.maximizeButton.title = i18n.getText('Facets', 'RestoreBtnTitle');
262
+ this.maximizeButton.classList.toggle("".concat(this.cssPrefix, "-button-maximize"), false);
263
+ this.maximizeButton.classList.toggle("".concat(this.cssPrefix, "-button-restore"), true);
264
+ }
265
+ else {
266
+ this.slot.removeAttribute('data-is-maximized');
267
+ this.maximizeButton.title = i18n.getText('Facets', 'MaximizeBtnTitle');
268
+ this.maximizeButton.classList.toggle("".concat(this.cssPrefix, "-button-restore"), false);
269
+ this.maximizeButton.classList.toggle("".concat(this.cssPrefix, "-button-maximize"), true);
270
+ }
271
+ var arrToHide = document.querySelectorAll('[data-hide-on-max]');
272
+ arrToHide.forEach(function (el) {
273
+ if (isMaximized_1) {
274
+ el.setAttribute('style', 'display: none;');
275
+ }
276
+ else {
277
+ el.removeAttribute('style');
278
+ }
279
+ });
280
+ }
281
+ this.facets.forEach(function (facetTab) { return facetTab.onResize(); });
282
+ };
283
+ ResultFacetsPanel.prototype.renderActiveFacet = function (refresh) {
284
+ var _this = this;
285
+ if (refresh === void 0) { refresh = true; }
286
+ this.tabsUl.querySelectorAll('li') //`.${this.cssPrefix}-header-item.${this.cssPrefix}-facet`)
287
+ .forEach(function (el, index) {
288
+ if (el.classList.contains('active')) {
289
+ el.classList.remove('active');
290
+ }
291
+ if (_this.activeFacetIndex === index) {
292
+ el.classList.add('active');
293
+ }
294
+ });
295
+ this.bodyDiv.querySelectorAll(".".concat(eqCssPrefix, "-facet"))
296
+ .forEach(function (el, index) {
297
+ domel(el).hide();
298
+ if (_this.activeFacetIndex === index) {
299
+ domel(el).show();
300
+ if (refresh) {
301
+ _this.facets[index].refresh();
302
+ }
303
+ }
304
+ });
305
+ };
306
+ ResultFacetsPanel.prototype.renderFacet = function (facet) {
307
+ this.renderFacetTab(facet);
308
+ var body = this.renderFacetSlot(facet);
309
+ facet.init(body);
310
+ };
311
+ ResultFacetsPanel.prototype.renderFacetTab = function (facet) {
312
+ var _this = this;
313
+ return domel('li', this.tabsUl)
314
+ //.addClass(`${this.cssPrefix}-header-item`, `${this.cssPrefix}-facet`)
315
+ //facet settings button
316
+ .addChild('span', function (b) { return b
317
+ .addClass("".concat(eqCssPrefix, "-facet-settings"))
318
+ .on('click', function (e) {
319
+ e.stopPropagation();
320
+ _this.settingsClickHandler(facet);
321
+ }); })
322
+ .addChild('a', function (b) { return b
323
+ .addText(facet.title)
324
+ .attr('href', 'javascript:void(0)'); })
325
+ //facet close button
326
+ .addChild('span', function (b) { return b
327
+ .addClass("".concat(eqCssPrefix, "-facet-close"))
328
+ .on('click', function (e) {
329
+ e.stopPropagation();
330
+ _this.closeClickHandler(facet);
331
+ }); })
332
+ .on('click', function (e) { return _this.selectClickHandler(facet); })
333
+ .toDOM();
334
+ };
335
+ ResultFacetsPanel.prototype.renderFacetSlot = function (facet) {
336
+ var element = domel('div', this.bodyDiv)
337
+ .addClass("".concat(eqCssPrefix, "-facet"))
338
+ .hide()
339
+ .toDOM();
340
+ return element;
341
+ };
342
+ ResultFacetsPanel.prototype.refreshFacetTabs = function () {
343
+ var _this = this;
344
+ this.tabsUl.querySelectorAll('li') //`.${this.cssPrefix}-header-item.${this.cssPrefix}-facet`)
345
+ .forEach(function (item) {
346
+ _this.tabsUl.removeChild(item);
347
+ });
348
+ for (var _i = 0, _a = this.facets; _i < _a.length; _i++) {
349
+ var facet = _a[_i];
350
+ this.renderFacetTab(facet);
351
+ }
352
+ };
353
+ ResultFacetsPanel.prototype.removeFacet = function (facet) {
354
+ var index = this.facets.indexOf(facet);
355
+ if (index >= 0) {
356
+ this.facets.splice(index, 1);
357
+ var header = this.tabsUl.childNodes[index];
358
+ this.tabsUl.removeChild(header);
359
+ var body = this.bodyDiv.childNodes[index];
360
+ this.bodyDiv.removeChild(body);
361
+ if (this.facets.length > 0) {
362
+ this.activeFacetIndex =
363
+ index < this.facets.length
364
+ ? index
365
+ : this.facets.length - 1;
366
+ }
367
+ else {
368
+ this.activeFacetIndex = -1;
369
+ }
370
+ this.renderActiveFacet();
371
+ this.validateAddFacetButton();
372
+ }
373
+ };
374
+ ResultFacetsPanel.prototype.addClickHandler = function (ev) {
375
+ var _this = this;
376
+ this.addMenu.showMenu({
377
+ anchor: ev.target,
378
+ itemFilterCallback: this.menuItemsFilter,
379
+ itemSelectedCallback: function (data) {
380
+ var facet = _this.createFacetTab(data.id);
381
+ var facetSlot = _this.renderFacetSlot(facet);
382
+ facet.init(facetSlot);
383
+ facet.showSettingsDialog()
384
+ .then(function (submited) {
385
+ if (submited) {
386
+ _this.facets.push(facet);
387
+ _this.activeFacetIndex = _this.facets.length - 1;
388
+ _this.renderFacetTab(facet);
389
+ _this.renderActiveFacet();
390
+ _this.saveFacets();
391
+ }
392
+ else {
393
+ _this.bodyDiv.removeChild(facetSlot);
394
+ }
395
+ //this.validateAddFacetButton();
396
+ })
397
+ .catch(function (error) { return console.error(error); });
398
+ }
399
+ });
400
+ };
401
+ ResultFacetsPanel.prototype.selectClickHandler = function (facet) {
402
+ var index = this.facets.indexOf(facet);
403
+ this.setActiveFacet(index);
404
+ };
405
+ ResultFacetsPanel.prototype.settingsClickHandler = function (facet) {
406
+ var _this = this;
407
+ facet.showSettingsDialog()
408
+ .then(function (submited) {
409
+ if (submited) {
410
+ _this.refreshFacetTabs();
411
+ _this.renderActiveFacet();
412
+ _this.saveFacets();
413
+ }
414
+ })
415
+ .catch(function (error) { return console.error(error); });
416
+ };
417
+ ResultFacetsPanel.prototype.closeClickHandler = function (facet) {
418
+ var _this = this;
419
+ var ds = this.getDialogService();
420
+ ds.openConfirm(i18n.getText('Facets', 'RemoveFacetDlgTitle'), i18n.getText('Facets', 'RemoveFacetDlgContent')
421
+ .replace('{facetTitle}', facet.title))
422
+ .then(function (confirmed) {
423
+ if (confirmed) {
424
+ _this.removeFacet(facet);
425
+ _this.saveFacets();
426
+ }
427
+ })
428
+ .catch(function (error) { return console.error(error); });
429
+ };
430
+ ResultFacetsPanel.prototype.clear = function () {
431
+ this.firstRender = true;
432
+ this.slot.innerHTML = "";
433
+ };
434
+ ResultFacetsPanel.prototype.createDefaultFacetIfNotExist = function () {
435
+ if (this.facets.length === 0) {
436
+ var facet = this.createFacetTab(FacetType.DataGrid);
437
+ this.facets.push(facet);
438
+ this.activeFacetIndex = 0;
439
+ }
440
+ };
441
+ ResultFacetsPanel.prototype.validateAddFacetButton = function () {
442
+ this.addFacetButton.hidden = this.addMenu.getItems()
443
+ .filter(this.menuItemsFilter).length == 0;
444
+ };
445
+ ResultFacetsPanel.prototype.setActiveFacet = function (index) {
446
+ if (this.activeFacetIndex != index) {
447
+ this.activeFacetIndex = index;
448
+ this.renderActiveFacet();
449
+ this.saveFacets(true);
450
+ }
451
+ };
452
+ ResultFacetsPanel.prototype.setOptions = function (options) {
453
+ dataUtils.assignDeep(this.options, options);
454
+ };
455
+ ResultFacetsPanel.prototype.getDialogService = function () {
456
+ return this.getContext()
457
+ .getServices()
458
+ .getDialogService();
459
+ };
460
+ ResultFacetsPanel.prototype.saveFacets = function (isActivate) {
461
+ if (isActivate === void 0) { isActivate = false; }
462
+ var query = this.getQuery();
463
+ query.innerData = query.innerData || {};
464
+ query.innerData.facets = {
465
+ active: this.activeFacetIndex,
466
+ items: this.facets.map(function (f) { return f.saveToData(); })
467
+ };
468
+ query.fireChangedEvent({
469
+ part: QueryChangePart.Facets,
470
+ action: isActivate ? QueryChangeAction.Activate : QueryChangeAction.All,
471
+ source: this
472
+ });
473
+ };
474
+ ResultFacetsPanel.prototype.reloadFacets = function () {
475
+ for (var _i = 0, _a = this.facets; _i < _a.length; _i++) {
476
+ var facet = _a[_i];
477
+ facet.destroy();
478
+ }
479
+ this.loadFacets();
480
+ };
481
+ ResultFacetsPanel.prototype.loadFacets = function () {
482
+ var query = this.getQuery();
483
+ this.facets = [];
484
+ if (query.innerData && query.innerData.facets) {
485
+ var items = query.innerData.facets.items;
486
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
487
+ var fd = items_1[_i];
488
+ var facet = this.createFacetTab(fd.type);
489
+ facet.loadFromData(fd);
490
+ this.facets.push(facet);
491
+ }
492
+ var active = query.innerData.facets.active;
493
+ this.activeFacetIndex = (active >= 0)
494
+ ? active
495
+ : this.facets.length - 1;
496
+ }
497
+ else {
498
+ this.createDefaultFacetIfNotExist();
499
+ }
500
+ };
501
+ return ResultFacetsPanel;
502
+ }(FacetContainer));
503
+ export { ResultFacetsPanel };
502
504
  //# sourceMappingURL=result_facets_panel.js.map