pui9-datatables 1.16.4
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/README.md +24 -0
- package/dist/demo.html +10 -0
- package/dist/pui9-datatables.common.js +89206 -0
- package/dist/pui9-datatables.common.js.map +1 -0
- package/dist/pui9-datatables.css +5 -0
- package/dist/pui9-datatables.umd.js +89216 -0
- package/dist/pui9-datatables.umd.js.map +1 -0
- package/dist/pui9-datatables.umd.min.js +55 -0
- package/dist/pui9-datatables.umd.min.js.map +1 -0
- package/package-lock.json +15982 -0
- package/package.json +89 -0
- package/src/App.vue +37 -0
- package/src/components/desktop/PuiDatatable.vue +709 -0
- package/src/components/desktop/PuiQuickEditionDatatable.vue +548 -0
- package/src/components/desktop/PuiSimpleDatatable.vue +1498 -0
- package/src/components/desktop/datatables.net-plugins/pagination/input.js +213 -0
- package/src/components/desktop/footer/PuiDatatableFooter.vue +65 -0
- package/src/components/desktop/footer/PuiGridActionFooter.vue +132 -0
- package/src/components/desktop/quickedition/PuiQuickEditionExportBtn.vue +138 -0
- package/src/components/desktop/quickedition/PuiQuickEditionForm.vue +60 -0
- package/src/components/desktop/quickedition/PuiQuickEditionToolbar.vue +144 -0
- package/src/components/desktop/row/PuiGridRowActions.vue +112 -0
- package/src/components/desktop/subdialogs/PuiDatatableColumnMenu.vue +186 -0
- package/src/components/desktop/toolbar/PuiGridToolbar.vue +310 -0
- package/src/components/desktop/toolbar/actions/PuiGridActionListItem.vue +34 -0
- package/src/components/desktop/toolbar/actions/PuiGridActionsBtn.vue +56 -0
- package/src/components/desktop/toolbar/actions/PuiGridActionsDialog.vue +66 -0
- package/src/components/desktop/toolbar/actions/audit/PuiAuditDialog.vue +92 -0
- package/src/components/desktop/toolbar/actions/docgen/PuiDocgenTemplateMatchingsDialog.vue +139 -0
- package/src/components/desktop/toolbar/actions/docgen/PuiDocgenTemplateParametersDialog.vue +317 -0
- package/src/components/desktop/toolbar/actions/importexport/PuiGridExportDialog.vue +187 -0
- package/src/components/desktop/toolbar/actions/importexport/PuiGridImportDialog.vue +421 -0
- package/src/components/desktop/toolbar/export/PuiGridExportBtn.vue +175 -0
- package/src/components/desktop/toolbar/filtercombo/PuiGridFilterCombo.vue +237 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterBtns.vue +163 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterDialog.vue +434 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterGroup.vue +313 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterListBtn.vue +85 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterListDialog.vue +254 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterListItem.vue +192 -0
- package/src/components/desktop/toolbar/filtering/PuiGridFilterRule.vue +517 -0
- package/src/components/desktop/toolbar/grid-configuration/PuiGridConfBtns.vue +99 -0
- package/src/components/desktop/toolbar/grid-configuration/PuiGridConfDialog.vue +640 -0
- package/src/components/desktop/toolbar/grid-configuration/PuiSaveConfigDialog.vue +154 -0
- package/src/components/desktop/toolbar/row/PuiGridCreateBtn.vue +39 -0
- package/src/components/desktop/toolbar/row/PuiGridDeleteBtn.vue +86 -0
- package/src/components/desktop/toolbar/row/PuiGridRefreshBtn.vue +39 -0
- package/src/components/desktop/toolbar/row/PuiGridUpdateBtn.vue +56 -0
- package/src/components/desktop/toolbar/searching/PuiGridSearcher.vue +67 -0
- package/src/components/desktop/toolbar/searching/PuiGridSearcherColumnsList.vue +43 -0
- package/src/components/desktop/toolbar/sorting/PuiGridSortBtn.vue +44 -0
- package/src/components/desktop/toolbar/sorting/PuiGridSortDialog.vue +113 -0
- package/src/components/mobile/PuiDatalist.vue +477 -0
- package/src/components/mobile/PuiSimpleDatalist.vue +313 -0
- package/src/components/mobile/actions/PuiListActionListItem.vue +34 -0
- package/src/components/mobile/actions/PuiListActionsBtn.vue +38 -0
- package/src/components/mobile/actions/PuiListActionsDialog.vue +66 -0
- package/src/components/mobile/footer/PuiListActionFooter.vue +56 -0
- package/src/components/mobile/toolbar/PuiListToolbar.vue +60 -0
- package/src/components/mobile/toolbar/searching/PuiListSearcher.vue +53 -0
- package/src/components/mobile/toolbar/searching/PuiListSearcherColumnsList.vue +43 -0
- package/src/components/mobile/toolbar/sorting/PuiListSortBtn.vue +46 -0
- package/src/components/mobile/toolbar/sorting/PuiListSortDialog.vue +140 -0
- package/src/components/puiaudit/PuiAuditForm.vue +107 -0
- package/src/generalActions.js +135 -0
- package/src/index.js +31 -0
- package/src/main.js +67 -0
- package/src/mixins/PuiActionsBtnMixin.js +287 -0
- package/src/mixins/PuiActionsDialogMixin.js +161 -0
- package/src/mixins/PuiActionsListItemMixin.js +62 -0
- package/src/mixins/PuiDatatablesKeepPage.js +15 -0
- package/src/mixins/PuiGridFormMethodsMixin.js +133 -0
- package/src/mixins/PuiModelConfigurationMixin.js +15 -0
- package/src/mixins/PuiSearcherColumnsListMixin.js +108 -0
- package/src/mixins/PuiSearcherMixin.js +192 -0
- package/src/mixins/PuiSortBtnMixin.js +54 -0
- package/src/mixins/PuiSortDialogMixin.js +256 -0
- package/src/mixins/PuiToolbarBtnMixin.js +66 -0
- package/src/mixins/PuiToolbarDialogMixin.js +12 -0
- package/src/router.js +18 -0
- package/src/tests/PuiContainer.vue +139 -0
- package/src/tests/PuiProfileTestSimpleDatatable.vue +66 -0
- package/src/tests/PuiUserTestCompleteDatatable.vue +126 -0
- package/src/tests/PuiVariableTestQuickEditionDatatable.vue +39 -0
- package/src/tests/PuiVariableTestQuickEditionForm.vue +18 -0
- package/src/tests/modelConfigurations.json +3516 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import PuiToolbarDialogMixin from './PuiToolbarDialogMixin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mixins: [PuiToolbarDialogMixin],
|
|
5
|
+
data() {
|
|
6
|
+
return {
|
|
7
|
+
checkColumns: [],
|
|
8
|
+
searchAll: true,
|
|
9
|
+
height: 20,
|
|
10
|
+
itemHeight: 31
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
props: {
|
|
14
|
+
position: {
|
|
15
|
+
type: Object
|
|
16
|
+
},
|
|
17
|
+
modelName: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
watch: {
|
|
23
|
+
searchAll(val) {
|
|
24
|
+
this.checkUnCheckAllColumns(val);
|
|
25
|
+
if (val) {
|
|
26
|
+
this.$puiEvents.$emit(`onPuiApplySearchingColumnsDisable-${this.modelName}`);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
checkColumns: {
|
|
30
|
+
handler(newVal) {
|
|
31
|
+
if (newVal) {
|
|
32
|
+
this.$puiEvents.$emit(`onPuiApplySearchingColumns-${this.modelName}`, newVal);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
deep: true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
createColumnsList(columns) {
|
|
40
|
+
this.checkColumns = [];
|
|
41
|
+
columns
|
|
42
|
+
.sort((a, b) => (a.title < b.title ? -1 : a.title > b.title ? 1 : 0))
|
|
43
|
+
.forEach(column => {
|
|
44
|
+
const columnChecked = {};
|
|
45
|
+
columnChecked.name = column.name;
|
|
46
|
+
columnChecked.title = column.title;
|
|
47
|
+
columnChecked.checked = true;
|
|
48
|
+
this.checkColumns.push(columnChecked);
|
|
49
|
+
});
|
|
50
|
+
this.calculateHeightSubPanel(this.checkColumns);
|
|
51
|
+
},
|
|
52
|
+
updateColumnsList(columns) {
|
|
53
|
+
this.searchAll = false;
|
|
54
|
+
this.checkColumns = [];
|
|
55
|
+
columns
|
|
56
|
+
.sort((a, b) => (a.title < b.title ? -1 : a.title > b.title ? 1 : 0))
|
|
57
|
+
.forEach(column => {
|
|
58
|
+
const columnChecked = {};
|
|
59
|
+
columnChecked.name = column.name;
|
|
60
|
+
columnChecked.title = column.title;
|
|
61
|
+
columnChecked.checked = column.checked;
|
|
62
|
+
this.checkColumns.push(columnChecked);
|
|
63
|
+
});
|
|
64
|
+
this.calculateHeightSubPanel(this.checkColumns);
|
|
65
|
+
},
|
|
66
|
+
checkFirstElement() {
|
|
67
|
+
// check first element
|
|
68
|
+
if (this.checkColumns && this.checkColumns.length > 0) {
|
|
69
|
+
if (!this.checkAll) {
|
|
70
|
+
this.checkColumns[0].checked = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
checkUnCheckAllColumns(checkAll) {
|
|
75
|
+
this.checkColumns.forEach(column => {
|
|
76
|
+
column.checked = checkAll;
|
|
77
|
+
});
|
|
78
|
+
this.checkFirstElement();
|
|
79
|
+
},
|
|
80
|
+
calculateHeightSubPanel(items) {
|
|
81
|
+
var size = this.itemHeight;
|
|
82
|
+
if (items.length > 0) {
|
|
83
|
+
this.height = items.length * size + 8;
|
|
84
|
+
} else {
|
|
85
|
+
this.height = size + 8;
|
|
86
|
+
}
|
|
87
|
+
if (this.height > 240) {
|
|
88
|
+
this.height = 240;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
computed: {
|
|
93
|
+
compStyle() {
|
|
94
|
+
var style = {
|
|
95
|
+
top: this.position.top + 'px',
|
|
96
|
+
right: '0px'
|
|
97
|
+
};
|
|
98
|
+
return style;
|
|
99
|
+
},
|
|
100
|
+
compStyleMaxHeight() {
|
|
101
|
+
var style = {
|
|
102
|
+
height: this.height + 'px',
|
|
103
|
+
'overflow-y': 'auto'
|
|
104
|
+
};
|
|
105
|
+
return style;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import PuiToolbarDialogMixin from './PuiToolbarDialogMixin';
|
|
2
|
+
import PuiToolbarBtnMixin from './PuiToolbarBtnMixin';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
mixins: [PuiToolbarDialogMixin, PuiToolbarBtnMixin],
|
|
6
|
+
data() {
|
|
7
|
+
return {
|
|
8
|
+
idTool: 'gridsearcher',
|
|
9
|
+
isMobile: false,
|
|
10
|
+
input: {
|
|
11
|
+
previousSearchingText: '',
|
|
12
|
+
searchingText: '',
|
|
13
|
+
applied: false
|
|
14
|
+
},
|
|
15
|
+
visibleColumns: [],
|
|
16
|
+
active: false,
|
|
17
|
+
panel: {
|
|
18
|
+
searchingColumns: [],
|
|
19
|
+
firstSubscribe: true,
|
|
20
|
+
position: {
|
|
21
|
+
top: 40,
|
|
22
|
+
left: 0
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
props: {
|
|
28
|
+
columns: {
|
|
29
|
+
type: Array,
|
|
30
|
+
default: () => [],
|
|
31
|
+
required: true
|
|
32
|
+
},
|
|
33
|
+
modelName: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true
|
|
36
|
+
},
|
|
37
|
+
showOnlyVisibleColumns: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
computed: {
|
|
43
|
+
getPlaceholder() {
|
|
44
|
+
return this.$t('puidatatables.searchPlaceholder');
|
|
45
|
+
},
|
|
46
|
+
compClass() {
|
|
47
|
+
return this.isMobile ? 'puiGridSearcher--mobile' : 'puiGridSearcher--desktop';
|
|
48
|
+
},
|
|
49
|
+
compIconClass() {
|
|
50
|
+
return {
|
|
51
|
+
'puiGridSearcher__icon--applied': this.input.applied
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
getTitle() {
|
|
55
|
+
return this.$t('puidatatables.searchBtnTitle');
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
created() {
|
|
59
|
+
this.isMobile = this.$store.getters.isMobile;
|
|
60
|
+
this.$puiEvents.$on('onPui-click-mainContainer', () => {
|
|
61
|
+
this.active = false;
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
mounted() {
|
|
65
|
+
this.$puiEvents.$on(`onPuiApplySearchingColumnsDisable-${this.modelName}`, () => {
|
|
66
|
+
this.disapplyTool();
|
|
67
|
+
});
|
|
68
|
+
this.$puiEvents.$on(`onPui-active-toolbarBtn-${this.modelName}`, (idtool) => {
|
|
69
|
+
if (idtool !== this.idTool) {
|
|
70
|
+
this.active = false;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this.$puiEvents.$on(`onPuiApplySearchingColumns-${this.modelName}`, (searchingColumns) => {
|
|
74
|
+
this.panel.searchingColumns = searchingColumns;
|
|
75
|
+
if (this.panel.firstSubscribe === false) {
|
|
76
|
+
this.publishSearching(this.input.searchingText);
|
|
77
|
+
}
|
|
78
|
+
this.panel.firstSubscribe = false;
|
|
79
|
+
});
|
|
80
|
+
this.showOnlyVisibleColumns === true &&
|
|
81
|
+
this.$puiEvents.$on(`onPui-apply-configuration-${this.modelName}`, (configuration) => {
|
|
82
|
+
this.setVisibleColumns(configuration.columns);
|
|
83
|
+
this.$refs.searchdialog.createColumnsList(this.visibleColumns);
|
|
84
|
+
});
|
|
85
|
+
// relocate panel onresize
|
|
86
|
+
window.addEventListener('resize', this.calculateDialogPosition);
|
|
87
|
+
this.setVisibleColumns(this.columns);
|
|
88
|
+
this.$refs.searchdialog.createColumnsList(this.visibleColumns);
|
|
89
|
+
this.applySearching();
|
|
90
|
+
},
|
|
91
|
+
beforeDestroy() {
|
|
92
|
+
this.$puiEvents.$off(`onPuiApplySearchingColumns-${this.modelName}`);
|
|
93
|
+
this.$puiEvents.$off(`onPuiApplySearchingColumnsDisable-${this.modelName}`);
|
|
94
|
+
this.$puiEvents.$off(`onPui-apply-configuration-${this.modelName}`);
|
|
95
|
+
window.removeEventListener('resize', this.calculateDialogPosition);
|
|
96
|
+
},
|
|
97
|
+
methods: {
|
|
98
|
+
setVisibleColumns(columns) {
|
|
99
|
+
this.visibleColumns = columns
|
|
100
|
+
.filter((column) => {
|
|
101
|
+
if (this.showOnlyVisibleColumns === true) {
|
|
102
|
+
return column.visible === true;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
})
|
|
106
|
+
.sort(function (a, b) {
|
|
107
|
+
if (a.name > b.name) {
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
110
|
+
if (a.name < b.name) {
|
|
111
|
+
return -1;
|
|
112
|
+
}
|
|
113
|
+
return 0;
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
goSearch() {
|
|
117
|
+
clearTimeout(this.delayTimer);
|
|
118
|
+
this.delayTimer = setTimeout(() => {
|
|
119
|
+
if (this.input.previousSearchingText !== this.input.searchingText) {
|
|
120
|
+
this.input.previousSearchingText = this.input.searchingText;
|
|
121
|
+
this.publishSearching(this.input.searchingText);
|
|
122
|
+
}
|
|
123
|
+
}, 500);
|
|
124
|
+
},
|
|
125
|
+
goClearSearch() {
|
|
126
|
+
this.input.searchingText = null;
|
|
127
|
+
this.input.previousSearchingText = this.input.searchingText;
|
|
128
|
+
this.publishSearching('');
|
|
129
|
+
},
|
|
130
|
+
hideDialog() {
|
|
131
|
+
this.active = false;
|
|
132
|
+
},
|
|
133
|
+
goDialog() {
|
|
134
|
+
if (!this.active) {
|
|
135
|
+
this.calculateDialogPosition();
|
|
136
|
+
}
|
|
137
|
+
this.active = !this.active;
|
|
138
|
+
this.$puiEvents.$emit(`onPui-active-toolbarBtn-${this.modelName}`, this.idTool);
|
|
139
|
+
},
|
|
140
|
+
publishSearching(searchText) {
|
|
141
|
+
this.disapplyTool();
|
|
142
|
+
//miramos si hay columnas para la búsqueda, con que haya una seleccionamos el puiSearcher__icon de
|
|
143
|
+
//color sencodarycolor, después publicamos
|
|
144
|
+
for (let index = 0, length = this.panel.searchingColumns.length; index < length; index++) {
|
|
145
|
+
if (this.panel.searchingColumns[index] !== undefined && this.panel.searchingColumns[index].checked === false) {
|
|
146
|
+
this.applyTool();
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
this.saveSearching(searchText);
|
|
151
|
+
if (this.panel.searchingColumns.filter(c => c.checked).length > 0) {
|
|
152
|
+
this.$puiEvents.$emit(`onPui-apply-searching-${this.modelName}`, [searchText, this.panel.searchingColumns]);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
applyTool() {
|
|
156
|
+
this.input.applied = true;
|
|
157
|
+
},
|
|
158
|
+
disapplyTool() {
|
|
159
|
+
this.input.applied = false;
|
|
160
|
+
},
|
|
161
|
+
calculateDialogPosition() {
|
|
162
|
+
var offset = this.$puiUtils.getComponentOffset(this.$el);
|
|
163
|
+
this.panel.position.left = offset.left - 43;
|
|
164
|
+
},
|
|
165
|
+
saveSearching(searchText) {
|
|
166
|
+
// save searchText & searchColumns in model store for future uses
|
|
167
|
+
const currentModel = this.$store.getters.getModelByName(this.modelName);
|
|
168
|
+
currentModel.searcher = null;
|
|
169
|
+
if (searchText) {
|
|
170
|
+
currentModel.searcher = {
|
|
171
|
+
searchText: searchText,
|
|
172
|
+
applied: this.input.applied,
|
|
173
|
+
searchingColumns: this.panel.searchingColumns
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
this.$store.commit('puiModelsAddModel', currentModel);
|
|
177
|
+
},
|
|
178
|
+
applySearching() {
|
|
179
|
+
// apply searchText & searchColumns from model store
|
|
180
|
+
const currentModel = this.$store.getters.getModelByName(this.modelName);
|
|
181
|
+
if (currentModel.searcher) {
|
|
182
|
+
this.input.previousSearchingText = currentModel.searcher.searchText;
|
|
183
|
+
this.input.searchingText = currentModel.searcher.searchText;
|
|
184
|
+
this.input.applied = currentModel.searcher.applied;
|
|
185
|
+
this.panel.searchingColumns = currentModel.searcher.searchingColumns;
|
|
186
|
+
if (this.input.applied) {
|
|
187
|
+
this.$refs.searchdialog.updateColumnsList(this.panel.searchingColumns);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import PuiToolbarBtnMixin from './PuiToolbarBtnMixin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mixins: [PuiToolbarBtnMixin],
|
|
5
|
+
props: {
|
|
6
|
+
columns: {
|
|
7
|
+
type: Array
|
|
8
|
+
},
|
|
9
|
+
modelName: {
|
|
10
|
+
type: String
|
|
11
|
+
},
|
|
12
|
+
groupedColumn: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
data() {
|
|
18
|
+
return {
|
|
19
|
+
idTool: 'sorting',
|
|
20
|
+
panel: {
|
|
21
|
+
position: {}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
mounted() {
|
|
26
|
+
this.calculateDialogPosition();
|
|
27
|
+
},
|
|
28
|
+
created() {
|
|
29
|
+
this.$puiEvents.$on(`onPui-apply-sorting-${this.modelName}`, rules => {
|
|
30
|
+
if (rules && rules.length > 0) {
|
|
31
|
+
this.states.applied = true;
|
|
32
|
+
} else {
|
|
33
|
+
this.states.applied = false;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
computed: {
|
|
38
|
+
compClass() {
|
|
39
|
+
return {
|
|
40
|
+
'pui-toolbar__btn--applied': this.states.applied,
|
|
41
|
+
'pui-toolbar__btn--active': this.states.active
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
destroyed() {
|
|
46
|
+
this.$puiEvents.$off(`onPui-apply-sorting-${this.modelName}`);
|
|
47
|
+
},
|
|
48
|
+
methods: {
|
|
49
|
+
toggleSorting() {
|
|
50
|
+
this.states.applied = !this.states.applied;
|
|
51
|
+
this.$children[2].toggleSorting(this.states.applied);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import PuiToolbarDialogMixin from './PuiToolbarDialogMixin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mixins: [PuiToolbarDialogMixin],
|
|
5
|
+
props: {
|
|
6
|
+
columns: {
|
|
7
|
+
type: Array
|
|
8
|
+
},
|
|
9
|
+
position: {
|
|
10
|
+
type: Object
|
|
11
|
+
},
|
|
12
|
+
modelName: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
groupedColumn: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
selected: {},
|
|
24
|
+
selectedNum: 0,
|
|
25
|
+
width: 300,
|
|
26
|
+
height: 50,
|
|
27
|
+
rules: [],
|
|
28
|
+
grouped: false,
|
|
29
|
+
availableColumnsSetted: false,
|
|
30
|
+
availableColumns: [],
|
|
31
|
+
positionHelper: {
|
|
32
|
+
top: null,
|
|
33
|
+
right: null
|
|
34
|
+
},
|
|
35
|
+
sortingTypes: [
|
|
36
|
+
{
|
|
37
|
+
text: 'puidatatables.ascendent',
|
|
38
|
+
value: 'asc'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
text: 'puidatatables.descendent',
|
|
42
|
+
value: 'desc'
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
watch: {
|
|
48
|
+
rules(val) {
|
|
49
|
+
var size = 50;
|
|
50
|
+
if (val.length > 0) {
|
|
51
|
+
this.height = val.length * size;
|
|
52
|
+
} else {
|
|
53
|
+
this.height = size;
|
|
54
|
+
}
|
|
55
|
+
if (this.height > 250) {
|
|
56
|
+
this.height = 280;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
computed: {
|
|
61
|
+
heightPanel() {
|
|
62
|
+
return this.height + 'px';
|
|
63
|
+
},
|
|
64
|
+
showAddBtn() {
|
|
65
|
+
if (this.columns.length > this.rules.length) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
},
|
|
70
|
+
getTitleRemove() {
|
|
71
|
+
return this.$t('puidatatables.removeBtnTitle');
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
created() {
|
|
75
|
+
this.$puiEvents.$on(`onPui-groupColumn-dataTable-${this.modelName}`, (columnIndex) => {
|
|
76
|
+
this.grouped = columnIndex !== -1;
|
|
77
|
+
});
|
|
78
|
+
this.$puiEvents.$on(`onPui-apply-sorting-dataTable-${this.modelName}`, (sortingRule) => {
|
|
79
|
+
this.rules = sortingRule;
|
|
80
|
+
this.$parent.states.applied = true;
|
|
81
|
+
});
|
|
82
|
+
this.$puiEvents.$on(`onPui-apply-configuration-${this.modelName}`, (configuration) => {
|
|
83
|
+
if (configuration) {
|
|
84
|
+
this.grouped = configuration.grouped;
|
|
85
|
+
if (configuration.order.length > 0 && configuration.order[0].column) {
|
|
86
|
+
this.rules = configuration.order;
|
|
87
|
+
this.$parent.states.applied = true;
|
|
88
|
+
} else {
|
|
89
|
+
this.rules = [];
|
|
90
|
+
this.addRule();
|
|
91
|
+
this.$parent.states.applied = false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
this.translateSortingTypes();
|
|
96
|
+
},
|
|
97
|
+
mounted() {
|
|
98
|
+
const currentConfig = this.$store.getters.getCurrentGridConfiguration(this.modelName);
|
|
99
|
+
if (currentConfig && Array.isArray(currentConfig.configuration.order) && currentConfig.configuration.order.length > 0) {
|
|
100
|
+
currentConfig.configuration.order.forEach((sortingRule) => this.rules.push(sortingRule));
|
|
101
|
+
this.$puiEvents.$emit(`onPui-apply-sorting-${this.modelName}`, this.rules);
|
|
102
|
+
} else {
|
|
103
|
+
this.addRule();
|
|
104
|
+
}
|
|
105
|
+
this.grouped = this.groupedColumn;
|
|
106
|
+
},
|
|
107
|
+
updated() {
|
|
108
|
+
if (this.availableColumnsSetted === false && this.columns.length !== 0) {
|
|
109
|
+
this.availableColumnsSetted = true;
|
|
110
|
+
/*this.columns.forEach(column => {
|
|
111
|
+
this.availableColumns.push(column.name);
|
|
112
|
+
});*/
|
|
113
|
+
const rulesColNames = this.rules.map((rule) => {
|
|
114
|
+
return rule.column;
|
|
115
|
+
});
|
|
116
|
+
this.columns
|
|
117
|
+
.sort((a, b) => (a.title < b.title ? -1 : a.title > b.title ? 1 : 0))
|
|
118
|
+
.forEach((column) => {
|
|
119
|
+
if (rulesColNames.includes(column.name) === false && this.availableColumns.includes(column.name) === false) {
|
|
120
|
+
this.availableColumns.push(column.name);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
this.calculatePosition();
|
|
125
|
+
},
|
|
126
|
+
destroyed() {
|
|
127
|
+
this.$puiEvents.$off(`onPui-apply-sorting-dataTable-${this.modelName}`);
|
|
128
|
+
this.$puiEvents.$off(`onPui-apply-configuration-${this.modelName}`);
|
|
129
|
+
this.$puiEvents.$off(`onPui-groupColumn-dataTable-${this.modelName}`);
|
|
130
|
+
},
|
|
131
|
+
methods: {
|
|
132
|
+
toggleSorting(val) {
|
|
133
|
+
const rules = val ? this.rules : [];
|
|
134
|
+
this.$puiEvents.$emit(`onPui-apply-sorting-${this.modelName}`, rules);
|
|
135
|
+
},
|
|
136
|
+
reset() {
|
|
137
|
+
this.columns
|
|
138
|
+
.sort((a, b) => (a.title < b.title ? -1 : a.title > b.title ? 1 : 0))
|
|
139
|
+
.forEach((column) => {
|
|
140
|
+
this.availableColumns.push(column.name);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
this.rules = [];
|
|
144
|
+
this.addRule();
|
|
145
|
+
this.$puiEvents.$emit(`onPui-reset-sorting-${this.modelName}`);
|
|
146
|
+
},
|
|
147
|
+
toggleDialog(val) {
|
|
148
|
+
this.dialog = val;
|
|
149
|
+
},
|
|
150
|
+
removeSelectsFocus() {
|
|
151
|
+
for (let i = 0, length = this.rules.length; i < length; i++) {
|
|
152
|
+
this.$refs[`${i}-column`][0].$el.classList.remove('v-input--is-focused');
|
|
153
|
+
this.$refs[`${i}-sortType`][0].$el.classList.remove('v-input--is-focused');
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
getAvailableColumns(index) {
|
|
157
|
+
const availableColumns = this.availableColumns;
|
|
158
|
+
const columnNameSelected = this.rules[index].column;
|
|
159
|
+
|
|
160
|
+
const columnsAvailableForTheSelect = this.columns.filter((column) => {
|
|
161
|
+
return availableColumns.includes(column.name) || column.name === columnNameSelected;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return columnsAvailableForTheSelect;
|
|
165
|
+
},
|
|
166
|
+
onRuleNameChanged(value) {
|
|
167
|
+
//quitamos de las disponibles la nueva columna
|
|
168
|
+
this.removeColumnFromAvailable(value);
|
|
169
|
+
//a contiunación añadimos a disponibles la columna que se ha cambiado
|
|
170
|
+
const rulesColNames = this.rules.map((rule) => {
|
|
171
|
+
return rule.column;
|
|
172
|
+
});
|
|
173
|
+
this.columns
|
|
174
|
+
.sort((a, b) => (a.title < b.title ? -1 : a.title > b.title ? 1 : 0))
|
|
175
|
+
.forEach((column) => {
|
|
176
|
+
if (rulesColNames.includes(column.name) === false && this.availableColumns.includes(column.name) === false) {
|
|
177
|
+
this.availableColumns.push(column.name);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
removeColumnFromAvailable(columnName) {
|
|
182
|
+
for (let i = 0, length = this.availableColumns.length; i < length; i++) {
|
|
183
|
+
const column = this.availableColumns[i];
|
|
184
|
+
if (column === columnName) {
|
|
185
|
+
this.availableColumns.splice(i, 1);
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
calculatePosition() {
|
|
191
|
+
if (!this.top) {
|
|
192
|
+
var paneltop = this.position.top + 7;
|
|
193
|
+
this.$refs.dialog.style.top = paneltop + 'px';
|
|
194
|
+
const right = this.width / 2 < this.position.right ? 10 : this.width / 2 - this.position.right;
|
|
195
|
+
this.$refs.dialog.style.right = `${right}px`;
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
removeRule(index) {
|
|
199
|
+
this.availableColumns.push(this.rules[index].column);
|
|
200
|
+
this.rules.splice(index, 1);
|
|
201
|
+
if (this.rules.length === 0) {
|
|
202
|
+
this.columns
|
|
203
|
+
.sort((a, b) => (a.title < b.title ? -1 : a.title > b.title ? 1 : 0))
|
|
204
|
+
.forEach((column) => {
|
|
205
|
+
this.availableColumns.push(column.name);
|
|
206
|
+
});
|
|
207
|
+
this.addRule();
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
addRule() {
|
|
211
|
+
this.rules.push({ column: '', direction: 'asc' });
|
|
212
|
+
},
|
|
213
|
+
translateSortingTypes() {
|
|
214
|
+
for (var i = 0, length = this.sortingTypes.length; i < length; i++) {
|
|
215
|
+
this.sortingTypes[i].text = this.$t(this.sortingTypes[i].text);
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
setIndex(index) {
|
|
219
|
+
this.index = index;
|
|
220
|
+
},
|
|
221
|
+
validateSelectedRules() {
|
|
222
|
+
var ok = true;
|
|
223
|
+
for (let i = 0, length = this.rules.length; i < length; i++) {
|
|
224
|
+
const rule = this.rules[i];
|
|
225
|
+
if (rule.column.length === 0) {
|
|
226
|
+
ok = false;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return ok;
|
|
231
|
+
},
|
|
232
|
+
publishSorting() {
|
|
233
|
+
var ok = this.validateSelectedRules();
|
|
234
|
+
if (ok) {
|
|
235
|
+
this.$puiEvents.$emit(`onPui-apply-sorting-${this.modelName}`, this.rules);
|
|
236
|
+
// close dialogt
|
|
237
|
+
this.$puiEvents.$emit(`onPui-active-toolbarBtn-${this.modelName}`, '');
|
|
238
|
+
} else {
|
|
239
|
+
this.$puiNotify.warning(this.$t('puidatatables.wrongSortingRules'));
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
handleScroll(event) {
|
|
243
|
+
const el = event.srcElement;
|
|
244
|
+
const classPrefix = 'puiToolbar-dialog';
|
|
245
|
+
if (el.scrollTop === 0) {
|
|
246
|
+
this.$refs.header.classList.remove(`${classPrefix}__header--scrolling`);
|
|
247
|
+
return;
|
|
248
|
+
} else if (el.scrollTop + el.clientHeight === el.scrollHeight) {
|
|
249
|
+
this.$refs.btnBar.classList.remove(`${classPrefix}__btnBar--scrolling`);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
this.$refs.header.classList.add(`${classPrefix}__header--scrolling`);
|
|
253
|
+
this.$refs.btnBar.classList.add(`${classPrefix}__btnBar--scrolling`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
data() {
|
|
3
|
+
return {
|
|
4
|
+
states: {
|
|
5
|
+
active: false,
|
|
6
|
+
applied: false,
|
|
7
|
+
unsaved: false,
|
|
8
|
+
hide: false
|
|
9
|
+
},
|
|
10
|
+
prevStates: {}
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
mounted() {
|
|
14
|
+
this.$puiEvents.$on(`onPui-active-toolbarBtn-${this.modelName}`, (idtool) => {
|
|
15
|
+
if (idtool !== this.idTool) {
|
|
16
|
+
this.states.active = false;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
destroyed() {
|
|
21
|
+
this.$puiEvents.$off(`onPui-active-toolbarBtn-${this.modelName}`);
|
|
22
|
+
},
|
|
23
|
+
computed: {
|
|
24
|
+
compClass() {
|
|
25
|
+
return {
|
|
26
|
+
'pui-toolbar__btn--applied': this.states.applied && !this.states.unsaved /** prioridad 2 **/,
|
|
27
|
+
'pui-toolbar__btn--active': this.states.active && !this.states.applied && !this.states.unsaved /** prioridad 3 **/,
|
|
28
|
+
'pui-toolbar__btn--unsaved': this.states.unsaved /** prioridad 1 **/
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
onPuiMenuIconBarSelected() {
|
|
32
|
+
return this.$store.state.menu.iconBarSelected;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
watch: {
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* Este metodo sirve para autocerrar el dialogo que controla este botón cuando se clica desde fuera del dialogo
|
|
39
|
+
*/
|
|
40
|
+
'states.active'(val) {
|
|
41
|
+
if (val === true) {
|
|
42
|
+
this.$puiEvents.$emit('onPui-active-toolbarBtn', this.idTool);
|
|
43
|
+
this.$puiEvents.$emit(`onPui-active-toolbarBtn-${this.modelName}`, this.idTool);
|
|
44
|
+
this.$puiEvents.$on('onPui-click-mainContainer', () => {
|
|
45
|
+
this.states.active = false;
|
|
46
|
+
this.$puiEvents.$off('onPui-click-mainContainer');
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
this.$puiEvents.$off('onPui-click-mainContainer');
|
|
50
|
+
this.$puiEvents.$emit(`onPui-inactive-toolbarBtn-${this.modelName}`, this.idTool);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
onPuiMenuIconBarSelected() {
|
|
54
|
+
this.states.active = false;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
methods: {
|
|
58
|
+
calculateDialogPosition() {
|
|
59
|
+
const topBtn = this.$refs.btn.offsetTop;
|
|
60
|
+
const topPanel = topBtn + 40;
|
|
61
|
+
const leftPanel = this.$refs.btn.offsetLeft;
|
|
62
|
+
this.panel.position.top = topPanel;
|
|
63
|
+
this.panel.position.right = window.innerWidth - leftPanel;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
methods: {
|
|
3
|
+
calculatePosition () {
|
|
4
|
+
if (this.position === undefined || this.$refs.dialog === undefined) {
|
|
5
|
+
return
|
|
6
|
+
}
|
|
7
|
+
this.$refs.dialog.style.top = this.position.top + 'px'
|
|
8
|
+
const right = this.width / 2 < this.position.right ? 0 : this.width / 2 - this.position.right
|
|
9
|
+
this.$refs.dialog.style.right = `${right}px`
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/router.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const router = {
|
|
2
|
+
routes: [
|
|
3
|
+
{
|
|
4
|
+
path: '/example1',
|
|
5
|
+
component: () => import('@/tests/PuiProfileTestSimpleDatatable')
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
path: '/example2',
|
|
9
|
+
component: () => import('@/tests/PuiUserTestCompleteDatatable')
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
path: '/example3',
|
|
13
|
+
component: () => import('@/tests/PuiVariableTestQuickEditionDatatable')
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default router;
|