Compare commits

..

2 Commits

Author SHA1 Message Date
Andrew Henry
d026a67ac0 Update on sort 2019-02-26 13:08:41 -08:00
Andrew Henry
78018628ce Remove slice operation 2019-02-26 09:16:37 -08:00
18 changed files with 119 additions and 251 deletions

View File

@@ -25,7 +25,7 @@
"eventemitter3": "^1.2.0",
"exports-loader": "^0.7.0",
"express": "^4.13.1",
"fast-sass-loader": "1.4.6",
"fast-sass-loader": "^1.4.5",
"file-loader": "^1.1.11",
"file-saver": "^1.3.8",
"git-rev-sync": "^1.4.0",

View File

@@ -92,7 +92,16 @@ function (
* @memberof platform/commonUI/edit.SaveAction#
*/
SaveAsAction.prototype.perform = function () {
return this.save();
// Discard the current root view (which will be the editing
// UI, which will have been pushed atop the Browse UI.)
function returnToBrowse(object) {
if (object) {
object.getCapability("action").perform("navigate");
}
return object;
}
return this.save().then(returnToBrowse);
};
/**
@@ -183,7 +192,7 @@ function (
if (reason !== "user canceled") {
self.notificationService.error("Save Failed");
}
throw reason;
return false;
}
return getParent(domainObject)

View File

@@ -67,19 +67,12 @@ define(
openmct = this.openmct,
newObject;
function onCancel() {
openmct.editor.cancel();
function onSave() {
// openmct.editor.save();
}
function navigateAndEdit(object) {
let objectPath = object.getCapability('context').getPath(),
url = '#/browse/' + objectPath
.map(function (o) {
return o && openmct.objects.makeKeyString(o.getId())
})
.join('/') + '?edit=true';
window.location.href = url;
function onCancel() {
openmct.editor.cancel();
}
newModel.type = this.type.getKey();
@@ -87,7 +80,7 @@ define(
newObject = this.parent.useCapability('instantiation', newModel);
openmct.editor.edit();
newObject.getCapability("action").perform("save-as").then(navigateAndEdit, onCancel);
newObject.getCapability("action").perform("save-as").then(onSave, onCancel);
// TODO: support editing object without saving object first.
// Which means we have to toggle createwizard afterwards. For now,
// We will disable this.

View File

@@ -29,13 +29,12 @@ define(
function SnapshotPreviewController($scope, openmct) {
$scope.previewImage = function (imageUrl) {
let imageDiv = document.createElement('div');
imageDiv.classList = 'image-main s-image-main';
imageDiv.style.backgroundImage = `url(${imageUrl})`;
let image = document.createElement('img');
image.src = imageUrl;
let previewImageOverlay = openmct.overlays.overlay(
{
element: imageDiv,
element: image,
size: 'large',
buttons: [
{

View File

@@ -178,12 +178,8 @@ define([
* @method remove
*/
DefaultCompositionProvider.prototype.remove = function (domainObject, childId) {
let composition = domainObject.composition.filter(function (child) {
return !(childId.namespace === child.namespace &&
childId.key === child.key);
});
this.publicAPI.objects.mutate(domainObject, 'composition', composition);
// TODO: this needs to be synchronized via mutation.
throw new Error('Default Provider does not implement removal.');
};
/**

View File

@@ -28,9 +28,9 @@ define([], function () {
key: "layout",
description: "A toolbar for objects inside a display layout.",
forSelection: function (selection) {
// Apply the layout toolbar if the selected object
// Apply the layout toolbar if the edit mode is on, and the selected object
// is inside a layout, or the main layout is selected.
return (selection &&
return (openmct.editor.isEditing() && selection &&
((selection[1] && selection[1].context.item && selection[1].context.item.type === 'layout') ||
(selection[0].context.item && selection[0].context.item.type === 'layout')));
},

View File

@@ -506,27 +506,9 @@ export default {
this.persist();
},
deleteContainer(containerId) {
let container = this.containers.filter(c => c.id === containerId)[0],
containerIndex = this.containers.indexOf(container);
/*
remove associated domainObjects from composition
*/
container.frames.forEach(f => {
this.composition.remove({identifier: f.domainObjectIdentifier});
});
let container = this.containers.filter(c => c.id === containerId)[0];
let containerIndex = this.containers.indexOf(container);
this.containers.splice(containerIndex, 1);
/*
add a container when there are no containers in the FL,
to prevent user from not being able to add a frame via
drag and drop.
*/
if (this.containers.length === 0) {
this.containers.push(new Container(100));
}
sizeToFill(this.containers);
this.persist();
},
@@ -566,12 +548,6 @@ export default {
.frames
.filter((f => f.id === frameId))[0];
let frameIndex = container.frames.indexOf(frame);
/*
remove associated domainObject from composition
*/
this.composition.remove({identifier: frame.domainObjectIdentifier});
container.frames.splice(frameIndex, 1);
sizeToFill(container.frames);
this.persist(containerIndex);
@@ -644,7 +620,7 @@ export default {
} else {
this.containers.splice(toIndex, 0, container);
}
this.persist();
this.persist(index);
},
removeChildObject(identifier) {
let removeIdentifier = this.openmct.objects.makeKeyString(identifier);

View File

@@ -57,7 +57,7 @@ define([
layoutObject: domainObject
},
el: element,
template: '<flexible-layout-component ref="flexibleLayout" :isEditing="isEditing"></flexible-layout-component>'
template: '<flexible-layout-component ref="flexibleLayout"></flexible-layout-component>'
});
},
getSelectionContext: function () {

View File

@@ -29,7 +29,7 @@ function ToolbarProvider(openmct) {
forSelection: function (selection) {
let context = selection[0].context;
return (context && context.type &&
return (openmct.editor.isEditing() && context && context.type &&
(context.type === 'flexible-layout' || context.type === 'container' || context.type === 'frame'));
},
toolbar: function (selection) {
@@ -204,7 +204,7 @@ function ToolbarProvider(openmct) {
addContainer,
toggleFrame ? separator: undefined,
toggleFrame,
deleteFrame || deleteContainer ? separator : undefined,
deleteFrame || deleteContainer ? separator: undefined,
deleteFrame,
deleteContainer
];

View File

@@ -30,7 +30,7 @@ define(
],
function (
html2canvas,
{ saveAs }
saveAs
) {
/**

View File

@@ -34,12 +34,13 @@
<script>
export default {
inject: ['table'],
data: function () {
let row = this.table.filteredRows.rows[this.rowOffset + this.rowIndex];
return {
rowTop: (this.rowOffset + this.rowIndex) * this.rowHeight + 'px',
formattedRow: this.row.getFormattedDatum(this.headers),
rowLimitClass: this.row.getRowLimitClass(),
cellLimitClasses: this.row.getCellLimitClasses()
formattedRow: row.getFormattedDatum(this.headers),
rowLimitClass: row.getRowLimitClass(),
cellLimitClasses: row.getCellLimitClasses()
}
},
props: {
@@ -47,10 +48,6 @@ export default {
type: Object,
required: true
},
row: {
type: Object,
required: true
},
columnWidths: {
type: Object,
required: true
@@ -58,7 +55,7 @@ export default {
rowIndex: {
type: Number,
required: false,
default: undefined
default: 0
},
rowOffset: {
type: Number,
@@ -71,11 +68,20 @@ export default {
default: 0
}
},
mounted() {
this.table.filteredRows.on('sort', this.renderRowContent);
},
destroy() {
this.table.filteredRows.off('sort', this.renderRowContent);
},
computed: {
rowTop() {
return (this.rowOffset + this.rowIndex) * this.rowHeight + 'px';
}
},
methods: {
calculateRowTop: function (rowOffset) {
this.rowTop = (rowOffset + this.rowIndex) * this.rowHeight + 'px';
},
formatRow: function (row) {
renderRowContent: function () {
let row = this.table.filteredRows.rows[this.rowOffset + this.rowIndex];
this.formattedRow = row.getFormattedDatum(this.headers);
this.rowLimitClass = row.getRowLimitClass();
this.cellLimitClasses = row.getCellLimitClasses();
@@ -83,11 +89,7 @@ export default {
},
// TODO: use computed properties
watch: {
rowOffset: 'calculateRowTop',
row: {
handler: 'formatRow',
deep: false
}
rowOffset: 'renderRowContent'
}
}
</script>

View File

@@ -80,13 +80,13 @@
<table class="c-table__body c-telemetry-table__body"
:style="{ height: totalHeight + 'px'}">
<tbody>
<telemetry-table-row v-for="(row, rowIndex) in visibleRows"
<telemetry-table-row v-for="rowIndex in (rowEnd - rowOffset)"
:headers="headers"
:columnWidths="columnWidths"
:rowIndex="rowIndex"
:rowIndex="rowIndex - 1"
:rowOffset="rowOffset"
:rowHeight="rowHeight"
:row="row">
:rowEnd="rowEnd">
</telemetry-table-row>
</tbody>
</table>
@@ -295,7 +295,8 @@ export default {
dropOffsetLeft: undefined,
isDropTargetActive: false,
isAutosizeEnabled: configuration.autosize,
scrollW: 0
scrollW: 0,
rowEnd: 0
}
},
computed: {
@@ -359,7 +360,7 @@ export default {
}
}
this.rowOffset = start;
this.visibleRows = filteredRows.slice(start, end);
this.rowEnd = end;
},
calculateFirstVisibleRow() {
return Math.floor(this.scrollable.scrollTop / this.rowHeight);
@@ -451,10 +452,10 @@ export default {
} else {
sizingRow = rows;
}
if (!this.sizingRows[sizingRow.objectKeyString]) {
/*if (!this.sizingRows[sizingRow.objectKeyString]) {
this.sizingRows[sizingRow.objectKeyString] = sizingRow;
this.$nextTick().then(this.calculateColumnWidths);
}
}*/
if (!this.updatingView) {
this.updatingView = true;

View File

@@ -1,10 +1,6 @@
<template>
<div class="c-elements-pool">
<Search class="c-elements-pool__search"
:value="currentSearch"
@input="applySearch"
@clear="applySearch">
</Search>
<Search class="c-elements-pool__search" @input="applySearch"></Search>
<div class="c-elements-pool__elements">
<ul class="tree c-tree c-elements-pool__tree" id="inspector-elements-tree"
v-if="elements.length > 0">
@@ -73,8 +69,7 @@ export default {
return {
elements: [],
isEditing: this.openmct.editor.isEditing(),
parentObject: undefined,
currentSearch: ''
parentObject: undefined
}
},
mounted() {

View File

@@ -15,7 +15,7 @@
{{ domainObject.name }}
</span>
</div>
<div class="l-browse-bar__context-actions c-disclosure-button" @click.prevent.stop="showContextMenu"></div>
<div class="l-browse-bar__context-actions c-disclosure-button" @click="showContextMenu"></div>
</div>
<div class="l-browse-bar__end">
@@ -24,7 +24,7 @@
<button class="c-button--menu"
:class="currentView.cssClass"
title="Switch view type"
@click.stop="toggleViewMenu">
@click="toggleViewMenu">
<span class="c-button__label">
{{ currentView.name }}
</span>
@@ -43,32 +43,13 @@
</div>
<!-- Action buttons -->
<div class="l-browse-bar__actions">
<button class="l-browse-bar__actions__notebook-entry c-button icon-notebook"
<button class="l-browse-bar__actions__edit c-button icon-notebook"
title="New Notebook entry"
@click="snapshot()">
</button>
<button class="l-browse-bar__actions__edit c-button c-button--major icon-pencil" title="Edit" v-if="isViewEditable & !isEditing" @click="edit()"></button>
<div class="l-browse-bar__view-switcher c-ctrl-wrapper c-ctrl-wrapper--menus-left"
v-if="isEditing">
<button class="c-button--menu c-button--major icon-save" title="Save" @click.stop="toggleSaveMenu"></button>
<div class="c-menu" v-show="showSaveMenu">
<ul>
<li @click="saveAndFinishEditing"
class="icon-save"
title="Save and Finish Editing">
Save and Finish Editing
</li>
<li @click="saveAndContinueEditing"
class="icon-save"
title="Save and Continue Editing">
Save and Continue Editing
</li>
</ul>
</div>
</div>
<button class="l-browse-bar__actions c-button icon-x" title="Cancel Editing" v-if="isEditing" @click="promptUserandCancelEditing()"></button>
<button class="l-browse-bar__actions__notebook-entry c-button c-button--major icon-pencil" title="Edit" v-if="isViewEditable & !isEditing" @click="edit()"></button>
<button class="l-browse-bar__actions c-button c-button--major icon-save" title="Save and Finish Editing" v-if="isEditing" @click="saveAndFinishEditing()"></button>
<button class="l-browse-bar__actions c-button icon-x" title="Cancel Editing" v-if="isEditing" @click="cancelEditing()"></button>
</div>
</div>
</div>
@@ -81,16 +62,10 @@ const PLACEHOLDER_OBJECT = {};
export default {
inject: ['openmct'],
methods: {
toggleViewMenu() {
toggleViewMenu(event) {
event.stopPropagation();
this.showViewMenu = !this.showViewMenu;
},
toggleSaveMenu() {
this.showSaveMenu = !this.showSaveMenu;
},
closeViewAndSaveMenu() {
this.showViewMenu = false;
this.showSaveMenu = false;
},
updateName(event) {
// TODO: handle isssues with contenteditable text escaping.
if (event.target.innerText !== this.domainObject.name) {
@@ -109,48 +84,20 @@ const PLACEHOLDER_OBJECT = {};
edit() {
this.openmct.editor.edit();
},
promptUserandCancelEditing() {
let dialog = this.openmct.overlays.dialog({
iconClass: 'alert',
message: 'Are you sure you want to continue? All unsaved changes will be lost!',
buttons: [
{
label: 'Ok',
emphasis: true,
callback: () => {
this.openmct.editor.cancel();
dialog.dismiss();
}
},
{
label: 'Cancel',
callback: () => {
dialog.dismiss();
}
}
]
});
},
promptUserbeforeNavigatingAway(event) {
if(this.openmct.editor.isEditing()) {
event.preventDefault();
event.returnValue = '';
}
cancelEditing() {
this.openmct.editor.cancel();
},
saveAndFinishEditing() {
return this.openmct.editor.save().then(()=> {
this.openmct.editor.save().then(()=> {
this.openmct.notifications.info('Save successful');
}).catch((error) => {
this.openmct.notifications.error('Error saving objects');
console.error(error);
});
},
saveAndContinueEditing() {
this.saveAndFinishEditing().then(() => {
this.openmct.editor.edit();
});
},
showContextMenu(event) {
event.preventDefault();
event.stopPropagation();
this.openmct.contextMenu._showContextMenuForObjectPath(this.openmct.router.path, event.clientX, event.clientY);
},
snapshot() {
@@ -164,7 +111,6 @@ const PLACEHOLDER_OBJECT = {};
data: function () {
return {
showViewMenu: false,
showSaveMenu: false,
domainObject: PLACEHOLDER_OBJECT,
viewKey: undefined,
isEditing: this.openmct.editor.isEditing()
@@ -215,16 +161,15 @@ const PLACEHOLDER_OBJECT = {};
mounted: function () {
this.notebookSnapshot = new NotebookSnapshot(this.openmct);
document.addEventListener('click', this.closeViewAndSaveMenu);
window.addEventListener('beforeunload', this.promptUserbeforeNavigatingAway);
document.addEventListener('click', () => {
if (this.showViewMenu) {
this.showViewMenu = false;
}
});
this.openmct.editor.on('isEditing', (isEditing) => {
this.isEditing = isEditing;
});
},
beforeDestroy: function () {
document.removeEventListener('click', this.closeViewAndSaveMenu);
window.removeEventListener('click', this.promptUserbeforeNavigatingAway);
}
}
</script>

View File

@@ -296,20 +296,29 @@
Toolbar
},
mounted() {
this.openmct.selection.on('change', this.toggleHasToolbar);
this.openmct.editor.on('isEditing', this.toggleIsEditing);
this.openmct.editor.on('isEditing', (isEditing)=>{
this.isEditing = isEditing;
});
},
data: function () {
return {
fullScreen: false,
conductorComponent: undefined,
isEditing: false,
hasToolbar: false
conductorComponent: {},
isEditing: false
}
},
computed: {
toolbar() {
return this.isEditing && this.hasToolbar;
let selection = this.openmct.selection.get();
let structure = undefined;
if (!selection[0]) {
structure = [];
} else {
structure = this.openmct.toolbars.get(selection);
}
return this.isEditing && structure.length > 0;
}
},
methods: {
@@ -324,25 +333,7 @@
},
openInNewTab(event) {
window.open(window.location.href);
},
toggleHasToolbar(selection) {
let structure = undefined;
if (!selection[0]) {
structure = [];
} else {
structure = this.openmct.toolbars.get(selection);
}
this.hasToolbar = structure.length > 0;
},
toggleIsEditing(isEditing) {
this.isEditing = isEditing;
}
},
beforeDestroy() {
this.openmct.selection.off('change', this.toggleHasToolbar);
this.openmct.editor.off('isEditing', this.toggleIsEditing);
}
}
</script>

View File

@@ -178,21 +178,15 @@
getFilteredChildren() {
this.searchService.query(this.searchValue).then(children => {
this.filteredTreeItems = children.hits.map(child => {
let context = child.object.getCapability('context'),
object = child.object.useCapability('adapter'),
objectPath = [];
if (context) {
objectPath = context.getPath().slice(1)
.map(oldObject => oldObject.useCapability('adapter'))
.reverse();
}
let objectPath = child.object.getCapability('context')
.getPath().slice(1).map(oldObject => oldObject.useCapability('adapter'))
.reverse(),
object = child.object.useCapability('adapter');
return {
id: this.openmct.objects.makeKeyString(object.identifier),
object,
objectPath
objectPath
}
});
});

View File

@@ -20,31 +20,19 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
<template>
<div class="l-preview-window">
<div class="l-browse-bar">
<div class="l-browse-bar__start">
<div class="l-browse-bar__object-name--w"
:class="type.cssClass">
<span class="l-browse-bar__object-name">
{{ domainObject.name }}
</span>
<context-menu-drop-down :object-path="objectPath"></context-menu-drop-down>
</div>
</div>
<div class="l-browse-bar__end">
<div class="l-browse-bar__actions">
<button class="l-browse-bar__actions__edit c-button icon-notebook"
title="New Notebook entry"
@click="snapshot">
</button>
</div>
</div>
</div>
<div class="l-preview-window__object-view">
<div ref="objectView"></div>
</div>
<div class="l-preview-window">
<div class="l-preview-window__object-name l-browse-bar__object-name--w" :class="type.cssClass">
<span class="l-browse-bar__object-name">
{{ domainObject.name }}
</span>
<context-menu-drop-down :object-path="objectPath"></context-menu-drop-down>
</div>
</template>
<div class="l-preview-window__object-view">
<div ref="objectView">
</div>
</div>
</div>
</template>
<style lang="scss">
@import '~styles/sass-base';
@@ -75,7 +63,6 @@
<script>
import ContextMenuDropDown from '../../ui/components/contextMenuDropDown.vue';
import NotebookSnapshot from '../utils/notebook-snapshot';
export default {
components: {
@@ -85,12 +72,6 @@
'openmct',
'objectPath'
],
methods: {
snapshot() {
let element = document.getElementsByClassName("l-preview-window__object-view")[0];
this.notebookSnapshot.capture(this.domainObject, element);
}
},
data() {
let domainObject = this.objectPath[0];
let type = this.openmct.types.get(domainObject.type);
@@ -104,7 +85,6 @@
let viewProvider = this.openmct.objectViews.get(this.domainObject)[0];
this.view = viewProvider.view(this.domainObject);
this.view.show(this.$refs.objectView, false);
this.notebookSnapshot = new NotebookSnapshot(this.openmct);
},
destroy() {
this.view.destroy();

View File

@@ -8,17 +8,13 @@ define([
let navigateCall = 0;
let browseObject;
function viewObject(object, viewProvider, edit) {
function viewObject(object, viewProvider) {
openmct.layout.$refs.browseObject.show(object, viewProvider.key, true);
openmct.layout.$refs.browseBar.domainObject = object;
openmct.layout.$refs.browseBar.viewKey = viewProvider.key;
};
if (edit && viewProvider.canEdit && viewProvider.canEdit(object)) {
openmct.editor.edit();
}
}
function navigateToPath(path, currentViewKey, edit) {
function navigateToPath(path, currentViewKey) {
navigateCall++;
let currentNavigation = navigateCall;
@@ -52,7 +48,7 @@ define([
.getByProviderKey(currentViewKey)
if (currentProvider && currentProvider.canView(navigatedObject)) {
viewObject(navigatedObject, currentProvider, edit);
viewObject(navigatedObject, currentProvider);
return;
}
@@ -75,27 +71,18 @@ define([
if (!navigatePath) {
navigatePath = 'mine';
}
navigateToPath(navigatePath, params.view, params.edit === 'true');
navigateToPath(navigatePath, params.view);
});
openmct.router.on('change:params', function (newParams, oldParams, changed) {
if (changed.view && browseObject) {
let provider = openmct
.objectViews
.getByProviderKey(changed.view),
edit = newParams.edit === 'true';
viewObject(browseObject, provider, edit);
.objectViews
.getByProviderKey(changed.view);
viewObject(browseObject, provider);
}
});
openmct.editor.on('isEditing', function (isEditing) {
openmct.router.updateParams({
edit: isEditing
});
})
}
});