ru.coon 2.8.65 → 3.0.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 (130) hide show
  1. package/CHANGELOG.md +319 -6
  2. package/package.json +1 -1
  3. package/src/Function.js +1 -1
  4. package/src/VisualLinker.js +610 -0
  5. package/src/VisualLinker.scss +219 -0
  6. package/src/app/Application.js +1 -0
  7. package/src/app/ApplicationSettings.js +49 -0
  8. package/src/app/Config.js +60 -0
  9. package/src/app/Router.js +37 -21
  10. package/src/app/viewPort/CVWrapperPanel.js +53 -0
  11. package/src/app/viewPort/CenterView.js +153 -46
  12. package/src/app/viewPort/CenterView.scss +151 -0
  13. package/src/app/viewPort/ComponentContextManager.js +24 -0
  14. package/src/app/viewPort/Main.js +4 -1
  15. package/src/app/viewPort/Routing.d2 +23 -0
  16. package/src/app/viewPort/TabHistory.js +81 -0
  17. package/src/common/ComponentFactory.js +167 -0
  18. package/src/common/button/DropdownContentButton.js +146 -0
  19. package/src/common/button/DropdownContentButton.scss +92 -0
  20. package/src/common/button/DropdownContentButtonController.js +60 -0
  21. package/src/common/component/editor/EditorFactory.js +3 -1
  22. package/src/common/component/formeditor/UiCustomFilterForm.scss +0 -1
  23. package/src/common/component/settings/modules/settingClosePageConfirmation.js +1 -3
  24. package/src/common/component/settings/modules/settingFavoritePanelShow.js +21 -0
  25. package/src/common/component/settings/modules/settingReportCalculator.js +22 -0
  26. package/src/common/component/settings/modules/settingShowNeedReloadMessage.js +1 -3
  27. package/src/common/component/settings/modules/settingwindowHolder.js +2 -3
  28. package/src/common/panel/WindowWrap.js +19 -11
  29. package/src/common/tree/BaseContextMenu.js +4 -3
  30. package/src/log.js +4 -5
  31. package/src/nav/AppNavCalcButton.js +23 -0
  32. package/src/nav/AppNavCalcButton.scss +6 -0
  33. package/src/nav/AppNavigationBar.js +1 -1
  34. package/src/nav/AppNavigationMenuController.js +2 -2
  35. package/src/nav/AppNavigationMenuMinimized.js +61 -0
  36. package/src/nav/AppNavigationPanel.js +115 -0
  37. package/src/nav/AppNavigationPanel.scss +178 -0
  38. package/src/nav/AppNavigationPanelController.js +386 -0
  39. package/src/nav/FavoriteCfg.js +18 -0
  40. package/src/nav/MenuEntity.js +23 -15
  41. package/src/nav/MenuFavoritesBar.js +100 -0
  42. package/src/nav/MenuFavoritesBar.scss +92 -0
  43. package/src/nav/editor/NavigateElementEditorView.js +2 -2
  44. package/src/nav/editor/workspace/NavWorkspaceListView.js +1 -4
  45. package/src/nav/menu/WorkspaceMenuViewMinimized.js +22 -0
  46. package/src/overrides/panel/TabPanel.js +36 -0
  47. package/src/overrides/panel/TabPanel.scss +65 -0
  48. package/src/report/component/ClearFiltersButton.js +4 -1
  49. package/src/report/component/CopyCellValueMenuItem.js +18 -0
  50. package/src/report/component/ReportFieldMap.js +274 -0
  51. package/src/report/component/ReportPanel.js +73 -44
  52. package/src/report/component/ReportPanel.scss +2 -2
  53. package/src/report/component/ReportTagLookup.js +59 -2
  54. package/src/report/component/calculator/ReportCalculatorController.js +266 -0
  55. package/src/report/component/calculator/ReportCalculatorField.js +47 -0
  56. package/src/report/component/calculator/ReportCalculatorHistoryPlugin.js +128 -0
  57. package/src/report/component/calculator/ReportCalculatorHistoryPlugin.scss +33 -0
  58. package/src/report/component/calculator/ReportCalculatorMenuItem.js +101 -0
  59. package/src/report/component/calculator/ReportCalculatorMenuItem.scss +41 -0
  60. package/src/report/component/calculator/ReportCalculatorPanel.js +363 -0
  61. package/src/report/component/calculator/ReportCalculatorPanel.scss +86 -0
  62. package/src/report/component/reportpanel/CopyReportPanelController.js +1 -1
  63. package/src/report/component/reportpanel/FilterPanel.js +13 -15
  64. package/src/report/component/reportpanel/FilterPanel.scss +5 -1
  65. package/src/report/component/reportpanel/FormFieldFocusPlugin.js +157 -0
  66. package/src/report/component/reportpanel/FormFieldFocusPlugin.scss +14 -0
  67. package/src/report/component/reportpanel/NorthPanel.js +16 -17
  68. package/src/report/component/reportpanel/NorthPanel.scss +1 -1
  69. package/src/report/component/reportpanel/ReportContextMenu.js +219 -0
  70. package/src/report/component/reportpanel/ReportGrid.js +1 -0
  71. package/src/report/component/reportpanel/ReportGrid.scss +4 -0
  72. package/src/report/component/settings/field/ReportFormFieldsGrid.js +2 -2
  73. package/src/report/component/settings/field/ReportFormFieldsGridController.js +2 -2
  74. package/src/report/component/settings/property/ReportPropertiesPanelController.js +1 -1
  75. package/src/report/component/settings/property/ReportPropertyDictionary.js +7 -0
  76. package/src/report/plugin/configPanel/AddFilterConditionPluginConfigPanel.js +34 -11
  77. package/src/report/plugin/configPanel/GridFiltersPluginConfigPanelFiltersGrid.js +3 -2
  78. package/src/report/plugin/configPanel/openCustomPanelButtonPlugin/OpenCustomPanelButtonPluginConfigPanel.js +274 -255
  79. package/src/report/plugin/configPanel/openCustomPanelButtonPlugin/OpenCustomPanelButtonPluginConfigPanel.scss +17 -0
  80. package/src/report/plugin/grid/AddFilterConditionPlugin.js +530 -87
  81. package/src/report/plugin/grid/CalculatorPlugin.js +90 -0
  82. package/src/report/plugin/grid/GridContextMenu.js +12 -10
  83. package/src/report/plugin/grid/GridRowCountPlugin.js +0 -1
  84. package/src/report/plugin/grid/GridToolbarButtonPlugin.js +11 -2
  85. package/src/report/plugin/grid/OpenCustomPanelButtonPlugin.js +126 -89
  86. package/src/report/plugin/grid/ReportCharacteristicBindPlugin.js +6 -4
  87. package/src/report/plugin/grid/ReportColumnStatePlugin.js +15 -3
  88. package/src/report/plugin/grid/SetSingleParameterPlugin.js +1 -1
  89. package/src/report/plugin/grid/ToolbarButtonPlugin.js +1 -1
  90. package/src/report/plugin/grid/addFilterConditionPlugin/AdvancedSearchPanel.js +55 -0
  91. package/src/report/plugin/grid/addFilterConditionPlugin/AdvancedSearchPanelController.js +226 -0
  92. package/src/report/plugin/grid/addFilterConditionPlugin/FilterConfigMixin.js +138 -0
  93. package/src/report/plugin/grid/addFilterConditionPlugin/FilterFieldFactory.js +223 -0
  94. package/src/report/plugin/grid/addFilterConditionPlugin/FilterItem.js +164 -0
  95. package/src/report/plugin/grid/addFilterConditionPlugin/FilterItem.scss +21 -0
  96. package/src/report/plugin/grid/addFilterConditionPlugin/FilterMenu.js +29 -0
  97. package/src/report/plugin/grid/addFilterConditionPlugin/FilterWrapPanel.js +53 -0
  98. package/src/report/plugin/grid/addFilterConditionPlugin/FilterWrapPanelController.js +57 -0
  99. package/src/report/plugin/grid/addFilterConditionPlugin/InfoMenuItem.js +111 -0
  100. package/src/report/plugin/grid/addFilterConditionPlugin/InfoMenuItem.scss +83 -0
  101. package/src/report/plugin/grid/addFilterConditionPlugin/SelectColumnPanel.js +102 -0
  102. package/src/report/selectionModels/MixedRowSelectionModel.js +36 -45
  103. package/src/report/toolbar/dropdown/ToolbarOverflowButton.js +16 -5
  104. package/src/report/toolbar/dropdown/ToolbarOverflowPanel.scss +26 -14
  105. package/src/report/toolbar/layout/ReportToolbarOverflow.js +5 -2
  106. package/src/ringBuffer.js +7 -3
  107. package/src/uielement/command/GetUIElementCommand.js +0 -1
  108. package/src/uielement/component/UiCPWrapper.js +26 -36
  109. package/src/uielement/component/UiCustomController.js +7 -0
  110. package/src/uielement/component/UiCustomPanel.js +46 -2
  111. package/src/uielement/component/settings/UiCustomPanelEditorController.js +35 -29
  112. package/src/uielement/component/settings/plugin/UiCustomPanelPluginGrid.js +146 -33
  113. package/src/uielement/component/settings/plugin/UiCustomPanelPluginGrid.scss +28 -0
  114. package/src/uielement/component/settings/plugin/UiCustomPanelPluginGridController.js +366 -22
  115. package/src/uielement/component/settings/plugin/UiCustomPanelPluginModel.js +1 -0
  116. package/src/uielement/component/settings/plugin/UiCustomPanelPluginPanel.js +10 -4
  117. package/src/uielement/component/settings/plugin/UiCustomPanelPluginPanelController.js +28 -30
  118. package/src/uielement/plugin/UnifiedButtonToolbarPlugin.js +203 -22
  119. package/src/uielement/plugin/configPanel/ExecuteFunctionPluginConfigPanelFormEditor.js +4 -36
  120. package/src/uielement/plugin/configPanel/FireEventPluginConfigPanelFormEditor.js +5 -36
  121. package/src/uielement/plugin/configPanel/MethodChainPluginConfigPanelFormEditor.js +4 -36
  122. package/src/uielement/plugin/configPanel/OpenPanelPluginConfigPanelFormEditor.js +2 -38
  123. package/src/uielement/plugin/configPanel/PrintPdfPluginConfigPanelFormEditor.js +2 -35
  124. package/src/uielement/plugin/configPanel/UiCPPluginFormPanel.js +54 -0
  125. package/src/uielement/plugin/configPanel/UnifiedButtonToolbarPluginConfigPanelFormEditor.js +28 -18
  126. package/src/userSettings.js +1 -0
  127. package/src/util/ContextManager.js +109 -0
  128. package/src/util.js +96 -15
  129. package/src/version.js +1 -1
  130. package/src/app/viewPort/CenterViewController.js +0 -158
@@ -1,39 +1,39 @@
1
1
  Ext.define('Coon.uielement.plugin.configPanel.UnifiedButtonToolbarPluginConfigPanelFormEditor', {
2
- extend: 'Ext.panel.Panel',
2
+ extend: 'Coon.uielement.plugin.configPanel.UiCPPluginFormPanel',
3
+ requires: ['Coon.uielement.plugin.configPanel.UiCPPluginFormPanel'],
3
4
  alias: 'widget.UnifiedButtonToolbarPluginConfigPanelFormEditor',
4
5
  description: 'Добавляет стандартный тулбар',
5
6
  viewModel: {
6
7
  data: {
7
8
  saveHandlerName: '',
8
9
  prepareBeanHandlerName: '',
10
+ getHashDataHandlerName: '',
9
11
  validateBeanHandlerName: '',
10
12
  dock: 'bottom',
11
13
  checkChangesOnSave: true,
14
+ needReloadEventOnSave: false,
12
15
  },
13
16
  },
14
- layout: {
15
- type: 'vbox',
16
- align: 'stretch',
17
- },
18
17
  items: [
19
18
  {
20
- xtype: 'pluginDescriptionLabel',
19
+ xtype: 'SearchByPropCombo',
20
+ fieldLabel: 'Обработчик подготовки данных для сохранения (необходим синхронный метод)',
21
21
  bind: {
22
- value: '{description}',
22
+ value: '{prepareBeanHandlerName}',
23
23
  },
24
24
  },
25
25
  {
26
26
  xtype: 'SearchByPropCombo',
27
- fieldLabel: 'Обработчик валидации данных',
27
+ fieldLabel: 'Обработчик получения данных для генерации хеша (необходим синхронный метод)',
28
28
  bind: {
29
- value: '{validateBeanHandlerName}',
29
+ value: '{getHashDataHandlerName}',
30
30
  },
31
31
  },
32
32
  {
33
33
  xtype: 'SearchByPropCombo',
34
- fieldLabel: 'Обработчик подготовки данных для сохранения',
34
+ fieldLabel: 'Обработчик валидации данных (необходим синхронный метод)',
35
35
  bind: {
36
- value: '{prepareBeanHandlerName}',
36
+ value: '{validateBeanHandlerName}',
37
37
  },
38
38
  },
39
39
  {
@@ -75,14 +75,16 @@ Ext.define('Coon.uielement.plugin.configPanel.UnifiedButtonToolbarPluginConfigPa
75
75
  bind: {
76
76
  value: '{checkChangesOnSave}',
77
77
  },
78
+ },
79
+ {
80
+ xtype: 'checkbox',
81
+ boxLabel: 'Срабатывание события needReload при сохранении данных.',
82
+ bind: {
83
+ value: '{needReloadEventOnSave}',
84
+ },
78
85
  }
79
86
  ],
80
- getData: function() {
81
- return this.getConfiguration();
82
- },
83
- setData: function(data) {
84
- data && this.doInit(data);
85
- },
87
+
86
88
  doInit: function(config) {
87
89
  this.getViewModel().set('description', this.description);
88
90
  for (const parameterName in config) {
@@ -95,7 +97,15 @@ Ext.define('Coon.uielement.plugin.configPanel.UnifiedButtonToolbarPluginConfigPa
95
97
  getConfiguration: function() {
96
98
  const result = {};
97
99
  const vm = this.getViewModel();
98
- ['saveHandlerName', 'prepareBeanHandlerName', 'validateBeanHandlerName', 'dock', 'checkChangesOnSave'].forEach((el) => {
100
+ [
101
+ 'saveHandlerName',
102
+ 'prepareBeanHandlerName',
103
+ 'validateBeanHandlerName',
104
+ 'dock',
105
+ 'checkChangesOnSave',
106
+ 'getHashDataHandlerName',
107
+ 'needReloadEventOnSave'
108
+ ].forEach((el) => {
99
109
  if (typeof vm.get(el) !== 'undefined') {
100
110
  result[el] = vm.get(el);
101
111
  }
@@ -4,6 +4,7 @@ Ext.define('Coon.userSettings', {
4
4
  requires: [
5
5
  'Coon.common.component.settings.modules.settingClosePageConfirmation',
6
6
  'Coon.common.component.settings.modules.settingwindowHolder',
7
+ 'Coon.common.component.settings.modules.settingReportCalculator',
7
8
  'Coon.common.component.settings.stores.userSettingsStoreService'
8
9
  ],
9
10
 
@@ -0,0 +1,109 @@
1
+ Ext.define('Coon.util.ContextManager', {
2
+ singleton: true,
3
+
4
+ contextMap: new Map(),
5
+
6
+ isDeleted: Symbol('isDeleted'),
7
+
8
+ generateKey(uniqueContext) {
9
+ if (typeof uniqueContext === 'string') {
10
+ return uniqueContext;
11
+ }
12
+ return Coon.util.generateHashFromObj(uniqueContext, {algorithm: 'md5'});
13
+ },
14
+
15
+ createContext(parentKey = null, componentContext, uniqueContext) {
16
+ uniqueContext = uniqueContext || componentContext;
17
+ const key = this.generateKey(uniqueContext);
18
+ const сontext = {
19
+ key,
20
+ parentKey,
21
+ componentContext,
22
+ children: [],
23
+ timestamp: Date.now(),
24
+ };
25
+
26
+ this.contextMap.set(key, сontext);
27
+
28
+ if (parentKey) {
29
+ const parentContext = this.contextMap.get(parentKey);
30
+ if (parentContext) {
31
+ parentContext.children.push(key);
32
+ } else {
33
+ Coon.log.error(`Parent context with key ${parentKey} not found!`);
34
+ }
35
+ }
36
+
37
+ return key;
38
+ },
39
+
40
+ getContext(key) {
41
+ return this.contextMap.get(key);
42
+ },
43
+
44
+ removeContext(key) {
45
+ const context = this.getContext(key);
46
+ if (context.children.length) {
47
+ context.children.forEach((childKey) => {
48
+ this.updateContext(childKey, (ctx) => {
49
+ ctx.parentKey = this.isDeleted;
50
+ return ctx;
51
+ });
52
+ });
53
+ }
54
+ if (this.isRootContext(key)) {
55
+ return;
56
+ }
57
+ this.updateContext(context.parentKey, (ctx) => {
58
+ ctx.children = ctx.children.filter((childKey) => childKey !== key);
59
+ return ctx;
60
+ });
61
+ this.contextMap.delete(key);
62
+ },
63
+
64
+ updateContext(key, handler) {
65
+ const context = this.contextMap.get(key);
66
+ if (typeof handler === 'function') {
67
+ this.contextMap.set(handler(context));
68
+ }
69
+ },
70
+
71
+ updateComponentContext(key, componentContext) {
72
+ const context = this.contextMap.get(key);
73
+ context.componentContext = componentContext;
74
+ this.contextMap.set(context);
75
+ },
76
+
77
+ isRootContext(key) {
78
+ const {parentKey} = this.getContext(key) || {};
79
+ return parentKey === null && parentKey !== this.isDeleted;
80
+ },
81
+
82
+ getParentContext(childKey) {
83
+ if (this.isRootContext(childKey)) {
84
+ return null;
85
+ }
86
+ const child = this.getContext(childKey);
87
+ return child && child.parentKey !== this.isDeleted ? this.getContext(child.parentKey) : null;
88
+ },
89
+
90
+ buildContextChain(startKey) {
91
+ const chain = [];
92
+ let currentKey = startKey;
93
+ while (currentKey !== null) {
94
+ const context = this.contextMap.get(currentKey);
95
+ if (!context) {
96
+ break;
97
+ }
98
+ chain.unshift(context);
99
+ currentKey = context.parentKey;
100
+ }
101
+ return chain;
102
+ },
103
+
104
+ getChildContexts(parentKey) {
105
+ return Array.from(this.contextMap.values()).filter(
106
+ ({parentKey: ctxParentKey}) => ctxParentKey === parentKey
107
+ );
108
+ },
109
+ });
package/src/util.js CHANGED
@@ -343,11 +343,9 @@ Ext.define('Coon.util', {
343
343
 
344
344
  safeDecodeURI(source) {
345
345
  if (!typeof source == 'string') {
346
- // Coon.log.debug('safeDecodeURI.not string', typeof source);
347
346
  return source;
348
347
  }
349
348
  let decoded = decodeURIComponent(source);
350
- // Coon.log.debug('safeDecodeURI.decoded', {source, decoded});
351
349
  decoded = decoded === source ? source : decoded;
352
350
  try {
353
351
  return JSON.parse(decoded);
@@ -356,15 +354,10 @@ Ext.define('Coon.util', {
356
354
  }
357
355
  },
358
356
 
359
- filterMap(arr, fnIterator, checkForNoNEmpty) {
360
- if (typeof checkForNoNEmpty !== 'function') {
361
- checkForNoNEmpty = function(v) {
362
- return !!v;
363
- };
364
- }
357
+ filterMap(arr, iterator, checkForNoNEmpty = (v) => !!v) {
365
358
  const acc = [];
366
359
  for (const el of arr) {
367
- const result = fnIterator(el);
360
+ const result = iterator(el);
368
361
  if (checkForNoNEmpty(result)) {
369
362
  acc.push(result);
370
363
  }
@@ -630,9 +623,82 @@ Ext.define('Coon.util', {
630
623
  * @returns {boolean}
631
624
  */
632
625
  objectsIsEqual(obj1 = {}, obj2 = {}) {
626
+ obj1 = Coon.util.convertExtObject(obj1);
627
+ obj2 = Coon.util.convertExtObject(obj2);
633
628
  return Coon.util.generateHashFromObj(obj1) === Coon.util.generateHashFromObj(obj2);
634
629
  },
635
630
 
631
+ /**
632
+ * deep call handler for each object property value
633
+ * filter if handler result is not null or undefined
634
+ * @param {Object} src
635
+ * @param {Function} handler, arguments: value[Any], property name[String]
636
+ * @returns Object
637
+ */
638
+ deepObjectFilter(src, handler, options = {cureCircular: true}) {
639
+ let obj = src;
640
+ if (options.cureCircular) {
641
+ obj = Coon.util.markCircularLinks(src);
642
+ }
643
+ return Object.fromEntries(
644
+ Coon.util.filterMap(Object.entries(obj), ([k, v]) => {
645
+ if (Ext.isObject(v)) {
646
+ v = Coon.util.deepObjectFilter(v, handler);
647
+ }
648
+ v = handler(v, k);
649
+ return Coon.util.isNotNullOrUndefined(v) && [k, v];
650
+ })
651
+ );
652
+ },
653
+
654
+ isNullOrUndefined(src) {
655
+ return Coon.util.isTypeIn(src, ['null', 'undefined']);
656
+ },
657
+
658
+ isNotNullOrUndefined(src) {
659
+ return !Coon.util.isTypeIn(src, ['null', 'undefined']);
660
+ },
661
+
662
+ getInstanceIdProperties(instance) {
663
+ if (instance.id ||
664
+ instance.xtype ||
665
+ instance.ptype ||
666
+ instance.$className ||
667
+ Ext.isObject(instance.initialConfig)
668
+ ) {
669
+ return Object.assign(
670
+ {},
671
+ Coon.util.mapObject(instance, [
672
+ 'id',
673
+ 'xtype',
674
+ 'ptype',
675
+ '$className',
676
+ {
677
+ from: 'config',
678
+ convert: Coon.util.convertExtObject,
679
+ },
680
+ {
681
+ from: 'initialConfig',
682
+ convert: Coon.util.convertExtObject,
683
+ }
684
+ ])
685
+ );
686
+ } else {
687
+ return {};
688
+ }
689
+ },
690
+
691
+ convertExtObject(src) {
692
+ return Coon.util.deepObjectFilter(
693
+ Coon.util.markCircularLinks(src),
694
+ (value) => {
695
+ if (Ext.isObject(value) && value.isInstance) {
696
+ return Coon.util.getInstanceIdProperties(value);
697
+ }
698
+ return value;
699
+ });
700
+ },
701
+
636
702
  /**
637
703
  * bind methods from one component to another
638
704
  * @param {Array} methods array of method names
@@ -694,16 +760,18 @@ Ext.define('Coon.util', {
694
760
  return data;
695
761
  }
696
762
  const markerValue = '__linkedObj';
697
- const linkMap = new WeakSet();
698
- const converter = (data) => {
763
+ const linkSet = new WeakSet();
764
+ const linkMap = new WeakMap();
765
+ const converter = (data, key) => {
699
766
  const acc = {};
700
767
  if (Ext.isObject(data)) {
701
- if (linkMap.has(data)) {
768
+ if (linkSet.has(data)) {
702
769
  return markerValue;
703
770
  }
704
- linkMap.add(data);
771
+ linkSet.add(data);
772
+ key && linkMap.set(data, key);
705
773
  Object.entries(data).forEach(([key, val]) => {
706
- acc[key] = converter(val);
774
+ acc[key] = converter(val, key);
707
775
  });
708
776
  return acc;
709
777
  }
@@ -712,6 +780,19 @@ Ext.define('Coon.util', {
712
780
  }
713
781
  return data;
714
782
  };
715
- return converter(data);
783
+ const result = converter(data);
784
+ return result;
785
+ },
786
+
787
+ createObjFromTpl(src, tpl) {
788
+ if (!Ext.isObject(src) || !Ext.isObject(tpl)) {
789
+ return src;
790
+ }
791
+ const keys = Object.keys(tpl);
792
+ return Object.fromEntries(
793
+ Object.entries(src).filter(([key, _]) => {
794
+ return keys.includes(key);
795
+ })
796
+ );
716
797
  },
717
798
  });
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '2.8.65',
3
+ number: '3.0.2',
4
4
  });
@@ -1,158 +0,0 @@
1
- Ext.define('Coon.app.viewPort.CenterViewController', {
2
- extend: 'Ext.app.ViewController',
3
- alias: 'controller.CenterViewController',
4
- requires: ['Coon.util', 'Coon.Function'],
5
- cache: new Map(),
6
- privates: {
7
- paramsToObject(params) {
8
- const entries = [];
9
- if (Array.isArray(params) && params.length > 1) {
10
- for (let i = 0; i < Math.floor(params.length / 2); i++) {
11
- entries.push([params[i * 2], params[i * 2 + 1]]);
12
- }
13
- }
14
- return entries.length ? Object.fromEntries(entries) : null;
15
- },
16
- triggerPlugin(pluginId, target) {
17
- if (target && Array.isArray(target.plugins)) {
18
- const triggerPlugin = target.plugins.find((p) => p.pluginId === pluginId);
19
- if (triggerPlugin && typeof triggerPlugin.handler === 'function') {
20
- triggerPlugin.handler.call(triggerPlugin);
21
- }
22
- }
23
- },
24
- onActivateComponent(params, cmp) {
25
- if (cmp.xtype === 'ReportPanel') {
26
- if (params) {
27
- cmp.updateFilterDefaults(params);
28
- if (params.plugin) {
29
- if (!cmp.grid) {
30
- cmp.on('gridReady', (reportPanel) => {
31
- this.triggerPlugin(params.plugin, reportPanel.grid);
32
- });
33
- } else {
34
- this.triggerPlugin(params.plugin, cmp.grid);
35
- }
36
- }
37
- }
38
- }
39
- },
40
-
41
- onRenderEditor(editor, id) {
42
- const c = editor.getController();
43
- typeof c.doInit === 'function' && c.doInit.call(c, id);
44
- },
45
- },
46
- async create(id, type = 'panel', params = [], useCache = true) {
47
- const cacheKey = useCache && JSON.stringify({id, type, params});
48
- let config;
49
- if (!id) {
50
- return config;
51
- }
52
- if (cacheKey) {
53
- const cached = this.cache.get(cacheKey);
54
- if (cached) {
55
- return cached;
56
- }
57
- }
58
- const paramsObject = this.paramsToObject(params);
59
- const filterDefaults =
60
- (paramsObject && Object.assign(paramsObject, {doFilter: true})) || {};
61
- switch (String(type).toUpperCase()) {
62
- case 'REPORT':
63
- config = {
64
- xtype: 'ReportPanel',
65
- reportID: id,
66
- filterDefaults,
67
- listeners: {
68
- 'router:activate': this.onActivateComponent.bind(
69
- this,
70
- paramsObject
71
- ),
72
- },
73
- };
74
- break;
75
- case 'PANEL':
76
- try {
77
- config = await Coon.util.promisifyCmd(
78
- 'Coon.uielement.command.GetUIElementCommand',
79
- id
80
- );
81
- if (typeof config === 'object') {
82
- if (typeof config.propertyData === 'string') {
83
- config.propertyData = JSON5.parse(
84
- config.propertyData,
85
- (key, value) => {
86
- if (value === 'true') {
87
- return true;
88
- }
89
- if (value === 'false') {
90
- return false;
91
- }
92
- return value;
93
- }
94
- );
95
- }
96
- config = Object.assign(
97
- {xtype: config.xtype, itemId: id},
98
- config.propertyData
99
- );
100
- if (config.xtype === 'ReportPanel') {
101
- Object.assign(config, {
102
- filterDefaults,
103
- listeners: {
104
- 'router:activate': this.onActivateComponent.bind(
105
- this,
106
- paramsObject
107
- ),
108
- },
109
- });
110
- } else if (config.xtype === 'UiCustomPanel') {
111
- Object.assign(config, {
112
- listeners: {
113
- 'router:activate': this.onActivateComponent.bind(
114
- this,
115
- paramsObject
116
- ),
117
- 'afterrender': (panel) =>
118
- Coon.Function.executeComponentDoInit(panel, paramsObject),
119
- },
120
- });
121
- } else {
122
- Object.assign(config, {
123
- listeners: {
124
- 'afterrender': (panel) =>
125
- Coon.Function.executeComponentDoInit(panel, paramsObject),
126
- },
127
- });
128
- }
129
- }
130
- } catch (e) {
131
- Coon.log.error(e.message);
132
- }
133
- break;
134
- case 'EDIT-REPORT':
135
- config = {
136
- _preferFullScreen: true,
137
- _allowRedirect: false,
138
- xtype: 'ReportFormEditPanel',
139
- listeners: {
140
- 'afterrender': (panel) => this.onRenderEditor.call(this, panel, id),
141
- },
142
- };
143
- break;
144
- case 'EDIT-PANEL':
145
- config = {
146
- _preferFullScreen: true,
147
- _allowRedirect: false,
148
- xtype: 'UiCustomPanelEditor',
149
- listeners: {
150
- 'afterrender': (panel) => this.onRenderEditor.call(this, panel, id),
151
- },
152
- };
153
- break;
154
- }
155
- cacheKey && this.cache.set(cacheKey, config);
156
- return config;
157
- },
158
- });