Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/resources/md_bookmarks/toolbar.js

Issue 2912893002: MD Bookmarks: Support policies for disabling bookmark editing (Closed)
Patch Set: Review comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 Polymer({ 5 Polymer({
6 is: 'bookmarks-toolbar', 6 is: 'bookmarks-toolbar',
7 7
8 behaviors: [ 8 behaviors: [
9 bookmarks.StoreClient, 9 bookmarks.StoreClient,
10 ], 10 ],
11 11
12 properties: { 12 properties: {
13 /** @private */ 13 /** @private */
14 searchTerm_: { 14 searchTerm_: {
15 type: String, 15 type: String,
16 observer: 'onSearchTermChanged_', 16 observer: 'onSearchTermChanged_',
17 }, 17 },
18 18
19 sidebarWidth: { 19 sidebarWidth: {
20 type: String, 20 type: String,
21 observer: 'onSidebarWidthChanged_', 21 observer: 'onSidebarWidthChanged_',
22 }, 22 },
23 23
24 showSelectionOverlay: { 24 showSelectionOverlay: {
25 type: Boolean, 25 type: Boolean,
26 computed: 'shouldShowSelectionOverlay_(selectedCount_)', 26 computed: 'shouldShowSelectionOverlay_(selectedItems_, canEdit_)',
27 readOnly: true, 27 readOnly: true,
28 reflectToAttribute: true, 28 reflectToAttribute: true,
29 }, 29 },
30 30
31 /** @private */ 31 /** @private */
32 narrow_: { 32 narrow_: {
33 type: Boolean, 33 type: Boolean,
34 reflectToAttribute: true, 34 reflectToAttribute: true,
35 }, 35 },
36 36
37 /** @private {!Set<string>} */
38 selectedItems_: Object,
39
37 /** @private */ 40 /** @private */
38 selectedCount_: Number, 41 canEdit_: Boolean,
42
43 /** @private */
44 selectedFolder_: String,
45
46 /** @private */
47 canChangeList_: {
48 type: Boolean,
49 computed: 'computeCanChangeList_(selectedFolder_, searchTerm_, canEdit_)',
50 }
39 }, 51 },
40 52
41 attached: function() { 53 attached: function() {
42 this.watch('searchTerm_', function(state) { 54 this.watch('searchTerm_', function(state) {
43 return state.search.term; 55 return state.search.term;
44 }); 56 });
45 this.watch('selectedCount_', function(state) { 57 this.watch('selectedItems_', function(state) {
46 return state.selection.items.size; 58 return state.selection.items;
59 });
60 this.watch('canEdit_', function(state) {
61 return state.prefs.canEdit;
62 });
63 this.watch('selectedFolder_', function(state) {
64 return state.selectedFolder;
47 }); 65 });
48 this.updateFromStore(); 66 this.updateFromStore();
49 }, 67 },
50 68
51 /** @return {CrToolbarSearchFieldElement} */ 69 /** @return {CrToolbarSearchFieldElement} */
52 get searchField() { 70 get searchField() {
53 return /** @type {CrToolbarElement} */ (this.$$('cr-toolbar')) 71 return /** @type {CrToolbarElement} */ (this.$$('cr-toolbar'))
54 .getSearchField(); 72 .getSearchField();
55 }, 73 },
56 74
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 154
137 /** @private */ 155 /** @private */
138 onSearchTermChanged_: function() { 156 onSearchTermChanged_: function() {
139 this.searchField.setValue(this.searchTerm_ || ''); 157 this.searchField.setValue(this.searchTerm_ || '');
140 }, 158 },
141 159
142 /** 160 /**
143 * @return {boolean} 161 * @return {boolean}
144 * @private 162 * @private
145 */ 163 */
146 hasSearchTerm_: function() { 164 computeCanChangeList_: function() {
147 return !!this.searchTerm_; 165 return !this.searchTerm_ &&
166 bookmarks.util.canReorderChildren(
167 this.getState(), this.selectedFolder_);
148 }, 168 },
149 169
150 /** 170 /**
151 * @return {boolean} 171 * @return {boolean}
152 * @private 172 * @private
153 */ 173 */
154 shouldShowSelectionOverlay_: function() { 174 shouldShowSelectionOverlay_: function() {
155 return this.selectedCount_ > 1; 175 return this.selectedItems_.size > 1 && this.canEdit_;
176 },
177
178 canDeleteSelection_: function() {
179 return bookmarks.CommandManager.getInstance().canExecute(
180 Command.DELETE, this.selectedItems_);
156 }, 181 },
157 182
158 /** 183 /**
159 * @return {string} 184 * @return {string}
160 * @private 185 * @private
161 */ 186 */
162 getItemsSelectedString_: function() { 187 getItemsSelectedString_: function() {
163 return loadTimeData.getStringF('itemsSelected', this.selectedCount_); 188 return loadTimeData.getStringF('itemsSelected', this.selectedItems_.size);
164 }, 189 },
165 }); 190 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698