Made owner of sheets and libraries more visible
This commit is contained in:
@@ -2,18 +2,21 @@
|
||||
<div class="creature-form">
|
||||
<text-field
|
||||
label="Name"
|
||||
:disabled="!editPermission"
|
||||
:value="model.name"
|
||||
:error-messages="errors.name"
|
||||
@change="(value, ack) => $emit('change', {path: ['name'], value, ack})"
|
||||
/>
|
||||
<text-field
|
||||
label="Alignment"
|
||||
:disabled="!editPermission"
|
||||
:value="model.alignment"
|
||||
:error-messages="errors.alignment"
|
||||
@change="(value, ack) => $emit('change', {path: ['alignment'], value, ack})"
|
||||
/>
|
||||
<text-field
|
||||
label="Gender"
|
||||
:disabled="!editPermission"
|
||||
:value="model.gender"
|
||||
:error-messages="errors.gender"
|
||||
@change="(value, ack) => $emit('change', {path: ['gender'], value, ack})"
|
||||
@@ -21,6 +24,7 @@
|
||||
<text-field
|
||||
label="Picture URL"
|
||||
hint="A link to a high resolution image"
|
||||
:disabled="!editPermission"
|
||||
:value="model.picture"
|
||||
:error-messages="errors.picture"
|
||||
@change="(value, ack) => $emit('change', {path: ['picture'], value, ack})"
|
||||
@@ -28,6 +32,7 @@
|
||||
<text-field
|
||||
label="Avatar picture URL"
|
||||
hint="A link to a smaller, square image to use as an avatar"
|
||||
:disabled="!editPermission"
|
||||
:value="model.avatarPicture"
|
||||
:error-messages="errors.avatarPicture"
|
||||
@change="(value, ack) => $emit('change', {path: ['avatarPicture'], value, ack})"
|
||||
@@ -36,21 +41,25 @@
|
||||
<form-section name="Settings">
|
||||
<v-switch
|
||||
label="Hide redundant stats"
|
||||
:disabled="!editPermission"
|
||||
:input-value="model.settings.hideUnusedStats"
|
||||
@change="value => $emit('change', {path: ['settings','hideUnusedStats'], value: !!value})"
|
||||
/>
|
||||
<v-switch
|
||||
label="Hide rest buttons"
|
||||
:disabled="!editPermission"
|
||||
:input-value="model.settings.hideRestButtons"
|
||||
@change="value => $emit('change', {path: ['settings','hideRestButtons'], value: !!value})"
|
||||
/>
|
||||
<v-switch
|
||||
label="Show spells tab"
|
||||
:disabled="!editPermission"
|
||||
:input-value="!model.settings.hideSpellsTab"
|
||||
@change="changeHideSpellsTab"
|
||||
/>
|
||||
<v-switch
|
||||
label="Show tree tab"
|
||||
:disabled="!editPermission"
|
||||
:input-value="model.settings.showTreeTab"
|
||||
@change="changeShowTreeTab"
|
||||
/>
|
||||
@@ -62,6 +71,7 @@
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.1"
|
||||
:disabled="!editPermission"
|
||||
:value="model.settings.hitDiceResetMultiplier"
|
||||
@change="(value, ack) => $emit('change', {path: ['settings','hitDiceResetMultiplier'], value, ack})"
|
||||
/>
|
||||
@@ -69,6 +79,7 @@
|
||||
label="Discord Webhook URL"
|
||||
hint="This creature's logs will be posted to the discord channel"
|
||||
placeholder="https://discordapp.com/api/webhooks/<id>/<token>"
|
||||
:disabled="!editPermission"
|
||||
:value="model.settings.discordWebhook"
|
||||
@change="(value, ack) => $emit('change', {path: ['settings','discordWebhook'], value, ack})"
|
||||
/>
|
||||
@@ -96,12 +107,13 @@
|
||||
<form-section name="Libraries">
|
||||
<smart-switch
|
||||
label="All user libraries"
|
||||
:disabled="!editPermission"
|
||||
:value="allUserLibraries"
|
||||
@change="allUserLibrariesChange"
|
||||
/>
|
||||
<library-list
|
||||
selection
|
||||
:disabled="!model.allowedLibraries && !model.allowedLibraryCollections"
|
||||
:disabled="!editPermission || (!model.allowedLibraries && !model.allowedLibraryCollections)"
|
||||
:libraries-selected="model.allowedLibraries"
|
||||
:library-collections-selected="model.allowedLibraryCollections"
|
||||
:libraries-selected-by-collections="librariesSelectedByCollections"
|
||||
@@ -142,6 +154,7 @@ import FormSection, { FormSections } from '/imports/client/ui/properties/forms/s
|
||||
import LibraryList from '/imports/client/ui/library/LibraryList.vue';
|
||||
import LibraryCollections from '/imports/api/library/LibraryCollections.js';
|
||||
import { changeAllowedLibraries, toggleAllUserLibraries } from '/imports/api/creature/creatures/methods/changeAllowedLibraries.js';
|
||||
import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -227,6 +240,14 @@ export default {
|
||||
});
|
||||
return ids;
|
||||
},
|
||||
editPermission() {
|
||||
try {
|
||||
assertEditPermission(this.model, Meteor.userId());
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
changeShowTreeTab(value) {
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
bottom
|
||||
left
|
||||
transition="slide-y-transition"
|
||||
data-id="creature-menu"
|
||||
>
|
||||
<template #activator="{ on }">
|
||||
<v-btn
|
||||
data-id="creature-menu"
|
||||
icon
|
||||
v-on="on"
|
||||
>
|
||||
@@ -40,6 +40,35 @@
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-list>
|
||||
<v-list-item
|
||||
v-if="!isOwner && ownerName"
|
||||
two-line
|
||||
disabled
|
||||
>
|
||||
<v-list-item-avatar>
|
||||
<v-icon>
|
||||
mdi-account
|
||||
</v-icon>
|
||||
</v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>
|
||||
{{ ownerName }}
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle>
|
||||
Sheet owner
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
<v-list-item
|
||||
v-if="!isOwner"
|
||||
@click="unshareWithMe"
|
||||
>
|
||||
<v-list-item-title>
|
||||
<v-icon left>
|
||||
mdi-cancel
|
||||
</v-icon> Unshare with me
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
<v-list-item :to="printUrl">
|
||||
<v-list-item-title>
|
||||
<v-icon left>
|
||||
@@ -47,37 +76,31 @@
|
||||
</v-icon> Print
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
<template v-if="editPermission">
|
||||
<v-list-item @click="deleteCharacter">
|
||||
<v-list-item-title>
|
||||
<v-icon left>
|
||||
mdi-delete
|
||||
</v-icon> Delete
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
<v-list-item @click="showCharacterForm">
|
||||
<v-list-item-title>
|
||||
<v-icon left>
|
||||
mdi-pencil
|
||||
</v-icon> Edit details
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
<v-list-item @click="showShareDialog">
|
||||
<v-list-item-title>
|
||||
<v-icon left>
|
||||
mdi-share-variant
|
||||
</v-icon> Sharing
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
</template>
|
||||
<v-list-item @click="showCharacterForm">
|
||||
<v-list-item-title>
|
||||
<v-icon left>
|
||||
mdi-pencil
|
||||
</v-icon> Edit details
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
<v-list-item
|
||||
v-else
|
||||
@click="unshareWithMe"
|
||||
:disabled="!isOwner"
|
||||
@click="showShareDialog"
|
||||
>
|
||||
<v-list-item-title>
|
||||
<v-icon left>
|
||||
mdi-share-variant
|
||||
</v-icon> Sharing
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
<v-list-item
|
||||
:disabled="!isOwner"
|
||||
@click="deleteCharacter"
|
||||
>
|
||||
<v-list-item-title>
|
||||
<v-icon left>
|
||||
mdi-delete
|
||||
</v-icon> Unshare with me
|
||||
</v-icon> Delete
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
@@ -266,6 +289,15 @@ export default {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
isOwner() {
|
||||
if (!this.creature) return;
|
||||
return Meteor.userId() === this.creature.owner;
|
||||
},
|
||||
ownerName() {
|
||||
if (!this.creature) return;
|
||||
const username = Meteor.users.findOne(this.creature.owner)?.username;
|
||||
return username;
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<v-btn
|
||||
icon
|
||||
data-id="share-library-button"
|
||||
:disabled="!isOwner"
|
||||
@click="share"
|
||||
>
|
||||
<v-icon>mdi-share-variant</v-icon>
|
||||
@@ -15,12 +16,32 @@
|
||||
<v-btn
|
||||
icon
|
||||
data-id="delete-library-button"
|
||||
:disabled="!isOwner"
|
||||
@click="remove"
|
||||
>
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<template v-if="model">
|
||||
<v-list-item
|
||||
v-if="!isOwner"
|
||||
class="px-0"
|
||||
two-line
|
||||
>
|
||||
<v-list-item-avatar>
|
||||
<v-icon>
|
||||
mdi-account
|
||||
</v-icon>
|
||||
</v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>
|
||||
{{ ownerName || '?' }}
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle>
|
||||
Collection owner
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
<text-field
|
||||
label="name"
|
||||
:value="model.name"
|
||||
@@ -33,6 +54,7 @@
|
||||
/>
|
||||
<smart-switch
|
||||
:value="model.showInMarket"
|
||||
:disabled="!isOwner"
|
||||
label="Show in community library browser"
|
||||
@change="(showInMarket, ack) => updateLibraryCollection({showInMarket}, ack)"
|
||||
/>
|
||||
@@ -121,6 +143,9 @@ export default {
|
||||
meteor: {
|
||||
'$subscribe': {
|
||||
libraries: [],
|
||||
libraryCollection() {
|
||||
return [this._id]
|
||||
},
|
||||
},
|
||||
model() {
|
||||
return LibraryCollections.findOne(this._id);
|
||||
@@ -144,6 +169,15 @@ export default {
|
||||
};
|
||||
});
|
||||
},
|
||||
isOwner() {
|
||||
if (!this.model) return;
|
||||
return Meteor.userId() === this.model.owner;
|
||||
},
|
||||
ownerName() {
|
||||
if (!this.model) return;
|
||||
const username = Meteor.users.findOne(this.model.owner)?.username;
|
||||
return username;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<v-btn
|
||||
icon
|
||||
data-id="share-library-button"
|
||||
:disabled="!isOwner"
|
||||
@click="share"
|
||||
>
|
||||
<v-icon>mdi-share-variant</v-icon>
|
||||
@@ -15,12 +16,32 @@
|
||||
<v-btn
|
||||
icon
|
||||
data-id="delete-library-button"
|
||||
:disabled="!isOwner"
|
||||
@click="remove"
|
||||
>
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<template v-if="model">
|
||||
<v-list-item
|
||||
v-if="!isOwner && ownerName"
|
||||
class="px-0"
|
||||
two-line
|
||||
>
|
||||
<v-list-item-avatar>
|
||||
<v-icon>
|
||||
mdi-account
|
||||
</v-icon>
|
||||
</v-list-item-avatar>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>
|
||||
{{ ownerName }}
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle>
|
||||
Library owner
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
<text-field
|
||||
label="name"
|
||||
:value="model.name"
|
||||
@@ -33,6 +54,7 @@
|
||||
/>
|
||||
<smart-switch
|
||||
:value="model.showInMarket"
|
||||
:disabled="!isOwner"
|
||||
label="Show in community library browser"
|
||||
@change="updateShowInMarket"
|
||||
/>
|
||||
@@ -170,7 +192,16 @@ export default {
|
||||
}, {
|
||||
sort: { order: 1 },
|
||||
});
|
||||
}
|
||||
},
|
||||
isOwner() {
|
||||
if (!this.model) return;
|
||||
return Meteor.userId() === this.model.owner;
|
||||
},
|
||||
ownerName() {
|
||||
if (!this.model) return;
|
||||
const username = Meteor.users.findOne(this.model.owner)?.username;
|
||||
return username;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -82,7 +82,14 @@ Meteor.publish('libraryCollection', function (libraryCollectionId) {
|
||||
}, {
|
||||
sort: { name: 1 }
|
||||
});
|
||||
return [libraryCollectionCursor, libraryCursor];
|
||||
return [
|
||||
libraryCollectionCursor,
|
||||
libraryCursor,
|
||||
Meteor.users.find(
|
||||
libraryCollection.owner,
|
||||
{ fields: { username: 1 } }
|
||||
),
|
||||
];
|
||||
});
|
||||
});
|
||||
})
|
||||
@@ -148,13 +155,21 @@ Meteor.publish('browseLibraries', function () {
|
||||
showInMarket: true,
|
||||
public: true,
|
||||
}, {
|
||||
sort: { name: 1 }
|
||||
sort: {
|
||||
subscriberCount: 1,
|
||||
name: 1,
|
||||
},
|
||||
limit: 500,
|
||||
}),
|
||||
LibraryCollections.find({
|
||||
showInMarket: true,
|
||||
public: true,
|
||||
}, {
|
||||
sort: { name: 1 }
|
||||
sort: {
|
||||
subscriberCount: 1,
|
||||
name: 1
|
||||
},
|
||||
limit: 500,
|
||||
}),
|
||||
];
|
||||
});
|
||||
@@ -169,9 +184,15 @@ Meteor.publish('library', function (libraryId) {
|
||||
catch (e) {
|
||||
return this.error(e);
|
||||
}
|
||||
return Libraries.find({
|
||||
_id: libraryId,
|
||||
});
|
||||
return [
|
||||
Libraries.find({
|
||||
_id: libraryId,
|
||||
}),
|
||||
Meteor.users.find(
|
||||
library.owner,
|
||||
{ fields: { username: 1 } }
|
||||
),
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ Meteor.publish('singleCharacter', function (creatureId) {
|
||||
const self = this;
|
||||
try {
|
||||
schema.validate({ creatureId });
|
||||
} catch (e){
|
||||
} catch (e) {
|
||||
this.error(e);
|
||||
}
|
||||
this.autorun(function (computation){
|
||||
this.autorun(function (computation) {
|
||||
let userId = this.userId;
|
||||
let permissionCreature = Creatures.findOne({
|
||||
_id: creatureId,
|
||||
@@ -32,11 +32,11 @@ Meteor.publish('singleCharacter', function (creatureId) {
|
||||
try { assertViewPermission(permissionCreature, userId) }
|
||||
catch (e) { return [] }
|
||||
loadCreature(creatureId, self);
|
||||
if (permissionCreature.computeVersion !== VERSION && computation.firstRun){
|
||||
if (permissionCreature.computeVersion !== VERSION && computation.firstRun) {
|
||||
try {
|
||||
computeCreature(creatureId)
|
||||
}
|
||||
catch(e){ console.error(e) }
|
||||
catch (e) { console.error(e) }
|
||||
}
|
||||
return [
|
||||
Creatures.find({
|
||||
@@ -52,7 +52,13 @@ Meteor.publish('singleCharacter', function (creatureId) {
|
||||
creatureId,
|
||||
}, {
|
||||
limit: 20,
|
||||
sort: {date: -1},
|
||||
sort: { date: -1 },
|
||||
}),
|
||||
// Also publish the owner's username
|
||||
Meteor.users.find(permissionCreature.owner, {
|
||||
fields: {
|
||||
username: 1,
|
||||
},
|
||||
}),
|
||||
];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user