╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ──────────────╮ │src/ui/Repo/Threads.zig│ ╰───────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │486 try addSubmitButtonLabeled(allocator, &box, "submit"); │ │487 box.getFocus().child_id = box.children.keys()[comment_author_field_index]; │ │488 return box; │ │489 + } │ │490 + │ │491 + fn initRemoveForm(allocator: std.mem.Allocator, action: []const u8, label: []const u8) !ui.Center { │ │492 + var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .rounded_corners = true, .direction = .vert }); │ │493 + errdefer box.deinit(allocator); │ │494 + box.getFocus().kind = .{ .custom = action }; │ │495 + │ │496 + var prompt = try wgt.Text(ui.Widget).init(allocator, "are you sure?"); │ │497 + errdefer prompt.deinit(allocator); │ │498 + try box.children.put(allocator, prompt.getFocus().id, .{ .widget = .{ .text = prompt }, .rect = null, .min_size = null }); │ │499 + │ │500 + var button = try wgt.TextBox(ui.Widget).init(allocator, label, .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none });│ │501 + errdefer button.deinit(allocator); │ │502 + button.getFocus().focusable = true; │ │503 + button.getFocus().kind = .{ .custom = "submit" }; │ │504 + try box.children.put(allocator, button.getFocus().id, .{ .widget = .{ .text_box = button }, .rect = null, .min_size = null }); │ │505 + box.getFocus().child_id = button.getFocus().id; │ │506 + │ │507 + return ui.Center.init(allocator, .{ .box = box }); │ │508 } │ │509 │ │510 // a form's submit button, then a spacer absorbing the leftover │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │759 }; │ │760 } │ │761 │ │762 + fn removeForm(self: *This) ?*wgt.Box(ui.Widget) { │ │763 + return switch (self.viewStack().children.values()[form_view_index]) { │ │764 + .center => |*center| switch (center.child.*) { │ │765 + .box => |*box| box, │ │766 + else => null, │ │767 + }, │ │768 + else => null, │ │769 + }; │ │770 + } │ │771 + │ │772 // the resolve form's scroll on the terminal (the web page scrolls itself)│ │773 fn resolveScroll(self: *This) ?*wgt.Scroll(ui.Widget) { │ │774 return switch (self.viewStack().children.values()[form_view_index]) { │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │871 .edit => editRoute(self.data.identity, self.data.selected_id), │ │872 .new_comment => newCommentRoute(self.data.identity, self.data.selected_id, self.data.comment_id), │ │873 .edit_comment => editCommentRoute(self.data.identity, self.data.selected_id, self.data.comment_id),│ │874 + .remove => removeRoute(self.data.identity, self.data.selected_id, self.data.comment_id), │ │875 .resolve => resolveRoute(self.data.identity, self.data.selected_id, self.data.theirs_picks), │ │876 else => newRoute(self.data.identity), │ │877 } else switch (self.data.view) { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │878 .edit => editRoute(self.data.identity, self.data.selected_id), │ │879 .new_comment => newCommentRoute(self.data.identity, self.data.selected_id, self.data.comment_id), │ │880 .edit_comment => editCommentRoute(self.data.identity, self.data.selected_id, self.data.comment_id),│ │881 + .remove => removeRoute(self.data.identity, self.data.selected_id, self.data.comment_id), │ │882 else => newRoute(self.data.identity), │ │883 }) │ │884 else if (has_conflicts and index == conflict_view_index) │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────╮ │1018 inner.getFocus().child_id = null; │ │1019 self.author_id[index] = null; │ │1020 self.status_button_id[index] = null; │ │ 979 - self.remove_button_id[index] = null; │ │1021 │ │1022 // the tool row: the open/close and edit buttons; the description page│ │1023 // shows none. │ ╰────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1097 } │ │1098 │ │1099 if (self.session.data.is_local or self.session.data.user_id != null) { │ │1059 - const thread_route = commentsRoute(self.data.identity, entry.id, 0) orelse return error.RouteTooLong; │ │1060 - const remove_url = try std.fmt.allocPrint(pa, "{s}/remove", .{try thread_route.toUrl(self.session.page_arena)}); │ │1061 - const action_kind: []const u8 = if (entryConflicted(entry)) blk: { │ │1062 - row.getFocus().kind = .{ .custom = try std.fmt.allocPrint(pa, "form:{s}", .{remove_url}) }; │ │1063 - break :blk "submit"; │ │1064 - } else try std.fmt.allocPrint(pa, "{s}{s}", .{ ui.submit_action_prefix, remove_url }); │ │1065 - │ │1100 var remove = try wgt.TextBox(ui.Widget).init(allocator, "✕", .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none });│ │1101 errdefer remove.deinit(allocator); │ │1102 remove.getFocus().focusable = true; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1069 - remove.getFocus().kind = .{ .custom = action_kind }; │ │1070 - self.remove_button_id[index] = remove.getFocus().id; │ │1103 + const route = removeRoute(self.data.identity, entry.id, "") orelse return error.RouteTooLong; │ │1104 + remove.getFocus().kind = .{ .custom = try std.fmt.allocPrint(pa, "a:{s}", .{try route.toUrl(self.session.page_arena)}) }; │ │1105 try row.children.put(allocator, remove.getFocus().id, .{ .widget = .{ .text_box = remove }, .rect = null, .min_size = .{ .width = 3, .height = null } });│ │1106 } │ │1107 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1261 return; │ │1262 } │ │1263 if (self.formViewActive()) { │ │1230 - if (has_conflicts and self.data.view == .resolve) { │ │1264 + if (self.data.view == .remove) { │ │1265 + try self.removeFormInput(allocator, key, root_focus); │ │1266 + } else if (has_conflicts and self.data.view == .resolve) { │ │1267 try self.resolveInput(allocator, key, root_focus); │ │1268 } else if (self.data.view == .new_comment or self.data.view == .edit_comment) {│ │1269 try self.commentFormInput(allocator, key, root_focus); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1382 const row = self.toolRow(index); │ │1383 const cur = if (row.getFocus().child_id) |cid| row.children.getIndex(cid) orelse return else return; │ │1384 const on_status = if (self.status_button_id[index]) |id| row.getFocus().child_id == id else false; │ │1349 - const on_remove = if (self.remove_button_id[index]) |id| row.getFocus().child_id == id else false; │ │1385 switch (key) { │ │1386 .arrow_left => if (cur > first_in_row_index) root_focus.setFocus(row.children.keys()[cur - 1]) else try self.focusList(index, root_focus),│ │1387 .arrow_right => if (cur + 1 < row.children.count()) root_focus.setFocus(row.children.keys()[cur + 1]), │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1390 self.focusDetailEdge(index, root_focus, false); │ │1391 self.detailScroll(index).y = 0; │ │1392 }, │ │1358 - .enter => if (on_remove) try self.removeThread(allocator, index) else if (on_status) try self.toggleStatus(allocator, index), │ │1359 - .mouse => |mouse| if (self.remove_button_id[index]) |id| { │ │1360 - if (inp.leftClickOn(root_focus, id, mouse)) return self.removeThread(allocator, index); │ │1361 - if (self.status_button_id[index]) |status_id| if (inp.leftClickOn(root_focus, status_id, mouse)) try self.toggleStatus(allocator, index);│ │1362 - } else if (self.status_button_id[index]) |id| { │ │1393 + .enter => if (on_status) try self.toggleStatus(allocator, index), │ │1394 + .mouse => |mouse| if (self.status_button_id[index]) |id| { │ │1395 if (inp.leftClickOn(root_focus, id, mouse)) try self.toggleStatus(allocator, index); │ │1396 }, │ │1397 else => {}, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯