ru.coon 3.0.16 → 3.0.17

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,7 @@
1
+ # Version 3.0.17, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/0dcb35eed6ba22aaca715caec2b37099e186dcfa)
2
+ * HT-12960 #feat доработка пункта контекстного меню с кнопками калькулятор ([ed4cdb], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/ed4cdbe1f7152f362c35896adea0131ba76b917c))
3
+ * update: CHANGELOG.md ([bccfcb], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/bccfcbbaa044a23a919d7a572b562a113e750ed2))
4
+
1
5
  # Version 3.0.16, [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/8c523f942539c21495d27f79366c3429cfbba26a)
2
6
  * ## Fixes
3
7
  * <span style='color:red'>fix</span> ([e33cdc], [link](http://gitlab-dbr.sigma-it.local/dbr/ru.coon/-/commit/e33cdc8c5ee5899795915cfe174ad874a952b2bf))
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "ru.coon"
5
5
  },
6
6
  "description": "",
7
- "version": "3.0.16",
7
+ "version": "3.0.17",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+http://gitlab-dbr.sigma-it.local/dbr/ru.coon"
@@ -4,63 +4,110 @@ Ext.define('Coon.report.component.calculator.ReportCalculatorMenuItem', {
4
4
  xtype: 'ReportCalculatorMenuItem',
5
5
  cls: 'ReportCalculatorMenuItem',
6
6
  defaultListenerScope: true,
7
+ referenceHolder: true,
8
+
7
9
  viewModel: {
8
10
  data: {
9
- isHiddenAll: false,
11
+ oneCellValue: 0,
12
+ summaryValue: 0,
13
+ oneCellValueVisible: false,
14
+ summaryValueVisible: false,
15
+ valueVariant: 'cell',
16
+ },
17
+ formulas: {
18
+ isHiddenAll: {
19
+ get: function(data) {
20
+ return !data('oneCellValueVisible') && !data('summaryValueVisible');
21
+ },
22
+ },
10
23
  },
11
24
  },
12
25
  margin: '0 0 0 48',
13
26
  bodyPadding: '5 0 0 0',
14
- layout: {type: 'hbox'},
27
+ layout: {type: 'hbox', align: 'stretch'},
15
28
  items: [
16
29
  {
17
30
  xtype: 'container',
18
- layout: {type: 'hbox', align: 'stretch'},
19
- defaults: {
20
- margin: '0 0 0 6',
21
- cls: 'calculator-contextmenu-button-type1',
22
- },
31
+ flex: 1,
32
+ layout: {type: 'vbox', align: 'stretch'},
23
33
  items: [
24
34
  {
25
- xtype: 'button',
26
- margin: '0 0 0 0',
27
- iconCls: 'svg-icon svg-icon-calculator',
28
- eventName: 'openCalculator',
29
- handler: 'onClickButton',
30
- },
31
- {
32
- xtype: 'button',
33
- text: 'M=',
34
- eventName: 'setMemory',
35
- handler: 'onClickButton',
36
- width: 46,
35
+ xtype: 'radiogroup',
36
+ simpleValue: true,
37
37
  hidden: true,
38
+ columns: 1,
39
+ vertical: true,
38
40
  bind: {
39
41
  hidden: '{isHiddenAll}',
42
+ value: '{valueVariant}',
40
43
  },
44
+ items: [
45
+ {
46
+ bind: {
47
+ boxLabel: '{oneCellValue}',
48
+ visible: '{oneCellValueVisible}',
49
+ },
50
+ inputValue: 'cell',
51
+ },
52
+ {
53
+ bind: {
54
+ boxLabel: '<span class="sum-icon">&sum;</span> {summaryValue}',
55
+ visible: '{summaryValueVisible}',
56
+ },
57
+ inputValue: 'range',
58
+ }
59
+ ],
41
60
  },
42
61
  {
43
- xtype: 'button',
44
- text: 'M+',
45
- eventName: 'addMemory',
46
- handler: 'onClickButton',
47
- width: 46,
48
- hidden: true,
49
- bind: {
50
- hidden: '{isHiddenAll}',
51
- },
52
- },
53
- {
54
- xtype: 'button',
55
- text: 'M-',
56
- eventName: 'subtractMemory',
57
- handler: 'onClickButton',
58
- width: 46,
59
- margin: '0 6 0 6',
60
- hidden: true,
61
- bind: {
62
- hidden: '{isHiddenAll}',
62
+ xtype: 'container',
63
+ layout: {type: 'hbox', align: 'stretch'},
64
+ defaults: {
65
+ margin: '0 0 0 6',
66
+ cls: 'calculator-contextmenu-button-type1',
63
67
  },
68
+ items: [
69
+ {
70
+ xtype: 'button',
71
+ margin: '0 0 0 0',
72
+ iconCls: 'svg-icon svg-icon-calculator',
73
+ eventName: 'openCalculator',
74
+ handler: 'onClickButton',
75
+ },
76
+ {
77
+ xtype: 'button',
78
+ text: 'M=',
79
+ eventName: 'setMemory',
80
+ handler: 'onClickButton',
81
+ width: 46,
82
+ hidden: true,
83
+ bind: {
84
+ hidden: '{isHiddenAll}',
85
+ },
86
+ },
87
+ {
88
+ xtype: 'button',
89
+ text: 'M+',
90
+ eventName: 'addMemory',
91
+ handler: 'onClickButton',
92
+ width: 46,
93
+ hidden: true,
94
+ bind: {
95
+ hidden: '{isHiddenAll}',
96
+ },
97
+ },
98
+ {
99
+ xtype: 'button',
100
+ text: 'M-',
101
+ eventName: 'subtractMemory',
102
+ handler: 'onClickButton',
103
+ width: 46,
104
+ margin: '0 6 0 6',
105
+ hidden: true,
106
+ bind: {
107
+ hidden: '{isHiddenAll}',
108
+ },
109
+ }
110
+ ],
64
111
  }
65
112
  ],
66
113
  },
@@ -85,11 +132,29 @@ Ext.define('Coon.report.component.calculator.ReportCalculatorMenuItem', {
85
132
  },
86
133
 
87
134
  onClickButton(button) {
88
- this.fireEvent(button.eventName, button.text);
135
+ const vm = this.getViewModel();
136
+ const value = vm.get('valueVariant') === 'cell' ?
137
+ vm.get('oneCellValue'):
138
+ vm.get('summaryValue');
139
+
140
+ this.fireEvent(button.eventName, button.text, value);
89
141
  },
90
142
 
91
- setHiddenMemoryButtons(isHidden) {
92
- this.getViewModel().set('isHiddenAll', isHidden);
143
+ /**
144
+ * Установка свойств, влияющих на видимость радиокнопок
145
+ * @param {boolean} oneCellValueVisible
146
+ * @param {boolean} summaryValueVisible
147
+ */
148
+ setVisibleValueVariants(oneCellValueVisible, summaryValueVisible) {
149
+ this.getViewModel().set({
150
+ oneCellValueVisible,
151
+ summaryValueVisible,
152
+ });
153
+ if (!oneCellValueVisible && summaryValueVisible) {
154
+ this.getViewModel().set('valueVariant', 'range');
155
+ } else if (oneCellValueVisible && !summaryValueVisible) {
156
+ this.getViewModel().set('valueVariant', 'cell');
157
+ }
93
158
  },
94
159
 
95
160
  isItemHidden() {
@@ -98,4 +163,15 @@ Ext.define('Coon.report.component.calculator.ReportCalculatorMenuItem', {
98
163
  isItemDisabled() {
99
164
  return false;
100
165
  },
166
+ /**
167
+ * Установка значений
168
+ * @param {number} value значение ячейки
169
+ * @param {number} summaryValue сумма значений ячеек по выделенным записям
170
+ */
171
+ setValueByContext(value, summaryValue) {
172
+ this.getViewModel().set({
173
+ oneCellValue: `${value}`,
174
+ summaryValue: `${summaryValue}`,
175
+ });
176
+ },
101
177
  });
@@ -38,4 +38,14 @@
38
38
  padding: 6px 6px;
39
39
  }
40
40
  }
41
+
42
+ .x-form-item-body-default {
43
+ min-height: 22px !important;
44
+ }
45
+ .x-form-cb-wrap-default {
46
+ height: 24px !important;
47
+ }
48
+ .sum-icon {
49
+ color: gray !important;
50
+ }
41
51
  }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * todo: Вынести бизнеслогику и хранение стейтов в отдельный класс singleton.
3
+ */
1
4
  Ext.define('Coon.report.component.calculator.ReportCalculatorPanel', {
2
5
  extend: 'Ext.panel.Panel',
3
6
  alias: 'widget.ReportCalculatorPanel',
@@ -0,0 +1,73 @@
1
+ Ext.define('Coon.report.component.settings.property.ReportPropertyForm', {
2
+ extend: 'Ext.panel.Panel',
3
+ xtype: 'ReportPropertyForm',
4
+ layout: {
5
+ type: 'vbox',
6
+ align: 'stretch',
7
+ },
8
+ padding: 16,
9
+ bind: {
10
+ disabled: '{!reportPropertyGrid.selection}',
11
+ },
12
+ items: [
13
+ {
14
+ xtype: 'panel',
15
+ itemId: 'editPropertyForm',
16
+ layout: {
17
+ type: 'vbox',
18
+ align: 'stretch',
19
+ },
20
+ reference: 'propForm',
21
+ defaults: {
22
+ margin: 8,
23
+ },
24
+ items: [
25
+ {
26
+ xtype: 'panel',
27
+ itemId: 'description',
28
+ flex: 1,
29
+ frame: true,
30
+ bodyStyle: {
31
+ fontSize: '16px',
32
+ padding: '8px',
33
+ lineHeight: '1.2',
34
+ color: 'gray',
35
+ wordBreak: 'break-word',
36
+ },
37
+ },
38
+ {
39
+ xtype: 'textarea',
40
+ name: 'value',
41
+ flex: 1,
42
+ // anchor: '95%',
43
+ allowBlank: false,
44
+ grow: true,
45
+ minHeight: 100,
46
+ fieldLabel: 'значение',
47
+ bind: {
48
+ disabled: '{reportPropertyGrid.selection.isDeleted}',
49
+ value: '{locals.propValue}',
50
+ },
51
+ }
52
+ ],
53
+ buttons: [
54
+ {
55
+ text: 'удалить',
56
+ handler: 'onRemoveProp',
57
+ bind: {
58
+ text: '{reportPropertyGrid.selection.isDeleted ? "восстановить" : "удалить"}',
59
+ },
60
+ },
61
+ {
62
+ text: 'подтвердить',
63
+ disabled: true,
64
+ itemId: 'submit',
65
+ handler: 'onChangeValue',
66
+ bind: {
67
+ disabled: '{locals.originalPropValue === locals.propValue}',
68
+ },
69
+ }
70
+ ],
71
+ }
72
+ ],
73
+ });
@@ -0,0 +1,42 @@
1
+ Ext.define('Coon.report.component.settings.property.ReportPropertyGrid', {
2
+ extend: 'Ext.grid.Panel',
3
+ xtype: 'ReportPropertyGrid',
4
+ layout: 'fit',
5
+ store: {
6
+ type: 'json',
7
+ sorters: [
8
+ {
9
+ property: 'key',
10
+ direction: 'ASC',
11
+ }
12
+ ],
13
+ },
14
+ viewConfig: {
15
+ getRowClass(record) {
16
+ const {isDeleted, isNew} = record.getData();
17
+ if (isDeleted) {
18
+ return 'is-deleted';
19
+ }
20
+ if (isNew) {
21
+ return 'is-new';
22
+ }
23
+ },
24
+ },
25
+ columns: {
26
+ defaults: {xtype: 'HintColumn', hintProperty: 'description', sortable: false, menuDisabled: true, flex: 1},
27
+ items: [
28
+ {
29
+ dataIndex: 'key',
30
+ text: 'свойство',
31
+ maxWidth: 250,
32
+ renderer(v, mt, rec) {
33
+ if (rec.get('dict')) {
34
+ mt.tdStyle = 'color: blue;font-weight: bold';
35
+ }
36
+ return v;
37
+ },
38
+ },
39
+ {dataIndex: 'value', text: 'значение', minWidth: 120}
40
+ ],
41
+ },
42
+ });
@@ -38,10 +38,65 @@ Ext.define('Coon.report.plugin.grid.CalculatorPlugin', {
38
38
  isVisibleMemoryButtons = this.canBeingNumber(this.columnValue)!==false;
39
39
  }
40
40
  if (showReportCalculator) {
41
- this.calculatorButtons.setHiddenMemoryButtons(!isVisibleMemoryButtons);
41
+ const selected = this.getSelected();
42
+ const dataIndex = this.column && this.column.dataIndex;
43
+ this.calculatorButtons.setVisibleValueVariants(
44
+ isVisibleMemoryButtons,
45
+ selected.length > 1 && this.atLeastOneCanBeingNumber(selected, dataIndex)
46
+ );
47
+ this.calculatorButtons.setValueByContext(this.columnValue, this.sumFieldValueByRecords(selected, dataIndex));
42
48
  }
43
49
  },
44
50
 
51
+ /**
52
+ *
53
+ * @param {Array<Ext.data.Model|Object>} selected
54
+ * @param {string} dataIndex
55
+ * @returns {boolean}
56
+ */
57
+ atLeastOneCanBeingNumber(selected, dataIndex) {
58
+ return Array.isArray(selected) && selected.reduce((acc, record) => {
59
+ const cellValue = record.isModel ? record.get(dataIndex) : record[dataIndex];
60
+ return acc? true: this.canBeingNumber(cellValue);
61
+ }, false);
62
+ },
63
+
64
+ /**
65
+ *
66
+ * @param {Array<Ext.data.Model|Object>} selected
67
+ * @param {string} dataIndex
68
+ * @returns {number}
69
+ */
70
+ sumFieldValueByRecords(selected, dataIndex) {
71
+ return selected.reduce((acc, record) => {
72
+ const cellValue = record.isModel ? record.get(dataIndex) : record[dataIndex];
73
+
74
+ return window.Decimal(acc).plus(window.Decimal(this.canBeingNumber(cellValue) !== false ? cellValue : 0));
75
+ }, 0);
76
+ },
77
+
78
+ getSelected() {
79
+ const sm = this.grid.getSelectionModel();
80
+ const checkColumnName = this.grid.checkColumn || this.grid.ownerCt.checkColumn ||
81
+ this.grid.ownerCt.ownerCt.checkColumn || (this.grid.properties && this.grid.properties['checkColumn']);
82
+ const checkedRecords = this.grid.getCheckedRecords();
83
+ let selectedRecords = [];
84
+ if (checkColumnName) {
85
+ const store = this.grid.getStore();
86
+ const records = store.getRange(0, store.getCount());
87
+ for (let i = 0; i < records.length; i++) {
88
+ if (records[i].get(checkColumnName) === true) {
89
+ selectedRecords.push(records[i]);
90
+ }
91
+ }
92
+ } else if (checkedRecords && checkedRecords.length) {
93
+ selectedRecords = checkedRecords;
94
+ } else {
95
+ selectedRecords = Coon.Function.getDataFromSelectionModel(sm, false);
96
+ }
97
+ return selectedRecords;
98
+ },
99
+
45
100
  canBeingNumber(cellValue) {
46
101
  if (typeof cellValue === 'number' && !isNaN(cellValue)) {
47
102
  return cellValue;
@@ -60,20 +115,19 @@ Ext.define('Coon.report.plugin.grid.CalculatorPlugin', {
60
115
  return false;
61
116
  }
62
117
  },
63
- setCalcOperation(text) {
118
+ setCalcOperation(text, value) {
119
+ Coon.log.log('setCalcOperation', {text, value});
64
120
  const vm = Coon.report.component.calculator.ReportCalculatorPanel.getViewModel();
65
- const cellValue = Ext.isString(this.columnValue) ? Number(this.columnValue.replace(',', '.').replaceAll(' ', '')):
66
- this.columnValue;
67
121
  const memory = vm.get('memory') || 0;
68
122
  switch (text) {
69
123
  case 'M=':
70
- vm.set('memory', cellValue);
124
+ vm.set('memory', value);
71
125
  break;
72
126
  case 'M+':
73
- vm.set('memory', window.Decimal(memory).plus(window.Decimal(cellValue)));
127
+ vm.set('memory', window.Decimal(memory).plus(window.Decimal(value)));
74
128
  break;
75
129
  case 'M-':
76
- vm.set('memory', window.Decimal(memory).minus(window.Decimal(cellValue)));
130
+ vm.set('memory', window.Decimal(memory).minus(window.Decimal(value)));
77
131
  break;
78
132
  }
79
133
  this.closeMenu();
@@ -86,7 +86,8 @@ Ext.define('Coon.report.plugin.grid.GridContextMenu', {
86
86
  },
87
87
 
88
88
  cellContextMenuHandler: function(view, td, cellIndex, record, tr, rowIndex, event) {
89
- this.grid.getSelectionModel().select(rowIndex);
89
+ // В режиме Multi выделение записи где возникло событие контекстного меню приводит к отмене всех выделенных строк
90
+ // this.grid.getSelectionModel().select(rowIndex);
90
91
  if (record) {
91
92
  this.showContextMenu({view, td, cellIndex, record, tr, rowIndex, event, hasContext: true});
92
93
  }
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  Ext.define('Coon.version', {
2
2
  singleton: true,
3
- number: '3.0.16',
3
+ number: '3.0.17',
4
4
  });