Skip to content

Commit

Permalink
[Fixed] Specify default layout grid (#1296)
Browse files Browse the repository at this point in the history
* [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 #1285

* [Fixed] Don't hardcode grid size

Remove hardcoded grid size per comments.

#1296 (comment)

* [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.

#1296 (comment)

* [Spec] Update spec to match

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

#1296
  • Loading branch information
larkin authored and akhenry committed Nov 8, 2016
1 parent 67b763c commit 5b6f95b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions platform/features/fixed/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ define([
}
],
"model": {
"layoutGrid": [64, 16],
"composition": []
},
"properties": [
Expand Down
12 changes: 5 additions & 7 deletions platform/features/layout/src/FixedController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -293,7 +292,6 @@ define(
});
}

this.gridSize = DEFAULT_GRID_SIZE;
this.elementProxies = [];
this.generateDragHandle = generateDragHandle;
this.generateDragHandles = generateDragHandles;
Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions platform/features/layout/test/FixedControllerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ define(
mockFormatter
);

findWatch("model.layoutGrid")(testModel.layoutGrid);
findWatch("selection")(mockScope.selection);
});

Expand Down

0 comments on commit 5b6f95b

Please sign in to comment.