mock api rewtite + more vuex

This commit is contained in:
2021-05-31 16:09:36 +03:00
parent bb204e12ab
commit 91f582c289
4 changed files with 72 additions and 56 deletions
+15 -21
View File
@@ -93,7 +93,7 @@
<script>
import "bootstrap-icons/icons/exclamation-triangle-fill.svg?sprite";
import { mapGetters } from "vuex";
import { mapGetters, mapMutations } from "vuex";
import InfobaseURLEditor from "@/components/InfobaseURLEditor.vue";
@@ -109,31 +109,25 @@ export default {
infobases: [],
url_editors: {},
}),
computed: mapGetters(["allInfobases", "isLoading", "isLoadingError"]),
computed: mapGetters([
"allInfobases",
"getInfobaseByName",
"isLoading",
"isLoadingError",
]),
methods: {
infobase(name) {
return this.allInfobases.find((infobase) => name === infobase.name);
},
...mapMutations({
set_url: "setInfobaseURL",
set_publication: "setInfobasePublication",
}),
add_publication(name) {
let infobase = this.infobase(name);
if (infobase === undefined) return;
infobase.publicated = true;
this.set_publication({ name, publicated: true });
},
remove_publication(name) {
let infobase = this.infobase(name);
if (infobase === undefined) return;
infobase.publicated = false;
},
set_url(name, url) {
let infobase = this.infobase(name);
if (infobase === undefined) return;
infobase.url = url;
this.set_publication({ name, publicated: false });
},
start_edit_url(name) {
let infobase = this.infobase(name);
let infobase = this.getInfobaseByName(name);
if (infobase === undefined) return;
this.url_editors[name] = true;
@@ -142,7 +136,7 @@ export default {
delete this.url_editors[name];
},
apply_edit_url({ name, url }) {
this.set_url(name, url);
this.set_url({ name, url });
delete this.url_editors[name];
},
is_edit_url_active(name) {