Lint + few best practices
This commit is contained in:
@@ -43,7 +43,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
props: {
|
||||
show: Boolean
|
||||
@@ -62,10 +61,12 @@ export default {
|
||||
this.$toast.info($t("invalid_environment_name"));
|
||||
return;
|
||||
}
|
||||
let newEnvironment = [{
|
||||
name: this.$data.name,
|
||||
variables: []
|
||||
}]
|
||||
let newEnvironment = [
|
||||
{
|
||||
name: this.$data.name,
|
||||
variables: []
|
||||
}
|
||||
];
|
||||
this.$store.commit("postwoman/importAddEnvironments", newEnvironment);
|
||||
this.$emit("hide-modal");
|
||||
},
|
||||
|
||||
@@ -49,18 +49,21 @@
|
||||
></textarea>
|
||||
</li>
|
||||
</ul>
|
||||
<ul v-for="(variable, index) in this.editingEnvCopy.variables" :key="index">
|
||||
<ul
|
||||
v-for="(variable, index) in this.editingEnvCopy.variables"
|
||||
:key="index"
|
||||
>
|
||||
<li>
|
||||
<input
|
||||
:placeholder="$t('parameter_count', { count: index + 1 })"
|
||||
:name="'param' + index"
|
||||
:value="variable.key"
|
||||
@change="
|
||||
$store.commit('postwoman/setVariableKey', {
|
||||
index,
|
||||
value: $event.target.value
|
||||
})
|
||||
"
|
||||
$store.commit('postwoman/setVariableKey', {
|
||||
index,
|
||||
value: $event.target.value
|
||||
})
|
||||
"
|
||||
autofocus
|
||||
/>
|
||||
</li>
|
||||
@@ -70,11 +73,11 @@
|
||||
:name="'value' + index"
|
||||
:value="variable.value"
|
||||
@change="
|
||||
$store.commit('postwoman/setVariableValue', {
|
||||
index,
|
||||
value: $event.target.value
|
||||
})
|
||||
"
|
||||
$store.commit('postwoman/setVariableValue', {
|
||||
index,
|
||||
value: $event.target.value
|
||||
})
|
||||
"
|
||||
/>
|
||||
</li>
|
||||
<div>
|
||||
@@ -137,21 +140,24 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
editingEnvironment: function(update) {
|
||||
this.$store.commit("postwoman/setEditingEnvironment", this.$props.editingEnvironment);
|
||||
this.$store.commit(
|
||||
"postwoman/setEditingEnvironment",
|
||||
this.$props.editingEnvironment
|
||||
);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
editingEnvCopy() {
|
||||
return this.$store.state.postwoman.editingEnvironment
|
||||
return this.$store.state.postwoman.editingEnvironment;
|
||||
},
|
||||
variableString() {
|
||||
const result = this.editingEnvCopy.variables
|
||||
const result = this.editingEnvCopy.variables;
|
||||
return result === "" ? "" : JSON.stringify(result);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clearContent(e) {
|
||||
this.$store.commit("postwoman/removeVariables", [])
|
||||
this.$store.commit("postwoman/removeVariables", []);
|
||||
e.target.innerHTML = this.doneButton;
|
||||
this.$toast.info(this.$t("cleared"), {
|
||||
icon: "clear_all"
|
||||
@@ -162,15 +168,17 @@ export default {
|
||||
);
|
||||
},
|
||||
addEnvironmentVariable() {
|
||||
let value = { key: "", value: "" }
|
||||
let value = { key: "", value: "" };
|
||||
this.$store.commit("postwoman/addVariable", value);
|
||||
},
|
||||
removeEnvironmentVariable(index) {
|
||||
let variableIndex = index
|
||||
const oldVariables = this.editingEnvCopy.variables.slice()
|
||||
const newVariables = this.editingEnvCopy.variables.filter((variable, index) => variableIndex !== index)
|
||||
let variableIndex = index;
|
||||
const oldVariables = this.editingEnvCopy.variables.slice();
|
||||
const newVariables = this.editingEnvCopy.variables.filter(
|
||||
(variable, index) => variableIndex !== index
|
||||
);
|
||||
|
||||
this.$store.commit("postwoman/removeVariable", newVariables)
|
||||
this.$store.commit("postwoman/removeVariable", newVariables);
|
||||
this.$toast.error(this.$t("deleted"), {
|
||||
icon: "delete",
|
||||
action: {
|
||||
@@ -198,7 +206,7 @@ export default {
|
||||
this.$emit("hide-modal");
|
||||
},
|
||||
hideModal() {
|
||||
this.$data.name = undefined
|
||||
this.$data.name = undefined;
|
||||
this.$emit("hide-modal");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,7 @@
|
||||
: $t('replace_current')
|
||||
}"
|
||||
>
|
||||
<button
|
||||
:disabled="true"
|
||||
class="icon"
|
||||
@click="syncEnvironments"
|
||||
>
|
||||
<button :disabled="true" class="icon" @click="syncEnvironments">
|
||||
<i class="material-icons">folder_shared</i>
|
||||
<span>{{ $t("import_from_sync") }}</span>
|
||||
</button>
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<template>
|
||||
<pw-section class="green" icon="history" :label="$t('environment')" ref="environment">
|
||||
<pw-section
|
||||
class="green"
|
||||
icon="history"
|
||||
:label="$t('environment')"
|
||||
ref="environment"
|
||||
>
|
||||
<addEnvironment :show="showModalAdd" @hide-modal="displayModalAdd(false)" />
|
||||
<editEnvironment
|
||||
:show="showModalEdit"
|
||||
@@ -11,7 +16,6 @@
|
||||
:show="showModalImportExport"
|
||||
@hide-modal="displayModalImportExport(false)"
|
||||
/>
|
||||
|
||||
<div class="flex-wrap">
|
||||
<div>
|
||||
<button class="icon" @click="displayModalAdd(true)">
|
||||
@@ -35,7 +39,10 @@
|
||||
:remain="Math.min(5, environments.length)"
|
||||
>
|
||||
<ul>
|
||||
<li v-for="(environment, index) in environments" :key="environment.name">
|
||||
<li
|
||||
v-for="(environment, index) in environments"
|
||||
:key="environment.name"
|
||||
>
|
||||
<environment
|
||||
:environmentIndex="index"
|
||||
:environment="environment"
|
||||
@@ -84,7 +91,7 @@ export default {
|
||||
showModalAdd: false,
|
||||
showModalEdit: false,
|
||||
editingEnvironment: undefined,
|
||||
editingEnvironmentIndex: undefined,
|
||||
editingEnvironmentIndex: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -125,9 +132,9 @@ export default {
|
||||
syncEnvironments() {
|
||||
// TODO
|
||||
},
|
||||
beforeDestroy() {
|
||||
document.removeEventListener("keydown", this._keyListener);
|
||||
beforeDestroy() {
|
||||
document.removeEventListener("keydown", this._keyListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user