This commit is contained in:
Dmitry Belyaev 2021-05-30 17:26:40 +03:00
parent 37af190769
commit 3c589a4b05
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
2 changed files with 42 additions and 35 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <div class="container-fluid">
<h2>Список баз</h2> <h2>Список баз</h2>
<div v-if="loading_error" class="text-danger m-4"> <div v-if="loading_error" class="text-danger m-4">
<span class="fs-1">&#9940;</span><br /> <span class="fs-1">&#9940;</span><br />
@ -21,17 +21,17 @@
<table v-else class="table table-striped"> <table v-else class="table table-striped">
<thead> <thead>
<tr> <tr>
<th scope="col" class="col">#</th> <th scope="col" class="col text-end">#</th>
<th scope="col" class="col-lg-6">Имя</th> <th scope="col" class="col text-center">Имя</th>
<th scope="col" class="col">Ссылка</th> <th scope="col" class="col text-start">Ссылка</th>
<th scope="col" class="col">Действия</th> <th scope="col" class="col text-end">Действия</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="(infobase, index) in infobases" :key="infobase.name"> <tr v-for="(infobase, index) in infobases" :key="infobase.name">
<th scope="row">{{ index + 1 }}</th> <th class="text-end" scope="row">{{ index + 1 }}</th>
<td>{{ infobase.name }}</td> <td class="text-center">{{ infobase.name }}</td>
<td> <td class="text-start">
<template v-if="infobase.publicated"> <template v-if="infobase.publicated">
<InfobaseURLEditor <InfobaseURLEditor
v-if="is_edit_url_active(infobase.name)" v-if="is_edit_url_active(infobase.name)"
@ -41,12 +41,16 @@
@submit="apply_edit_url" @submit="apply_edit_url"
@cancel="cancel_edit_url" @cancel="cancel_edit_url"
/> />
<a v-else v-bind:href="url_base + infobase.url" target="blank">{{ <a
infobase.url class="text-break"
}}</a> v-if="!is_edit_url_active(infobase.name)"
v-bind:href="url_base + infobase.url"
target="blank"
>{{ infobase.url }}</a
>
</template> </template>
</td> </td>
<td> <td class="text-end">
<div <div
v-if="!is_edit_url_active(infobase.name)" v-if="!is_edit_url_active(infobase.name)"
class="btn-group shadow" class="btn-group shadow"
@ -57,7 +61,7 @@
type="button" type="button"
class="btn btn-warning" class="btn btn-warning"
@click="start_edit_url(infobase.name)" @click="start_edit_url(infobase.name)"
hint="Изменить URL" title="Изменить URL"
> >
Изменить Изменить
</button> </button>
@ -66,16 +70,16 @@
type="button" type="button"
class="btn btn-danger" class="btn btn-danger"
@click="remove_publication(infobase.name)" @click="remove_publication(infobase.name)"
hint="Снять с публикации" title="Снять с публикации"
> >
Отменить Отменить
</button> </button>
<button <button
v-else v-if="!infobase.publicated"
type="button" type="button"
class="btn btn-primary" class="btn btn-primary"
@click="publicate(infobase.name)" @click="add_publication(infobase.name)"
hint="Опубликовать базу" title="Опубликовать базу"
> >
Публиковать Публиковать
</button> </button>
@ -108,34 +112,37 @@ export default {
url_editors: {}, url_editors: {},
}), }),
methods: { methods: {
publicate(name) { infobase(name) {
let infobase = this.infobases.find((infobase) => name === infobase.name); return this.infobases.find((infobase) => name === infobase.name);
},
add_publication(name) {
let infobase = this.infobase(name);
if (infobase === undefined) return; if (infobase === undefined) return;
infobase.publicated = true; infobase.publicated = true;
}, },
remove_publication(name) { remove_publication(name) {
let infobase = this.infobases.find((infobase) => name === infobase.name); let infobase = this.infobase(name);
if (infobase === undefined) return; if (infobase === undefined) return;
infobase.publicated = false; infobase.publicated = false;
}, },
set_url(name, url) { set_url(name, url) {
let infobase = this.infobases.find((infobase) => name === infobase.name); let infobase = this.infobase(name);
if (infobase === undefined) return; if (infobase === undefined) return;
infobase.url = url; infobase.url = url;
}, },
start_edit_url(name) { start_edit_url(name) {
let infobase = this.infobases.find((infobase) => name === infobase.name); let infobase = this.infobase(name);
if (infobase === undefined) return; if (infobase === undefined) return;
this.url_editors[name] = true; this.url_editors[name] = true;
}, },
cancel_edit_url({name}) { cancel_edit_url({ name }) {
delete this.url_editors[name]; delete this.url_editors[name];
}, },
apply_edit_url({name, url}) { apply_edit_url({ name, url }) {
this.set_url(name, url); this.set_url(name, url);
delete this.url_editors[name]; delete this.url_editors[name];
}, },

View File

@ -1,12 +1,12 @@
<template> <template>
<form @submit.prevent="submit"> <form @submit.prevent="submit">
<div class="btn-group shadow rounded-start" role="group"> <div class="input-group shadow" role="group">
<input <input type="text" v-model="url" class="form-control" />
type="text" <button
v-model="url" type="submit"
class="rounded-start" class="btn btn-sm btn-outline-primary"
/> title="Принять"
<button type="submit" class="btn btn-sm btn-primary" hint="Принять"> >
<svg width="16" height="16"> <svg width="16" height="16">
<use xlink:href="#check-lg--sprite"></use> <use xlink:href="#check-lg--sprite"></use>
</svg> </svg>
@ -15,7 +15,7 @@
type="button" type="button"
class="btn btn-sm btn-outline-secondary" class="btn btn-sm btn-outline-secondary"
@click="cancel" @click="cancel"
hint="Отменить" title="Отменить"
> >
<svg width="16" height="16"><use xlink:href="#x-lg--sprite"></use></svg> <svg width="16" height="16"><use xlink:href="#x-lg--sprite"></use></svg>
</button> </button>
@ -46,7 +46,7 @@ export default {
}, },
emits: { emits: {
submit: ({ name, url }) => { submit: ({ name, url }) => {
if (name && url ) { if (name && url) {
return true; return true;
} else { } else {
console.warn("Invalid submit event payload!"); console.warn("Invalid submit event payload!");
@ -58,7 +58,7 @@ export default {
methods: { methods: {
submit() { submit() {
if (this.url === this.init_url) { if (this.url === this.init_url) {
this.cancel() this.cancel();
return; return;
} }
this.$emit("submit", { name: this.infobase_name, url: this.url }); this.$emit("submit", { name: this.infobase_name, url: this.url });