Skip to content

Commit 5fe10eb

Browse files
committed
1 parent 9160e27 commit 5fe10eb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

js/timer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,15 @@
409409
tagIds = $(this).data('tagids').toString().split(',');
410410
tagNames = $(this).data('tagnames').toString().split(',');
411411
}
412+
412413
$(this).select2({
413414
tags: true,
414415
width: '200px',
415416
placeholder: "Select tags...",
416417
allowClear: true,
418+
417419
ajax: {
418-
url: OC.generateUrl('/apps/timetracker/ajax/tags')+'?workItem='+$(this).data('myid'),
420+
url: function (params) { return OC.generateUrl('/apps/timetracker/ajax/tags')+'?workItem='+$(this).data('myid')+'&q='+params;},
419421
formatNoMatches: function() {
420422
return '';
421423
},

lib/Controller/AjaxController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ public function deleteTag($id) {
770770
public function getTags(){
771771
$workItem = $this->request->workItem;
772772
$project = null;
773+
$q = $this->request->q;
773774
if ($workItem != null){
774775
$wi = $this->workIntervalMapper->find($workItem);
775776
if ($wi->projectId != null){
@@ -782,6 +783,15 @@ public function getTags(){
782783
} else {
783784
$tags = $this->tagMapper->findAll($this->userId);
784785
}
786+
if ($q != null){
787+
$filteredTags = [];
788+
foreach($tags as $t){
789+
if (stripos($t->name, $q) !== FALSE){
790+
$filteredTags[] = $t;
791+
}
792+
}
793+
$tags = $filteredTags;
794+
}
785795
return new JSONResponse(["Tags" => json_decode(json_encode($tags), true)]);
786796
}
787797

0 commit comments

Comments
 (0)