Skip to content

Commit 368a091

Browse files
committed
[General] Take care of a few todos
1 parent fd7a466 commit 368a091

File tree

7 files changed

+56
-15
lines changed

7 files changed

+56
-15
lines changed

notes.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
- [X] Gradients with three points
1515
- [ ] Legend displaying what the colours mean
1616
- [ ] Pick default algorithm
17-
- [ ] Space to confirm current assignment (i.e. create annotation for it)
18-
- [ ] Keybind to flag as invalid
17+
- [X] Space to confirm current assignment (i.e. create annotation for it)
18+
- [X] Keybind to flag as invalid
19+
- [X] Shift to show all algorithms for current fixation
20+
- [ ] Use other combination for the above, as shift key cannot be detected (neither all other modifiers)
1921
- [ ] Do we need more settings for the above?
20-
- [ ] Shift to show all algorithms for current fixation
2122
- [X] Fixation click on fixation in box directly assigning it
2223
- [ ] Test the above, may need to be changed to a more complex handler
2324
- [X] Filter annotations by algorithms

src/components/admin/surveys/SurveyBrowser.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<script setup lang="ts">
2+
import {
3+
onMounted,
4+
onUnmounted,
5+
ref
6+
} from 'vue';
27
import {
38
adminBaseRoute
49
} from '../adminConfig';
510
import {
611
listSurveys
712
} from '@/ts/surveys';
8-
import {
9-
ref
10-
} from 'vue';
1113
import testData from '@/ts/dev/SurveyTesData.json';
1214
import {
1315
useNotification
@@ -67,7 +69,16 @@
6769
router.push( adminBaseRoute + 'surveys/create' );
6870
};
6971
70-
reloadFromServer();
72+
onMounted( () => {
73+
reloadFromServer();
74+
document.addEventListener( 'eyetap:survey:create', reloadFromServer );
75+
} );
76+
77+
onUnmounted( () => {
78+
try {
79+
document.removeEventListener( 'eyetap:survey:create', reloadFromServer );
80+
} catch { /* empty */ }
81+
} );
7182
</script>
7283

7384
<template>

src/components/admin/surveys/SurveyCreator.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
).then( links => {
134134
surveyStore.setLinks( links );
135135
router.push( adminBaseRoute + 'surveys/magiclinks' );
136+
document.dispatchEvent( new CustomEvent( 'eyetap:survey:create' ) );
136137
} );
137138
};
138139

src/editor/components/KeybindPane.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
'function': 'Undo'
3030
},
3131
{
32-
'keybind': 'Delete / Backspace',
32+
'keybind': 'Backspace',
3333
'function': 'Undo'
3434
},
3535
{
@@ -51,6 +51,10 @@
5151
{
5252
'keybind': 'Letters',
5353
'function': 'Assign the current fixation to the closest box of this letter'
54+
},
55+
{
56+
'keybind': 'Delete',
57+
'function': 'Mark fixation as invalid'
5458
}
5559
];
5660
const show = defineModel<boolean>();

src/editor/components/OptionsPane.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script setup lang="ts">
2-
32
import {
43
boxesDisplay,
54
boxesDisplayOptions,
@@ -17,6 +16,7 @@
1716
<div class="options-pane">
1817
<div class="options-container">
1918
<div class="options-section">
19+
{{ linesDisplay }}
2020
<p> Display </p>
2121
<SliderOptions
2222
v-model="boxesDisplay"

src/editor/io/keyboard.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
import {
2+
type LinesDisplay,
3+
disableKeyHandler,
4+
keyboardZoomPanStep,
5+
keyboardZoomStep,
6+
linesDisplay
7+
} from '../config';
18
import {
29
algorithmsList,
310
annotations,
411
fixations,
512
selectedAlgorithm,
613
selectedFixation
714
} from '../data';
8-
import {
9-
disableKeyHandler,
10-
keyboardZoomPanStep,
11-
keyboardZoomStep
12-
} from '../config';
1315
import {
1416
onMounted,
1517
onUnmounted
@@ -36,6 +38,8 @@ import zoom from '../manager/zoom';
3638
export const keyboardHandler = ( renderer: Renderer ) => {
3739
const annotation = annotationManager( renderer );
3840

41+
let prevSelectedDisplayMode: LinesDisplay = linesDisplay.value;
42+
3943
const handler = ( ev: KeyboardEvent ) => {
4044
if ( !disableKeyHandler.value ) {
4145
if ( isCharacterKey( ev.key ) && !ev.ctrlKey && !ev.metaKey && !ev.altKey ) {
@@ -46,7 +50,7 @@ export const keyboardHandler = ( renderer: Renderer ) => {
4650
false,
4751
true
4852
);
49-
} else if ( isUndoCmd( ev ) || ev.key === 'Backspace' || ev.key === 'Delete' ) {
53+
} else if ( isUndoCmd( ev ) || ev.key === 'Backspace' ) {
5054
ev.preventDefault();
5155
undo();
5256
} else if ( isRedoCmd( ev ) ) {
@@ -94,18 +98,37 @@ export const keyboardHandler = ( renderer: Renderer ) => {
9498
false
9599
);
96100
} catch { /* empty */ }
101+
} else if ( ev.key === 'Delete' ) {
102+
// TODO: Update this keybind if needed
103+
annotation.markAsInvalid( selectedFixation.value );
104+
} else if ( ev.key === 'Enter' ) {
105+
if ( linesDisplay.value !== 'allalgos' ) {
106+
prevSelectedDisplayMode = linesDisplay.value;
107+
linesDisplay.value = 'allalgos';
108+
}
97109
}
98110
}
99111
};
100112

113+
const keyUpHandler = ( ev: KeyboardEvent ) => {
114+
if ( ev.key === 'Enter' ) {
115+
linesDisplay.value = prevSelectedDisplayMode;
116+
}
117+
};
118+
101119
onMounted( () => {
102120
document.addEventListener( 'keydown', handler );
121+
document.addEventListener( 'keyup', keyUpHandler );
103122
} );
104123

105124
onUnmounted( () => {
106125
try {
107126
document.removeEventListener( 'keydown', handler );
108127
} catch { /* empty */ }
128+
129+
try {
130+
document.removeEventListener( 'keyup', keyUpHandler );
131+
} catch { /* empty */ }
109132
} );
110133
};
111134

src/types/globals/events.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ declare global {
2222
'eyetap:keys:next': CustomEvent<void>;
2323
'eyetap:keys:prev': CustomEvent<void>;
2424
'eyetap:theme': CustomEvent<void>;
25+
'eyetap:survey:create': CustomEvent<void>;
2526
}
2627
}

0 commit comments

Comments
 (0)