Добавлена маршрутизация, выбор вида списка: Авторы, Серии, Книги
This commit is contained in:
@@ -122,7 +122,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- Формирование списка конец ------------------------------------------------------------------>
|
<!-- Формирование списка конец ------------------------------------------------------------------>
|
||||||
|
|
||||||
<div v-if="ready && !refreshing && !tableData.length" class="row items-center q-ml-md" style="font-size: 120%">
|
<div v-if="!refreshing && !tableData.length" class="row items-center q-ml-md" style="font-size: 120%">
|
||||||
<q-icon class="la la-meh q-mr-xs" size="28px" />
|
<q-icon class="la la-meh q-mr-xs" size="28px" />
|
||||||
Поиск не дал результатов
|
Поиск не дал результатов
|
||||||
</div>
|
</div>
|
||||||
@@ -176,16 +176,11 @@ const componentOptions = {
|
|||||||
showDeleted() {
|
showDeleted() {
|
||||||
this.updateTableData();
|
this.updateTableData();
|
||||||
},
|
},
|
||||||
ready(newValue) {
|
|
||||||
if (newValue)
|
|
||||||
this.refresh();//no await
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
class AuthorList extends BaseList {
|
class AuthorList extends BaseList {
|
||||||
_options = componentOptions;
|
_options = componentOptions;
|
||||||
_props = {
|
_props = {
|
||||||
ready: Boolean,
|
|
||||||
list: Object,
|
list: Object,
|
||||||
search: Object,
|
search: Object,
|
||||||
genreMap: Object,
|
genreMap: Object,
|
||||||
@@ -221,6 +216,10 @@ class AuthorList extends BaseList {
|
|||||||
this.loadSettings();
|
this.loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.refresh();//no await
|
||||||
|
}
|
||||||
|
|
||||||
loadSettings() {
|
loadSettings() {
|
||||||
const settings = this.settings;
|
const settings = this.settings;
|
||||||
|
|
||||||
@@ -811,9 +810,6 @@ class AuthorList extends BaseList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refresh() {
|
async refresh() {
|
||||||
if (!this.ready)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//параметры запроса
|
//параметры запроса
|
||||||
const newQuery = _.cloneDeep(this.search);
|
const newQuery = _.cloneDeep(this.search);
|
||||||
newQuery.offset = (newQuery.page - 1)*newQuery.limit;
|
newQuery.offset = (newQuery.page - 1)*newQuery.limit;
|
||||||
|
|||||||
@@ -30,6 +30,16 @@
|
|||||||
</q-tooltip>
|
</q-tooltip>
|
||||||
</DivBtn>
|
</DivBtn>
|
||||||
|
|
||||||
|
<q-btn-toggle
|
||||||
|
v-model="selectedList"
|
||||||
|
class="q-ml-md"
|
||||||
|
toggle-color="primary"
|
||||||
|
:options="listOptions"
|
||||||
|
push
|
||||||
|
no-caps
|
||||||
|
rounded
|
||||||
|
/>
|
||||||
|
|
||||||
<div class="col"></div>
|
<div class="col"></div>
|
||||||
<div class="q-px-sm q-py-xs bg-green-12 clickable2" style="border: 1px solid #aaaaaa; border-radius: 6px" @click="openReleasePage">
|
<div class="q-px-sm q-py-xs bg-green-12 clickable2" style="border: 1px solid #aaaaaa; border-radius: 6px" @click="openReleasePage">
|
||||||
{{ projectName }}
|
{{ projectName }}
|
||||||
@@ -111,7 +121,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Формирование списка ------------------------------------------------------------------------>
|
<!-- Формирование списка ------------------------------------------------------------------------>
|
||||||
<AuthorList :ready="ready" :list="list" :search="search" :genre-map="genreMap" @list-event="listEvent" />
|
<component :is="selectedListComponent" v-if="selectedListComponent" :list="list" :search="search" :genre-map="genreMap" @list-event="listEvent" />
|
||||||
<!-- Формирование списка конец ------------------------------------------------------------------>
|
<!-- Формирование списка конец ------------------------------------------------------------------>
|
||||||
|
|
||||||
<div class="row justify-center">
|
<div class="row justify-center">
|
||||||
@@ -164,6 +174,7 @@
|
|||||||
import vueComponent from '../vueComponent.js';
|
import vueComponent from '../vueComponent.js';
|
||||||
|
|
||||||
import AuthorList from './AuthorList/AuthorList.vue';
|
import AuthorList from './AuthorList/AuthorList.vue';
|
||||||
|
import SeriesList from './SeriesList/SeriesList.vue';
|
||||||
|
|
||||||
import PageScroller from './PageScroller/PageScroller.vue';
|
import PageScroller from './PageScroller/PageScroller.vue';
|
||||||
import SelectGenreDialog from './SelectGenreDialog/SelectGenreDialog.vue';
|
import SelectGenreDialog from './SelectGenreDialog/SelectGenreDialog.vue';
|
||||||
@@ -178,9 +189,16 @@ import diffUtils from '../../share/diffUtils';
|
|||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
const route2component = {
|
||||||
|
'author': {component: 'AuthorList', label: 'Авторы'},
|
||||||
|
'series': {component: 'SeriesList', label: 'Серии'},
|
||||||
|
//'book': 'BookList',
|
||||||
|
};
|
||||||
|
|
||||||
const componentOptions = {
|
const componentOptions = {
|
||||||
components: {
|
components: {
|
||||||
AuthorList,
|
AuthorList,
|
||||||
|
SeriesList,
|
||||||
PageScroller,
|
PageScroller,
|
||||||
SelectGenreDialog,
|
SelectGenreDialog,
|
||||||
SelectLangDialog,
|
SelectLangDialog,
|
||||||
@@ -229,6 +247,7 @@ const componentOptions = {
|
|||||||
this.setSetting('abCacheEnabled', newValue);
|
this.setSetting('abCacheEnabled', newValue);
|
||||||
},
|
},
|
||||||
$route(to) {
|
$route(to) {
|
||||||
|
this.updateListFromRoute(to);
|
||||||
this.updateSearchFromRouteQuery(to);
|
this.updateSearchFromRouteQuery(to);
|
||||||
},
|
},
|
||||||
langDefault() {
|
langDefault() {
|
||||||
@@ -245,6 +264,13 @@ const componentOptions = {
|
|||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
|
selectedList(newValue) {
|
||||||
|
this.selectedListComponent = (route2component[newValue] ? route2component[newValue].component : null);
|
||||||
|
|
||||||
|
if (this.getListRoute() != newValue) {
|
||||||
|
this.updateRouteQueryFromSearch();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
class Search {
|
class Search {
|
||||||
@@ -252,6 +278,9 @@ class Search {
|
|||||||
|
|
||||||
ready = false;
|
ready = false;
|
||||||
|
|
||||||
|
selectedList = '';
|
||||||
|
selectedListComponent = '';
|
||||||
|
|
||||||
collection = '';
|
collection = '';
|
||||||
projectName = '';
|
projectName = '';
|
||||||
|
|
||||||
@@ -339,6 +368,7 @@ class Search {
|
|||||||
this.$refs.authorInput.focus();
|
this.$refs.authorInput.focus();
|
||||||
|
|
||||||
this.setDefaults();
|
this.setDefaults();
|
||||||
|
this.updateListFromRoute(this.$route);
|
||||||
this.updateSearchFromRouteQuery(this.$route);
|
this.updateSearchFromRouteQuery(this.$route);
|
||||||
|
|
||||||
this.sendMessage({type: 'mes', data: 'hello-from-inpx-web'});
|
this.sendMessage({type: 'mes', data: 'hello-from-inpx-web'});
|
||||||
@@ -403,6 +433,27 @@ class Search {
|
|||||||
return result.join(', ');
|
return result.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get listOptions() {
|
||||||
|
const result = [];
|
||||||
|
for (const [route, rec] of Object.entries(route2component))
|
||||||
|
result.push({label: rec.label, value: route});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateListFromRoute(to) {
|
||||||
|
const newPath = to.path;
|
||||||
|
let newList = this.getListRoute(newPath);
|
||||||
|
newList = (newList ? newList : 'author');
|
||||||
|
if (this.selectedList != newList)
|
||||||
|
this.selectedList = newList;
|
||||||
|
}
|
||||||
|
|
||||||
|
getListRoute(newPath) {
|
||||||
|
newPath = (newPath ? newPath : this.$route.path);
|
||||||
|
const m = newPath.match(/^\/([^/]*).*$/i);
|
||||||
|
return (m ? m[1] : newPath);
|
||||||
|
}
|
||||||
|
|
||||||
openReleasePage() {
|
openReleasePage() {
|
||||||
window.open('https://github.com/bookpauk/inpx-web/releases', '_blank');
|
window.open('https://github.com/bookpauk/inpx-web/releases', '_blank');
|
||||||
}
|
}
|
||||||
@@ -672,7 +723,7 @@ class Search {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateSearchFromRouteQuery(to) {
|
updateSearchFromRouteQuery(to) {
|
||||||
if (this.list.liberamaReady)
|
if (this.list.liberamaReady)
|
||||||
this.sendCurrentUrl();
|
this.sendCurrentUrl();
|
||||||
|
|
||||||
@@ -709,7 +760,7 @@ class Search {
|
|||||||
|
|
||||||
const diff = diffUtils.getObjDiff(oldQuery, query);
|
const diff = diffUtils.getObjDiff(oldQuery, query);
|
||||||
if (!diffUtils.isEmptyObjDiff(diff)) {
|
if (!diffUtils.isEmptyObjDiff(diff)) {
|
||||||
this.$router.replace({query});
|
this.$router.replace({path: this.selectedList, query});
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
(async() => {
|
(async() => {
|
||||||
@@ -722,7 +773,7 @@ class Search {
|
|||||||
async updateGenreTreeIfNeeded() {
|
async updateGenreTreeIfNeeded() {
|
||||||
if (this.genreTreeUpdating)
|
if (this.genreTreeUpdating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.genreTreeUpdating = true;
|
this.genreTreeUpdating = true;
|
||||||
try {
|
try {
|
||||||
if (this.genreTreeInpxHash !== this.list.inpxHash) {
|
if (this.genreTreeInpxHash !== this.list.inpxHash) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {QLinearProgress} from 'quasar/src/components/linear-progress';
|
|||||||
import {QInput} from 'quasar/src/components/input';
|
import {QInput} from 'quasar/src/components/input';
|
||||||
import {QBtn} from 'quasar/src/components/btn';
|
import {QBtn} from 'quasar/src/components/btn';
|
||||||
//import {QBtnGroup} from 'quasar/src/components/btn-group';
|
//import {QBtnGroup} from 'quasar/src/components/btn-group';
|
||||||
//import {QBtnToggle} from 'quasar/src/components/btn-toggle';
|
import {QBtnToggle} from 'quasar/src/components/btn-toggle';
|
||||||
import {QIcon} from 'quasar/src/components/icon';
|
import {QIcon} from 'quasar/src/components/icon';
|
||||||
//import {QSlider} from 'quasar/src/components/slider';
|
//import {QSlider} from 'quasar/src/components/slider';
|
||||||
//import {QTabs, QTab} from 'quasar/src/components/tabs';
|
//import {QTabs, QTab} from 'quasar/src/components/tabs';
|
||||||
@@ -48,7 +48,7 @@ const components = {
|
|||||||
QInput,
|
QInput,
|
||||||
QBtn,
|
QBtn,
|
||||||
//QBtnGroup,
|
//QBtnGroup,
|
||||||
//QBtnToggle,
|
QBtnToggle,
|
||||||
QIcon,
|
QIcon,
|
||||||
//QSlider,
|
//QSlider,
|
||||||
//QTabs, QTab,
|
//QTabs, QTab,
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ const Search = () => import('./components/Search/Search.vue');
|
|||||||
|
|
||||||
const myRoutes = [
|
const myRoutes = [
|
||||||
['/', Search],
|
['/', Search],
|
||||||
|
['/author', Search],
|
||||||
|
['/series', Search],
|
||||||
|
['/book', Search],
|
||||||
['/:pathMatch(.*)*', null, null, '/'],
|
['/:pathMatch(.*)*', null, null, '/'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user