From 32da19a4869edc7054fe21d4be60a0af571cc2a9 Mon Sep 17 00:00:00 2001 From: charlesh88 Date: Wed, 25 Mar 2020 16:19:46 -0700 Subject: [PATCH] New Condition Widget, WIP - Add new Vue components, mod configs; --- index.html | 2 +- src/MCT.js | 1 + .../ConditionWidgetViewProvider.js | 65 +++++++++++++++++++ .../components/ConditionWidget.vue | 16 +++++ src/plugins/conditionWidget/plugin.js | 52 +++++++++++++++ src/plugins/plugins.js | 3 + 6 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 src/plugins/conditionWidget/ConditionWidgetViewProvider.js create mode 100644 src/plugins/conditionWidget/components/ConditionWidget.vue create mode 100644 src/plugins/conditionWidget/plugin.js diff --git a/index.html b/index.html index bb5ed70d51..095e80b594 100644 --- a/index.html +++ b/index.html @@ -43,7 +43,7 @@ openmct.legacyRegistry.enable.bind(openmct.legacyRegistry) ); - openmct.install(openmct.plugins.Snow()); + openmct.install(openmct.plugins.Espresso()); openmct.install(openmct.plugins.MyItems()); openmct.install(openmct.plugins.LocalStorage()); openmct.install(openmct.plugins.Generator()); diff --git a/src/MCT.js b/src/MCT.js index 14a3b46a46..d9292cbcd1 100644 --- a/src/MCT.js +++ b/src/MCT.js @@ -265,6 +265,7 @@ define([ this.install(this.plugins.ImportExport()); this.install(this.plugins.WebPage()); this.install(this.plugins.Condition()); + this.install(this.plugins.ConditionWidget()); } MCT.prototype = Object.create(EventEmitter.prototype); diff --git a/src/plugins/conditionWidget/ConditionWidgetViewProvider.js b/src/plugins/conditionWidget/ConditionWidgetViewProvider.js new file mode 100644 index 0000000000..879cf0c019 --- /dev/null +++ b/src/plugins/conditionWidget/ConditionWidgetViewProvider.js @@ -0,0 +1,65 @@ +/***************************************************************************** + * Open MCT, Copyright (c) 2014-2019, 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. + *****************************************************************************/ + +import ConditionWidgetComponent from './components/ConditionWidget.vue'; +import Vue from 'vue'; + +export default function ConditionWidget(openmct) { + return { + key: 'conditionWidget', + name: 'Condition Widget', + cssClass: 'icon-asterisk', + objectClass: 'o-condition-widget', + canView: function (domainObject) { + return domainObject.type === 'conditionWidget'; + }, + canEdit: function (domainObject) { + return domainObject.type === 'conditionWidget'; + }, + view: function (domainObject) { + let component; + + return { + show: function (element) { + component = new Vue({ + el: element, + components: { + ConditionWidgetComponent: ConditionWidgetComponent + }, + provide: { + openmct, + domainObject + }, + template: '' + }); + }, + destroy: function (element) { + component.$destroy(); + component = undefined; + } + }; + }, + priority: function () { + return 1; + } + }; +} diff --git a/src/plugins/conditionWidget/components/ConditionWidget.vue b/src/plugins/conditionWidget/components/ConditionWidget.vue new file mode 100644 index 0000000000..d86d0b9f18 --- /dev/null +++ b/src/plugins/conditionWidget/components/ConditionWidget.vue @@ -0,0 +1,16 @@ + + + diff --git a/src/plugins/conditionWidget/plugin.js b/src/plugins/conditionWidget/plugin.js new file mode 100644 index 0000000000..f9f3df9183 --- /dev/null +++ b/src/plugins/conditionWidget/plugin.js @@ -0,0 +1,52 @@ +/***************************************************************************** + * 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. + *****************************************************************************/ + +import ConditionWidgetViewProvider from './ConditionWidgetViewProvider.js'; + +export default function plugin() { + return function install(openmct) { + openmct.objectViews.addProvider(new ConditionWidgetViewProvider(openmct)); + + openmct.types.addType('conditionWidget', { + name: "Condition Widget", + description: "Condition Widget description TBD", + creatable: true, + cssClass: 'icon-asterisk', + form: [ + { + "key": "label", + "name": "Label", + "control": "textfield", + "required": true, + "cssClass": "l-input" + }, + { + "key": "url", + "name": "URL", + "control": "textfield", + "required": false, + "cssClass": "l-input-lg" + } + ] + }); + }; +} diff --git a/src/plugins/plugins.js b/src/plugins/plugins.js index 7492b95340..cfba102cc3 100644 --- a/src/plugins/plugins.js +++ b/src/plugins/plugins.js @@ -48,6 +48,7 @@ define([ './clearData/plugin', './webPage/plugin', './condition/plugin', + './conditionWidget/plugin', './themes/espresso', './themes/maelstrom', './themes/snow' @@ -79,6 +80,7 @@ define([ ClearData, WebPagePlugin, ConditionPlugin, + ConditionWidgetPlugin, Espresso, Maelstrom, Snow @@ -188,6 +190,7 @@ define([ plugins.Maelstrom = Maelstrom.default; plugins.Snow = Snow.default; plugins.Condition = ConditionPlugin.default; + plugins.ConditionWidget = ConditionWidgetPlugin.default; return plugins; });