Skip to content

Commit 6f5fc43

Browse files
committed
Toggle submitted recordings in sidebar
1 parent 20febf7 commit 6f5fc43

File tree

3 files changed

+100
-54
lines changed

3 files changed

+100
-54
lines changed

client/src/components/RecordingList.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ import { EditingRecording } from './UploadRecording.vue';
77
export default defineComponent({
88
setup() {
99
10-
const { sharedList, recordingList, currentUser, configuration } = useState();
10+
const {
11+
sharedList,
12+
recordingList,
13+
currentUser,
14+
configuration,
15+
showSubmittedRecordings,
16+
myRecordingsDisplay,
17+
sharedRecordingsDisplay,
18+
} = useState();
1119
const editingRecording: Ref<EditingRecording | null> = ref(null);
1220
1321
const fetchRecordings = async () => {
@@ -47,18 +55,27 @@ export default defineComponent({
4755
openPanel,
4856
userSubmittedAnnotation,
4957
configuration,
58+
myRecordingsDisplay,
59+
sharedRecordingsDisplay,
60+
showSubmittedRecordings,
5061
};
5162
},
5263
});
5364
</script>
5465

5566
<template>
5667
<v-expansion-panels v-model="openPanel">
68+
<v-checkbox
69+
v-if="configuration.mark_annotations_completed_enabled"
70+
v-model="showSubmittedRecordings"
71+
label="Show submitted recordings"
72+
hide-details
73+
/>
5774
<v-expansion-panel>
5875
<v-expansion-panel-title>My Recordings</v-expansion-panel-title>
5976
<v-expansion-panel-text>
6077
<div
61-
v-for="item in recordingList"
78+
v-for="item in myRecordingsDisplay"
6279
:key="`public_${item.id}`"
6380
>
6481
<v-card class="pa-2 my-2">

client/src/use/useState.ts

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, Ref, watch } from "vue";
1+
import { computed, ref, Ref, watch } from "vue";
22
import { useRouter } from 'vue-router';
33
import { cloneDeep } from "lodash";
44
import * as d3 from "d3";
@@ -160,6 +160,65 @@ export default function useState() {
160160

161161
const showSubmittedRecordings = ref(false);
162162

163+
const submittedMyRecordings = computed(() => {
164+
const submittedByMe = recordingList.value.filter((recording: Recording) => {
165+
const myAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
166+
annotation.owner === currentUser.value && annotation.submitted
167+
));
168+
return myAnnotations.length > 0;
169+
});
170+
return submittedByMe;
171+
});
172+
173+
const submittedSharedRecordings = computed(() => {
174+
const submittedByMe = sharedList.value.filter((recording: Recording) => {
175+
const myAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
176+
annotation.owner === currentUser.value && annotation.submitted
177+
));
178+
return myAnnotations.length > 0;
179+
});
180+
return submittedByMe;
181+
});
182+
183+
const unsubmittedMyRecordings = computed(() => {
184+
const unsubmitted = recordingList.value.filter((recording: Recording) => {
185+
const myAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
186+
annotation.owner === currentUser.value && annotation.submitted
187+
));
188+
return myAnnotations.length === 0;
189+
});
190+
return unsubmitted;
191+
});
192+
193+
const unsubmittedSharedRecordings = computed(() => {
194+
const unsubmitted = sharedList.value.filter((recording: Recording) => {
195+
const myAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
196+
annotation.owner === currentUser.value && annotation.submitted
197+
));
198+
return myAnnotations.length === 0;
199+
});
200+
return unsubmitted;
201+
});
202+
203+
// Use state to determine which recordings should be shown to the user
204+
const myRecordingsDisplay = computed(() => {
205+
if (!configuration.value.mark_annotations_completed_enabled) {
206+
return recordingList.value;
207+
} else {
208+
return showSubmittedRecordings.value ? recordingList.value : unsubmittedMyRecordings.value;
209+
}
210+
});
211+
212+
const sharedRecordingsDisplay = computed(() => {
213+
if (!configuration.value.mark_annotations_completed_enabled) {
214+
return sharedList.value;
215+
} else {
216+
return showSubmittedRecordings.value ? sharedList.value : unsubmittedSharedRecordings.value;
217+
}
218+
});
219+
220+
221+
163222
return {
164223
annotationState,
165224
creationType,
@@ -203,5 +262,11 @@ export default function useState() {
203262
fixedAxes,
204263
toggleFixedAxes,
205264
showSubmittedRecordings,
265+
submittedMyRecordings,
266+
submittedSharedRecordings,
267+
unsubmittedMyRecordings,
268+
unsubmittedSharedRecordings,
269+
myRecordingsDisplay,
270+
sharedRecordingsDisplay,
206271
};
207272
}

client/src/views/Recordings.vue

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import RecordingAnnotationSummary from '@components/RecordingAnnotationSummary.v
2222
import { FilterFunction, InternalItem } from 'vuetify';
2323
2424
export default defineComponent({
25-
components: {
26-
UploadRecording,
27-
MapLocation,
28-
BatchUploadRecording,
29-
RecordingInfoDisplay,
30-
RecordingAnnotationSummary,
31-
},
25+
components: {
26+
UploadRecording,
27+
MapLocation,
28+
BatchUploadRecording,
29+
RecordingInfoDisplay,
30+
RecordingAnnotationSummary,
31+
},
3232
setup() {
3333
const itemsPerPage = ref(-1);
3434
const {
@@ -39,6 +39,10 @@ export default defineComponent({
3939
configuration,
4040
loadCurrentUser,
4141
showSubmittedRecordings,
42+
submittedMyRecordings,
43+
submittedSharedRecordings,
44+
myRecordingsDisplay,
45+
sharedRecordingsDisplay,
4246
} = useState();
4347
const editingRecording: Ref<EditingRecording | null> = ref(null);
4448
let intervalRef: number | null = null;
@@ -232,46 +236,6 @@ export default defineComponent({
232236
}
233237
}
234238
235-
const submittedMyRecordings = computed(() => {
236-
const submittedByMe = recordingList.value.filter((recording: Recording) => {
237-
const myAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
238-
annotation.owner === currentUser.value && annotation.submitted
239-
));
240-
return myAnnotations.length > 0;
241-
});
242-
return submittedByMe;
243-
});
244-
245-
const submittedSharedRecordings = computed(() => {
246-
const submittedByMe = sharedList.value.filter((recording: Recording) => {
247-
const myAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
248-
annotation.owner === currentUser.value && annotation.submitted
249-
));
250-
return myAnnotations.length > 0;
251-
});
252-
return submittedByMe;
253-
});
254-
255-
const unsubmittedMyRecordings = computed(() => {
256-
const unsubmitted = recordingList.value.filter((recording: Recording) => {
257-
const myAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
258-
annotation.owner === currentUser.value && annotation.submitted
259-
));
260-
return myAnnotations.length === 0;
261-
});
262-
return unsubmitted;
263-
});
264-
265-
const unsubmittedSharedRecordings = computed(() => {
266-
const unsubmitted = sharedList.value.filter((recording: Recording) => {
267-
const myAnnotations = recording.fileAnnotations.filter((annotation: FileAnnotation) => (
268-
annotation.owner === currentUser.value && annotation.submitted
269-
));
270-
return myAnnotations.length === 0;
271-
});
272-
return unsubmitted;
273-
});
274-
275239
const recordingListStyles = computed(() => {
276240
const sectionHeight = configuration.value.mark_annotations_completed_enabled ? '35vh' : '40vh';
277241
return {
@@ -359,10 +323,10 @@ export default defineComponent({
359323
configuration,
360324
submittedMyRecordings,
361325
submittedSharedRecordings,
362-
unsubmittedMyRecordings,
363-
unsubmittedSharedRecordings,
364326
recordingListStyles,
365327
showSubmittedRecordings,
328+
myRecordingsDisplay,
329+
sharedRecordingsDisplay,
366330
};
367331
},
368332
});
@@ -436,7 +400,7 @@ export default defineComponent({
436400
<v-data-table
437401
v-model:items-per-page="itemsPerPage"
438402
:headers="headers"
439-
:items="showSubmittedRecordings ? recordingList : unsubmittedMyRecordings"
403+
:items="myRecordingsDisplay"
440404
:custom-filter="tagFilter"
441405
filter-keys="['tag']"
442406
:search="filterTags.length ? 'seach-active' : ''"
@@ -637,7 +601,7 @@ export default defineComponent({
637601
<v-data-table
638602
v-model:items-per-page="itemsPerPage"
639603
:headers="sharedHeaders"
640-
:items="showSubmittedRecordings ? sharedList : unsubmittedSharedRecordings"
604+
:items="sharedRecordingsDisplay"
641605
:custom-filter="sharedTagFilter"
642606
filter-keys="['tag']"
643607
:search="sharedFilterTags.length ? 'seach-active' : ''"

0 commit comments

Comments
 (0)