@openui5/sap.ui.mdc 1.93.3 → 1.96.2

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 (237) hide show
  1. package/.reuse/dep5 +6 -11
  2. package/THIRDPARTY.txt +10 -16
  3. package/package.json +4 -4
  4. package/src/sap/ui/mdc/.library +1 -1
  5. package/src/sap/ui/mdc/ActionToolbar.js +236 -334
  6. package/src/sap/ui/mdc/AggregationBaseDelegate.js +2 -1
  7. package/src/sap/ui/mdc/Chart.js +150 -22
  8. package/src/sap/ui/mdc/ChartDelegateNew.js +15 -0
  9. package/src/sap/ui/mdc/ChartNew.js +107 -66
  10. package/src/sap/ui/mdc/Control.js +4 -3
  11. package/src/sap/ui/mdc/Element.js +5 -4
  12. package/src/sap/ui/mdc/Field.js +2 -2
  13. package/src/sap/ui/mdc/FilterBar.js +1 -10
  14. package/src/sap/ui/mdc/FilterField.js +28 -4
  15. package/src/sap/ui/mdc/Link.js +2 -2
  16. package/src/sap/ui/mdc/MultiValueField.js +1 -1
  17. package/src/sap/ui/mdc/Table.js +172 -79
  18. package/src/sap/ui/mdc/TableDelegate.js +20 -3
  19. package/src/sap/ui/mdc/ValueHelp.js +1474 -0
  20. package/src/sap/ui/mdc/ValueHelpDelegate.js +147 -0
  21. package/src/sap/ui/mdc/actiontoolbar/ActionToolbarAction.js +49 -104
  22. package/src/sap/ui/mdc/chart/DimensionItem.js +3 -3
  23. package/src/sap/ui/mdc/chart/Item.js +2 -3
  24. package/src/sap/ui/mdc/chart/MeasureItem.js +2 -2
  25. package/src/sap/ui/mdc/chart/SelectionDetailsActions.js +21 -2
  26. package/src/sap/ui/mdc/chart/ToolbarHandler.js +237 -225
  27. package/src/sap/ui/mdc/chartNew/ChartSelectionDetailsNew.js +1 -1
  28. package/src/sap/ui/mdc/chartNew/ChartToolbarNew.js +14 -10
  29. package/src/sap/ui/mdc/chartNew/ChartTypeButtonNew.js +1 -1
  30. package/src/sap/ui/mdc/chartNew/DrillStackHandlerNew.js +12 -10
  31. package/src/sap/ui/mdc/chartNew/ItemNew.js +0 -1
  32. package/src/sap/ui/mdc/chartNew/PropertyHelperNew.js +1 -1
  33. package/src/sap/ui/mdc/condition/Condition.js +2 -2
  34. package/src/sap/ui/mdc/condition/ConditionConverter.js +1 -1
  35. package/src/sap/ui/mdc/condition/ConditionModel.js +1 -1
  36. package/src/sap/ui/mdc/condition/FilterConverter.js +1 -1
  37. package/src/sap/ui/mdc/condition/FilterOperatorUtil.js +13 -7
  38. package/src/sap/ui/mdc/condition/Operator.js +4 -4
  39. package/src/sap/ui/mdc/condition/RangeOperator.js +1 -1
  40. package/src/sap/ui/mdc/designtime/actiontoolbar/ActionToolbar.designtime.js +43 -0
  41. package/src/sap/ui/mdc/designtime/chart/ChartNew.designtime.js +91 -0
  42. package/src/sap/ui/mdc/designtime/filterbar/FilterBar.designtime.js +20 -0
  43. package/src/sap/ui/mdc/designtime/filterbar/FilterBarBase.designtime.js +31 -0
  44. package/src/sap/ui/mdc/designtime/table/Table.designtime.js +5 -0
  45. package/src/sap/ui/mdc/enum/ContentMode.js +25 -4
  46. package/src/sap/ui/mdc/enum/SelectType.js +43 -0
  47. package/src/sap/ui/mdc/field/BoolFieldHelp.js +1 -1
  48. package/src/sap/ui/mdc/field/ConditionFieldHelp.js +1 -1
  49. package/src/sap/ui/mdc/field/ConditionType.js +19 -4
  50. package/src/sap/ui/mdc/field/ConditionsType.js +5 -4
  51. package/src/sap/ui/mdc/field/CustomFieldHelp.js +1 -1
  52. package/src/sap/ui/mdc/field/CustomFieldInfo.js +1 -1
  53. package/src/sap/ui/mdc/field/DefineConditionPanel.js +38 -14
  54. package/src/sap/ui/mdc/field/FieldBase.js +92 -41
  55. package/src/sap/ui/mdc/field/FieldBaseDelegate.js +9 -2
  56. package/src/sap/ui/mdc/field/FieldHelpBase.js +64 -4
  57. package/src/sap/ui/mdc/field/FieldInfoBase.js +9 -1
  58. package/src/sap/ui/mdc/field/FieldInput.js +1 -1
  59. package/src/sap/ui/mdc/field/FieldInputRenderUtil.js +1 -1
  60. package/src/sap/ui/mdc/field/FieldMultiInput.js +1 -1
  61. package/src/sap/ui/mdc/field/FieldValueHelp.js +7 -1
  62. package/src/sap/ui/mdc/field/FieldValueHelpContentWrapperBase.js +1 -1
  63. package/src/sap/ui/mdc/field/FieldValueHelpMTableWrapper.js +1 -1
  64. package/src/sap/ui/mdc/field/FieldValueHelpMdcTableWrapper.js +1 -1
  65. package/src/sap/ui/mdc/field/FieldValueHelpTableWrapperBase.js +2 -2
  66. package/src/sap/ui/mdc/field/FieldValueHelpUITableWrapper.js +1 -1
  67. package/src/sap/ui/mdc/field/InParameter.js +1 -1
  68. package/src/sap/ui/mdc/field/ListFieldHelp.js +3 -3
  69. package/src/sap/ui/mdc/field/ListFieldHelpItem.js +1 -1
  70. package/src/sap/ui/mdc/field/MultiValueFieldItem.js +1 -1
  71. package/src/sap/ui/mdc/field/OutParameter.js +1 -1
  72. package/src/sap/ui/mdc/field/ValueHelpPanel.js +1 -1
  73. package/src/sap/ui/mdc/field/content/BooleanContent.js +15 -3
  74. package/src/sap/ui/mdc/field/content/ContentFactory.js +16 -8
  75. package/src/sap/ui/mdc/field/content/DefaultContent.js +64 -23
  76. package/src/sap/ui/mdc/field/content/LinkContent.js +6 -0
  77. package/src/sap/ui/mdc/field/content/SearchContent.js +21 -3
  78. package/src/sap/ui/mdc/field/content/UnitContent.js +2 -2
  79. package/src/sap/ui/mdc/filterbar/FilterBarBase.js +105 -44
  80. package/src/sap/ui/mdc/filterbar/PropertyHelper.js +52 -0
  81. package/src/sap/ui/mdc/filterbar/p13n/AdaptationFilterBar.js +10 -51
  82. package/src/sap/ui/mdc/filterbar/vh/FilterBar.js +1 -1
  83. package/src/sap/ui/mdc/flexibility/ActionToolbar.flexibility.js +22 -0
  84. package/src/sap/ui/mdc/flexibility/ActionToolbarAction.flexibility.js +19 -0
  85. package/src/sap/ui/mdc/flexibility/Chart.flexibility.js +1 -1
  86. package/src/sap/ui/mdc/flexibility/ConditionFlex.js +57 -46
  87. package/src/sap/ui/mdc/flexibility/FilterBar.flexibility.js +1 -1
  88. package/src/sap/ui/mdc/flexibility/FilterItemFlex.js +1 -1
  89. package/src/sap/ui/mdc/flexibility/ItemBaseFlex.js +203 -197
  90. package/src/sap/ui/mdc/library.js +588 -8
  91. package/src/sap/ui/mdc/link/ContactDetails.js +1 -1
  92. package/src/sap/ui/mdc/link/ContactDetailsAddressItem.js +1 -1
  93. package/src/sap/ui/mdc/link/ContactDetailsEmailItem.js +1 -1
  94. package/src/sap/ui/mdc/link/ContactDetailsItem.js +1 -1
  95. package/src/sap/ui/mdc/link/ContactDetailsPhoneItem.js +1 -1
  96. package/src/sap/ui/mdc/link/Factory.js +1 -1
  97. package/src/sap/ui/mdc/link/FakeFlpConnector.js +1 -1
  98. package/src/sap/ui/mdc/link/LinkItem.js +1 -1
  99. package/src/sap/ui/mdc/link/Panel.js +1 -1
  100. package/src/sap/ui/mdc/link/PanelItem.js +1 -1
  101. package/src/sap/ui/mdc/link/PanelListItem.js +1 -1
  102. package/src/sap/ui/mdc/link/SelectionDialog.js +2 -2
  103. package/src/sap/ui/mdc/link/SelectionDialogItem.js +1 -1
  104. package/src/sap/ui/mdc/link/SemanticObjectMapping.js +1 -1
  105. package/src/sap/ui/mdc/link/SemanticObjectMappingItem.js +1 -1
  106. package/src/sap/ui/mdc/link/SemanticObjectUnavailableAction.js +1 -1
  107. package/src/sap/ui/mdc/messagebundle.properties +31 -5
  108. package/src/sap/ui/mdc/messagebundle_ar.properties +19 -4
  109. package/src/sap/ui/mdc/messagebundle_bg.properties +18 -3
  110. package/src/sap/ui/mdc/messagebundle_ca.properties +18 -3
  111. package/src/sap/ui/mdc/messagebundle_cs.properties +31 -16
  112. package/src/sap/ui/mdc/messagebundle_cy.properties +18 -3
  113. package/src/sap/ui/mdc/messagebundle_da.properties +18 -3
  114. package/src/sap/ui/mdc/messagebundle_de.properties +20 -5
  115. package/src/sap/ui/mdc/messagebundle_el.properties +19 -4
  116. package/src/sap/ui/mdc/messagebundle_en.properties +17 -2
  117. package/src/sap/ui/mdc/messagebundle_en_GB.properties +18 -3
  118. package/src/sap/ui/mdc/messagebundle_en_US_sappsd.properties +11 -3
  119. package/src/sap/ui/mdc/messagebundle_en_US_saprigi.properties +19 -3
  120. package/src/sap/ui/mdc/messagebundle_en_US_saptrc.properties +11 -2
  121. package/src/sap/ui/mdc/messagebundle_es.properties +43 -28
  122. package/src/sap/ui/mdc/messagebundle_es_MX.properties +18 -3
  123. package/src/sap/ui/mdc/messagebundle_et.properties +18 -3
  124. package/src/sap/ui/mdc/messagebundle_fi.properties +19 -4
  125. package/src/sap/ui/mdc/messagebundle_fr.properties +32 -17
  126. package/src/sap/ui/mdc/messagebundle_fr_CA.properties +18 -3
  127. package/src/sap/ui/mdc/messagebundle_hi.properties +18 -3
  128. package/src/sap/ui/mdc/messagebundle_hr.properties +18 -3
  129. package/src/sap/ui/mdc/messagebundle_hu.properties +19 -4
  130. package/src/sap/ui/mdc/messagebundle_id.properties +19 -4
  131. package/src/sap/ui/mdc/messagebundle_it.properties +41 -26
  132. package/src/sap/ui/mdc/messagebundle_iw.properties +18 -3
  133. package/src/sap/ui/mdc/messagebundle_ja.properties +28 -13
  134. package/src/sap/ui/mdc/messagebundle_kk.properties +18 -3
  135. package/src/sap/ui/mdc/messagebundle_ko.properties +18 -3
  136. package/src/sap/ui/mdc/messagebundle_lt.properties +18 -3
  137. package/src/sap/ui/mdc/messagebundle_lv.properties +18 -3
  138. package/src/sap/ui/mdc/messagebundle_ms.properties +18 -3
  139. package/src/sap/ui/mdc/messagebundle_nl.properties +19 -4
  140. package/src/sap/ui/mdc/messagebundle_no.properties +25 -10
  141. package/src/sap/ui/mdc/messagebundle_pl.properties +22 -7
  142. package/src/sap/ui/mdc/messagebundle_pt.properties +19 -4
  143. package/src/sap/ui/mdc/messagebundle_pt_PT.properties +18 -3
  144. package/src/sap/ui/mdc/messagebundle_ro.properties +21 -6
  145. package/src/sap/ui/mdc/messagebundle_ru.properties +18 -3
  146. package/src/sap/ui/mdc/messagebundle_sh.properties +18 -3
  147. package/src/sap/ui/mdc/messagebundle_sk.properties +19 -4
  148. package/src/sap/ui/mdc/messagebundle_sl.properties +18 -3
  149. package/src/sap/ui/mdc/messagebundle_sv.properties +19 -4
  150. package/src/sap/ui/mdc/messagebundle_th.properties +24 -9
  151. package/src/sap/ui/mdc/messagebundle_tr.properties +18 -3
  152. package/src/sap/ui/mdc/messagebundle_uk.properties +18 -3
  153. package/src/sap/ui/mdc/messagebundle_vi.properties +18 -3
  154. package/src/sap/ui/mdc/messagebundle_zh_CN.properties +18 -3
  155. package/src/sap/ui/mdc/messagebundle_zh_TW.properties +18 -3
  156. package/src/sap/ui/mdc/mixin/AdaptationMixin.js +1 -1
  157. package/src/sap/ui/mdc/mixin/DelegateMixin.js +2 -2
  158. package/src/sap/ui/mdc/mixin/FilterIntegrationMixin.js +3 -3
  159. package/src/sap/ui/mdc/mixin/PromiseMixin.js +94 -0
  160. package/src/sap/ui/mdc/odata/v4/ChartPropertyHelperNew.js +1 -1
  161. package/src/sap/ui/mdc/odata/v4/FilterBarDelegate.js +6 -6
  162. package/src/sap/ui/mdc/odata/v4/TableDelegate.js +37 -10
  163. package/src/sap/ui/mdc/odata/v4/ValueHelpDelegate.js +94 -0
  164. package/src/sap/ui/mdc/odata/v4/vizChart/ChartDelegateNew.js +492 -203
  165. package/src/sap/ui/mdc/p13n/DefaultProviderRegistry.js +1 -1
  166. package/src/sap/ui/mdc/p13n/Engine.js +3 -2
  167. package/src/sap/ui/mdc/p13n/P13nBuilder.js +6 -60
  168. package/src/sap/ui/mdc/p13n/PropertyHelper.js +1 -1
  169. package/src/sap/ui/mdc/p13n/UIManager.js +1 -1
  170. package/src/sap/ui/mdc/p13n/modification/ModificationHandler.js +22 -24
  171. package/src/sap/ui/mdc/p13n/panels/ActionToolbarPanel.js +59 -0
  172. package/src/sap/ui/mdc/p13n/panels/AdaptFiltersPanel.js +1 -2
  173. package/src/sap/ui/mdc/p13n/panels/BasePanel.js +17 -8
  174. package/src/sap/ui/mdc/p13n/panels/ChartItemPanel.js +1 -2
  175. package/src/sap/ui/mdc/p13n/panels/ChartItemPanelNew.js +1171 -0
  176. package/src/sap/ui/mdc/p13n/panels/GroupPanel.js +1 -1
  177. package/src/sap/ui/mdc/p13n/panels/GroupView.js +7 -11
  178. package/src/sap/ui/mdc/p13n/panels/ListView.js +5 -3
  179. package/src/sap/ui/mdc/p13n/panels/QueryPanel.js +16 -9
  180. package/src/sap/ui/mdc/p13n/panels/SelectionPanel.js +0 -1
  181. package/src/sap/ui/mdc/p13n/panels/SortPanel.js +0 -1
  182. package/src/sap/ui/mdc/p13n/panels/SortQueryPanel.js +1 -1
  183. package/src/sap/ui/mdc/p13n/panels/Wrapper.js +1 -1
  184. package/src/sap/ui/mdc/p13n/subcontroller/ActionToolbarController.js +89 -0
  185. package/src/sap/ui/mdc/p13n/subcontroller/BaseController.js +9 -6
  186. package/src/sap/ui/mdc/p13n/subcontroller/ChartItemController.js +33 -4
  187. package/src/sap/ui/mdc/p13n/subcontroller/ColumnController.js +9 -15
  188. package/src/sap/ui/mdc/p13n/subcontroller/FilterController.js +12 -0
  189. package/src/sap/ui/mdc/p13n/subcontroller/GroupController.js +5 -12
  190. package/src/sap/ui/mdc/p13n/subcontroller/SortController.js +19 -21
  191. package/src/sap/ui/mdc/table/Column.js +35 -9
  192. package/src/sap/ui/mdc/table/CreationRow.js +1 -1
  193. package/src/sap/ui/mdc/table/GridTableType.js +0 -1
  194. package/src/sap/ui/mdc/table/PropertyHelper.js +108 -5
  195. package/src/sap/ui/mdc/table/ResponsiveTableType.js +19 -3
  196. package/src/sap/ui/mdc/table/RowSettings.js +1 -1
  197. package/src/sap/ui/mdc/table/TableTypeBase.js +0 -1
  198. package/src/sap/ui/mdc/table/V4AnalyticsPropertyHelper.js +1 -1
  199. package/src/sap/ui/mdc/themes/base/FilterBar.less +2 -2
  200. package/src/sap/ui/mdc/themes/base/GroupView.less +2 -2
  201. package/src/sap/ui/mdc/themes/base/ListView.less +2 -2
  202. package/src/sap/ui/mdc/themes/base/ValueHelpDialog.less +56 -21
  203. package/src/sap/ui/mdc/ui/Container.js +2 -2
  204. package/src/sap/ui/mdc/ui/ContainerItem.js +2 -2
  205. package/src/sap/ui/mdc/util/Common.js +26 -0
  206. package/src/sap/ui/mdc/util/FilterUtil.js +12 -1
  207. package/src/sap/ui/mdc/util/IdentifierUtil.js +4 -0
  208. package/src/sap/ui/mdc/util/PromiseCache.js +266 -0
  209. package/src/sap/ui/mdc/util/PropertyHelper.js +22 -1
  210. package/src/sap/ui/mdc/valuehelp/Dialog.js +498 -0
  211. package/src/sap/ui/mdc/valuehelp/Popover.js +362 -0
  212. package/src/sap/ui/mdc/valuehelp/base/Container.js +642 -0
  213. package/src/sap/ui/mdc/valuehelp/base/Content.js +628 -0
  214. package/src/sap/ui/mdc/valuehelp/base/DialogTab.js +139 -0
  215. package/src/sap/ui/mdc/valuehelp/base/FilterableListContent.js +557 -0
  216. package/src/sap/ui/mdc/valuehelp/base/ListContent.js +133 -0
  217. package/src/sap/ui/mdc/valuehelp/content/Bool.js +318 -0
  218. package/src/sap/ui/mdc/valuehelp/content/Conditions.js +276 -0
  219. package/src/sap/ui/mdc/valuehelp/content/FixedList.js +532 -0
  220. package/src/sap/ui/mdc/valuehelp/content/MDCTable.js +638 -0
  221. package/src/sap/ui/mdc/valuehelp/content/MTable.js +916 -0
  222. package/test/sap/ui/mdc/testutils/opa/TestLibrary.js +3 -2
  223. package/test/sap/ui/mdc/testutils/opa/actions/OpenContextMenu.js +48 -0
  224. package/test/sap/ui/mdc/testutils/opa/chartNew/ActionsBase.js +310 -0
  225. package/test/sap/ui/mdc/testutils/opa/chartNew/ActionsViz.js +39 -0
  226. package/test/sap/ui/mdc/testutils/opa/chartNew/AssertionsBase.js +118 -0
  227. package/test/sap/ui/mdc/testutils/opa/chartNew/AssertionsViz.js +137 -0
  228. package/test/sap/ui/mdc/testutils/opa/chartNew/ChartNew.js +24 -0
  229. package/test/sap/ui/mdc/testutils/opa/chartNew/TestObjects.js +289 -0
  230. package/test/sap/ui/mdc/testutils/opa/filterbar/Actions.js +250 -0
  231. package/test/sap/ui/mdc/testutils/opa/filterbar/Assertions.js +91 -0
  232. package/test/sap/ui/mdc/testutils/opa/filterbar/TestObjects.js +137 -0
  233. package/test/sap/ui/mdc/testutils/opa/filterbar/Util.js +25 -0
  234. package/test/sap/ui/mdc/testutils/opa/p13n/Actions.js +401 -93
  235. package/test/sap/ui/mdc/testutils/opa/p13n/Util.js +4 -1
  236. package/test/sap/ui/mdc/testutils/opa/p13n/{waitForP13nButtonWithParentAndIcon.js → waitForP13nButtonWithMatchers.js} +5 -18
  237. package/test/sap/ui/mdc/testutils/opa/table/TestObjects.js +0 -1
@@ -0,0 +1,1171 @@
1
+ /*
2
+ * ! OpenUI5
3
+ * (c) Copyright 2009-2021 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ sap.ui.define([
7
+ "sap/m/p13n/BasePanel",
8
+ "sap/m/Label",
9
+ "sap/m/ColumnListItem",
10
+ "sap/m/Select",
11
+ "sap/m/Text",
12
+ "sap/ui/core/Item",
13
+ "sap/ui/mdc/library",
14
+ "sap/m/Button",
15
+ 'sap/m/Column',
16
+ "sap/m/Table",
17
+ "sap/ui/model/Filter",
18
+ "sap/ui/model/FilterOperator",
19
+ "sap/m/VBox",
20
+ "sap/m/HBox",
21
+ "sap/m/ComboBox",
22
+ "sap/ui/model/Sorter",
23
+ "sap/base/Log",
24
+ "sap/m/library",
25
+ "sap/ui/Device",
26
+ "sap/ui/core/ResizeHandler",
27
+ "sap/ui/core/CustomData"
28
+ ], function (BasePanel, Label, ColumnListItem, Select, Text, Item, MDCLib, Button, Column, Table, Filter, FilterOperator, VBox, HBox, ComboBox, Sorter, Log, mLibrary, Device, ResizeHandler, CustomData) {
29
+ "use strict";
30
+
31
+ // shortcut for sap.m.FlexJustifyContent
32
+ var FlexJustifyContent = mLibrary.FlexJustifyContent;
33
+ var core = sap.ui.getCore();
34
+
35
+ /**
36
+ * Constructor for ChartItemPanel
37
+ *
38
+ * @param {string} [sId] ID for the new control, generated automatically if no ID is given
39
+ * @param {object} [mSettings] initial settings for the new control
40
+ * @class TODO
41
+ * <h3><b>Note:</b></h3>
42
+ * The control is experimental and the API/behaviour is not finalised and hence this should not be used for productive usage.
43
+ * @extends sap.ui.mdc.p13n.panels.BasePanel
44
+ * @author SAP SE
45
+ * @constructor The API/behaviour is not finalised and hence this control should not be used for productive usage.
46
+ * @private
47
+ * @experimental
48
+ * @since 1.97
49
+ * @alias sap.ui.mdc.p13n.panels.ChartItemPanel
50
+ * @ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel
51
+ */
52
+ var ChartItemPanel = BasePanel.extend("sap.ui.mdc.p13n.panels.ChartItemPanelNew", {
53
+ metadata: {
54
+ library: "sap.ui.mdc",
55
+ properties: {
56
+ /*This provides the panel the necessary information to build the UI for MDC/Comp.
57
+ * The object contains the following information:
58
+ * {
59
+ * allowedLayoutOptions : [] -> an array of strings with the allowed layout options for the current chart type, e.g. "axis1", "axis2", "category", "series", ...
60
+ templateConfig : [ -> array containing information how the templating rows should look like
61
+ {kind: "Groupable"}, -> object containing information for which tyoe should be a termplate row created (may contain additional config in the future e.g. only one measure allwoed)
62
+ {kind: "Aggregatable"}
63
+ ]
64
+ * }
65
+ */
66
+ panelConfig: {
67
+ type: "object"
68
+ }
69
+ },
70
+ events: {
71
+ // TODO
72
+ /**
73
+ * Event raised when one or more <code>DimMeasureItems</code> has been updated.
74
+ * Aggregation <code>DimMeasureItems</code> should be updated outside...
75
+ * @since 1.50.0
76
+ */
77
+ changeItems: {}
78
+ }
79
+ },
80
+ init: function () {
81
+
82
+ this._bMobileMode = Device.system.phone;
83
+
84
+ // Initialize the BasePanel
85
+ BasePanel.prototype.init.apply(this, arguments);
86
+
87
+ this._bindListItems();
88
+ this.setEnableReorder(true);
89
+
90
+ },
91
+ renderer: {}
92
+ });
93
+
94
+ ChartItemPanel.prototype._setInnerLayout = function() {
95
+
96
+ this._oInnerControl = new VBox({
97
+ items: [
98
+ this._oListControl
99
+ ]
100
+ });
101
+
102
+ this.setAggregation("_content", this._oInnerControl);
103
+
104
+ this._fnHandleResize = function() {
105
+ //var bChangeResult = false, iScrollContainerHeightOld, iScrollContainerHeightNew;
106
+ if (this.getParent) {
107
+ var $dialogCont = null;
108
+ var oParent = this.getParent();
109
+ if (oParent && oParent.$) {
110
+ $dialogCont = oParent.$("cont");
111
+ if ($dialogCont.children().length > 0) {
112
+ var iScrollContainerWidth = this._oInnerControl.$()[0].clientWidth;
113
+ var iMinWidth = 570;
114
+
115
+ if (!this._bMobileMode && iScrollContainerWidth <= iMinWidth) {
116
+ this._switchMobileMode(true);
117
+ } else if (this._bMobileMode && iScrollContainerWidth > iMinWidth) {
118
+ this._switchMobileMode(false);
119
+ }
120
+
121
+ }
122
+ }
123
+ }
124
+ //return bChangeResult;
125
+ };
126
+
127
+
128
+ if (Device.system.desktop) {
129
+ this._sContainerResizeListener = ResizeHandler.register(this._oInnerControl , this._fnHandleResize.bind(this));
130
+ }
131
+
132
+ };
133
+
134
+ ChartItemPanel.prototype._switchMobileMode = function(bMobile) {
135
+
136
+ if (this._bMobileMode == bMobile) {
137
+ return;
138
+ }
139
+
140
+ this._bMobileMode = bMobile;
141
+
142
+ if (this._sContainerResizeListener) {
143
+ ResizeHandler.deregister(this._sContainerResizeListener);
144
+ this._sContainerResizeListener = null;
145
+ }
146
+
147
+ this._oListControl.destroy();
148
+ this._oDragDropInfo = null;
149
+
150
+ // list is necessary to set the template + model on
151
+ this._oListControl = this._createInnerListControl();
152
+
153
+ // disable 'select all'
154
+ this._oListControl.setMultiSelectMode("ClearAll");
155
+
156
+ this._setInnerLayout();
157
+ this._bindListItems();
158
+
159
+ };
160
+
161
+ ChartItemPanel.prototype._createInnerListControl = function() {
162
+
163
+ var sId = this._bMobileMode ? this.getId() + "-innerP13nListMobile" : this.getId() + "-innerP13nList";
164
+
165
+ var oTable = new Table(sId, Object.assign(this._getListControlConfig(), {}));
166
+
167
+ oTable.addEventDelegate({
168
+ onAfterRendering: this._checkFocusAfterTableRerender.bind(this)
169
+ });
170
+
171
+ return oTable;
172
+ };
173
+
174
+ ChartItemPanel.prototype._checkFocusAfterTableRerender = function(){
175
+
176
+ if (this._oFocusInfo && this._oFocusInfo.tableItem){
177
+ //Focus table item directly
178
+ this._oFocusInfo.tableItem.focus();
179
+ }
180
+
181
+ //Reset focus info
182
+ this._oFocusInfo = null;
183
+ };
184
+
185
+ ChartItemPanel.prototype._bindListItems = function(mBindingInfo) {
186
+ var oSorter;
187
+ var MDCRb = sap.ui.getCore().getLibraryResourceBundle("sap.ui.mdc");
188
+
189
+ if ( this.getPanelConfig() && this.getPanelConfig().sorter) {
190
+ oSorter = this.getPanelConfig().sorter;
191
+ } else {
192
+
193
+ var oMeasuresGroup = { text: MDCRb.getText('chart.PERSONALIZATION_DIALOG_MEASURE_GROUP_HEADER')};
194
+ var oDimensionsGroup = { text: MDCRb.getText('chart.PERSONALIZATION_DIALOG_DIMENSION_GROUP_HEADER')};
195
+
196
+ var mGroupInfo = {
197
+ "Aggregatable": oMeasuresGroup,
198
+ "Groupable" : oDimensionsGroup,
199
+ "Measure": oMeasuresGroup,
200
+ "Dimension" : oDimensionsGroup
201
+ };
202
+
203
+ var fGrouper = function(oContext) {
204
+ var group = oContext.getProperty("kind");
205
+ return { key: group, text: mGroupInfo[group].text };
206
+ };
207
+
208
+ var fSorter = function(a,b) {
209
+ if (a === b) {
210
+ return 0;
211
+ }
212
+
213
+ if (a === "MEASURE" || a === "AGGREGATABLE"){
214
+ return 1;
215
+ }
216
+
217
+ return -1;
218
+ };
219
+
220
+ oSorter = new Sorter("kind", false, fGrouper, fSorter);
221
+ }
222
+
223
+
224
+ var oFactoryFunction;
225
+ this._mTemplatesMap = new Map();
226
+ if (this._bMobileMode) {
227
+ oFactoryFunction = this._createListItemMobile;
228
+ } else {
229
+ oFactoryFunction = this._createListItem;
230
+ }
231
+
232
+ this._oListControl.bindItems(Object.assign({
233
+ path: this.P13N_MODEL + ">/items",
234
+ key: "name", //TODO: Bind with combined key (name + kind)?
235
+ filters: [new Filter({
236
+ filters: [
237
+ new Filter("visible", FilterOperator.EQ, true),
238
+ new Filter("template", FilterOperator.EQ, true)
239
+ ],
240
+ and: false
241
+ })],
242
+ factory: oFactoryFunction.bind(this),
243
+ sorter : oSorter
244
+ }, mBindingInfo));
245
+ };
246
+
247
+ ChartItemPanel.prototype._getTemplateComboBox = function(sKind){
248
+ var oVisibleFilter = new Filter("visible", FilterOperator.EQ, false);
249
+
250
+ var oComboBox = new ComboBox({
251
+ id: "p13nPanel-templateComboBox-" + sKind,
252
+ width: "100%",
253
+ placeholder: this._getPlaceholderTextForKind(sKind),
254
+ items: {
255
+ path: this.P13N_MODEL + ">/items",
256
+ template: new Item({
257
+ key: "{" + this.P13N_MODEL + ">name}",
258
+ text: "{" + this.P13N_MODEL + ">label}"
259
+ }),
260
+ templateShareable : false,
261
+ filters: [oVisibleFilter, new Filter("kind", FilterOperator.EQ, sKind)]
262
+ },
263
+ change: [this.onChangeOfTemplateName, this]
264
+ });
265
+
266
+ this._mTemplatesMap.set(sKind, oComboBox);
267
+
268
+ return oComboBox;
269
+ };
270
+
271
+ ChartItemPanel.prototype._getPlaceholderTextForKind = function(sKind) {
272
+ var MDCRb = sap.ui.getCore().getLibraryResourceBundle("sap.ui.mdc");
273
+ var sPlaceholderMeasure = MDCRb.getText('chart.PERSONALIZATION_DIALOG_TEMPLATE_MEASURE');
274
+ var sPlaceholderDimension = MDCRb.getText('chart.PERSONALIZATION_DIALOG_TEMPLATE_DIMENSION');
275
+
276
+ var mPlaceholderTexts = {
277
+ "Aggregatable": sPlaceholderMeasure,
278
+ "Groupable" : sPlaceholderDimension,
279
+ "Measure": sPlaceholderMeasure,
280
+ "Dimension" : sPlaceholderDimension
281
+ };
282
+
283
+ return mPlaceholderTexts[sKind];
284
+ };
285
+
286
+ ChartItemPanel.prototype._getRoleSelect = function() {
287
+ return new Select({
288
+ width: "100%",
289
+ selectedKey: "{" + this.P13N_MODEL + ">role}",
290
+ change: [this.onChangeOfRole, this],
291
+ forceSelection: false,
292
+ items: {
293
+ path: this.P13N_MODEL + ">availableRoles",
294
+ templateShareable: false,
295
+ template: new Item({
296
+ key: "{" + this.P13N_MODEL + ">key}",
297
+ text: "{" + this.P13N_MODEL + ">text}"
298
+ })
299
+ },
300
+ visible: {
301
+ path: this.P13N_MODEL + ">availableRoles",
302
+ formatter: function(aRoles) {
303
+
304
+ if (!aRoles) {
305
+ return false;
306
+ }
307
+
308
+ return aRoles.length > 1;
309
+ }
310
+ }
311
+ });
312
+ };
313
+
314
+ ChartItemPanel.prototype._getNameComboBox = function(sKind, sName) {
315
+ var oNameFilterPersistent = new Filter({
316
+ filters: [
317
+ new Filter("visible", FilterOperator.EQ, false),
318
+ new Filter("name", FilterOperator.EQ, sName)
319
+ ],
320
+ and: false
321
+ });
322
+
323
+ return new ComboBox({
324
+ width: "100%",
325
+ items: {
326
+ path: this.P13N_MODEL + ">/items",
327
+ template: new Item({
328
+ key: "{" + this.P13N_MODEL + ">name}",
329
+ text: "{" + this.P13N_MODEL + ">label}"
330
+ }),
331
+ templateShareable : false,
332
+ filters: [oNameFilterPersistent, new Filter("kind", FilterOperator.EQ, sKind)]
333
+ },
334
+ change: [this.onChangeOfItemName, this],
335
+ selectedKey: "{" + this.P13N_MODEL + ">tempName}",
336
+ customData: [new CustomData({key: "prevName", value: sName}),
337
+ new CustomData({key: "prevKind", value: sKind})]
338
+ });
339
+ };
340
+
341
+ ChartItemPanel.prototype._createListItem = function(sId, oObject){
342
+
343
+ var sRemoveBtnId, aCells = [];
344
+
345
+
346
+ if (oObject.getObject() && oObject.getObject().template){
347
+ aCells.push(this._getTemplateComboBox(oObject.getObject().kind));
348
+ } else {
349
+ aCells.push(this._getNameComboBox(oObject.getObject().kind, oObject.getObject().name));
350
+ aCells.push(this._getRoleSelect());
351
+ sRemoveBtnId = oObject.getObject().kind + "-RemoveBtn-" + oObject.getObject().name;
352
+
353
+ aCells.push(new HBox({
354
+ justifyContent: FlexJustifyContent.End,
355
+ items: [
356
+ new Button({
357
+ id: sRemoveBtnId,
358
+ press: [this._onPressHide, this],
359
+ type: "Transparent", icon: "sap-icon://decline",
360
+ customData: [new CustomData({key: "propertyName", value: "{" + this.P13N_MODEL + ">name}"}),
361
+ new CustomData({key: "propertyKind", value: "{" + this.P13N_MODEL + ">kind}"})]
362
+ })
363
+ ]}));
364
+ }
365
+
366
+ var oListItem;
367
+ if (oObject.getObject() && oObject.getObject().template) {
368
+ var sKind = oObject.getObject().kind;
369
+ oListItem = new ColumnListItem({
370
+ cells: aCells,
371
+ visible: {
372
+ path: this.P13N_MODEL + ">/items",
373
+ formatter: function(aItems){
374
+ aItems = aItems.filter(function(oItem){return oItem.visible === false && oItem.template === false && oItem.kind === sKind;});
375
+ return aItems.length != 0;
376
+ }
377
+ }
378
+ });
379
+ } else {
380
+ oListItem = new ColumnListItem({
381
+ cells: aCells
382
+ });
383
+ }
384
+
385
+ oListItem.addEventDelegate({
386
+ onmouseover: this._hoverHandler.bind(this),
387
+ onfocusin: this._focusHandler.bind(this),
388
+ onkeydown: this._handleOnKeyDown.bind(this)
389
+ });
390
+
391
+ return oListItem;
392
+ };
393
+
394
+ ChartItemPanel.prototype._createListItemMobile = function(sId, oObject){
395
+
396
+ var sRemoveBtnId, aCells = [];
397
+
398
+ if (oObject.getObject() && oObject.getObject().template){
399
+ aCells.push(this._getTemplateComboBox(oObject.getObject().kind));
400
+ } else {
401
+
402
+ var oVBox = new VBox({
403
+ items: [
404
+ this._getNameComboBox(oObject.getObject().kind, oObject.getObject().name),
405
+ this._getRoleSelect()
406
+ ]
407
+ });
408
+
409
+ sRemoveBtnId = oObject.getObject().kind + "-RemoveBtn-" + oObject.getObject().name;
410
+ aCells.push(oVBox);
411
+
412
+ }
413
+
414
+ var oRemoveColumn = new HBox({
415
+ justifyContent: FlexJustifyContent.End,
416
+ items: [new Button({
417
+ id: sRemoveBtnId,
418
+ press: [this._onPressHide, this],
419
+ type: "Transparent", icon: "sap-icon://decline",
420
+ visible: {
421
+ path: this.P13N_MODEL + ">template",
422
+ formatter: function(bEnabled) {
423
+ return !bEnabled;
424
+ }
425
+ },
426
+ customData: [new CustomData({key: "propertyName", value: "{" + this.P13N_MODEL + ">name}"}),
427
+ new CustomData({key: "propertyKind", value: "{" + this.P13N_MODEL + ">kind}"})]
428
+ })]});
429
+
430
+ aCells.push(oRemoveColumn);
431
+
432
+
433
+ var oListItem;
434
+ if (oObject.getObject() && oObject.getObject().template) {
435
+ var sKind = oObject.getObject().kind;
436
+ oListItem = new ColumnListItem({
437
+ cells: aCells,
438
+ visible: {
439
+ path: this.P13N_MODEL + ">/items",
440
+ formatter: function(aItems){
441
+ aItems = aItems.filter(function(oItem){return oItem.visible === false && oItem.template === false && oItem.kind === sKind;});
442
+ return aItems.length != 0;
443
+ }
444
+ }
445
+ });
446
+ } else {
447
+ oListItem = new ColumnListItem({
448
+ cells: aCells
449
+ });
450
+ }
451
+
452
+ oListItem.addEventDelegate({
453
+ onmouseover: this._hoverHandler.bind(this),
454
+ onfocusin: this._focusHandler.bind(this),
455
+ onkeydown: this._handleOnKeyDown.bind(this)
456
+ });
457
+
458
+ return oListItem;
459
+ };
460
+
461
+ //ACC realted stuff
462
+ ChartItemPanel.prototype._handleOnKeyDown = function(oEvent){
463
+ if (oEvent.keyCode === 38 && oEvent.ctrlKey){
464
+ //Ctrl+Arrow Up
465
+ //Move Up
466
+ //Disabled for now until further clarification
467
+ /*
468
+ if (this._oMoveUpButton && this._oMoveUpButton.getEnabled() && this._getMoveButtonContainer()){
469
+ this._onPressButtonMoveUp(oEvent, core.byId(oEvent.currentTarget.id));
470
+ }*/
471
+ } else if (oEvent.keyCode === 40 && oEvent.ctrlKey){
472
+ //Ctrl+Arrow Down
473
+ //Move Down
474
+ //Disabled for now until further clarification
475
+ /*
476
+ if (this._oMoveUpButton && this._oMoveDownButton.getEnabled() && this._getMoveButtonContainer()){
477
+ this._onPressButtonMoveDown(oEvent, core.byId(oEvent.currentTarget.id));
478
+ }*/
479
+ } else if (oEvent.keyCode === 68 && oEvent.ctrlKey){
480
+ //Ctrl+D
481
+ //Remove
482
+ var oRemoveBtn, oListItem = core.byId(oEvent.currentTarget.id);
483
+
484
+ if (this._bMobileMode) {
485
+ oRemoveBtn = oListItem.getCells()[1].getItems()[oListItem.getCells()[1].getItems().length - 1];
486
+ } else {
487
+ oRemoveBtn = oListItem.getCells()[2].getItems()[oListItem.getCells()[2].getItems().length - 1];
488
+ }
489
+
490
+ if (oRemoveBtn){
491
+ this._onPressHide(oEvent, oRemoveBtn);
492
+ oEvent.preventDefault();
493
+ }
494
+
495
+ }
496
+
497
+ };
498
+
499
+ ChartItemPanel.prototype._handleActivated = function(oHoveredItem) {
500
+ var oItem = this._getModelItemByTableItem(oHoveredItem);
501
+ if (oItem && oItem.template) {
502
+ this.removeMoveButtons();
503
+ }
504
+
505
+ this._oHoveredItem = oHoveredItem;
506
+ this._updateEnableOfMoveButtons(oHoveredItem, false);
507
+ this._addMoveButtons(oHoveredItem);
508
+ this._setMoveButtonVisibility(true);
509
+
510
+ };
511
+
512
+ ChartItemPanel.prototype.onChangeOfItemName = function(oEvent) {
513
+ var sPrevName = oEvent.getSource().data().prevName;
514
+ var sKind = oEvent.getSource().data().prevKind; //Can only select fields within same kind
515
+ var sNewName = oEvent.getSource().getSelectedKey();
516
+
517
+ var oPrevItem = this._getP13nModel().getProperty("/items").find(function(it){ return it.name === sPrevName && it.kind === sKind;});
518
+ var oNewItem = this._getP13nModel().getProperty("/items").find(function(it){ return it.name === sNewName && it.kind === sKind;});
519
+
520
+ this.removeMoveButtons();
521
+
522
+ if (oPrevItem && oNewItem) {
523
+
524
+ oPrevItem.visible = false;
525
+ oNewItem.visible = true;
526
+
527
+ oPrevItem.tempName = oPrevItem.name;
528
+
529
+ oNewItem.role = oPrevItem.role;
530
+ this._moveItemsByIndex(this._getItemIndex(oNewItem), this._getItemIndex(oPrevItem));
531
+
532
+ this._getP13nModel().refresh(true);
533
+
534
+ this._fireChangeItems();
535
+ }
536
+
537
+ };
538
+
539
+ ChartItemPanel.prototype._getItemIndexByNameAndKind = function(sName, sKind) {
540
+ var aFields = this._getP13nModel().getProperty("/items");
541
+ var oField = aFields.find(function(it){return (it.name === sName && it.kind === sKind && !it.template);});
542
+
543
+ return this._getItemIndex(oField);
544
+ };
545
+
546
+ ChartItemPanel.prototype._getItemIndex = function(oItem) {
547
+ return this._getP13nModel().getProperty("/items").indexOf(oItem);
548
+ };
549
+
550
+ ChartItemPanel.prototype.removeMoveButtons = function() {
551
+ var oMoveButtonBox = this._getMoveButtonContainer();
552
+
553
+ if (oMoveButtonBox){
554
+ oMoveButtonBox.removeItem(this._getMoveBottomButton());
555
+ oMoveButtonBox.removeItem(this._getMoveDownButton());
556
+ oMoveButtonBox.removeItem(this._getMoveUpButton());
557
+ oMoveButtonBox.removeItem(this._getMoveTopButton());
558
+ }
559
+
560
+ };
561
+
562
+ //Called on exit of panel; resets templates
563
+ ChartItemPanel.prototype.getP13nState = function() {
564
+
565
+ var aItems = this._getCleanP13nItems();
566
+
567
+ this._getP13nModel().setProperty("/items", aItems);
568
+
569
+ return aItems;
570
+ };
571
+
572
+ ChartItemPanel.prototype._getMoveButtonContainer = function() {
573
+ if (this._oMoveUpButton &&
574
+ this._oMoveUpButton.getParent() &&
575
+ this._oMoveUpButton.getParent().isA("sap.m.FlexBox")
576
+ ){
577
+ return this._oMoveUpButton.getParent();
578
+ }
579
+
580
+ return undefined;
581
+ };
582
+
583
+ ChartItemPanel.prototype._addMoveButtons = function(oItem) {
584
+ var oTableItem = oItem;
585
+ if (!oTableItem){
586
+ return;
587
+ }
588
+
589
+ var bIgnore = this._getP13nModel().getProperty(oTableItem.getBindingContextPath()) ? this._getP13nModel().getProperty(oTableItem.getBindingContextPath()).template : true;
590
+
591
+ if (!bIgnore){
592
+ if (this._bMobileMode){
593
+ oTableItem.getCells()[1].insertItem(this._getMoveDownButton(), 0);
594
+ oTableItem.getCells()[1].insertItem(this._getMoveUpButton(), 0);
595
+ } else {
596
+ oTableItem.getCells()[2].insertItem(this._getMoveBottomButton(), 0);
597
+ oTableItem.getCells()[2].insertItem(this._getMoveDownButton(), 0);
598
+ oTableItem.getCells()[2].insertItem(this._getMoveUpButton(), 0);
599
+ oTableItem.getCells()[2].insertItem(this._getMoveTopButton(), 0);
600
+ }
601
+
602
+ }
603
+ };
604
+
605
+ ChartItemPanel.prototype._moveSelectedItem = function(){
606
+ this._oSelectedItem = this._getMoveButtonContainer().getParent();
607
+
608
+ BasePanel.prototype._moveSelectedItem.apply(this, arguments);
609
+ };
610
+
611
+
612
+ ChartItemPanel.prototype._updateAvailableRolesForItems = function() {
613
+ var aItems = this._getP13nModel().getProperty("/items");
614
+ var aAllowedRoles = [];
615
+ if (this.getPanelConfig() && this.getPanelConfig().allowedLayoutOptions) {
616
+ aAllowedRoles = this.getPanelConfig().allowedLayoutOptions;
617
+ } else {
618
+ Log.warning("No allowedLayoutOptions configured for chart type. This will not show any p13n options!");
619
+ }
620
+
621
+
622
+ aItems.forEach(function(oItem){
623
+
624
+ if (!oItem.availableRoles) {
625
+ return;
626
+ }
627
+
628
+ oItem.availableRoles = oItem.availableRoles.filter(function(it){return aAllowedRoles.indexOf(it.key) != -1;});
629
+ });
630
+
631
+ this._getP13nModel().setProperty("/items", aItems);
632
+ this._getP13nModel().refresh(true);
633
+ };
634
+
635
+ ChartItemPanel.prototype._onPressHide = function(oEvent, oRemoveBtn) {
636
+
637
+ var sPropertyName;
638
+ if (oRemoveBtn) {
639
+ sPropertyName = oRemoveBtn.data().propertyName;
640
+ } else {
641
+ sPropertyName = oEvent.getSource().data().propertyName;
642
+ }
643
+
644
+ var aItems = jQuery.extend([], this._getP13nModel().getProperty("/items"), true);
645
+
646
+ aItems.filter(function(it){return it.name === sPropertyName;}).forEach(function(oItem){
647
+ oItem.visible = false;
648
+ //Used to set focus on template row after re-render of table
649
+ if (this._mTemplatesMap.has(oItem.kind) && this._mTemplatesMap.get(oItem.kind).getVisible()){
650
+ this._mTemplatesMap.get(oItem.kind).focus();
651
+ }
652
+ }.bind(this));
653
+
654
+ this._getP13nModel().setProperty("/items", aItems);
655
+ this._getP13nModel().refresh(true);
656
+ this._fireChangeItems();
657
+ this._updateVisibleIndexes();
658
+ };
659
+
660
+ ChartItemPanel.prototype.setP13nData = function(aP13nData){
661
+
662
+ //Clear previous templates (if any)
663
+ aP13nData = aP13nData.filter(function(it){return !it.template;});
664
+
665
+ BasePanel.prototype.setP13nData.apply(this, arguments);
666
+
667
+ var aItems = [];
668
+ var aAddableItems = [];
669
+
670
+ this.getP13nData().forEach(function(oItem, iIndex){
671
+ if (!oItem.availableRoles) {
672
+ oItem.availableRoles = this._getChartItemTextByKey(oItem.kind);
673
+ }
674
+
675
+ if (this.getPanelConfig() && this.getPanelConfig().allowedLayoutOptions) {
676
+ var aAllowedRoles = this.getPanelConfig().allowedLayoutOptions;
677
+
678
+ if (aAllowedRoles && aAllowedRoles.length >= 1) {
679
+ oItem.availableRoles = oItem.availableRoles.filter(function(it){return aAllowedRoles.indexOf(it.key) != -1;});
680
+
681
+ //Reset if an invalid role is selected
682
+ if (aAllowedRoles.indexOf(oItem.role) === -1) {
683
+ oItem.role = aAllowedRoles[0];
684
+ }
685
+ }
686
+ }
687
+
688
+ oItem.template = false;
689
+ //Used for comboboxes renaming
690
+ oItem.tempName = oItem.name;
691
+
692
+ if (!oItem.visible){
693
+ aAddableItems.push(oItem);
694
+ }
695
+
696
+ if (!oItem.index) {
697
+ oItem.index = iIndex;
698
+ }
699
+
700
+ aItems.push(oItem);
701
+ }.bind(this));
702
+
703
+ aItems = aItems.concat(this._getTemplateItems());
704
+
705
+ this._getP13nModel().setProperty("/items", aItems);
706
+ this._updateVisibleIndexes();
707
+ };
708
+
709
+ ChartItemPanel.prototype._updateVisibleIndexes = function() {
710
+ this._mVisibleIndexes = new Map();
711
+
712
+ this._getP13nModel().getProperty("/items").forEach(function(oItem, _iIndex){
713
+
714
+ if (oItem.template || !oItem.visible) {
715
+ return;
716
+ }
717
+
718
+ if (this._mVisibleIndexes.has(oItem.kind)){
719
+ this._mVisibleIndexes.get(oItem.kind).push(_iIndex);
720
+ } else {
721
+ var aIndexes = [_iIndex];
722
+ this._mVisibleIndexes.set(oItem.kind, aIndexes);
723
+ }
724
+ }.bind(this));
725
+
726
+ };
727
+
728
+ ChartItemPanel.prototype.onChangeOfTemplateName = function(oEvent){
729
+
730
+ var sSelectedName = oEvent.getSource().getSelectedKey();
731
+
732
+ var oSelectedItem = this._getCleanP13nItems().find(function(it){ return it.name === sSelectedName;});
733
+
734
+ if (oSelectedItem){
735
+ oSelectedItem.visible = true;
736
+
737
+ oEvent.getSource().setSelectedKey(undefined);
738
+ this._getP13nModel().refresh(true);
739
+
740
+ var aIndexes = this._mVisibleIndexes.has(oSelectedItem.kind) ? this._mVisibleIndexes.get(oSelectedItem.kind) : [];
741
+ var iOldIndex = this._getItemIndexByNameAndKind(oSelectedItem.name, oSelectedItem.kind);
742
+ var iNewIndex = aIndexes[aIndexes.length - 1];
743
+
744
+ if (iOldIndex > iNewIndex) {
745
+ iNewIndex += 1;
746
+ }
747
+
748
+ if (iNewIndex) {
749
+ this._moveItemsByIndex(iOldIndex, iNewIndex, true);
750
+ } else {
751
+ this._fireChangeItems(); //Otherwise already fired by _moveItemsByIndex
752
+ }
753
+
754
+
755
+ this._updateVisibleIndexes();
756
+ } else {
757
+ oEvent.getSource().setSelectedKey(undefined);
758
+ }
759
+
760
+ };
761
+
762
+ ChartItemPanel.prototype._getTemplateItems = function() {
763
+ var aItems = [];
764
+
765
+ if (!this.getPanelConfig() || !this.getPanelConfig().templateConfig){
766
+ return [];
767
+ }
768
+
769
+ this.getPanelConfig().templateConfig.forEach(function(oTemplateConfig){
770
+ var oItem = {template: true, kind: oTemplateConfig.kind};
771
+
772
+ aItems.push(oItem);
773
+ });
774
+
775
+ return aItems;
776
+ };
777
+
778
+ ChartItemPanel.prototype._getListControlConfig = function(){
779
+ var oConfig = BasePanel.prototype._getListControlConfig.apply(this, arguments);
780
+
781
+ if (this._bMobileMode){
782
+ oConfig.columns = [new Column({
783
+ header: new Text({
784
+ text: this._getResourceTextMDC("chart.PERSONALIZATION_DIALOG_COLUMN_DESCRIPTION") + " / " + this._getResourceTextMDC("chart.PERSONALIZATION_DIALOG_COLUMN_TYPE")
785
+ })
786
+ }), new Column()];
787
+ } else {
788
+
789
+ var oDescColumn = new Column({
790
+ header: new Text({
791
+ text: this._getResourceTextMDC("chart.PERSONALIZATION_DIALOG_COLUMN_DESCRIPTION")
792
+ })
793
+ });
794
+
795
+ var oRoleColumn = new Column({
796
+ header: new Text({
797
+ text: this._getResourceTextMDC("chart.PERSONALIZATION_DIALOG_COLUMN_TYPE")
798
+ })
799
+ });
800
+ oConfig.columns = [oDescColumn, oRoleColumn, new Column()];
801
+ }
802
+
803
+ oConfig.mode = "None";
804
+ return oConfig;
805
+ };
806
+
807
+ ChartItemPanel.prototype._getCleanP13nItems = function() {
808
+ return this._getP13nModel().getProperty("/items").filter(function(it){return !it.template;});
809
+ };
810
+
811
+ ChartItemPanel.prototype._fireChangeItems = function() {
812
+
813
+ this.fireChangeItems({
814
+ items: this._getCleanP13nItems().map(function(oMItem) {
815
+ return {
816
+ columnKey: oMItem.name,
817
+ visible: oMItem.visible,
818
+ index: oMItem.index,
819
+ role: oMItem.role
820
+ };
821
+ })
822
+ });
823
+
824
+ };
825
+
826
+ ChartItemPanel.prototype.onChangeOfRole = function (oEvent) {
827
+ var oSelectedItem = oEvent.getParameter("selectedItem");
828
+ // Fire event only for valid selection
829
+ if (oSelectedItem) {
830
+
831
+ var oTableItem;
832
+
833
+ if (this._bMobileMode){
834
+ oTableItem = oEvent.getSource().getParent().getParent();
835
+ } else {
836
+ oTableItem = oEvent.getSource().getParent();
837
+ }
838
+
839
+ this.fireChange();
840
+ this._updateEnableOfMoveButtons(oTableItem);
841
+ }
842
+
843
+ this._fireChangeItems();
844
+ };
845
+
846
+ ChartItemPanel.prototype._updateEnableOfMoveButtons = function(oTableItem, bFocus) {
847
+
848
+ if (!oTableItem) {
849
+ return;
850
+ }
851
+
852
+ var aIndexes, oMItem = this._getModelItemByTableItem(oTableItem);
853
+ var iTableItemPos = this._getP13nModel().getProperty("/items").indexOf(oMItem);
854
+ var bUpEnabled = true, bDownEnabled = true;
855
+
856
+ if (!oMItem || oMItem.template) {
857
+ return;
858
+ }
859
+
860
+ aIndexes = this._mVisibleIndexes.has(oMItem.kind) ? this._mVisibleIndexes.get(oMItem.kind) : [];
861
+
862
+ if (iTableItemPos == 0 || aIndexes.indexOf(iTableItemPos) === 0 ) {
863
+ // disable move buttons upwards, if the item is at the top
864
+ bUpEnabled = false;
865
+ }
866
+
867
+ if (aIndexes.indexOf(iTableItemPos) === aIndexes.length - 1 ) {
868
+ bDownEnabled = false;
869
+ }
870
+
871
+ this._getMoveTopButton().setEnabled(bUpEnabled);
872
+ this._getMoveUpButton().setEnabled(bUpEnabled);
873
+ this._getMoveDownButton().setEnabled(bDownEnabled);
874
+ this._getMoveBottomButton().setEnabled(bDownEnabled);
875
+
876
+ if (bFocus) {
877
+ //Table re-renders after reorder; this is used in onAfterRendering
878
+ this._oFocusInfo = {tableItem : oTableItem};
879
+ }
880
+ };
881
+
882
+ ChartItemPanel.prototype._getListItemFromMoveButton = function (oBtn) {
883
+ if (oBtn && oBtn.getParent() && oBtn.getParent().getParent()) {
884
+ return oBtn.getParent().getParent();
885
+ }
886
+
887
+ return undefined;
888
+ };
889
+
890
+ ChartItemPanel.prototype._onPressButtonMoveToTop = function(oEvent) {
891
+ var oListItem = this._getListItemFromMoveButton(oEvent.getSource());
892
+ if (!oListItem){
893
+ return;
894
+ }
895
+ var oMItem = this._getP13nModel().getProperty(oListItem.getBindingContextPath());
896
+ var oTopIndex = this._mVisibleIndexes.get(oMItem.kind)[0];
897
+
898
+ this._oSelectedItem = oListItem;
899
+
900
+ this._moveSelectedItem(oTopIndex);
901
+ };
902
+
903
+ ChartItemPanel.prototype._onPressButtonMoveUp = function(oEvent, oListItem) {
904
+ if (!oListItem){
905
+ oListItem = this._getListItemFromMoveButton(oEvent.getSource());
906
+ }
907
+
908
+ if (!oListItem){
909
+ return;
910
+ }
911
+ var oMItem = this._getP13nModel().getProperty(oListItem.getBindingContextPath());
912
+ var aIndexes = this._mVisibleIndexes.get(oMItem.kind);
913
+ var iTableItemPos = this._getP13nModel().getProperty("/items").indexOf(oMItem);
914
+
915
+ this._oSelectedItem = oListItem;
916
+
917
+ //TODO: Get current index
918
+ var oNewIndex = aIndexes[aIndexes.indexOf(iTableItemPos) - 1];
919
+
920
+ this._moveSelectedItem(oNewIndex);
921
+ };
922
+
923
+ ChartItemPanel.prototype._onPressButtonMoveDown = function(oEvent, oListItem) {
924
+ if (!oListItem){
925
+ oListItem = this._getListItemFromMoveButton(oEvent.getSource());
926
+ }
927
+
928
+ if (!oListItem){
929
+ return;
930
+ }
931
+ var oMItem = this._getP13nModel().getProperty(oListItem.getBindingContextPath());
932
+ var aIndexes = this._mVisibleIndexes.get(oMItem.kind);
933
+ var iTableItemPos = this._getP13nModel().getProperty("/items").indexOf(oMItem);
934
+
935
+ this._oSelectedItem = oListItem;
936
+
937
+ //TODO: Get current index
938
+ var oNewIndex = aIndexes[aIndexes.indexOf(iTableItemPos) + 1];
939
+
940
+ this._moveSelectedItem(oNewIndex);
941
+ };
942
+
943
+ ChartItemPanel.prototype._onPressButtonMoveToBottom = function(oEvent) {
944
+
945
+ var oListItem = this._getListItemFromMoveButton(oEvent.getSource());
946
+ if (!oListItem){
947
+ return;
948
+ }
949
+ var oMItem = this._getP13nModel().getProperty(oListItem.getBindingContextPath());
950
+ var oBottomIndex = this._mVisibleIndexes.get(oMItem.kind)[this._mVisibleIndexes.get(oMItem.kind).length - 1];
951
+
952
+ this._oSelectedItem = oListItem;
953
+ this._moveSelectedItem(oBottomIndex);
954
+ };
955
+
956
+ ChartItemPanel.prototype._moveTableItem = function(oItem, iNewIndex) {
957
+ var aFields = this._getP13nModel().getProperty("/items");
958
+
959
+ // index of the item in the model not the index in the aggregation
960
+ var iOldIndex = aFields.indexOf(oItem.getBindingContext(this.P13N_MODEL).getObject());
961
+
962
+ this._moveItemsByIndex(iOldIndex, iNewIndex);
963
+ };
964
+
965
+ ChartItemPanel.prototype._moveItemsByIndex = function(iOldIndex, iNewIndex, bPreventFocusHandling) {
966
+ var aFields = this._getP13nModel().getProperty("/items");
967
+
968
+ // limit the minumum and maximum index
969
+ iNewIndex = (iNewIndex <= 0) ? 0 : Math.min(iNewIndex, aFields.length - 1);
970
+
971
+ if (iNewIndex == iOldIndex) {
972
+ return;
973
+ }
974
+
975
+ // remove data from old position and insert it into new position
976
+ aFields.splice(iNewIndex, 0, aFields.splice(iOldIndex, 1)[0]);
977
+ aFields.forEach(function(oField, iIndex){
978
+ if (!oField.template) {
979
+ oField.index = iIndex;
980
+ }
981
+ });
982
+ this._getP13nModel().setProperty("/items", aFields);
983
+
984
+ // store the moved item again due to binding
985
+ this._oSelectedItem = this._oListControl.getItems().find(function(it){
986
+ var oItem = this._getModelItemByTableItem(it);
987
+
988
+ return oItem && oItem === aFields[iNewIndex];
989
+
990
+ }.bind(this));
991
+
992
+ this._updateEnableOfMoveButtons(this._oSelectedItem, !bPreventFocusHandling);
993
+
994
+ this._handleActivated(this._oSelectedItem);
995
+
996
+ this._fireChangeItems();
997
+ };
998
+
999
+ ChartItemPanel.prototype._getModelItemByTableItem = function (oTableItem) {
1000
+ return this._getP13nModel().getProperty(oTableItem.getBindingContextPath());
1001
+ };
1002
+ //TODO: Check from here on for kind
1003
+
1004
+ ChartItemPanel.prototype._getMoveConfigForTableItem = function(oTableItem) {
1005
+
1006
+ var oModelItem = this._getModelItemByTableItem(oTableItem);
1007
+
1008
+ if (!oModelItem) {
1009
+ return undefined;
1010
+ }
1011
+
1012
+ return {
1013
+ currentIndex: this._getP13nModel().getProperty("/items").indexOf(oModelItem),
1014
+ aggregationRole: oModelItem.kind,
1015
+ template: oModelItem.template
1016
+ };
1017
+ };
1018
+
1019
+ ChartItemPanel.prototype._getDragDropConfig = function () {
1020
+ var oDndConfig = BasePanel.prototype._getDragDropConfig.apply(this, arguments);
1021
+
1022
+ oDndConfig.attachDragStart(this._checkDragStart.bind(this));
1023
+ oDndConfig.attachDragEnter(this._checkDrag.bind(this));
1024
+ oDndConfig.attachDragEnd(function() {
1025
+ this._oDraggedItem = null;
1026
+ }.bind(this));
1027
+
1028
+ return oDndConfig;
1029
+ };
1030
+
1031
+ ChartItemPanel.prototype._checkDrag = function(oEvent) {
1032
+ var oEventItem = oEvent.getParameter("target");
1033
+ var oMoveConfigEvent = this._getMoveConfigForTableItem(oEventItem);
1034
+ var oMoveConfigDragged = this._getMoveConfigForTableItem(this._oDraggedItem);
1035
+
1036
+ //Prevents template from being draggable
1037
+ if (!oMoveConfigEvent || oMoveConfigEvent.template || oMoveConfigDragged.aggregationRole != oMoveConfigEvent.aggregationRole) {
1038
+ oEvent.preventDefault();
1039
+ return;
1040
+ }
1041
+ };
1042
+
1043
+ ChartItemPanel.prototype._checkDragStart = function(oEvent) {
1044
+ this._oDraggedItem = oEvent.getParameter("target");
1045
+
1046
+ this._checkDrag(oEvent);
1047
+ };
1048
+
1049
+ ChartItemPanel.prototype._onRearrange = function(oEvent) {
1050
+ var oDraggedItem = oEvent.getParameter("draggedControl");
1051
+ var oDroppedItem = oEvent.getParameter("droppedControl");
1052
+ var sDropPosition = oEvent.getParameter("dropPosition");
1053
+
1054
+ var oMoveConfigDragged = this._getMoveConfigForTableItem(oDraggedItem);
1055
+ var oMoveConfigDropped = this._getMoveConfigForTableItem(oDroppedItem);
1056
+
1057
+ if (!oMoveConfigDragged || oMoveConfigDragged.template || !oMoveConfigDropped) {
1058
+ oEvent.preventDefault();
1059
+ return;
1060
+ }
1061
+
1062
+ var iDraggedIndex = oMoveConfigDragged.currentIndex;
1063
+ var iDroppedIndex = oMoveConfigDropped.currentIndex;
1064
+
1065
+ if (oMoveConfigDropped.template && sDropPosition == "After") {
1066
+ oEvent.preventDefault();
1067
+ return;
1068
+ }
1069
+
1070
+ if (!oMoveConfigDropped.template &&
1071
+ (
1072
+ oMoveConfigDragged.aggregationRole != undefined &&
1073
+ oMoveConfigDragged.aggregationRole != oMoveConfigDropped.aggregationRole)) {
1074
+ oEvent.preventDefault();
1075
+ return;
1076
+ }
1077
+
1078
+ //When an item gets dragged into the same "direction" it come from inside the array, an offset is needed
1079
+ if (iDraggedIndex < iDroppedIndex) {
1080
+ if (sDropPosition == "Before" && iDroppedIndex != 0) {
1081
+ iDroppedIndex -= 1;
1082
+ }
1083
+
1084
+ //Max index not needed here since draggedIndex must be greater than dropped index -> can't be dropped at max
1085
+ } else if (sDropPosition == "After") {
1086
+
1087
+ iDroppedIndex += 1;
1088
+ }
1089
+
1090
+ this._moveItemsByIndex(iDraggedIndex, iDroppedIndex);
1091
+
1092
+ this._getP13nModel().refresh(true);
1093
+ this._updateVisibleIndexes();
1094
+
1095
+ };
1096
+
1097
+ ChartItemPanel.prototype._getMoveTopButton = function() {
1098
+
1099
+ if (this._oMoveTopBtn && this._oMoveTopBtn.isDestroyed()) {
1100
+ this._oMoveTopBtn = null;
1101
+ }
1102
+
1103
+ return BasePanel.prototype._getMoveTopButton.apply(this, arguments);
1104
+ };
1105
+
1106
+ ChartItemPanel.prototype._getMoveUpButton = function() {
1107
+
1108
+ if (this._oMoveUpButton && this._oMoveUpButton.isDestroyed()) {
1109
+ this._oMoveUpButton = null;
1110
+ }
1111
+
1112
+ return BasePanel.prototype._getMoveUpButton.apply(this, arguments);
1113
+ };
1114
+
1115
+ ChartItemPanel.prototype._getMoveDownButton = function() {
1116
+
1117
+ if (this._oMoveDownButton && this._oMoveDownButton.isDestroyed()) {
1118
+ this._oMoveDownButton = null;
1119
+ }
1120
+
1121
+ return BasePanel.prototype._getMoveDownButton.apply(this, arguments);
1122
+ };
1123
+
1124
+ ChartItemPanel.prototype._getMoveBottomButton = function() {
1125
+
1126
+ if (this._oMoveBottomButton && this._oMoveBottomButton.isDestroyed()) {
1127
+ this._oMoveBottomButton = null;
1128
+ }
1129
+
1130
+ return BasePanel.prototype._getMoveBottomButton.apply(this, arguments);
1131
+ };
1132
+
1133
+ ChartItemPanel.prototype._getChartItemTextByKey = function (sKey) {
1134
+ var MDCRb = sap.ui.getCore().getLibraryResourceBundle("sap.ui.mdc");
1135
+ var oAvailableRoles = {
1136
+ Dimension: [
1137
+ {
1138
+ key: MDCLib.ChartItemRoleType.category,
1139
+ text: MDCRb.getText('chart.PERSONALIZATION_DIALOG_CHARTROLE_CATEGORY')
1140
+ }, {
1141
+ key: MDCLib.ChartItemRoleType.category2,
1142
+ text: MDCRb.getText('chart.PERSONALIZATION_DIALOG_CHARTROLE_CATEGORY2')
1143
+ }, {
1144
+ key: MDCLib.ChartItemRoleType.series,
1145
+ text: MDCRb.getText('chart.PERSONALIZATION_DIALOG_CHARTROLE_SERIES')
1146
+ }
1147
+ ],
1148
+ Measure: [
1149
+ {
1150
+ key: MDCLib.ChartItemRoleType.axis1,
1151
+ text: MDCRb.getText('chart.PERSONALIZATION_DIALOG_CHARTROLE_AXIS1')
1152
+ }, {
1153
+ key: MDCLib.ChartItemRoleType.axis2,
1154
+ text: MDCRb.getText('chart.PERSONALIZATION_DIALOG_CHARTROLE_AXIS2')
1155
+ }, {
1156
+ key: MDCLib.ChartItemRoleType.axis3,
1157
+ text: MDCRb.getText('chart.PERSONALIZATION_DIALOG_CHARTROLE_AXIS3')
1158
+ }
1159
+ ]
1160
+ };
1161
+ return oAvailableRoles[sKey];
1162
+ };
1163
+
1164
+ ChartItemPanel.prototype._getResourceTextMDC = function(sText, vValue) {
1165
+ this.oResourceBundleMDC = this.oResourceBundleMDC ? this.oResourceBundleMDC : sap.ui.getCore().getLibraryResourceBundle("sap.ui.mdc");
1166
+ return sText ? this.oResourceBundleMDC.getText(sText, vValue) : this.oResourceBundleMDC;
1167
+ };
1168
+
1169
+ return ChartItemPanel;
1170
+
1171
+ });