mirror of
https://github.com/nasa/openmct.git
synced 2025-04-07 11:26:49 +00:00
[Layout] Store position/size changes
Store changes to the size and position of panels in a layout to its configuration. The mct-representation directive (and its constituent parts) is responsible for detecting and persisting these changes as appropriate. WTD-535.
This commit is contained in:
parent
a6de53c118
commit
7dadc62f23
@ -15,6 +15,15 @@ define(
|
||||
rawPositions = {},
|
||||
positions = {};
|
||||
|
||||
|
||||
function shallowCopy(obj, keys) {
|
||||
var copy = {};
|
||||
keys.forEach(function (k) {
|
||||
copy[k] = obj[k];
|
||||
});
|
||||
return copy;
|
||||
}
|
||||
|
||||
function convertPosition(raw) {
|
||||
return {
|
||||
left: (width * raw.position[0]) + 'px',
|
||||
@ -39,10 +48,11 @@ define(
|
||||
}
|
||||
|
||||
function lookupPanels(model) {
|
||||
var configuration =
|
||||
((model || {}).configuration || {}).layout || {};
|
||||
var configuration = $scope.configuration || {},
|
||||
ids = (model || {}).composition || [];
|
||||
|
||||
// Clear prior positions
|
||||
rawPositions = shallowCopy(configuration.panels || {}, ids);
|
||||
positions = {};
|
||||
|
||||
// Update width/height that we are tracking
|
||||
@ -50,7 +60,7 @@ define(
|
||||
// Pull values from panels field to rawPositions
|
||||
|
||||
// Compute positions and add defaults where needed
|
||||
((model || {}).composition || []).forEach(populatePosition);
|
||||
ids.forEach(populatePosition);
|
||||
}
|
||||
|
||||
$scope.$watch("model", lookupPanels);
|
||||
@ -76,7 +86,14 @@ define(
|
||||
}
|
||||
},
|
||||
endDrag: function () {
|
||||
// TODO: Mutate, persist
|
||||
// Write to configuration; this is watched and
|
||||
// saved by the EditRepresenter.
|
||||
$scope.configuration =
|
||||
$scope.configuration || {};
|
||||
$scope.configuration.panels =
|
||||
$scope.configuration.panels || {};
|
||||
$scope.configuration.panels[activeDragId] =
|
||||
rawPositions[activeDragId];
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user