Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Polymer element for displaying network nameserver options. | 6 * @fileoverview Polymer element for displaying network nameserver options. |
| 7 */ | 7 */ |
| 8 Polymer({ | 8 Polymer({ |
| 9 is: 'network-nameservers', | 9 is: 'network-nameservers', |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 }, | 36 }, |
| 37 }, | 37 }, |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * The selected nameserver type. | 40 * The selected nameserver type. |
| 41 * @private | 41 * @private |
| 42 */ | 42 */ |
| 43 nameserversType_: { | 43 nameserversType_: { |
| 44 type: String, | 44 type: String, |
| 45 value: 'automatic', | 45 value: 'automatic', |
| 46 observer: 'nameserversTypeChanged_', | |
| 46 }, | 47 }, |
| 47 | 48 |
| 48 /** | 49 /** |
| 49 * Array of nameserver types. | 50 * Array of nameserver types. |
| 50 * @private | 51 * @private |
| 51 */ | 52 */ |
| 52 nameserverTypeNames_: { | 53 nameserverTypeNames_: { |
| 53 type: Array, | 54 type: Array, |
| 54 value: ['automatic', 'google', 'custom'], | 55 value: ['automatic', 'google', 'custom'], |
| 55 readOnly: true, | 56 readOnly: true, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 type = 'google'; | 96 type = 'google'; |
| 96 } else { | 97 } else { |
| 97 type = 'custom'; | 98 type = 'custom'; |
| 98 } | 99 } |
| 99 } else { | 100 } else { |
| 100 type = 'automatic'; | 101 type = 'automatic'; |
| 101 } | 102 } |
| 102 this.setNameservers_(type, nameservers); | 103 this.setNameservers_(type, nameservers); |
| 103 }, | 104 }, |
| 104 | 105 |
| 106 /** @private */ | |
| 107 nameserversTypeChanged_: function() { | |
| 108 this.$.nameserverType.value = this.nameserversType_; | |
|
dpapad
2016/10/17 22:57:05
I don't think this observer needed? You can use a
stevenjb
2016/10/17 23:10:19
Hmm, I'm not sure I understand how using data bind
stevenjb
2016/10/17 23:58:01
After looking over the settings-dropdown-menu impl
| |
| 109 }, | |
| 110 | |
| 105 /** | 111 /** |
| 106 * @param {string} nameserversType | 112 * @param {string} nameserversType |
| 107 * @param {!Array<string>} nameservers | 113 * @param {!Array<string>} nameservers |
| 108 * @private | 114 * @private |
| 109 */ | 115 */ |
| 110 setNameservers_: function(nameserversType, nameservers) { | 116 setNameservers_: function(nameserversType, nameservers) { |
| 111 this.nameserversType_ = nameserversType; | 117 this.nameserversType_ = nameserversType; |
| 112 if (nameserversType == 'custom') { | 118 if (nameserversType == 'custom') { |
| 113 // Add empty entries for unset custom nameservers. | 119 // Add empty entries for unset custom nameservers. |
| 114 for (let i = nameservers.length; i < this.MAX_NAMESERVERS; ++i) | 120 for (let i = nameservers.length; i < this.MAX_NAMESERVERS; ++i) |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 135 * @return {boolean} True if the nameservers are editable. | 141 * @return {boolean} True if the nameservers are editable. |
| 136 * @private | 142 * @private |
| 137 */ | 143 */ |
| 138 canEdit_: function() { | 144 canEdit_: function() { |
| 139 return this.editable && this.nameserversType_ == 'custom'; | 145 return this.editable && this.nameserversType_ == 'custom'; |
| 140 }, | 146 }, |
| 141 | 147 |
| 142 /** | 148 /** |
| 143 * Event triggered when the selected type changes. Updates nameservers and | 149 * Event triggered when the selected type changes. Updates nameservers and |
| 144 * sends the change value if necessary. | 150 * sends the change value if necessary. |
| 145 * @param {!{detail: !{selected: string}}} e | 151 * @param {!{target: !{value: string}}} e |
|
dpapad
2016/10/17 22:57:05
Same here.
stevenjb
2016/10/17 23:58:01
Acknowledged.
| |
| 146 * @private | 152 * @private |
| 147 */ | 153 */ |
| 148 onTypeChange_: function(e) { | 154 onTypeChange_: function(e) { |
| 149 if (this.nameserversType_ == 'custom') | 155 if (this.nameserversType_ == 'custom') |
| 150 this.savedNameservers_ = this.nameservers_; | 156 this.savedNameservers_ = this.nameservers_; |
| 151 var type = e.detail.selected; | 157 var type = e.target.value; |
| 152 this.nameserversType_ = type; | 158 this.nameserversType_ = type; |
| 153 if (type == 'custom') { | 159 if (type == 'custom') { |
| 154 // Restore the saved nameservers. | 160 // Restore the saved nameservers. |
| 155 this.setNameservers_(type, this.savedNameservers_); | 161 this.setNameservers_(type, this.savedNameservers_); |
| 156 // Only send custom nameservers if they are not empty. | 162 // Only send custom nameservers if they are not empty. |
| 157 if (this.savedNameservers_.length == 0) | 163 if (this.savedNameservers_.length == 0) |
| 158 return; | 164 return; |
| 159 } | 165 } |
| 160 this.sendNameServers_(); | 166 this.sendNameServers_(); |
| 161 }, | 167 }, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 }); | 208 }); |
| 203 } else { | 209 } else { |
| 204 // automatic | 210 // automatic |
| 205 this.fire('nameservers-change', { | 211 this.fire('nameservers-change', { |
| 206 field: 'NameServersConfigType', | 212 field: 'NameServersConfigType', |
| 207 value: CrOnc.IPConfigType.DHCP, | 213 value: CrOnc.IPConfigType.DHCP, |
| 208 }); | 214 }); |
| 209 } | 215 } |
| 210 }, | 216 }, |
| 211 }); | 217 }); |
| OLD | NEW |