Skip to content

Commit 4ed642c

Browse files
committed
New feature - VueUiTable - Add field to change export filename #250
1 parent b846dda commit 4ed642c

File tree

3 files changed

+68
-7
lines changed

3 files changed

+68
-7
lines changed

src/components/vue-ui-table.vue

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434
<span>{{ FINAL_CONFIG.translations.exportPageButton }}</span>
3535
</button>
3636
</div>
37+
<div class="vue-ui-table-dialog-field">
38+
<label class="label vue-ui-table-dialog-input-label">
39+
{{ FINAL_CONFIG.translations.filename }}
40+
<input ref="filenameInputRef" @keydown.space.stop pattern=".*" class="vue-ui-table-dialog-input" type="text" v-model="filename"/>
41+
</label>
42+
<button class="vue-ui-table-dialog-field-button" @click="filename = ''">
43+
<BaseIcon name="close" :stroke="FINAL_CONFIG.style.exportMenu.color" :size="18"/>
44+
</button>
45+
</div>
3746
</div>
3847
</div>
3948
</div>
@@ -557,6 +566,7 @@ import {
557566
import { useConfig } from "../useConfig";
558567
import VueUiXy from "./vue-ui-xy.vue";
559568
import VueUiDonut from "./vue-ui-donut.vue";
569+
import BaseIcon from "../atoms/BaseIcon.vue";
560570
561571
export default {
562572
name: "vue-ui-table",
@@ -574,7 +584,7 @@ export default {
574584
}
575585
}
576586
},
577-
components: { VueUiXy, VueUiDonut },
587+
components: { VueUiXy, VueUiDonut, BaseIcon },
578588
emits: ['page-change'],
579589
data() {
580590
const uid = `vue-ui-table-${Math.random()}`;
@@ -669,6 +679,7 @@ export default {
669679
type: head.type, // this attribute is mandatory
670680
}
671681
}),
682+
filename: '',
672683
}
673684
},
674685
mounted() {
@@ -692,8 +703,17 @@ export default {
692703
e.preventDefault();
693704
}
694705
})
706+
this.filename = this.FINAL_CONFIG.style.exportMenu.filename;
695707
},
696708
watch: {
709+
isExportRequest: function (bool) {
710+
if (bool) {
711+
const filenameInput = this.$refs.filenameInputRef;
712+
if (filenameInput) {
713+
filenameInput.focus();
714+
}
715+
}
716+
},
697717
showChart: function (hasChart) {
698718
if (hasChart) {
699719
this.$nextTick(() => {
@@ -1104,7 +1124,7 @@ export default {
11041124
const body = selection === 'all' ? this.bodyCopy.map(b => b.td) : this.visibleRows.map(r => r.td);
11051125
const table = [head].concat(body);
11061126
const csvContent = this.createCsvContent(table);
1107-
this.downloadCsv({ csvContent, title: 'vue-ui-table' })
1127+
this.downloadCsv({ csvContent, title: this.filename })
11081128
},
11091129
calcLinearProgression,
11101130
closeAllDropdowns() {
@@ -2388,7 +2408,36 @@ button.th-reset:not(:disabled) {
23882408
justify-content: flex-start;
23892409
}
23902410
2391-
.vue-ui-table-main .vue-ui-table-export-hub-option-wrapper .label {
2411+
.vue-ui-table-main .vue-ui-table-dialog-field {
2412+
width: calc(100% - 12px);
2413+
padding-right: 12px;
2414+
align-items:center;
2415+
position: relative;
2416+
}
2417+
2418+
.vue-ui-table-dialog-field {
2419+
width: 100%;
2420+
}
2421+
2422+
input.vue-ui-table-dialog-input {
2423+
width: calc(100% - 44px);
2424+
padding-right: 44px;
2425+
}
2426+
2427+
.vue-ui-table-dialog-field-button {
2428+
background: transparent;
2429+
border: none !important;
2430+
box-shadow: none;
2431+
outline: none;
2432+
position: absolute;
2433+
right: 4px;
2434+
top: 26px;
2435+
min-width: 36px !important;
2436+
width: 36px;
2437+
}
2438+
2439+
.vue-ui-table-main .vue-ui-table-export-hub-option-wrapper .label,
2440+
.vue-ui-table-main .vue-ui-table-dialog-field .label {
23922441
font-size: 12px;
23932442
line-height: 12px;
23942443
margin-bottom: 6px;
@@ -2442,4 +2491,7 @@ button.th-reset:not(:disabled) {
24422491
opacity: 0;
24432492
}
24442493
}
2494+
input {
2495+
font-family: inherit !important;
2496+
}
24452497
</style>

src/useConfig.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export function useConfig() {
233233
startIndex: null,
234234
endIndex: null,
235235
enableRangeHandles: true,
236-
enableSelectionDrag: true
236+
enableSelectionDrag: true,
237237
}
238238

239239
const MINIMAP = {
@@ -245,6 +245,8 @@ export function useConfig() {
245245
selectionRadius: 2,
246246
indicatorColor: COLOR_BLACK,
247247
verticalHandles: false,
248+
compact: true,
249+
merged: false,
248250
}
249251

250252
const vue_ui_stackbar = {
@@ -2913,7 +2915,7 @@ export function useConfig() {
29132915
zoomStartIndex: null,
29142916
zoomEndIndex: null,
29152917
zoomEnableRangeHandles: true,
2916-
zoomEnableSelectionDrag: true
2918+
zoomEnableSelectionDrag: true,
29172919
}
29182920

29192921
const vue_ui_age_pyramid = {
@@ -5337,7 +5339,8 @@ export function useConfig() {
53375339
buttons: {
53385340
backgroundColor: COLOR_WHITE_ALMOST,
53395341
color: COLOR_BLACK
5340-
}
5342+
},
5343+
filename: ''
53415344
},
53425345
closeButtons: {
53435346
backgroundColor: 'transparent',
@@ -5419,7 +5422,8 @@ export function useConfig() {
54195422
sum: 'Sum',
54205423
to: 'To',
54215424
total: 'Total',
5422-
totalRows: 'Total rows'
5425+
totalRows: 'Total rows',
5426+
filename: 'File name'
54235427
},
54245428
useChart: true
54255429
}

types/vue-data-ui.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ declare module "vue-data-ui" {
306306
selectionRadius?: number;
307307
indicatorColor?: string;
308308
verticalHandles?: boolean;
309+
compact?: boolean;
310+
merged?: boolean;
309311
};
310312

311313
export type ChartZoom = {
@@ -5563,6 +5565,7 @@ declare module "vue-data-ui" {
55635565
backgroundColor?: string;
55645566
color?: string;
55655567
};
5568+
filename?: string | number;
55665569
};
55675570
closeButtons?: {
55685571
backgroundColor?: string;
@@ -5645,6 +5648,7 @@ declare module "vue-data-ui" {
56455648
to?: string;
56465649
total?: string;
56475650
totalRows?: string;
5651+
filename?: string;
56485652
};
56495653
useChart?: boolean;
56505654
};
@@ -6189,6 +6193,7 @@ declare module "vue-data-ui" {
61896193
zoomEndIndex?: number | null;
61906194
zoomEnableRangeHandles?: boolean;
61916195
zoomEnableSelectionDrag?: boolean;
6196+
zoomCompact?: boolean;
61926197
userOptionsPosition?: "right" | "left";
61936198
userOptionsButtons?: {
61946199
tooltip?: boolean;

0 commit comments

Comments
 (0)