began implementing sharing dialog
This commit is contained in:
@@ -9,7 +9,8 @@ let SharingSchema = new SimpleSchema({
|
|||||||
readers: {
|
readers: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
index: 1
|
index: 1,
|
||||||
|
max: 50,
|
||||||
},
|
},
|
||||||
"readers.$": {
|
"readers.$": {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -18,7 +19,8 @@ let SharingSchema = new SimpleSchema({
|
|||||||
writers: {
|
writers: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
index: 1
|
index: 1,
|
||||||
|
max: 20,
|
||||||
},
|
},
|
||||||
"writers.$": {
|
"writers.$": {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ const userSchema = new SimpleSchema({
|
|||||||
username: {
|
username: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: 30,
|
||||||
|
min: 4,
|
||||||
},
|
},
|
||||||
emails: {
|
emails: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -103,7 +105,7 @@ Meteor.users.sendVerificationEmail = new ValidatedMethod({
|
|||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
run(userId, address){
|
run({userId, address}){
|
||||||
userId = this.userId || userId;
|
userId = this.userId || userId;
|
||||||
let user = Meteor.users.findOne(userId);
|
let user = Meteor.users.findOne(userId);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@@ -123,3 +125,17 @@ Meteor.users.isAdmin = function(userId){
|
|||||||
let user = Meteor.users.findOne(userId);
|
let user = Meteor.users.findOne(userId);
|
||||||
return user && user.roles.includes('admin');
|
return user && user.roles.includes('admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Meteor.users.findUserByUsernameOrEmail = new ValidatedMethod({
|
||||||
|
name: 'Users.methods.findUserByUsernameOrEmail',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
usernameOrEmail:{
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
}).validator(),
|
||||||
|
run({usernameOrEmail}){
|
||||||
|
let user = Accounts.findUserByUsername(username) ||
|
||||||
|
Accounts.findUserByEmail(email);
|
||||||
|
return user && user._id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ Meteor.publish("user", function(){
|
|||||||
}});
|
}});
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.publish("userNames", function(ids){
|
Meteor.publish("userPublicProfiles", function(ids){
|
||||||
if (!this.userId || !ids) return [];
|
if (!this.userId || !ids) return [];
|
||||||
return Meteor.users.find(
|
return Meteor.users.find({
|
||||||
{_id: {$in: ids}},
|
_id: {$in: ids}
|
||||||
{fields: {username: 1}}
|
},{
|
||||||
);
|
fields: {username: 1},
|
||||||
|
sort: {username: 1},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
100
app/imports/ui/sharing/ShareDialog.vue
Normal file
100
app/imports/ui/sharing/ShareDialog.vue
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<dialog-base>
|
||||||
|
<div slot="toolbar">
|
||||||
|
Sharing {{name}}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<smart-select
|
||||||
|
label="Who can view"
|
||||||
|
:items="[
|
||||||
|
{text: 'Only people I share with', value: false},
|
||||||
|
{text: 'Anyone with link', value: true}
|
||||||
|
]"
|
||||||
|
:value="model.public"
|
||||||
|
:error-messages="errors.public"
|
||||||
|
@change="(value, ack) => setSheetPublic({value, ack}))"
|
||||||
|
/>
|
||||||
|
<div class="layout row">
|
||||||
|
<text-field
|
||||||
|
label="Username or email"
|
||||||
|
@change="(value, ack) => getUser({value, ack})"
|
||||||
|
:debounceTime="300"
|
||||||
|
/>
|
||||||
|
<v-btn :disabled="userFoundState !== found">
|
||||||
|
Share
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
<div class="sharedWith">
|
||||||
|
<h3>Can Edit</h3>
|
||||||
|
<div v-for="userId in model.writers">
|
||||||
|
{{username(userId)}}
|
||||||
|
<v-btn flat icon>
|
||||||
|
<v-icon>delete</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
<h3>Can View</h3>
|
||||||
|
<div v-for="userId in model.readers">
|
||||||
|
{{username(userId)}}
|
||||||
|
<v-btn flat icon>
|
||||||
|
<v-icon>delete</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dialog-base>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
||||||
|
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
DialogBase,
|
||||||
|
},
|
||||||
|
data(){
|
||||||
|
userFoundState: 'idle',
|
||||||
|
userId: undefined,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
ref: Object,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getUser({value, ack}){
|
||||||
|
Meteor.users.findUserByUsernameOrEmail.call({
|
||||||
|
usernameOrEmail: value
|
||||||
|
}, (error, result) => {
|
||||||
|
if (error) {
|
||||||
|
ack(error && error.reason || error);
|
||||||
|
this.userFoundState = 'failed';
|
||||||
|
} else {
|
||||||
|
this.userId = result;
|
||||||
|
if (result){
|
||||||
|
this.userFoundState = 'found';
|
||||||
|
ack();
|
||||||
|
} else {
|
||||||
|
this.userFoundState = 'notFound';
|
||||||
|
ack('User not found');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
meteor: {
|
||||||
|
model: {
|
||||||
|
return fetchDocByRef(this.ref);
|
||||||
|
},
|
||||||
|
username(userId){
|
||||||
|
let user = Meteor.users.findOne(userId);
|
||||||
|
return user && user.username;
|
||||||
|
},
|
||||||
|
$subscribe: {
|
||||||
|
'userPublicProfiles'(){
|
||||||
|
return [...this.model.writers, ...this.model.readers];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user