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">
<dialog-base>
<template slot="toolbar">
<div>
{{model && model.name}}
</div>
<v-spacer/>
<v-btn flat icon @click="remove">
<v-icon>delete</v-icon>
</v-btn>
</template>
<template v-if="model">
<text-field label="name" :value="model.name" @change="updateName"/>
</template>
<template slot="actions">
<v-spacer/>
<v-btn
flat
@click="$store.dispatch('popDialogStack')"
data-id="delete-library-button"
>
Done
</v-btn>
</template>
</dialog-base>
<dialog-base>
<template slot="toolbar">
<div>
{{ model && model.name }}
</div>
<v-spacer />
<v-btn
flat
icon
data-id="share-library-button"
@click="share"
>
<v-icon>share</v-icon>
</v-btn>
<v-btn
flat
icon
data-id="delete-library-button"
@click="remove"
>
<v-icon>delete</v-icon>
</v-btn>
</template>
<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>
<script>
@@ -38,7 +55,7 @@ export default {
},
methods: {
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);
});
},
@@ -53,7 +70,7 @@ export default {
},
callback(confirmation){
if(!confirmation) return;
removeLibrary.call({_id: that._id}, (error, result) => {
removeLibrary.call({_id: that._id}, (error) => {
if (error) {
console.error(error);
} 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: {
model(){

View File

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