From 5578dca6e9bab84fd5aae398dcf43cf2714cffce Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Mon, 2 Mar 2020 16:31:57 +0200 Subject: [PATCH] began implementing sharing dialog --- app/imports/api/sharing/SharingSchema.js | 6 +- app/imports/api/users/Users.js | 18 +++- app/imports/server/publications/users.js | 12 +-- app/imports/ui/sharing/ShareDialog.vue | 100 +++++++++++++++++++++++ 4 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 app/imports/ui/sharing/ShareDialog.vue diff --git a/app/imports/api/sharing/SharingSchema.js b/app/imports/api/sharing/SharingSchema.js index 3098ead6..02b1e58e 100644 --- a/app/imports/api/sharing/SharingSchema.js +++ b/app/imports/api/sharing/SharingSchema.js @@ -9,7 +9,8 @@ let SharingSchema = new SimpleSchema({ readers: { type: Array, defaultValue: [], - index: 1 + index: 1, + max: 50, }, "readers.$": { type: String, @@ -18,7 +19,8 @@ let SharingSchema = new SimpleSchema({ writers: { type: Array, defaultValue: [], - index: 1 + index: 1, + max: 20, }, "writers.$": { type: String, diff --git a/app/imports/api/users/Users.js b/app/imports/api/users/Users.js index 158f2181..10192cc1 100644 --- a/app/imports/api/users/Users.js +++ b/app/imports/api/users/Users.js @@ -4,6 +4,8 @@ const userSchema = new SimpleSchema({ username: { type: String, optional: true, + max: 30, + min: 4, }, emails: { type: Array, @@ -103,7 +105,7 @@ Meteor.users.sendVerificationEmail = new ValidatedMethod({ type: String, }, }).validator(), - run(userId, address){ + run({userId, address}){ userId = this.userId || userId; let user = Meteor.users.findOne(userId); if (!user) { @@ -123,3 +125,17 @@ Meteor.users.isAdmin = function(userId){ let user = Meteor.users.findOne(userId); 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; + } +}); diff --git a/app/imports/server/publications/users.js b/app/imports/server/publications/users.js index 603483f0..5ac7d962 100644 --- a/app/imports/server/publications/users.js +++ b/app/imports/server/publications/users.js @@ -9,10 +9,12 @@ Meteor.publish("user", function(){ }}); }); -Meteor.publish("userNames", function(ids){ +Meteor.publish("userPublicProfiles", function(ids){ if (!this.userId || !ids) return []; - return Meteor.users.find( - {_id: {$in: ids}}, - {fields: {username: 1}} - ); + return Meteor.users.find({ + _id: {$in: ids} + },{ + fields: {username: 1}, + sort: {username: 1}, + }); }); diff --git a/app/imports/ui/sharing/ShareDialog.vue b/app/imports/ui/sharing/ShareDialog.vue new file mode 100644 index 00000000..8ee08574 --- /dev/null +++ b/app/imports/ui/sharing/ShareDialog.vue @@ -0,0 +1,100 @@ + + + + +