Skip to content

Commit 56d9c29

Browse files
committed
Move moveModal and clean COntentNodeOptions
1 parent 27d3422 commit 56d9c29

7 files changed

Lines changed: 64 additions & 105 deletions

File tree

contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeEditListItem.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,8 @@
9191
</template>
9292

9393
<template #context-menu="{ showContextMenu, positionX, positionY }">
94-
<ContentNodeContextMenu
95-
v-if="false"
96-
:show="showContextMenu"
97-
:positionX="positionX"
98-
:positionY="positionY"
94+
<ContentNodeOptions
95+
isContextMenu
9996
:nodeId="nodeId"
10097
/>
10198
</template>

contentcuration/contentcuration/frontend/channelEdit/components/ContentNodeOptions.vue

Lines changed: 13 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,22 @@
11
<template>
22

33
<KDropdownMenu
4+
:isContextMenu="isContextMenu"
45
:options="menuOptions"
5-
@select="onSelect"
6+
@select="handleSelect"
67
/>
7-
<!-- <div
8-
style="max-height: 80vh"
9-
>
10-
<VList ref="optionsList">
11-
<template
12-
v-for="(group, groupIndex) in groupedOptions"
13-
>
14-
<VListTile
15-
v-for="(option, index) in group"
16-
:key="groupIndex + '-' + index"
17-
class="options-list-item"
18-
ripple
19-
:to="option.to"
20-
tabindex="0"
21-
@click="option.onClick($event)"
22-
@keydown.enter="option.onClick($event)"
23-
@keydown.tab="checkTabBoundaries($event)"
24-
>
25-
<VListTileTitle>
26-
{{ option.label }}
27-
</VListTileTitle>
28-
</VListTile>
29-
<VDivider
30-
v-if="groupIndex < groupedOptions.length - 1"
31-
:key="groupIndex + '-divider'"
32-
class="divider"
33-
/>
34-
</template>
35-
</VList>
36-
37-
<MoveModal
38-
v-if="moveModalOpen"
39-
ref="moveModal"
40-
v-model="moveModalOpen"
41-
:moveNodeIds="[nodeId]"
42-
@target="moveNode"
43-
/>
44-
</div> -->
458

469
</template>
4710

4811
<script>
4912
5013
import { mapActions, mapGetters } from 'vuex';
5114
import { RouteNames, TabNames, QuickEditModals } from '../constants';
52-
import MoveModal from './move/MoveModal';
5315
import { withChangeTracker } from 'shared/data/changes';
5416
import { RELATIVE_TREE_POSITIONS } from 'shared/data/constants';
5517
5618
export default {
5719
name: 'ContentNodeOptions',
58-
components: {
59-
MoveModal,
60-
},
6120
props: {
6221
nodeId: {
6322
type: String,
@@ -71,11 +30,10 @@
7130
type: Boolean,
7231
default: false,
7332
},
74-
},
75-
data() {
76-
return {
77-
moveModalOpen: false,
78-
};
33+
isContextMenu: {
34+
type: Boolean,
35+
default: false,
36+
},
7937
},
8038
computed: {
8139
...mapGetters('currentChannel', ['canEdit', 'trashId']),
@@ -117,7 +75,8 @@
11775
label: this.$tr('move'),
11876
onClick: $event => {
11977
$event.stopPropagation();
120-
this.moveModalOpen = true;
78+
this.trackAction('Move');
79+
this.setMoveNodesIds([this.nodeId]);
12180
},
12281
condition: this.canEdit,
12382
},
@@ -228,22 +187,6 @@
228187
};
229188
},
230189
},
231-
watch: {
232-
moveModalOpen(open) {
233-
if (open) {
234-
this.trackAction('Move');
235-
}
236-
},
237-
},
238-
beforeMount() {
239-
this.lastFocus = document.activeElement;
240-
},
241-
mounted() {
242-
this.focusFirstOption();
243-
},
244-
destroyed() {
245-
this.lastFocus && this.lastFocus.focus();
246-
},
247190
methods: {
248191
...mapActions(['showSnackbar', 'clearSnackbar']),
249192
...mapActions('contentNode', [
@@ -252,33 +195,12 @@
252195
'copyContentNode',
253196
'waitForCopyingStatus',
254197
'setQuickEditModal',
198+
'setMoveNodesIds',
255199
]),
256200
...mapActions('clipboard', ['copy']),
257-
async focusFirstOption() {
258-
// const { optionsList } = this.$refs;
259-
// const firstOption = optionsList.$el.querySelector('a');
260-
// let tries = 0;
261-
// while (document.activeElement !== firstOption && tries++ < 20) {
262-
// await new Promise(resolve => setTimeout(resolve, 0));
263-
// firstOption.focus();
264-
// }
265-
},
266-
checkTabBoundaries($event) {
267-
const optionsList = this.$refs.optionsList;
268-
const options = optionsList.$el.querySelectorAll('a');
269-
const index = Array.from(options).indexOf($event.target);
270-
if (
271-
(index === 0 && $event.shiftKey) ||
272-
(index === options.length - 1 && !$event.shiftKey)
273-
) {
274-
// destroy component
275-
$event.preventDefault();
276-
this.$destroy();
277-
}
278-
},
279-
onSelect(option) {
201+
handleSelect(option, $event) {
280202
if (option.onClick) {
281-
option.onClick();
203+
option.onClick($event);
282204
}
283205
if (option.to) {
284206
this.$router.push(option.to);
@@ -301,11 +223,6 @@
301223
});
302224
});
303225
},
304-
moveNode(target) {
305-
return this.moveContentNodes({ id__in: [this.nodeId], parent: target }).then(
306-
this.$refs.moveModal.moveComplete
307-
);
308-
},
309226
getRemoveNodeRedirect() {
310227
// Returns a callback to do appropriate post-removal navigation
311228
const { detailNodeId, nodeId } = this.$route.params;
@@ -329,7 +246,8 @@
329246
return () => {};
330247
},
331248
quickEditModalFactory(modal) {
332-
return () => {
249+
return $event => {
250+
$event.preventDefault();
333251
this.setQuickEditModal({
334252
modal,
335253
nodeIds: [this.nodeId],

contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@
228228
<AboutLicensesModal
229229
v-if="isAboutLicensesModalOpen"
230230
/>
231+
<MoveModal
232+
ref="moveModal"
233+
v-model="moveModalDialog"
234+
:moveNodeIds="moveNodeIds"
235+
@target="moveNodes"
236+
/>
231237
<MessageDialog
232238
v-model="showDeleteModal"
233239
:header="$tr('deleteTitle')"
@@ -317,6 +323,7 @@
317323
import ProgressModal from '../progress/ProgressModal';
318324
import PublishModal from '../../components/publish/PublishModal';
319325
import QuickEditModal from '../../components/QuickEditModal';
326+
import MoveModal from '../../components/move/MoveModal';
320327
import SavingIndicator from '../../components/edit/SavingIndicator';
321328
import { DraggableRegions, DraggableUniverses, RouteNames } from '../../constants';
322329
import MainNavigationDrawer from 'shared/views/MainNavigationDrawer';
@@ -348,6 +355,7 @@
348355
DraggablePlaceholder,
349356
MessageDialog,
350357
SavingIndicator,
358+
MoveModal,
351359
QuickEditModal,
352360
AboutLicensesModal,
353361
},
@@ -374,7 +382,10 @@
374382
offline: state => !state.connection.online,
375383
}),
376384
...mapGetters(['isAboutLicensesModalOpen']),
377-
...mapGetters('contentNode', ['getContentNode']),
385+
...mapGetters('contentNode', [
386+
'getContentNode',
387+
'getMoveNodesIds',
388+
]),
378389
...mapGetters('currentChannel', ['currentChannel', 'canEdit', 'canManage', 'rootId']),
379390
rootNode() {
380391
return this.getContentNode(this.rootId);
@@ -473,9 +484,28 @@
473484
dropEffect() {
474485
return DropEffect.COPY;
475486
},
487+
moveNodeIds() {
488+
return this.getMoveNodesIds();
489+
},
490+
moveModalDialog: {
491+
get() {
492+
return (
493+
this.moveNodeIds && this.moveNodeIds.length > 0
494+
)
495+
},
496+
set(value) {
497+
if (!value) {
498+
this.setMoveNodesIds([]);
499+
}
500+
},
501+
},
476502
},
477503
methods: {
478504
...mapActions('channel', ['deleteChannel']),
505+
...mapActions('contentNode', [
506+
'setMoveNodesIds',
507+
'moveContentNodes',
508+
]),
479509
handleDelete() {
480510
this.deleteChannel(this.currentChannel.id).then(() => {
481511
localStorage.snackbar = this.$tr('channelDeletedSnackbar');
@@ -497,6 +527,11 @@
497527
this.showPublishModal = true;
498528
this.trackClickEvent('Publish');
499529
},
530+
moveNodes(target) {
531+
return this.moveContentNodes({ id__in: [this.nodeId], parent: target }).then(
532+
this.$refs.moveModal.moveComplete
533+
);
534+
},
500535
trackClickEvent(eventLabel) {
501536
this.$analytics.trackClick('channel_editor_toolbar', eventLabel);
502537
},

contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ export async function checkSavingProgress(
546546
return Boolean(query);
547547
}
548548

549+
export function setMoveNodesIds(context, ids) {
550+
context.commit('SET_MOVE_NODES', ids);
551+
}
552+
549553
export function setQuickEditModal(context, open) {
550554
context.commit('SET_QUICK_EDIT_MODAL', open);
551555
}

contentcuration/contentcuration/frontend/channelEdit/vuex/contentNode/getters.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,9 @@ export function getQuickEditModalOpen(state) {
357357
return state.quickEditModalOpen;
358358
};
359359
}
360+
361+
export function getMoveNodesIds(state) {
362+
return function() {
363+
return state.moveNodes;
364+
}
365+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"jspdf": "https://github.com/parallax/jsPDF.git#b7a1d8239c596292ce86dafa77f05987bcfa2e6e",
7474
"jszip": "^3.10.1",
7575
"kolibri-constants": "^0.2.0",
76-
"kolibri-design-system": "3.1.0",
76+
"kolibri-design-system": "https://github.com/AlexVelezLl/kolibri-design-system.git#8b8808f35a330e0e25103720ea63f42154f6e678",
7777
"lodash": "^4.17.21",
7878
"material-icons": "0.3.1",
7979
"mutex-js": "^1.1.5",

yarn.lock

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9123,10 +9123,9 @@ kolibri-constants@^0.2.0:
91239123
resolved "https://registry.yarnpkg.com/kolibri-constants/-/kolibri-constants-0.2.0.tgz#47c9d773894e23251ba5ac4db420822e45603142"
91249124
integrity sha512-WYDMGDzB9gNxRbpX1O2cGe1HrJvLvSZGwMuAv6dqrxJgPf7iO+Hi40/1CXjHM7nk5CRt+hn5bqnMzCBmj1omPA==
91259125

9126-
kolibri-design-system@3.1.0:
9126+
"kolibri-design-system@https://github.com/AlexVelezLl/kolibri-design-system.git#8b8808f35a330e0e25103720ea63f42154f6e678":
91279127
version "3.1.0"
9128-
resolved "https://registry.yarnpkg.com/kolibri-design-system/-/kolibri-design-system-3.1.0.tgz#b8cfeeba3c41b0d2c43b4098732367e6732763a8"
9129-
integrity sha512-Xynv24J0uKJFQvhTgbOOWZdRRUMO3NSsobCCrD6R6lvzUqCEqcrJTLgK0ls6LX0MZu2dzxMGA0riLZx4qwikJw==
9128+
resolved "https://github.com/AlexVelezLl/kolibri-design-system.git#8b8808f35a330e0e25103720ea63f42154f6e678"
91309129
dependencies:
91319130
"@vue/composition-api" "^1.7.2"
91329131
aphrodite "https://github.com/learningequality/aphrodite/"

0 commit comments

Comments
 (0)