Skip to content

Commit

Permalink
Planner: fix wrong scales when changing the displayMode
Browse files Browse the repository at this point in the history
When the 'displayMode' is changed on the server model, the scales might
be rendered incorrectly. Reason: Calling setDisplayMode() will
automatically update the 'viewRange' property. Because this is triggered
via a property change listener, the JsonPlanner adapter will be notified
about 'viewRange' before 'displayMode'. On the UI, _renderViewRange
calls _renderScale, which relies on the displayMode.

Fix: ensure property changes for 'displayMode' are processed before any
other properties.

222829

Change-Id: I8f58ef37e615149904a63e3ed611d4540c0b133d
Reviewed-on: https://git.eclipse.org/r/c/scout/org.eclipse.scout.rt/+/174688
Tested-by: Scout Bot <scout-bot@eclipse.org>
Reviewed-by: Claudio Guglielmo <claudio.guglielmo@bsiag.com>
Reviewed-by: Beat Schwarzentrub <bsh@bsiag.com>
  • Loading branch information
bschwarzent committed Jan 15, 2021
1 parent d6f6a32 commit 9a46432
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,3 @@ scout.ValueFieldAdapter.prototype._syncDisplayText = function(displayText) {
this.widget.setDisplayText(displayText);
this.widget.parseAndSetValue(displayText);
};

scout.ValueFieldAdapter.prototype._createPropertySortFunc = function(order) {
return function(a, b) {
var ia = order.indexOf(a);
var ib = order.indexOf(b);
if (ia > -1 && ib > -1) { // both are in the list
return ia - ib;
}
if (ia > -1) { // B is not in list
return -1;
}
if (ib > -1) { // A is not in list
return 1;
}
return scout.comparators.TEXT.compare(a, b); // both are not in list
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ scout.PlannerAdapter = function() {
};
scout.inherits(scout.PlannerAdapter, scout.ModelAdapter);

scout.PlannerAdapter.PROPERTIES_ORDER = ['displayMode', 'viewRange'];

scout.PlannerAdapter.prototype._orderPropertyNamesOnSync = function(newProperties) {
return Object.keys(newProperties).sort(this._createPropertySortFunc(scout.PlannerAdapter.PROPERTIES_ORDER));
};

scout.PlannerAdapter.prototype._sendViewRange = function(viewRange) {
this._send('property', {
viewRange: scout.dates.toJsonDateRange(viewRange)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,23 @@ scout.ModelAdapter.prototype._orderPropertyNamesOnSync = function(newProperties)
return Object.keys(newProperties);
};

scout.ModelAdapter.prototype._createPropertySortFunc = function(order) {
return function(a, b) {
var ia = order.indexOf(a);
var ib = order.indexOf(b);
if (ia > -1 && ib > -1) { // both are in the list
return ia - ib;
}
if (ia > -1) { // B is not in list
return -1;
}
if (ib > -1) { // A is not in list
return 1;
}
return scout.comparators.TEXT.compare(a, b); // both are not in list
};
};

/**
* Called by Session.js for every event from the model
*/
Expand Down

0 comments on commit 9a46432

Please sign in to comment.