Libraries can now be shared from the library edit dialog

This commit is contained in:
Thaum Rystra
2020-05-09 13:40:01 +02:00
parent f0e22dc1ca
commit ea88a9c41e
2 changed files with 127 additions and 76 deletions

View File

@@ -1,28 +1,45 @@
<template lang="html"> <template lang="html">
<dialog-base> <dialog-base>
<template slot="toolbar"> <template slot="toolbar">
<div> <div>
{{model && model.name}} {{ model && model.name }}
</div> </div>
<v-spacer/> <v-spacer />
<v-btn flat icon @click="remove"> <v-btn
<v-icon>delete</v-icon> flat
</v-btn> icon
</template> data-id="share-library-button"
<template v-if="model"> @click="share"
<text-field label="name" :value="model.name" @change="updateName"/> >
</template> <v-icon>share</v-icon>
<template slot="actions"> </v-btn>
<v-spacer/> <v-btn
<v-btn flat
flat icon
@click="$store.dispatch('popDialogStack')" data-id="delete-library-button"
data-id="delete-library-button" @click="remove"
> >
Done <v-icon>delete</v-icon>
</v-btn> </v-btn>
</template> </template>
</dialog-base> <template v-if="model">
<text-field
label="name"
:value="model.name"
@change="updateName"
/>
</template>
<template slot="actions">
<v-spacer />
<v-btn
flat
data-id="delete-library-button"
@click="$store.dispatch('popDialogStack')"
>
Done
</v-btn>
</template>
</dialog-base>
</template> </template>
<script> <script>
@@ -38,7 +55,7 @@ export default {
}, },
methods: { methods: {
updateName(value, ack){ updateName(value, ack){
updateLibraryName.call({_id: this._id, name: value}, (error, result) =>{ updateLibraryName.call({_id: this._id, name: value}, (error) =>{
ack(error && error.reason || error); ack(error && error.reason || error);
}); });
}, },
@@ -53,7 +70,7 @@ export default {
}, },
callback(confirmation){ callback(confirmation){
if(!confirmation) return; if(!confirmation) return;
removeLibrary.call({_id: that._id}, (error, result) => { removeLibrary.call({_id: that._id}, (error) => {
if (error) { if (error) {
console.error(error); console.error(error);
} else { } else {
@@ -63,6 +80,18 @@ export default {
} }
}); });
}, },
share(){
this.$store.commit('pushDialogStack', {
component: 'share-dialog',
elementId: 'share-library-button',
data: {
docRef: {
id: this._id,
collection: 'libraries',
}
},
});
},
}, },
meteor: { meteor: {
model(){ model(){

View File

@@ -1,51 +1,70 @@
<template lang="html"> <template lang="html">
<dialog-base> <dialog-base>
<div slot="toolbar"> <div slot="toolbar">
Sharing Sharing
</div> </div>
<div v-if="model"> <div v-if="model">
<smart-select <smart-select
label="Who can view" label="Who can view"
:items="[ :items="[
{text: 'Only people I share with', value: 'false'}, {text: 'Only people I share with', value: 'false'},
{text: 'Anyone with link', value: 'true'} {text: 'Anyone with link', value: 'true'}
]" ]"
:value="!!model.public + ''" :value="!!model.public + ''"
@change="(value, ack) => setSheetPublic({value, ack})" @change="(value, ack) => setSheetPublic({value, ack})"
/> />
<div class="layout row"> <div class="layout row">
<text-field <text-field
label="Username or email" label="Username or email"
:value="userSearched" :value="userSearched"
@change="(value, ack) => getUser({value, ack})" :debounce-time="300"
:debounceTime="300" @change="(value, ack) => getUser({value, ack})"
/> />
<v-btn :disabled="userFoundState !== 'found'"> <v-btn :disabled="userFoundState !== 'found'">
Share Share
</v-btn> </v-btn>
</div> </div>
<div class="sharedWith"> <div class="sharedWith">
<h3 v-if="writers.length">Can Edit</h3> <h3 v-if="writers.length">
<div v-for="user in writers"> Can Edit
{{user}} </h3>
<v-btn flat icon> <div
<v-icon>delete</v-icon> v-for="user in writers"
</v-btn> :key="user._id"
</div> >
<h3 v-if="readers.length">Can View</h3> {{ user }}
<div v-for="user in readers"> <v-btn
{{user}} flat
<v-btn flat icon> icon
<v-icon>delete</v-icon> >
</v-btn> <v-icon>delete</v-icon>
</div> </v-btn>
</div> </div>
</div> <h3 v-if="readers.length">
<v-btn Can View
slot="actions" </h3>
flat <div
@click="$store.dispatch('popDialogStack')" v-for="user in readers"
>Done</v-btn> :key="user._id"
>
{{ user }}
<v-btn
flat
icon
>
<v-icon>delete</v-icon>
</v-btn>
</div>
</div>
</div>
<v-spacer slot="actions" />
<v-btn
slot="actions"
flat
@click="$store.dispatch('popDialogStack')"
>
Done
</v-btn>
</dialog-base> </dialog-base>
</template> </template>
@@ -58,20 +77,23 @@ export default {
components: { components: {
DialogBase, DialogBase,
}, },
props: {
docRef: {
type: Object,
required: true,
},
},
data(){ return { data(){ return {
userSearched: undefined, userSearched: undefined,
userFoundState: 'idle', userFoundState: 'idle',
userId: undefined, userId: undefined,
}}, }},
props: {
docRef: Object,
},
methods: { methods: {
setSheetPublic({value, ack}){ setSheetPublic({value, ack}){
setPublic.call({ setPublic.call({
docRef: this.docRef, docRef: this.docRef,
public: value === 'true', public: value === 'true',
}, (error, value) => { }, (error) => {
ack(error && error.reason || error); ack(error && error.reason || error);
}); });
}, },