Fixed property trees in detail dialogs not showing any props
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: "game-icons";
|
font-family: "game-icons";
|
||||||
src: url("/fonts/game-icons.eot?817af6e52c83163eb30ece54d9f7d16d?#iefix") format("embedded-opentype"),
|
src: url("/fonts/game-icons.eot?817af6e52c83163eb30ece54d9f7d16d?#iefix") format("embedded-opentype"),
|
||||||
url("/fonts/game-icons.woff?817af6e52c83163eb30ece54d9f7d16d") format("woff"),
|
url("/fonts/game-icons.woff?817af6e52c83163eb30ece54d9f7d16d") format("woff"),
|
||||||
url("/fonts/game-icons.ttf?817af6e52c83163eb30ece54d9f7d16d") format("truetype");
|
url("/fonts/game-icons.ttf?817af6e52c83163eb30ece54d9f7d16d") format("truetype");
|
||||||
}
|
}
|
||||||
|
|
||||||
.game-icon {
|
.game-icon {
|
||||||
|
|||||||
@@ -93,16 +93,16 @@ type FilteredDoc = {
|
|||||||
export function filterToForest(
|
export function filterToForest(
|
||||||
collection: Mongo.Collection<TreeDoc>,
|
collection: Mongo.Collection<TreeDoc>,
|
||||||
rootId: string,
|
rootId: string,
|
||||||
filter?: Mongo.Query<TreeDoc>,
|
filter?: Mongo.Selector<TreeDoc>,
|
||||||
{
|
{
|
||||||
options = <Mongo.Options<object>>{},
|
options = <Mongo.Options<TreeDoc>>{},
|
||||||
includeFilteredDocAncestors = false,
|
includeFilteredDocAncestors = false,
|
||||||
includeFilteredDocDescendants = false
|
includeFilteredDocDescendants = false
|
||||||
} = {}
|
} = {}
|
||||||
): TreeNode<FilteredDoc>[] {
|
): TreeNode<FilteredDoc>[] {
|
||||||
if (!Meteor.isClient) throw 'Only available on the client';
|
if (!Meteor.isClient) throw 'Only available on the client';
|
||||||
// Setup the filter
|
// Setup the filter
|
||||||
let collectionFilter: Mongo.Query<TreeDoc> = {
|
let collectionFilter: Mongo.Selector<TreeDoc> = {
|
||||||
'root.id': rootId,
|
'root.id': rootId,
|
||||||
'removed': { $ne: true },
|
'removed': { $ne: true },
|
||||||
};
|
};
|
||||||
@@ -113,16 +113,17 @@ export function filterToForest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set up the options
|
// Set up the options
|
||||||
let collectionSort = {
|
let collectionSort: Mongo.Options<TreeDoc>['sort'] = {
|
||||||
left: 1
|
left: 1
|
||||||
};
|
};
|
||||||
if (options && options.sort) {
|
if (options.sort) {
|
||||||
collectionSort = {
|
collectionSort = {
|
||||||
...collectionSort,
|
...collectionSort,
|
||||||
|
// @ts-expect-error go home typescript you're drunk
|
||||||
...options.sort,
|
...options.sort,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let collectionOptions: Mongo.Options<object> = {
|
let collectionOptions: Mongo.Options<TreeDoc> = {
|
||||||
sort: collectionSort,
|
sort: collectionSort,
|
||||||
}
|
}
|
||||||
if (options) {
|
if (options) {
|
||||||
@@ -671,8 +672,8 @@ export function setDocToLastOrder(collection: Mongo.Collection<TreeDoc>, doc: Tr
|
|||||||
doc.left = Number.MAX_SAFE_INTEGER;
|
doc.left = Number.MAX_SAFE_INTEGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function rebuildNestedSets(collection: Mongo.Collection<TreeDoc>, rootId: string) {
|
export function rebuildNestedSets(collection: Mongo.Collection<TreeDoc>, rootId: string) {
|
||||||
const docs = await collection.find({
|
const docs = collection.find({
|
||||||
'root.id': rootId,
|
'root.id': rootId,
|
||||||
removed: { $ne: true }
|
removed: { $ne: true }
|
||||||
}, {
|
}, {
|
||||||
@@ -681,13 +682,13 @@ export async function rebuildNestedSets(collection: Mongo.Collection<TreeDoc>, r
|
|||||||
//Reverse sorting so that arrays can be used as stacks with the first item on top
|
//Reverse sorting so that arrays can be used as stacks with the first item on top
|
||||||
left: 1,
|
left: 1,
|
||||||
},
|
},
|
||||||
}).fetchAsync();
|
}).fetch();
|
||||||
|
|
||||||
const operations = calculateNestedSetOperations(docs);
|
const operations = calculateNestedSetOperations(docs);
|
||||||
return writeBulkOperations(collection, operations);
|
return writeBulkOperations(collection, operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function rebuildCreatureNestedSets(creatureId) {
|
export function rebuildCreatureNestedSets(creatureId) {
|
||||||
const docs = getProperties(creatureId);
|
const docs = getProperties(creatureId);
|
||||||
const operations = calculateNestedSetOperations(docs);
|
const operations = calculateNestedSetOperations(docs);
|
||||||
return writeBulkOperations(CreatureProperties as Mongo.Collection<TreeDoc, TreeDoc>, operations);
|
return writeBulkOperations(CreatureProperties as Mongo.Collection<TreeDoc, TreeDoc>, operations);
|
||||||
@@ -823,8 +824,9 @@ export function applyNestedSetProperties<T extends TreeDoc>(docs: T[]): Forest<T
|
|||||||
* @param operations An array of bulk operations to write
|
* @param operations An array of bulk operations to write
|
||||||
* @returns Promise<undefined>
|
* @returns Promise<undefined>
|
||||||
*/
|
*/
|
||||||
async function writeBulkOperations(collection: Mongo.Collection<TreeDoc>, operations) {
|
function writeBulkOperations(collection: Mongo.Collection<TreeDoc>, operations) {
|
||||||
if (Meteor.isServer && operations.length) {
|
if (Meteor.isServer) {
|
||||||
|
if (!operations.length) return Promise.resolve();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
collection.rawCollection().bulkWrite(
|
collection.rawCollection().bulkWrite(
|
||||||
operations,
|
operations,
|
||||||
@@ -841,20 +843,19 @@ async function writeBulkOperations(collection: Mongo.Collection<TreeDoc>, operat
|
|||||||
} else {
|
} else {
|
||||||
// Don't do latency compensation if there are too many operations, it just causes client
|
// Don't do latency compensation if there are too many operations, it just causes client
|
||||||
// lag without much benefit
|
// lag without much benefit
|
||||||
const promises = operations.map(op => {
|
operations.forEach(op => {
|
||||||
if (op.updateOne) {
|
if (op.updateOne) {
|
||||||
return collection.updateAsync(
|
collection.update(
|
||||||
op.updateOne.filter,
|
op.updateOne.filter,
|
||||||
op.updateOne.update,
|
op.updateOne.update,
|
||||||
);
|
);
|
||||||
} else if (op.updateMany) {
|
} else if (op.updateMany) {
|
||||||
return collection.updateAsync(
|
collection.update(
|
||||||
op.updateMany.filter,
|
op.updateMany.filter,
|
||||||
op.updateMany.update,
|
op.updateMany.update,
|
||||||
{ multi: true },
|
{ multi: true },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Promise.all(promises);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<tree-node-list
|
||||||
|
v-if="model"
|
||||||
|
:children="children"
|
||||||
|
:group="group"
|
||||||
|
:organize="organize"
|
||||||
|
:start-expanded="expanded"
|
||||||
|
:root="model.root"
|
||||||
|
@selected="e => $emit('selected', e)"
|
||||||
|
@move-within-root="moveWithinRoot"
|
||||||
|
@move-between-roots="moveBetweenRoots"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import { docsToForest, getFilter } from '/imports/api/parenting/parentingFunctions';
|
||||||
|
import TreeNodeList from '/imports/client/ui/components/tree/TreeNodeList.vue';
|
||||||
|
import { moveBetweenRoots, moveWithinRoot } from '/imports/api/parenting/organizeMethods';
|
||||||
|
import { getCollectionByName } from '/imports/api/parenting/parentingFunctions';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
TreeNodeList,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
// The document for which we are finding children
|
||||||
|
model: {
|
||||||
|
type: Object,
|
||||||
|
default: undefined,
|
||||||
|
},
|
||||||
|
organize: Boolean,
|
||||||
|
group: {
|
||||||
|
type: String,
|
||||||
|
default: 'creatureProperties'
|
||||||
|
},
|
||||||
|
collection: {
|
||||||
|
type: String,
|
||||||
|
default: 'creatureProperties'
|
||||||
|
},
|
||||||
|
expanded: Boolean,
|
||||||
|
},
|
||||||
|
meteor: {
|
||||||
|
children() {
|
||||||
|
const collection = getCollectionByName(this.collection);
|
||||||
|
const docs = collection.find({
|
||||||
|
removed: { $ne: true },
|
||||||
|
...getFilter.descendants(this.model),
|
||||||
|
}, {
|
||||||
|
sort: { left: 1 }
|
||||||
|
}).fetch();
|
||||||
|
this.$emit('length', docs.length);
|
||||||
|
|
||||||
|
return docsToForest(docs);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
moveWithinRoot({ doc, newPosition }) {
|
||||||
|
moveWithinRoot.callAsync({
|
||||||
|
docRef: {
|
||||||
|
id: doc._id,
|
||||||
|
collection: this.collection,
|
||||||
|
},
|
||||||
|
newPosition,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
moveBetweenRoots({ doc, newPosition, newRootRef }) {
|
||||||
|
moveBetweenRoots.callAsync({
|
||||||
|
docRef: {
|
||||||
|
id: doc._id,
|
||||||
|
collection: this.collection,
|
||||||
|
},
|
||||||
|
newPosition,
|
||||||
|
newRootRef,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -167,10 +167,11 @@
|
|||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
class="pa-2 no-hover"
|
class="pa-2 no-hover"
|
||||||
>
|
>
|
||||||
<creature-properties-tree
|
<descendant-properties-tree
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
organize
|
organize
|
||||||
:root="{collection, id: model._id}"
|
:model="model"
|
||||||
|
:root="model.root"
|
||||||
:collection="collection"
|
:collection="collection"
|
||||||
@selected="e => $emit('select-sub-property', e)"
|
@selected="e => $emit('select-sub-property', e)"
|
||||||
/>
|
/>
|
||||||
@@ -225,7 +226,7 @@ import InlineComputationField from '/imports/client/ui/properties/forms/shared/I
|
|||||||
import FormSection, { FormSections } from '/imports/client/ui/properties/forms/shared/FormSection.vue';
|
import FormSection, { FormSections } from '/imports/client/ui/properties/forms/shared/FormSection.vue';
|
||||||
import propertyFormIndex from '/imports/client/ui/properties/forms/shared/propertyFormIndex';
|
import propertyFormIndex from '/imports/client/ui/properties/forms/shared/propertyFormIndex';
|
||||||
import IconColorMenu from '/imports/client/ui/properties/forms/shared/IconColorMenu.vue';
|
import IconColorMenu from '/imports/client/ui/properties/forms/shared/IconColorMenu.vue';
|
||||||
import CreaturePropertiesTree from '/imports/client/ui/creature/creatureProperties/CreaturePropertiesTree.vue';
|
import DescendantPropertiesTree from '/imports/client/ui/creature/creatureProperties/DescendantPropertiesTree.vue';
|
||||||
import OutlinedInput from '/imports/client/ui/properties/viewers/shared/OutlinedInput.vue';
|
import OutlinedInput from '/imports/client/ui/properties/viewers/shared/OutlinedInput.vue';
|
||||||
import { getSuggestedChildren } from '/imports/constants/PROPERTIES';
|
import { getSuggestedChildren } from '/imports/constants/PROPERTIES';
|
||||||
import PROPERTIES from '/imports/constants/PROPERTIES';
|
import PROPERTIES from '/imports/constants/PROPERTIES';
|
||||||
@@ -243,7 +244,7 @@ export default {
|
|||||||
FormSection,
|
FormSection,
|
||||||
FormSections,
|
FormSections,
|
||||||
IconColorMenu,
|
IconColorMenu,
|
||||||
CreaturePropertiesTree,
|
DescendantPropertiesTree,
|
||||||
OutlinedInput,
|
OutlinedInput,
|
||||||
...propertyFormIndex,
|
...propertyFormIndex,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -134,9 +134,9 @@
|
|||||||
name="Child properties"
|
name="Child properties"
|
||||||
:cols="{cols: 12}"
|
:cols="{cols: 12}"
|
||||||
>
|
>
|
||||||
<creature-properties-tree
|
<descendant-properties-tree
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
:root="{collection, id: model._id}"
|
:model="model"
|
||||||
:collection="collection"
|
:collection="collection"
|
||||||
@length="childrenLength = $event"
|
@length="childrenLength = $event"
|
||||||
@selected="selectSubProperty"
|
@selected="selectSubProperty"
|
||||||
@@ -155,14 +155,14 @@ import CreaturePropertiesTree from '/imports/client/ui/creature/creatureProperti
|
|||||||
import PropertyField from '/imports/client/ui/properties/viewers/shared/PropertyField.vue';
|
import PropertyField from '/imports/client/ui/properties/viewers/shared/PropertyField.vue';
|
||||||
import { getPropertyName } from '/imports/constants/PROPERTIES';
|
import { getPropertyName } from '/imports/constants/PROPERTIES';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||||
import TreeNodeView from '/imports/client/ui/properties/treeNodeViews/TreeNodeView.vue';
|
import DescendantPropertiesTree from '/imports/client/ui/creature/creatureProperties/DescendantPropertiesTree.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
...propertyViewerIndex,
|
...propertyViewerIndex,
|
||||||
CreaturePropertiesTree,
|
CreaturePropertiesTree,
|
||||||
PropertyField,
|
PropertyField,
|
||||||
TreeNodeView,
|
DescendantPropertiesTree,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
model: {
|
model: {
|
||||||
|
|||||||
Reference in New Issue
Block a user