ru.coon 2.6.6 → 2.6.7

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 (31) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/index.js +0 -1
  3. package/package.json +1 -1
  4. package/src/Function.js +1 -1
  5. package/src/common/component/formeditor/UiCFCard.js +86 -0
  6. package/src/common/component/formeditor/UiCFCardsGrid.js +69 -0
  7. package/src/common/component/formeditor/UiCFCell.js +12 -0
  8. package/src/common/component/formeditor/UiCFCellController.js +236 -0
  9. package/src/common/component/formeditor/UiCFCheckboxGroup.js +53 -0
  10. package/src/common/component/formeditor/UiCFContainer.js +15 -0
  11. package/src/common/component/formeditor/UiCFContainerController.js +217 -0
  12. package/src/common/component/formeditor/UiCFFieldsConfig.js +342 -0
  13. package/src/common/component/formeditor/UiCFRadioGrid.js +70 -0
  14. package/src/common/component/formeditor/UiCFRadioGroup.js +53 -0
  15. package/src/common/component/formeditor/UiCFReportField.js +48 -0
  16. package/src/common/component/formeditor/UiCFRow.js +13 -0
  17. package/src/common/component/formeditor/UiCFRowController.js +155 -0
  18. package/src/common/component/formeditor/UiCFSegmentedButton.js +62 -0
  19. package/src/common/component/formeditor/UiCFSegmentedButtonGrid.js +70 -0
  20. package/src/common/component/formeditor/UiCFSettingsWindow.js +62 -0
  21. package/src/common/component/formeditor/UiCFSpacer.js +8 -0
  22. package/src/common/component/formeditor/UiCFTab.js +51 -0
  23. package/src/common/component/formeditor/UiCustomForm.js +33 -0
  24. package/src/common/component/formeditor/UiCustomFormController.js +6 -0
  25. package/src/common/component/formeditor/UiCustomFormEditor.js +191 -0
  26. package/src/common/component/formeditor/UiCustomFormEditor.scss +13 -0
  27. package/src/common/component/formeditor/UiCustomFormEditorController.js +654 -0
  28. package/src/common/component/formeditor/UiCustomFormEditorView.js +7 -0
  29. package/src/report/component/settings/plugin/ReportFormPluginPanelController.js +1 -1
  30. package/src/report/plugin/grid/ReportColumnStatePlugin.js +18 -2
  31. package/src/version.js +1 -1
@@ -0,0 +1,48 @@
1
+ Ext.define('Coon.common.component.formeditor.UiCFReportField', {
2
+ extend: 'Ext.form.field.ComboBox',
3
+ xtype: 'UiCFReportField',
4
+ controller: {
5
+ refField: null,
6
+ init(view) {
7
+ view.on('render', (view) => {
8
+ const form = view.up('[reference="settingsForm"]');
9
+ if (!form) {
10
+ Ext.Msg.alert('Ошибка', 'Не удалось найти форму');
11
+ return;
12
+ }
13
+ const refField = form.down('[itemId="reportsList"]');
14
+ if (!refField) {
15
+ Ext.Msg.alert('Ошибка', 'Не удалось найти поле - список отчетов');
16
+ return;
17
+ }
18
+ this.refField = refField;
19
+ this.refField.on('change', this.onChangeRefField, this);
20
+ }, this);
21
+ },
22
+ onChangeRefField(field, value) {
23
+ const combo = this.getView();
24
+ combo.getStore().removeAll();
25
+ if (value) {
26
+ Coon.util.promisifyCmd('Coon.report.command.GetDynamicReportDataCommand',
27
+ 'REPORT_FIELDS',
28
+ '[{"type":"REPORT_CD","value":"'+value+'"}]')
29
+ .then((data) => {
30
+ if (Ext.isArray(data.list)) {
31
+ combo.getStore().loadData(data.list);
32
+ }
33
+ })
34
+ .catch((error) => {
35
+ Coon.log.debug(error);
36
+ Ext.Msg.alert(error.toString());
37
+ });
38
+ }
39
+ },
40
+ },
41
+ queryMode: 'local',
42
+ displayField: 'DESCR',
43
+ valueField: 'REPORT_FIELD_CD',
44
+ store: {
45
+ type: 'json',
46
+ data: [],
47
+ },
48
+ });
@@ -0,0 +1,13 @@
1
+ /* global Ext */
2
+ Ext.define('Coon.common.component.formeditor.UiCFRow', {
3
+ extend: 'Ext.container.Container',
4
+ controller: 'UiCFRowController',
5
+ xtype: 'UiCFRow',
6
+ minHeight: 20,
7
+ layout: {
8
+ type: 'hbox',
9
+ align: 'stretch',
10
+ },
11
+ items: [
12
+ ],
13
+ });
@@ -0,0 +1,155 @@
1
+ Ext.define('Coon.common.component.formeditor.UiCFRowController', {
2
+ extend: 'Ext.app.ViewController',
3
+ alias: 'controller.UiCFRowController',
4
+ menuItems: {},
5
+
6
+ init() {
7
+ this.setDefaultMenuItems();
8
+ },
9
+
10
+ setDefaultMenuItems() {
11
+ this.menuItems = {
12
+ up: {text: 'вверх', iconCls: 'fa fa-arrow-up', handler: this.moveRowUp.bind(this)},
13
+ down: {text: 'вниз', iconCls: 'fa fa-arrow-down', handler: this.moveRowDown.bind(this)},
14
+ };
15
+ },
16
+ getCountRows() {
17
+ return this.getUiCFContainerController().getCountRows();
18
+ },
19
+ getRowIndex() {
20
+ return this.getUiCFContainerController().getRowIndex(this.getView());
21
+ },
22
+ getMenuItems(activeCell) {
23
+ const me = this;
24
+ const menuItems = [{
25
+ text: 'в строку', iconCls: 'fa fa-plus',
26
+ menu: Coon.UiCFFieldsConfig.getFieldsTypes().map((item) => {
27
+ return {
28
+ text: item.description,
29
+ iconCls: '',
30
+ handler: () => {
31
+ me.addCell(item.type, activeCell);
32
+ },
33
+ };
34
+ }),
35
+ }];
36
+ const count = this.getCountRows();
37
+ if (count > 1) {
38
+ const index = this.getRowIndex() + 1;
39
+ if (index > 1) {
40
+ menuItems.push(this.menuItems.up);
41
+ }
42
+ if (count > index) {
43
+ menuItems.push(this.menuItems.down);
44
+ }
45
+ }
46
+ return menuItems;
47
+ },
48
+
49
+ getUiCFContainerController() {
50
+ return this.getView().up('UiCFContainer').getController();
51
+ },
52
+
53
+ setFlex() {
54
+ const cntr = this;
55
+ Ext.Msg.prompt('Относительный размер', 'Укажите размер:', function(btn, text) {
56
+ if (btn == 'ok') {
57
+ if (text && Ext.isNumber(Number(text))) {
58
+ cntr.getView().setFlex(Number(text));
59
+ cntr.getView().up('UiCFContainer').updateLayout();
60
+ } else {
61
+ Ext.Msg.show({
62
+ title: 'Ошибка',
63
+ message: 'Значение должно быть числом от 0',
64
+ buttons: Ext.Msg.YES,
65
+ icon: Ext.Msg.ERROR,
66
+ });
67
+ return false;
68
+ }
69
+ }
70
+ }, this, false, this.getView().flex || 0);
71
+ },
72
+
73
+ addCell(type, activeCell) {
74
+ let cfg = null;
75
+ if (!Ext.isObject(type)) {
76
+ cfg = {
77
+ xtype: 'UiCFCell',
78
+ items: [Ext.apply({
79
+ xtype: type,
80
+ name: type + '-' + (this.getUiCFContainerController().getCountElemsByXtype(type) + 1),
81
+ cls: 'componentTarget',
82
+ }, Coon.UiCFFieldsConfig.getFieldCfg(type))],
83
+ };
84
+ } else {
85
+ cfg = type;
86
+ }
87
+ const view = this.getView();
88
+ if (activeCell) {
89
+ view.insert(this.getCellIndexInRow(activeCell) + 1, cfg);
90
+ activeCell.getController().setResizer();
91
+ } else {
92
+ view.add(cfg);
93
+ }
94
+ },
95
+
96
+ removeCell(cell) {
97
+ this.getViewModel().set('focusedField', null);
98
+ if (this.getCountCells() > 1) {
99
+ this.getView().remove(this.getCellIndexInRow(cell));
100
+ } else {
101
+ this.getUiCFContainerController().removeRow(this.getView());
102
+ }
103
+ },
104
+
105
+ moveRowUp(direction) {
106
+ this.getUiCFContainerController().moveRow(this.getView(), 'up');
107
+ },
108
+
109
+ moveRowDown(direction) {
110
+ this.getUiCFContainerController().moveRow(this.getView(), 'down');
111
+ },
112
+
113
+ moveCell(cell, direction) {
114
+ const cellIndexInRow = this.getCellIndexInRow(cell);
115
+ const view = this.getView();
116
+ const countCells = this.getCountCells();
117
+ if (countCells > 1) {
118
+ if (direction === 'left') {
119
+ view.moveBefore(cell, view.items.getAt(cellIndexInRow - 1));
120
+ } else {
121
+ view.moveAfter(cell, view.items.getAt(cellIndexInRow + 1));
122
+ }
123
+ }
124
+ },
125
+
126
+ getCountCells() {
127
+ return this.getView().items.length;
128
+ },
129
+
130
+ getCellIndexInRow(cell) {
131
+ return this.getView().items.indexOfKey(cell.id);
132
+ },
133
+
134
+ getCells() {
135
+ return this.getView().items.getRange();
136
+ },
137
+
138
+ layoutCellsInRow() {
139
+ this.getCells().forEach((cell) => {
140
+ cell.setFlex(200);
141
+ });
142
+ this.getView().updateLayout();
143
+ },
144
+
145
+ layoutByTemplate() {
146
+ const uiCFContainerController = this.getUiCFContainerController();
147
+ const cells = this.getCells();
148
+ const flexMatrix = cells.map((cell) => cell.flex);
149
+ uiCFContainerController.getRows().filter(
150
+ (row) => row.items.length === cells.length && row.id !== this.getView().id
151
+ ).forEach((row) => row.items.getRange().forEach((cell, index) => cell.setFlex(flexMatrix[index])));
152
+ this.getView().updateLayout();
153
+ },
154
+
155
+ });
@@ -0,0 +1,62 @@
1
+ /* global Ext */
2
+ Ext.define('Coon.common.component.formeditor.UiCFSegmentedButton', {
3
+ extend: 'Ext.button.Segmented',
4
+ xtype: 'UiCFSegmentedButton',
5
+ style: {
6
+ maxHeight: '30px',
7
+ },
8
+ getName() {
9
+ return this.name;
10
+ },
11
+ setName(name) {
12
+ this.name = name;
13
+ },
14
+ controller: {
15
+ init(view) {
16
+ let i = 1;
17
+ if (view.initialConfig && !view.initialConfig.checkOptions) {
18
+ if (view.initialConfig && view.initialConfig.countCards) {
19
+ view.initialConfig.countCards.forEach((setting, index) => {
20
+ let item = view.items.getAt(view.items.findIndex('itemId', setting.itemId));
21
+ if (!item) {
22
+ item = view.add({
23
+ itemId: setting.itemId,
24
+ value: setting.value,
25
+ });
26
+ }
27
+ if (setting.text) {
28
+ item.setText(setting.text);
29
+ }
30
+ if (setting.value) {
31
+ item.value = setting.value;
32
+ } else {
33
+ item.value = i++;
34
+ }
35
+ });
36
+ if (view.initialConfig.countCards.length < view.items.getCount()) {
37
+ const ids = view.initialConfig.countCards.map((item) => item.itemId);
38
+ view.items.items.forEach((item) => {
39
+ if (ids.indexOf(item.itemId) < 0) {
40
+ view.remove(item);
41
+ }
42
+ });
43
+ }
44
+ } else {
45
+ const itemId = 'UiCFSegmented_' + Ext.id().replace('-', '_');
46
+ view.countCards = [
47
+ {
48
+ 'itemId': itemId,
49
+ 'value': i,
50
+ }
51
+ ],
52
+ view.add({
53
+ 'itemId': itemId,
54
+ 'value': i,
55
+ });
56
+ i++;
57
+ }
58
+ }
59
+ },
60
+ },
61
+ items: [],
62
+ });
@@ -0,0 +1,70 @@
1
+ /* global Ext */
2
+ Ext.define('Coon.common.component.formeditor.UiCFSegmentedButtonGrid', {
3
+ extend: 'Ext.grid.Panel',
4
+ xtype: 'UiCFSegmentedButtonGrid',
5
+ flex: 1,
6
+ title: 'Значения',
7
+ minHeight: 100,
8
+ controller: {
9
+ init(view) {
10
+ const vm = this.getViewModel();
11
+ vm.getStore('cardsStore').on('datachanged', (store) => {
12
+ vm.set('dataCount', store.data.length);
13
+ }, this);
14
+ if (view.initialConfig && view.initialConfig.value) {
15
+ vm.getStore('cardsStore').loadData(view.initialConfig.value);
16
+ }
17
+ view.getFormData = this.getFormData.bind(this);
18
+ },
19
+ getFormData() {
20
+ return this.getViewModel().getStore('cardsStore').getRange().map((rec) => {
21
+ return {text: rec.get('text'), itemId: rec.get('itemId'), value: rec.get('value')};
22
+ });
23
+ },
24
+ addRow() {
25
+ this.getViewModel().getStore('cardsStore').add({itemId: 'UiCFSegmented_' + Ext.id().replace('-', '_')});
26
+ },
27
+ deleteRow() {
28
+ this.getViewModel().getStore('cardsStore').remove(this.getViewModel().get('selection'));
29
+ },
30
+ },
31
+ viewModel: {
32
+ data: {
33
+ selection: null,
34
+ dataCount: 1,
35
+ },
36
+ stores: {
37
+ cardsStore: {
38
+ type: 'json',
39
+ fields: ['text', 'itemId', 'value'],
40
+ data: [
41
+ ],
42
+ },
43
+ },
44
+ },
45
+ tbar: [
46
+ {
47
+ text: 'Добавить',
48
+ handler: 'addRow',
49
+ },
50
+ {
51
+ text: 'Удалить',
52
+ handler: 'deleteRow',
53
+ bind: {
54
+ disabled: '{!selection || dataCount < 2}',
55
+ },
56
+ }
57
+ ],
58
+ bind: {
59
+ store: '{cardsStore}',
60
+ selection: '{selection}',
61
+ },
62
+ columns: [
63
+ {xtype: 'rownumberer'},
64
+ {dataIndex: 'text', text: 'Заголовок', flex: 2, editor: {xtype: 'textfield'}},
65
+ {dataIndex: 'value', text: 'Значение', flex: 1, editor: {xtype: 'textfield'}}
66
+ ],
67
+ plugins: [
68
+ {ptype: 'cellediting'}
69
+ ],
70
+ });
@@ -0,0 +1,62 @@
1
+ Ext.define('Coon.common.component.formeditor.UiCFSettingsWindow', {
2
+ extend: 'Ext.window.Window',
3
+ xtype: 'UiCFSettingsWindow',
4
+ closable: true,
5
+ closeAction: 'hide',
6
+ width: 500,
7
+ title: 'Настройки формы',
8
+ height: 220,
9
+ modal: true,
10
+ maximazible: false,
11
+ minimazible: false,
12
+ items: [
13
+ {
14
+ xtype: 'form',
15
+ reference: 'formData',
16
+ bodyPadding: 5,
17
+ items: [
18
+ {
19
+ xtype: 'textfield',
20
+ reference: 'idField',
21
+ name: 'UI_ELEMENT_CD',
22
+ allowBlank: false,
23
+ width: '100%',
24
+ fieldLabel: 'UI_ELEMENT_CD',
25
+ },
26
+ {
27
+ xtype: 'textfield',
28
+ name: 'description',
29
+ allowBlank: false,
30
+ width: '100%',
31
+ fieldLabel: 'Описание',
32
+ }
33
+ ],
34
+ buttons: [
35
+ {
36
+ text: 'Применить',
37
+ formBind: true,
38
+ handler: function() {
39
+ const window = this.up('window');
40
+ const form = window.down('form');
41
+ window.fireEvent('applySettings', form.getForm().getValues());
42
+ window.close();
43
+ },
44
+ },
45
+ {
46
+ text: 'Отмена',
47
+ handler: function() {
48
+ this.up('window').close();
49
+ },
50
+ }
51
+ ],
52
+ }
53
+ ],
54
+
55
+ loadFormData(params) {
56
+ if (params['UI_ELEMENT_CD']) {
57
+ this.down('[reference="idField"]').setReadOnly(true);
58
+ }
59
+ this.down('form').getForm().setValues(params);
60
+ },
61
+ })
62
+ ;
@@ -0,0 +1,8 @@
1
+ /* global Ext */
2
+ Ext.define('Coon.common.component.formeditor.UiCFSpacer', {
3
+ extend: 'Ext.Component',
4
+ xtype: 'UiCFSpacer',
5
+ style: {
6
+ height: '30px',
7
+ },
8
+ });
@@ -0,0 +1,51 @@
1
+ /* global Ext */
2
+ Ext.define('Coon.common.component.formeditor.UiCFTab', {
3
+ extend: 'Ext.tab.Panel',
4
+ xtype: 'UiCFTab',
5
+ controller: {
6
+ init(view) {
7
+ if (view.initialConfig && !view.initialConfig.checkOptions) {
8
+ if (view.initialConfig && view.initialConfig.countCards) {
9
+ view.initialConfig.countCards.forEach((setting, index) => {
10
+ let item = view.items.getAt(view.items.findIndex('itemId', setting.itemId));
11
+ if (!item) {
12
+ item = view.add({
13
+ xtype: 'panel',
14
+ layout: 'fit',
15
+ itemId: setting.itemId,
16
+ items: [{xtype: 'UiCFContainer'}],
17
+ });
18
+ }
19
+ if (setting.title) {
20
+ item.setTitle(setting.title);
21
+ }
22
+ });
23
+ if (view.initialConfig.countCards.length < view.items.getCount()) {
24
+ const ids = view.initialConfig.countCards.map((item) => item.itemId);
25
+ view.items.items.forEach((item) => {
26
+ if (ids.indexOf(item.itemId) < 0) {
27
+ view.remove(item);
28
+ }
29
+ });
30
+ }
31
+ } else {
32
+ const itemId = 'UiCFCard_' + Ext.id().replace('-', '_');
33
+ view.value = view.countCards = [
34
+ {
35
+ 'title': '',
36
+ 'itemId': itemId,
37
+ }
38
+ ],
39
+ view.add({
40
+ xtype: 'panel',
41
+ layout: 'fit',
42
+ itemId: itemId,
43
+ items: [{xtype: 'UiCFContainer'}],
44
+ });
45
+ }
46
+ }
47
+ },
48
+ },
49
+ minHeight: 100,
50
+ items: [],
51
+ });
@@ -0,0 +1,33 @@
1
+ /* global Ext */
2
+ Ext.define('Coon.common.component.formeditor.UiCustomForm', {
3
+ extend: 'Ext.form.Panel',
4
+ xtype: 'UiCustomForm',
5
+ layout: 'form',
6
+ setFormData(data) {
7
+ this.getForm().setValues(data);
8
+ },
9
+ getFormData(valuesAsIs, dateFormat, excludeReadOnly, excludeDisabled) {
10
+ return Coon.Function.getDataFromForm(this, valuesAsIs, dateFormat, excludeReadOnly, excludeDisabled);
11
+ },
12
+ initComponent() {
13
+ if (this.initialConfig && this.initialConfig.UiCFId) {
14
+ this.on('added', (view) => {
15
+ const command = Ext.create('Coon.uielement.command.GetUIElementCommand');
16
+ command.on('complete', function(response) {
17
+ if (response) {
18
+ const data = response.propertyData !== '{}' ? JSON.parse(response.propertyData) : null;
19
+ if (data) {
20
+ view.add(data.items || []);
21
+ Ext.defer(() => {
22
+ Ext.ComponentQuery.query('UiCFCell', view).forEach((cmp) => cmp.getController().readOnly = true);
23
+ Ext.ComponentQuery.query('UiCFContainer', view).forEach((cmp) => cmp.getController().readOnly = true);
24
+ }, 500);
25
+ }
26
+ }
27
+ }, this);
28
+ command.execute(view.initialConfig.UiCFId);
29
+ }, this);
30
+ }
31
+ this.callParent();
32
+ },
33
+ });
@@ -0,0 +1,6 @@
1
+ Ext.define('Coon.common.component.formeditor.UiCustomFormController', {
2
+ extend: 'Ext.app.ViewController',
3
+ alias: 'controller.UiCustomFormController',
4
+
5
+
6
+ });