Merge branch 'version-2' of https://github.com/ThaumRystra/DiceCloud1 into version-2

This commit is contained in:
Stefan Zermatten
2020-10-19 11:39:24 +02:00
35 changed files with 348 additions and 133 deletions

View File

@@ -9,7 +9,7 @@ import { recomputeCreature } from '/imports/api/creature/computation/recomputeCr
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
import Creatures from '/imports/api/creature/Creatures.js';
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
import { softRemove } from '/imports/api/parenting/softRemove.js';
import { softRemove, restore } from '/imports/api/parenting/softRemove.js';
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
import propertySchemasIndex from '/imports/api/properties/computedPropertySchemasIndex.js';
import {
@@ -445,6 +445,23 @@ const softRemoveProperty = new ValidatedMethod({
}
});
const restoreProperty = new ValidatedMethod({
name: 'creatureProperties.restore',
validate: new SimpleSchema({
_id: SimpleSchema.RegEx.Id
}).validator(),
mixins: [RateLimiterMixin],
rateLimit: {
numRequests: 5,
timeInterval: 5000,
},
run({_id}){
let property = CreatureProperties.findOne(_id);
assertPropertyEditPermission(property, this.userId);
restore({_id, collection: CreatureProperties});
recomputeCreatures(property);
}
});
export default CreatureProperties;
export {
@@ -458,5 +475,6 @@ export {
selectAmmoItem,
pushToProperty,
pullFromProperty,
softRemoveProperty,
softRemoveProperty,
restoreProperty,
};

View File

@@ -41,16 +41,21 @@ const restoreError = function(){
};
export function restore({_id, collection}){
collection = getCollectionByName(collection);
if (typeof collection === 'string') {
collection = getCollectionByName(collection);
}
let numUpdated = collection.update({
_id,
removedWith: {$exists: false}
}, { $unset: {
removed: 1,
removedAt: 1,
}});
}}, {
selector: {type: 'any'},
},);
if (numUpdated === 0) restoreError();
updateDescendants({
collection,
ancestorId: _id,
filter: {
removedWith: _id,

View File

@@ -6,6 +6,10 @@ let ClassLevelSchema = new SimpleSchema({
type: String,
optional: true,
},
description: {
type: String,
optional: true,
},
// The name of this class level's variable
variableName: {
type: String,

View File

@@ -0,0 +1,48 @@
<template lang="html">
<v-snackbar
v-if="snackbar"
:key="snackbar.text"
auto-height
bottom
:value="true"
:timeout="0"
>
{{ snackbar.text }}
<v-btn
v-if="snackbar.callback"
class="primary--text"
flat
icon
@click="doCallback"
>
{{ snackbar.callbackName }}
</v-btn>
<v-btn
v-if="snackbar.showCloseButton"
flat
icon
@click="$store.dispatch('closeSnackbar')"
>
<v-icon>close</v-icon>
</v-btn>
</v-snackbar>
</template>
<script>
export default {
computed: {
snackbar(){
return this.$store.state.snackbars.snackbars[0];
}
},
methods: {
doCallback(){
this.snackbar.callback();
this.$store.dispatch('closeSnackbar')
}
}
}
</script>
<style lang="css" scoped>
</style>

View File

@@ -0,0 +1,47 @@
const snackbarStore = {
state: {
snackbars: [],
snackbarTimout: undefined,
},
mutations: {
addSnackbar(state, value){
state.snackbars.push(value)
},
closeCurrentSnackbar (state){
state.snackbars.shift();
},
cancelSnackbarTimeout (state){
if(state.snackbarTimout){
clearTimeout(state.snackbarTimout);
}
},
setSnackbarTimout(state, value){
state.snackbarTimout = value;
},
},
actions: {
snackbar({dispatch, commit}, value){
// value = {
// text,
// showCloseButton,
// callback,
// callbackName
// }
commit('addSnackbar', value);
commit('setSnackbarTimout', setTimeout(() => {
dispatch('closeSnackbar');
}, 5000));
},
closeSnackbar({dispatch, commit, state}){
commit('closeCurrentSnackbar');
commit('cancelSnackbarTimeout');
if (state.snackbars.length){
commit('setSnackbarTimout', setTimeout(() => {
dispatch('closeSnackbar');
}, 5000));
}
},
}
};
export default snackbarStore;

View File

@@ -93,9 +93,6 @@
required: true,
},
},
data(){return {
snackbars: [],
}},
reactiveProvide: {
name: 'context',
include: ['creature', 'editPermission'],
@@ -124,10 +121,9 @@
added(doc){
if (!that.$subReady.singleCharacter) return;
if (that.$store.state.rightDrawer) return;
if (that.snackbars.some(o => o._id === doc._id)) return;
doc.open = true;
that.$store.commit('snackbar', {
doc
that.$store.dispatch('snackbar', {
text: doc.text,
showCloseButton: true,
});
},
});

View File

@@ -66,6 +66,7 @@ import CreatureProperties, {
pushToProperty,
pullFromProperty,
softRemoveProperty,
restoreProperty,
} from '/imports/api/creature/CreatureProperties.js';
import Creatures from '/imports/api/creature/Creatures.js';
import PropertyToolbar from '/imports/ui/components/propertyToolbar.vue';
@@ -75,6 +76,7 @@ import PropertyIcon from '/imports/ui/properties/shared/PropertyIcon.vue';
import propertyFormIndex from '/imports/ui/properties/forms/shared/propertyFormIndex.js';
import propertyViewerIndex from '/imports/ui/properties/viewers/shared/propertyViewerIndex.js';
import CreaturePropertiesTree from '/imports/ui/creature/creatureProperties/CreaturePropertiesTree.vue';
import getPropertyTitle from '/imports/ui/properties/shared/getPropertyTitle.js';
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
import { get, findLast } from 'lodash';
@@ -174,12 +176,20 @@ export default {
});
},
remove(){
softRemoveProperty.call({_id: this._id});
const _id = this._id;
softRemoveProperty.call({_id});
if (this.embedded){
this.$emit('removed');
} else {
this.$store.dispatch('popDialogStack');
}
this.$store.dispatch('snackbar', {
text: `Deleted ${getPropertyTitle(this.model)}`,
callbackName: 'undo',
callback(){
restoreProperty.call({_id});
},
});
},
selectSubProperty(_id){
this.$store.commit('pushDialogStack', {

View File

@@ -19,7 +19,8 @@
style="max-width: 500px;"
hover
ripple
:class="{'primary theme--dark': node._id === (selectedNode && selectedNode._id)}"
:class="{'primary': node._id === (selectedNode && selectedNode._id)}"
:dark="node._id === (selectedNode && selectedNode._id)"
@click="selectedNode = node"
>
<v-img
@@ -31,14 +32,13 @@
<v-card-title primary-title>
<div>
<h3 class="title mb-0">
<property-icon
v-if="!node.picture"
<tree-node-view
class="mr-2"
:class="{'theme--dark': node._id === (selectedNode && selectedNode._id)}"
:hide-icon="node.picture"
:model="node"
:color="node.color"
/>
{{ getTitle(node) }}
</h3>
<div v-if="node.description">
{{ node.description }}
@@ -108,14 +108,14 @@ import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
import { getPropertyName } from '/imports/constants/PROPERTIES.js';
import { parse, CompilationContext } from '/imports/parser/parser.js';
import PROPERTIES from '/imports/constants/PROPERTIES.js';
import PropertyIcon from '/imports/ui/properties/shared/PropertyIcon.vue';
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
import TreeNodeView from '/imports/ui/properties/treeNodeViews/TreeNodeView.vue';
export default {
components: {
DialogBase,
ColumnLayout,
PropertyIcon,
TreeNodeView,
},
props:{
slotId: {

View File

@@ -12,26 +12,31 @@
{{ slot.totalFilled }} / {{ slot.quantityExpected }}
</span>
</h3>
<div
v-for="child in slot.children"
:key="child._id"
class="layout row"
:data-id="`slot-child-${child._id}`"
>
<tree-node-view
class="slotChild"
:model="child"
/>
<v-spacer />
<v-btn
icon
flat
small
@click="remove(child._id)"
<v-list v-if="slot.children.length">
<v-list-tile
v-for="child in slot.children"
:key="child._id"
:data-id="`slot-child-${child._id}`"
@click="clickSlotChild(child)"
>
<v-icon>delete</v-icon>
</v-btn>
</div>
<v-list-tile-content>
<tree-node-view
class="slotChild"
:model="child"
/>
</v-list-tile-content>
<v-list-tile-action>
<v-btn
icon
flat
small
@click.stop="remove(child)"
>
<v-icon>delete</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
</v-list>
<v-btn
v-if="!slot.quantityExpected || slot.quantityExpected > slot.totalFilled"
icon
@@ -48,8 +53,14 @@
<script>
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
import TreeNodeView from '/imports/ui/properties/treeNodeViews/TreeNodeView.vue';
import { softRemoveProperty, insertPropertyFromLibraryNode } from '/imports/api/creature/CreatureProperties.js';
import {
insertPropertyFromLibraryNode,
softRemoveProperty,
restoreProperty
} from '/imports/api/creature/CreatureProperties.js';
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
import getPropertyTitle from '/imports/ui/properties/shared/getPropertyTitle.js';
export default {
components: {
TreeNodeView,
@@ -64,6 +75,13 @@ export default {
},
},
methods: {
clickSlotChild({_id}){
this.$store.commit('pushDialogStack', {
component: 'creature-property-dialog',
elementId: `slot-child-${_id}`,
data: {_id},
});
},
fillSlot(slot){
let slotId = slot._id;
let creatureId = this.creatureId;
@@ -90,8 +108,15 @@ export default {
}
});
},
remove(_id){
softRemoveProperty.call({_id});
remove(model){
softRemoveProperty.call({_id: model._id});
this.$store.dispatch('snackbar', {
text: `Deleted ${getPropertyTitle(model)}`,
callbackName: 'undo',
callback(){
restoreProperty.call({_id: model._id});
},
});
}
},
meteor: {
@@ -126,7 +151,4 @@ export default {
</script>
<style lang="css" scoped>
div {
background-color: inherit;
}
</style>

View File

@@ -67,31 +67,7 @@
name="rightDrawer"
/>
<dialog-stack />
<v-snackbar
v-for="snackbar in snackbars"
:key="snackbar._id"
:value="snackbar.open"
auto-height
bottom
>
{{ snackbar.text.split(/\n+/).pop() }}
<v-btn
v-if="snackbar.callback"
flat
icon
@click="snackbar.callback"
>
<v-icon>{{ snackbar.callbackName }}</v-icon>
</v-btn>
<v-btn
v-if="snackbar.showCloseButton"
flat
icon
@click="snackbar.open = false"
>
<v-icon>close</v-icon>
</v-btn>
</v-snackbar>
<snackbars />
</v-app>
</template>
@@ -101,11 +77,13 @@
import DialogStack from '/imports/ui/dialogStack/DialogStack.vue';
import { theme, darkTheme } from '/imports/ui/theme.js';
import { mapMutations } from 'vuex';
import Snackbars from '/imports/ui/components/snackbars/Snackbars.vue';
export default {
components: {
Sidebar,
DialogStack,
Snackbars,
},
data(){return {
name: 'Home',

View File

@@ -29,6 +29,14 @@
:menu-props="{auto: true, lazy: true}"
@change="change('target', ...arguments)"
/>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -65,6 +65,14 @@
name="Advanced"
standalone
>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
<div class="layout column align-center">
<smart-switch
v-if="model.attributeType !== 'hitDice'"

View File

@@ -31,6 +31,14 @@
:menu-props="{auto: true, lazy: true}"
@change="change('target', ...arguments)"
/>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -27,6 +27,13 @@
@change="change('variableName', ...arguments)"
/>
</div>
<text-area
label="Description"
hint="A brief description of what this class level gives a character"
:value="model.description"
:error-messages="errors.description"
@change="change('description', ...arguments)"
/>
<text-field
label="Condition"
hint="A caclulation to determine if this can be added to the character"

View File

@@ -55,6 +55,14 @@
name="Advanced"
standalone
>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
<div class="layout row justify-center">
<div>
<smart-switch

View File

@@ -28,6 +28,16 @@
:menu-props="{auto: true, lazy: true}"
@change="change('target', ...arguments)"
/>
<smart-combobox
label="Tags"
class="mr-2"
multiple
chips
deletable-chips
:value="model.tags"
:error-messages="errors.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -28,6 +28,14 @@
@change="change('value', ...arguments)"
/>
</div>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -79,12 +79,6 @@
name="Advanced"
standalone
>
<smart-switch
label="Show increment button"
:value="model.showIncrement"
:error-messages="errors.showIncrement"
@change="change('showIncrement', ...arguments)"
/>
<smart-combobox
label="Tags"
class="mr-2"
@@ -95,6 +89,12 @@
:error-messages="errors.tags"
@change="change('tags', ...arguments)"
/>
<smart-switch
label="Show increment button"
:value="model.showIncrement"
:error-messages="errors.showIncrement"
@change="change('showIncrement', ...arguments)"
/>
<smart-switch
label="Requires attunement"
:value="model.requiresAttunement"

View File

@@ -13,6 +13,14 @@
:error-messages="errors.description"
@change="change('description', ...arguments)"
/>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -27,6 +27,14 @@
@change="change('value', ...arguments)"
/>
</div>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -21,6 +21,16 @@
:error-messages="errors.stat"
@change="change('stat', ...arguments)"
/>
<smart-combobox
label="Tags"
class="mr-2"
multiple
chips
deletable-chips
:value="model.tags"
:error-messages="errors.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -44,6 +44,14 @@
name="Advanced"
standalone
>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
<div class="layout row justify-center">
<text-field
label="Base Value"

View File

@@ -15,6 +15,12 @@
:error-messages="errors.name"
@change="change('name', ...arguments)"
/>
<text-area
label="Description"
:value="model.description"
:error-messages="errors.description"
@change="change('description', ...arguments)"
/>
<text-field
label="Picture URL"
hint="A link to an image representing this property"
@@ -31,15 +37,6 @@
:error-messages="errors.slotFillerType"
@change="change('slotFillerType', ...arguments)"
/>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
:error-messages="errors.tags"
@change="change('tags', ...arguments)"
/>
<text-field
label="Quantity"
type="number"
@@ -57,25 +54,23 @@
:error-messages="errors.slotFillerCondition"
@change="change('slotFillerCondition', ...arguments)"
/>
<calculation-error-list :errors="model.slotConditionErrors" />
<text-area
label="Description"
:value="model.description"
:error-messages="errors.description"
@change="change('description', ...arguments)"
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
:error-messages="errors.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>
<script>
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
import PROPERTIES from '/imports/constants/PROPERTIES.js';
export default {
components: {
CalculationErrorList,
},
mixins: [propertyFormMixin],
data(){
let slotTypes = [];

View File

@@ -17,7 +17,7 @@
@change="change('slotType', ...arguments)"
/>
<smart-combobox
label="Tags"
label="Tags Required"
hint="The slot must be filled with a property which has all the listed tags"
multiple
chips
@@ -54,6 +54,14 @@
name="Advanced"
standalone
>
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
<div class="layout row wrap justify-space-between">
<smart-switch
label="Ignored"

View File

@@ -31,6 +31,14 @@
@change="change('maxPrepared', ...arguments)"
/>
<calculation-error-list :errors="model.maxPreparedErrors" />
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -39,6 +39,14 @@
/>
</v-fade-transition>
<calculation-error-list :errors="model.errors" />
<smart-combobox
label="Tags"
multiple
chips
deletable-chips
:value="model.tags"
@change="change('tags', ...arguments)"
/>
</div>
</template>

View File

@@ -0,0 +1,6 @@
import { getPropertyName } from '/imports/constants/PROPERTIES.js';
export default function getPropertyTitle(prop){
if (prop.name) return prop.name;
return getPropertyName(prop.type);
}

View File

@@ -1,6 +1,7 @@
<template lang="html">
<div class="layout row align-center justify-start">
<property-icon
v-if="!hideIcon"
class="mr-2"
:model="model"
:class="selected && 'primary--text'"

View File

@@ -1,6 +1,7 @@
<template lang="html">
<div class="layout row align-center justify-start">
<property-icon
v-if="!hideIcon"
class="mr-2"
:model="model"
:color="model.color"

View File

@@ -1,6 +1,7 @@
<template lang="html">
<div class="layout row align-center justify-start">
<v-icon
v-if="!hideIcon"
class="mr-2"
:color="model.color"
:class="selected && 'primary--text'"

View File

@@ -1,6 +1,7 @@
<template lang="html">
<div class="layout row align-center justify-start">
<property-icon
v-if="!hideIcon"
class="mr-2"
:model="model"
:color="model.color"

View File

@@ -1,6 +1,7 @@
<template lang="html">
<div class="layout row align-center justify-start">
<v-icon
v-if="!hideIcon"
class="mr-2"
:class="selected && 'primary--text'"
:color="model.color"

View File

@@ -1,13 +1,14 @@
<template lang="html">
<div class="layout row align-center justify-start">
<property-icon
v-if="!hideIcon"
class="mr-2"
:model="model"
:color="model.color"
:class="selected && 'primary--text'"
/>
<v-icon
v-if="model.equipped"
v-if="model.equipped && !hideIcon"
class="mr-2"
:class="selected && 'primary--text'"
small

View File

@@ -11,6 +11,7 @@ export default {
default: () => ({}),
},
selected: Boolean,
hideIcon: Boolean,
},
computed: {
title(){

View File

@@ -1,19 +1,19 @@
import Vue from 'vue';
import Vuex from 'vuex';
import dialogStackStore from '/imports/ui/dialogStack/dialogStackStore.js';
import snackbarStore from '/imports/ui/components/snackbars/snackboxStore.js';
Vue.use(Vuex);
const store = new Vuex.Store({
strict: process.env.NODE_ENV !== 'production',
modules: {
dialogStack: dialogStackStore,
snackbars: snackbarStore,
},
state: {
drawer: undefined,
rightDrawer: undefined,
pageTitle: undefined,
snackbars: [],
snackbarTimout: undefined,
},
mutations: {
toggleDrawer (state) {
@@ -32,43 +32,7 @@ const store = new Vuex.Store({
state.pageTitle = value;
document.title = value;
},
addSnackbar(state, value){
value.open = true;
state.snackbars.push(value)
},
closeCurrentSnackbar (state){
state.snackbars.shift();
},
cancelSnackbarTimeout (state){
if(state.snackbarTimout){
clearTimeout(state.snackbarTimout);
}
},
setSnackbarTimout(state, value){
state.snackbarTimout = value;
},
},
actions: {
snackbar({commit}, value){
// value = {
// text,
// showCloseButton,
// callback,
// callbackName
// }
commit('addSnackbar', value);
},
closeSnackbar({dispatch, commit, state}){
commit('closeCurrentSnackbar');
commit('cancelSnackbarTimeout');
if (state.snackbars.length){
commit('setSnackbarTimout');
state.snackbarTimout = setTimeout(() => {
dispatch('closeSnackbar');
}, 5000);
}
},
}
});
export default store;