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

Drag-and-Drop for video sorting #845

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions assets/css/opencast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ $action-menu-icon-size: 20px;
overflow: hidden;
max-height: 70px;

.dragarea .oc--drag-handle {
cursor: move;
}

.oc--playercontainer {
background-color: transparent;

Expand Down
1 change: 1 addition & 0 deletions assets/images/grabber_grey.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 10 additions & 15 deletions vueapp/components/Videos/VideoRow.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<template>
<tr class="oc--episode" v-if="event.refresh === undefined" :key="event.id">
<td v-if="playlistEditable && videoSortMode">
<a class="dragarea" title="$gettextInterpolate($gettext('Video per Drag & Drop verschieben'))">
<img class="oc--drag-handle"
:src="dragHandle"
height="24"
/>
</a>
</td>

<td v-if="showCheckbox">
<input type="checkbox" :checked="isChecked" @click.stop="toggleVideo">
</td>
Expand Down Expand Up @@ -103,21 +112,6 @@
@redirectAction="redirectAction"
/>
</td>

<td v-if="playlistEditable && videoSortMode" class="oc--sort-options">
<studip-icon
:style="{visibility: canMoveUp ? 'visible' : 'hidden'}"
shape="arr_2up" role="navigation"
@click="$emit('moveUp', event.token)"
:title="$gettext('Element nach oben verschieben')"
/>
<studip-icon
:style="{visibility: canMoveDown ? 'visible' : 'hidden'}"
shape="arr_2down" role="navigation"
@click="$emit('moveDown', event.token)"
:title="$gettext('Element nach unten verschieben')"
/>
</td>
</tr>
<tr v-else>
<td :colspan="numberOfColumns">
Expand Down Expand Up @@ -180,6 +174,7 @@ export default {
preview: window.OpencastPlugin.PLUGIN_ASSET_URL + '/images/default-preview.png',
play: window.OpencastPlugin.PLUGIN_ASSET_URL + '/images/play.svg',
cut: window.OpencastPlugin.PLUGIN_ASSET_URL + '/images/cut.svg',
dragHandle: window.OpencastPlugin.PLUGIN_ASSET_URL + '/images/grabber_grey.svg',
DeleteConfirmDialog: false,
DownloadDialog: false,
editDialog: false,
Expand Down
49 changes: 7 additions & 42 deletions vueapp/components/Videos/VideosTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@

<table id="episodes" class="default oc--episode-table--small">
<colgroup>
<col v-if="editable && videoSortMode" style="width: 20px">
<col v-if="showCheckbox" style="width: 30px">
<col style="width: 119px">
<col>
<col style="width: 180px" class="responsive-hidden">
<col style="width: 150px" class="responsive-hidden">
<col style="width: 18px">
<col v-if="showActions" style="width: 64px">
<col v-if="showActions && !videoSortMode" style="width: 64px">
</colgroup>
<thead>
<tr class="sortable">
<th v-if="editable && videoSortMode" data-sort="false"></th>
<th v-if="showCheckbox" data-sort="false">
<input
type="checkbox"
Expand All @@ -56,7 +58,7 @@
</a>
</th>
<th></th>
<th v-if="showActions" class="actions" data-sort="false">{{ $gettext('Aktionen') }}</th>
<th v-if="showActions && !videoSortMode" class="actions" data-sort="false">{{ $gettext('Aktionen') }}</th>
</tr>
</thead>

Expand Down Expand Up @@ -85,10 +87,6 @@
<VideoRow
:event="element"
:numberOfColumns="numberOfColumns"
:canMoveUp="canMoveUp(index)"
:canMoveDown="canMoveDown(index)"
@moveUp="moveUpVideoRow"
@moveDown="moveDownVideoRow"
:selectedVideos="selectedVideos"
@toggle="toggleVideo"
:selectable="selectable"
Expand Down Expand Up @@ -224,10 +222,9 @@ export default {
VideoDownload, VideoReport,
VideoEdit, VideoRestore,
VideoDelete, VideoDeletePermanent,
VideoLinkToPlaylists, VideoRemoveFromPlaylist,
CaptionUpload, BulkVideoDelete,
BulkVideoDeletePermanent, BulkVideoRestore,
draggable,
VideoRemoveFromPlaylist, CaptionUpload,
BulkVideoDelete, BulkVideoDeletePermanent,
BulkVideoRestore, draggable,
},

props: {
Expand Down Expand Up @@ -486,26 +483,6 @@ export default {
return classes;
},

canMoveUp(index) {
return this.videoSortMode && (index !== 0);
},

canMoveDown(index) {
return this.videoSortMode && (index !== this.loadedVideos.length - 1);
},

moveUpVideoRow(token) {
const index = this.sortedVideos.findIndex(video => {
return video.token === token;
});

if (this.canMoveUp(index)) {
let tmp = this.sortedVideos[index - 1];
this.sortedVideos[index - 1] = this.sortedVideos[index];
this.sortedVideos[index] = tmp;
}
},

removeVideosFromPlaylist() {
let view = this;

Expand All @@ -524,18 +501,6 @@ export default {
})
},

moveDownVideoRow(token) {
const index = this.sortedVideos.findIndex(video => {
return video.token === token;
});

if (this.canMoveDown(index)) {
let tmp = this.sortedVideos[index + 1];
this.sortedVideos[index + 1] = this.sortedVideos[index];
this.sortedVideos[index] = tmp;
}
},

/*
addVideosToPlaylist() {
let view = this;
Expand Down