Fix bug where changeURL was not updating to reflect its change object
Computed bindings are recomputed (say, on a model update), when the arguments to the computation function change. Since no arguments were being passed to changeURL(), it was only being computed once. In order to maintain a clean API for external callers, move changeURL from a function to a computed property. This way the caller doesn't have to pass in the change number but it still updates when the change number does. Bug: Issue 3689 Change-Id: I92a659b3c917f77d4e212c98af7c763174756074
This commit is contained in:
@@ -76,7 +76,7 @@ limitations under the License.
|
|||||||
<span class="positionIndicator">▶</span>
|
<span class="positionIndicator">▶</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href$="[[changeURL()]]">[[change.subject]]</a>
|
<a href$="[[changeURL]]">[[change.subject]]</a>
|
||||||
</td>
|
</td>
|
||||||
<td>[[_computeChangeStatusString(change)]]</td>
|
<td>[[_computeChangeStatusString(change)]]</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -118,11 +118,15 @@ limitations under the License.
|
|||||||
reflectToAttribute: true,
|
reflectToAttribute: true,
|
||||||
},
|
},
|
||||||
change: Object,
|
change: Object,
|
||||||
|
changeURL: {
|
||||||
|
type: String,
|
||||||
|
computed: '_computeChangeURL(change._number)',
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changeURL: function() {
|
_computeChangeURL: function(changeNum) {
|
||||||
if (!this.change) { return ''; }
|
if (!changeNum) { return ''; }
|
||||||
return '/c/' + this.change._number + '/';
|
return '/c/' + changeNum + '/';
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeChangeStatusString: function(change) {
|
_computeChangeStatusString: function(change) {
|
||||||
|
@@ -111,7 +111,7 @@ limitations under the License.
|
|||||||
_changeURLForIndex: function(index) {
|
_changeURLForIndex: function(index) {
|
||||||
var changeEls = this._getNonHeaderListItems();
|
var changeEls = this._getNonHeaderListItems();
|
||||||
if (index < changeEls.length && changeEls[index]) {
|
if (index < changeEls.length && changeEls[index]) {
|
||||||
return changeEls[index].changeURL();
|
return changeEls[index].changeURL;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
@@ -82,7 +82,9 @@ limitations under the License.
|
|||||||
'/q/status:open+project:combustible-stuff+branch:lemons');
|
'/q/status:open+project:combustible-stuff+branch:lemons');
|
||||||
|
|
||||||
element.change = { _number: 42 };
|
element.change = { _number: 42 };
|
||||||
assert.equal(element.changeURL(), '/c/42/');
|
assert.equal(element.changeURL, '/c/42/');
|
||||||
|
element.change = { _number: 43 };
|
||||||
|
assert.equal(element.changeURL, '/c/43/');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user