Progress aligning and improving node/prop forms

This commit is contained in:
Stefan Zermatten
2023-04-20 15:37:12 +02:00
parent a58ccc0e0e
commit 9e4bbe0d1b
7 changed files with 329 additions and 261 deletions

View File

@@ -68,8 +68,7 @@
<v-card-text
v-if="!$slots['unwrapped-content']"
>
<component
:is="type"
<property-form
v-if="type"
class="creature-property-form"
:model="model"
@@ -191,12 +190,12 @@ import PROPERTIES, { getPropertyName } from '/imports/constants/PROPERTIES.js';
import TreeNodeView from '/imports/client/ui/properties/treeNodeViews/TreeNodeView.vue';
import LibraryNodeExpansionContent from '/imports/client/ui/library/LibraryNodeExpansionContent.vue';
import schemaFormMixin from '/imports/client/ui/properties/forms/shared/schemaFormMixin.js';
import propertyFormIndex from '/imports/client/ui/properties/forms/shared/propertyFormIndex.js';
import propertySchemasIndex from '/imports/api/properties/propertySchemasIndex.js';
import Libraries from '/imports/api/library/Libraries.js';
import getThemeColor from '/imports/client/ui/utility/getThemeColor.js';
import PropertySelector from '/imports/client/ui/properties/shared/PropertySelector.vue';
import {snackbar} from '/imports/client/ui/components/snackbars/SnackbarQueue.js';
import PropertyForm from '/imports/client/ui/properties/PropertyForm.vue';
export default {
components: {
@@ -204,7 +203,7 @@ export default {
DialogBase,
TreeNodeView,
LibraryNodeExpansionContent,
...propertyFormIndex,
PropertyForm,
},
mixins: [schemaFormMixin],
props: {

View File

@@ -13,10 +13,10 @@
</template>
<script lang="js">
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import nodesToTree from '/imports/api/parenting/nodesToTree.js'
import TreeNodeList from '/imports/client/ui/components/tree/TreeNodeList.vue';
import { organizeDoc, reorderDoc } from '/imports/api/parenting/organizeMethods.js';
import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
export default {
components: {
@@ -40,12 +40,16 @@ export default {
type: String,
default: 'creatureProperties'
},
collection: {
type: String,
default: 'creatureProperties'
},
expanded: Boolean,
},
meteor: {
children() {
const children = nodesToTree({
collection: CreatureProperties,
collection: getCollectionByName(this.collection),
ancestorId: this.root.id,
filter: this.filter,
includeFilteredDocAncestors: true,
@@ -60,7 +64,7 @@ export default {
reorderDoc.call({
docRef: {
id: doc._id,
collection: 'creatureProperties',
collection: this.collection,
},
order: newIndex,
});
@@ -70,7 +74,7 @@ export default {
if (parent) {
parentRef = {
id: parent._id,
collection: 'creatureProperties',
collection: this.collection,
};
} else {
parentRef = this.root;
@@ -78,7 +82,7 @@ export default {
organizeDoc.call({
docRef: {
id: doc._id,
collection: 'creatureProperties',
collection: this.collection,
},
parentRef,
order: newIndex,

View File

@@ -40,6 +40,7 @@
@push="push"
@pull="pull"
@add-child="addProperty"
@select-sub-property="selectSubProperty"
/>
</div>
<div v-else>
@@ -244,7 +245,11 @@ export default {
},
});
},
selectSubProperty(_id){
selectSubProperty(_id) {
if (this.embedded) {
this.$emit('select-sub-property', _id);
return;
}
this.$store.commit('pushDialogStack', {
component: 'creature-property-dialog',
elementId: `tree-node-${_id}`,
@@ -254,14 +259,15 @@ export default {
},
});
},
addProperty(){
addProperty({elementId, suggestedType}){
let parentPropertyId = this.model._id;
this.$store.commit('pushDialogStack', {
component: 'add-creature-property-dialog',
elementId: 'insert-creature-property-btn',
elementId,
data: {
parentDoc: this.model,
creatureId: this.creatureId,
suggestedType,
},
callback(result){
if (!result) return;