@openui5/sap.ui.mdc 1.94.0 → 1.97.0

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