Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions app/javascript/controllers/wunderbaum_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1136,13 +1136,25 @@ export default class extends Controller {
// Opens the shared dropdown popup to edit a cell value inline instead of applying a column filter
_showInlineEditor(cell, node, colId) {
this._showDropdownFilter(cell, colId, null, {
currentValue: this._normalizeValue(colId, node.data[colId]),
currentValue: this._normalizeValue(
colId,
colId === "assigned_to" ? node.data.assigned_to_id : node.data[colId]
),
onSelect: (value) => {
const normalized = this._normalizeValue(colId, value);
node.data[colId] = normalized;

if (colId === "assigned_to") {
node.data.assigned_to_id = normalized === "unassigned" ? null : normalized;
node.data.assigned_to = this._optionLabelFor("assigned_to", normalized);
} else {
node.data[colId] = normalized;
}

this._saveCellChange(node, colId, normalized);

const label = this._optionLabelFor(colId, normalized);
const label = colId === "assigned_to"
? node.data.assigned_to
: this._optionLabelFor(colId, normalized);
cell.textContent = label || "Unassigned";
cell.classList.add("wb-select-like");
}
Expand Down Expand Up @@ -1304,8 +1316,13 @@ export default class extends Controller {

if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const data = await resp.json();

node.data[field] = value;

if (field === "assigned_to" || data.field === "assigned_to_id") {
node.data.assigned_to_id = data.value;
node.data.assigned_to = data.label || "Unassigned";
} else {
node.data[field] = data.value ?? value;
}
} catch (err) {
console.error("Failed to save cell change", err);
}
Expand Down
32 changes: 32 additions & 0 deletions spec/system/wunderbaum_select_like_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@

let!(:volume) { create(:volume) }
let!(:user) { create(:user, email: "tester@temple.edu") }
let!(:assignee) { create(:user, name: "Alex Assign", email: "alex@example.com") }
let!(:default_migration_status) { create(:migration_status, :default) }
let!(:migrated_status) { create(:migration_status, :migrated) }
let!(:root_folder) do
create(:isilon_folder, :root, volume:, full_path: "/volume/#{volume.id}/root")
end
let!(:other_root_folder) do
create(:isilon_folder, volume:, parent_folder: nil, full_path: "/volume/#{volume.id}/other-root")
end
let!(:match_asset) do
create(
:isilon_asset,
Expand Down Expand Up @@ -53,6 +57,34 @@
expect(page).to have_css(".wb-select-like", text: "tester@temple.edu")
end

it "keeps the assignee label after another file tree selection rerenders the row" do
visit volume_path(volume)

root_row = find(
:xpath,
"//div[contains(@class,'wb-row')][.//span[contains(@class,'wb-title')][starts-with(normalize-space(.), 'root')]]",
wait: 10
)
root_row.find("[data-colid='assigned_to']").click
find(".wb-popup select").find("option", text: assignee.name).select_option
page.execute_script("document.querySelector('.wb-popup select')?.dispatchEvent(new Event('change', { bubbles: true }))")

expect(page).to have_css(".wb-row [data-colid='assigned_to'].wb-select-like", text: assignee.name, wait: 10)

find(
:xpath,
"//div[contains(@class,'wb-row')][.//span[contains(@class,'wb-title')][starts-with(normalize-space(.), 'other-root')]]",
wait: 10
).find("i.wb-checkbox").click

updated_root_row = find(
:xpath,
"//div[contains(@class,'wb-row')][.//span[contains(@class,'wb-title')][starts-with(normalize-space(.), 'root')]]",
wait: 10
)
expect(updated_root_row.find("[data-colid='assigned_to']").text).to eq(assignee.name)
end

it "stores assigned_to as unassigned when initially blank" do
visit volume_path(volume)

Expand Down
Loading