WIP tag category setter
parent
bf466589b0
commit
9019bb3c32
|
|
@ -26,7 +26,7 @@ export interface Tag {
|
||||||
names: string[];
|
names: string[];
|
||||||
category: string;
|
category: string;
|
||||||
version: number;
|
version: number;
|
||||||
description?: any;
|
description?: string; // Markdown
|
||||||
creationTime: Date;
|
creationTime: Date;
|
||||||
lastEditTime?: Date;
|
lastEditTime?: Date;
|
||||||
usages: number;
|
usages: number;
|
||||||
|
|
|
||||||
|
|
@ -146,13 +146,34 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.pushInfo("Uploading...");
|
// Create and upload post
|
||||||
|
let uploadMsg = new Message("Uploading...");
|
||||||
|
this.messages.push(uploadMsg);
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
const createdPost = await this.szuru.createPost(this.post);
|
const createdPost = await this.szuru.createPost(this.post);
|
||||||
this.clearMessages();
|
|
||||||
// TODO: Clicking a link doesn't actually open it in a new tab,
|
// TODO: Clicking a link doesn't actually open it in a new tab,
|
||||||
// see https://stackoverflow.com/questions/8915845
|
// see https://stackoverflow.com/questions/8915845
|
||||||
this.pushInfo(`<a href='${this.getPostUrl(createdPost)}'>Uploaded post</a>`);
|
uploadMsg.content = `<a href='${this.getPostUrl(createdPost)}'>Uploaded post</a>`;
|
||||||
|
|
||||||
|
let tagsMsg = new Message("Checking tags...");
|
||||||
|
this.messages.push(tagsMsg);
|
||||||
|
|
||||||
|
// Find tags with "default" category and update it
|
||||||
|
// TODO: Make all these categories configurable
|
||||||
|
const tagsWithCategory = this.post.tags.filter(x => x.category);
|
||||||
|
const unsetCategoryTags = createdPost.tags
|
||||||
|
.filter(x => x.category == "default")
|
||||||
|
.filter(x => tagsWithCategory.some(y => x.names.includes(y.name)));
|
||||||
|
|
||||||
|
console.dir(unsetCategoryTags);
|
||||||
|
|
||||||
|
if (unsetCategoryTags.length == 0) {
|
||||||
|
tagsMsg.content = "All tags have the correct category";
|
||||||
|
} else {
|
||||||
|
tagsMsg.content = `${unsetCategoryTags.length} tags need a different category`;
|
||||||
|
// TODO: Call /tags?query={tag1},{tag2},{tag3}
|
||||||
|
// TODO: Foreach tag call PUT /tag/{tag1} with updated category
|
||||||
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
const error = ex as LocalError;
|
const error = ex as LocalError;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"lib": [
|
"lib": [
|
||||||
"es2015",
|
"es2017",
|
||||||
"dom"
|
"dom"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue