mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 13:07:08 +00:00
Fix copy/paste logic for lineNameInfo widget
This commit is contained in:
@@ -4,15 +4,15 @@
|
||||
<v-card-subtitle v-text="subtitle"></v-card-subtitle>
|
||||
<v-card-text>
|
||||
<v-tabs v-model="tab">
|
||||
<v-tab>Paths</v-tab>
|
||||
<v-tab>Globs</v-tab>
|
||||
<v-tab v-if="pattern">Pattern</v-tab>
|
||||
<v-tab v-if="lineNameInfo">Line info</v-tab>
|
||||
<v-tab tab-value="paths">Paths</v-tab>
|
||||
<v-tab tab-value="globs">Globs</v-tab>
|
||||
<v-tab tab-value="pattern" v-if="pattern">Pattern</v-tab>
|
||||
<v-tab tab-value="lineNameInfo" v-if="lineNameInfo">Line info</v-tab>
|
||||
</v-tabs>
|
||||
|
||||
<v-tabs-items v-model="tab">
|
||||
|
||||
<v-tab-item>
|
||||
<v-tab-item value="paths">
|
||||
<v-card flat>
|
||||
<v-card-subtitle>
|
||||
A list of directories which are searched for matching files.
|
||||
@@ -56,7 +56,7 @@
|
||||
</v-card>
|
||||
</v-tab-item>
|
||||
|
||||
<v-tab-item>
|
||||
<v-tab-item value="globs">
|
||||
<v-card flat>
|
||||
<v-card-subtitle>
|
||||
A list of <a href="https://en.wikipedia.org/wiki/Glob_(programming)" target="_blank">glob patterns</a> expanding to match the files of interest. Note that Linux is case-sensitive.
|
||||
@@ -93,7 +93,7 @@
|
||||
</v-card>
|
||||
</v-tab-item>
|
||||
|
||||
<v-tab-item v-if="pattern">
|
||||
<v-tab-item value="pattern" v-if="pattern">
|
||||
<v-card flat>
|
||||
<v-card-subtitle>
|
||||
Regular expression that describes the file format definition. Used to capture information such as line and sequence number, etc.
|
||||
@@ -153,7 +153,7 @@
|
||||
</v-card>
|
||||
</v-tab-item>
|
||||
|
||||
<v-tab-item v-if="lineNameInfo">
|
||||
<v-tab-item value="lineNameInfo">
|
||||
<v-card flat>
|
||||
<v-card-subtitle>
|
||||
Line information that will be extracted from file names
|
||||
@@ -165,14 +165,14 @@
|
||||
label="Example file name"
|
||||
hint="Enter the name of a representative file to make it easier to visualise your configuration"
|
||||
persistent-hint
|
||||
v-model="lineNameInfo.example"
|
||||
v-model="lineNameInfo_.example"
|
||||
></v-text-field>
|
||||
|
||||
<dougal-fixed-string-decoder
|
||||
:multiline="true"
|
||||
:text="lineNameInfo.example"
|
||||
:fixed.sync="lineNameInfo.fixed"
|
||||
:fields.sync="lineNameInfo.fields"
|
||||
:text="lineNameInfo_.example"
|
||||
:fixed.sync="lineNameInfo_.fixed"
|
||||
:fields.sync="lineNameInfo_.fields"
|
||||
></dougal-fixed-string-decoder>
|
||||
|
||||
</v-form>
|
||||
@@ -195,6 +195,23 @@
|
||||
@click="reset"
|
||||
>Reset</v-btn>
|
||||
-->
|
||||
<v-btn
|
||||
v-if="tab=='lineNameInfo'"
|
||||
:disabled="!validLineNameInfo"
|
||||
@click="copyLineNameInfo"
|
||||
title="Copy this definition into the clipboard. It can then be pasted into other sections or configurations."
|
||||
>
|
||||
<v-icon left>mdi-content-copy</v-icon>
|
||||
Copy
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="tab=='lineNameInfo'"
|
||||
@click="pasteLineNameInfo"
|
||||
title="Paste a line info definition copied from elsewhere"
|
||||
>
|
||||
<v-icon left>mdi-content-paste</v-icon>
|
||||
Paste
|
||||
</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="secondary"
|
||||
@@ -253,6 +270,9 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
validLineNameInfo () {
|
||||
return typeof this.lineNameInfo == 'object';
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
@@ -285,6 +305,28 @@ export default {
|
||||
|
||||
methods: {
|
||||
|
||||
async copyLineNameInfo () {
|
||||
await navigator.clipboard.writeText(JSON.stringify(this.lineNameInfo, null, 4));
|
||||
this.showSnack(["Line name information copied to clipboard", "primary"]);
|
||||
},
|
||||
|
||||
async pasteLineNameInfo () {
|
||||
const text = await navigator.clipboard.readText();
|
||||
try {
|
||||
const data = JSON.parse(text);
|
||||
if (["fixed", "fields", "example"].every( key => key in data )) {
|
||||
this.$emit("update:lineNameInfo", data);
|
||||
this.showSnack(["Line name information pasted from clipboard", "primary"]);
|
||||
} else {
|
||||
this.showSnack(["Clipboard contents are not valid line name information", "error"]);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
this.showSnack(["Clipboard contents are not valid line name information", "error"]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
reset () {
|
||||
this.globs_ = this.globs;
|
||||
this.paths_ = this.paths;
|
||||
@@ -302,6 +344,8 @@ export default {
|
||||
this.$emit('close');
|
||||
},
|
||||
|
||||
...mapActions(["showSnack"])
|
||||
|
||||
},
|
||||
|
||||
mounted () {
|
||||
|
||||
Reference in New Issue
Block a user