| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 'import-supervised-user' is a dialog that allows user to select | 6 * @fileoverview 'import-supervised-user' is a dialog that allows user to select |
| 7 * a supervised profile from a list of profiles to import on the current device. | 7 * a supervised profile from a list of profiles to import on the current device. |
| 8 */ | 8 */ |
| 9 (function() { | 9 (function() { |
| 10 /** | 10 /** |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 }, | 44 }, |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * Index of the selected supervised user. | 47 * Index of the selected supervised user. |
| 48 * @private {number} | 48 * @private {number} |
| 49 */ | 49 */ |
| 50 supervisedUserIndex_: {type: Number, value: NO_USER_SELECTED} | 50 supervisedUserIndex_: {type: Number, value: NO_USER_SELECTED} |
| 51 }, | 51 }, |
| 52 | 52 |
| 53 /** override */ | |
| 54 ready: function() { | |
| 55 this.$.dialog.lastFocusableNode = this.$.cancel; | |
| 56 }, | |
| 57 | |
| 58 /** | 53 /** |
| 59 * Displays the dialog. | 54 * Displays the dialog. |
| 60 * @param {(!SignedInUser|undefined)} signedInUser | 55 * @param {(!SignedInUser|undefined)} signedInUser |
| 61 * @param {!Array<!SupervisedUser>} supervisedUsers | 56 * @param {!Array<!SupervisedUser>} supervisedUsers |
| 62 */ | 57 */ |
| 63 show: function(signedInUser, supervisedUsers) { | 58 show: function(signedInUser, supervisedUsers) { |
| 64 this.supervisedUsers_ = supervisedUsers; | 59 this.supervisedUsers_ = supervisedUsers; |
| 65 this.supervisedUsers_.sort(function(a, b) { | 60 this.supervisedUsers_.sort(function(a, b) { |
| 66 if (a.onCurrentDevice != b.onCurrentDevice) | 61 if (a.onCurrentDevice != b.onCurrentDevice) |
| 67 return a.onCurrentDevice ? 1 : -1; | 62 return a.onCurrentDevice ? 1 : -1; |
| 68 return a.name.localeCompare(b.name); | 63 return a.name.localeCompare(b.name); |
| 69 }); | 64 }); |
| 70 | 65 |
| 71 this.supervisedUserIndex_ = NO_USER_SELECTED; | 66 this.supervisedUserIndex_ = NO_USER_SELECTED; |
| 72 | 67 |
| 73 this.signedInUser_ = signedInUser || null; | 68 this.signedInUser_ = signedInUser || null; |
| 74 if (this.signedInUser_) | 69 if (this.signedInUser_) |
| 75 this.$.dialog.open(); | 70 this.$.dialog.showModal(); |
| 76 }, | 71 }, |
| 77 | 72 |
| 78 /** | 73 /** |
| 79 * param {number} supervisedUserIndex Index of the selected supervised user. | 74 * @param {number} supervisedUserIndex Index of the selected supervised user. |
| 75 * @return {boolean} Whether the 'Import' button should be disabled. |
| 80 * @private | 76 * @private |
| 81 * @return {boolean} Whether the 'Import' button should be disabled. | |
| 82 */ | 77 */ |
| 83 isImportDisabled_: function(supervisedUserIndex) { | 78 isImportDisabled_: function(supervisedUserIndex) { |
| 84 var disabled = supervisedUserIndex == NO_USER_SELECTED; | 79 return supervisedUserIndex == NO_USER_SELECTED; |
| 85 if (!disabled) { | |
| 86 this.$.dialog.lastFocusableNode = this.$.import; | |
| 87 } | |
| 88 return disabled; | |
| 89 }, | 80 }, |
| 90 | 81 |
| 91 /** | 82 /** |
| 92 * Called when the user clicks the 'Import' button. it proceeds with importing | 83 * Called when the user clicks the 'Import' button. it proceeds with importing |
| 93 * the supervised user. | 84 * the supervised user. |
| 94 * @private | 85 * @private |
| 95 */ | 86 */ |
| 96 onImportTap_: function() { | 87 onImportTap_: function() { |
| 97 var supervisedUser = this.supervisedUsers_[this.supervisedUserIndex_]; | 88 var supervisedUser = this.supervisedUsers_[this.supervisedUserIndex_]; |
| 98 if (this.signedInUser_ && supervisedUser) { | 89 if (this.signedInUser_ && supervisedUser) { |
| 99 this.$.dialog.close(); | 90 this.$.dialog.close(); |
| 100 // Event is caught by create-profile. | 91 // Event is caught by create-profile. |
| 101 this.fire( | 92 this.fire( |
| 102 'import', | 93 'import', |
| 103 {supervisedUser: supervisedUser, signedInUser: this.signedInUser_}); | 94 {supervisedUser: supervisedUser, signedInUser: this.signedInUser_}); |
| 104 } | 95 } |
| 105 } | 96 }, |
| 97 |
| 98 /** @private */ |
| 99 onCancelTap_: function() { |
| 100 this.$.dialog.close(); |
| 101 }, |
| 106 }); | 102 }); |
| 107 })(); | 103 })(); |
| OLD | NEW |