Title: [196549] trunk/Source/WebInspectorUI
- Revision
- 196549
- Author
- [email protected]
- Date
- 2016-02-13 01:23:40 -0800 (Sat, 13 Feb 2016)
Log Message
Web Inspector: DataGrid Header Cells should have Context Menu for Sorting
https://bugs.webkit.org/show_bug.cgi?id=154050
Patch by Devin Rousso <[email protected]> on 2016-02-13
Reviewed by Joseph Pecoraro.
* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid.prototype.set sortOrder):
(WebInspector.DataGrid.prototype._toggledSortOrder):
Returns the opposite sort order from the current order.
(WebInspector.DataGrid.prototype._selectSortColumnAndSetOrder):
Changes the selected column to the one with the specified identifier and
then switches the sort order to the given order.
(WebInspector.DataGrid.prototype._headerCellClicked):
Moved logic for switching cells/sort-order to a separate function for
better reusability.
(WebInspector.DataGrid.prototype._contextMenuInHeader):
Adds context menu items on DataGrid header items to change the current
sort order to the specified order. If the context menu is on the selected
header item, only show the sort order that is not currently applied.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (196548 => 196549)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-02-13 08:49:22 UTC (rev 196548)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-02-13 09:23:40 UTC (rev 196549)
@@ -1,3 +1,29 @@
+2016-02-13 Devin Rousso <[email protected]>
+
+ Web Inspector: DataGrid Header Cells should have Context Menu for Sorting
+ https://bugs.webkit.org/show_bug.cgi?id=154050
+
+ Reviewed by Joseph Pecoraro.
+
+ * Localizations/en.lproj/localizedStrings.js:
+ * UserInterface/Views/DataGrid.js:
+ (WebInspector.DataGrid.prototype.set sortOrder):
+ (WebInspector.DataGrid.prototype._toggledSortOrder):
+ Returns the opposite sort order from the current order.
+
+ (WebInspector.DataGrid.prototype._selectSortColumnAndSetOrder):
+ Changes the selected column to the one with the specified identifier and
+ then switches the sort order to the given order.
+
+ (WebInspector.DataGrid.prototype._headerCellClicked):
+ Moved logic for switching cells/sort-order to a separate function for
+ better reusability.
+
+ (WebInspector.DataGrid.prototype._contextMenuInHeader):
+ Adds context menu items on DataGrid header items to change the current
+ sort order to the specified order. If the context menu is on the selected
+ header item, only show the sort order that is not currently applied.
+
2016-02-12 Joseph Pecoraro <[email protected]>
Web Inspector: Rename domAgent to domTreeManager in DOMNode
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (196548 => 196549)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2016-02-13 08:49:22 UTC (rev 196548)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2016-02-13 09:23:40 UTC (rev 196549)
@@ -617,6 +617,8 @@
localizedStrings["Small Icons"] = "Small Icons";
localizedStrings["Socket"] = "Socket";
localizedStrings["Sockets"] = "Sockets";
+localizedStrings["Sort Ascending"] = "Sort Ascending";
+localizedStrings["Sort Descending"] = "Sort Descending";
localizedStrings["Spacing"] = "Spacing";
localizedStrings["Specificity: (%d, %d, %d)"] = "Specificity: (%d, %d, %d)";
localizedStrings["Specificity: No value for selected element"] = "Specificity: No value for selected element";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (196548 => 196549)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js 2016-02-13 08:49:22 UTC (rev 196548)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js 2016-02-13 09:23:40 UTC (rev 196549)
@@ -182,7 +182,7 @@
set sortOrder(order)
{
- if (order === this._sortOrder)
+ if (!order || order === this._sortOrder)
return;
this._sortOrder = order;
@@ -941,6 +941,17 @@
tbody.appendChild(fillerRowElement); // We expect to find a filler row when attaching nodes.
}
+ _toggledSortOrder()
+ {
+ return this._sortOrder !== WebInspector.DataGrid.SortOrder.Descending ? WebInspector.DataGrid.SortOrder.Descending : WebInspector.DataGrid.SortOrder.Ascending;
+ }
+
+ _selectSortColumnAndSetOrder(columnIdentifier, sortOrder)
+ {
+ this.sortColumnIdentifier = columnIdentifier;
+ this.sortOrder = sortOrder;
+ }
+
_keyDown(event)
{
if (!this.selectedNode || event.shiftKey || event.metaKey || event.ctrlKey || this._editing)
@@ -1047,18 +1058,12 @@
_headerCellClicked(event)
{
- var cell = event.target.enclosingNodeOrSelfWithNodeName("th");
+ let cell = event.target.enclosingNodeOrSelfWithNodeName("th");
if (!cell || !cell.columnIdentifier || !cell.classList.contains(WebInspector.DataGrid.SortableColumnStyleClassName))
return;
- var clickedColumnIdentifier = cell.columnIdentifier;
- if (this.sortColumnIdentifier === clickedColumnIdentifier) {
- if (this.sortOrder !== WebInspector.DataGrid.SortOrder.Descending)
- this.sortOrder = WebInspector.DataGrid.SortOrder.Descending;
- else
- this.sortOrder = WebInspector.DataGrid.SortOrder.Ascending;
- } else
- this.sortColumnIdentifier = clickedColumnIdentifier;
+ let sortOrder = this._sortColumnIdentifier === cell.columnIdentifier ? this._toggledSortOrder() : this.sortOrder;
+ this._selectSortColumnAndSetOrder(cell.columnIdentifier, sortOrder);
}
_mouseoverColumnCollapser(event)
@@ -1178,7 +1183,22 @@
if (this._hasCopyableData())
contextMenu.appendItem(WebInspector.UIString("Copy Table"), this._copyTable.bind(this));
- // FIXME: <https://webkit.org/b/154050> Web Inspector: DataGrid Header Cells should have Context Menu for Sorting
+ let cell = event.target.enclosingNodeOrSelfWithNodeName("th");
+ if (cell && cell.columnIdentifier && cell.classList.contains(WebInspector.DataGrid.SortableColumnStyleClassName)) {
+ contextMenu.appendSeparator();
+
+ if (this.sortColumnIdentifier !== cell.columnIdentifier || this.sortOrder !== WebInspector.DataGrid.SortOrder.Ascending) {
+ contextMenu.appendItem(WebInspector.UIString("Sort Ascending"), () => {
+ this._selectSortColumnAndSetOrder(cell.columnIdentifier, WebInspector.DataGrid.SortOrder.Ascending);
+ });
+ }
+
+ if (this.sortColumnIdentifier !== cell.columnIdentifier || this.sortOrder !== WebInspector.DataGrid.SortOrder.Descending) {
+ contextMenu.appendItem(WebInspector.UIString("Sort Descending"), () => {
+ this._selectSortColumnAndSetOrder(cell.columnIdentifier, WebInspector.DataGrid.SortOrder.Descending);
+ });
+ }
+ }
}
_contextMenuInDataTable(event)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes