Merge "Sync patch set dropdowns on navigation"
This commit is contained in:
@@ -18,6 +18,7 @@ limitations under the License.
|
|||||||
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior.html">
|
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior.html">
|
||||||
<link rel="import" href="../../../behaviors/rest-client-behavior.html">
|
<link rel="import" href="../../../behaviors/rest-client-behavior.html">
|
||||||
<link rel="import" href="../../shared/gr-account-link/gr-account-link.html">
|
<link rel="import" href="../../shared/gr-account-link/gr-account-link.html">
|
||||||
|
<link rel="import" href="../../shared/gr-select/gr-select.html">
|
||||||
<link rel="import" href="../../shared/gr-button/gr-button.html">
|
<link rel="import" href="../../shared/gr-button/gr-button.html">
|
||||||
<link rel="import" href="../../shared/gr-change-star/gr-change-star.html">
|
<link rel="import" href="../../shared/gr-change-star/gr-change-star.html">
|
||||||
<link rel="import" href="../../shared/gr-date-formatter/gr-date-formatter.html">
|
<link rel="import" href="../../shared/gr-date-formatter/gr-date-formatter.html">
|
||||||
@@ -206,7 +207,7 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="container loading" hidden$="{{!_loading}}">Loading...</div>
|
<div class="container loading" hidden$="[[!_loading]]">Loading...</div>
|
||||||
<div class="container" hidden$="{{_loading}}">
|
<div class="container" hidden$="{{_loading}}">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<span class="header-title">
|
<span class="header-title">
|
||||||
@@ -231,7 +232,7 @@ limitations under the License.
|
|||||||
<div id="change_plugins"></div>
|
<div id="change_plugins"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="changeInfo-column mainChangeInfo">
|
<div class="changeInfo-column mainChangeInfo">
|
||||||
<div class="commitActions" hidden$="[[!_loggedIn]]"">
|
<div class="commitActions" hidden$="[[!_loggedIn]]">
|
||||||
<gr-button
|
<gr-button
|
||||||
class="reply"
|
class="reply"
|
||||||
secondary
|
secondary
|
||||||
@@ -261,18 +262,24 @@ limitations under the License.
|
|||||||
<div class="relatedChanges">
|
<div class="relatedChanges">
|
||||||
<gr-related-changes-list id="relatedChanges"
|
<gr-related-changes-list id="relatedChanges"
|
||||||
change="[[_change]]"
|
change="[[_change]]"
|
||||||
patch-num="[[_computeLatestPatchNum(_allPatchSets)]]"></gr-related-changes-list>
|
patch-num="[[_computeLatestPatchNum(_allPatchSets)]]">
|
||||||
|
</gr-related-changes-list>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class$="patchInfo [[_computePatchInfoClass(_patchRange.patchNum, _allPatchSets)]]">
|
<section class$="patchInfo [[_computePatchInfoClass(_patchRange.patchNum,
|
||||||
|
_allPatchSets)]]">
|
||||||
<div class="patchInfo-header">
|
<div class="patchInfo-header">
|
||||||
<div>
|
<div>
|
||||||
<label class="patchSelectLabel" for="patchSetSelect">Patch set</label>
|
<label class="patchSelectLabel" for="patchSetSelect">
|
||||||
<select id="patchSetSelect" on-change="_handlePatchChange">
|
Patch set
|
||||||
<template is="dom-repeat" items="[[_allPatchSets]]" as="patchNumber">
|
</label>
|
||||||
<option value$="[[patchNumber]]" selected$="[[_computePatchIndexIsSelected(index, _patchRange.patchNum)]]">
|
<select id="patchSetSelect" bind-value="{{_selectedPatchSet}}"
|
||||||
|
is="gr-select" on-change="_handlePatchChange">
|
||||||
|
<template is="dom-repeat" items="[[_allPatchSets]]"
|
||||||
|
as="patchNumber">
|
||||||
|
<option value$="[[patchNumber]]">
|
||||||
<span>[[patchNumber]]</span>
|
<span>[[patchNumber]]</span>
|
||||||
/
|
/
|
||||||
<span>[[_computeLatestPatchNum(_allPatchSets)]]</span>
|
<span>[[_computeLatestPatchNum(_allPatchSets)]]</span>
|
||||||
|
@@ -73,7 +73,10 @@
|
|||||||
type: String,
|
type: String,
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
_patchRange: Object,
|
_patchRange: {
|
||||||
|
type: Object,
|
||||||
|
observer: '_updateSelected',
|
||||||
|
},
|
||||||
_allPatchSets: {
|
_allPatchSets: {
|
||||||
type: Array,
|
type: Array,
|
||||||
computed: '_computeAllPatchSets(_change)',
|
computed: '_computeAllPatchSets(_change)',
|
||||||
@@ -89,6 +92,7 @@
|
|||||||
value: 'Reply',
|
value: 'Reply',
|
||||||
computed: '_computeReplyButtonLabel(_diffDrafts.*)',
|
computed: '_computeReplyButtonLabel(_diffDrafts.*)',
|
||||||
},
|
},
|
||||||
|
_selectedPatchSet: String,
|
||||||
_initialLoadComplete: {
|
_initialLoadComplete: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
@@ -458,6 +462,8 @@
|
|||||||
this._patchRange.patchNum ||
|
this._patchRange.patchNum ||
|
||||||
this._computeLatestPatchNum(this._allPatchSets));
|
this._computeLatestPatchNum(this._allPatchSets));
|
||||||
|
|
||||||
|
this._updateSelected();
|
||||||
|
|
||||||
var title = change.subject + ' (' + change.change_id.substr(0, 9) + ')';
|
var title = change.subject + ' (' + change.change_id.substr(0, 9) + ')';
|
||||||
this.fire('title-change', {title: title});
|
this.fire('title-change', {title: title});
|
||||||
},
|
},
|
||||||
@@ -528,10 +534,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_computePatchIndexIsSelected: function(index, patchNum) {
|
|
||||||
return this._allPatchSets[index] == patchNum;
|
|
||||||
},
|
|
||||||
|
|
||||||
_computeLabelNames: function(labels) {
|
_computeLabelNames: function(labels) {
|
||||||
return Object.keys(labels).sort();
|
return Object.keys(labels).sort();
|
||||||
},
|
},
|
||||||
@@ -776,5 +778,9 @@
|
|||||||
this.$.fileList.reload(),
|
this.$.fileList.reload(),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_updateSelected: function() {
|
||||||
|
this._selectedPatchSet = this._patchRange.patchNum;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
@@ -277,12 +277,10 @@ limitations under the License.
|
|||||||
var optionEls = Polymer.dom(element.root).querySelectorAll(
|
var optionEls = Polymer.dom(element.root).querySelectorAll(
|
||||||
'.patchInfo-header option');
|
'.patchInfo-header option');
|
||||||
assert.equal(optionEls.length, 4);
|
assert.equal(optionEls.length, 4);
|
||||||
assert.isFalse(element.$$('.patchInfo-header option[value="1"]')
|
var select = element.$$('.patchInfo-header #patchSetSelect').bindValue;
|
||||||
.hasAttribute('selected'));
|
assert.notEqual(select, 1);
|
||||||
assert.isTrue(element.$$('.patchInfo-header option[value="2"]')
|
assert.equal(select, 2);
|
||||||
.hasAttribute('selected'));
|
assert.notEqual(select, 3);
|
||||||
assert.isFalse(element.$$('.patchInfo-header option[value="3"]')
|
|
||||||
.hasAttribute('selected'));
|
|
||||||
assert.equal(optionEls[3].value, 13);
|
assert.equal(optionEls[3].value, 13);
|
||||||
|
|
||||||
var showStub = sandbox.stub(page, 'show');
|
var showStub = sandbox.stub(page, 'show');
|
||||||
@@ -329,12 +327,12 @@ limitations under the License.
|
|||||||
var optionEls = Polymer.dom(element.root).querySelectorAll(
|
var optionEls = Polymer.dom(element.root).querySelectorAll(
|
||||||
'.patchInfo-header option');
|
'.patchInfo-header option');
|
||||||
assert.equal(optionEls.length, 4);
|
assert.equal(optionEls.length, 4);
|
||||||
assert.isFalse(element.$$('.patchInfo-header option[value="1"]')
|
assert.notEqual(
|
||||||
.hasAttribute('selected'));
|
element.$$('.patchInfo-header #patchSetSelect').bindValue, 1);
|
||||||
assert.isTrue(element.$$('.patchInfo-header option[value="2"]')
|
assert.equal(
|
||||||
.hasAttribute('selected'));
|
element.$$('.patchInfo-header #patchSetSelect').bindValue, 2);
|
||||||
assert.isFalse(element.$$('.patchInfo-header option[value="3"]')
|
assert.notEqual(
|
||||||
.hasAttribute('selected'));
|
element.$$('.patchInfo-header #patchSetSelect').bindValue, 3);
|
||||||
assert.equal(optionEls[3].value, 13);
|
assert.equal(optionEls[3].value, 13);
|
||||||
|
|
||||||
var showStub = sandbox.stub(page, 'show');
|
var showStub = sandbox.stub(page, 'show');
|
||||||
|
@@ -22,6 +22,7 @@ limitations under the License.
|
|||||||
<link rel="import" href="../../shared/gr-button/gr-button.html">
|
<link rel="import" href="../../shared/gr-button/gr-button.html">
|
||||||
<link rel="import" href="../../shared/gr-linked-text/gr-linked-text.html">
|
<link rel="import" href="../../shared/gr-linked-text/gr-linked-text.html">
|
||||||
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||||
|
<link rel="import" href="../../shared/gr-select/gr-select.html">
|
||||||
|
|
||||||
<dom-module id="gr-file-list">
|
<dom-module id="gr-file-list">
|
||||||
<template>
|
<template>
|
||||||
@@ -182,13 +183,17 @@ limitations under the License.
|
|||||||
<span class="separator">/</span>
|
<span class="separator">/</span>
|
||||||
<label>
|
<label>
|
||||||
Diff against
|
Diff against
|
||||||
<select id="patchChange" on-change="_handlePatchChange">
|
<select id="patchChange" bind-value="{{_diffAgainst}}" is="gr-select"
|
||||||
|
on-change="_handlePatchChange">
|
||||||
<option value="PARENT">Base</option>
|
<option value="PARENT">Base</option>
|
||||||
<template is="dom-repeat" items="[[_computePatchSets(revisions, patchRange.*)]]" as="patchNum">
|
<template
|
||||||
<option
|
is="dom-repeat"
|
||||||
value$="[[patchNum]]"
|
items="[[_computePatchSets(revisions, patchRange.*)]]"
|
||||||
selected$="[[_computePatchSetSelected(patchNum, patchRange.basePatchNum)]]"
|
as="patchNum">
|
||||||
disabled$="[[_computePatchSetDisabled(patchNum, patchRange.patchNum)]]">[[patchNum]]</option>
|
<option value$="[[patchNum]]" disabled$=
|
||||||
|
"[[_computePatchSetDisabled(patchNum, patchRange.patchNum)]]">
|
||||||
|
[[patchNum]]
|
||||||
|
</option>
|
||||||
</template>
|
</template>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
@@ -207,7 +212,8 @@ limitations under the License.
|
|||||||
<div class$="[[_computeClass('status', file.__path)]]">
|
<div class$="[[_computeClass('status', file.__path)]]">
|
||||||
[[_computeFileStatus(file.status)]]
|
[[_computeFileStatus(file.status)]]
|
||||||
</div>
|
</div>
|
||||||
<a class="path" href$="[[_computeDiffURL(changeNum, patchRange, file.__path)]]">
|
<a class="path"
|
||||||
|
href$="[[_computeDiffURL(changeNum, patchRange, file.__path)]]">
|
||||||
<div title$="[[_computeFileDisplayName(file.__path)]]">
|
<div title$="[[_computeFileDisplayName(file.__path)]]">
|
||||||
[[_computeFileDisplayName(file.__path)]]
|
[[_computeFileDisplayName(file.__path)]]
|
||||||
</div>
|
</div>
|
||||||
@@ -217,7 +223,9 @@ limitations under the License.
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="comments">
|
<div class="comments">
|
||||||
<span class="drafts">[[_computeDraftsString(drafts, patchRange.patchNum, file.__path)]]</span>
|
<span class="drafts">
|
||||||
|
[[_computeDraftsString(drafts, patchRange.patchNum, file.__path)]]
|
||||||
|
</span>
|
||||||
[[_computeCommentsString(comments, patchRange.patchNum, file.__path)]]
|
[[_computeCommentsString(comments, patchRange.patchNum, file.__path)]]
|
||||||
</div>
|
</div>
|
||||||
<div class$="[[_computeClass('stats', file.__path)]]">
|
<div class$="[[_computeClass('stats', file.__path)]]">
|
||||||
|
@@ -25,7 +25,10 @@
|
|||||||
is: 'gr-file-list',
|
is: 'gr-file-list',
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
patchRange: Object,
|
patchRange: {
|
||||||
|
type: Object,
|
||||||
|
observer: '_updateSelected',
|
||||||
|
},
|
||||||
patchNum: String,
|
patchNum: String,
|
||||||
changeNum: String,
|
changeNum: String,
|
||||||
comments: Object,
|
comments: Object,
|
||||||
@@ -58,6 +61,7 @@
|
|||||||
type: Array,
|
type: Array,
|
||||||
value: function() { return []; },
|
value: function() { return []; },
|
||||||
},
|
},
|
||||||
|
_diffAgainst: String,
|
||||||
_diffPrefs: Object,
|
_diffPrefs: Object,
|
||||||
_userPrefs: Object,
|
_userPrefs: Object,
|
||||||
_localPrefs: Object,
|
_localPrefs: Object,
|
||||||
@@ -181,10 +185,6 @@
|
|||||||
return parseInt(patchNum, 10) >= parseInt(currentPatchNum, 10);
|
return parseInt(patchNum, 10) >= parseInt(currentPatchNum, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
_computePatchSetSelected: function(patchNum, basePatchNum) {
|
|
||||||
return parseInt(patchNum, 10) === parseInt(basePatchNum, 10);
|
|
||||||
},
|
|
||||||
|
|
||||||
_handleHiddenChange: function(e) {
|
_handleHiddenChange: function(e) {
|
||||||
var model = e.model;
|
var model = e.model;
|
||||||
model.set('file.__expanded', !model.file.__expanded);
|
model.set('file.__expanded', !model.file.__expanded);
|
||||||
@@ -527,6 +527,10 @@
|
|||||||
this._numFilesShown = this._files.length;
|
this._numFilesShown = this._files.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_updateSelected: function(patchRange) {
|
||||||
|
this._diffAgainst = patchRange.basePatchNum;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _getDiffViewMode: Get the diff view (side-by-side or unified) based on
|
* _getDiffViewMode: Get the diff view (side-by-side or unified) based on
|
||||||
* the current state.
|
* the current state.
|
||||||
|
@@ -436,7 +436,7 @@ limitations under the License.
|
|||||||
document.getElementById('blank').restore();
|
document.getElementById('blank').restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('show/hide diffs disabled for large amounds of files', function(done) {
|
test('show/hide diffs disabled for large amounts of files', function(done) {
|
||||||
element._files = [];
|
element._files = [];
|
||||||
element.changeNum = '42';
|
element.changeNum = '42';
|
||||||
element.patchRange = {
|
element.patchRange = {
|
||||||
|
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
<link rel="import" href="../../shared/gr-select/gr-select.html">
|
||||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||||
|
|
||||||
<dom-module id="gr-patch-range-select">
|
<dom-module id="gr-patch-range-select">
|
||||||
@@ -28,12 +28,11 @@ limitations under the License.
|
|||||||
</style>
|
</style>
|
||||||
Patch set:
|
Patch set:
|
||||||
<span class="patchRange">
|
<span class="patchRange">
|
||||||
<select id="leftPatchSelect" on-change="_handlePatchChange">
|
<select id="leftPatchSelect" bind-value="{{_leftSelected}}"
|
||||||
<option value="PARENT"
|
on-change="_handlePatchChange" is="gr-select">
|
||||||
selected$="[[_computeLeftSelected('PARENT', patchRange)]]">Base</option>
|
<option value="PARENT">Base</option>
|
||||||
<template is="dom-repeat" items="{{availablePatches}}" as="patchNum">
|
<template is="dom-repeat" items="{{availablePatches}}" as="patchNum">
|
||||||
<option value$="[[patchNum]]"
|
<option value$="[[patchNum]]"
|
||||||
selected$="[[_computeLeftSelected(patchNum, patchRange)]]"
|
|
||||||
disabled$="[[_computeLeftDisabled(patchNum, patchRange)]]">[[patchNum]]</option>
|
disabled$="[[_computeLeftDisabled(patchNum, patchRange)]]">[[patchNum]]</option>
|
||||||
</template>
|
</template>
|
||||||
</select>
|
</select>
|
||||||
@@ -46,10 +45,10 @@ limitations under the License.
|
|||||||
</span>
|
</span>
|
||||||
→
|
→
|
||||||
<span class="patchRange">
|
<span class="patchRange">
|
||||||
<select id="rightPatchSelect" on-change="_handlePatchChange">
|
<select id="rightPatchSelect" bind-value="{{_rightSelected}}"
|
||||||
|
on-change="_handlePatchChange" is="gr-select">
|
||||||
<template is="dom-repeat" items="{{availablePatches}}" as="patchNum">
|
<template is="dom-repeat" items="{{availablePatches}}" as="patchNum">
|
||||||
<option value$="[[patchNum]]"
|
<option value$="[[patchNum]]"
|
||||||
selected$="[[_computeRightSelected(patchNum, patchRange)]]"
|
|
||||||
disabled$="[[_computeRightDisabled(patchNum, patchRange)]]">[[patchNum]]</option>
|
disabled$="[[_computeRightDisabled(patchNum, patchRange)]]">[[patchNum]]</option>
|
||||||
</template>
|
</template>
|
||||||
</select>
|
</select>
|
||||||
|
@@ -21,13 +21,23 @@
|
|||||||
availablePatches: Array,
|
availablePatches: Array,
|
||||||
changeNum: String,
|
changeNum: String,
|
||||||
filesWeblinks: Object,
|
filesWeblinks: Object,
|
||||||
patchRange: Object,
|
|
||||||
path: String,
|
path: String,
|
||||||
|
patchRange: {
|
||||||
|
type: Object,
|
||||||
|
observer: '_updateSelected'
|
||||||
|
},
|
||||||
|
_rightSelected: String,
|
||||||
|
_leftSelected: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateSelected: function() {
|
||||||
|
this._rightSelected = this.patchRange.patchNum;
|
||||||
|
this._leftSelected = this.patchRange.basePatchNum;
|
||||||
},
|
},
|
||||||
|
|
||||||
_handlePatchChange: function(e) {
|
_handlePatchChange: function(e) {
|
||||||
var leftPatch = this.$.leftPatchSelect.value;
|
var leftPatch = this._leftSelected;
|
||||||
var rightPatch = this.$.rightPatchSelect.value;
|
var rightPatch = this._rightSelected;
|
||||||
var rangeStr = rightPatch;
|
var rangeStr = rightPatch;
|
||||||
if (leftPatch != 'PARENT') {
|
if (leftPatch != 'PARENT') {
|
||||||
rangeStr = leftPatch + '..' + rangeStr;
|
rangeStr = leftPatch + '..' + rangeStr;
|
||||||
@@ -36,14 +46,6 @@
|
|||||||
e.target.blur();
|
e.target.blur();
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeLeftSelected: function(patchNum, patchRange) {
|
|
||||||
return patchNum == patchRange.basePatchNum;
|
|
||||||
},
|
|
||||||
|
|
||||||
_computeRightSelected: function(patchNum, patchRange) {
|
|
||||||
return patchNum == patchRange.patchNum;
|
|
||||||
},
|
|
||||||
|
|
||||||
_computeLeftDisabled: function(patchNum, patchRange) {
|
_computeLeftDisabled: function(patchNum, patchRange) {
|
||||||
return parseInt(patchNum, 10) >= parseInt(patchRange.patchNum, 10);
|
return parseInt(patchNum, 10) >= parseInt(patchRange.patchNum, 10);
|
||||||
},
|
},
|
||||||
@@ -52,5 +54,18 @@
|
|||||||
if (patchRange.basePatchNum == 'PARENT') { return false; }
|
if (patchRange.basePatchNum == 'PARENT') { return false; }
|
||||||
return parseInt(patchNum, 10) <= parseInt(patchRange.basePatchNum, 10);
|
return parseInt(patchNum, 10) <= parseInt(patchRange.basePatchNum, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// On page load, the dom-if for options getting added occurs after
|
||||||
|
// the value was set in the select. This ensures that after they
|
||||||
|
// are loaded, the correct value will get selected. I attempted to
|
||||||
|
// debounce these, but because they are detecting two different
|
||||||
|
// events, sometimes the timing was off and one ended up missing.
|
||||||
|
_synchronizeSelectionRight: function() {
|
||||||
|
this.$.rightPatchSelect.value = this._rightSelected;
|
||||||
|
},
|
||||||
|
|
||||||
|
_synchronizeSelectionLeft: function() {
|
||||||
|
this.$.leftPatchSelect.value = this._leftSelected;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
@@ -67,6 +67,10 @@ limitations under the License.
|
|||||||
element.changeNum = '42';
|
element.changeNum = '42';
|
||||||
element.path = 'path/to/file.txt';
|
element.path = 'path/to/file.txt';
|
||||||
element.availablePatches = ['1', '2', '3'];
|
element.availablePatches = ['1', '2', '3'];
|
||||||
|
element.patchRange = {
|
||||||
|
basePatchNum: 'PARENT',
|
||||||
|
patchNum: '3',
|
||||||
|
};
|
||||||
flushAsynchronousOperations();
|
flushAsynchronousOperations();
|
||||||
|
|
||||||
var numEvents = 0;
|
var numEvents = 0;
|
||||||
|
@@ -16,40 +16,33 @@
|
|||||||
|
|
||||||
Polymer({
|
Polymer({
|
||||||
is: 'gr-select',
|
is: 'gr-select',
|
||||||
|
|
||||||
extends: 'select',
|
extends: 'select',
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
bindValue: {
|
bindValue: {
|
||||||
type: String,
|
type: String,
|
||||||
notify: true,
|
notify: true,
|
||||||
|
observer: '_updateValue',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
observers: [
|
listeners: {
|
||||||
'_valueChanged(bindValue)',
|
change: '_valueChanged',
|
||||||
],
|
'dom-change': '_updateValue',
|
||||||
|
},
|
||||||
|
|
||||||
attached: function() {
|
_updateValue: function() {
|
||||||
this.addEventListener('change', function() {
|
if (this.bindValue) {
|
||||||
|
this.value = this.bindValue;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_valueChanged: function() {
|
||||||
this.bindValue = this.value;
|
this.bindValue = this.value;
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ready: function() {
|
ready: function() {
|
||||||
// If not set via the property, set bind-value to the element value.
|
// If not set via the property, set bind-value to the element value.
|
||||||
if (!this.bindValue) { this.bindValue = this.value; }
|
if (!this.bindValue) { this.bindValue = this.value; }
|
||||||
},
|
},
|
||||||
|
|
||||||
_valueChanged: function(bindValue) {
|
|
||||||
var options = Polymer.dom(this.root).querySelectorAll('option');
|
|
||||||
for (var i = 0; i < options.length; i++) {
|
|
||||||
if (options[i].getAttribute('value') === bindValue + '') {
|
|
||||||
options[i].setAttribute('selected', true);
|
|
||||||
this.value = bindValue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
Reference in New Issue
Block a user