Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
:includeItemTags="includeItemTags"
:canDragDrop="canDragDrop"
@selected="nodeSelected"
@clear-selected="clearSelection"
:selected="selected"
@checked="(item, check) => $emit('checked', item, check)"
@reload="$emit('reload')" />
Expand Down Expand Up @@ -78,7 +79,7 @@ export default {
includeItemTags: Boolean,
canDragDrop: Boolean
},
emits: ['reload', 'checked', 'selected'],
emits: ['reload', 'checked', 'selected', 'clear-selected'],
components: {
Draggable,
ModelTreeviewItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:icon-md="icon('md')"
:textColor="iconColor"
:color="(model.item.created !== false) ? 'blue' : 'orange'"
:selected="selected && selected.item.name === model.item.name ? true : null"
:selected="itemSelected"
:opened="model.opened"
:toggle="canHaveChildren"
@treeview:open="model.opened = true"
Expand Down Expand Up @@ -37,7 +37,8 @@
:parentNode="model"
:rootNode="rootNode"
@selected="(event) => $emit('selected', event)"
:selected="node.selected"
@clear-selected="clearSelection"
:selected="selected"
:includeItemName="includeItemName"
:includeItemTags="includeItemTags"
:canDragDrop="canDragDrop"
Expand Down Expand Up @@ -94,7 +95,7 @@ export default {
includeItemTags: Boolean,
canDragDrop: Boolean
},
emits: ['reload', 'selected', 'checked'],
emits: ['reload', 'selected', 'clear-selected', 'checked'],
components: {
Draggable,
ModelTreeviewItem: 'model-treeview-item'
Expand All @@ -118,6 +119,9 @@ export default {
? semantics.config.relatesTo : null
return this.model.class.substring(this.model.class.lastIndexOf('_') + 1) +
((property) ? ' (' + property.replace('Property_', '') + ')' : '')
},
itemSelected () {
return this.selected && this.selected.item.name === this.model.item.name ? true : null
}
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import ItemMixin from '@/components/item/item-mixin'
import TagMixin from '@/components/tags/tag-mixin'
import fastDeepEqual from 'fast-deep-equal/es6'

// TODO-V3.1 console.debug calls with cloneDeep - do we need to remove them?

export default {
mixins: [ItemMixin, TagMixin],
emits: ['clear-selected'],
watch: {
canSave (val) {
if (val) this.saveUpdate()
Expand Down Expand Up @@ -64,6 +63,7 @@ export default {
},
methods: {
onDragStart (event) {
this.$emit('clear-selected')
this.moveState.node = this.children[event.oldIndex]
if (!this.moveState.node.item.editable) return
console.time('Timer: Drag')
Expand Down Expand Up @@ -257,8 +257,6 @@ export default {
} else {
this.addIntoRoot(node, parentNode)
}
this.moveState.canAdd = false
this.moveState.adding = false
console.timeEnd('Timer: validateAdd')
},
isValidGroupType (node, parentNode) {
Expand Down Expand Up @@ -468,7 +466,6 @@ export default {
const nodeChildren = this.nodeChildren(node)
nodeChildren.filter((n) => !n.class).forEach((n) => this.addIntoLocation(n, node))
this.updateAfterAdd(node, parentNode, semantics)
this.saveUpdate()
console.timeEnd('Timer: addLocation')
},
addEquipment (node, parentNode) {
Expand All @@ -486,7 +483,6 @@ export default {
const nodeChildren = this.nodeChildren(node)
nodeChildren.filter((n) => !n.class).forEach((n) => this.addIntoEquipment(n, node))
this.updateAfterAdd(node, parentNode, semantics)
this.saveUpdate()
console.timeEnd('Timer: addEquipment')
},
addPoint (node, parentNode) {
Expand All @@ -502,7 +498,6 @@ export default {
if (!node.item.tags.includes(tag)) node.item.tags.push(tag)
node.class = semantics.value
this.updateAfterAdd(node, parentNode, semantics)
this.saveUpdate()
console.timeEnd('Timer: addPoint')
},
addNonSemantic (node, parentNode) {
Expand Down Expand Up @@ -541,6 +536,9 @@ export default {
if (updateRequired) {
this.moveState.nodesToUpdate.push(node)
}
this.moveState.canAdd = false
this.moveState.adding = false
if (!this.moveState.canRemove) this.moveState.dragFinished = true
console.debug('Add - finished, new moveState:', cloneDeep(this.moveState))
console.timeEnd('Timer: updateAfterAdd')
},
Expand Down Expand Up @@ -586,6 +584,7 @@ export default {
const groupNameIndex = node.item.groupNames.findIndex((g) => g === parentNode.item?.name)
if (groupNameIndex >= 0) {
node.item.groupNames.splice(groupNameIndex, 1)
this.moveState.nodesToUpdate.push(node)
}
const newChildren = this.nodeChildren(parentNode)
newChildren.splice(oldIndex, 1)
Expand All @@ -604,7 +603,7 @@ export default {
console.time('Timer: updateAfterRemove')
this.moveState.canRemove = false
this.moveState.removing = false
this.moveState.dragFinished = true
if (!this.moveState.canAdd) this.moveState.dragFinished = true
console.timeEnd('Timer: updateAfterRemove')
},
saveUpdate () {
Expand All @@ -626,11 +625,13 @@ export default {
saveModelUpdate () {
console.time('Timer: saveModelUpdate')
this.moveState.dragFinished = false
const promises = []
this.moveState.nodesToUpdate.forEach((n) => {
const updatedItem = n.item
console.debug('Save - updatedItem: ', cloneDeep(updatedItem))
this.saveItem(updatedItem)
promises.push(this.saveItem(updatedItem))
})
Promise.all(promises)
this.moveState.saving = false
console.timeEnd('Timer: saveModelUpdate')
console.timeEnd('Timer: Drag')
Expand Down Expand Up @@ -662,6 +663,9 @@ export default {
console.timeEnd('Timer: Drag')
this.moveState.cancelled = true
}
},
clearSelection () {
this.$emit('clear-selected')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ export default {

if (this.includeNonSemantic) {
this.rootGroups = this.items
.filter((i) => i.type === 'Group' && (!i.metadata || !i.metadata.semantics) && i.groupNames.length === 0)
.filter((i) => i.type === 'Group' && !i.metadata?.semantics && i.groupNames.length === 0)
.map(this.modelItem).sort(compareModelItems)
this.rootGroups.forEach(this.getChildren)
this.rootItems = this.items
.filter((i) => i.type !== 'Group' && (!i.metadata || !i.metadata.semantics) && i.groupNames.length === 0)
.filter((i) => i.type !== 'Group' && !i.metadata?.semantics && i.groupNames.length === 0)
.map(this.modelItem).sort(compareModelItems)
}

Expand Down Expand Up @@ -173,19 +173,16 @@ export default {
}

if (this.includeNonSemantic) {
parent.children.groups = this.items
.filter((i) => i.type === 'Group' && !(parent.item.metadata && parent.item.metadata.semantics) && i.groupNames.indexOf(parent.item.name) >= 0)
const nonSemanticItems = this.items
.filter((i) => !i.metadata?.semantics && i.groupNames.indexOf(parent.item.name) >= 0)
.map(this.modelItem).sort(compareModelItems)

// Only non-semantic groups in groups
parent.children.groups = nonSemanticItems.filter((i) => i.item.type === 'Group')
parent.children.groups.forEach(this.getChildren)
if (parent.item.metadata && parent.item.metadata.semantics) {
parent.children.items = this.items
.filter((i) => i.type !== 'Group' && (!i.metadata || (i.metadata && !i.metadata.semantics)) && i.groupNames.indexOf(parent.item.name) >= 0)
.map(this.modelItem).sort(compareModelItems)
} else {
parent.children.items = this.items
.filter((i) => i.type !== 'Group' && i.groupNames.indexOf(parent.item.name) >= 0)
.map(this.modelItem).sort(compareModelItems)
}

// Only non-semantic items in groups
parent.children.items = nonSemanticItems.filter((i) => i.item.type !== 'Group')
}
},
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
:includeItemTags="includeItemTags"
:canDragDrop="true"
@selected="selectItem"
@clear-selected="clearSelection"
:selected="selectedItem"
@reload="load"
@click.stop />
Expand Down Expand Up @@ -482,8 +483,9 @@ export default {
}
},
clearSelection (ev) {
if (ev.target && ev.currentTarget && ev.target === ev.currentTarget) {
if (!ev || (ev.target && ev.currentTarget && ev.target === ev.currentTarget)) {
this.selectedItem = null
this.previousSelection = null
this.detailsOpened = false
}
},
Expand Down