@easyquery/ui 7.2.3 → 7.2.4-rc01

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 (215) hide show
  1. package/dist/assets/css/easyquery.css +5 -2
  2. package/dist/browser/eq.community.css.map +1 -1
  3. package/dist/browser/eq.community.js +32224 -33715
  4. package/dist/browser/eq.community.js.map +1 -1
  5. package/dist/browser/eq.community.min.js +1 -9
  6. package/dist/browser/eq.community.min.js.map +1 -1
  7. package/dist/browser/eq.core.css +22 -114
  8. package/dist/browser/eq.core.min.css +3 -10
  9. package/dist/browser/eq.view.css +1 -1
  10. package/dist/browser/eq.view.css.map +1 -1
  11. package/dist/browser/eq.view.min.css +1 -10
  12. package/dist/bundles/easyquery.ui.js +22951 -22870
  13. package/dist/bundles/easyquery.ui.js.map +1 -1
  14. package/dist/bundles/easyquery.ui.min.js +1 -1
  15. package/dist/bundles/easyquery.ui.min.js.map +1 -1
  16. package/dist/lib/dialog/aggr_settings_dialog.d.ts +12 -12
  17. package/dist/lib/dialog/aggr_settings_dialog.js +106 -106
  18. package/dist/lib/dialog/export_dialog.d.ts +7 -7
  19. package/dist/lib/dialog/export_dialog.js +63 -63
  20. package/dist/lib/extensions.d.ts +7 -7
  21. package/dist/lib/extensions.js +13 -13
  22. package/dist/lib/facets/chart_facet.d.ts +21 -21
  23. package/dist/lib/facets/chart_facet.js +240 -238
  24. package/dist/lib/facets/chart_facet.js.map +1 -1
  25. package/dist/lib/facets/datatable_facet.d.ts +15 -15
  26. package/dist/lib/facets/datatable_facet.js +71 -69
  27. package/dist/lib/facets/datatable_facet.js.map +1 -1
  28. package/dist/lib/facets/pivot_table_facet.d.ts +51 -51
  29. package/dist/lib/facets/pivot_table_facet.js +698 -696
  30. package/dist/lib/facets/pivot_table_facet.js.map +1 -1
  31. package/dist/lib/facets/result_facet.d.ts +40 -40
  32. package/dist/lib/facets/result_facet.js +246 -246
  33. package/dist/lib/facets/result_facet.js.map +1 -1
  34. package/dist/lib/i18n/text_resources.d.ts +1 -1
  35. package/dist/lib/i18n/text_resources.js +260 -259
  36. package/dist/lib/i18n/text_resources.js.map +1 -1
  37. package/dist/lib/public_api.d.ts +61 -61
  38. package/dist/lib/public_api.js +92 -90
  39. package/dist/lib/public_api.js.map +1 -1
  40. package/dist/lib/types/facet_type.d.ts +5 -5
  41. package/dist/lib/types/facet_type.js +6 -6
  42. package/dist/lib/types/qp_editable_part.d.ts +15 -15
  43. package/dist/lib/types/qp_editable_part.js +16 -16
  44. package/dist/lib/utils/browser_utils.d.ts +8 -8
  45. package/dist/lib/utils/browser_utils.js +58 -58
  46. package/dist/lib/utils/display_format_parser.d.ts +11 -11
  47. package/dist/lib/utils/display_format_parser.js +61 -61
  48. package/dist/lib/utils/dropdown.d.ts +11 -11
  49. package/dist/lib/utils/dropdown.js +57 -55
  50. package/dist/lib/utils/dropdown.js.map +1 -1
  51. package/dist/lib/utils/popup_menu.d.ts +163 -163
  52. package/dist/lib/utils/popup_menu.js +1259 -1260
  53. package/dist/lib/utils/popup_menu.js.map +1 -1
  54. package/dist/lib/utils/utils.d.ts +9 -9
  55. package/dist/lib/utils/utils.js +46 -46
  56. package/dist/lib/utils/utils.js.map +1 -1
  57. package/dist/lib/views/adv_search_view.d.ts +95 -95
  58. package/dist/lib/views/adv_search_view.js +712 -710
  59. package/dist/lib/views/adv_search_view.js.map +1 -1
  60. package/dist/lib/views/data_filter_view.d.ts +17 -17
  61. package/dist/lib/views/data_filter_view.js +79 -77
  62. package/dist/lib/views/data_filter_view.js.map +1 -1
  63. package/dist/lib/views/html_data_filter_view.d.ts +19 -19
  64. package/dist/lib/views/html_data_filter_view.js +44 -42
  65. package/dist/lib/views/html_data_filter_view.js.map +1 -1
  66. package/dist/lib/views/report_view.d.ts +173 -173
  67. package/dist/lib/views/report_view.js +733 -731
  68. package/dist/lib/views/report_view.js.map +1 -1
  69. package/dist/lib/views/view.d.ts +149 -149
  70. package/dist/lib/views/view.js +538 -538
  71. package/dist/lib/views/view.js.map +1 -1
  72. package/dist/lib/views/view_options.d.ts +113 -113
  73. package/dist/lib/views/view_options.js +1 -0
  74. package/dist/lib/widgets/aggregation_bar.d.ts +30 -30
  75. package/dist/lib/widgets/aggregation_bar.js +145 -143
  76. package/dist/lib/widgets/aggregation_bar.js.map +1 -1
  77. package/dist/lib/widgets/charts/chart_type.d.ts +14 -14
  78. package/dist/lib/widgets/charts/chart_type.js +15 -15
  79. package/dist/lib/widgets/charts/chart_widget.d.ts +92 -92
  80. package/dist/lib/widgets/charts/chart_widget.js +384 -382
  81. package/dist/lib/widgets/charts/chart_widget.js.map +1 -1
  82. package/dist/lib/widgets/charts/chart_widget_chartjs.d.ts +23 -23
  83. package/dist/lib/widgets/charts/chart_widget_chartjs.js +186 -184
  84. package/dist/lib/widgets/charts/chart_widget_chartjs.js.map +1 -1
  85. package/dist/lib/widgets/charts/chart_widget_google.d.ts +23 -23
  86. package/dist/lib/widgets/charts/chart_widget_google.js +165 -163
  87. package/dist/lib/widgets/charts/chart_widget_google.js.map +1 -1
  88. package/dist/lib/widgets/columns_bar.d.ts +64 -64
  89. package/dist/lib/widgets/columns_bar.js +722 -721
  90. package/dist/lib/widgets/columns_bar.js.map +1 -1
  91. package/dist/lib/widgets/columns_panel.d.ts +64 -62
  92. package/dist/lib/widgets/columns_panel.js +740 -721
  93. package/dist/lib/widgets/columns_panel.js.map +1 -1
  94. package/dist/lib/widgets/easy_grid_widget.d.ts +38 -38
  95. package/dist/lib/widgets/easy_grid_widget.js +229 -227
  96. package/dist/lib/widgets/easy_grid_widget.js.map +1 -1
  97. package/dist/lib/widgets/entities_panel.d.ts +49 -49
  98. package/dist/lib/widgets/entities_panel.js +627 -625
  99. package/dist/lib/widgets/entities_panel.js.map +1 -1
  100. package/dist/lib/widgets/eq_result_html_grid.d.ts +32 -32
  101. package/dist/lib/widgets/eq_result_html_grid.js +185 -183
  102. package/dist/lib/widgets/eq_result_html_grid.js.map +1 -1
  103. package/dist/lib/widgets/export_widget.d.ts +10 -10
  104. package/dist/lib/widgets/export_widget.js +57 -55
  105. package/dist/lib/widgets/export_widget.js.map +1 -1
  106. package/dist/lib/widgets/facet_container.d.ts +12 -12
  107. package/dist/lib/widgets/facet_container.js +53 -51
  108. package/dist/lib/widgets/facet_container.js.map +1 -1
  109. package/dist/lib/widgets/filter_bar.d.ts +38 -38
  110. package/dist/lib/widgets/filter_bar.js +259 -257
  111. package/dist/lib/widgets/filter_bar.js.map +1 -1
  112. package/dist/lib/widgets/grid.d.ts +35 -35
  113. package/dist/lib/widgets/grid.js +79 -77
  114. package/dist/lib/widgets/grid.js.map +1 -1
  115. package/dist/lib/widgets/html_content_widget.d.ts +35 -35
  116. package/dist/lib/widgets/html_content_widget.js +71 -69
  117. package/dist/lib/widgets/html_content_widget.js.map +1 -1
  118. package/dist/lib/widgets/locale_widget.d.ts +16 -16
  119. package/dist/lib/widgets/locale_widget.js +79 -77
  120. package/dist/lib/widgets/locale_widget.js.map +1 -1
  121. package/dist/lib/widgets/manage_drilldown_widget.d.ts +18 -18
  122. package/dist/lib/widgets/manage_drilldown_widget.js +154 -152
  123. package/dist/lib/widgets/manage_drilldown_widget.js.map +1 -1
  124. package/dist/lib/widgets/process_widget.d.ts +21 -21
  125. package/dist/lib/widgets/process_widget.js +50 -48
  126. package/dist/lib/widgets/process_widget.js.map +1 -1
  127. package/dist/lib/widgets/query_panel.d.ts +62 -58
  128. package/dist/lib/widgets/query_panel.js +675 -653
  129. package/dist/lib/widgets/query_panel.js.map +1 -1
  130. package/dist/lib/widgets/queryname_widget.d.ts +27 -27
  131. package/dist/lib/widgets/queryname_widget.js +109 -107
  132. package/dist/lib/widgets/queryname_widget.js.map +1 -1
  133. package/dist/lib/widgets/renderers/aggr_settings/aggr_settings_renderer.d.ts +54 -54
  134. package/dist/lib/widgets/renderers/aggr_settings/aggr_settings_renderer.js +429 -429
  135. package/dist/lib/widgets/renderers/aggr_settings/aggr_settings_renderer.js.map +1 -1
  136. package/dist/lib/widgets/renderers/base_element_renderer.d.ts +15 -15
  137. package/dist/lib/widgets/renderers/base_element_renderer.js +63 -63
  138. package/dist/lib/widgets/renderers/columnsbar/aggrfunc_column_renderer.d.ts +11 -11
  139. package/dist/lib/widgets/renderers/columnsbar/aggrfunc_column_renderer.js +62 -60
  140. package/dist/lib/widgets/renderers/columnsbar/aggrfunc_column_renderer.js.map +1 -1
  141. package/dist/lib/widgets/renderers/columnsbar/column_renderer_cb.d.ts +53 -53
  142. package/dist/lib/widgets/renderers/columnsbar/column_renderer_cb.js +550 -550
  143. package/dist/lib/widgets/renderers/columnsbar/column_renderer_cb.js.map +1 -1
  144. package/dist/lib/widgets/renderers/columnsbar/simple_column_renderer.d.ts +9 -9
  145. package/dist/lib/widgets/renderers/columnsbar/simple_column_renderer.js +79 -77
  146. package/dist/lib/widgets/renderers/columnsbar/simple_column_renderer.js.map +1 -1
  147. package/dist/lib/widgets/renderers/columnspanel/aggrfunc_column_renderer.d.ts +17 -17
  148. package/dist/lib/widgets/renderers/columnspanel/aggrfunc_column_renderer.js +180 -178
  149. package/dist/lib/widgets/renderers/columnspanel/aggrfunc_column_renderer.js.map +1 -1
  150. package/dist/lib/widgets/renderers/columnspanel/column_renderer_cp.d.ts +74 -72
  151. package/dist/lib/widgets/renderers/columnspanel/column_renderer_cp.js +829 -817
  152. package/dist/lib/widgets/renderers/columnspanel/column_renderer_cp.js.map +1 -1
  153. package/dist/lib/widgets/renderers/columnspanel/customsql_column_renderer.d.ts +21 -18
  154. package/dist/lib/widgets/renderers/columnspanel/customsql_column_renderer.js +238 -214
  155. package/dist/lib/widgets/renderers/columnspanel/customsql_column_renderer.js.map +1 -1
  156. package/dist/lib/widgets/renderers/columnspanel/simple_column_renderer.d.ts +13 -13
  157. package/dist/lib/widgets/renderers/columnspanel/simple_column_renderer.js +180 -178
  158. package/dist/lib/widgets/renderers/columnspanel/simple_column_renderer.js.map +1 -1
  159. package/dist/lib/widgets/renderers/dropdown_renderer.d.ts +9 -9
  160. package/dist/lib/widgets/renderers/dropdown_renderer.js +42 -40
  161. package/dist/lib/widgets/renderers/dropdown_renderer.js.map +1 -1
  162. package/dist/lib/widgets/renderers/querypanel/addrow_renderer.d.ts +16 -16
  163. package/dist/lib/widgets/renderers/querypanel/addrow_renderer.js +87 -85
  164. package/dist/lib/widgets/renderers/querypanel/addrow_renderer.js.map +1 -1
  165. package/dist/lib/widgets/renderers/querypanel/attribute_expression_renderer.d.ts +14 -14
  166. package/dist/lib/widgets/renderers/querypanel/attribute_expression_renderer.js +71 -69
  167. package/dist/lib/widgets/renderers/querypanel/attribute_expression_renderer.js.map +1 -1
  168. package/dist/lib/widgets/renderers/querypanel/bind_to_parent_column_expression_renderer.d.ts +7 -7
  169. package/dist/lib/widgets/renderers/querypanel/bind_to_parent_column_expression_renderer.js +41 -39
  170. package/dist/lib/widgets/renderers/querypanel/bind_to_parent_column_expression_renderer.js.map +1 -1
  171. package/dist/lib/widgets/renderers/querypanel/condition_group_renderer.d.ts +27 -27
  172. package/dist/lib/widgets/renderers/querypanel/condition_group_renderer.js +231 -229
  173. package/dist/lib/widgets/renderers/querypanel/condition_group_renderer.js.map +1 -1
  174. package/dist/lib/widgets/renderers/querypanel/condition_renderer.d.ts +48 -48
  175. package/dist/lib/widgets/renderers/querypanel/condition_renderer.js +509 -507
  176. package/dist/lib/widgets/renderers/querypanel/condition_renderer.js.map +1 -1
  177. package/dist/lib/widgets/renderers/querypanel/datetime_expression_render.d.ts +13 -13
  178. package/dist/lib/widgets/renderers/querypanel/datetime_expression_render.js +108 -106
  179. package/dist/lib/widgets/renderers/querypanel/datetime_expression_render.js.map +1 -1
  180. package/dist/lib/widgets/renderers/querypanel/expression_renderer.d.ts +28 -28
  181. package/dist/lib/widgets/renderers/querypanel/expression_renderer.js +91 -89
  182. package/dist/lib/widgets/renderers/querypanel/expression_renderer.js.map +1 -1
  183. package/dist/lib/widgets/renderers/querypanel/input_expression_renderer.d.ts +14 -14
  184. package/dist/lib/widgets/renderers/querypanel/input_expression_renderer.js +165 -163
  185. package/dist/lib/widgets/renderers/querypanel/input_expression_renderer.js.map +1 -1
  186. package/dist/lib/widgets/renderers/querypanel/list_expression_renderer.d.ts +35 -35
  187. package/dist/lib/widgets/renderers/querypanel/list_expression_renderer.js +317 -315
  188. package/dist/lib/widgets/renderers/querypanel/list_expression_renderer.js.map +1 -1
  189. package/dist/lib/widgets/renderers/querypanel/operator_renderer.d.ts +19 -19
  190. package/dist/lib/widgets/renderers/querypanel/operator_renderer.js +95 -93
  191. package/dist/lib/widgets/renderers/querypanel/operator_renderer.js.map +1 -1
  192. package/dist/lib/widgets/renderers/querypanel/subquery_expression_renderer.d.ts +27 -27
  193. package/dist/lib/widgets/renderers/querypanel/subquery_expression_renderer.js +237 -235
  194. package/dist/lib/widgets/renderers/querypanel/subquery_expression_renderer.js.map +1 -1
  195. package/dist/lib/widgets/renderers/querypanel/text_renderer.d.ts +11 -11
  196. package/dist/lib/widgets/renderers/querypanel/text_renderer.js +36 -36
  197. package/dist/lib/widgets/renderers/querypanel/text_renderer.js.map +1 -1
  198. package/dist/lib/widgets/renderers/sortingbar/column_renderer_sp.d.ts +26 -26
  199. package/dist/lib/widgets/renderers/sortingbar/column_renderer_sp.js +163 -163
  200. package/dist/lib/widgets/renderers/sortingbar/column_renderer_sp.js.map +1 -1
  201. package/dist/lib/widgets/result_facets_panel.d.ts +64 -64
  202. package/dist/lib/widgets/result_facets_panel.js +503 -501
  203. package/dist/lib/widgets/result_facets_panel.js.map +1 -1
  204. package/dist/lib/widgets/sorting_bar.d.ts +32 -34
  205. package/dist/lib/widgets/sorting_bar.js +245 -328
  206. package/dist/lib/widgets/sorting_bar.js.map +1 -1
  207. package/dist/lib/widgets/statement_panel.d.ts +21 -21
  208. package/dist/lib/widgets/statement_panel.js +60 -58
  209. package/dist/lib/widgets/statement_panel.js.map +1 -1
  210. package/dist/lib/widgets/widget_options.d.ts +433 -429
  211. package/dist/lib/widgets/widget_options.js +1 -0
  212. package/package.json +25 -25
  213. package/webpack.config.js +31 -24
  214. package/dist/browser/eq.community.min.css.map +0 -1
  215. package/dist/browser/eq.view.min.css.map +0 -1
@@ -1,508 +1,510 @@
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 { i18n } from '@easydata/core';
15
- import { utils as dataUtils } from '@easydata/core';
16
- import { equtils, QueryChangeAction } from '@easyquery/core';
17
- import { createBrowserEvent, domel } from '@easydata/ui';
18
- import { TextRenderer } from './text_renderer';
19
- import { browserUtils } from '../../../utils/browser_utils';
20
- import { QPEditablePart } from '../../../types/qp_editable_part';
21
- export var ConditionAction;
22
- (function (ConditionAction) {
23
- ConditionAction[ConditionAction["AddCondition"] = 0] = "AddCondition";
24
- ConditionAction[ConditionAction["AddGroup"] = 1] = "AddGroup";
25
- ConditionAction[ConditionAction["Enable"] = 2] = "Enable";
26
- ConditionAction[ConditionAction["Delete"] = 4] = "Delete";
27
- ConditionAction[ConditionAction["Menu"] = 5] = "Menu";
28
- ConditionAction[ConditionAction["Parameterized"] = 6] = "Parameterized";
29
- ConditionAction[ConditionAction["InJoin"] = 7] = "InJoin";
30
- })(ConditionAction || (ConditionAction = {}));
31
- var ConditionRenderer = /** @class */ (function () {
32
- function ConditionRenderer(panel, condition, slot) {
33
- this.panel = panel;
34
- this.condition = condition;
35
- this.element = slot || domel('div').toDOM();
36
- }
37
- Object.defineProperty(ConditionRenderer.prototype, "cssPrefix", {
38
- get: function () {
39
- return 'eqjs-qp';
40
- },
41
- enumerable: true,
42
- configurable: true
43
- });
44
- ConditionRenderer.prototype.refresh = function () {
45
- this.render();
46
- };
47
- ConditionRenderer.prototype.clear = function () {
48
- if (this.element) {
49
- this.element.className = '';
50
- this.element.removeAttribute('data-id');
51
- this.element.removeAttribute('style');
52
- domel(this.element)
53
- .html('');
54
- }
55
- };
56
- ConditionRenderer.prototype.render = function (autoAppear) {
57
- this.clear();
58
- //this.preRender();
59
- this.coreRender(autoAppear);
60
- if (this.panel.options.onConditionRendered) {
61
- this.panel.options.onConditionRendered(this.condition, this.element);
62
- }
63
- return this.element;
64
- };
65
- ConditionRenderer.prototype.isEditable = function () {
66
- return this.condition.enabled && !this.condition.isReadOnly();
67
- };
68
- return ConditionRenderer;
69
- }());
70
- export { ConditionRenderer };
71
- var SimpleConditionRenderer = /** @class */ (function (_super) {
72
- __extends(SimpleConditionRenderer, _super);
73
- function SimpleConditionRenderer() {
74
- return _super !== null && _super.apply(this, arguments) || this;
75
- }
76
- SimpleConditionRenderer.prototype.getClassesToAdd = function () {
77
- var result = this.cssPrefix + "-row " + this.cssPrefix + "-row-condition";
78
- result += this.condition.isInJoin() ? " " + this.cssPrefix + "-condition-injoin" : '';
79
- result += this.condition.isParameterized() ? " " + this.cssPrefix + "-condition-parameterized" : '';
80
- if (!browserUtils.isMobileMode()) {
81
- var level = this.condition.getLevel();
82
- if (level > 0)
83
- result += " " + this.cssPrefix + "-level-" + level;
84
- }
85
- result += this.condition.enabled ? '' : " " + this.cssPrefix + "-disabled";
86
- if (this.condition.enabled) {
87
- result += this.condition.isReadOnly() ? " " + this.cssPrefix + "-readonly" : '';
88
- }
89
- return result;
90
- };
91
- SimpleConditionRenderer.prototype.coreRender = function (autoAppear) {
92
- var _this = this;
93
- var model = this.panel.getContext().getModel();
94
- var operator = model.getOperatorById(this.condition.getOperatorId());
95
- var arrFormat = equtils.parseOperatorFormat(operator);
96
- var item = null;
97
- var arrLength = arrFormat.length;
98
- var builder = domel('div');
99
- if (this.element && this.element.parentNode) {
100
- this.element.parentNode
101
- .replaceChild(builder.toDOM(), this.element);
102
- }
103
- this.element = builder.toDOM();
104
- builder
105
- .addClass(this.getClassesToAdd())
106
- .addClass(browserUtils.getMobileCssClass())
107
- .data('id', this.condition.id)
108
- .data('condrow', '')
109
- .addChildElement(this.renderCheckbox())
110
- .addChildElement(this.renderConjunction());
111
- var mayAppear = autoAppear;
112
- var minLength = operator == model.nullOperator
113
- ? Math.min(arrLength, this.condition.expressions.length + 1)
114
- : arrLength;
115
- var _loop_1 = function (idx) {
116
- item = arrFormat[idx];
117
- if (item.type === 'operator') {
118
- var renderer = this_1.panel.getOperatorRenderer(this_1.condition, item.text);
119
- if (renderer) {
120
- builder.addChildElement(renderer.render());
121
- }
122
- }
123
- else if (item.type === 'expression') {
124
- var toAppear = mayAppear && (item.index > 0);
125
- var exprRenderer_1 = this_1.panel.getExpressionRenderer(this_1.condition.expressions[item.index]);
126
- if (exprRenderer_1) {
127
- var el = exprRenderer_1.render(toAppear);
128
- builder.addChildElement(el);
129
- setTimeout(function () {
130
- exprRenderer_1.adjustWidth();
131
- }, 100);
132
- }
133
- mayAppear = mayAppear && !toAppear;
134
- }
135
- else if (item.type === 'text') {
136
- builder.addChildElement(new TextRenderer(this_1.panel, item.text).render());
137
- }
138
- };
139
- var this_1 = this;
140
- for (var idx = 0; idx < minLength; idx++) {
141
- _loop_1(idx);
142
- }
143
- if (this.panel.options.accentActiveCondition || browserUtils.isMobileMode()) {
144
- builder.on('click', function (ev) {
145
- ev.stopPropagation();
146
- _this.panel.toggleConditionPicked(_this.condition);
147
- _this.adjustButtonsVisibility();
148
- if (!browserUtils.isMobileMode()) {
149
- _this.element.dispatchEvent(createBrowserEvent("mouseenter"));
150
- }
151
- return false;
152
- });
153
- }
154
- builder
155
- .addChildElement(this.renderButtonsBlock());
156
- if (!browserUtils.isMobileMode()) {
157
- builder
158
- .on('mouseenter', function (event) {
159
- _this.isMouseOverBlock = true;
160
- _this.enterButtonBlock();
161
- event.stopPropagation();
162
- return false;
163
- })
164
- .on('mouseleave', function (event) {
165
- _this.isMouseOverBlock = false;
166
- if (!_this.keepShowingButtons && domel(_this.buttonsBlock).isVisible()) {
167
- _this.leaveButtonBlock();
168
- }
169
- event.stopPropagation();
170
- return false;
171
- });
172
- }
173
- };
174
- SimpleConditionRenderer.prototype.setConditionParameterized = function (value) {
175
- this.condition.setParameterized(value);
176
- this.condition.fireChangedEvent();
177
- };
178
- SimpleConditionRenderer.prototype.setConditionInJoin = function (value) {
179
- this.condition.setInJoin(value);
180
- this.condition.fireChangedEvent();
181
- };
182
- SimpleConditionRenderer.prototype.getConditionMenu = function () {
183
- return this.panel.getConditionMenu();
184
- };
185
- SimpleConditionRenderer.prototype.renderConjunction = function () {
186
- var parent = this.condition.getParent();
187
- if (!parent)
188
- return null;
189
- var isFirstConditionInGroup = dataUtils.findItemIndexById(parent.getConditions(), this.condition.id) == 0;
190
- if (this.panel.options.showConjunctions && !isFirstConditionInGroup) {
191
- var linkTypeStr = equtils.linkTypeToStr(this.condition.getParent().linkType);
192
- var conjuctionText = i18n.getText("Conj" + linkTypeStr);
193
- return domel("span")
194
- .text(conjuctionText)
195
- .title(conjuctionText)
196
- .addClass(this.cssPrefix + "-condelement " + this.cssPrefix + "-condition-conjuction")
197
- .toDOM();
198
- }
199
- return null;
200
- };
201
- SimpleConditionRenderer.prototype.renderCheckbox = function () {
202
- var _this = this;
203
- if (this.panel.options.showCheckboxes && !this.condition.isReadOnly()) {
204
- return domel("div")
205
- .title(i18n.getText('CmdToggleEnable'))
206
- .attr('tabIndex', '0')
207
- .addClass(this.cssPrefix + "-condelement " + this.cssPrefix + "-condition-checkbox")
208
- .addClass("" + (this.condition.enabled ? 'enabled' : ''))
209
- .on('click', function () {
210
- _this.condition.enabled = !_this.condition.enabled;
211
- _this.condition.fireChangedEvent();
212
- return false;
213
- })
214
- .on('keypress', function (evt) { if ([13, 32].includes(evt.keyCode)) {
215
- evt.target.click();
216
- } })
217
- .toDOM();
218
- }
219
- else {
220
- return null;
221
- }
222
- };
223
- SimpleConditionRenderer.prototype.isConditionActive = function () {
224
- return this.element.classList.contains("active");
225
- };
226
- SimpleConditionRenderer.prototype.hideButtons = function () {
227
- domel(this.element).data("show-buttons", null);
228
- };
229
- SimpleConditionRenderer.prototype.showButtons = function () {
230
- domel(this.element).data("show-buttons", "");
231
- };
232
- SimpleConditionRenderer.prototype.adjustButtonsVisibility = function () {
233
- if (this.panel.options.alwaysShowButtonsInConditions
234
- || (this.panel.options.accentActiveCondition && this.isConditionActive())) {
235
- this.showButtons();
236
- }
237
- };
238
- SimpleConditionRenderer.prototype.enterButtonBlock = function () {
239
- this.showButtons();
240
- };
241
- SimpleConditionRenderer.prototype.leaveButtonBlock = function () {
242
- if (!this.panel.options.alwaysShowButtonsInConditions
243
- && (!this.isConditionActive() || !this.panel.options.accentActiveCondition)) {
244
- this.hideButtons();
245
- }
246
- };
247
- SimpleConditionRenderer.prototype.conditionMenuHandler = function (action, evt) {
248
- var _this = this;
249
- switch (action) {
250
- case ConditionAction.AddCondition:
251
- if (!this.condition.isGroup())
252
- return;
253
- var entMenu = this.panel.getEntitiesMenu();
254
- if (entMenu) {
255
- entMenu.showMenu({
256
- anchor: evt.target,
257
- itemSelectedCallback: function (item) {
258
- var query = _this.panel.getQuery();
259
- var descr = {
260
- parent: _this.condition,
261
- attributeId: item.id
262
- };
263
- var cond = query.addSimpleCondition(descr);
264
- if (cond) {
265
- query.fireConditionsChangedEvent(QueryChangeAction.Add, cond);
266
- }
267
- return false;
268
- }
269
- });
270
- }
271
- break;
272
- case ConditionAction.AddGroup:
273
- if (!this.condition.isGroup())
274
- return;
275
- var query = this.panel.getQuery();
276
- var descr = {
277
- parent: this.condition
278
- };
279
- var group = this.panel.getQuery().addConditionGroup(descr);
280
- if (group) {
281
- query.fireConditionsChangedEvent(QueryChangeAction.Add, group);
282
- }
283
- break;
284
- case ConditionAction.Enable:
285
- this.condition.enabled = !this.condition.enabled;
286
- this.condition.fireChangedEvent();
287
- break;
288
- case ConditionAction.Delete:
289
- var parent_1 = this.condition.getParent();
290
- if (!parent_1)
291
- return;
292
- var conditions = parent_1.getConditions();
293
- var idx = conditions.indexOf(this.condition);
294
- if (idx >= 0) {
295
- conditions.splice(idx, 1);
296
- this.condition.getQuery().fireConditionsChangedEvent(QueryChangeAction.Delete, this.condition);
297
- }
298
- break;
299
- case ConditionAction.Menu:
300
- var condMenu = this.getConditionMenu();
301
- this.keepShowingButtons = true;
302
- condMenu.showMenu({
303
- anchor: evt.target,
304
- selectedIds: this.getConditionMenuSelectedItems(),
305
- itemSelectedCallback: function (item) {
306
- var action;
307
- switch (item.id) {
308
- case "enable":
309
- action = ConditionAction.Enable;
310
- break;
311
- case "delete":
312
- action = ConditionAction.Delete;
313
- break;
314
- case "param":
315
- action = ConditionAction.Parameterized;
316
- break;
317
- case "inJoin":
318
- action = ConditionAction.InJoin;
319
- break;
320
- case "addCondition":
321
- action = ConditionAction.AddCondition;
322
- break;
323
- case "addGroup":
324
- action = ConditionAction.AddGroup;
325
- break;
326
- }
327
- _this.conditionMenuHandler(action, evt);
328
- },
329
- itemFilterCallback: function (item) {
330
- var result = _this.condition.enabled || item.id === "enable" || item.id === "delete";
331
- if (item.id === "enable") {
332
- var parent_2 = _this.condition.getParent();
333
- result = result && parent_2 && parent_2.enabled;
334
- }
335
- else if (item.id === "delete") {
336
- result = result && ((_this.panel.options.editableParts & QPEditablePart.Removal) === QPEditablePart.Removal);
337
- }
338
- else if (item.id === "addGroup" || item.id === "addCondition") {
339
- result = result && ((_this.panel.options.editableParts & QPEditablePart.Addition) === QPEditablePart.Addition);
340
- }
341
- return result;
342
- },
343
- menuClosedCallback: function () {
344
- _this.keepShowingButtons = false;
345
- if (!_this.isMouseOverBlock)
346
- _this.leaveButtonBlock();
347
- }
348
- });
349
- break;
350
- case ConditionAction.Parameterized:
351
- this.condition.setParameterized(!this.condition.isParameterized());
352
- this.condition.fireChangedEvent();
353
- break;
354
- case ConditionAction.InJoin:
355
- this.condition.setInJoin(!this.condition.isInJoin());
356
- this.condition.fireChangedEvent();
357
- break;
358
- }
359
- evt.stopPropagation();
360
- return false;
361
- };
362
- SimpleConditionRenderer.prototype.getConditionMenuSelectedItems = function () {
363
- var arrSelected = [];
364
- if (this.condition.enabled) {
365
- arrSelected.push("enable");
366
- }
367
- ;
368
- if (this.condition.isParameterized()) {
369
- arrSelected.push("param");
370
- }
371
- ;
372
- if (this.condition.isInJoin()) {
373
- arrSelected.push("inJoin");
374
- }
375
- ;
376
- return arrSelected;
377
- };
378
- SimpleConditionRenderer.prototype.renderButtonsBlock = function () {
379
- var _this = this;
380
- var onButtonMouseEnter = function (evt) {
381
- domel(evt.target)
382
- .addClass(_this.cssPrefix + "-condition-button-active");
383
- };
384
- var onButtonMouseLeave = function (evt) {
385
- domel(evt.target)
386
- .removeClass(_this.cssPrefix + "-condition-button-active");
387
- };
388
- var builder = domel("div")
389
- .addClass(this.cssPrefix + "-condition-buttonsBlock")
390
- .addClass(browserUtils.getMobileCssClass());
391
- this.buttonsBlock = builder.toDOM();
392
- if (this.condition.isReadOnly()) {
393
- return this.buttonsBlock;
394
- }
395
- var buttonsToShow = this.getButtonsToShow();
396
- if (buttonsToShow.indexOf("addCondition") >= 0 && this.condition.enabled
397
- && ((this.panel.options.editableParts & QPEditablePart.Addition) == QPEditablePart.Addition)) {
398
- builder.addChild("div", function (b) {
399
- b.addClass(_this.cssPrefix + "-button-placeholder")
400
- .data("btnplaceholder", "")
401
- .addChild("div", function (b) {
402
- b.addClass(_this.cssPrefix + "-condition-button " + _this.cssPrefix + "-condition-button-addCondition")
403
- .attr('tabIndex', '0')
404
- .data("button", "")
405
- .title(i18n.getText('CmdAddCondition'))
406
- .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.AddCondition, evt); })
407
- .on('keypress', function (evt) { if (evt.keyCode == 13) {
408
- evt.target.click();
409
- } })
410
- .on('mouseenter', onButtonMouseEnter)
411
- .on('mouseleave', onButtonMouseLeave);
412
- });
413
- });
414
- }
415
- ;
416
- var showAddGroupBtn = buttonsToShow.indexOf("addGroup") >= 0 || buttonsToShow.indexOf("addPredicate") >= 0;
417
- if (showAddGroupBtn && this.condition.enabled
418
- && ((this.panel.options.editableParts & QPEditablePart.Addition) == QPEditablePart.Addition)) {
419
- builder.addChild("div", function (b) {
420
- b.addClass(_this.cssPrefix + "-button-placeholder")
421
- .data("btnplaceholder", "")
422
- .addChild("div", function (b) {
423
- b.addClass(_this.cssPrefix + "-condition-button " + _this.cssPrefix + "-condition-button-addPredicate")
424
- .attr('tabIndex', '0')
425
- .data("button", "")
426
- .title(i18n.getText('CmdAddCondGroup'))
427
- .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.AddGroup, evt); })
428
- .on('keypress', function (evt) { if (evt.keyCode == 13) {
429
- evt.target.click();
430
- } })
431
- .on('mouseenter', onButtonMouseEnter)
432
- .on('mouseleave', onButtonMouseLeave);
433
- });
434
- });
435
- }
436
- ;
437
- if (this.getButtonsToShow().indexOf("enable") >= 0 && this.condition.getParent() && this.condition.getParent().enabled) {
438
- builder.addChild("div", function (b) {
439
- b.addClass(_this.cssPrefix + "-button-placeholder")
440
- .data("btnplaceholder", "")
441
- .addChild("div", function (b) {
442
- b.addClass(_this.cssPrefix + "-condition-button " + _this.cssPrefix + "-condition-button-enable")
443
- .attr('tabIndex', '0')
444
- .data("button", "")
445
- .title(i18n.getText('CmdToggleEnable'))
446
- .addClass(_this.condition.enabled ? 'enabled' : '')
447
- .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.Enable, evt); })
448
- .on('keypress', function (evt) { if (evt.keyCode == 13) {
449
- evt.target.click();
450
- } })
451
- .on('mouseenter', onButtonMouseEnter)
452
- .on('mouseleave', onButtonMouseLeave);
453
- });
454
- });
455
- }
456
- ;
457
- if (this.getButtonsToShow().indexOf("delete") >= 0 && this.condition.getParent()
458
- && ((this.panel.options.editableParts & QPEditablePart.Removal) == QPEditablePart.Removal)) {
459
- builder.addChild("div", function (b) {
460
- b.addClass(_this.cssPrefix + "-button-placeholder")
461
- .data("btnplaceholder", "")
462
- .addChild("div", function (b) {
463
- b.addClass(_this.cssPrefix + "-condition-button " + _this.cssPrefix + "-condition-button-delete")
464
- .attr('tabIndex', '0')
465
- .data("button", "")
466
- .title(i18n.getText('CmdDelete'))
467
- .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.Delete, evt); })
468
- .on('keypress', function (evt) { if (evt.keyCode == 13) {
469
- evt.target.click();
470
- } })
471
- .on('mouseenter', onButtonMouseEnter)
472
- .on('mouseleave', onButtonMouseLeave);
473
- });
474
- });
475
- }
476
- ;
477
- if (this.getButtonsToShow().indexOf("menu") >= 0) {
478
- builder.addChild("div", function (b) {
479
- b.addClass(_this.cssPrefix + "-button-placeholder")
480
- .data("btnplaceholder", "")
481
- .addChild("div", function (b) {
482
- b.addClass(_this.cssPrefix + "-condition-button " + _this.cssPrefix + "-condition-button-menu")
483
- .attr('tabIndex', '0')
484
- .data("button", "")
485
- .title(i18n.getText('ButtonMenu'))
486
- .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.Menu, evt); });
487
- if (!browserUtils.isMobileMode()) {
488
- b
489
- .on('keypress', function (evt) { if (evt.keyCode == 13) {
490
- evt.target.click();
491
- } })
492
- .on('mouseenter', onButtonMouseEnter)
493
- .on('mouseleave', onButtonMouseLeave);
494
- }
495
- });
496
- });
497
- }
498
- ;
499
- this.adjustButtonsVisibility();
500
- return this.buttonsBlock;
501
- };
502
- SimpleConditionRenderer.prototype.getButtonsToShow = function () {
503
- return this.panel.options.buttons && this.panel.options.buttons.condition && Array.isArray(this.panel.options.buttons.condition) ? this.panel.options.buttons.condition : ["enable", "delete"];
504
- };
505
- return SimpleConditionRenderer;
506
- }(ConditionRenderer));
507
- export { SimpleConditionRenderer };
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 { i18n } from '@easydata/core';
17
+ import { utils as dataUtils } from '@easydata/core';
18
+ import { equtils, QueryChangeAction } from '@easyquery/core';
19
+ import { createBrowserEvent, domel } from '@easydata/ui';
20
+ import { TextRenderer } from './text_renderer';
21
+ import { browserUtils } from '../../../utils/browser_utils';
22
+ import { QPEditablePart } from '../../../types/qp_editable_part';
23
+ export var ConditionAction;
24
+ (function (ConditionAction) {
25
+ ConditionAction[ConditionAction["AddCondition"] = 0] = "AddCondition";
26
+ ConditionAction[ConditionAction["AddGroup"] = 1] = "AddGroup";
27
+ ConditionAction[ConditionAction["Enable"] = 2] = "Enable";
28
+ ConditionAction[ConditionAction["Delete"] = 4] = "Delete";
29
+ ConditionAction[ConditionAction["Menu"] = 5] = "Menu";
30
+ ConditionAction[ConditionAction["Parameterized"] = 6] = "Parameterized";
31
+ ConditionAction[ConditionAction["InJoin"] = 7] = "InJoin";
32
+ })(ConditionAction || (ConditionAction = {}));
33
+ var ConditionRenderer = /** @class */ (function () {
34
+ function ConditionRenderer(panel, condition, slot) {
35
+ this.panel = panel;
36
+ this.condition = condition;
37
+ this.element = slot || domel('div').toDOM();
38
+ }
39
+ Object.defineProperty(ConditionRenderer.prototype, "cssPrefix", {
40
+ get: function () {
41
+ return 'eqjs-qp';
42
+ },
43
+ enumerable: false,
44
+ configurable: true
45
+ });
46
+ ConditionRenderer.prototype.refresh = function () {
47
+ this.render();
48
+ };
49
+ ConditionRenderer.prototype.clear = function () {
50
+ if (this.element) {
51
+ this.element.className = '';
52
+ this.element.removeAttribute('data-id');
53
+ this.element.removeAttribute('style');
54
+ domel(this.element)
55
+ .html('');
56
+ }
57
+ };
58
+ ConditionRenderer.prototype.render = function (autoAppear) {
59
+ this.clear();
60
+ //this.preRender();
61
+ this.coreRender(autoAppear);
62
+ if (this.panel.options.onConditionRendered) {
63
+ this.panel.options.onConditionRendered(this.condition, this.element);
64
+ }
65
+ return this.element;
66
+ };
67
+ ConditionRenderer.prototype.isEditable = function () {
68
+ return this.condition.enabled && !this.condition.isReadOnly();
69
+ };
70
+ return ConditionRenderer;
71
+ }());
72
+ export { ConditionRenderer };
73
+ var SimpleConditionRenderer = /** @class */ (function (_super) {
74
+ __extends(SimpleConditionRenderer, _super);
75
+ function SimpleConditionRenderer() {
76
+ return _super !== null && _super.apply(this, arguments) || this;
77
+ }
78
+ SimpleConditionRenderer.prototype.getClassesToAdd = function () {
79
+ var result = "".concat(this.cssPrefix, "-row ").concat(this.cssPrefix, "-row-condition");
80
+ result += this.condition.isInJoin() ? " ".concat(this.cssPrefix, "-condition-injoin") : '';
81
+ result += this.condition.isParameterized() ? " ".concat(this.cssPrefix, "-condition-parameterized") : '';
82
+ if (!browserUtils.isMobileMode()) {
83
+ var level = this.condition.getLevel();
84
+ if (level > 0)
85
+ result += " ".concat(this.cssPrefix, "-level-").concat(level);
86
+ }
87
+ result += this.condition.enabled ? '' : " ".concat(this.cssPrefix, "-disabled");
88
+ if (this.condition.enabled) {
89
+ result += this.condition.isReadOnly() ? " ".concat(this.cssPrefix, "-readonly") : '';
90
+ }
91
+ return result;
92
+ };
93
+ SimpleConditionRenderer.prototype.coreRender = function (autoAppear) {
94
+ var _this = this;
95
+ var model = this.panel.getContext().getModel();
96
+ var operator = model.getOperatorById(this.condition.getOperatorId());
97
+ var arrFormat = equtils.parseOperatorFormat(operator);
98
+ var item = null;
99
+ var arrLength = arrFormat.length;
100
+ var builder = domel('div');
101
+ if (this.element && this.element.parentNode) {
102
+ this.element.parentNode
103
+ .replaceChild(builder.toDOM(), this.element);
104
+ }
105
+ this.element = builder.toDOM();
106
+ builder
107
+ .addClass(this.getClassesToAdd())
108
+ .addClass(browserUtils.getMobileCssClass())
109
+ .data('id', this.condition.id)
110
+ .data('condrow', '')
111
+ .addChildElement(this.renderCheckbox())
112
+ .addChildElement(this.renderConjunction());
113
+ var mayAppear = autoAppear;
114
+ var minLength = operator == model.nullOperator
115
+ ? Math.min(arrLength, this.condition.expressions.length + 1)
116
+ : arrLength;
117
+ var _loop_1 = function (idx) {
118
+ item = arrFormat[idx];
119
+ if (item.type === 'operator') {
120
+ var renderer = this_1.panel.getOperatorRenderer(this_1.condition, item.text);
121
+ if (renderer) {
122
+ builder.addChildElement(renderer.render());
123
+ }
124
+ }
125
+ else if (item.type === 'expression') {
126
+ var toAppear = mayAppear && (item.index > 0);
127
+ var exprRenderer_1 = this_1.panel.getExpressionRenderer(this_1.condition.expressions[item.index]);
128
+ if (exprRenderer_1) {
129
+ var el = exprRenderer_1.render(toAppear);
130
+ builder.addChildElement(el);
131
+ setTimeout(function () {
132
+ exprRenderer_1.adjustWidth();
133
+ }, 100);
134
+ }
135
+ mayAppear = mayAppear && !toAppear;
136
+ }
137
+ else if (item.type === 'text') {
138
+ builder.addChildElement(new TextRenderer(this_1.panel, item.text).render());
139
+ }
140
+ };
141
+ var this_1 = this;
142
+ for (var idx = 0; idx < minLength; idx++) {
143
+ _loop_1(idx);
144
+ }
145
+ if (this.panel.options.accentActiveCondition || browserUtils.isMobileMode()) {
146
+ builder.on('click', function (ev) {
147
+ ev.stopPropagation();
148
+ _this.panel.toggleConditionPicked(_this.condition);
149
+ _this.adjustButtonsVisibility();
150
+ if (!browserUtils.isMobileMode()) {
151
+ _this.element.dispatchEvent(createBrowserEvent("mouseenter"));
152
+ }
153
+ return false;
154
+ });
155
+ }
156
+ builder
157
+ .addChildElement(this.renderButtonsBlock());
158
+ if (!browserUtils.isMobileMode()) {
159
+ builder
160
+ .on('mouseenter', function (event) {
161
+ _this.isMouseOverBlock = true;
162
+ _this.enterButtonBlock();
163
+ event.stopPropagation();
164
+ return false;
165
+ })
166
+ .on('mouseleave', function (event) {
167
+ _this.isMouseOverBlock = false;
168
+ if (!_this.keepShowingButtons && domel(_this.buttonsBlock).isVisible()) {
169
+ _this.leaveButtonBlock();
170
+ }
171
+ event.stopPropagation();
172
+ return false;
173
+ });
174
+ }
175
+ };
176
+ SimpleConditionRenderer.prototype.setConditionParameterized = function (value) {
177
+ this.condition.setParameterized(value);
178
+ this.condition.fireChangedEvent();
179
+ };
180
+ SimpleConditionRenderer.prototype.setConditionInJoin = function (value) {
181
+ this.condition.setInJoin(value);
182
+ this.condition.fireChangedEvent();
183
+ };
184
+ SimpleConditionRenderer.prototype.getConditionMenu = function () {
185
+ return this.panel.getConditionMenu();
186
+ };
187
+ SimpleConditionRenderer.prototype.renderConjunction = function () {
188
+ var parent = this.condition.getParent();
189
+ if (!parent)
190
+ return null;
191
+ var isFirstConditionInGroup = dataUtils.findItemIndexById(parent.getConditions(), this.condition.id) == 0;
192
+ if (this.panel.options.showConjunctions && !isFirstConditionInGroup) {
193
+ var linkTypeStr = equtils.linkTypeToStr(this.condition.getParent().linkType);
194
+ var conjuctionText = i18n.getText("Conj" + linkTypeStr);
195
+ return domel("span")
196
+ .text(conjuctionText)
197
+ .title(conjuctionText)
198
+ .addClass("".concat(this.cssPrefix, "-condelement ").concat(this.cssPrefix, "-condition-conjuction"))
199
+ .toDOM();
200
+ }
201
+ return null;
202
+ };
203
+ SimpleConditionRenderer.prototype.renderCheckbox = function () {
204
+ var _this = this;
205
+ if (this.panel.options.showCheckboxes && !this.condition.isReadOnly()) {
206
+ return domel("div")
207
+ .title(i18n.getText('CmdToggleEnable'))
208
+ .attr('tabIndex', '0')
209
+ .addClass("".concat(this.cssPrefix, "-condelement ").concat(this.cssPrefix, "-condition-checkbox"))
210
+ .addClass("".concat(this.condition.enabled ? 'enabled' : ''))
211
+ .on('click', function () {
212
+ _this.condition.enabled = !_this.condition.enabled;
213
+ _this.condition.fireChangedEvent();
214
+ return false;
215
+ })
216
+ .on('keypress', function (evt) { if ([13, 32].includes(evt.keyCode)) {
217
+ evt.target.click();
218
+ } })
219
+ .toDOM();
220
+ }
221
+ else {
222
+ return null;
223
+ }
224
+ };
225
+ SimpleConditionRenderer.prototype.isConditionActive = function () {
226
+ return this.element.classList.contains("active");
227
+ };
228
+ SimpleConditionRenderer.prototype.hideButtons = function () {
229
+ domel(this.element).data("show-buttons", null);
230
+ };
231
+ SimpleConditionRenderer.prototype.showButtons = function () {
232
+ domel(this.element).data("show-buttons", "");
233
+ };
234
+ SimpleConditionRenderer.prototype.adjustButtonsVisibility = function () {
235
+ if (this.panel.options.alwaysShowButtonsInConditions
236
+ || (this.panel.options.accentActiveCondition && this.isConditionActive())) {
237
+ this.showButtons();
238
+ }
239
+ };
240
+ SimpleConditionRenderer.prototype.enterButtonBlock = function () {
241
+ this.showButtons();
242
+ };
243
+ SimpleConditionRenderer.prototype.leaveButtonBlock = function () {
244
+ if (!this.panel.options.alwaysShowButtonsInConditions
245
+ && (!this.isConditionActive() || !this.panel.options.accentActiveCondition)) {
246
+ this.hideButtons();
247
+ }
248
+ };
249
+ SimpleConditionRenderer.prototype.conditionMenuHandler = function (action, evt) {
250
+ var _this = this;
251
+ switch (action) {
252
+ case ConditionAction.AddCondition:
253
+ if (!this.condition.isGroup())
254
+ return;
255
+ var entMenu = this.panel.getEntitiesMenu();
256
+ if (entMenu) {
257
+ entMenu.showMenu({
258
+ anchor: evt.target,
259
+ itemSelectedCallback: function (item) {
260
+ var query = _this.panel.getQuery();
261
+ var descr = {
262
+ parent: _this.condition,
263
+ attributeId: item.id
264
+ };
265
+ var cond = query.addSimpleCondition(descr);
266
+ if (cond) {
267
+ query.fireConditionsChangedEvent(QueryChangeAction.Add, cond);
268
+ }
269
+ return false;
270
+ }
271
+ });
272
+ }
273
+ break;
274
+ case ConditionAction.AddGroup:
275
+ if (!this.condition.isGroup())
276
+ return;
277
+ var query = this.panel.getQuery();
278
+ var descr = {
279
+ parent: this.condition
280
+ };
281
+ var group = this.panel.getQuery().addConditionGroup(descr);
282
+ if (group) {
283
+ query.fireConditionsChangedEvent(QueryChangeAction.Add, group);
284
+ }
285
+ break;
286
+ case ConditionAction.Enable:
287
+ this.condition.enabled = !this.condition.enabled;
288
+ this.condition.fireChangedEvent();
289
+ break;
290
+ case ConditionAction.Delete:
291
+ var parent_1 = this.condition.getParent();
292
+ if (!parent_1)
293
+ return;
294
+ var conditions = parent_1.getConditions();
295
+ var idx = conditions.indexOf(this.condition);
296
+ if (idx >= 0) {
297
+ conditions.splice(idx, 1);
298
+ this.condition.getQuery().fireConditionsChangedEvent(QueryChangeAction.Delete, this.condition);
299
+ }
300
+ break;
301
+ case ConditionAction.Menu:
302
+ var condMenu = this.getConditionMenu();
303
+ this.keepShowingButtons = true;
304
+ condMenu.showMenu({
305
+ anchor: evt.target,
306
+ selectedIds: this.getConditionMenuSelectedItems(),
307
+ itemSelectedCallback: function (item) {
308
+ var action;
309
+ switch (item.id) {
310
+ case "enable":
311
+ action = ConditionAction.Enable;
312
+ break;
313
+ case "delete":
314
+ action = ConditionAction.Delete;
315
+ break;
316
+ case "param":
317
+ action = ConditionAction.Parameterized;
318
+ break;
319
+ case "inJoin":
320
+ action = ConditionAction.InJoin;
321
+ break;
322
+ case "addCondition":
323
+ action = ConditionAction.AddCondition;
324
+ break;
325
+ case "addGroup":
326
+ action = ConditionAction.AddGroup;
327
+ break;
328
+ }
329
+ _this.conditionMenuHandler(action, evt);
330
+ },
331
+ itemFilterCallback: function (item) {
332
+ var result = _this.condition.enabled || item.id === "enable" || item.id === "delete";
333
+ if (item.id === "enable") {
334
+ var parent_2 = _this.condition.getParent();
335
+ result = result && parent_2 && parent_2.enabled;
336
+ }
337
+ else if (item.id === "delete") {
338
+ result = result && ((_this.panel.options.editableParts & QPEditablePart.Removal) === QPEditablePart.Removal);
339
+ }
340
+ else if (item.id === "addGroup" || item.id === "addCondition") {
341
+ result = result && ((_this.panel.options.editableParts & QPEditablePart.Addition) === QPEditablePart.Addition);
342
+ }
343
+ return result;
344
+ },
345
+ menuClosedCallback: function () {
346
+ _this.keepShowingButtons = false;
347
+ if (!_this.isMouseOverBlock)
348
+ _this.leaveButtonBlock();
349
+ }
350
+ });
351
+ break;
352
+ case ConditionAction.Parameterized:
353
+ this.condition.setParameterized(!this.condition.isParameterized());
354
+ this.condition.fireChangedEvent();
355
+ break;
356
+ case ConditionAction.InJoin:
357
+ this.condition.setInJoin(!this.condition.isInJoin());
358
+ this.condition.fireChangedEvent();
359
+ break;
360
+ }
361
+ evt.stopPropagation();
362
+ return false;
363
+ };
364
+ SimpleConditionRenderer.prototype.getConditionMenuSelectedItems = function () {
365
+ var arrSelected = [];
366
+ if (this.condition.enabled) {
367
+ arrSelected.push("enable");
368
+ }
369
+ ;
370
+ if (this.condition.isParameterized()) {
371
+ arrSelected.push("param");
372
+ }
373
+ ;
374
+ if (this.condition.isInJoin()) {
375
+ arrSelected.push("inJoin");
376
+ }
377
+ ;
378
+ return arrSelected;
379
+ };
380
+ SimpleConditionRenderer.prototype.renderButtonsBlock = function () {
381
+ var _this = this;
382
+ var onButtonMouseEnter = function (evt) {
383
+ domel(evt.target)
384
+ .addClass("".concat(_this.cssPrefix, "-condition-button-active"));
385
+ };
386
+ var onButtonMouseLeave = function (evt) {
387
+ domel(evt.target)
388
+ .removeClass("".concat(_this.cssPrefix, "-condition-button-active"));
389
+ };
390
+ var builder = domel("div")
391
+ .addClass("".concat(this.cssPrefix, "-condition-buttonsBlock"))
392
+ .addClass(browserUtils.getMobileCssClass());
393
+ this.buttonsBlock = builder.toDOM();
394
+ if (this.condition.isReadOnly()) {
395
+ return this.buttonsBlock;
396
+ }
397
+ var buttonsToShow = this.getButtonsToShow();
398
+ if (buttonsToShow.indexOf("addCondition") >= 0 && this.condition.enabled
399
+ && ((this.panel.options.editableParts & QPEditablePart.Addition) == QPEditablePart.Addition)) {
400
+ builder.addChild("div", function (b) {
401
+ b.addClass("".concat(_this.cssPrefix, "-button-placeholder"))
402
+ .data("btnplaceholder", "")
403
+ .addChild("div", function (b) {
404
+ b.addClass("".concat(_this.cssPrefix, "-condition-button ").concat(_this.cssPrefix, "-condition-button-addCondition"))
405
+ .attr('tabIndex', '0')
406
+ .data("button", "")
407
+ .title(i18n.getText('CmdAddCondition'))
408
+ .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.AddCondition, evt); })
409
+ .on('keypress', function (evt) { if (evt.keyCode == 13) {
410
+ evt.target.click();
411
+ } })
412
+ .on('mouseenter', onButtonMouseEnter)
413
+ .on('mouseleave', onButtonMouseLeave);
414
+ });
415
+ });
416
+ }
417
+ ;
418
+ var showAddGroupBtn = buttonsToShow.indexOf("addGroup") >= 0 || buttonsToShow.indexOf("addPredicate") >= 0;
419
+ if (showAddGroupBtn && this.condition.enabled
420
+ && ((this.panel.options.editableParts & QPEditablePart.Addition) == QPEditablePart.Addition)) {
421
+ builder.addChild("div", function (b) {
422
+ b.addClass("".concat(_this.cssPrefix, "-button-placeholder"))
423
+ .data("btnplaceholder", "")
424
+ .addChild("div", function (b) {
425
+ b.addClass("".concat(_this.cssPrefix, "-condition-button ").concat(_this.cssPrefix, "-condition-button-addPredicate"))
426
+ .attr('tabIndex', '0')
427
+ .data("button", "")
428
+ .title(i18n.getText('CmdAddCondGroup'))
429
+ .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.AddGroup, evt); })
430
+ .on('keypress', function (evt) { if (evt.keyCode == 13) {
431
+ evt.target.click();
432
+ } })
433
+ .on('mouseenter', onButtonMouseEnter)
434
+ .on('mouseleave', onButtonMouseLeave);
435
+ });
436
+ });
437
+ }
438
+ ;
439
+ if (this.getButtonsToShow().indexOf("enable") >= 0 && this.condition.getParent() && this.condition.getParent().enabled) {
440
+ builder.addChild("div", function (b) {
441
+ b.addClass("".concat(_this.cssPrefix, "-button-placeholder"))
442
+ .data("btnplaceholder", "")
443
+ .addChild("div", function (b) {
444
+ b.addClass("".concat(_this.cssPrefix, "-condition-button ").concat(_this.cssPrefix, "-condition-button-enable"))
445
+ .attr('tabIndex', '0')
446
+ .data("button", "")
447
+ .title(i18n.getText('CmdToggleEnable'))
448
+ .addClass(_this.condition.enabled ? 'enabled' : '')
449
+ .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.Enable, evt); })
450
+ .on('keypress', function (evt) { if (evt.keyCode == 13) {
451
+ evt.target.click();
452
+ } })
453
+ .on('mouseenter', onButtonMouseEnter)
454
+ .on('mouseleave', onButtonMouseLeave);
455
+ });
456
+ });
457
+ }
458
+ ;
459
+ if (this.getButtonsToShow().indexOf("delete") >= 0 && this.condition.getParent()
460
+ && ((this.panel.options.editableParts & QPEditablePart.Removal) == QPEditablePart.Removal)) {
461
+ builder.addChild("div", function (b) {
462
+ b.addClass("".concat(_this.cssPrefix, "-button-placeholder"))
463
+ .data("btnplaceholder", "")
464
+ .addChild("div", function (b) {
465
+ b.addClass("".concat(_this.cssPrefix, "-condition-button ").concat(_this.cssPrefix, "-condition-button-delete"))
466
+ .attr('tabIndex', '0')
467
+ .data("button", "")
468
+ .title(i18n.getText('CmdDelete'))
469
+ .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.Delete, evt); })
470
+ .on('keypress', function (evt) { if (evt.keyCode == 13) {
471
+ evt.target.click();
472
+ } })
473
+ .on('mouseenter', onButtonMouseEnter)
474
+ .on('mouseleave', onButtonMouseLeave);
475
+ });
476
+ });
477
+ }
478
+ ;
479
+ if (this.getButtonsToShow().indexOf("menu") >= 0) {
480
+ builder.addChild("div", function (b) {
481
+ b.addClass("".concat(_this.cssPrefix, "-button-placeholder"))
482
+ .data("btnplaceholder", "")
483
+ .addChild("div", function (b) {
484
+ b.addClass("".concat(_this.cssPrefix, "-condition-button ").concat(_this.cssPrefix, "-condition-button-menu"))
485
+ .attr('tabIndex', '0')
486
+ .data("button", "")
487
+ .title(i18n.getText('ButtonMenu'))
488
+ .on('click', function (evt) { return _this.conditionMenuHandler(ConditionAction.Menu, evt); });
489
+ if (!browserUtils.isMobileMode()) {
490
+ b
491
+ .on('keypress', function (evt) { if (evt.keyCode == 13) {
492
+ evt.target.click();
493
+ } })
494
+ .on('mouseenter', onButtonMouseEnter)
495
+ .on('mouseleave', onButtonMouseLeave);
496
+ }
497
+ });
498
+ });
499
+ }
500
+ ;
501
+ this.adjustButtonsVisibility();
502
+ return this.buttonsBlock;
503
+ };
504
+ SimpleConditionRenderer.prototype.getButtonsToShow = function () {
505
+ return this.panel.options.buttons && this.panel.options.buttons.condition && Array.isArray(this.panel.options.buttons.condition) ? this.panel.options.buttons.condition : ["enable", "delete"];
506
+ };
507
+ return SimpleConditionRenderer;
508
+ }(ConditionRenderer));
509
+ export { SimpleConditionRenderer };
508
510
  //# sourceMappingURL=condition_renderer.js.map