* revised new tree refactor, moved most of the logic to mct-tree instead of tree-item * scrollTo set for sync, bug fixes, window resize handling * removing console logs * checking domainobject composition for length to verify children instead of composition object itself * added scrollTo on load if in viewed objects directory * loading, sync bug, search issues, opitmization * initial PR review updates * modified so search now uses the same container and virtual scroll * eslint fix * Adding new glyphs - Multiple new glyphs cherrypicked from branch `add-new-glyphs-062320`; * Styling for new-tree-refactor WIP - WIP! - New glyphs, markup changes in BrowseBar.vue; - Refinements to tree items, WIP; - TODO: move hard-coded CSS values into _constants, make theme-compatible; * Styling for new-tree-refactor WIP - WIP! - Added new `c-click-link` CSS class; - Move tree sync button into tree pane area; - Added named "controls" slot to pane.vue; - _up and _down arrows now use visibility instead of opacity to prevent accidental clicks; * Styling for new-tree-refactor WIP - WIP! - Significant mods and simplification in pane.vue and assoc CSS for expand/collapse functionality; - Wait spinner when in tree: cleanups, simplification; * More new glyphs, updated art - New glyphs: icon-unlocked and icon-target; - Updated art for icon-lock glyph; * remove arrows for search results, hightlight "my items" correctly, added empty folder notic * Styling for new-tree-refactor WIP - WIP! - Refinements to "empty" object element; - Changed sync-tree icon glyph; * Styling for new-tree-refactor WIP - Nav up arrows now left-align properly; * Styling for new-tree-refactor - Significant consolidation and cleanups in mct-tree.scss; - Normalize base and hover styles across new tree, legacy tree, list-items (used in Notebook) and Folder List View; - Class naming normalization, change `c-list-item__name-value` to `c-list-item__name`; - Add styling to override and remove `<a> outline: dotted` coming from normalize-min; - Removed too-broad `<a>` coloring in tables; * Styling for new-tree-refactor - Fix styles for Snow theme; - Sync Maelstrom and Espresso themes; - Remove too-broad `<a>` hover styling from global.scss; - Disallow pointer-events on `is-navigated` object's label (click on c-nav__down element still allowed); * Styling for new-tree-refactor - Normalizing status area expand/collapse iconography to match new approach in panes; * Adding new glyphs - Added `icon-items-collapse` and `icon-items-expand`; * Styling for new-tree-refactor - Using new glyphs for items expand/collapse in Status area; * dynamic item height for desktop and mobile views * lint fixes * updated addChild and removeChild functions as they were not working at all * some PR comment updates!; * Remove unneeded hard-coded CSS color property * fixed issues when multiple root children exist, added plugin to change the name of the default root object * removing "my other items" testing references * linting fixes * updating karma timeouts for testing purposes * eslint fixes * WIP: fixing linting issues * updating for testing * set root object provider to update root registry if called more than once * tweaking tests so that it passes both locally and on the serve tests * removing old css code preventing context clicks on active menu items * fixing testing errors * backwards compatible storage fix Co-authored-by: charlesh88 <charlesh88@gmail.com> Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
140 lines
4.4 KiB
Vue
140 lines
4.4 KiB
Vue
<template>
|
|
<div
|
|
class="l-pane"
|
|
:class="{
|
|
'l-pane--horizontal-handle-before': type === 'horizontal' && handle === 'before',
|
|
'l-pane--horizontal-handle-after': type === 'horizontal' && handle === 'after',
|
|
'l-pane--vertical-handle-before': type === 'vertical' && handle === 'before',
|
|
'l-pane--vertical-handle-after': type === 'vertical' && handle === 'after',
|
|
'l-pane--collapsed': collapsed,
|
|
'l-pane--reacts': !handle,
|
|
'l-pane--resizing': resizing === true
|
|
}"
|
|
>
|
|
<div
|
|
v-if="handle"
|
|
class="l-pane__handle"
|
|
@mousedown="start"
|
|
></div>
|
|
<div class="l-pane__header">
|
|
<span v-if="label"
|
|
class="l-pane__label"
|
|
>{{ label }}</span>
|
|
<slot name="controls"></slot>
|
|
<button
|
|
v-if="collapsable"
|
|
class="l-pane__collapse-button c-icon-button"
|
|
@click="toggleCollapse"
|
|
></button>
|
|
</div>
|
|
<button
|
|
class="l-pane__expand-button"
|
|
@click="toggleCollapse"
|
|
>
|
|
<span class="l-pane__expand-button__label">{{ label }}</span>
|
|
</button>
|
|
<div class="l-pane__contents">
|
|
<slot></slot>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
const COLLAPSE_THRESHOLD_PX = 40;
|
|
|
|
export default {
|
|
props: {
|
|
handle: {
|
|
type: String,
|
|
default: '',
|
|
validator: function (value) {
|
|
return ['', 'before', 'after'].indexOf(value) !== -1;
|
|
}
|
|
},
|
|
collapsable: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
label: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
collapsed: false,
|
|
resizing: false
|
|
};
|
|
},
|
|
beforeMount() {
|
|
this.type = this.$parent.type;
|
|
this.styleProp = (this.type === 'horizontal') ? 'width' : 'height';
|
|
},
|
|
methods: {
|
|
toggleCollapse: function () {
|
|
this.collapsed = !this.collapsed;
|
|
if (this.collapsed) {
|
|
// Pane is expanded and is being collapsed
|
|
this.currentSize = (this.dragCollapse === true) ? this.initial : this.$el.style[this.styleProp];
|
|
this.$el.style[this.styleProp] = '';
|
|
} else {
|
|
// Pane is collapsed and is being expanded
|
|
this.$el.style[this.styleProp] = this.currentSize;
|
|
delete this.currentSize;
|
|
delete this.dragCollapse;
|
|
}
|
|
},
|
|
trackSize: function () {
|
|
if (!this.dragCollapse === true) {
|
|
if (this.type === 'vertical') {
|
|
this.initial = this.$el.offsetHeight;
|
|
} else if (this.type === 'horizontal') {
|
|
this.initial = this.$el.offsetWidth;
|
|
}
|
|
}
|
|
},
|
|
getPosition: function (event) {
|
|
return this.type === 'horizontal'
|
|
? event.pageX
|
|
: event.pageY;
|
|
},
|
|
getNewSize: function (event) {
|
|
let delta = this.startPosition - this.getPosition(event);
|
|
if (this.handle === "before") {
|
|
return `${this.initial + delta}px`;
|
|
}
|
|
|
|
if (this.handle === "after") {
|
|
return `${this.initial - delta}px`;
|
|
}
|
|
},
|
|
updatePosition: function (event) {
|
|
let size = this.getNewSize(event);
|
|
let intSize = parseInt(size.substr(0, size.length - 2), 10);
|
|
if (intSize < COLLAPSE_THRESHOLD_PX && this.collapsable === true) {
|
|
this.dragCollapse = true;
|
|
this.end();
|
|
this.toggleCollapse();
|
|
} else {
|
|
this.$el.style[this.styleProp] = size;
|
|
}
|
|
},
|
|
start: function (event) {
|
|
event.preventDefault(); // stop from firing drag event
|
|
|
|
this.startPosition = this.getPosition(event);
|
|
document.body.addEventListener('mousemove', this.updatePosition);
|
|
document.body.addEventListener('mouseup', this.end);
|
|
this.resizing = true;
|
|
this.trackSize();
|
|
},
|
|
end: function (event) {
|
|
document.body.removeEventListener('mousemove', this.updatePosition);
|
|
document.body.removeEventListener('mouseup', this.end);
|
|
this.resizing = false;
|
|
this.trackSize();
|
|
}
|
|
}
|
|
};
|
|
</script>
|