Merge condition-ui branch into this.

This commit is contained in:
Joshi 2020-02-04 15:12:33 -08:00
parent a5a3e41d21
commit 79811d6662
13 changed files with 309 additions and 199 deletions

View File

@ -24,7 +24,7 @@ import * as EventEmitter from 'eventemitter3';
import uuid from 'uuid';
import TelemetryCriterion from "@/plugins/condition/criterion/TelemetryCriterion";
import { TRIGGER } from "@/plugins/condition/utils/constants";
import {computeConditionForAll, computeConditionForAny} from "@/plugins/condition/utils/evaluator";
import {computeCondition} from "@/plugins/condition/utils/evaluator";
/*
* conditionDefinition = {
@ -228,11 +228,7 @@ export default class ConditionClass extends EventEmitter {
//TODO: implement as part of the evaluator class task.
evaluate() {
if (this.trigger === TRIGGER.ANY) {
this.result = computeConditionForAny(this.criteriaResults);
} else if (this.trigger === TRIGGER.ALL) {
this.result = computeConditionForAll(this.criteriaResults);
}
this.result = computeCondition(this.criteriaResults, this.trigger === TRIGGER.ALL);
}
emitEvent(eventName, data) {

View File

@ -58,7 +58,7 @@ export default class ConditionSetViewProvider {
isEditing
}
},
template: '<condition-set ref="conditionSet" :isEditing="isEditing"></condition-set>'
template: '<condition-set :isEditing="isEditing"></condition-set>'
});
},
onEditModeChange: (isEditing) => {

View File

@ -103,7 +103,6 @@ describe("The condition", function () {
it("initializes with criteria from the condition definition", function () {
expect(conditionObj.criteria.length).toEqual(1);
let criterion = conditionObj.criteria[0];
console.log(criterion);
expect(criterion instanceof TelemetryCriterion).toBeTrue();
expect(criterion.operator).toEqual(testConditionDefinition.definition.criteria[0].operator);
expect(criterion.input).toEqual(testConditionDefinition.definition.criteria[0].input);

View File

@ -1,4 +1,5 @@
<template>
<!-- TODO: current condition class should be set using openmct.objects.makeKeyString(<identifier>) -->
<div v-if="condition"
id="conditionArea"
class="c-cs-ui__conditions"
@ -21,6 +22,8 @@
</template>
<script>
import ConditionClass from "@/plugins/condition/Condition";
export default {
inject: ['openmct'],
props: {
@ -38,10 +41,26 @@ export default {
condition: this.condition
};
},
destroyed() {
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
}
},
mounted() {
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
this.condition = obj;
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
}));
},
methods: {
handleConditionResult(args) {
this.$emit('conditionResultUpdated', {
id: this.conditionIdentifier,
result: args.data.result
})
}
}
}
</script>

View File

@ -1,3 +1,25 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, 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>
<section id="conditionCollection"
class="c-cs__ui_section"
@ -41,18 +63,20 @@
@dragover.prevent
></div>
<ConditionEdit :condition-identifier="conditionIdentifier"
:telemetry="telemetryObjs"
:current-condition-identifier="currentConditionIdentifier"
:condition-index="index"
@update-current-condition="updateCurrentCondition"
@remove-condition="removeCondition"
@updateCurrentCondition="updateCurrentCondition"
@removeCondition="removeCondition"
@clone-condition="cloneCondition"
@condition-result-updated="handleConditionResult"
@set-move-index="setMoveIndex"
@conditionResultUpdated="handleConditionResult"
@setMoveIndex="setMoveIndex"
/>
</div>
<div v-else>
<Condition :condition-identifier="conditionIdentifier"
:current-condition-identifier="currentConditionIdentifier"
@conditionResultUpdated="handleConditionResult"
/>
</div>
</li>
@ -67,7 +91,6 @@ import Condition from '../../condition/components/Condition.vue';
import ConditionEdit from '../../condition/components/ConditionEdit.vue';
import uuid from 'uuid';
export default {
inject: ['openmct', 'domainObject'],
components: {
@ -84,7 +107,9 @@ export default {
conditionCollection: [],
conditions: [],
currentConditionIdentifier: this.currentConditionIdentifier || {},
moveIndex: null
telemetryObjs: this.telemetryObjs,
moveIndex: Number,
isDragging: false
};
},
destroyed() {
@ -96,6 +121,7 @@ export default {
this.instantiate = this.openmct.$injector.get('instantiate');
this.composition = this.openmct.composition.get(this.domainObject);
this.composition.on('add', this.addTelemetry);
this.composition.on('remove', this.removeTelemetry);
this.composition.load();
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
if (!this.conditionCollection.length) {
@ -107,10 +133,11 @@ export default {
methods: {
setMoveIndex(index) {
this.moveIndex = index;
this.isDragging = true;
},
dropCondition(e) {
let targetIndex = Array.from(document.querySelectorAll('.c-c__drag-ghost')).indexOf(e.target);
if (targetIndex > this.moveIndex) { targetIndex-- }
if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move
const oldIndexArr = Object.keys(this.conditionCollection);
const move = function (arr, old_index, new_index) {
while (old_index < 0) {
@ -138,11 +165,12 @@ export default {
this.reorder(reorderPlan);
e.target.classList.remove("dragging");
this.isDragging = false;
},
dragEnter(e) {
if (!this.isDragging) { return }
let targetIndex = Array.from(document.querySelectorAll('.c-c__drag-ghost')).indexOf(e.target);
if (targetIndex > this.moveIndex) { targetIndex-- }
if (targetIndex > this.moveIndex) { targetIndex-- } // for 'downward' move
if (this.moveIndex === targetIndex) { return }
e.target.classList.add("dragging");
},
@ -164,11 +192,21 @@ export default {
break;
}
}
this.$emit('current-condition-updated', currentConditionIdentifier);
this.$emit('currentConditionUpdated', currentConditionIdentifier);
},
addTelemetry(telemetryDomainObject) {
this.telemetryObjs.push(telemetryDomainObject);
},
removeTelemetry(telemetryDomainObjectIdentifier) {
let index = _.findIndex(this.telemetryObjs, (obj) => {
let objId = this.openmct.objects.makeKeyString(obj.identifier);
let id = this.openmct.objects.makeKeyString(telemetryDomainObjectIdentifier);
return objId === id;
});
if (index > -1) {
this.telemetryObjs.splice(index, 1);
}
},
/*
Adds a condition to list via programatic creation of default for initial list, manual
creation via Add Condition button, or duplication via button in title bar of condition.
@ -180,15 +218,14 @@ export default {
index (number): index of condition being duplicated
*/
addCondition(event, isDefault, isClone, definition, index) {
let conditionDO = this.getConditionDomainObject(!!isDefault, isClone, definition);
//persist the condition DO so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
this.openmct.objects.mutate(conditionDO, 'created', new Date());
let conditionDomainObject = this.getConditionDomainObject(!!isDefault);
//persist the condition domain object so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
this.openmct.objects.mutate(conditionDomainObject, 'created', new Date());
if (!isClone) {
this.conditionCollection.unshift(conditionDO.identifier);
this.conditionCollection.unshift(conditionDomainObject.identifier);
} else {
this.conditionCollection.splice(index + 1, 0, conditionDO.identifier);
}
this.persist();
this.conditionCollection.splice(index + 1, 0, conditionDomainObject.identifier);
} this.persist();
},
updateCurrentCondition(identifier) {
this.currentConditionIdentifier = identifier;
@ -204,7 +241,7 @@ export default {
metaDataKey: this.openmct.telemetry.getMetadata(this.telemetryObjs[0]).values()[0].key,
key: this.telemetryObjs.length ? this.openmct.objects.makeKeyString(this.telemetryObjs[0].identifier) : null
}]
}
};
let conditionObj = {
isDefault: isDefault,
identifier: {
@ -214,10 +251,10 @@ export default {
definition: isClone ? definition: definitionTemplate,
summary: 'summary description'
};
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
let newDO = this.instantiate(conditionObj, conditionDOKeyString);
let conditionDomainObjectKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
let newDomainObject = this.instantiate(conditionObj, conditionDomainObjectKeyString);
return newDO.useCapability('adapter');
return newDomainObject.useCapability('adapter');
},
removeCondition(identifier) {
let index = _.findIndex(this.conditionCollection, (condition) => {

View File

@ -1,16 +1,37 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, 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>
<!-- TODO: current condition class should be set using openmct.objects.makeKeyString(<identifier>) -->
<div v-if="condition"
:data-condition-index="conditionIndex"
class="c-c-editui__conditions c-c-container__container c-c__drag-wrapper"
:class="['widget-condition', { 'widget-condition--current': currentConditionIdentifier && (currentConditionIdentifier.key === conditionIdentifier.key) }]"
>
<div class="title-bar">
<span class="c-c__menu-hamburger"
:class="{ 'is-enabled': !condition.isDefault }"
:draggable="!condition.isDefault"
@dragstart="dragStart"
@dragover.stop
>
<div class="title-bar">
<span
class="c-c__menu-hamburger"
:class="{ 'is-enabled': !condition.isDefault }"
></span>
<span
class="is-enabled flex-elem"
@ -19,6 +40,7 @@
></span>
<div class="condition-summary">
<span class="condition-name">{{ condition.definition.name }}</span>
<!-- TODO: description should be derived from criteria -->
<span class="condition-description">{{ condition.definition.name }}</span>
</div>
<span v-if="!condition.isDefault"
@ -86,17 +108,22 @@
</li>
</ul>
<ul class="t-widget-condition-config">
<li v-if="telemetryObject && telemetryMetadata"
<li v-if="telemetry.length"
class="has-local-controls t-condition"
>
<label>when</label>
<span class="t-configuration">
<span class="controls">
<select v-model="selectedTelemetryKey"
class=""
@change="updateTelemetryMetaData"
>
<option value="">- Select Telemetry -</option>
<option :value="telemetryObject.identifier">{{ telemetryObject.name }}</option>
<option v-for="telemetryOption in telemetry"
:key="telemetryOption.identifier.key"
:value="telemetryOption.identifier"
>
{{ telemetryOption.name }}
</option>
</select>
</span>
<span class="controls">
@ -111,8 +138,8 @@
</select>
</span>
<span class="controls">
<select v-model="selectedOperationKey"
@change="operationKeyChange"
<select v-model="selectOperationName"
@change="setInputValueVisibility"
>
<option value="">- Select Comparison -</option>
<option v-for="option in operations"
@ -125,7 +152,7 @@
<input v-if="comparisonValueField"
class="t-condition-name-input"
type="text"
@keyup="getOperationValue"
v-model="operationValue"
>
</span>
</span>
@ -155,6 +182,11 @@ export default {
type: Object,
required: true
},
telemetry: {
type: Array,
required: true,
default: () => []
},
conditionIndex: {
type: Number,
required: true
@ -167,12 +199,13 @@ export default {
telemetryObject: this.telemetryObject,
telemetryMetadata: this.telemetryMetadata,
operations: OPERATIONS,
selectedMetaDataKey: null,
selectedMetaDataKey: '',
selectedTelemetryKey: '',
selectedOperationKey: '',
selectedOutputKey: null,
selectOperationName: '',
selectedOutputKey: '',
stringOutputField: false,
comparisonValueField: false,
operationValue: this.operationValue,
outputOptions: [
{
key: 'false',
@ -191,41 +224,62 @@ export default {
};
},
destroyed() {
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
}
this.destroy();
},
mounted() {
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
this.condition = obj;
this.initialize();
}));
},
updated() {
//validate telemetry exists, update criteria as needed
this.validate();
this.persist();
},
methods: {
dragStart(e) {
e.dataTransfer.effectAllowed = "copyMove";
e.dataTransfer.setDragImage(e.target.closest('.c-c-container__container'), 0, 0);
this.$emit('setMoveIndex', this.conditionIndex);
},
initialize() {
this.setOutput();
this.setOperation();
this.updateTelemetry();
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this));
}));
this.dragGhost = document.getElementById('js-c-drag-ghost');
},
updated() {
if (this.isCurrent && this.isCurrent.key === this.condition.key) {
this.updateCurrentCondition();
destroy() {
this.conditionClass.off('conditionResultUpdated', this.handleConditionResult.bind(this));
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
delete this.conditionClass;
}
this.persist();
},
methods: {
dragStart(e) {
this.$emit('set-move-index', Number(e.target.getAttribute('data-condition-index')));
reset() {
this.selectedMetaDataKey = '';
this.selectedTelemetryKey = '';
this.selectOperationName = '';
this.operationValue = '';
},
validate() {
if (this.hasTelemetry() && !this.getTelemetryKey()) {
this.reset();
} else {
if (!this.conditionClass) {
this.initialize();
}
}
},
handleConditionResult(args) {
this.$emit('condition-result-updated', {
this.$emit('conditionResultUpdated', {
id: this.conditionIdentifier,
result: args.data.result
})
},
removeCondition(ev) {
this.$emit('remove-condition', this.conditionIdentifier);
this.$emit('removeCondition', this.conditionIdentifier);
},
cloneCondition(ev) {
this.$emit('clone-condition', {
@ -234,10 +288,11 @@ export default {
});
},
setOutput() {
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
let conditionOutput = this.condition.definition.output;
if (conditionOutput !== 'false' && conditionOutput !== 'true') {
this.selectedOutputKey = this.outputOptions[2].key;
} else {
if (this.condition.definition.output === 'true') {
if (conditionOutput === 'true') {
this.selectedOutputKey = this.outputOptions[1].key;
} else {
this.selectedOutputKey = this.outputOptions[0].key;
@ -248,7 +303,11 @@ export default {
if (this.condition.definition.criteria.length && this.condition.definition.criteria[0].operation) {
for (let i=0, ii=this.operations.length; i < ii; i++) {
if (this.condition.definition.criteria[0].operation === this.operations[i].name) {
this.selectedOperationKey = this.operations[i].name;
this.selectOperationName = this.operations[i].name;
this.comparisonValueField = this.operations[i].inputCount > 0;
if (this.comparisonValueField) {
this.operationValue = this.condition.definition.criteria[0].input[0];
}
}
}
}
@ -258,17 +317,47 @@ export default {
this.openmct.objects.get(this.condition.definition.criteria[0].key).then((obj) => {
this.telemetryObject = obj;
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
this.selectedMetaDataKey = '';
this.selectedTelemetryKey = this.telemetryObject.identifier;
this.selectedMetaDataKey = this.getTelemetryMetadataKey();
this.selectedTelemetryKey = this.getTelemetryKey();
});
} else {
this.telemetryObject = null;
}
},
getTelemetryMetadataKey() {
let index = -1;
if (this.condition.definition.criteria[0].metaDataKey) {
index = _.findIndex(this.telemetryMetadata, (metadata) => {
return metadata.key === this.condition.definition.criteria[0].metaDataKey;
});
}
return this.telemetryMetadata.length && index > -1 ? this.telemetryMetadata[index].key : '';
},
getTelemetryKey() {
let index = -1;
if (this.condition.definition.criteria[0].key) {
index = _.findIndex(this.telemetry, (obj) => {
let key = this.openmct.objects.makeKeyString(obj.identifier);
let conditionKey = this.openmct.objects.makeKeyString(this.condition.definition.criteria[0].key);
return key === conditionKey;
});
}
return this.telemetry.length && index > -1 ? this.telemetry[index].identifier : '';
},
hasTelemetry() {
return this.condition.definition.criteria.length && this.condition.definition.criteria[0].key;
},
updateConditionCriteria() {
if (this.condition.definition.criteria.length) {
let criterion = this.condition.definition.criteria[0];
criterion.key = this.selectedTelemetryKey;
criterion.metaDataKey = this.selectedMetaDataKey;
criterion.operation = this.selectOperationName;
criterion.input = [this.operationValue];
}
},
persist() {
this.updateConditionCriteria();
this.openmct.objects.mutate(this.condition, 'definition', this.condition.definition);
},
checkInputValue() {
@ -278,23 +367,22 @@ export default {
this.condition.definition.output = this.selectedOutputKey;
}
},
operationKeyChange(ev) {
if (ev.target.value !== 'isUndefined' && ev.target.value !== 'isDefined') {
this.comparisonValueField = true;
} else {
this.comparisonValueField = false;
setInputValueVisibility(ev) {
for (let i=0, ii=this.operations.length; i < ii; i++) {
if (this.selectOperationName === this.operations[i].name) {
this.comparisonValueField = this.operations[i].inputCount > 0;
break;
}
}
this.condition.definition.criteria[0].operation = this.selectedOperationKey;
this.persist();
//find the criterion being updated and set the operation property
},
getOperationValue(ev) {
this.condition.definition.criteria[0].input = [ev.target.value];
this.persist();
//find the criterion being updated and set the input property
updateTelemetryMetaData() {
this.selectedMetaDataKey = '';
this.updateConditionCriteria();
this.updateTelemetry();
},
updateCurrentCondition() {
this.$emit('update-current-condition', this.conditionIdentifier);
this.$emit('updateCurrentCondition', this.conditionIdentifier);
}
}
}

View File

@ -1,14 +1,34 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, 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-object-view u-contents">
<div class="c-cs-edit w-condition-set">
<div class="c-cs-edit w-condition-set">
<div class="c-sw-edit__ui holder">
<CurrentOutput :condition="currentCondition" />
<TestData :is-editing="isEditing" />
<ConditionCollection :is-editing="isEditing"
@current-condition-updated="updateCurrentCondition"
@currentConditionUpdated="updateCurrentCondition"
/>
</div>
</div>
</div>
</template>

View File

@ -1,3 +1,25 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, 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>
<section id="current-output">
<div v-if="condition"

View File

@ -1,83 +0,0 @@
/*****************************************************************************
* 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 v-show="isValidTarget">
<div
class="c-drop-hint c-drop-hint--always-show"
:class="{'is-mouse-over': isMouseOver}"
@dragover.prevent
@dragenter="dragenter"
@dragleave="dragleave"
@drop="dropHandler"
></div>
</div>
</template>
<script>
export default {
props:{
index: {
type: Number,
required: true
},
allowDrop: {
type: Function,
required: true
}
},
data() {
return {
isMouseOver: false,
isValidTarget: false
}
},
mounted() {
document.addEventListener('dragstart', this.dragstart);
document.addEventListener('dragend', this.dragend);
document.addEventListener('drop', this.dragend);
},
destroyed() {
document.removeEventListener('dragstart', this.dragstart);
document.removeEventListener('dragend', this.dragend);
document.removeEventListener('drop', this.dragend);
},
methods: {
dragenter() {
this.isMouseOver = true;
},
dragleave() {
this.isMouseOver = false;
},
dropHandler(event) {
this.$emit('object-drop-to', this.index, event);
this.isValidTarget = false;
},
dragstart(event) {
this.isValidTarget = this.allowDrop(event, this.index);
},
dragend() {
this.isValidTarget = false;
}
}
}
</script>

View File

@ -1,3 +1,25 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, 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>
<section v-show="isEditing"
id="test-data"

View File

@ -1,6 +1,6 @@
.widget-condition {
background-color: #eee;
margin: 0 0 5px;
margin: 0 0 0.33em;
border-radius: 3px;
&--current {
@ -137,7 +137,14 @@
}
}
.c-c__menu-hamburger {
&:active {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
}
&:before {
content: $glyph-icon-menu-hamburger;
}
@ -157,9 +164,9 @@
.c-c__drag-ghost {
width: 100%;
min-height: 5px;
min-height: 0.33em;
&.dragging {
min-height: 20px;
min-height: 2em;
border: solid 1px blue;
background-color: lightblue;
border-radius: 2px;

View File

@ -1,28 +1,13 @@
/**
* Returns true only if at least one of the results is true
**/
export const computeConditionForAny = (resultMap) => {
export const computeCondition = (resultMap, allMustBeTrue) => {
let result = false;
for (let key in resultMap) {
if (resultMap.hasOwnProperty(key)) {
result = resultMap[key];
if (result) {
break;
}
}
}
return result;
};
/**
* Returns true only if all the results are true
**/
export const computeConditionForAll = (resultMap) => {
let result = false;
for (let key in resultMap) {
if (resultMap.hasOwnProperty(key)) {
result = resultMap[key];
if (!result) {
if (allMustBeTrue && !result) {
//If we want all conditions to be true, then even one negative result should break.
break;
} else if (!allMustBeTrue && result) {
//If we want at least one condition to be true, then even one positive result should break.
break;
}
}

View File

@ -1,2 +0,0 @@
import Vue from 'vue';
export const EventBus = new Vue();