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

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: Rebased 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 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 Resources.ItemsView = class extends UI.VBox {
dgozman 2017/01/27 22:48:45 nit: empty line before this?
eostroukhov 2017/01/28 00:03:29 Done.
5 constructor(title, filterName) {
dgozman 2017/01/27 22:48:45 JSDoc please
eostroukhov 2017/01/28 00:03:29 Done.
6 super(false);
7 /** @type {?RegExp} */
8 this._filterRegex = null;
9
10
11 this._filterBar = new UI.FilterBar(filterName, true);
12 this._textFilterUI = new UI.TextFilterUI(true);
13 this._textFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, this._ filterChanged, this);
14 this._filterBar.addFilter(this._textFilterUI);
15
16 this._deleteAllButton = this._addButton(Common.UIString('Clear All'), 'large icon-clear', this.deleteAll);
17 this._deleteSelectedButton =
18 this._addButton(Common.UIString('Delete Selected'), 'largeicon-delete', this.deleteSelected);
19 this._refreshButton = this._addButton(Common.UIString('Refresh'), 'largeicon -refresh', this.refresh);
20 this._filterButton = this._filterBar.filterButton();
21
22 this._mainToolbar = new UI.Toolbar('top-resources-toolbar', this.element);
23
24 var toolbarItems = [
25 this._refreshButton, this._deleteAllButton, this._deleteSelectedButton, ne w UI.ToolbarSeparator(),
26 this._filterButton
27 ];
28
29 for (var item of toolbarItems)
30 this._mainToolbar.appendToolbarItem(item);
31
32 this._filterBar.show(this.element);
33 }
34
35 /**
36 * @param {string} label
37 * @param {string} glyph
38 * @param {!Function} callback
39 * @return {!UI.ToolbarButton}
40 */
41 _addButton(label, glyph, callback) {
42 var button = new UI.ToolbarButton(label, glyph);
43 button.addEventListener(UI.ToolbarButton.Events.Click, callback, this);
44 return button;
45 }
46
47 /**
48 * @param {!Common.Event} event
49 */
50 _filterChanged(event) {
51 var text = this._textFilterUI.value();
52 this._filterRegex = text ? new RegExp(text.escapeForRegExp(), 'i') : null;
53 this.refresh();
54 }
55
56 /**
57 * @param {!Array<?Object>} items
58 * @param {function(?Object): string} keyFunction
59 * @return {!Array<?Object>}
60 * @protected
61 */
62 filter(items, keyFunction) {
63 if (!this._filterRegex)
64 return items;
65 return items.filter(item => this._filterRegex.test(keyFunction(item)));
66 }
67
68 /**
69 * @override
70 */
71 wasShown() {
72 this.refresh();
73 }
74
75 /**
76 * @override
77 */
78 willHide() {
79 this.setCanDeleteSelected(false);
dgozman 2017/01/27 22:48:45 Why this?
eostroukhov 2017/01/28 00:03:29 That's how it worked in those panels, I pushed up
dgozman 2017/01/30 21:53:48 Let's either understand why it's here (using blame
eostroukhov 2017/01/31 01:17:34 Looks like "it had always been this way" - I trace
dgozman 2017/01/31 03:51:17 Yes, please.
eostroukhov 2017/01/31 18:39:10 Done.
80 }
81
82 /**
83 * @param {boolean} enabled
84 * @protected
85 */
86 setCanDeleteAll(enabled) {
87 this._deleteAllButton.setEnabled(enabled);
88 }
89
90 /**
91 * @param {boolean} enabled
92 * @protected
93 */
94 setCanDeleteSelected(enabled) {
95 this._deleteSelectedButton.setEnabled(enabled);
96 }
97
98 /**
99 * @param {boolean} enabled
100 * @protected
101 */
102 setCanRefresh(enabled) {
103 this._refreshButton.setEnabled(enabled);
104 }
105
106 /**
107 * @param {boolean} enabled
108 * @protected
109 */
110 setCanFilter(enabled) {
111 this._filterButton.setEnabled(enabled);
112 }
113
114 deleteAll() {
115 }
116
117 deleteSelected() {
118 }
119
120 refresh() {
121 }
122 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698