diff --git a/src/public/app/widgets/search_options/limit.js b/src/public/app/widgets/search_options/limit.js new file mode 100644 index 000000000..28af4a2db --- /dev/null +++ b/src/public/app/widgets/search_options/limit.js @@ -0,0 +1,49 @@ +import AbstractSearchOption from "./abstract_search_option.js"; + +const TPL = ` + + + + + Limit + + + + + + + + + +`; + +export default class Limit extends AbstractSearchOption { + static get optionName() { return "limit" }; + static get attributeType() { return "label" }; + + static async create(noteId) { + await AbstractSearchOption.setAttribute(noteId, 'label', 'limit', '10'); + } + + doRender() { + const $option = $(TPL); + + 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')); + + return $option; + } + + async update() { + const limit = this.$limit.val(); + + await this.setAttribute('label', 'limit', limit); + } +} diff --git a/src/public/app/widgets/type_property_widgets/search_definition.js b/src/public/app/widgets/type_property_widgets/search_definition.js index 4df0cef68..66c64d6b4 100644 --- a/src/public/app/widgets/type_property_widgets/search_definition.js +++ b/src/public/app/widgets/type_property_widgets/search_definition.js @@ -18,6 +18,7 @@ import Ancestor from "../search_options/ancestor.js"; import IncludeArchivedNotes from "../search_options/include_archived_notes.js"; import OrderBy from "../search_options/order_by.js"; import SearchScript from "../search_options/search_script.js"; +import Limit from "../search_options/limit.js"; const TPL = `
@@ -106,6 +107,11 @@ const TPL = ` order by + +