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.
Files changed (86) hide show
  1. package/README.md +24 -0
  2. package/dist/demo.html +10 -0
  3. package/dist/pui9-datatables.common.js +89206 -0
  4. package/dist/pui9-datatables.common.js.map +1 -0
  5. package/dist/pui9-datatables.css +5 -0
  6. package/dist/pui9-datatables.umd.js +89216 -0
  7. package/dist/pui9-datatables.umd.js.map +1 -0
  8. package/dist/pui9-datatables.umd.min.js +55 -0
  9. package/dist/pui9-datatables.umd.min.js.map +1 -0
  10. package/package-lock.json +15982 -0
  11. package/package.json +89 -0
  12. package/src/App.vue +37 -0
  13. package/src/components/desktop/PuiDatatable.vue +709 -0
  14. package/src/components/desktop/PuiQuickEditionDatatable.vue +548 -0
  15. package/src/components/desktop/PuiSimpleDatatable.vue +1498 -0
  16. package/src/components/desktop/datatables.net-plugins/pagination/input.js +213 -0
  17. package/src/components/desktop/footer/PuiDatatableFooter.vue +65 -0
  18. package/src/components/desktop/footer/PuiGridActionFooter.vue +132 -0
  19. package/src/components/desktop/quickedition/PuiQuickEditionExportBtn.vue +138 -0
  20. package/src/components/desktop/quickedition/PuiQuickEditionForm.vue +60 -0
  21. package/src/components/desktop/quickedition/PuiQuickEditionToolbar.vue +144 -0
  22. package/src/components/desktop/row/PuiGridRowActions.vue +112 -0
  23. package/src/components/desktop/subdialogs/PuiDatatableColumnMenu.vue +186 -0
  24. package/src/components/desktop/toolbar/PuiGridToolbar.vue +310 -0
  25. package/src/components/desktop/toolbar/actions/PuiGridActionListItem.vue +34 -0
  26. package/src/components/desktop/toolbar/actions/PuiGridActionsBtn.vue +56 -0
  27. package/src/components/desktop/toolbar/actions/PuiGridActionsDialog.vue +66 -0
  28. package/src/components/desktop/toolbar/actions/audit/PuiAuditDialog.vue +92 -0
  29. package/src/components/desktop/toolbar/actions/docgen/PuiDocgenTemplateMatchingsDialog.vue +139 -0
  30. package/src/components/desktop/toolbar/actions/docgen/PuiDocgenTemplateParametersDialog.vue +317 -0
  31. package/src/components/desktop/toolbar/actions/importexport/PuiGridExportDialog.vue +187 -0
  32. package/src/components/desktop/toolbar/actions/importexport/PuiGridImportDialog.vue +421 -0
  33. package/src/components/desktop/toolbar/export/PuiGridExportBtn.vue +175 -0
  34. package/src/components/desktop/toolbar/filtercombo/PuiGridFilterCombo.vue +237 -0
  35. package/src/components/desktop/toolbar/filtering/PuiGridFilterBtns.vue +163 -0
  36. package/src/components/desktop/toolbar/filtering/PuiGridFilterDialog.vue +434 -0
  37. package/src/components/desktop/toolbar/filtering/PuiGridFilterGroup.vue +313 -0
  38. package/src/components/desktop/toolbar/filtering/PuiGridFilterListBtn.vue +85 -0
  39. package/src/components/desktop/toolbar/filtering/PuiGridFilterListDialog.vue +254 -0
  40. package/src/components/desktop/toolbar/filtering/PuiGridFilterListItem.vue +192 -0
  41. package/src/components/desktop/toolbar/filtering/PuiGridFilterRule.vue +517 -0
  42. package/src/components/desktop/toolbar/grid-configuration/PuiGridConfBtns.vue +99 -0
  43. package/src/components/desktop/toolbar/grid-configuration/PuiGridConfDialog.vue +640 -0
  44. package/src/components/desktop/toolbar/grid-configuration/PuiSaveConfigDialog.vue +154 -0
  45. package/src/components/desktop/toolbar/row/PuiGridCreateBtn.vue +39 -0
  46. package/src/components/desktop/toolbar/row/PuiGridDeleteBtn.vue +86 -0
  47. package/src/components/desktop/toolbar/row/PuiGridRefreshBtn.vue +39 -0
  48. package/src/components/desktop/toolbar/row/PuiGridUpdateBtn.vue +56 -0
  49. package/src/components/desktop/toolbar/searching/PuiGridSearcher.vue +67 -0
  50. package/src/components/desktop/toolbar/searching/PuiGridSearcherColumnsList.vue +43 -0
  51. package/src/components/desktop/toolbar/sorting/PuiGridSortBtn.vue +44 -0
  52. package/src/components/desktop/toolbar/sorting/PuiGridSortDialog.vue +113 -0
  53. package/src/components/mobile/PuiDatalist.vue +477 -0
  54. package/src/components/mobile/PuiSimpleDatalist.vue +313 -0
  55. package/src/components/mobile/actions/PuiListActionListItem.vue +34 -0
  56. package/src/components/mobile/actions/PuiListActionsBtn.vue +38 -0
  57. package/src/components/mobile/actions/PuiListActionsDialog.vue +66 -0
  58. package/src/components/mobile/footer/PuiListActionFooter.vue +56 -0
  59. package/src/components/mobile/toolbar/PuiListToolbar.vue +60 -0
  60. package/src/components/mobile/toolbar/searching/PuiListSearcher.vue +53 -0
  61. package/src/components/mobile/toolbar/searching/PuiListSearcherColumnsList.vue +43 -0
  62. package/src/components/mobile/toolbar/sorting/PuiListSortBtn.vue +46 -0
  63. package/src/components/mobile/toolbar/sorting/PuiListSortDialog.vue +140 -0
  64. package/src/components/puiaudit/PuiAuditForm.vue +107 -0
  65. package/src/generalActions.js +135 -0
  66. package/src/index.js +31 -0
  67. package/src/main.js +67 -0
  68. package/src/mixins/PuiActionsBtnMixin.js +287 -0
  69. package/src/mixins/PuiActionsDialogMixin.js +161 -0
  70. package/src/mixins/PuiActionsListItemMixin.js +62 -0
  71. package/src/mixins/PuiDatatablesKeepPage.js +15 -0
  72. package/src/mixins/PuiGridFormMethodsMixin.js +133 -0
  73. package/src/mixins/PuiModelConfigurationMixin.js +15 -0
  74. package/src/mixins/PuiSearcherColumnsListMixin.js +108 -0
  75. package/src/mixins/PuiSearcherMixin.js +192 -0
  76. package/src/mixins/PuiSortBtnMixin.js +54 -0
  77. package/src/mixins/PuiSortDialogMixin.js +256 -0
  78. package/src/mixins/PuiToolbarBtnMixin.js +66 -0
  79. package/src/mixins/PuiToolbarDialogMixin.js +12 -0
  80. package/src/router.js +18 -0
  81. package/src/tests/PuiContainer.vue +139 -0
  82. package/src/tests/PuiProfileTestSimpleDatatable.vue +66 -0
  83. package/src/tests/PuiUserTestCompleteDatatable.vue +126 -0
  84. package/src/tests/PuiVariableTestQuickEditionDatatable.vue +39 -0
  85. package/src/tests/PuiVariableTestQuickEditionForm.vue +18 -0
  86. package/src/tests/modelConfigurations.json +3516 -0
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Sometimes for quick navigation, it can be useful to allow an end user to
3
+ * enter which page they wish to jump to manually. This paging control uses a
4
+ * text input box to accept new paging numbers (arrow keys are also allowed
5
+ * for), and four standard navigation buttons are also presented to the end
6
+ * user.
7
+ *
8
+ * @name Navigation with text input
9
+ * @summary Shows an input element into which the user can type a page number
10
+ * @author [Allan Jardine](http://sprymedia.co.uk)
11
+ * @author [Gordey Doronin](http://github.com/GDoronin)
12
+ *
13
+ * @author [Miguel Llacer]
14
+ * Adaptation from the original Datatables pagination input plug-in for using
15
+ * with VueJS (https://datatables.net/plug-ins/pagination/input)
16
+ *
17
+ */
18
+
19
+ var firstClassName = 'first';
20
+ var previousClassName = 'previous';
21
+ var nextClassName = 'next';
22
+ var lastClassName = 'last';
23
+
24
+ var paginateClassName = 'paginate';
25
+ var paginateInputClassName = 'paginate_input';
26
+
27
+ import $ from 'jquery';
28
+
29
+ /* eslint-disable */
30
+ $.fn.dataTableExt.oPagination.input = {
31
+ fnInit: function(oSettings, nPaging, fnCallbackDraw) {
32
+ var nFirst = document.createElement('span');
33
+ var nPrevious = document.createElement('span');
34
+ var nNext = document.createElement('span');
35
+ var nLast = document.createElement('span');
36
+ var nInput = document.createElement('input');
37
+
38
+ var language = oSettings.oLanguage.oPaginate;
39
+ var classes = oSettings.oClasses;
40
+
41
+ nFirst.innerHTML = language.sFirst;
42
+ nPrevious.innerHTML = language.sPrevious;
43
+ nNext.innerHTML = language.sNext;
44
+ nLast.innerHTML = language.sLast;
45
+
46
+ nFirst.className = firstClassName + ' ' + classes.sPageButton;
47
+ nPrevious.className = previousClassName + ' ' + classes.sPageButton;
48
+ nNext.className = nextClassName + ' ' + classes.sPageButton;
49
+ nLast.className = lastClassName + ' ' + classes.sPageButton;
50
+
51
+ nInput.className = paginateInputClassName;
52
+
53
+ if (oSettings.sTableId !== '') {
54
+ nPaging.setAttribute('id', oSettings.sTableId + '_' + paginateClassName);
55
+ nFirst.setAttribute('id', oSettings.sTableId + '_' + firstClassName);
56
+ nPrevious.setAttribute('id', oSettings.sTableId + '_' + previousClassName);
57
+ nNext.setAttribute('id', oSettings.sTableId + '_' + nextClassName);
58
+ nLast.setAttribute('id', oSettings.sTableId + '_' + lastClassName);
59
+ }
60
+
61
+ nInput.type = 'text';
62
+
63
+ nPaging.appendChild(nFirst);
64
+ nPaging.appendChild(nPrevious);
65
+ nPaging.appendChild(nInput);
66
+ nPaging.appendChild(nNext);
67
+ nPaging.appendChild(nLast);
68
+
69
+ $(nFirst).click(function() {
70
+ var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
71
+ if (iCurrentPage !== 1) {
72
+ oSettings.oApi._fnPageChange(oSettings, 'first');
73
+ fnCallbackDraw(oSettings);
74
+ }
75
+ });
76
+
77
+ $(nPrevious).click(function() {
78
+ var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
79
+ if (iCurrentPage !== 1) {
80
+ oSettings.oApi._fnPageChange(oSettings, 'previous');
81
+ fnCallbackDraw(oSettings);
82
+ }
83
+ });
84
+
85
+ $(nNext).click(function() {
86
+ var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
87
+ if (iCurrentPage !== Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)) {
88
+ oSettings.oApi._fnPageChange(oSettings, 'next');
89
+ fnCallbackDraw(oSettings);
90
+ }
91
+ });
92
+
93
+ $(nLast).click(function() {
94
+ var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
95
+ if (iCurrentPage !== Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)) {
96
+ oSettings.oApi._fnPageChange(oSettings, 'last');
97
+ fnCallbackDraw(oSettings);
98
+ }
99
+ });
100
+
101
+ $(nInput).keyup(function(e) {
102
+ // 38 = up arrow, 39 = right arrow
103
+ if (e.which === 38 || e.which === 39) {
104
+ this.value++;
105
+ }
106
+ // 37 = left arrow, 40 = down arrow
107
+ else if ((e.which === 37 || e.which === 40) && this.value > 1) {
108
+ this.value--;
109
+ }
110
+
111
+ if (this.value === '' || this.value.match(/[^0-9]/)) {
112
+ /* Nothing entered or non-numeric character */
113
+ this.value = this.value.replace(/[^\d]/g, ''); // don't even allow anything but digits
114
+ return;
115
+ }
116
+
117
+ var iNewStart = oSettings._iDisplayLength * (this.value - 1);
118
+ if (iNewStart < 0) {
119
+ iNewStart = 0;
120
+ }
121
+ if (iNewStart >= oSettings.fnRecordsDisplay()) {
122
+ iNewStart = (Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength) - 1) * oSettings._iDisplayLength;
123
+ }
124
+
125
+ oSettings._iDisplayStart = iNewStart;
126
+ fnCallbackDraw(oSettings);
127
+ });
128
+
129
+ // Take the brutal approach to cancelling text selection.
130
+ $('span', nPaging).bind('mousedown', function() {
131
+ return false;
132
+ });
133
+ $('span', nPaging).bind('selectstart', function() {
134
+ return false;
135
+ });
136
+
137
+ // If we can't page anyway, might as well not show it.
138
+ var iPages = Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength);
139
+ if (iPages <= 1) {
140
+ $(nPaging).hide();
141
+ }
142
+ },
143
+
144
+ fnUpdate: function(oSettings) {
145
+ if (!oSettings.aanFeatures.p) {
146
+ return;
147
+ }
148
+
149
+ var iPages = Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength);
150
+ var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
151
+
152
+ var an = oSettings.aanFeatures.p;
153
+ if (iPages <= 1) {
154
+ // hide paging when we can't page
155
+ $(an).hide();
156
+ return;
157
+ }
158
+
159
+ var calcDisableClasses = function(oSettings) {
160
+ var start = oSettings._iDisplayStart;
161
+ var length = oSettings._iDisplayLength;
162
+ var visibleRecords = oSettings.fnRecordsDisplay();
163
+ var all = length === -1;
164
+
165
+ // Gordey Doronin: Re-used this code from main jQuery.dataTables source code. To be consistent.
166
+ var page = all ? 0 : Math.ceil(start / length);
167
+ var pages = all ? 1 : Math.ceil(visibleRecords / length);
168
+
169
+ var disableFirstPrevClass = page > 0 ? '' : oSettings.oClasses.sPageButtonDisabled;
170
+ var disableNextLastClass = page < pages - 1 ? '' : oSettings.oClasses.sPageButtonDisabled;
171
+
172
+ return {
173
+ first: disableFirstPrevClass,
174
+ previous: disableFirstPrevClass,
175
+ next: disableNextLastClass,
176
+ last: disableNextLastClass
177
+ };
178
+ };
179
+
180
+ var disableClasses = calcDisableClasses(oSettings);
181
+
182
+ $(an).show();
183
+
184
+ // Enable/Disable `first` button.
185
+ $(an)
186
+ .children('.' + firstClassName)
187
+ .removeClass(oSettings.oClasses.sPageButtonDisabled)
188
+ .addClass(disableClasses[firstClassName]);
189
+
190
+ // Enable/Disable `prev` button.
191
+ $(an)
192
+ .children('.' + previousClassName)
193
+ .removeClass(oSettings.oClasses.sPageButtonDisabled)
194
+ .addClass(disableClasses[previousClassName]);
195
+
196
+ // Enable/Disable `next` button.
197
+ $(an)
198
+ .children('.' + nextClassName)
199
+ .removeClass(oSettings.oClasses.sPageButtonDisabled)
200
+ .addClass(disableClasses[nextClassName]);
201
+
202
+ // Enable/Disable `last` button.
203
+ $(an)
204
+ .children('.' + lastClassName)
205
+ .removeClass(oSettings.oClasses.sPageButtonDisabled)
206
+ .addClass(disableClasses[lastClassName]);
207
+
208
+ // Current page numer input value
209
+ $(an)
210
+ .children('.' + paginateInputClassName)
211
+ .val(iCurrentPage);
212
+ }
213
+ };
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <div class="pa-1 pl-3 pr-3 elevation-2" :class="getComp">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: 'PuiDatatableFooter',
10
+ data: () => ({
11
+ isMobile: false,
12
+ desktopMenuOpened: false
13
+ }),
14
+ computed: {
15
+ getComp() {
16
+ return {
17
+ 'pui-datatableFooter--menuexpanded': this.desktopMenuOpened,
18
+ 'pui-datatableFooter': !this.isMobile,
19
+ 'pui-datatableFooter_mobile': this.isMobile
20
+ };
21
+ },
22
+ onPuiExpandMenu() {
23
+ return this.$store.state.menu.expandMenuForce;
24
+ }
25
+ },
26
+ watch: {
27
+ onPuiExpandMenu() {
28
+ this.desktopMenuOpened = this.$store.state.menu.expandMenu;
29
+ }
30
+ },
31
+ created() {
32
+ this.isMobile = this.$store.getters.isMobile;
33
+ this.desktopMenuOpened = this.$store.state.menu.expanded === true;
34
+ },
35
+ mounted() {
36
+ if (this.isMobile) {
37
+ const nav = document.getElementsByClassName('puimenubottombar');
38
+ const actionFooter = document.getElementsByClassName('pui-datatableFooter_mobile')[0];
39
+ if (nav.length !== 0) actionFooter.style.marginBottom = nav[0].offsetHeight + 'px';
40
+ }
41
+ }
42
+ };
43
+ </script>
44
+
45
+ <style lang="postcss" scoped>
46
+ .pui-datatableFooter {
47
+ position: fixed;
48
+ background-color: var(--N-0);
49
+ bottom: 0px;
50
+ width: calc(100% - 64px);
51
+ z-index: 100;
52
+ &--menuexpanded {
53
+ width: calc(100% - 304px);
54
+ }
55
+ }
56
+ .pui-datatableFooter_mobile {
57
+ position: fixed;
58
+ background-color: var(--N-0);
59
+ bottom: 0px;
60
+ width: 100%;
61
+ z-index: 100;
62
+ margin-left: -4px !important;
63
+ box-shadow: none !important;
64
+ }
65
+ </style>
@@ -0,0 +1,132 @@
1
+ <template>
2
+ <pui-datatable-footer class="pui-gridActionFooter">
3
+ <v-layout align-center justify-space-between:fill-height="!isMobile">
4
+ <v-btn text outlined @click.native="back()">{{ this.$t('form.cancel') }}</v-btn>
5
+ <div>
6
+ <p v-if="!showCurrentFilterDialog && !isMobile" class="ml-2 pui-gridActionFooter_message">
7
+ {{ this.$t('puidatatables.selectmulti') }}
8
+ </p>
9
+ </div>
10
+ <v-spacer></v-spacer>
11
+ <v-btn v-if="isAplicableToCurrentFilter" depressed color="secondary" class="elevation-0" @click.native="showCurrentFilterDialog = true">{{
12
+ isMobile ? this.$t('puidatatables.applytocurrentfiltermobile') : this.$t('puidatatables.applytocurrentfilter')
13
+ }}</v-btn>
14
+ <v-btn :disabled="isDisabled" depressed color="secondary" class="elevation-0" @click.native="runAction()">{{
15
+ isMobile ? this.$t('puidatatables.applyactionmobile') : this.$t('puidatatables.applyActionToSelected')
16
+ }}</v-btn>
17
+ </v-layout>
18
+ <pui-modal-dialog
19
+ v-if="showCurrentFilterDialog"
20
+ :cancelText="$t('form.cancel')"
21
+ :okText="$t('pui9.accept')"
22
+ :titleText="$t('puidatatables.applytocurrentfilter')"
23
+ :messageText="$t('puidatatables.applytocurrentfilter.message')"
24
+ :dialogName="`applyToCurrentFilter-${this.modelName}`"
25
+ ></pui-modal-dialog>
26
+ </pui-datatable-footer>
27
+ </template>
28
+
29
+ <script>
30
+ import PuiDatatableFooter from './PuiDatatableFooter';
31
+
32
+ export default {
33
+ name: 'PuiGridActionFooter',
34
+ components: {
35
+ PuiDatatableFooter
36
+ },
37
+ props: {
38
+ modelName: {
39
+ type: String
40
+ },
41
+ action: {
42
+ type: Object,
43
+ required: false
44
+ },
45
+ registries: {
46
+ type: Array,
47
+ required: false
48
+ }
49
+ },
50
+ data() {
51
+ return {
52
+ showCurrentFilterDialog: false,
53
+ isMobile: false
54
+ };
55
+ },
56
+ computed: {
57
+ isDisabled() {
58
+ if (this.registries && this.registries.length > 0) {
59
+ return false;
60
+ }
61
+ return true;
62
+ },
63
+ isAplicableToCurrentFilter() {
64
+ if (this.action && this.action.applicableToCurrentFilter) {
65
+ return true;
66
+ }
67
+ return false;
68
+ }
69
+ },
70
+ created() {
71
+ this.isMobile = this.$store.getters.isMobile;
72
+ },
73
+ mounted() {
74
+ this.$puiEvents.$on(`pui-modalDialog-applyToCurrentFilter-${this.modelName}-ok`, () => {
75
+ this.runActionWithCurrentFilter();
76
+ this.showCurrentFilterDialog = false;
77
+ });
78
+ this.$puiEvents.$on(`pui-modalDialog-applyToCurrentFilter-${this.modelName}-cancel`, () => {
79
+ this.showCurrentFilterDialog = false;
80
+ });
81
+ },
82
+ destroyed() {
83
+ this.$puiEvents.$off(`pui-modalDialog-applyToCurrentFilter-${this.modelName}-ok`);
84
+ this.$puiEvents.$off(`pui-modalDialog-applyToCurrentFilter-${this.modelName}-cancel`);
85
+ },
86
+ methods: {
87
+ runAction() {
88
+ this.$puiEvents.$emit(`onPui-action-running-${this.modelName}`);
89
+ const model = this.$store.getters.getModelByName(this.modelName);
90
+ const selectedRows = this.registries.map((registries) => {
91
+ return Object.values(registries)[0];
92
+ });
93
+ this.action.runAction.call(this, this.action, model, selectedRows);
94
+ },
95
+ runActionWithCurrentFilter() {
96
+ this.$puiEvents.$emit(`onPui-action-running-${this.modelName}`);
97
+ const model = this.$store.getters.getModelByName(this.modelName);
98
+ const parameters = this.getParameters();
99
+ this.action.runAction.call(this, this.action, model, null, parameters);
100
+ },
101
+ getParameters() {
102
+ const currentSearch = this.$parent.$parent.getCurrentSearch();
103
+ let queryText = '';
104
+ let queryFields = [];
105
+ if (currentSearch !== undefined && currentSearch !== null) {
106
+ queryText = currentSearch[0];
107
+ queryFields = currentSearch[1].map((field) => {
108
+ return field.name;
109
+ });
110
+ }
111
+ return {
112
+ queryText: queryText,
113
+ queryFields: queryFields,
114
+ queryLang: this.$store.getters.getUserLanguage,
115
+ filter: this.$parent.$parent.getCurrentFilter(),
116
+ order: this.$parent.$parent.getCurrentSorting()
117
+ };
118
+ },
119
+ back() {
120
+ this.$puiEvents.$emit(`onPui-action-running-cancelled-${this.modelName}`);
121
+ }
122
+ }
123
+ };
124
+ </script>
125
+
126
+ <style lang="postcss" scoped>
127
+ .pui-gridActionFooter {
128
+ &_message {
129
+ margin-bottom: 0px !important;
130
+ }
131
+ }
132
+ </style>
@@ -0,0 +1,138 @@
1
+ <template>
2
+ <div>
3
+ <div ref="btn">
4
+ <v-btn class="elevation-0 pui-toolbar__btn pui-toolbar__actionBtn" @click.native.stop="states.active = !states.active">
5
+ <v-icon class="pr-3" small>fa fa-file-export</v-icon>
6
+ <v-icon v-if="!states.active" small>fa fa-angle-down</v-icon>
7
+ <v-icon v-else small>fa fa-angle-up</v-icon>
8
+ </v-btn>
9
+ </div>
10
+ <div v-show="states.active" class="pui-dialog--export elevation-5 pl-0 pr-0" :ref="'dialog'" @click.stop>
11
+ <v-layout wrap class="mb-1">
12
+ <v-list>
13
+ <v-list-item
14
+ v-for="format in formats"
15
+ :key="format.extension"
16
+ @click="exportData(format)"
17
+ tabindex="0"
18
+ @keydown.native.enter="exportData(format)"
19
+ >
20
+ <v-list-item-action>
21
+ <v-icon style="font-size: 16px">{{ `fa fa-${format.icon}` }}</v-icon>
22
+ </v-list-item-action>
23
+
24
+ <v-list-item-content>
25
+ <v-list-item-title v-text="`${$t('puidatatables.export_to')} ${format.name}`"></v-list-item-title>
26
+ </v-list-item-content>
27
+ </v-list-item>
28
+ </v-list>
29
+ </v-layout>
30
+ </div>
31
+ </div>
32
+ </template>
33
+
34
+ <script>
35
+ import PuiToolbarBtnMixin from '../../../mixins/PuiToolbarBtnMixin';
36
+
37
+ export default {
38
+ name: 'PuiQuickEditionExportBtn',
39
+ mixins: [PuiToolbarBtnMixin],
40
+ props: {
41
+ modelName: {
42
+ type: String,
43
+ required: true
44
+ },
45
+ externalFilter: {
46
+ type: Object
47
+ }
48
+ },
49
+ data() {
50
+ return {
51
+ idTool: 'export',
52
+ panel: {
53
+ position: {}
54
+ },
55
+ formats: {
56
+ pdf: {
57
+ name: 'PDF',
58
+ type: 'direct',
59
+ extension: '.pdf',
60
+ icon: 'file-pdf'
61
+ },
62
+ csv: {
63
+ name: 'CSV',
64
+ type: 'direct',
65
+ extension: '.csv',
66
+ icon: 'file-csv'
67
+ },
68
+ excel: {
69
+ name: 'Excel',
70
+ type: 'direct',
71
+ extension: '.xls',
72
+ icon: 'file-excel'
73
+ }
74
+ }
75
+ };
76
+ },
77
+ mounted() {
78
+ this.calculateDialogPosition();
79
+ this.$puiEvents.$on(`onPui-apply-sorting-dataTable-${this.modelName}`, (sortingRule) => {
80
+ this.externalOrder = sortingRule;
81
+ });
82
+ },
83
+ destroyed() {
84
+ this.$puiEvents.$off(`onPui-apply-sorting-dataTable-${this.modelName}`);
85
+ },
86
+ methods: {
87
+ exportData(format) {
88
+ this.$puiNotify.info(this.$t('puidatatables.downloading'));
89
+ const currentConfiguration = this.$store.getters.getCurrentGridConfiguration(this.modelName);
90
+ const currentColumns = currentConfiguration.configuration.columns
91
+ .filter((column) => {
92
+ return column.visible === undefined || column.visible === true || column.visibility === 'visible';
93
+ })
94
+ .map((column, index) => {
95
+ let dateformat = this.$store.getters.javaDateFormat;
96
+ if (
97
+ !(
98
+ this.$parent.$parent.modelColumnDefs &&
99
+ this.$parent.$parent.modelColumnDefs[column.name] &&
100
+ this.$parent.$parent.modelColumnDefs[column.name].withoutHours
101
+ )
102
+ ) {
103
+ dateformat += ' ' + this.$store.getters.timeFormat;
104
+ }
105
+ return {
106
+ order: index,
107
+ title: this.$t(column.title),
108
+ name: column.name,
109
+ dateformat: dateformat
110
+ };
111
+ });
112
+ const currentFilter = this.externalFilter;
113
+ const currentOrder = this.externalOrder || currentConfiguration.configuration.order;
114
+
115
+ this.$puiRequests.downloadFileRequest(
116
+ 'post',
117
+ `/${this.modelName}/export`,
118
+ {
119
+ model: this.modelName,
120
+ exportTitle: this.$t(this.modelName),
121
+ exportType: format.name.toLowerCase(),
122
+ exportColumns: currentColumns,
123
+ filter: currentFilter,
124
+ order: currentOrder,
125
+ queryFlexible: false,
126
+ queryLang: this.$store.getters.getUserLanguage
127
+ },
128
+ (response) => {
129
+ const link = document.createElement('a');
130
+ link.href = window.URL.createObjectURL(new window.Blob([response.data]));
131
+ link.download = this.$puiUtils.getFilenameFromHeaders(response.headers);
132
+ link.click();
133
+ }
134
+ );
135
+ }
136
+ }
137
+ };
138
+ </script>
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <v-form v-model="valid" lazy-validation :ref="quickEditionForm">
3
+ <v-layout wrap>
4
+ <v-flex xs12>
5
+ <component
6
+ v-if="formComponent && formModel"
7
+ :is="formComponent"
8
+ :model="formModel"
9
+ :formDisabled="formDisabled"
10
+ :parentModel="parentModel"
11
+ />
12
+ </v-flex>
13
+ </v-layout>
14
+ </v-form>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ name: 'PuiQuickEditionForm',
20
+ data() {
21
+ return {
22
+ valid: true,
23
+ quickEditionForm: `${this.modelName}_quickeditionform`
24
+ };
25
+ },
26
+ props: {
27
+ modelName: {
28
+ type: String,
29
+ required: true
30
+ },
31
+ formComponent: {
32
+ type: String,
33
+ required: true
34
+ },
35
+ formModel: {
36
+ type: Object,
37
+ required: true
38
+ },
39
+ formDisabled: {
40
+ type: Boolean,
41
+ required: true
42
+ },
43
+ parentModel: {
44
+ type: Object
45
+ }
46
+ },
47
+ mounted() {
48
+ this.$puiEvents.$on(`onPui-quickEditionForm-${this.modelName}-validate`, () => {
49
+ if (this.$refs[this.quickEditionForm] && this.$refs[this.quickEditionForm].validate && !this.$refs[this.quickEditionForm].validate()) {
50
+ this.$puiEvents.$emit(`pui-modalDialog-saveRegistry-${this.modelName}-validate`, false);
51
+ } else {
52
+ this.$puiEvents.$emit(`pui-modalDialog-saveRegistry-${this.modelName}-validate`, true);
53
+ }
54
+ });
55
+ },
56
+ destroyed() {
57
+ this.$puiEvents.$off(`onPui-quickEditionForm-${this.modelName}-validate`);
58
+ }
59
+ };
60
+ </script>