mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 02:42:27 +08:00
chore(client/ts): port search_options
This commit is contained in:
parent
2c714afa21
commit
423037b9d6
@ -58,7 +58,7 @@ export default class Ancestor extends AbstractSearchOption {
|
||||
return "relation";
|
||||
}
|
||||
|
||||
static async create(noteId) {
|
||||
static async create(noteId: string) {
|
||||
await AbstractSearchOption.setAttribute(noteId, "relation", "ancestor", "root");
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ export default class Ancestor extends AbstractSearchOption {
|
||||
});
|
||||
|
||||
$ancestorDepth.on("change", async () => {
|
||||
const ancestorDepth = $ancestorDepth.val();
|
||||
const ancestorDepth = String($ancestorDepth.val());
|
||||
|
||||
if (ancestorDepth) {
|
||||
await this.setAttribute("label", "ancestorDepth", ancestorDepth);
|
||||
@ -88,7 +88,7 @@ export default class Ancestor extends AbstractSearchOption {
|
||||
|
||||
const ancestorNoteId = this.note.getRelationValue("ancestor");
|
||||
|
||||
if (ancestorNoteId !== "root") {
|
||||
if (ancestorNoteId && ancestorNoteId !== "root") {
|
||||
$ancestor.setNote(ancestorNoteId);
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ const TPL = `
|
||||
</tr>`;
|
||||
|
||||
export default class Limit extends AbstractSearchOption {
|
||||
|
||||
private $limit!: JQuery<HTMLElement>;
|
||||
|
||||
static get optionName() {
|
||||
return "limit";
|
||||
}
|
||||
@ -30,7 +33,7 @@ export default class Limit extends AbstractSearchOption {
|
||||
return "label";
|
||||
}
|
||||
|
||||
static async create(noteId) {
|
||||
static async create(noteId: string) {
|
||||
await AbstractSearchOption.setAttribute(noteId, "label", "limit", "10");
|
||||
}
|
||||
|
||||
@ -40,13 +43,13 @@ export default class Limit extends AbstractSearchOption {
|
||||
this.$limit = $option.find("input[name=limit]");
|
||||
this.$limit.on("change", () => this.update());
|
||||
this.$limit.on("input", () => this.update());
|
||||
this.$limit.val(this.note.getLabelValue("limit"));
|
||||
this.$limit.val(this.note.getLabelValue("limit") ?? "");
|
||||
|
||||
return $option;
|
||||
}
|
||||
|
||||
async update() {
|
||||
const limit = this.$limit.val();
|
||||
const limit = String(this.$limit.val());
|
||||
|
||||
await this.setAttribute("label", "limit", limit);
|
||||
}
|
@ -36,6 +36,7 @@ const TPL = `
|
||||
</tr>`;
|
||||
|
||||
export default class OrderBy extends AbstractSearchOption {
|
||||
|
||||
static get optionName() {
|
||||
return "orderBy";
|
||||
}
|
||||
@ -43,7 +44,7 @@ export default class OrderBy extends AbstractSearchOption {
|
||||
return "label";
|
||||
}
|
||||
|
||||
static async create(noteId) {
|
||||
static async create(noteId: string) {
|
||||
await AbstractSearchOption.setAttribute(noteId, "label", "orderBy", "relevancy");
|
||||
await AbstractSearchOption.setAttribute(noteId, "label", "orderDirection", "asc");
|
||||
}
|
||||
@ -53,15 +54,15 @@ export default class OrderBy extends AbstractSearchOption {
|
||||
|
||||
const $orderBy = $option.find("select[name=orderBy]");
|
||||
$orderBy.on("change", async () => {
|
||||
const orderBy = $orderBy.val();
|
||||
const orderBy = String($orderBy.val());
|
||||
|
||||
await this.setAttribute("label", "orderBy", orderBy);
|
||||
});
|
||||
$orderBy.val(this.note.getLabelValue("orderBy"));
|
||||
$orderBy.val(this.note.getLabelValue("orderBy") ?? "");
|
||||
|
||||
const $orderDirection = $option.find("select[name=orderDirection]");
|
||||
$orderDirection.on("change", async () => {
|
||||
const orderDirection = $orderDirection.val();
|
||||
const orderDirection = String($orderDirection.val());
|
||||
|
||||
await this.setAttribute("label", "orderDirection", orderDirection);
|
||||
});
|
@ -40,7 +40,7 @@ export default class SearchScript extends AbstractSearchOption {
|
||||
return "relation";
|
||||
}
|
||||
|
||||
static async create(noteId) {
|
||||
static async create(noteId: string) {
|
||||
await AbstractSearchOption.setAttribute(noteId, "relation", "searchScript", "root");
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ export default class SearchScript extends AbstractSearchOption {
|
||||
|
||||
const searchScriptNoteId = this.note.getRelationValue("searchScript");
|
||||
|
||||
if (searchScriptNoteId !== "root") {
|
||||
if (searchScriptNoteId && searchScriptNoteId !== "root") {
|
||||
$searchScript.setNote(searchScriptNoteId);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user