[Fixed] Specify default layout grid (#1296)

* [Fixed] Specify default layout grid

Previously users would see blank values for grid size
even though a default was applied.  Users will now
see default values for grid size which should prevent
them from accidentally changing grid size.

Fixes https://github.com/nasa/openmct/issues/1285

* [Fixed] Don't hardcode grid size

Remove hardcoded grid size per comments.

https://github.com/nasa/openmct/pull/1296#issuecomment-259231499

* [Fixed] read layout before initial refresh

Read the layoutGrid sizes from scope (when watch is registered)
before refreshing elements, to ensure that layoutGrid is set
properly.

https://github.com/nasa/openmct/pull/1296#issuecomment-259231499

* [Spec] Update spec to match

Update spec to trigger watch on initialization to ensure
layoutGrid is set.

https://github.com/nasa/openmct/pull/1296
This commit is contained in:
Pete Richards 2016-11-08 14:59:09 -08:00 committed by Andrew Henry
parent 67b763c4c0
commit 5b6f95bd4a
3 changed files with 7 additions and 7 deletions

View File

@ -204,6 +204,7 @@ define([
}
],
"model": {
"layoutGrid": [64, 16],
"composition": []
},
"properties": [

View File

@ -24,8 +24,7 @@ define(
['./FixedProxy', './elements/ElementProxies', './FixedDragHandle'],
function (FixedProxy, ElementProxies, FixedDragHandle) {
var DEFAULT_DIMENSIONS = [2, 1],
DEFAULT_GRID_SIZE = [64, 16];
var DEFAULT_DIMENSIONS = [2, 1];
/**
* The FixedController is responsible for supporting the
@ -132,7 +131,7 @@ define(
// Update element positions when grid size changes
function updateElementPositions(layoutGrid) {
// Update grid size from model
self.gridSize = layoutGrid || DEFAULT_GRID_SIZE;
self.gridSize = layoutGrid;
self.elementProxies.forEach(function (elementProxy) {
elementProxy.style = convertPosition(elementProxy);
@ -293,7 +292,6 @@ define(
});
}
this.gridSize = DEFAULT_GRID_SIZE;
this.elementProxies = [];
this.generateDragHandle = generateDragHandle;
this.generateDragHandles = generateDragHandles;
@ -310,15 +308,15 @@ define(
}
}.bind(this));
// Detect changes to grid size
$scope.$watch("model.layoutGrid", updateElementPositions);
// Refresh list of elements whenever model changes
$scope.$watch("model.modified", refreshElements);
// Position panes when the model field changes
$scope.$watch("model.composition", updateComposition);
// Detect changes to grid size
$scope.$watch("model.layoutGrid", updateElementPositions);
// Subscribe to telemetry when an object is available
$scope.$watch("domainObject", subscribe);

View File

@ -147,6 +147,7 @@ define(
mockFormatter
);
findWatch("model.layoutGrid")(testModel.layoutGrid);
findWatch("selection")(mockScope.selection);
});