Fixed library node insert button
This commit is contained in:
@@ -13,9 +13,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="js">
|
<script lang="js">
|
||||||
import { getAncestry } from '/imports/api/parenting/parenting.js';
|
import { insertNode } from '/imports/api/library/LibraryNodes.js';
|
||||||
import { setDocToLastOrder } from '/imports/api/parenting/order.js';
|
|
||||||
import LibraryNodes, { insertNode } from '/imports/api/library/LibraryNodes.js';
|
|
||||||
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -45,48 +43,29 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get ancestry reference
|
// Get ancestry reference
|
||||||
let order, parentRef;
|
const parentRef = {
|
||||||
let selectedComponent = document.querySelector(
|
id: libraryId,
|
||||||
`[data-id="tree-node-${this.selectedNodeId}"]`
|
collection: 'libraries',
|
||||||
);
|
};
|
||||||
if (selectedComponent){
|
|
||||||
let vueInstance = selectedComponent.__vue__.$parent;
|
|
||||||
if (vueInstance.showExpanded){
|
|
||||||
parentRef = {
|
|
||||||
id: this.selectedNodeId,
|
|
||||||
collection: 'libraryNodes',
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
parentRef = vueInstance.node.parent;
|
|
||||||
order = vueInstance.node.order + 0.5;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
parentRef = {
|
|
||||||
id: libraryId,
|
|
||||||
collection: 'libraries',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
let {ancestors} = getAncestry({parentRef});
|
|
||||||
|
|
||||||
// Insert form dialog
|
// Insert form dialog
|
||||||
let that = this;
|
const that = this;
|
||||||
this.$store.commit('pushDialogStack', {
|
this.$store.commit('pushDialogStack', {
|
||||||
component: 'library-node-creation-dialog',
|
component: 'insert-property-dialog',
|
||||||
elementId: 'insert-library-node-button',
|
elementId: 'insert-library-node-button',
|
||||||
|
data: {
|
||||||
|
hideLibraryTab: true,
|
||||||
|
noBackdropClose: true,
|
||||||
|
showLibraryOnlyProps: true,
|
||||||
|
},
|
||||||
callback(libraryNode){
|
callback(libraryNode){
|
||||||
if (!libraryNode) return;
|
if (!libraryNode) return;
|
||||||
|
|
||||||
// Set ancestry and order
|
// Set order to first
|
||||||
libraryNode.parent = parentRef;
|
libraryNode.order = -1;
|
||||||
libraryNode.ancestors = ancestors;
|
|
||||||
if (order){
|
|
||||||
libraryNode.order = order;
|
|
||||||
} else {
|
|
||||||
setDocToLastOrder({collection: LibraryNodes, doc: libraryNode});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert doc
|
// Insert doc
|
||||||
let libraryNodeId = insertNode.call(libraryNode);
|
let libraryNodeId = insertNode.call({ libraryNode, parentRef });
|
||||||
that.$emit('selected', libraryNodeId);
|
that.$emit('selected', libraryNodeId);
|
||||||
return `tree-node-${libraryNodeId}`;
|
return `tree-node-${libraryNodeId}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -329,7 +329,8 @@ export default {
|
|||||||
this.tab = 1;
|
this.tab = 1;
|
||||||
this.schema = propertySchemasIndex[type];
|
this.schema = propertySchemasIndex[type];
|
||||||
this.validationContext = this.schema.newContext();
|
this.validationContext = this.schema.newContext();
|
||||||
let model = this.schema.clean(this.model || {});
|
let model = this.model || {};
|
||||||
|
model = this.schema.clean(model);
|
||||||
model.type = type;
|
model.type = type;
|
||||||
this.model = model;
|
this.model = model;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
suggestedChildren() {
|
suggestedChildren() {
|
||||||
if (!this.model?.type) return;
|
if (!this.model?.type) return [];
|
||||||
return getSuggestedChildren(this.model.type);
|
return getSuggestedChildren(this.model.type);
|
||||||
},
|
},
|
||||||
schemaHasName() {
|
schemaHasName() {
|
||||||
|
|||||||
Reference in New Issue
Block a user