diff --git a/app/imports/api/sharing/SharingSchema.js b/app/imports/api/sharing/SharingSchema.js index 02b1e58e..8078cf02 100644 --- a/app/imports/api/sharing/SharingSchema.js +++ b/app/imports/api/sharing/SharingSchema.js @@ -1,4 +1,5 @@ import SimpleSchema from 'simpl-schema'; +import '/imports/api/sharing/sharing.js'; let SharingSchema = new SimpleSchema({ owner: { @@ -28,7 +29,7 @@ let SharingSchema = new SimpleSchema({ }, public: { type: Boolean, - optional: true, + defaultValue: false, index: 1, }, }); diff --git a/app/imports/api/sharing/sharing.js b/app/imports/api/sharing/sharing.js new file mode 100644 index 00000000..d48bfd23 --- /dev/null +++ b/app/imports/api/sharing/sharing.js @@ -0,0 +1,20 @@ +import SimpleSchema from 'simpl-schema'; +import { assertOwnership } from '/imports/api/sharing/sharingPermissions.js'; +import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js'; +import getCollectionByName from '/imports/api/parenting/getCollectionByName.js'; +import { RefSchema } from '/imports/api/parenting/ChildSchema.js'; + +const setPublic = new ValidatedMethod({ + name: 'sharing.methods.setPublic', + validate: new SimpleSchema({ + docRef: RefSchema, + public: { type: Boolean }, + }).validator(), + run({docRef, public}){ + let doc = fetchDocByRef(docRef); + assertOwnership(doc, this.userId); + getCollectionByName(docRef.collection).update(docRef.id, {$set: {public}}); + }, +}); + +export { setPublic }; diff --git a/app/imports/api/users/Users.js b/app/imports/api/users/Users.js index 10192cc1..730669a6 100644 --- a/app/imports/api/users/Users.js +++ b/app/imports/api/users/Users.js @@ -134,8 +134,9 @@ Meteor.users.findUserByUsernameOrEmail = new ValidatedMethod({ }, }).validator(), run({usernameOrEmail}){ - let user = Accounts.findUserByUsername(username) || - Accounts.findUserByEmail(email); + if (Meteor.isClient) return; + let user = Accounts.findUserByUsername(usernameOrEmail) || + Accounts.findUserByEmail(usernameOrEmail); return user && user._id; } }); diff --git a/app/imports/ui/components/global/SmartInputMixin.js b/app/imports/ui/components/global/SmartInputMixin.js index 9fbb21fd..f483361c 100644 --- a/app/imports/ui/components/global/SmartInputMixin.js +++ b/app/imports/ui/components/global/SmartInputMixin.js @@ -71,7 +71,14 @@ export default { this.loading = false; this.dirty = false; this.error = !!error; - this.ackErrors = error || null; + if (!error){ + this.ackErrors = null; + } else if (typeof error === 'string'){ + this.ackErrors = error; + } else { + this.ackErrors = 'Something went wrong' + console.error(error); + } }, change(val){ this.dirty = true; diff --git a/app/imports/ui/creature/character/CharacterSheet.vue b/app/imports/ui/creature/character/CharacterSheet.vue index 88740513..66dfcef2 100644 --- a/app/imports/ui/creature/character/CharacterSheet.vue +++ b/app/imports/ui/creature/character/CharacterSheet.vue @@ -9,9 +9,30 @@ {{character.name}} - - more - + + + + + + delete Delete + + + + + create Edit details + + + + + share Sharing + + + +
- Sharing {{name}} + Sharing
-
+
- + Share
-

Can Edit

-
- {{username(userId)}} +

Can Edit

+
+ {{user}} delete
-

Can View

-
- {{username(userId)}} +

Can View

+
+ {{user}} delete @@ -45,21 +45,38 @@