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

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: [DevTools] Add filtering to DOM storages 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
5 Resources.ItemsView = class extends UI.VBox {
6 /**
7 * @param {string} title
8 * @param {string} filterName
9 */
10 constructor(title, filterName) {
11 super(false);
12 /** @type {?RegExp} */
13 this._filterRegex = null;
14
dgozman 2017/01/30 21:53:48 nit: extra blank line.
eostroukhov 2017/01/31 01:17:34 Done.
15
16 this._filterBar = new UI.FilterBar(filterName, true);
17 this._textFilterUI = new UI.TextFilterUI(true);
18 this._textFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, this._ filterChanged, this);
19 this._filterBar.addFilter(this._textFilterUI);
20
21 this._deleteAllButton = this._addButton(Common.UIString('Clear All'), 'large icon-clear', this.deleteAllItems);
22 this._deleteSelectedButton =
23 this._addButton(Common.UIString('Delete Selected'), 'largeicon-delete', this.deleteSelectedItem);
24 this._refreshButton = this._addButton(Common.UIString('Refresh'), 'largeicon -refresh', this.refreshItems);
25 this._filterButton = this._filterBar.filterButton();
26
27 this._mainToolbar = new UI.Toolbar('top-resources-toolbar', this.element);
28
29 var toolbarItems = [
30 this._refreshButton, this._deleteAllButton, this._deleteSelectedButton, ne w UI.ToolbarSeparator(),
31 this._filterButton
32 ];
33
34 for (var item of toolbarItems)
35 this._mainToolbar.appendToolbarItem(item);
36
37 this._filterBar.show(this.element);
38 }
39
40 /**
41 * @param {string} label
42 * @param {string} glyph
43 * @param {!Function} callback
44 * @return {!UI.ToolbarButton}
45 */
46 _addButton(label, glyph, callback) {
47 var button = new UI.ToolbarButton(label, glyph);
48 button.addEventListener(UI.ToolbarButton.Events.Click, callback, this);
49 return button;
50 }
51
52 /**
53 * @param {!Common.Event} event
54 */
55 _filterChanged(event) {
56 var text = this._textFilterUI.value();
57 this._filterRegex = text ? new RegExp(text.escapeForRegExp(), 'i') : null;
58 this.refreshItems();
59 }
60
61 /**
62 * @param {!Array<?Object>} items
63 * @param {function(?Object): string} keyFunction
64 * @return {!Array<?Object>}
65 * @protected
66 */
67 filter(items, keyFunction) {
68 if (!this._filterRegex)
69 return items;
70 return items.filter(item => this._filterRegex.test(keyFunction(item)));
71 }
72
73 /**
74 * @override
75 */
76 wasShown() {
77 this.refreshItems();
78 }
79
80 /**
81 * @override
82 */
83 willHide() {
84 this.setCanDeleteSelected(false);
85 }
86
87 /**
88 * @param {boolean} enabled
89 * @protected
90 */
91 setCanDeleteAll(enabled) {
92 this._deleteAllButton.setEnabled(enabled);
93 }
94
95 /**
96 * @param {boolean} enabled
97 * @protected
98 */
99 setCanDeleteSelected(enabled) {
100 this._deleteSelectedButton.setEnabled(enabled);
101 }
102
103 /**
104 * @param {boolean} enabled
105 * @protected
106 */
107 setCanRefresh(enabled) {
108 this._refreshButton.setEnabled(enabled);
109 }
110
111 /**
112 * @param {boolean} enabled
113 * @protected
114 */
115 setCanFilter(enabled) {
116 this._filterButton.setEnabled(enabled);
117 }
118
119 deleteAllItems() {
120 }
121
122 deleteSelectedItem() {
123 }
124
125 refreshItems() {
126 }
127 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698