Add config interface for tag ignores

pull/58/head
G1org1owo 2024-07-11 00:17:17 +02:00
parent 76a4c01577
commit ba7866e0b0
2 changed files with 31 additions and 2 deletions

View File

@ -8,7 +8,7 @@ import TabView from "primevue/tabview";
import TabPanel from "primevue/tabpanel";
import DataTable from "primevue/datatable";
import Column from "primevue/column";
import { SzuruSiteConfig, TagCategoryColor, getDefaultTagCategories } from "~/models";
import { TagDetails, SzuruSiteConfig, TagCategoryColor, getDefaultTagCategories } from "~/models";
import SzurubooruApi from "~/api";
type StatusType = "success" | "error" | "quiet";
@ -102,6 +102,14 @@ async function importTagCategoriesFromInstance() {
}
}
function addTagIgnore() {
cfg.value.tagIgnores.push(new TagDetails([""]))
}
function resetTagIgnores() {
cfg.value.tagIgnores.splice(0);
}
// For debugging
const wnd = window as any;
wnd.szc_get_config = () => JSON.parse(JSON.stringify(cfg.value));
@ -289,7 +297,26 @@ wnd.szc_set_config_version = (v = 0) => (cfg.value.version = v);
<!-- TODO: Tag category colors -->
<!-- TODO: Tag ignore list -->
<div class="grid">
<DataTable :value="cfg.tagIgnores" table-class="col-12" style="width: 100%">
<Column field="names" :header="'Names'">
<template #body="{ data, field }">
<input type="text" :name="field" v-model="data[field][0]" />
</template>
</Column>
<Column field="remove">
<template #body="{ index }">
<a class="color-primary cursor-pointer" @click="() => cfg.tagIgnores.splice(index, 1)">Remove</a>
</template>
</Column>
</DataTable>
<div class="col-12 flex flex-wrap grid grid-nogutter gap-1">
<button class="primary" @click="addTagIgnore">Add tag</button>
<button class="bg-danger sm:ml-auto" @click="resetTagIgnores">Clear</button>
</div>
</div>
<!-- TODO: Category ignore list -->
</TabPanel>

View File

@ -1,6 +1,7 @@
import { defineStore } from "pinia";
import deepMerge from "deepmerge";
import {
type TagDetails,
getDefaultTagCategories,
type ScrapedPostDetails,
type SetPostUploadInfoData,
@ -38,6 +39,7 @@ export const cfg = useStorageLocal(
showInstancePicker: true,
},
tagCategories: [] as Array<TagCategoryColor>,
tagIgnores: [] as Array<TagDetails>,
},
{
mergeDefaults(storageValue, defaults) {