Allow reordering of roster columns

merge-requests/175/merge
Sebastian Delmont 2022-01-04 14:30:09 -05:00 zatwierdzone przez Matthew Chambers
rodzic 441970c2e3
commit f92ca3dd51
3 zmienionych plików z 55 dodań i 20 usunięć

Wyświetl plik

@ -107,19 +107,3 @@ Final build results are left in:
# Editing GeoJSON files
We've had success using https://vector.rocks/ and then cleaning up the output with https://jsonformatter.org/
# Hacks
### Roster Column Ordering
We've added internal support for reordering roster columns, but have yet to implement a UI to change these settings.
In the meantime you can:
* Open the roster window, right click on the "More Controls" link on the top right corner and select "Inspect" from the context menu.
* Select the "Console" tab in the Chrome DevTools window that should have appeared.
* Enter `g_rosterSettings.columnOrder` in the Console and press `[return]` to see the current list of columns.
* Enter the following in the Console, changing the values of `columnOrder` to fit your needs: `changeRosterColumnOrder(["Callsign", "Grid", "Spot"]);` and press `[return]`.
Any columns included in this list will be shown before all other columns.

Wyświetl plik

@ -26,6 +26,8 @@ var g_callMenu = null;
var g_ageMenu = null;
var g_callingMenu = null;
var g_compactMenu = null;
var g_menuItemForCurrentColumn = null;
var g_currentColumnName = null;
var g_targetHash = "";
var g_clearIgnores = null;
var g_clearIgnoresCall = null;
@ -1706,6 +1708,19 @@ function init()
item = new nw.MenuItem({ type: "separator" });
g_menu.append(item);
g_menuItemForCurrentColumn = new nw.MenuItem({
type: "normal",
label: "Move Column Left",
click: function ()
{
moveColumnLeft(g_currentColumnName);
}
})
g_menu.append(g_menuItemForCurrentColumn)
item = new nw.MenuItem({ type: "separator" });
g_menu.append(item);
for (let columnIndex in g_rosterSettings.columnOrder)
{
let key = g_rosterSettings.columnOrder[columnIndex];
@ -2164,7 +2179,9 @@ function handleContextMenu(ev)
}
}
let name = ev.target.getAttribute("name");
let name
if (ev.target.tagName == "TD") name = ev.target.getAttribute("name");
if (name == "Callsign")
{
g_targetHash = ev.target.parentNode.id;
@ -2202,13 +2219,24 @@ function handleContextMenu(ev)
}
else
{
if (g_rosterSettings.compact == false)
if (g_rosterSettings.compact)
{
g_menu.popup(mouseX, mouseY);
g_compactMenu.popup(mouseX, mouseY);
}
else
{
g_compactMenu.popup(mouseX, mouseY);
if (ev.target.tagName == "TH" && ev.target.getAttribute("name"))
{
g_menuItemForCurrentColumn.enabled = true;
g_currentColumnName = ev.target.getAttribute("name");
}
else
{
g_menuItemForCurrentColumn.enabled = false;
g_currentColumnName = null;
}
g_menu.popup(mouseX, mouseY);
}
}
}

Wyświetl plik

@ -12,6 +12,8 @@ function renderHeaderForColumn(column)
let attrs = (columnInfo && columnInfo.tableHeader && columnInfo.tableHeader()) || {}
attrs.name = column
attrs.html = attrs.html || column
if (columnInfo.compare)
@ -98,12 +100,21 @@ function validateRosterColumnOrder(columns)
{
let correctedColumnOrder = (columns || DEFAULT_COLUMN_ORDER || []).slice();
// Aappend columns not included in the suggested list.
DEFAULT_COLUMN_ORDER.forEach(column =>
{
if (!correctedColumnOrder.includes(column)) correctedColumnOrder.push(column);
})
// Exclude any unexpected values
correctedColumnOrder = correctedColumnOrder.filter(column => !!ROSTER_COLUMNS[column])
// Ensure the first three columns are always the same
correctedColumnOrder = correctedColumnOrder.filter(column => column != "Callsign" && column != "Band" && column != "Mode");
correctedColumnOrder.unshift("Mode");
correctedColumnOrder.unshift("Band");
correctedColumnOrder.unshift("Callsign");
return correctedColumnOrder;
}
@ -113,3 +124,15 @@ function changeRosterColumnOrder(columns)
writeRosterSettings();
window.opener.goProcessRoster();
}
function moveColumnLeft(column)
{
const columns = rosterColumnList(g_rosterSettings.columns, { Callsign: true, Grid: true });
const pos = columns.indexOf(column);
if (pos > 1)
{
columns[pos] = columns[pos - 1];
columns[pos - 1] = column;
}
changeRosterColumnOrder(columns);
}