From b68f79f427e8d7d4016a1c07fbaac8027ad9bf1e Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Wed, 3 Mar 2021 09:50:48 -0800 Subject: [PATCH] [Elements Pool][Flexible Layout] Improvements (#3694) * fix flexible-layout bug * abstract element item from elements pool * improve dragging of elements pool * better dragover handling in elements pool Co-authored-by: Deep Tailor Co-authored-by: Shefali Joshi --- .../components/flexibleLayout.vue | 8 +- src/ui/inspector/ElementItem.vue | 96 +++++++++++++++++++ .../{Elements.vue => ElementsPool.vue} | 52 ++++------ src/ui/inspector/Inspector.vue | 6 +- src/ui/inspector/elements.scss | 13 ++- 5 files changed, 129 insertions(+), 46 deletions(-) create mode 100644 src/ui/inspector/ElementItem.vue rename src/ui/inspector/{Elements.vue => ElementsPool.vue} (76%) diff --git a/src/plugins/flexibleLayout/components/flexibleLayout.vue b/src/plugins/flexibleLayout/components/flexibleLayout.vue index de1f76abe3..cd90c28791 100644 --- a/src/plugins/flexibleLayout/components/flexibleLayout.vue +++ b/src/plugins/flexibleLayout/components/flexibleLayout.vue @@ -271,11 +271,6 @@ export default { }); }, removeFromComposition(identifier) { - let keystring = this.openmct.objects.makeKeyString(identifier); - - this.identifierMap[keystring] = undefined; - delete this.identifierMap[keystring]; - this.composition.remove({identifier}); }, setSelectionToParent() { @@ -355,6 +350,9 @@ export default { removeChildObject(identifier) { let removeIdentifier = this.openmct.objects.makeKeyString(identifier); + this.identifierMap[removeIdentifier] = undefined; + delete this.identifierMap[removeIdentifier]; + this.containers.forEach(container => { container.frames = container.frames.filter(frame => { let frameIdentifier = this.openmct.objects.makeKeyString(frame.domainObjectIdentifier); diff --git a/src/ui/inspector/ElementItem.vue b/src/ui/inspector/ElementItem.vue new file mode 100644 index 0000000000..7418abc14f --- /dev/null +++ b/src/ui/inspector/ElementItem.vue @@ -0,0 +1,96 @@ + + + diff --git a/src/ui/inspector/Elements.vue b/src/ui/inspector/ElementsPool.vue similarity index 76% rename from src/ui/inspector/Elements.vue rename to src/ui/inspector/ElementsPool.vue index fe058a28c7..7bce6ce4e7 100644 --- a/src/ui/inspector/Elements.vue +++ b/src/ui/inspector/ElementsPool.vue @@ -8,34 +8,22 @@ />
    -
  • -
    - - -
    -
  • + :index="index" + :element-object="element" + :parent-object="parentObject" + :allow-drop="allowDrop" + @dragstart-custom="moveFrom(index)" + @drop-custom="moveTo(index)" + />
  • import _ from 'lodash'; import Search from '../components/search.vue'; -import ObjectLabel from '../components/ObjectLabel.vue'; +import ElementItem from './ElementItem.vue'; export default { components: { 'Search': Search, - 'ObjectLabel': ObjectLabel + 'ElementItem': ElementItem }, inject: ['openmct'], data() { @@ -65,8 +53,9 @@ export default { isEditing: this.openmct.editor.isEditing(), parentObject: undefined, currentSearch: '', - isDragging: false, - selection: [] + selection: [], + contextClickTracker: {}, + allowDrop: false }; }, mounted() { @@ -148,20 +137,15 @@ export default { && element.name.toLowerCase().search(this.currentSearch) !== -1; }); }, - allowDrop(event) { - event.preventDefault(); - }, moveTo(moveToIndex) { - this.composition.reorder(this.moveFromIndex, moveToIndex); + if (this.allowDrop) { + this.composition.reorder(this.moveFromIndex, moveToIndex); + this.allowDrop = false; + } }, moveFrom(index) { - this.isDragging = true; + this.allowDrop = true; this.moveFromIndex = index; - document.addEventListener('dragend', this.hideDragStyling); - }, - hideDragStyling() { - this.isDragging = false; - document.removeEventListener('dragend', this.hideDragStyling); } } }; diff --git a/src/ui/inspector/Inspector.vue b/src/ui/inspector/Inspector.vue index 025c74d000..7ec6b021bb 100644 --- a/src/ui/inspector/Inspector.vue +++ b/src/ui/inspector/Inspector.vue @@ -29,7 +29,7 @@ handle="before" label="Elements" > - + import multipane from '../layout/multipane.vue'; import pane from '../layout/pane.vue'; -import Elements from './Elements.vue'; +import ElementsPool from './ElementsPool.vue'; import Location from './Location.vue'; import Properties from './Properties.vue'; import ObjectName from './ObjectName.vue'; @@ -71,7 +71,7 @@ export default { SavedStylesInspectorView, multipane, pane, - Elements, + ElementsPool, Properties, ObjectName, Location, diff --git a/src/ui/inspector/elements.scss b/src/ui/inspector/elements.scss index e7f8d61365..a3d4363cae 100644 --- a/src/ui/inspector/elements.scss +++ b/src/ui/inspector/elements.scss @@ -15,9 +15,6 @@ &__elements { flex: 1 1 auto; overflow: auto; - &.is-dragging { - li { opacity: 0.2; } - } } .c-grippy { @@ -27,8 +24,16 @@ transform: translateY(-2px); width: $d; height: $d; } + + &.is-context-clicked { + box-shadow: inset $colorItemTreeSelectedBg 0 0 0 1px; + } + + .hover { + background-color: $colorItemTreeSelectedBg; + } } .js-last-place { height: 10px; -} +} \ No newline at end of file