mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 06:48:38 +09:00
parent
0665a343a5
commit
a5b4f6e003
27 changed files with 829 additions and 169 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue