Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut to focus the "find label" input field #938

Merged
merged 17 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions resources/assets/js/annotations/annotatorContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default {
userUpdatedVolareResolution: false,
userId: null,
crossOriginError: false,
focusInputFindlabel: false,
};
},
computed: {
Expand Down Expand Up @@ -596,7 +597,18 @@ export default {
selectLastAnnotation() {
let lastAnnotation = this.annotations.reduce((lastAnnotated, a) => a.id > lastAnnotated.id ? a : lastAnnotated, { id: 0 });
this.handleSelectAnnotation(lastAnnotation);
},
openSidebarLabels() {
this.$refs.sidebar.$emit('open', 'labels');
this.setFocusInputFindLabel()
},
setFocusInputFindLabel(){
this.focusInputFindlabel = false;
this.$nextTick(() => {
this.focusInputFindlabel = true;
});
}

},
watch: {
async imageId(id) {
Expand Down Expand Up @@ -747,6 +759,8 @@ export default {
this.openTab = openTab;
}
}

Keyboard.on('control+k', this.openSidebarLabels, 0, this.listenerSet);

Keyboard.on('C', this.selectLastAnnotation, 0, this.listenerSet);
},
Expand Down
6 changes: 6 additions & 0 deletions resources/assets/js/annotations/components/labelsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export default {
selectedLabel: null,
};
},
props: {
focusInput:{
type: Boolean,
default: false,
}
},
computed: {
plugins() {
return plugins;
Expand Down
17 changes: 16 additions & 1 deletion resources/assets/js/label-trees/components/labelTrees.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="label-trees">
<div v-if="typeahead || clearable" class="label-trees__head">
<button v-if="clearable" @click="clear" class="btn btn-default" title="Clear selected labels" type="button"><span class="fa fa-times fa-fw" aria-hidden="true"></span></button>
<typeahead v-if="typeahead" :items="labels" more-info="tree.versionedName" @select="handleSelect" placeholder="Find label"></typeahead>
<typeahead ref="typeaheadInput" v-if="typeahead" :items="labels" more-info="tree.versionedName" @select="handleSelect" placeholder="Find label"></typeahead>
</div>
<div class="label-trees__body">
<label-tree v-if="hasFavourites" name="Favourites" :labels="favourites" :show-favourites="showFavourites" :flat="true" :showFavouriteShortcuts="true" :collapsible="collapsible" @select="handleSelect" @deselect="handleDeselect" @remove-favourite="handleRemoveFavourite"></label-tree>
Expand All @@ -15,6 +15,7 @@
import Keyboard from '../../core/keyboard';
import LabelTree from './labelTree';
import Typeahead from './labelTypeahead';
import Events from '../../core/events';

/**
* A component that displays a list of label trees.
Expand Down Expand Up @@ -73,6 +74,10 @@ export default {
type: String,
default: 'default',
},
focusInput:{
type: Boolean,
default: false,
}
},
computed: {
localeCompareSupportsLocales() {
Expand Down Expand Up @@ -192,7 +197,14 @@ export default {
});
},
},
focusInput(){
if(this.focusInput){
this.$refs.typeaheadInput.$el.querySelector('input').focus();
}
}

lehecht marked this conversation as resolved.
Show resolved Hide resolved
},

mounted() {
if (this.showFavourites) {
let favouriteIds = JSON.parse(localStorage.getItem(this.favouriteStorageKey));
Expand Down Expand Up @@ -222,6 +234,9 @@ export default {
}
bindFavouriteKey('0', 9);
}
Events.$on('callFunctionFocustypeahead', () => {
this.focusTypeahead();
});
lehecht marked this conversation as resolved.
Show resolved Hide resolved
},
};
</script>
22 changes: 22 additions & 0 deletions resources/assets/js/videos/videoContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default {
swappingLabel: false,
disableJobTracking: false,
supportsJumpByFrame: false,
focusInputFindlabel: false,
};
},
computed: {
Expand Down Expand Up @@ -677,6 +678,16 @@ export default {
selectLastAnnotation() {
let lastAnnotation = this.annotations.reduce((lastAnnotated, a) => a.id > lastAnnotated.id ? a : lastAnnotated, { id: 0 });
this.selectAnnotations([lastAnnotation], this.selectedAnnotations, lastAnnotation.startFrame);
},
openSidebarLabels() {
this.$refs.sidebar.$emit('open', 'labels');
this.setFocusInputFindLabel()
},
setFocusInputFindLabel(){
lehecht marked this conversation as resolved.
Show resolved Hide resolved
this.focusInputFindlabel = false;
this.$nextTick(() => {
this.focusInputFindlabel = true;
});
}
},
watch: {
Expand Down Expand Up @@ -742,6 +753,17 @@ export default {
if ("requestVideoFrameCallback" in HTMLVideoElement.prototype) {
this.supportsJumpByFrame = true;
}

Events.$on('focusTypeaheadEvent', () => {
this.focusInputFindlabel = false;
this.$nextTick(() => {
this.focusInputFindlabel = true;
});
this.focusInputFindlabel = false;
});
lehecht marked this conversation as resolved.
Show resolved Hide resolved

Keyboard.on('control+k', this.openSidebarLabels, 0, this.listenerSet);

},
mounted() {
// Wait for the sub-components to register their event listeners before
Expand Down
1 change: 1 addition & 0 deletions resources/views/annotations/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
ref="sidebar"
:open-tab="openTab"
:toggle-on-keyboard="true"
:focus-input="focusInputFindlabel"
lehecht marked this conversation as resolved.
Show resolved Hide resolved
v-on:open="handleOpenedTab"
v-on:close="handleClosedTab"
v-cloak>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/annotations/show/tabs/labels.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<sidebar-tab name="labels" icon="tags" title="Label trees">
<labels-tab v-on:select="handleSelectedLabel" v-cloak inline-template>
<labels-tab v-on:select="handleSelectedLabel" :focus-input="focusInputFindlabel" v-cloak inline-template>
<div class="labels-tab">
<div class="labels-tab__trees">
<label-trees :trees="labelTrees" :show-favourites="true" v-on:select="handleSelectedLabel" v-on:deselect="handleDeselectedLabel" v-on:clear="handleDeselectedLabel"></label-trees>
<label-trees :trees="labelTrees" :show-favourites="true" :focus-input="focusInput" v-on:select="handleSelectedLabel" v-on:deselect="handleDeselectedLabel" v-on:clear="handleDeselectedLabel"></label-trees>
</div>
<div class="labels-tab__plugins">
@mixin('annotationsLabelsTab')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
<td><kbd>c</kbd></td>
<td>Select last created annotation</td>
</tr>
<tr>
<td><kbd>Ctrl</kbd>+<kbd>k</kbd></td>
<td>Open label trees sidebar and focus the find label input field</td>
</tr>
</tbody>
</table>

Expand Down
4 changes: 4 additions & 0 deletions resources/views/manual/tutorials/videos/shortcuts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
<td><kbd>c</kbd></td>
<td>Select last created annotation</td>
</tr>
<tr>
<td><kbd>Ctrl</kbd>+<kbd>k</kbd></td>
<td>Open label trees sidebar and focus the find label input field</td>
</tr>
</tbody>
</table>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/videos/show/sidebar-labels.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<sidebar-tab name="labels" icon="tags" title="Label trees">
<div class="labels-tab">
<div class="labels-tab__trees">
<label-trees :trees="labelTrees" :show-favourites="true" v-on:select="handleSelectedLabel" v-on:deselect="handleDeselectedLabel" v-on:clear="handleDeselectedLabel"></label-trees>
<label-trees :trees="labelTrees" :focus-input="focusInputFindlabel" :show-favourites="true" v-on:select="handleSelectedLabel" v-on:deselect="handleDeselectedLabel" v-on:clear="handleDeselectedLabel"></label-trees>
</div>
</div>
</sidebar-tab>