From 245bfe640ad84c5cbde011f4970ab8f691f3c0b0 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sat, 30 Mar 2024 12:12:47 +0100 Subject: [PATCH] updated folder chooser --- op/op.Ajax.php | 10 ++++---- views/bootstrap4/styles/application.js | 33 ++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/op/op.Ajax.php b/op/op.Ajax.php index 3a58652df..03b024064 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -144,8 +144,8 @@ switch($command) { $result = array(); foreach($hits['folders'] as $hit) { if($hit->getAccessMode($user, 'search') >= M_READ) - //$result[] = $hit->getID().'#'.$basefolder->getName().'/'.$hit->getName(); - $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/'); +// $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/'); + $result[] = array('type'=>'F', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getFolderPathPlain(true, '/')), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/'))); } header('Content-Type: application/json'); echo json_encode($result); @@ -157,7 +157,8 @@ switch($command) { $result = array(); foreach($subfolders as $subfolder) { //$result[] = $subfolder->getID().'#'.$basefolder->getName().'/'.$subfolder->getName(); - $result[] = $subfolder->getID().'#'.$subfolder->getFolderPathPlain(true, '/'); +// $result[] = $subfolder->getID().'#'.$subfolder->getFolderPathPlain(true, '/'); + $result[] = array('type'=>'F', 'id'=>$subfolder->getId(), 'name'=>htmlspecialchars($subfolder->getFolderPathPlain(true, '/')), 'path'=>htmlspecialchars($subfolder->getParent()->getFolderPathPlain(true, '/'))); } header('Content-Type: application/json'); echo json_encode($result); @@ -172,7 +173,8 @@ switch($command) { $result = array(); foreach($hits['folders'] as $hit) { if($hit->getAccessMode($user, 'search') >= M_READ) - $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/'); +// $result[] = $hit->getID().'#'.$hit->getFolderPathPlain(true, '/'); + $result[] = array('type'=>'F', 'id'=>$hit->getId(), 'name'=>htmlspecialchars($hit->getFolderPathPlain(true, '/')), 'path'=>htmlspecialchars($hit->getParent()->getFolderPathPlain(true, '/'))); } header('Content-Type: application/json'); echo json_encode($result); diff --git a/views/bootstrap4/styles/application.js b/views/bootstrap4/styles/application.js index 46e6a7af6..115c4c110 100644 --- a/views/bootstrap4/styles/application.js +++ b/views/bootstrap4/styles/application.js @@ -236,7 +236,7 @@ function initMost() { /* Folder chooser */ $("[id^=choosefoldersearch]").typeahead({ /* {{{ */ menu: '', - item: '
  • ', + item: '', minLength: 3, source: function(query, process) { // console.log(this.options); @@ -248,19 +248,42 @@ function initMost() { * actually provided to update the input field, but here we use * it to set the document location. */ updater: function (item) { - strarr = item.value.split("#"); - //console.log(this.$element.data('target')); target = this.$element.data('target'); - $('#'+target).attr('value', strarr[0]); - return strarr[1]; + $('#'+target).attr('value', item.id); + return item.value; + }, + sorter: function(items) { + return items; }, /* Set a matcher that allows any returned value */ matcher : function (item) { return true; }, highlighter : function (item) { + return ' ' + item.name.replace(/' + item.path + '' : ''); strarr = item.split("#"); return ' ' + strarr[1].replace(/