Compare commits

...

9 Commits

Author SHA1 Message Date
07d0c4caee Merge latest, resolve conflicts.
Need to just apply these changes to Deep's branch and push
2018-10-29 16:03:02 -07:00
f3ebc94558 chage rows to frames and columns to containers, switch draggable to whole frame object 2018-10-29 14:56:29 -07:00
95972ee95d add editing capability 2018-10-29 14:20:05 -07:00
e7906dccfb enable persistance 2018-10-29 13:56:13 -07:00
b8a3628490 enable drag and drop between columns and rows 2018-10-29 13:24:16 -07:00
ace3ab13a8 add drop targets to every row 2018-10-29 11:58:18 -07:00
d7d400b34e merge current topic-core-refactor 2018-10-29 10:52:04 -07:00
1ce4daabac better drag handling 2018-10-26 10:41:53 -07:00
562e78b696 first cut of flexible layout 2018-10-25 14:31:43 -07:00
12 changed files with 444 additions and 1 deletions

View File

@ -78,6 +78,7 @@
openmct.install(openmct.plugins.Notebook());
openmct.install(openmct.plugins.FolderView());
openmct.install(openmct.plugins.Tabs());
openmct.install(openmct.plugins.FlexibleLayout());
openmct.time.clock('local', {start: -THIRTY_MINUTES, end: 0});
openmct.time.timeSystem('utc');
openmct.start();

View File

@ -0,0 +1,99 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
<template>
<div class="c-fl-container"
:style="[{'min-width': minWidth}]">
<frame-component
v-for="(frame, index) in frames"
:key="index"
:style="{
'min-height': frame.height || `${100/frames.length}%`
}"
:frame="frame"
:index="index"
:isEditing="isEditing"
@object-drag-from="dragFrom"
@object-drop-to="dropTo">
</frame-component>
</div>
</template>
<style lang="scss">
.flex-container{
min-height: 100%;
min-width: 100%;
.add{
display: flex;
flex-direction: columm;
font-size: 100%;
align-items: center;
justify-content: center;
min-width: 100%;
background: #009bd140;
border: 3px solid #009bd1;
border-width: 3px 1.5px;
cursor: pointer;
.large{
min-height: 100%;
}
}
&:hover{
.allow-drop {
background: red;
}
}
}
</style>
<script>
import FrameComponent from './frame.vue';
import Frame from '../utils/frame'
export default {
props: ['minWidth', 'frames', 'index', 'isEditing'],
components: {
FrameComponent
},
methods: {
dragFrom(frameIndex) {
this.$emit('object-drag-from', this.index, frameIndex);
},
dropTo(frameIndex, event) {
let domainObject = event.dataTransfer.getData('domainObject'),
frameObject;
if (domainObject) {
frameObject = new Frame(JSON.parse(domainObject));
}
this.$emit('object-drop-to', this.index, frameIndex, frameObject);
}
}
}
</script>

View File

@ -0,0 +1,129 @@
<template>
<div class="flexible-layout-container">
<div class="header"
v-if="isEditing"
@click="addContainer">
Add a new Container
</div>
<div class="body">
<container-component
v-for="(container, index) in containers"
:key="index"
:index="index"
:minWidth="container.width || `${100/containers.length}%`"
:frames="container.frames"
:isEditing="isEditing"
@addFrame="addFrame"
@object-drag-from="dragFromHandler"
@object-drop-to="dropToHandler">
</container-component>
</div>
</div>
</template>
<style lang="scss">
@import '~styles/sass-base';
.l-fl {
@include abs();
display: flex;
flex-direction: column;
.header {
font-size: 22px;
text-align: center;
min-height: 30px;
min-width: 100%;
background: rgb(66, 96, 96);
}
> * + * {
margin-top: $interiorMargin;
}
.temp-toolbar {
flex: 0 0 auto;
}
&__container-holder {
// Holds containers
display: flex;
flex: 1 1 auto;
&[class*='-column'] {
// @include test(blue);
flex-direction: column;
> * + * {
margin-top: 1px;
}
}
&[class*='-row'] {
// @include test(red);
flex-direction: row;
> * + * {
margin-left: 1px;
}
}
}
&__container {
background: $editColorBg;
flex: 1 1 auto;
}
}
</style>
<script>
import ContainerComponent from '../components/container.vue';
import Container from '../utils/container';
export default {
inject: ['openmct', 'domainObject'],
components: {
ContainerComponent
},
data() {
let containers = this.domainObject.configuration.containers;
return {
containers: containers,
dragFrom: [],
isEditing: false
}
},
methods: {
addContainer() {
let container = new Container()
this.containers.push(container);
},
addFrame(frame, index) {
this.containers[index].addFrame(frame);
},
dragFromHandler(containerIndex, frameIndex) {
this.dragFrom = [containerIndex, frameIndex];
},
dropToHandler(containerIndex, frameIndex, frameObject) {
if (!frameObject) {
frameObject = this.containers[this.dragFrom[0]].frames.splice(this.dragFrom[1], 1)[0];
}
this.containers[containerIndex].frames.splice((frameIndex + 1), 0, frameObject);
this.persist();
},
persist(){
this.openmct.objects.mutate(this.domainObject, '.configuration.containers', this.containers);
},
isEditingHandler(isEditing) {
this.isEditing = isEditing;
}
},
mounted() {
this.openmct.editor.on('isEditing', this.isEditingHandler);
}
}
</script>

View File

@ -0,0 +1,75 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
<template>
<div class="flex-frame" draggable="true">
<object-view
class="c-object-view"
v-if="frame.domainObject"
ref="dragObject"
:object="frame.domainObject">
</object-view>
<div class="drop-container add"
v-if="isEditing"
@drop="dropHandler">
+
</div>
</div>
</template>
<style lang="scss">
.flex-frame{
min-width: 100%;
min-height: 100%;
.drop-container {
min-height: 40px;
min-width: 100%;
}
}
</style>
<script>
import ObjectView from '../../../ui/components/layout/ObjectView.vue';
export default {
props: ['frame', 'index', 'isEditing'],
components: {
ObjectView
},
methods: {
dragstart(event) {
console.log('dragging');
this.$emit('object-drag-from', this.index);
},
dropHandler(event){
event.stopPropagation();
this.$emit('object-drop-to', this.index, event);
}
},
mounted() {
this.$el.addEventListener('dragstart', this.dragstart);
}
}
</script>

View File

@ -0,0 +1,67 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'./components/flexibleLayout.vue',
'vue'
], function (
FlexibleLayoutComponent,
Vue
) {
function FlexibleLayout(openmct) {
return {
key: 'flexible-layout',
name: 'FlexibleLayout',
cssClass: 'icon-layout-view',
canView: function (domainObject) {
return domainObject.type === 'flexible-layout';
},
view: function (domainObject) {
let component;
return {
show: function (element) {
component = new Vue({
components: {
FlexibleLayoutComponent: FlexibleLayoutComponent.default
},
provide: {
openmct,
domainObject
},
el: element,
template: '<flexible-layout-component></flexible-layout-component>'
});
},
destroy: function (element) {
component.$destroy();
component = undefined;
}
};
},
priority: function () {
return 1;
}
};
}
return FlexibleLayout;
});

View File

@ -0,0 +1,45 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
'./flexibleLayout'
], function (
FlexibleLayout
) {
return function plugin() {
return function install(openmct) {
openmct.objectViews.addProvider(new FlexibleLayout(openmct));
openmct.types.addType('flexible-layout', {
name: "Flexible Layout",
creatable: true,
cssClass: 'icon-layout',
initialize: function (domainObject) {
domainObject.composition = [];
domainObject.configuration = {
containers: []
};
}
});
};
};
});

View File

@ -0,0 +1,14 @@
import Frame from './frame';
class Container {
constructor (width) {
this.frames = [new Frame({}, '5%')];
this.width = width;
}
addFrame(frameObject) {
this.frames.push(frameObject);
}
}
export default Container;

View File

@ -0,0 +1,8 @@
class Frame {
constructor(domainObject, height) {
this.domainObject = domainObject;
this.height = height;
}
}
export default Frame;

View File

@ -37,6 +37,7 @@ define([
'./notebook/plugin',
'./displayLayout/plugin',
'./folderView/plugin',
'./flexibleLayout/plugin',
'./tabs/plugin',
'../../platform/features/fixed/plugin'
], function (
@ -56,6 +57,7 @@ define([
Notebook,
DisplayLayoutPlugin,
FolderView,
FlexibleLayout,
Tabs,
FixedView
) {
@ -171,6 +173,7 @@ define([
plugins.FolderView = FolderView;
plugins.Tabs = Tabs;
plugins.FixedView = FixedView;
plugins.FlexibleLayout = FlexibleLayout;
return plugins;
});

View File

@ -90,6 +90,7 @@ $colorTOIHov: $colorTime; // was $timeControllerToiLineColorHov
// Edit Colors
$editColor: #00c7c3;
$editColorBg: rgba($editColor, 0.1);
$editColorFg: $colorBodyFg;
$browseBorderSelectableHov: 1px dotted rgba($colorBodyFg, 0.2);
$browseShdwSelectableHov: rgba($colorBodyFg, 0.2) 0 0 3px;

View File

@ -90,6 +90,7 @@ $colorTOIHov: $colorTime; // was $timeControllerToiLineColorHov
// Edit Colors
$editColor: #00c7c3;
$editColorBg: rgba($editColor, 0.1);
$editColorFg: $colorBodyFg;
$browseBorderSelectableHov: 1px dotted rgba($colorBodyFg, 0.2);
$browseShdwSelectableHov: rgba($colorBodyFg, 0.2) 0 0 3px;

View File

@ -348,7 +348,7 @@ body.desktop .has-local-controls {
.l-shell__main-container > .l-layout,
.l-shell__main-container > .c-object-view .l-fixed-position {
// Target the top-most layout container and color its background
background: rgba($editColor, 0.1);
background: $editColorBg;
}
// Layouts