summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Controller/App.php24
-rw-r--r--app/Model/TaskFilter.php9
-rw-r--r--assets/js/app.js2
-rw-r--r--assets/js/src/base.js2
4 files changed, 27 insertions, 10 deletions
diff --git a/app/Controller/App.php b/app/Controller/App.php
index ebe39670..e4a97f8e 100644
--- a/app/Controller/App.php
+++ b/app/Controller/App.php
@@ -110,13 +110,21 @@ class App extends Base
*/
public function autocomplete()
{
- $this->response->json(
- $this->taskFilter
- ->create()
- ->filterByProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()))
- ->excludeTasks(array($this->request->getIntegerParam('exclude_task_id')))
- ->filterByTitle($this->request->getStringParam('term'))
- ->toAutoCompletion()
- );
+ $search = $this->request->getStringParam('term');
+
+ $filter = $this->taskFilter
+ ->create()
+ ->filterByProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()))
+ ->excludeTasks(array($this->request->getIntegerParam('exclude_task_id')));
+
+ // Search by task id or by title
+ if (ctype_digit($search)) {
+ $filter->filterById($search);
+ }
+ else {
+ $filter->filterByTitle($search);
+ }
+
+ $this->response->json($filter->toAutoCompletion());
}
}
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php
index 31de2795..94f6bab0 100644
--- a/app/Model/TaskFilter.php
+++ b/app/Model/TaskFilter.php
@@ -24,6 +24,15 @@ class TaskFilter extends Base
return $this;
}
+ public function filterById($task_id)
+ {
+ if ($task_id > 0) {
+ $this->query->eq('id', $task_id);
+ }
+
+ return $this;
+ }
+
public function filterByTitle($title)
{
$this->query->ilike('title', '%'.$title.'%');
diff --git a/assets/js/app.js b/assets/js/app.js
index 6ba7d7c9..bdceaf5b 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -142,7 +142,7 @@ return""!=a?"visible"==document[a]:!0},SetStorageItem:function(a,c){"undefined"!
c.parent().addClass("form-tab-selected");e.find(".markdown").html(a);e.css("height",f.css("height"));e.css("width",f.css("width"));d.hide();e.show()})},MarkdownWriter:function(a){a.preventDefault();$(this).closest("ul").find("li").removeClass("form-tab-selected");$(this).parent().addClass("form-tab-selected");$(".write-area").show();$(".preview-area").hide()},CheckSession:function(){$(".form-login").length||$.ajax({cache:!1,url:$("body").data("status-url"),statusCode:{401:function(){window.location=
$("body").data("login-url")}}})},Init:function(){$("#board-selector").chosen({width:180,no_results_text:$("#board-selector").data("notfound")});$("#board-selector").change(function(){window.location=$(this).attr("data-board-url").replace(/PROJECT_ID/g,$(this).val())});window.setInterval(Kanboard.CheckSession,6E4);Mousetrap.bindGlobal("mod+enter",function(){$("form").submit()});Mousetrap.bind("b",function(a){a.preventDefault();$("#board-selector").trigger("chosen:open")});$.datepicker.setDefaults($.datepicker.regional[$("body").data("js-lang")]);
Kanboard.InitAfterAjax()},InitAfterAjax:function(){$(document).on("click",".popover",Kanboard.Popover);$("[autofocus]").each(function(a,c){$(this).focus()});$(".form-date").datepicker({showOtherMonths:!0,selectOtherMonths:!0,dateFormat:"yy-mm-dd",constrainInput:!1});$("#markdown-preview").click(Kanboard.MarkdownPreview);$("#markdown-write").click(Kanboard.MarkdownWriter);$(".auto-select").focus(function(){$(this).select()});$(".dropit-submenu").hide();$(".dropdown").not(".dropit").dropit({triggerParentEl:"span"});
-$(".task-autocomplete").length&&(""==$(".opposite_task_id").val()&&$(".task-autocomplete").parent().find("input[type=submit]").attr("disabled","disabled"),$(".task-autocomplete").autocomplete({source:$(".task-autocomplete").data("search-url"),minLength:2,select:function(a,c){var b=$(".task-autocomplete").data("dst-field");$("input[name="+b+"]").val(c.item.id);$(".task-autocomplete").parent().find("input[type=submit]").removeAttr("disabled")}}));$(".column-tooltip").tooltip({content:function(){return'<div class="markdown">'+
+$(".task-autocomplete").length&&(""==$(".opposite_task_id").val()&&$(".task-autocomplete").parent().find("input[type=submit]").attr("disabled","disabled"),$(".task-autocomplete").autocomplete({source:$(".task-autocomplete").data("search-url"),minLength:1,select:function(a,c){var b=$(".task-autocomplete").data("dst-field");$("input[name="+b+"]").val(c.item.id);$(".task-autocomplete").parent().find("input[type=submit]").removeAttr("disabled")}}));$(".column-tooltip").tooltip({content:function(){return'<div class="markdown">'+
$(this).attr("title")+"</div>"},position:{my:"left-20 top",at:"center bottom+9",using:function(a,c){$(this).css(a);var b=c.target.left+c.target.width/2-c.element.left-20;$("<div>").addClass("tooltip-arrow").addClass(c.vertical).addClass(0==b?"align-left":"align-right").appendTo(this)}}});Kanboard.Exists("screenshot-zone")&&Kanboard.Screenshot.Init()}}}();
Kanboard.Board=function(){function a(a){a.preventDefault();a.stopPropagation();Kanboard.Popover(a,Kanboard.InitAfterAjax)}function c(){Mousetrap.bind("n",function(){Kanboard.OpenPopover($("#board").data("task-creation-url"),Kanboard.InitAfterAjax)});Mousetrap.bind("s",function(){"expanded"===(Kanboard.GetStorageItem(d())||"expanded")?(e(),Kanboard.SetStorageItem(d(),"collapsed")):(f(),Kanboard.SetStorageItem(d(),"expanded"))});Mousetrap.bind("c",function(){q()})}function b(){$(".filter-expand-link").click(function(a){a.preventDefault();
f();Kanboard.SetStorageItem(d(),"expanded")});$(".filter-collapse-link").click(function(a){a.preventDefault();e();Kanboard.SetStorageItem(d(),"collapsed")});g()}function d(){return"board_stacking_"+$("#board").data("project-id")}function e(){$(".filter-collapse").hide();$(".task-board-collapsed").show();$(".filter-expand").show();$(".task-board-expanded").hide()}function f(){$(".filter-collapse").show();$(".task-board-collapsed").hide();$(".filter-expand").hide();$(".task-board-expanded").show()}
diff --git a/assets/js/src/base.js b/assets/js/src/base.js
index 9b1e1b7d..bf61b1f3 100644
--- a/assets/js/src/base.js
+++ b/assets/js/src/base.js
@@ -234,7 +234,7 @@ var Kanboard = (function() {
$(".task-autocomplete").autocomplete({
source: $(".task-autocomplete").data("search-url"),
- minLength: 2,
+ minLength: 1,
select: function(event, ui) {
var field = $(".task-autocomplete").data("dst-field");
$("input[name=" + field + "]").val(ui.item.id);