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

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

Issue 2973783002: [MD Bookmarks] Prevent sorting of empty folders. (Closed)
Patch Set: remove flushes Created 3 years, 5 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 ],
(...skipping 26 matching lines...) Expand all
37 /** @private {!Set<string>} */ 37 /** @private {!Set<string>} */
38 selectedItems_: Object, 38 selectedItems_: Object,
39 39
40 /** @private */ 40 /** @private */
41 globalCanEdit_: Boolean, 41 globalCanEdit_: Boolean,
42 42
43 /** @private */ 43 /** @private */
44 selectedFolder_: String, 44 selectedFolder_: String,
45 45
46 /** @private */ 46 /** @private */
47 canSortFolder_: {
48 type: Boolean,
49 computed: 'computeCanSortFolder_(canChangeList_, selectedFolder_)',
50 },
51
52 /** @private */
47 canChangeList_: { 53 canChangeList_: {
48 type: Boolean, 54 type: Boolean,
49 computed: 55 computed:
50 'computeCanChangeList_(selectedFolder_, searchTerm_, globalCanEdit_)', 56 'computeCanChangeList_(selectedFolder_, searchTerm_, globalCanEdit_)',
51 } 57 }
52 }, 58 },
53 59
54 attached: function() { 60 attached: function() {
55 this.watch('searchTerm_', function(state) { 61 this.watch('searchTerm_', function(state) {
56 return state.search.term; 62 return state.search.term;
(...skipping 20 matching lines...) Expand all
77 * @param {Event} e 83 * @param {Event} e
78 * @private 84 * @private
79 */ 85 */
80 onMenuButtonOpenTap_: function(e) { 86 onMenuButtonOpenTap_: function(e) {
81 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown.get()); 87 var menu = /** @type {!CrActionMenuElement} */ (this.$.dropdown.get());
82 menu.showAt(/** @type {!Element} */ (e.target)); 88 menu.showAt(/** @type {!Element} */ (e.target));
83 }, 89 },
84 90
85 /** @private */ 91 /** @private */
86 onSortTap_: function() { 92 onSortTap_: function() {
87 chrome.bookmarkManagerPrivate.sortChildren( 93 chrome.bookmarkManagerPrivate.sortChildren(assert(this.selectedFolder_));
88 assert(this.getState().selectedFolder));
89 bookmarks.ToastManager.getInstance().show( 94 bookmarks.ToastManager.getInstance().show(
90 loadTimeData.getString('toastFolderSorted'), true); 95 loadTimeData.getString('toastFolderSorted'), true);
91 this.closeDropdownMenu_(); 96 this.closeDropdownMenu_();
92 }, 97 },
93 98
94 /** @private */ 99 /** @private */
95 onAddBookmarkTap_: function() { 100 onAddBookmarkTap_: function() {
96 var dialog = 101 var dialog =
97 /** @type {BookmarksEditDialogElement} */ (this.$.addDialog.get()); 102 /** @type {BookmarksEditDialogElement} */ (this.$.addDialog.get());
98 dialog.showAddDialog(false, assert(this.getState().selectedFolder)); 103 dialog.showAddDialog(false, assert(this.selectedFolder_));
99 this.closeDropdownMenu_(); 104 this.closeDropdownMenu_();
100 }, 105 },
101 106
102 /** @private */ 107 /** @private */
103 onAddFolderTap_: function() { 108 onAddFolderTap_: function() {
104 var dialog = 109 var dialog =
105 /** @type {BookmarksEditDialogElement} */ (this.$.addDialog.get()); 110 /** @type {BookmarksEditDialogElement} */ (this.$.addDialog.get());
106 dialog.showAddDialog(true, assert(this.getState().selectedFolder)); 111 dialog.showAddDialog(true, assert(this.selectedFolder_));
107 this.closeDropdownMenu_(); 112 this.closeDropdownMenu_();
108 }, 113 },
109 114
110 /** @private */ 115 /** @private */
111 onImportTap_: function() { 116 onImportTap_: function() {
112 chrome.bookmarks.import(); 117 chrome.bookmarks.import();
113 this.closeDropdownMenu_(); 118 this.closeDropdownMenu_();
114 }, 119 },
115 120
116 /** @private */ 121 /** @private */
117 onExportTap_: function() { 122 onExportTap_: function() {
118 chrome.bookmarks.export(); 123 chrome.bookmarks.export();
119 this.closeDropdownMenu_(); 124 this.closeDropdownMenu_();
120 }, 125 },
121 126
122 /** @private */ 127 /** @private */
123 onDeleteSelectionTap_: function() { 128 onDeleteSelectionTap_: function() {
124 var selection = this.getState().selection.items; 129 var selection = this.selectedItems_;
125 var commandManager = bookmarks.CommandManager.getInstance(); 130 var commandManager = bookmarks.CommandManager.getInstance();
126 assert(commandManager.canExecute(Command.DELETE, selection)); 131 assert(commandManager.canExecute(Command.DELETE, selection));
127 commandManager.handle(Command.DELETE, selection); 132 commandManager.handle(Command.DELETE, selection);
128 }, 133 },
129 134
130 /** @private */ 135 /** @private */
131 onClearSelectionTap_: function() { 136 onClearSelectionTap_: function() {
132 this.dispatch(bookmarks.actions.deselectItems()); 137 this.dispatch(bookmarks.actions.deselectItems());
133 }, 138 },
134 139
(...skipping 19 matching lines...) Expand all
154 }, 159 },
155 160
156 /** @private */ 161 /** @private */
157 onSearchTermChanged_: function() { 162 onSearchTermChanged_: function() {
158 this.searchField.setValue(this.searchTerm_ || ''); 163 this.searchField.setValue(this.searchTerm_ || '');
159 }, 164 },
160 165
161 /** 166 /**
162 * @return {boolean} 167 * @return {boolean}
163 * @private 168 * @private
169 */
170 computeCanSortFolder_: function() {
171 return this.canChangeList_ &&
172 this.getState().nodes[this.selectedFolder_].children.length > 0;
173 },
174
175 /**
176 * @return {boolean}
177 * @private
164 */ 178 */
165 computeCanChangeList_: function() { 179 computeCanChangeList_: function() {
166 return !this.searchTerm_ && 180 return !this.searchTerm_ &&
167 bookmarks.util.canReorderChildren( 181 bookmarks.util.canReorderChildren(
168 this.getState(), this.selectedFolder_); 182 this.getState(), this.selectedFolder_);
169 }, 183 },
170 184
171 /** 185 /**
172 * @return {boolean} 186 * @return {boolean}
173 * @private 187 * @private
174 */ 188 */
175 shouldShowSelectionOverlay_: function() { 189 shouldShowSelectionOverlay_: function() {
176 return this.selectedItems_.size > 1 && this.globalCanEdit_; 190 return this.selectedItems_.size > 1 && this.globalCanEdit_;
177 }, 191 },
178 192
179 canDeleteSelection_: function() { 193 canDeleteSelection_: function() {
180 return bookmarks.CommandManager.getInstance().canExecute( 194 return bookmarks.CommandManager.getInstance().canExecute(
181 Command.DELETE, this.selectedItems_); 195 Command.DELETE, this.selectedItems_);
182 }, 196 },
183 197
184 /** 198 /**
185 * @return {string} 199 * @return {string}
186 * @private 200 * @private
187 */ 201 */
188 getItemsSelectedString_: function() { 202 getItemsSelectedString_: function() {
189 return loadTimeData.getStringF('itemsSelected', this.selectedItems_.size); 203 return loadTimeData.getStringF('itemsSelected', this.selectedItems_.size);
190 }, 204 },
191 }); 205 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_bookmarks/toolbar.html ('k') | chrome/test/data/webui/md_bookmarks/toolbar_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698