statamic / collaboration

Real-time, multi-user editing with Statamic via websockets
https://statamic.com/addons/statamic/collaboration
33 stars 13 forks source link

New contents in stack are deleted after publication #19

Open wiebkevogel opened 4 years ago

wiebkevogel commented 4 years ago

When editing entries with several users, we have the problem that edited entries in a stack can be deleted by publishing them, for example:

User 1: is in the entry and makes a change User 2: opens another entry from the same entry (Relationship-Fieldtype: edit) in a stack and make some changes User 1: stores and publishes the new content User 2: gets a notification and has only the possibility to reload the page and not save its changes any more

Suggestion would be to include a "cancel" button in the dialog, so that user 2 gets the possibility to save or continue. What did you think?

wiebkevogel commented 4 years ago

Maybe something like:

Workspace.js

        this.channel.listenForWhisper('published', ({ user, message }) => {
            Statamic.$toast.success(`Published by ${user.name}.`);
            const messageProp = message
                ? `Entry has been published by ${user.name} with the message: ${message}`
                : `Entry has been published by ${user.name} with no message.`
            Statamic.$components.append('CollaborationBlockingNotification', {
                props: { message: messageProp }
            }).on('confirm', () => window.location.reload());
        });

BlockingNotification.vue

<template>

    <modal name="confirmation-modal" :pivotY="0.1" :overflow="false">
        <div class="confirmation-modal flex flex-col h-full" slot-scope="{ close }">
            <div class="text-lg font-medium p-2 pb-0">
                Refresh Required
            </div>
            <div class="flex-1 px-2 py-3 text-grey">
                {{ message }}
            </div>
            <div class="p-2 bg-grey-20 border-t flex items-center justify-end text-sm">
                <button class="btn btn-default ml-2" @click="close">Continue without reload</button>
                <button class="btn btn-primary ml-2" @click="$emit('confirm')">Refresh</button>
            </div>
        </div>
    </modal>

</template>

<script>
export default {

    props: ['message'],

}
</script>