Добавлен поиск по типу файла

This commit is contained in:
Book Pauk
2023-03-17 12:45:13 +07:00
parent 6be1b94b96
commit d9e19ff9b7
4 changed files with 31 additions and 9 deletions

View File

@@ -450,6 +450,13 @@ export default class BaseList {
librateFound = searchLibrate.has(book.librate);
}
//ext
let extFound = !s.ext;
if (!extFound) {
const searchExt = new Set(s.ext.split('|'));
extFound = searchExt.has(book.ext.toLowerCase() || emptyFieldValue);
}
return (this.showDeleted || !book.del)
&& authorFound
&& filterBySearch(book.series, s.series)
@@ -458,6 +465,7 @@ export default class BaseList {
&& langFound
&& dateFound
&& librateFound
&& extFound
;
});
}

View File

@@ -725,6 +725,7 @@ class Search {
result.push(s.genre ? 'Жанр' : '');
result.push(s.date ? 'Дата поступления' : '');
result.push(s.librate ? 'Оценка' : '');
result.push(s.ext ? 'Тип файла' : '');
return result.filter(s => s).join(', ');
}
@@ -1104,6 +1105,7 @@ class Search {
lang: (typeof(query.lang) == 'string' ? query.lang : this.langDefault),
date: query.date,
librate: query.librate,
ext: query.ext,
page: parseInt(query.page, 10),
limit: parseInt(query.limit, 10) || this.search.limit,

View File

@@ -16,7 +16,13 @@
:options="optionsPre"
type="checkbox"
inline
/>
>
<template #label="opt">
<div class="row items-center" style="width: 35px">
<span>{{ opt.label }}</span>
</div>
</template>
</q-option-group>
</div>
<q-checkbox v-model="tickAll" label="Выбрать/снять все" toggle-order="ft" @update:model-value="makeTickAll" />
@@ -57,12 +63,12 @@ const componentOptions = {
dialogVisible(newValue) {
this.$emit('update:modelValue', newValue);
},
lang() {
ext() {
this.updateTicked();
},
ticked() {
this.checkAllTicked();
this.updateLang();
this.updateExt();
},
}
};
@@ -95,7 +101,13 @@ class SelectExtDialog {
const result = [];
for (const ext of this.extList) {
result.push({label: ext, value: ext});
if (ext.length <= 4)
result.push({label: ext, value: ext});
}
for (const ext of this.extList) {
if (ext.length > 4)
result.push({label: ext, value: ext});
}
return result;
@@ -104,7 +116,7 @@ class SelectExtDialog {
get optionsPre() {
const result = [];
for (const ext of ['fb2', 'pdf']) {
for (const ext of ['fb2', 'epub', 'mobi', 'pdf', 'djvu', 'doc', 'docx', 'rtf', 'xml', 'html', 'txt', 'zip']) {
if (this.extList.includes(ext)) {
result.push({label: ext, value: ext});
}
@@ -145,11 +157,11 @@ class SelectExtDialog {
}
updateTicked() {
this.ticked = this.ext.split(',').filter(s => s);
this.ticked = this.ext.split('|').filter(s => s);
}
updateLang() {
this.$emit('update:ext', this.ticked.join(','));
updateExt() {
this.$emit('update:ext', this.ticked.join('|'));
}
okClick() {

View File

@@ -298,7 +298,7 @@ class DbSearcher {
table: 'ext',
rawResult: true,
where: `
const exts = ${db.esc(query.ext.split(','))};
const exts = ${db.esc(query.ext.split('|'))};
const ids = new Set();
for (const l of exts) {