mirror of
https://github.com/nasa/openmct.git
synced 2025-04-09 04:14:32 +00:00
working new folder action
This commit is contained in:
parent
31ac67b393
commit
51c9328dfd
@ -268,6 +268,7 @@ define([
|
||||
this.install(this.plugins.ConditionWidget());
|
||||
this.install(this.plugins.URLTimeSettingsSynchronizer());
|
||||
this.install(this.plugins.NotificationIndicator());
|
||||
this.install(this.plugins.NewFolderAction());
|
||||
}
|
||||
|
||||
MCT.prototype = Object.create(EventEmitter.prototype);
|
||||
|
80
src/plugins/newFolderAction/newFolderAction.js
Normal file
80
src/plugins/newFolderAction/newFolderAction.js
Normal file
@ -0,0 +1,80 @@
|
||||
/*****************************************************************************
|
||||
* 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.
|
||||
*****************************************************************************/
|
||||
|
||||
import uuid from 'uuid';
|
||||
|
||||
export default class NewFolderAction {
|
||||
constructor(openmct) {
|
||||
this.name = 'New Folder';
|
||||
this.key = 'newFolder';
|
||||
this.description = 'Create a new folder';
|
||||
this.cssClass = 'icon-folder';
|
||||
|
||||
this._openmct = openmct;
|
||||
this._dialogService = openmct.$injector.get('dialogService');
|
||||
this._folderType = openmct.types.get('folder');
|
||||
this._dialogForm = {
|
||||
name: "New Folder Name",
|
||||
sections: [
|
||||
{
|
||||
rows: [
|
||||
{
|
||||
key: "name",
|
||||
control: "textfield",
|
||||
name: "Folder Name",
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
invoke(objectPath) {
|
||||
let domainObject = objectPath[0],
|
||||
parentKeystring = this._openmct.objects.makeKeyString(domainObject.identifier),
|
||||
composition = this._openmct.composition.get(domainObject);
|
||||
|
||||
this._dialogService.getUserInput(this._dialogForm, {}).then((userInput) => {
|
||||
let name = userInput.name,
|
||||
identifier = {
|
||||
key: uuid(),
|
||||
namespace: domainObject.identifier.namespace
|
||||
},
|
||||
objectModel = {
|
||||
identifier,
|
||||
type: 'folder',
|
||||
location: parentKeystring
|
||||
};
|
||||
|
||||
this._folderType.definition.initialize(objectModel);
|
||||
objectModel.name = name;
|
||||
|
||||
this._openmct.objects.mutate(objectModel, 'created', Date.now());
|
||||
composition.add(objectModel);
|
||||
});
|
||||
}
|
||||
appliesTo(objectPath) {
|
||||
let domainObject = objectPath[0];
|
||||
|
||||
return domainObject.type === 'folder';
|
||||
}
|
||||
}
|
30
src/plugins/newFolderAction/plugin.js
Normal file
30
src/plugins/newFolderAction/plugin.js
Normal file
@ -0,0 +1,30 @@
|
||||
/*****************************************************************************
|
||||
* 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 NewFolderAction from './newFolderAction';
|
||||
|
||||
export default function () {
|
||||
return function (openmct) {
|
||||
openmct.on('start', () => {
|
||||
openmct.contextMenu.registerAction(new NewFolderAction(openmct));
|
||||
});
|
||||
};
|
||||
}
|
@ -53,7 +53,8 @@ define([
|
||||
'./themes/maelstrom',
|
||||
'./themes/snow',
|
||||
'./URLTimeSettingsSynchronizer/plugin',
|
||||
'./notificationIndicator/plugin'
|
||||
'./notificationIndicator/plugin',
|
||||
'./newFolderAction/plugin'
|
||||
], function (
|
||||
_,
|
||||
UTCTimeSystem,
|
||||
@ -87,7 +88,8 @@ define([
|
||||
Maelstrom,
|
||||
Snow,
|
||||
URLTimeSettingsSynchronizer,
|
||||
NotificationIndicator
|
||||
NotificationIndicator,
|
||||
NewFolderAction
|
||||
) {
|
||||
var bundleMap = {
|
||||
LocalStorage: 'platform/persistence/local',
|
||||
@ -198,6 +200,7 @@ define([
|
||||
plugins.ConditionWidget = ConditionWidgetPlugin.default;
|
||||
plugins.URLTimeSettingsSynchronizer = URLTimeSettingsSynchronizer.default;
|
||||
plugins.NotificationIndicator = NotificationIndicator.default;
|
||||
plugins.NewFolderAction = NewFolderAction.default;
|
||||
|
||||
return plugins;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user