From 390894c822f1b163f16744646372a28c0d93a89e Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 2 Mar 2018 13:36:16 +0100 Subject: Bug 1146194: Multiple cookies with the same name not shown Issue #31 --- devtools/client/shared/widgets/TableWidget.js | 34 +++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'devtools/client/shared/widgets') diff --git a/devtools/client/shared/widgets/TableWidget.js b/devtools/client/shared/widgets/TableWidget.js index 5dacd1b67..96c020230 100644 --- a/devtools/client/shared/widgets/TableWidget.js +++ b/devtools/client/shared/widgets/TableWidget.js @@ -615,8 +615,13 @@ TableWidget.prototype = { /** * Populates the header context menu with the names of the columns along with * displaying which columns are hidden or visible. + * + * @param {Array} privateColumns=[] + * An array of column names that should never appear in the table. This + * allows us to e.g. have an invisible compound primary key for a + * table's rows. */ - populateMenuPopup: function () { + populateMenuPopup: function (privateColumns = []) { if (!this.menupopup) { return; } @@ -626,6 +631,10 @@ TableWidget.prototype = { } for (let column of this.columns.values()) { + if (privateColumns.includes(column.id)) { + continue; + } + let menuitem = this.document.createElementNS(XUL_NS, "menuitem"); menuitem.setAttribute("label", column.header.getAttribute("value")); menuitem.setAttribute("data-id", column.id); @@ -663,16 +672,21 @@ TableWidget.prototype = { * Creates the columns in the table. Without calling this method, data cannot * be inserted into the table unless `initialColumns` was supplied. * - * @param {object} columns + * @param {Object} columns * A key value pair representing the columns of the table. Where the * key represents the id of the column and the value is the displayed * label in the header of the column. - * @param {string} sortOn + * @param {String} sortOn * The id of the column on which the table will be initially sorted on. - * @param {array} hiddenColumns + * @param {Array} hiddenColumns * Ids of all the columns that are hidden by default. + * @param {Array} privateColumns=[] + * An array of column names that should never appear in the table. This + * allows us to e.g. have an invisible compound primary key for a + * table's rows. */ - setColumns: function (columns, sortOn = this.sortedOn, hiddenColumns = []) { + setColumns: function (columns, sortOn = this.sortedOn, hiddenColumns = [], + privateColumns = []) { for (let column of this.columns.values()) { column.destroy(); } @@ -702,13 +716,14 @@ TableWidget.prototype = { } this.columns.set(id, new Column(this, id, columns[id])); - if (hiddenColumns.indexOf(id) > -1) { + if (hiddenColumns.includes(id) || privateColumns.includes(id)) { + // Hide the column. this.columns.get(id).toggleColumn(); } } this.sortedOn = sortOn; this.sortBy(this.sortedOn); - this.populateMenuPopup(); + this.populateMenuPopup(privateColumns); }, /** @@ -778,6 +793,11 @@ TableWidget.prototype = { return; } + if (this.editBookmark && !this.items.has(this.editBookmark)) { + // Key has been updated... update bookmark. + this.editBookmark = item[this.uniqueId]; + } + let index = this.columns.get(this.sortedOn).push(item); for (let [key, column] of this.columns) { if (key != this.sortedOn) { -- cgit v1.2.3 From 71fd51a863171d9f462d1311749de717361406a6 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 2 Mar 2018 14:59:24 +0100 Subject: Bug 1320362: Move indexedDb storage type in the storage inspector into a new column Issue #31 --- devtools/client/shared/widgets/TableWidget.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'devtools/client/shared/widgets') diff --git a/devtools/client/shared/widgets/TableWidget.js b/devtools/client/shared/widgets/TableWidget.js index 96c020230..84645b5b1 100644 --- a/devtools/client/shared/widgets/TableWidget.js +++ b/devtools/client/shared/widgets/TableWidget.js @@ -719,6 +719,10 @@ TableWidget.prototype = { if (hiddenColumns.includes(id) || privateColumns.includes(id)) { // Hide the column. this.columns.get(id).toggleColumn(); + + if (privateColumns.includes(id)) { + this.columns.get(id).private = true; + } } } this.sortedOn = sortOn; @@ -978,6 +982,9 @@ module.exports.TableWidget = TableWidget; * The displayed string on the column's header. */ function Column(table, id, header) { + // By default cells are visible in the UI. + this._private = false; + this.tbody = table.tbody; this.document = table.document; this.window = table.window; @@ -1060,6 +1067,23 @@ Column.prototype = { return this._sortState || 0; }, + /** + * Get the private state of the column (visibility in the UI). + */ + get private() { + return this._private; + }, + + /** + * Set the private state of the column (visibility in the UI). + * + * @param {Boolean} state + * Private (true or false) + */ + set private(state) { + this._private = state; + }, + /** * Sets the sorted value */ -- cgit v1.2.3 From 166fb9f2893dcfb3375aa3227d116fb0ce2c6d42 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 2 Mar 2018 17:52:34 +0100 Subject: moebius#339: Make it possible to add cookies, local and session storage entries Issue #31 https://github.com/MoonchildProductions/moebius/pull/339 --- devtools/client/shared/widgets/TableWidget.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'devtools/client/shared/widgets') diff --git a/devtools/client/shared/widgets/TableWidget.js b/devtools/client/shared/widgets/TableWidget.js index 84645b5b1..c9fa55d77 100644 --- a/devtools/client/shared/widgets/TableWidget.js +++ b/devtools/client/shared/widgets/TableWidget.js @@ -123,6 +123,8 @@ function TableWidget(node, options = {}) { TableWidget.prototype = { items: null, + editBookmark: null, + scrollIntoViewOnUpdate: null, /** * Getter for the headers context menu popup id. @@ -1159,7 +1161,9 @@ Column.prototype = { }, /** - * Called when a row is updated. + * Called when a row is updated e.g. a cell is changed. This means that + * for a new row this method will be called once for each column. If a single + * cell is changed this method will be called just once. * * @param {string} event * The event name of the event. i.e. EVENTS.ROW_UPDATED @@ -1168,7 +1172,23 @@ Column.prototype = { */ onRowUpdated: function (event, id) { this._updateItems(); + if (this.highlightUpdated && this.items[id] != null) { + if (this.table.scrollIntoViewOnUpdate) { + let cell = this.cells[this.items[id]]; + + // When a new row is created this method is called once for each column + // as each cell is updated. We can only scroll to cells if they are + // visible. We check for visibility and once we find the first visible + // cell in a row we scroll it into view and reset the + // scrollIntoViewOnUpdate flag. + if (cell.label.clientHeight > 0) { + cell.scrollIntoView(); + + this.table.scrollIntoViewOnUpdate = null; + } + } + if (this.table.editBookmark) { // A rows position in the table can change as the result of an edit. In // order to ensure that the correct row is highlighted after an edit we @@ -1180,6 +1200,7 @@ Column.prototype = { this.cells[this.items[id]].flash(); } + this.updateZebra(); }, @@ -1594,6 +1615,10 @@ Cell.prototype = { this.label.focus(); }, + scrollIntoView: function () { + this.label.scrollIntoView(false); + }, + destroy: function () { this.label.remove(); this.label = null; -- cgit v1.2.3 From f22bc3fd885b28be74266c2c48bcc84a3a7ede26 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 2 Mar 2018 18:22:50 +0100 Subject: moebius#342: Columns are not sorted correctly (Natural Sort algorithm) Issue #31 https://github.com/MoonchildProductions/moebius/pull/342 --- devtools/client/shared/widgets/TableWidget.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'devtools/client/shared/widgets') diff --git a/devtools/client/shared/widgets/TableWidget.js b/devtools/client/shared/widgets/TableWidget.js index c9fa55d77..9b6811731 100644 --- a/devtools/client/shared/widgets/TableWidget.js +++ b/devtools/client/shared/widgets/TableWidget.js @@ -8,6 +8,8 @@ loader.lazyRequireGetter(this, "setNamedTimeout", "devtools/client/shared/widgets/view-helpers", true); loader.lazyRequireGetter(this, "clearNamedTimeout", "devtools/client/shared/widgets/view-helpers", true); +loader.lazyRequireGetter(this, "naturalSortCaseInsensitive", + "devtools/client/shared/natural-sort", true); const {KeyCodes} = require("devtools/client/shared/keycodes"); const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -1283,11 +1285,11 @@ Column.prototype = { let index; if (this.sorted == 1) { index = this.cells.findIndex(element => { - return value < element.value; + return naturalSortCaseInsensitive(value, element.value) === -1; }); } else { index = this.cells.findIndex(element => { - return value > element.value; + return naturalSortCaseInsensitive(value, element.value) === 1; }); } index = index >= 0 ? index : this.cells.length; @@ -1415,7 +1417,7 @@ Column.prototype = { a[this.id].textContent : a[this.id]; let val2 = (b[this.id] instanceof Node) ? b[this.id].textContent : b[this.id]; - return val1 > val2; + return naturalSortCaseInsensitive(val1, val2); }); } else if (this.sorted > 1) { items.sort((a, b) => { @@ -1423,7 +1425,7 @@ Column.prototype = { a[this.id].textContent : a[this.id]; let val2 = (b[this.id] instanceof Node) ? b[this.id].textContent : b[this.id]; - return val2 > val1; + return naturalSortCaseInsensitive(val2, val1); }); } -- cgit v1.2.3 From 28d03f81da77b3841180055d1b728d33a46d28ed Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 2 Mar 2018 18:46:58 +0100 Subject: moebius#350: Don't display storage-sidebar after deleting all cookies Issue #31 https://github.com/MoonchildProductions/moebius/pull/350 --- devtools/client/shared/widgets/TableWidget.js | 38 +++++++++++++++++---------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'devtools/client/shared/widgets') diff --git a/devtools/client/shared/widgets/TableWidget.js b/devtools/client/shared/widgets/TableWidget.js index 9b6811731..a0f0dfc11 100644 --- a/devtools/client/shared/widgets/TableWidget.js +++ b/devtools/client/shared/widgets/TableWidget.js @@ -143,7 +143,12 @@ TableWidget.prototype = { */ set selectedRow(id) { for (let column of this.columns.values()) { - column.selectRow(id[this.uniqueId] || id); + if (id) { + column.selectRow(id[this.uniqueId] || id); + } else { + column.selectedRow = null; + column.selectRow(null); + } } }, @@ -842,7 +847,8 @@ TableWidget.prototype = { column.remove(item); column.updateZebra(); } - if (this.items.size == 0) { + if (this.items.size === 0) { + this.selectedRow = null; this.tbody.setAttribute("empty", "empty"); } @@ -885,6 +891,8 @@ TableWidget.prototype = { this.tbody.setAttribute("empty", "empty"); this.setPlaceholderText(this.emptyText); + this.selectedRow = null; + this.emit(EVENTS.TABLE_CLEARED, this); }, @@ -1227,15 +1235,16 @@ Column.prototype = { */ selectRowAt: function (index) { if (this.selectedRow != null) { - this.cells[this.items[this.selectedRow]].toggleClass("theme-selected"); + this.cells[this.items[this.selectedRow]].classList.remove("theme-selected"); } - if (index < 0) { + + let cell = this.cells[index]; + if (cell) { + cell.classList.add("theme-selected"); + this.selectedRow = cell.id; + } else { this.selectedRow = null; - return; } - let cell = this.cells[index]; - cell.toggleClass("theme-selected"); - this.selectedRow = cell.id; }, /** @@ -1399,7 +1408,6 @@ Column.prototype = { this.cells = []; this.items = {}; this._itemsDirty = false; - this.selectedRow = null; while (this.header.nextSibling) { this.header.nextSibling.remove(); } @@ -1430,7 +1438,7 @@ Column.prototype = { } if (this.selectedRow) { - this.cells[this.items[this.selectedRow]].toggleClass("theme-selected"); + this.cells[this.items[this.selectedRow]].classList.remove("theme-selected"); } this.items = {}; // Otherwise, just use the sorted array passed to update the cells value. @@ -1440,7 +1448,7 @@ Column.prototype = { this.cells[i].id = item[this.uniqueId]; }); if (this.selectedRow) { - this.cells[this.items[this.selectedRow]].toggleClass("theme-selected"); + this.cells[this.items[this.selectedRow]].classList.add("theme-selected"); } this._itemsDirty = false; this.updateZebra(); @@ -1454,7 +1462,9 @@ Column.prototype = { if (!cell.hidden) { i++; } - cell.toggleClass("even", !(i % 2)); + + let even = !(i % 2); + cell.classList.toggle("even", even); } }, @@ -1590,8 +1600,8 @@ Cell.prototype = { return this._value; }, - toggleClass: function (className, condition) { - this.label.classList.toggle(className, condition); + get classList() { + return this.label.classList; }, /** -- cgit v1.2.3