@d-mok/quasar-app-extension-quasar-axe 2.0.22 → 2.0.23
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/package.json
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import Papa from 'papaparse'
|
|
2
|
+
|
|
1
3
|
export function unparseCSV(arr: Record<string, any>[]): string {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
return Papa.unparse(arr, {
|
|
5
|
+
quotes: false, //or array of booleans
|
|
6
|
+
quoteChar: '"',
|
|
7
|
+
escapeChar: '"',
|
|
8
|
+
delimiter: '\t',
|
|
9
|
+
header: true,
|
|
10
|
+
newline: '\r\n',
|
|
11
|
+
skipEmptyLines: false, //other option is 'greedy', meaning skip delimiters, quotes, and whitespace.
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
// let fields = Object.keys(arr[0])
|
|
15
|
+
// let csv = fields.join(delimiter) + '\n'
|
|
16
|
+
// for (let obj of arr) {
|
|
17
|
+
// let line = fields.map(f => String(obj[f])).join(delimiter)
|
|
18
|
+
// csv += line + '\n'
|
|
19
|
+
// }
|
|
20
|
+
// return csv
|
|
9
21
|
}
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
</q-card-section>
|
|
31
31
|
|
|
32
32
|
<q-card-actions align="right">
|
|
33
|
+
<q-btn
|
|
34
|
+
label="Copy"
|
|
35
|
+
flat
|
|
36
|
+
@click="copy"
|
|
37
|
+
/>
|
|
33
38
|
<q-btn
|
|
34
39
|
v-if="cancel"
|
|
35
40
|
label="Cancel"
|
|
@@ -52,6 +57,8 @@ import handson from './handson.vue'
|
|
|
52
57
|
import { useDialogPluginComponent } from 'quasar'
|
|
53
58
|
import { ref } from 'vue'
|
|
54
59
|
import { toSchema, isMatchSchema, isPrimitive, clone } from './schema'
|
|
60
|
+
import { unparseCSV } from '../../csv'
|
|
61
|
+
import { copyToClipboard } from 'quasar'
|
|
55
62
|
|
|
56
63
|
defineEmits([...useDialogPluginComponent.emits])
|
|
57
64
|
|
|
@@ -106,4 +113,11 @@ function isBlank(row: row): boolean {
|
|
|
106
113
|
function filterBlank(rows: row[]): row[] {
|
|
107
114
|
return rows.filter($ => !isBlank($))
|
|
108
115
|
}
|
|
116
|
+
|
|
117
|
+
// copy to clipboard
|
|
118
|
+
|
|
119
|
+
function copy() {
|
|
120
|
+
let csv = unparseCSV(dummy.value)
|
|
121
|
+
copyToClipboard(csv)
|
|
122
|
+
}
|
|
109
123
|
</script>
|