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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/ItemsView.js

Issue 2649923006: [DevTools] Add filtering to DOM storages (Closed)
Patch Set: No more UI.SimpleView Created 3 years, 10 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
dgozman 2017/01/26 22:21:09 2017
eostroukhov 2017/01/26 23:35:46 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 /**
5 * @unrestricted
6 */
7 Resources.ItemsView = class extends UI.VBox {
8 constructor(title, filterName) {
9 super(false);
10 /** @type {?RegExp} */
11 this._filterRegex = null;
12
13 /**
14 * @protected
dgozman 2017/01/26 22:21:09 We usually do protected getters in this case.
eostroukhov 2017/01/26 23:35:46 There does not seem to be a need for accessing the
dgozman 2017/01/27 22:48:45 Sounds like extra indirection.
eostroukhov 2017/01/28 00:03:29 It was either a getter or this indirection. I actu
dgozman 2017/01/30 21:53:48 Sounds good.
15 */
16 this.clearAllButton = this._addButton(Common.UIString('Clear All'), 'largeic on-clear', this.onClearAll);
17 /**
18 * @protected
19 */
20 this.deleteButton = this._addButton(Common.UIString('Delete Selected'), 'lar geicon-delete', this.onDelete);
21 /**
22 * @protected
23 */
24 this.refreshButton = this._addButton(Common.UIString('Refresh'), 'largeicon- refresh', this.onRefresh);
25
26 this._filterBar = new UI.FilterBar(filterName, true);
27 this._textFilterUI = new UI.TextFilterUI(true);
28 this._textFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, this._ filterChanged, this);
29 this._filterBar.addFilter(this._textFilterUI);
30
31 /**
32 * @protected
33 */
34 this.filterButton = this._filterBar.filterButton();
35
36 this._mainToolbar = new UI.Toolbar('top-resources-toolbar', this.element);
37
38 var toolbarItems =
39 [this.refreshButton, this.clearAllButton, this.deleteButton, new UI.Tool barSeparator(), this.filterButton];
40
41 for (var item of toolbarItems)
42 this._mainToolbar.appendToolbarItem(item);
43 }
44
45 /**
46 * @param {string} label
47 * @param {string} glyph
48 * @param {!Function} callback
49 * @return {!UI.ToolbarButton}
50 */
51 _addButton(label, glyph, callback) {
52 var button = new UI.ToolbarButton(label, glyph);
53 button.addEventListener(UI.ToolbarButton.Events.Click, callback, this);
54 return button;
55 }
56
57 /**
58 * @param {!Common.Event} event
59 */
60 _filterChanged(event) {
61 var text = this._textFilterUI.value();
62 this._filterRegex = text ? new RegExp(text.escapeForRegExp(), 'i') : null;
63 this.onRefresh();
64 }
65
66 /**
67 * @protected
68 */
69 showFilterBar() {
dgozman 2017/01/26 22:21:09 Pass boolean |supportsFiltering| in constructor in
eostroukhov 2017/01/26 23:35:46 For now, this can be unconditional
70 this._filterBar.show(this.element);
71 }
72
73 /**
74 * @param {!Array<?Object>} items
75 * @param {function(?Object): string} keyFunction
76 * @return {!Array<?Object>}
77 * @protected
78 */
79 filter(items, keyFunction) {
80 if (!this._filterRegex)
81 return items;
82 return items.filter(item => this._filterRegex.test(keyFunction(item)));
83 }
84
85 onClearAll() {
dgozman 2017/01/26 22:21:09 @protected ?
eostroukhov 2017/01/26 23:35:46 ResourcesPanel calls "deleteAll" - so I'd like to
86 }
87 onDelete() {
dgozman 2017/01/26 22:21:09 style: empty line between functions
eostroukhov 2017/01/26 23:35:46 Done.
88 }
89 onRefresh() {
dgozman 2017/01/26 22:21:09 deleteAllItems, deleteSelectedItem, refreshItem
eostroukhov 2017/01/26 23:35:46 I'm suggesting dropping the "item" - deleteAll/del
dgozman 2017/01/27 22:48:45 I'm suggesting to leave the "item" - deleteAllItem
eostroukhov 2017/01/28 00:03:29 Done.
90 }
91 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698