Skip to content

Commit 4a210de

Browse files
committed
Migrate CurrentTopicView view mode and add dropdowns to KDS
1 parent 873c6a6 commit 4a210de

1 file changed

Lines changed: 67 additions & 58 deletions

File tree

contentcuration/contentcuration/frontend/channelEdit/views/CurrentTopicView.vue

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,19 @@
7272
</span>
7373
</template>
7474
</Breadcrumbs>
75-
<BaseMenu
75+
<KIconButton
7676
v-if="!loadingAncestors"
77-
class="pa-1"
77+
icon="list"
78+
:tooltip="$tr('viewModeTooltip')"
7879
>
79-
<template #activator="{ on }">
80-
<IconButton
81-
icon="list"
82-
:text="$tr('viewModeTooltip')"
83-
v-on="on"
80+
<template #menu>
81+
<KDropdownMenu
82+
:options="viewModeOptions"
83+
:hasIcons="true"
84+
@select="handleViewModeSelect"
8485
/>
8586
</template>
86-
<VList>
87-
<VListTile
88-
v-for="mode in viewModes"
89-
:key="mode"
90-
@click="(setViewMode(mode), trackViewMode(mode))"
91-
>
92-
<VListTileAction style="min-width: 32px">
93-
<Icon
94-
v-if="mode === viewMode"
95-
icon="check"
96-
/>
97-
</VListTileAction>
98-
<VListTileTitle>{{ $tr(mode) }}</VListTileTitle>
99-
</VListTile>
100-
</VList>
101-
</BaseMenu>
87+
</KIconButton>
10288
</VToolbar>
10389

10490
<!-- Topic actions -->
@@ -164,42 +150,21 @@
164150
/>
165151
<VSpacer v-if="!selected.length" />
166152
<VToolbarItems v-if="!loadingAncestors">
167-
<BaseMenu v-if="canEdit">
168-
<template #activator="{ on }">
169-
<VBtn
170-
color="primary"
171-
class="ml-2"
172-
style="height: 32px"
173-
v-on="on"
174-
>
175-
{{ $tr('addButton') }}
176-
<Icon
177-
icon="dropdown"
178-
:color="$themeTokens.textInverted"
179-
/>
180-
</VBtn>
153+
<KButton
154+
v-if="canEdit"
155+
:primary="true"
156+
:text="$tr('addButton')"
157+
hasDropdown
158+
class="ml-2"
159+
style="height: 32px"
160+
>
161+
<template #menu>
162+
<KDropdownMenu
163+
:options="addMenuOptions"
164+
@select="handleAddMenuSelect"
165+
/>
181166
</template>
182-
<VList>
183-
<VListTile @click="newTopicNode">
184-
<VListTileTitle>{{ $tr('addTopic') }}</VListTileTitle>
185-
</VListTile>
186-
<VListTile
187-
:to="uploadFilesLink"
188-
@click="trackClickEvent('Upload files')"
189-
>
190-
<VListTileTitle>{{ $tr('uploadFiles') }}</VListTileTitle>
191-
</VListTile>
192-
<VListTile @click="newExerciseNode">
193-
<VListTileTitle>{{ $tr('addExercise') }}</VListTileTitle>
194-
</VListTile>
195-
<VListTile
196-
:to="importFromChannelsRoute"
197-
@click="trackClickEvent('Import from other channels')"
198-
>
199-
<VListTileTitle>{{ $tr('importFromChannels') }}</VListTileTitle>
200-
</VListTile>
201-
</VList>
202-
</BaseMenu>
167+
</KButton>
203168
</VToolbarItems>
204169
</ToolBar>
205170

@@ -325,6 +290,13 @@
325290
import { searchRecommendationsStrings } from 'shared/strings/searchRecommendationsStrings';
326291
import AiRecommendationsBanner from 'shared/views/AiRecommendationsBanner';
327292
293+
const AddMenuOptions = {
294+
ADD_TOPIC: 'add-topic',
295+
UPLOAD_FILES: 'upload-files',
296+
ADD_EXERCISE: 'add-exercise',
297+
IMPORT_FROM_CHANNELS: 'import-from-channels',
298+
};
299+
328300
export default {
329301
name: 'CurrentTopicView',
330302
components: {
@@ -566,6 +538,13 @@
566538
viewModes() {
567539
return Object.values(viewModes);
568540
},
541+
viewModeOptions() {
542+
return this.viewModes.map(mode => ({
543+
label: this.$tr(mode),
544+
value: mode,
545+
icon: mode === this.viewMode ? 'check' : undefined,
546+
}));
547+
},
569548
importFromChannelsRoute() {
570549
return {
571550
name: RouteNames.IMPORT_FROM_CHANNELS_BROWSE,
@@ -574,6 +553,14 @@
574553
},
575554
};
576555
},
556+
addMenuOptions() {
557+
return [
558+
{ label: this.$tr('addTopic'), value: AddMenuOptions.ADD_TOPIC },
559+
{ label: this.$tr('uploadFiles'), value: AddMenuOptions.UPLOAD_FILES },
560+
{ label: this.$tr('addExercise'), value: AddMenuOptions.ADD_EXERCISE },
561+
{ label: this.$tr('importFromChannels'), value: AddMenuOptions.IMPORT_FROM_CHANNELS },
562+
];
563+
},
577564
selectionText() {
578565
return this.getSelectedTopicAndResourceCountText(this.selected);
579566
},
@@ -1015,6 +1002,28 @@
10151002
trackViewMode(mode) {
10161003
this.$analytics.trackAction('general', mode);
10171004
},
1005+
handleViewModeSelect(option) {
1006+
this.setViewMode(option.value);
1007+
this.trackViewMode(option.value);
1008+
},
1009+
handleAddMenuSelect(option) {
1010+
switch (option.value) {
1011+
case AddMenuOptions.ADD_TOPIC:
1012+
this.newTopicNode();
1013+
break;
1014+
case AddMenuOptions.UPLOAD_FILES:
1015+
this.trackClickEvent('Upload files');
1016+
this.$router.push(this.uploadFilesLink);
1017+
break;
1018+
case AddMenuOptions.ADD_EXERCISE:
1019+
this.newExerciseNode();
1020+
break;
1021+
case AddMenuOptions.IMPORT_FROM_CHANNELS:
1022+
this.trackClickEvent('Import from other channels');
1023+
this.$router.push(this.importFromChannelsRoute);
1024+
break;
1025+
}
1026+
},
10181027
showTitleDescriptionModal(nodeId) {
10191028
this.editTitleDescriptionModal = {
10201029
nodeId,

0 commit comments

Comments
 (0)