mirror of
https://github.com/nasa/openmct.git
synced 2025-06-06 01:11:41 +00:00
Added drag to enable edit mode
This commit is contained in:
parent
5382cca435
commit
92573b817f
@ -20,6 +20,7 @@
|
|||||||
"$scope",
|
"$scope",
|
||||||
"$route",
|
"$route",
|
||||||
"$location",
|
"$location",
|
||||||
|
"$q",
|
||||||
"objectService",
|
"objectService",
|
||||||
"navigationService",
|
"navigationService",
|
||||||
"urlService"
|
"urlService"
|
||||||
@ -34,7 +35,7 @@
|
|||||||
{
|
{
|
||||||
"key": "BrowseObjectController",
|
"key": "BrowseObjectController",
|
||||||
"implementation": "BrowseObjectController.js",
|
"implementation": "BrowseObjectController.js",
|
||||||
"depends": [ "$scope", "$location", "$route" ]
|
"depends": [ "$scope", "$location", "$route", "$q" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "CreateMenuController",
|
"key": "CreateMenuController",
|
||||||
@ -62,6 +63,7 @@
|
|||||||
{
|
{
|
||||||
"key": "browse-object",
|
"key": "browse-object",
|
||||||
"templateUrl": "templates/browse-object.html",
|
"templateUrl": "templates/browse-object.html",
|
||||||
|
"gestures": ["drop"],
|
||||||
"uses": [ "view" ]
|
"uses": [ "view" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -20,13 +20,8 @@
|
|||||||
at runtime from the About dialog for additional information.
|
at runtime from the About dialog for additional information.
|
||||||
-->
|
-->
|
||||||
<div ng-init="
|
<div ng-init="
|
||||||
editMode = false;
|
|
||||||
editBtns = [{ cssclass: 'save',title: 'Save Changes' },{ cssclass: 'cancel',title: 'Discard Changes' }];
|
editBtns = [{ cssclass: 'save',title: 'Save Changes' },{ cssclass: 'cancel',title: 'Discard Changes' }];
|
||||||
"></div>
|
"></div>
|
||||||
<a class="s-btn"
|
|
||||||
style="opacity: 0.9; position:absolute; right: 250px; z-index: 100"
|
|
||||||
ng-class="{ major:!editMode }"
|
|
||||||
ng-click="editMode = !editMode">Set EditMode to {{!editMode}}</a>
|
|
||||||
<span ng-controller="BrowseObjectController">
|
<span ng-controller="BrowseObjectController">
|
||||||
<div class="object-browse-bar bar l-flex">
|
<div class="object-browse-bar bar l-flex">
|
||||||
<div class="items-select left">
|
<div class="items-select left">
|
||||||
@ -50,16 +45,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="l-object-wrapper"
|
<div class="l-object-wrapper edit-main"
|
||||||
ng-class="{ active:editMode }">
|
ng-class="{ active:editMode }">
|
||||||
<div class="l-object-wrapper-inner l-flex flex-col">
|
<div class="l-object-wrapper-inner l-flex flex-col">
|
||||||
<!-- Toolbar and Save/Cancel buttons -->
|
<!-- Toolbar and Save/Cancel buttons -->
|
||||||
<div class="l-edit-controls flex-elem l-flex flex-row"
|
<div class="l-edit-controls flex-elem l-flex flex-row"
|
||||||
ng-class="{ active:editMode }">
|
ng-class="{ active:editMode }">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<mct-toolbar name="mctToolbar"
|
<mct-toolbar name="mctToolbar"
|
||||||
structure="toolbar.structure"
|
structure="toolbar.structure"
|
||||||
ng-model="toolbar.state"
|
ng-model="toolbar.state"
|
||||||
@ -80,10 +72,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<mct-representation key="'edit-action-buttons'"
|
<!--<mct-representation key="'edit-action-buttons'"
|
||||||
mct-object="domainObject"
|
mct-object="domainObject"
|
||||||
class='flex-elem conclude-editing'>
|
class='flex-elem conclude-editing'>
|
||||||
</mct-representation>
|
</mct-representation> -->
|
||||||
<!-- from edit-action-buttons.html -->
|
<!-- from edit-action-buttons.html -->
|
||||||
<!--<span>
|
<!--<span>
|
||||||
<span ng-repeat="btn in editBtns">
|
<span ng-repeat="btn in editBtns">
|
||||||
|
@ -26,8 +26,11 @@
|
|||||||
* @namespace platform/commonUI/browse
|
* @namespace platform/commonUI/browse
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
[],
|
[
|
||||||
function () {
|
'../../../representation/src/gestures/GestureConstants',
|
||||||
|
'../../edit/src/objects/EditableDomainObject'
|
||||||
|
],
|
||||||
|
function (GestureConstants, EditableDomainObject) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var ROOT_ID = "ROOT",
|
var ROOT_ID = "ROOT",
|
||||||
@ -43,7 +46,7 @@ define(
|
|||||||
* @memberof platform/commonUI/browse
|
* @memberof platform/commonUI/browse
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function BrowseController($scope, $route, $location, objectService, navigationService, urlService) {
|
function BrowseController($scope, $route, $location, $q, objectService, navigationService, urlService) {
|
||||||
var path = [ROOT_ID].concat(
|
var path = [ROOT_ID].concat(
|
||||||
($route.current.params.ids || DEFAULT_PATH).split("/")
|
($route.current.params.ids || DEFAULT_PATH).split("/")
|
||||||
);
|
);
|
||||||
@ -71,7 +74,9 @@ define(
|
|||||||
// Callback for updating the in-scope reference to the object
|
// Callback for updating the in-scope reference to the object
|
||||||
// that is currently navigated-to.
|
// that is currently navigated-to.
|
||||||
function setNavigation(domainObject) {
|
function setNavigation(domainObject) {
|
||||||
$scope.navigatedObject = domainObject;
|
var navigatedDomainObject = domainObject;
|
||||||
|
|
||||||
|
$scope.navigatedObject = navigatedDomainObject;
|
||||||
$scope.treeModel.selectedObject = domainObject;
|
$scope.treeModel.selectedObject = domainObject;
|
||||||
navigationService.setNavigation(domainObject);
|
navigationService.setNavigation(domainObject);
|
||||||
updateRoute(domainObject);
|
updateRoute(domainObject);
|
||||||
@ -154,6 +159,8 @@ define(
|
|||||||
navigationService.removeListener(setNavigation);
|
navigationService.removeListener(setNavigation);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.editMode = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return BrowseController;
|
return BrowseController;
|
||||||
|
@ -22,8 +22,9 @@
|
|||||||
/*global define,Promise*/
|
/*global define,Promise*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
[],
|
['../../../representation/src/gestures/GestureConstants',
|
||||||
function () {
|
'../../edit/src/objects/EditableDomainObject'],
|
||||||
|
function (GestureConstants, EditableDomainObject) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,8 +33,9 @@ define(
|
|||||||
* @memberof platform/commonUI/browse
|
* @memberof platform/commonUI/browse
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function BrowseObjectController($scope, $location, $route) {
|
function BrowseObjectController($scope, $location, $route, $q) {
|
||||||
function setViewForDomainObject(domainObject) {
|
function setViewForDomainObject(domainObject) {
|
||||||
|
|
||||||
var locationViewKey = $location.search().view;
|
var locationViewKey = $location.search().view;
|
||||||
|
|
||||||
function selectViewIfMatching(view) {
|
function selectViewIfMatching(view) {
|
||||||
@ -65,8 +67,23 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleEditMode(editMode){
|
||||||
|
var domainObject = $scope.domainObject;
|
||||||
|
if (editMode){
|
||||||
|
$scope.domainObject = domainObject && new EditableDomainObject(domainObject, $q);
|
||||||
|
} else {
|
||||||
|
$scope.domainObject = (domainObject.getDomainObject && domainObject.getDomainObject) || domainObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.$watch('editMode', toggleEditMode);
|
||||||
$scope.$watch('domainObject', setViewForDomainObject);
|
$scope.$watch('domainObject', setViewForDomainObject);
|
||||||
$scope.$watch('representation.selected.key', updateQueryParam);
|
$scope.$watch('representation.selected.key', updateQueryParam);
|
||||||
|
|
||||||
|
$scope.$on(GestureConstants.MCT_DROP_EVENT, function() {
|
||||||
|
$scope.editMode = true;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return BrowseObjectController;
|
return BrowseObjectController;
|
||||||
|
@ -102,6 +102,10 @@ define(
|
|||||||
capability;
|
capability;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
editableObject.getDomainObject = function() {
|
||||||
|
return domainObject;
|
||||||
|
}
|
||||||
|
|
||||||
return editableObject;
|
return editableObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
mct-object="childObject">
|
mct-object="childObject">
|
||||||
</mct-representation>
|
</mct-representation>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Drag handles -->
|
<!-- Drag handles -->
|
||||||
<span ng-show="domainObject.hasCapability('editor')">
|
<span ng-show="domainObject.hasCapability('editor')">
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ define(
|
|||||||
// If currently in edit mode allow drag and drop gestures to the
|
// If currently in edit mode allow drag and drop gestures to the
|
||||||
// domain object. An exception to this is folders which have drop
|
// domain object. An exception to this is folders which have drop
|
||||||
// gestures in browse mode.
|
// gestures in browse mode.
|
||||||
if (domainObjectType === 'folder' || domainObject.hasCapability('editor')) {
|
//if (domainObjectType === 'folder' || domainObject.hasCapability('editor')) {
|
||||||
|
|
||||||
// Handle the drop; add the dropped identifier to the
|
// Handle the drop; add the dropped identifier to the
|
||||||
// destination domain object's composition, and persist
|
// destination domain object's composition, and persist
|
||||||
@ -108,7 +108,7 @@ define(
|
|||||||
broadcastDrop(id, event);
|
broadcastDrop(id, event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
// TODO: Alert user if drag and drop is not allowed
|
// TODO: Alert user if drag and drop is not allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user