From 796bcc8d01dcf1cbe5a5e02370aff2f5dc36482e Mon Sep 17 00:00:00 2001 From: Christian Schiffer <c.schiffer@fz-juelich.de> Date: Wed, 31 Mar 2021 10:14:12 +0200 Subject: [PATCH] Implemented filter for annotation names --- microdraw/src/atlas_ui.js | 15 +++++++++++++++ microdraw/src/microdraw.html | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/microdraw/src/atlas_ui.js b/microdraw/src/atlas_ui.js index 3b7ad63..657ff7b 100644 --- a/microdraw/src/atlas_ui.js +++ b/microdraw/src/atlas_ui.js @@ -109,6 +109,7 @@ var app = new Vue({ selected_job: null, enable_auto_rename: true, annotation_import: new AnnotationImport(), + annotation_filter: null, }, methods: { getProjects: function () { @@ -379,6 +380,20 @@ var app = new Vue({ this.available_annotations.push(new_annotation); } }, + filterAnnotation: function(annotation) { + if (this.annotation_filter === null || this.annotation_filter === "") { + return true; + } + try { + // Ignore case + var re = new RegExp(this.annotation_filter, "i"); + } catch(err) { + // Invalid regex, might also occur during typing + return true; + } + var match = re.exec(annotation.name); + return match !== null; + }, deleteTask(project, task_index) { // Delete the task from the project let task = project.tasks[task_index]; diff --git a/microdraw/src/microdraw.html b/microdraw/src/microdraw.html index f76c08d..0effafe 100755 --- a/microdraw/src/microdraw.html +++ b/microdraw/src/microdraw.html @@ -335,6 +335,9 @@ <label for="atlas_ui_task_form_name">Name</label> <input v-model="selected_task.name" type="text" class="form-control" id="atlas_ui_task_form_name"> + <label for="atlas_ui_task_form_filter">Annotation filter</label> + <input v-model="annotation_filter" type="text" class="form-control" + id="atlas_ui_task_form_filter"> <input type="checkbox" v-model="enable_auto_rename" id="atlas_ui_task_form_auto_rename"/> <label for="atlas_ui_task_form_auto_rename">Enable auto-rename</label> </div> @@ -372,6 +375,7 @@ class="list-group atlas_annotation_list border border-dark rounded bg-light" v-if="selected_task !== null"> <li v-for="(annotation, index) in available_annotations" + v-if="filterAnnotation(annotation)" class="list-group-item list-group-item-action"> <div class="form-row"> <label class="col-1 col-form-label">Name</label> -- GitLab