ru.coon 3.0.46 → 3.0.48

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # Version 3.0.48, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/227c685c3c849b36bec245c8f91c338cb6ea40f7)
2
+ * ## Fixes
3
+ * <span style='color:red'>fix HT-14284 - remove title setting</span> ([29a26d], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/29a26d463a68d1755820e08698100eea7fcfb59f))
4
+
5
+ * HT-13994: Исправление работы плагина, добавление кнопки в тулбар для сброса состояния ([feaee6], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/feaee672face5d48cdb74326966df8e1d1f6ede5))
6
+ * update: CHANGELOG.md ([c2b6ce], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/c2b6ced6aafc5f28fec8ae207689d3eb5899c449))
7
+
8
+ # Version 3.0.47, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/3dd226d0cac935732115784118e6a1acdde75bae)
9
+ * HT-12816 fix: Исправление ошибки получения выбранных строк в ReportTagLookup ([4b89a3], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/4b89a35f198780bb93e4e7ce341d156c379ecb94))
10
+ * update: CHANGELOG.md ([f6f1e6], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/f6f1e6e36b78a7a728d61640c0b7b7f21810c6fb))
11
+
1
12
  # Version 3.0.46, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/6feb5506104ee6d9dcca9e829363f387ff566dcf)
2
13
  * ## Fixes
3
14
  * <span style='color:red'> ThreeStateCheckColumn, getGrid</span> ([0b4fab], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0b4fabcd5365e978b332f1b2685a39c805b1b267))
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "ru.coon"
5
5
  },
6
6
  "description": "",
7
- "version": "3.0.46",
7
+ "version": "3.0.48",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+http://gitlab-dbr.sigma-it.local/dbr/ru.coon"
@@ -11,15 +11,6 @@ Ext.define('Coon.app.Application', {
11
11
  this.appRouter = Coon.app.Router;
12
12
  },
13
13
 
14
- setDefaultWindowTitle() {
15
- Coon.SystemProperties.fetch('browserDefaultTitle').then((title) => {
16
- if (!title) {
17
- return;
18
- }
19
- window.document.title = title;
20
- }).catch((error) => console.error('setDefaultWindowTitle', error));
21
- },
22
-
23
14
  onLogout: function() {
24
15
  Ext.Msg.show({
25
16
  title: 'Сообщение системы',
@@ -104,9 +95,6 @@ Ext.define('Coon.app.Application', {
104
95
  this.setUserData();
105
96
  }
106
97
  const isAuthValid = authenticated === true && !requireTwoFactorAuthentication;
107
- if (isAuthValid) {
108
- this.setDefaultWindowTitle();
109
- }
110
98
  let view = isAuthValid ? 'mainview' : 'loginview';
111
99
 
112
100
  if (window.location.href.indexOf('customForm') > -1) {
@@ -181,6 +181,9 @@ Ext.define('Coon.report.component.ReportPanel', {
181
181
  currentGroupLevel = currentGroupLevel[currentGroupLevel.length - 1].columns;
182
182
  });
183
183
  columnConfig.cls = 'x-column-header-group-item';
184
+
185
+ columnConfig.draggable = false;
186
+
184
187
  currentGroupLevel.push(columnConfig);
185
188
  pushed = true;
186
189
  }
@@ -442,6 +445,9 @@ Ext.define('Coon.report.component.ReportPanel', {
442
445
  return;
443
446
  }
444
447
  setTimeout(function() {
448
+ if (!this.grid || this.grid.destroyed) {
449
+ return;
450
+ }
445
451
  if (this.grid.viewConfig) {
446
452
  this.grid.scrollTo(0, 0);
447
453
  }
@@ -983,6 +989,7 @@ Ext.define('Coon.report.component.ReportPanel', {
983
989
  url: this.url || '/ReportFormData/get',
984
990
  timeout: this.timeout || undefined,
985
991
  pageSize: this.pageSize || reportBean[ns.$rowCountPerPageValue],
992
+ sealedColumns: true,
986
993
  viewConfig: {
987
994
  emptyText: 'Не найдено записей, удовлетворяющих условию.',
988
995
  enableTextSelection: this.enableTextSelection,
@@ -1248,10 +1255,11 @@ Ext.define('Coon.report.component.ReportPanel', {
1248
1255
  return data;
1249
1256
  },
1250
1257
 
1251
- // getSelection: function(firstSelectedOnly) {
1252
- // const selectedRecords = this.grid.getSelection();
1253
- // return selectedRecords && selectedRecords.length > 0 && firstSelectedOnly ? selectedRecords[0] : selectedRecords;
1254
- // },
1258
+ // todo: Требуется рефакторинг.
1259
+ getSelection: function(firstSelectedOnly) {
1260
+ const selectedRecords = this.grid.getSelection();
1261
+ return selectedRecords && selectedRecords.length > 0 && firstSelectedOnly ? selectedRecords[0] : selectedRecords;
1262
+ },
1255
1263
 
1256
1264
  countSelectedRecords() {
1257
1265
  const grid = this.grid;
@@ -194,7 +194,7 @@ Ext.define('Coon.report.component.ReportTagLookup', {
194
194
  iconCls: 'x-ccb-btn-custom-pencil',
195
195
  handler: function(btn) {
196
196
  const panel = btn.up('ReportPanel');
197
- panel.fireEvent('itemdblclick', panel, panel.getSelection());
197
+ panel.fireEvent('itemdblclick', panel, panel.grid.getSelection());
198
198
  },
199
199
  }] : undefined,
200
200
  }
@@ -7,11 +7,14 @@ Ext.define('Coon.report.plugin.grid.ReportColumnStatePlugin', {
7
7
 
8
8
  configurePanelWizard: 'ReportColumnStatePluginConfigPanel',
9
9
 
10
+ suspendStateSave: false,
11
+ stateEnableConfigs: undefined,
12
+ defaultReportState: undefined,
10
13
 
11
14
  init(component) {
12
15
  if (component instanceof Coon.report.component.ReportPanel) {
13
16
  this.report = component;
14
- this.grid = component.grid;
17
+ this.report.grid = component.grid;
15
18
  } else {
16
19
  Coon.log.log('Incorrect definition of the parent component for the plugin');
17
20
  return;
@@ -19,104 +22,188 @@ Ext.define('Coon.report.plugin.grid.ReportColumnStatePlugin', {
19
22
 
20
23
  if (this.report.getEnableAutoSize) {
21
24
  Coon.log.log('To disable automatic column size, you need to set the enableAutoSize property of the report to "false"');
22
- };
25
+ }
26
+
27
+ this.setStateEnableConfigs();
28
+
23
29
  this.checkEnableAutoSize();
30
+ this.defaultReportState = this.getCurrentReportState()[this.report.reportId];
24
31
  this.applySavedState();
25
32
 
26
33
  const events = ['columnmove', 'columnhide', 'columnshow', 'columnresize'];
27
34
  events.forEach(function(e) {
28
- this.grid.on(e, this.columnInteractionHandler, this);
35
+ this.report.grid.on(e, this.columnInteractionHandler, this);
29
36
  }.bind(this));
37
+
38
+ this.registerApi();
30
39
  },
40
+
41
+ setStateEnableConfigs() {
42
+ this.stateEnableConfigs = {};
43
+ const columns = this.getAllColumns();
44
+
45
+ columns.forEach((column) => {
46
+ this.stateEnableConfigs[this.getColumnIndex(column)] = {
47
+ columnId: true,
48
+ position: Ext.isEmpty(column.columnGroup),
49
+ width: !!column.dataIndex,
50
+ hidden: true,
51
+ };
52
+ });
53
+ },
54
+
31
55
  checkEnableAutoSize() {
32
- if (typeof this.grid.getEnableAutoSize === 'function' && this.grid.getEnableAutoSize() === true) {
56
+ if (typeof this.report.grid.getEnableAutoSize === 'function' && this.report.grid.getEnableAutoSize() === true) {
33
57
  const savedState = localStorage.getItem('reportsState');
34
- let deserializedState; let currentReportState;
58
+ let deserializedState; let savedReportState;
35
59
  try {
36
60
  deserializedState = JSON.parse(savedState);
37
- currentReportState = deserializedState[this.report.reportId];
61
+ savedReportState = deserializedState[this.report.reportId];
38
62
  } catch (e) {
39
63
  Coon.log.log('Incorrect JSON state');
40
64
  return;
41
65
  }
42
- if (currentReportState) {
43
- this.grid.setEnableAutoSize(false);
66
+ if (savedReportState) {
67
+ this.report.grid.setEnableAutoSize(false);
44
68
  }
45
69
  }
46
70
  },
71
+
47
72
  columnInteractionHandler() {
73
+ if (!this.suspendStateSave) {
74
+ const stateObj = this.getCurrentReportState();
75
+ this.saveNewState(stateObj);
76
+ }
77
+ },
78
+
79
+ getCurrentReportState() {
48
80
  const currentState = [];
49
- const columns = this.grid.getColumns();
50
- columns.forEach((e) => {
51
- const currentColumnState = {
52
- columnId: e.dataIndex,
53
- position: e.fullColumnIndex,
54
- width: e.width,
55
- hidden: e.getHidden(),
56
- };
57
- currentState.push(currentColumnState);
81
+ const gridColumnSet = new Set(this.report.grid.getColumns());
82
+
83
+ const columns = this.getColumns();
84
+ columns.forEach((col, index) => {
85
+ currentState.push(this.getCurrentColumnState(col, index));
86
+ gridColumnSet.delete(col);
58
87
  });
59
88
 
89
+ // Колонки, входящие в группу
90
+ if (gridColumnSet.size > 0) {
91
+ gridColumnSet.forEach((col) => {
92
+ currentState.push(this.getCurrentColumnState(col, undefined));
93
+ });
94
+ }
60
95
 
61
96
  const stateObj = {};
62
97
  stateObj[this.report.reportId] = currentState;
63
- this.saveNewState(stateObj);
98
+ return stateObj;
99
+ },
100
+
101
+ getColumns() {
102
+ const columnHeader = this.report.grid.headerCt;
103
+ return columnHeader.getLayout().getLayoutItems();
104
+ },
105
+
106
+ /**
107
+ * Получение всех колонок.
108
+ * Решает проблему с группировкой колонок, т.к. ни один стандартный метод не возвращает все колонки сразу.
109
+ * @returns {*[]}
110
+ */
111
+ getAllColumns() {
112
+ const gridColumns = this.report.grid.getColumns();
113
+ const columnHeader = this.report.grid.headerCt;
114
+ const headerColumns = columnHeader.getLayout().getLayoutItems();
115
+
116
+ const allColumns = [...gridColumns, ...headerColumns];
117
+ return [...new Set(allColumns)];
118
+ },
119
+
120
+ getCurrentColumnState(col, position) {
121
+ const columnId = this.getColumnIndex(col);
122
+ return {
123
+ columnId,
124
+ position,
125
+ width: col.getWidth(),
126
+ hidden: col.getHidden(),
127
+ };
128
+ },
129
+
130
+ /**
131
+ * Получение индекса колонки. У группировочных колонок нет dataIndex, по этому возвращается text.
132
+ * @param column
133
+ * @returns {*}
134
+ */
135
+ getColumnIndex(column) {
136
+ return (column.dataIndex || column.text);
64
137
  },
65
138
 
66
139
  applySavedState() {
67
140
  if (this.getCmp().destroyed || !this.getCmp().rendered) {
68
141
  return;
69
142
  }
70
- const savedState = localStorage.getItem('reportsState');
71
- const columns = this.grid.getColumns();
72
- const columnHeader = this.grid.headerCt;
143
+
144
+ const columns = this.getColumns();
73
145
 
74
146
  if (!Array.isArray(columns)) {
75
147
  return;
76
148
  }
77
149
 
150
+ const {savedReportState} = this.getSavedState();
151
+
152
+ if (savedReportState && Ext.isArray(savedReportState)) {
153
+ this.applyState(savedReportState);
154
+ }
155
+ },
156
+
157
+ applyState(state) {
158
+ const columnHeader = this.report.grid.headerCt;
159
+ const columns = this.getAllColumns();
160
+
161
+ state.forEach((colState) => {
162
+ const column = this.getColumnById(colState.columnId, columns);
163
+ if (column.isHidden()) {
164
+ return;
165
+ }
166
+ if (colState.hidden && column.isHideable() && !column.isHidden()) {
167
+ column.setVisible(false);
168
+ }
169
+
170
+ if (this.stateEnableConfigs[colState.columnId].width) {
171
+ column.setWidth(colState.width ? colState.width : 100);
172
+ }
173
+
174
+ if (this.stateEnableConfigs[colState.columnId].position) {
175
+ columnHeader.remove(column, {destroy: false});
176
+ columnHeader.insert(colState.position, column);
177
+ }
178
+ });
179
+ },
180
+
181
+ /**
182
+ * Получение колонки по ее dataIndex если обычная колонка, или по text если это группа.
183
+ * @param columnId
184
+ * @param columns
185
+ * @returns {*}
186
+ */
187
+ getColumnById(columnId, columns) {
188
+ let column = columns.find((col) => col.dataIndex === columnId);
189
+ if (!column) {
190
+ column = columns.find((col) => col.text === columnId);
191
+ }
192
+ return column;
193
+ },
194
+
195
+ getSavedState() {
196
+ const savedState = localStorage.getItem('reportsState');
197
+ let deserializedState; let savedReportState;
78
198
  if (savedState) {
79
- let deserializedState; let currentReportState;
80
199
  try {
81
200
  deserializedState = JSON.parse(savedState);
82
- currentReportState = deserializedState[this.report.reportId];
201
+ savedReportState = deserializedState[this.report.reportId];
83
202
  } catch (e) {
84
203
  Coon.log.log('Incorrect JSON state');
85
- return;
86
- }
87
-
88
- if (Ext.isArray(currentReportState)) {
89
- const stateMap = new Map();
90
- currentReportState.forEach((e) => stateMap.set(e.columnId, e));
91
- const fixedColumns = [];
92
-
93
- columns.forEach((column) => {
94
- if (column.isHidden()) {
95
- return;
96
- }
97
- const state = stateMap.get(column.dataIndex);
98
- if (state) {
99
- if (!column.up().getMenu().child('#columnItem')) {
100
- return;
101
- }
102
- if (state.hidden && column.isHideable() && !column.isHidden()) {
103
- column.setVisible(false);
104
- }
105
- column.setWidth(state.width ? state.width : 100);
106
- columnHeader.moveBefore(column, columnHeader.getComponent(state.position));
107
- }
108
- if (column.fixedPosition >= 0) {
109
- fixedColumns.push(column);
110
- }
111
- });
112
-
113
- if (!Ext.isEmpty(fixedColumns)) {
114
- fixedColumns.forEach((column) => {
115
- columnHeader.moveBefore(column, columnHeader.getComponent(column.fixedPosition));
116
- });
117
- }
118
204
  }
119
205
  }
206
+ return {savedReportState, deserializedState};
120
207
  },
121
208
 
122
209
  saveNewState(state) {
@@ -130,4 +217,28 @@ Ext.define('Coon.report.plugin.grid.ReportColumnStatePlugin', {
130
217
  localStorage.setItem('reportsState', newState);
131
218
  this.checkEnableAutoSize();
132
219
  },
220
+
221
+ registerApi() {
222
+ this.report.registerApi('resetReportColumnState', {
223
+ menuItemText: 'Сбросить настройки внешнего вида',
224
+ removeSavedStateHandler: this.removeSavedState,
225
+ resetStateEnable: this.resetStateEnable.bind(this),
226
+ scope: this,
227
+ });
228
+ },
229
+
230
+ removeSavedState() {
231
+ const {deserializedState} = this.getSavedState();
232
+ delete deserializedState[this.report.reportId];
233
+ localStorage.setItem('reportsState', JSON.stringify(deserializedState));
234
+
235
+ this.suspendStateSave = true;
236
+ this.applyState(this.defaultReportState);
237
+ this.suspendStateSave = false;
238
+ },
239
+
240
+ resetStateEnable() {
241
+ const {savedReportState} = this.getSavedState();
242
+ return savedReportState;
243
+ },
133
244
  });
@@ -8,6 +8,7 @@ Ext.define('Coon.report.toolbar.OptionsMenuButton', {
8
8
  clearFilters: true,
9
9
  resetReport: true,
10
10
  advancedSearch: false,
11
+ resetReportColumnState: true,
11
12
  },
12
13
 
13
14
  iconCls: 'svg-icon-ellipsis',
@@ -34,6 +35,10 @@ Ext.define('Coon.report.toolbar.OptionsMenuButton', {
34
35
  {
35
36
  itemId: 'advancedSearch',
36
37
  handler: 'onAdvancedSearch',
38
+ },
39
+ {
40
+ itemId: 'resetReportColumnState',
41
+ hidden: true,
37
42
  }
38
43
  ],
39
44
  },
@@ -47,6 +52,7 @@ Ext.define('Coon.report.toolbar.OptionsMenuButton', {
47
52
  this.clearFiltersInit(menu);
48
53
  this.resetReportInit(menu);
49
54
  this.advancedSearchInit(menu);
55
+ this.resetColumnStateInit(menu);
50
56
  },
51
57
 
52
58
  clearFiltersInit(menu) {
@@ -78,6 +84,20 @@ Ext.define('Coon.report.toolbar.OptionsMenuButton', {
78
84
  }
79
85
  },
80
86
 
87
+ resetColumnStateInit(menu) {
88
+ const resetColumnStateMenuItem = menu.down('#resetReportColumnState');
89
+ const reportPanel = this.getReportPanel();
90
+ const stateApi = reportPanel.getApi('resetReportColumnState');
91
+ resetColumnStateMenuItem.setVisible(this.getResetReportColumnState() && stateApi);
92
+ if (stateApi) {
93
+ resetColumnStateMenuItem.handler = stateApi.removeSavedStateHandler.bind(stateApi.scope);
94
+ resetColumnStateMenuItem.setText(stateApi.menuItemText);
95
+ }
96
+ if (resetColumnStateMenuItem.isVisible()) {
97
+ resetColumnStateMenuItem.setDisabled(!stateApi.resetStateEnable());
98
+ }
99
+ },
100
+
81
101
  // Отключить фильтры в колонках
82
102
  onClearFilters() {
83
103
  if (Ext.isFunction(this.grid.clearFilters)) {
@@ -13,8 +13,8 @@ Ext.define('Coon.uielement.component.UiCustomController', {
13
13
  Coon.log.debug(` [Error]UiCustomController.init - view not found or view.on is not a function`);
14
14
  return;
15
15
  }
16
- this.setCustomPanelTitle();
17
16
  view.on('afterrender', function() {
17
+ this.setCustomPanelTitle();
18
18
  this.processSecurePoints(view);
19
19
  }, this);
20
20
  },
@@ -161,6 +161,7 @@ Ext.define('Coon.uielement.component.UiCustomController', {
161
161
  if (!typeof title === 'string') {
162
162
  return;
163
163
  }
164
+ this.getView().titleText = title;
164
165
  this.getView().fireEvent('titlechange', this.getView(), title);
165
166
  if (
166
167
  this.getView().tab &&
@@ -57,17 +57,41 @@ Ext.define('Coon.uielement.component.UiCustomPanel', {
57
57
  copyLink: false,
58
58
 
59
59
  initComponent() {
60
- let data = Object.assign(this.viewModel && this.viewModel.data || {}, {
60
+ let rowData = Object.assign(this.viewModel && this.viewModel.data || {}, {
61
61
  name: 'UiCustomPanel',
62
62
  });
63
63
  if (!this.inheritViewModel) {
64
- data = Ext.applyIf(data, this.getViewModelData());
65
64
  this.viewModel = Ext.create('Ext.app.ViewModel');
65
+
66
+ rowData = Ext.applyIf(rowData, this.getViewModelData());
67
+ const data = this.convertRowData(rowData);
68
+
66
69
  this.viewModel.setData(data);
67
70
  }
68
71
  this.callParent();
69
72
  },
70
73
 
74
+ convertRowData(rowData) {
75
+ const data = {};
76
+
77
+ let objectCursor;
78
+ Object.entries(rowData).forEach(([key, value]) => {
79
+ if (key.includes('.')) {
80
+ const parts = key.split('.');
81
+ objectCursor = data;
82
+ for (const part of parts) {
83
+ objectCursor[part] = objectCursor[part] || {};
84
+ objectCursor = objectCursor[part];
85
+ }
86
+ objectCursor[parts[parts.length - 1]] = value;
87
+ } else {
88
+ data[key] = value;
89
+ }
90
+ });
91
+
92
+ return data;
93
+ },
94
+
71
95
  getViewModelData() {
72
96
  const data = {};
73
97
  const addDoInitSupportPlugin = this.plugins && this.plugins.find((plugin) => plugin.ptype === 'AddDoInitSupportPlugin');
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '3.0.46',
3
+ number: '3.0.48',
4
4
  });