From d962317ad037f4424e70ddb48dded509d3ea7ea7 Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Sun, 12 Jan 2025 14:59:22 +0300 Subject: [PATCH] addd search --- Web/static/css/main.css | 11 ++++++++++- Web/static/js/al_docs.js | 35 +++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Web/static/css/main.css b/Web/static/css/main.css index cb5e14f8..6ede9f50 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -4007,7 +4007,7 @@ hr { background: #F0F0F0; } -#docs_page_wrapper .docs_page_search input[type="search"] { +#docs_page_wrapper .docs_page_search input[type="search"], .attachment_selector .attachment_search input { height: 23px; background: url('/assets/packages/static/openvk/img/search_icon.png') no-repeat 3px 5px; background-color: #fff; @@ -4238,3 +4238,12 @@ hr { cursor: pointer; user-select: none; } + +.attachment_selector .attachment_search { + margin: 6px 0px; +} + +.attachment_selector .attachment_search input { + height: 30px; + background-position-y: 9px; +} diff --git a/Web/static/js/al_docs.js b/Web/static/js/al_docs.js index 7d3eb07b..2c3539ca 100644 --- a/Web/static/js/al_docs.js +++ b/Web/static/js/al_docs.js @@ -305,14 +305,14 @@ u(document).on("click", ".docListViewItem a.viewerOpener, a.docGalleryItem", asy }) // ctx > "wall" and maybe "messages" in future -// source > "user" || "club" > source_id -async function __docAttachment(form, ctx = "wall", source = "user", source_id = 0) { +// source > "user" || "club" > source_arg +async function __docAttachment(form, ctx = "wall", source = "user", source_arg = 0) { const per_page = 10 const msg = new CMessageBox({ title: tr('select_doc'), custom_template: u(`
-
+
${tr("select_doc")} @@ -330,6 +330,9 @@ async function __docAttachment(form, ctx = "wall", source = "user", source_id =
+
@@ -340,7 +343,7 @@ async function __docAttachment(form, ctx = "wall", source = "user", source_id =
`), }) - msg.getNode().find(".ovk-photo-view").attr('style', 'width: 400px;') + msg.getNode().find(".ovk-photo-view").attr('style', 'width: 400px;min-height:90vh;') msg.getNode().find('.ovk-diag-body').attr('style', 'height:335px;padding:0px;') docs_reciever = new class { ctx = "my" @@ -358,7 +361,8 @@ async function __docAttachment(form, ctx = "wall", source = "user", source_id = count: 0, } - u('#gif_loader').remove() + u('#gif_loader, #_attachment_insert #show_more').remove() + u("#_attachment_insert .docsInsert").html("") } async page(page = 1, perPage = 10) { @@ -367,7 +371,12 @@ async function __docAttachment(form, ctx = "wall", source = "user", source_id = const fd = new FormData fd.append("context", "list") fd.append("hash", window.router.csrf) - const req = await fetch(`/docs${source == "club" ? source_id : ""}?picker=1&p=${page}`, { + let url = `/docs${source == "club" ? source_arg : ""}?picker=1&p=${page}` + if(this.query) { + fd.append("context", "search") + fd.append("ctx_query", this.query) + } + const req = await fetch(url, { method: "POST", body: fd }) @@ -403,6 +412,16 @@ async function __docAttachment(form, ctx = "wall", source = "user", source_id = this.showMore() } + async search(query_string) { + this.clean() + if(query_string == "") + this.query = null + else + this.query = query_string + + await this.page(1) + } + showMore() { if(this.stat.page < this.stat.pagesCount) { u('#_attachment_insert').append(` @@ -476,6 +495,10 @@ async function __docAttachment(form, ctx = "wall", source = "user", source_id = msg.close() await __docAttachment(form, "wall") }) + msg.getNode().on("change", ".attachment_search input", async (e) => { + await docs_reciever.search(ovk_proc_strtr(e.target.value, 100)) + }) + await docs_reciever.page(docs_reciever.stat.page + 1) }