Skip to content

Commit

Permalink
Add possibility to search document for missing annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroDinis committed Dec 10, 2023
1 parent 87ca416 commit 09bfae0
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/assets/scss/document_annotations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,12 @@

.missing-button-container {
background-color: transparent;
display: flex;
flex-direction: row;

.missing-btn {
.missing-btn,
.search-btn {
padding: 6px;
color: $grey-blue !important;
font-size: 14px !important;
font-weight: 500;
Expand Down
10 changes: 10 additions & 0 deletions src/components/DocumentAnnotations/AnnotationActionButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
<b-button type="is-ghost" class="missing-btn" @click.stop="markAsMissing">
{{ $t("missing_annotation") }}
</b-button>
<b-button
type="is-ghost"
class="search-btn"
@click.stop="searchInDocument"
>
{{ $t("search_in_document") }}
</b-button>
</div>

<!-- Restore not found annotations -->
Expand Down Expand Up @@ -141,6 +148,9 @@ export default {
restore() {
this.$emit("restore");
},
searchInDocument() {
this.$emit("search-label-in-document");
},
},
};
</script>
Expand Down
6 changes: 6 additions & 0 deletions src/components/DocumentAnnotations/AnnotationRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
@decline="handleSaveChanges(true)"
@cancel="handleCancelButton()"
@restore="handleRestore()"
@search-label-in-document="searchLabelInDocument"
/>
</div>
</div>
Expand Down Expand Up @@ -732,6 +733,11 @@ export default {
window.open(annotationDetailsUrl, "_blank");
},
searchLabelInDocument() {
console.log("searchLabelInDocument");
this.$store.dispatch("display/enableSearch", true);
this.$store.dispatch("display/setCurrentSearch", this.label.name);
},
},
};
</script>
Expand Down
15 changes: 13 additions & 2 deletions src/components/DocumentPage/SearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default {
computed: {
...mapState("display", [
"currentSearchResult",
"currentSearch",
"searchEnabled",
"searchResults",
"searchLoading",
Expand All @@ -87,12 +88,17 @@ export default {
},
watch: {
search(search) {
this.$store.dispatch("display/setCurrentSearch", search);
if (search.length >= this.minSearchLength) {
this.$store.dispatch("display/startSearchLoading");
this.$store.dispatch("display/debounceSearch", search);
}
},
currentSearch(search) {
if (this.search !== search) {
this.search = search;
}
this.$store.dispatch("display/debounceSearch", search);
},
searchEnabled(enabled) {
if (enabled) {
this.$nextTick(() => {
Expand All @@ -101,6 +107,11 @@ export default {
}
},
},
mounted() {
if (this.currentSearch !== this.search) {
this.search = this.currentSearch;
}
},
methods: {
focusSearchResult(n) {
this.$store.dispatch("display/setCurrentSearchResult", n);
Expand Down
3 changes: 2 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@
"edit_translation": "Zum Bearbeiten anklicken",
"search": "Suchen",
"no_results": "Keine Ergebnisse",
"search_below_minimum": "Mindestens 3 Zeichen"
"search_below_minimum": "Mindestens 3 Zeichen",
"search_in_document": "Suche im Dokument"
}
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@
"edit_translation": "Click to edit",
"search": "Search",
"no_results": "No results",
"search_below_minimum": "Minimum 3 characters"
"search_below_minimum": "Minimum 3 characters",
"search_in_document": "Search document"
}
3 changes: 2 additions & 1 deletion src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,6 @@
"edit_translation": "Clic para editar",
"search": "Buscar",
"no_results": "Sin resultados",
"search_below_minimum": "Mínimo 3 caracteres"
"search_below_minimum": "Mínimo 3 caracteres",
"search_in_document": "Buscar en documento"
}
8 changes: 8 additions & 0 deletions src/store/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const state = {
pageChangedFromThumbnail: false,
showAnnSetTable: null,
showChooseLabelSetModal: null,
currentSearch: "",
searchEnabled: false,
searchResults: [],
searchLoading: false,
Expand Down Expand Up @@ -321,6 +322,10 @@ const actions = {
commit("ENABLE_SEARCH", toEnable);
},

setCurrentSearch({ commit }, currentSearch) {
commit("SET_CURRENT_SEARCH", currentSearch);
},

setCurrentSearchResult({ commit, state }, n) {
let newSearchResult = state.currentSearchResult + n;
const searchResultsMaxIndex = state.searchResults.length - 1;
Expand Down Expand Up @@ -392,6 +397,9 @@ const mutations = {
ENABLE_SEARCH: (state, toEnable) => {
state.searchEnabled = toEnable;
},
SET_CURRENT_SEARCH: (state, currentSearch) => {
state.currentSearch = currentSearch;
},
SET_CURRENT_SEARCH_RESULT: (state, n) => {
state.currentSearchResult = n;
},
Expand Down

0 comments on commit 09bfae0

Please sign in to comment.