Skip to content

Commit

Permalink
Instant save in VideoAccess (#811)
Browse files Browse the repository at this point in the history
* Instant save in VideoAccess

* change close button and remove debug messages

* remove debug message

---------

Co-authored-by: Till <[email protected]>
  • Loading branch information
ssrahn and tgloeggl authored Oct 30, 2023
1 parent a618ab4 commit 628df2c
Showing 1 changed file with 38 additions and 30 deletions.
68 changes: 38 additions & 30 deletions vueapp/components/Videos/Actions/VideoAccess.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
<div>
<StudipDialog
:title="$gettext('Video freigeben')"
:confirmText="$gettext('Speichern')"
:confirmClass="'accept'"
:closeText="$gettext('Abbrechen')"
:closeText="$gettext('Schließen')"
:closeClass="'cancel'"
height="600"
width="600"
@close="decline"
@confirm="updateShares"
@close="$emit('done', 'refresh')"
>
<template v-slot:dialogContent>
<form class="default">
Expand Down Expand Up @@ -115,6 +112,7 @@
</table>
</fieldset>
</form>
<MessageList />
</template>
</StudipDialog>
</div>
Expand All @@ -125,6 +123,7 @@ import { mapGetters } from "vuex";
import StudipDialog from '@studip/StudipDialog'
import StudipIcon from '@studip/StudipIcon';
import StudipButton from "@studip/StudipButton";
import MessageList from "@/components/MessageList";
import ShareWithUsers from './VideoAccess/ShareWithUsers';
Expand All @@ -133,7 +132,8 @@ export default {
components: {
StudipDialog, StudipIcon,
ShareWithUsers, StudipButton
ShareWithUsers, StudipButton,
MessageList
},
props: ['event'],
Expand All @@ -154,11 +154,29 @@ export default {
addPerm(user)
{
this.shareUsers.push(user);
this.$store.dispatch('updateVideoShares', {
token: this.event.token,
shares: this.videoShares
})
.catch((er) => {
this.shareUsers.pop();
this.$store.dispatch('addMessage', this.$gettext('Beim Hinzufügen der Freigabe ist ein Fehler aufgetreten.'));
})
},
removePerm(index)
{
this.videoShares.perms.splice(index, 1);
let perm = this.videoShares.perms.splice(index, 1)[0];
this.$store.dispatch('updateVideoShares', {
token: this.event.token,
shares: this.videoShares
})
.catch((er) => {
this.videoShares.perms.splice(index, 0, perm);
this.$store.dispatch('addMessage', this.$gettext('Beim Löschen der Freigabe ist ein Fehler aufgetreten.'));
})
},
addLinkShare()
Expand All @@ -167,23 +185,30 @@ export default {
is_new: true
}
this.videoShares.shares.push(dummyLink);
this.$store.dispatch('updateVideoShares', {
token: this.event.token,
shares: this.videoShares
}).then(({ data }) => {
this.$store.dispatch('addMessage', {
type: 'success',
text: this.$gettext('Share-Link erstellt!')
});
this.initVideoShares();
}).catch((er) => {
console.log('Error while creating share link!', er);
this.$store.dispatch('addMessage', this.$gettext('Beim Hinzufügen des Links ist ein Fehler aufgetreten.'));
});
},
removeLinkShare(index)
{
this.videoShares.shares.splice(index, 1);
let link = this.videoShares.shares.splice(index, 1)[0];
this.$store.dispatch('updateVideoShares', {
token: this.event.token,
shares: this.videoShares
}).then(({ data }) => {
this.initVideoShares();
}).catch((er) => {
this.videoShares.shares.splice(index, 0, link);
this.$store.dispatch('addMessage', this.$gettext('Beim Löschen des Links ist ein Fehler aufgetreten.'));
});
},
copyLinkShare(id) {
Expand All @@ -203,23 +228,6 @@ export default {
}
},
decline() {
this.$emit('cancel');
},
updateShares() {
this.$store.dispatch('updateVideoShares', {
token: this.event.token,
shares: this.videoShares
})
.then(({ data }) => {
this.$store.dispatch('addMessage', this.$gettext('Freigaben gespeichert!'));
this.$emit('done', 'refresh');
}).catch(() => {
this.$emit('cancel');
});
},
initVideoShares() {
this.$store.dispatch('loadVideoShares', this.event.token)
.then(() => {
Expand Down

0 comments on commit 628df2c

Please sign in to comment.