diff --git a/app/Http/Controllers/Api/ProjectLabelTreeController.php b/app/Http/Controllers/Api/ProjectLabelTreeController.php index 1a57fbc08..2ada7fd92 100644 --- a/app/Http/Controllers/Api/ProjectLabelTreeController.php +++ b/app/Http/Controllers/Api/ProjectLabelTreeController.php @@ -59,13 +59,13 @@ public function index($id) } /** - * Display all label trees that can be used by the specified project. + * Display label trees that match the given name and can be used by the specified project. * - * @api {get} projects/:id/label-trees/available Get all available label trees + * @api {get} projects/:id/label-trees/available/:name Get matching label trees * @apiGroup Projects * @apiName IndexProjectAvailableLabelTrees * @apiPermission projectMember - * @apiDescription This endpoint lists all label trees that _can be_ used by the project (do not confuse this with the "used label trees" endpoint). + * @apiDescription This endpoint lists all matching label trees that _can be_ used by the project (do not confuse this with the "used label trees" endpoint). * * @apiParam {Number} id The project ID. * @@ -86,19 +86,22 @@ public function index($id) * ] * * @param int $id Project ID + * @param string $name Labeltree name * @return array */ - public function available($id) + public function available($id, $name) { $project = Project::findOrFail($id); $this->authorize('access', $project); $public = LabelTree::publicTrees() ->select('id', 'name', 'description', 'version_id') + ->where('name', 'ilike', "%{$name}%") ->with('version') ->get(); $authorized = $project->authorizedLabelTrees() ->select('id', 'name', 'description', 'version_id') + ->where('name', 'ilike', "%{$name}%") ->with('version') ->get(); diff --git a/app/Http/Controllers/Api/ProjectsAttachableVolumesController.php b/app/Http/Controllers/Api/ProjectsAttachableVolumesController.php index 70232d8e8..bc9cfb47a 100644 --- a/app/Http/Controllers/Api/ProjectsAttachableVolumesController.php +++ b/app/Http/Controllers/Api/ProjectsAttachableVolumesController.php @@ -10,14 +10,14 @@ class ProjectsAttachableVolumesController extends Controller { /** - * Shows all volumes that can be attached to the project by the requesting user. + * Shows volumes that match the given volume name and can be attached to the project by the requesting user. * - * @api {get} projects/:id/attachable-volumes Get attachable volumes + * @api {get} projects/:id/attachable-volumes/:name Get matching attachable volumes * @apiGroup Projects * @apiName IndexAttachableVolumes * @apiPermission projectAdmin * @apiParam {Number} id ID of the project for which the volumes should be fetched. - * @apiDescription A list of all volumes where the requesting user has admin rights for (excluding those already belonging to the specified project). + * @apiDescription A list of all matching volumes where the requesting user has admin rights for (excluding those already belonging to the specified project). * * @apiSuccessExample {json} Success response: * [ @@ -34,10 +34,11 @@ class ProjectsAttachableVolumesController extends Controller * * @param Request $request * @param int $id Project ID + * @param string $name Volume name * * @return \Illuminate\Database\Eloquent\Collection */ - public function index(Request $request, $id) + public function index(Request $request, $id, $name) { $project = Project::findOrFail($id); $this->authorize('update', $project); @@ -56,6 +57,7 @@ public function index(Request $request, $id) ->where('project_id', '!=', $id); }); }) + ->where('name', 'ilike', "%{$name}%") // Do not return volumes that are already attached to this project. // This is needed although we are already excluding the project in the // previous statement because other projects may already share volumes with diff --git a/resources/assets/js/core/api/projects.js b/resources/assets/js/core/api/projects.js index 41a4e47ca..3c2b9f6c4 100644 --- a/resources/assets/js/core/api/projects.js +++ b/resources/assets/js/core/api/projects.js @@ -86,7 +86,7 @@ export default Vue.resource('api/v1/projects{/id}', {}, { }, queryAvailableLabelTrees: { method: 'GET', - url: 'api/v1/projects{/id}/label-trees/available', + url: 'api/v1/projects{/id}/label-trees/available{/name}', }, attachLabelTree: { method: 'POST', diff --git a/resources/assets/js/core/components/typeahead.vue b/resources/assets/js/core/components/typeahead.vue index 7f514f350..7c9818140 100644 --- a/resources/assets/js/core/components/typeahead.vue +++ b/resources/assets/js/core/components/typeahead.vue @@ -4,6 +4,7 @@ ref="input" class="form-control" type="text" + v-model="inputText" :disabled="disabled" :placeholder="placeholder" @focus="emitFocus" @@ -15,11 +16,15 @@ :target="inputElement" :data="items" :force-select="true" - :limit="limit" + :limit="itemLimit" + :class="{'typeahead-scrollable': scrollable}" item-key="name" + v-show="showTypeahead" + @selected-item-changed="handleArrowKeyScroll" >