Added color picking to library properties

This commit is contained in:
Thaum Rystra
2020-05-25 19:09:55 +02:00
parent 2859bf0e00
commit dfb144b8dc
11 changed files with 20 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo'; import { Mongo } from 'meteor/mongo';
import { ValidatedMethod } from 'meteor/mdg:validated-method'; import { ValidatedMethod } from 'meteor/mdg:validated-method';
import SimpleSchema from 'simpl-schema'; import SimpleSchema from 'simpl-schema';
import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
import ChildSchema, { RefSchema } from '/imports/api/parenting/ChildSchema.js'; import ChildSchema, { RefSchema } from '/imports/api/parenting/ChildSchema.js';
import { recomputeCreature } from '/imports/api/creature/computation/recomputeCreature.js'; import { recomputeCreature } from '/imports/api/creature/computation/recomputeCreature.js';
import LibraryNodes from '/imports/api/library/LibraryNodes.js'; import LibraryNodes from '/imports/api/library/LibraryNodes.js';
@@ -41,6 +42,7 @@ for (let key in propertySchemasIndex){
let schema = new SimpleSchema({}); let schema = new SimpleSchema({});
schema.extend(propertySchemasIndex[key]); schema.extend(propertySchemasIndex[key]);
schema.extend(CreaturePropertySchema); schema.extend(CreaturePropertySchema);
schema.extend(ColorSchema);
schema.extend(ChildSchema); schema.extend(ChildSchema);
schema.extend(SoftRemovableSchema); schema.extend(SoftRemovableSchema);
CreatureProperties.attachSchema(schema, { CreatureProperties.attachSchema(schema, {

View File

@@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo'; import { Mongo } from 'meteor/mongo';
import { ValidatedMethod } from 'meteor/mdg:validated-method'; import { ValidatedMethod } from 'meteor/mdg:validated-method';
import SimpleSchema from 'simpl-schema'; import SimpleSchema from 'simpl-schema';
import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
import ChildSchema from '/imports/api/parenting/ChildSchema.js'; import ChildSchema from '/imports/api/parenting/ChildSchema.js';
import propertySchemasIndex from '/imports/api/properties/propertySchemasIndex.js'; import propertySchemasIndex from '/imports/api/properties/propertySchemasIndex.js';
import Libraries from '/imports/api/library/Libraries.js'; import Libraries from '/imports/api/library/Libraries.js';
@@ -28,6 +29,7 @@ let LibraryNodeSchema = new SimpleSchema({
for (let key in propertySchemasIndex){ for (let key in propertySchemasIndex){
let schema = new SimpleSchema({}); let schema = new SimpleSchema({});
schema.extend(LibraryNodeSchema); schema.extend(LibraryNodeSchema);
schema.extend(ColorSchema);
schema.extend(propertySchemasIndex[key]); schema.extend(propertySchemasIndex[key]);
schema.extend(ChildSchema); schema.extend(ChildSchema);
schema.extend(SoftRemovableSchema); schema.extend(SoftRemovableSchema);

View File

@@ -133,7 +133,7 @@ export function reorderDocs({collection, ancestorId}){
}); });
} }
}); });
if (Meteor.isServer){ if (Meteor.isServer && bulkWrite.length){
collection.rawCollection().bulkWrite( collection.rawCollection().bulkWrite(
bulkWrite, bulkWrite,
{ordered : false}, {ordered : false},

View File

@@ -27,7 +27,7 @@
> >
<v-scroll-y-transition> <v-scroll-y-transition>
<v-icon <v-icon
v-if="colorOption === color" v-if="kebabColor === colorOption"
:class="{dark: isDark(colorOption, shade)}" :class="{dark: isDark(colorOption, shade)}"
> >
check check
@@ -49,13 +49,13 @@
<div <div
v-for="shadeOption in shades" v-for="shadeOption in shades"
:key="shadeOption" :key="shadeOption"
:class="[color, shadeOption]" :class="[kebabColor, shadeOption]"
class="shade-swatch d-flex align-center" class="shade-swatch d-flex align-center"
@click="shade = shadeOption" @click="shade = shadeOption"
> >
<v-scroll-y-transition> <v-scroll-y-transition>
<v-icon <v-icon
v-if="shade === shadeOption" v-if="kebabShade === shadeOption"
:class="{dark: isDark(color, shade)}" :class="{dark: isDark(color, shade)}"
> >
check check
@@ -104,9 +104,9 @@
// Create an index of hex colors and what color/shade combination makes them // Create an index of hex colors and what color/shade combination makes them
let colorIndex = {}; let colorIndex = {};
for (let color in vuetifyColors){ for (let color in vuetifyColors){
color = camelToKebabCase(color); color = kebabToCamelCase(color);
for (let shade in vuetifyColors[color]){ for (let shade in vuetifyColors[color]){
shade = camelToKebabCase(shade); shade = kebabToCamelCase(shade);
colorIndex[vuetifyColors[color][shade]] = {color, shade}; colorIndex[vuetifyColors[color][shade]] = {color, shade};
} }
} }
@@ -167,7 +167,6 @@
return this.combination && this.combination.color; return this.combination && this.combination.color;
}, },
set(newColor){ set(newColor){
console.log(newColor, colorToHex(newColor, this.shade));
this.$emit('input', colorToHex(newColor, this.shade)); this.$emit('input', colorToHex(newColor, this.shade));
}, },
}, },
@@ -176,7 +175,6 @@
return this.combination && this.combination.shade; return this.combination && this.combination.shade;
}, },
set(newShade){ set(newShade){
console.log(newShade, colorToHex(this.color, newShade));
this.$emit('input', colorToHex(this.color, newShade)); this.$emit('input', colorToHex(this.color, newShade));
}, },
}, },

View File

@@ -21,7 +21,7 @@
> >
<v-spacer /> <v-spacer />
<color-picker <color-picker
v-if="false" v-if="$listeners && $listeners['color-changed']"
:value="model.color" :value="model.color"
@input="colorChanged" @input="colorChanged"
/> />

View File

@@ -1,5 +1,7 @@
<template lang="html"> <template lang="html">
<v-icon>{{icon}}</v-icon> <v-icon :color="color">
{{ icon }}
</v-icon>
</template> </template>
<script> <script>
@@ -8,6 +10,7 @@ import { getPropertyIcon } from '/imports/constants/PROPERTIES.js';
export default { export default {
props: { props: {
type: String, type: String,
color: String,
}, },
computed: { computed: {
icon(){ icon(){

View File

@@ -4,6 +4,7 @@
class="mr-2" class="mr-2"
:type="model.type" :type="model.type"
:class="selected && 'primary--text'" :class="selected && 'primary--text'"
:color="model.color"
/> />
<div <div
class="text-no-wrap text-truncate" class="text-no-wrap text-truncate"

View File

@@ -4,6 +4,7 @@
class="mr-2" class="mr-2"
:type="model.type" :type="model.type"
:class="selected && 'primary--text'" :class="selected && 'primary--text'"
:color="model.color"
/> />
<div <div
class="text-no-wrap text-truncate" class="text-no-wrap text-truncate"

View File

@@ -3,6 +3,7 @@
<property-icon <property-icon
class="mr-2" class="mr-2"
:type="model.type" :type="model.type"
:color="model.color"
:class="selected && 'primary--text'" :class="selected && 'primary--text'"
/> />
<div class="text-no-wrap text-truncate"> <div class="text-no-wrap text-truncate">

View File

@@ -3,6 +3,7 @@
<v-icon <v-icon
class="mr-2" class="mr-2"
:class="selected && 'primary--text'" :class="selected && 'primary--text'"
:color="model.color"
> >
{{ effectIcon }} {{ effectIcon }}
</v-icon> </v-icon>

View File

@@ -3,6 +3,7 @@
<v-icon <v-icon
class="mr-2" class="mr-2"
:class="selected && 'primary--text'" :class="selected && 'primary--text'"
:color="model.color"
> >
{{ model.equipped ? 'check_box' : 'check_box_outline_blank' }} {{ model.equipped ? 'check_box' : 'check_box_outline_blank' }}
</v-icon> </v-icon>