╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ UserSettings.zig ─────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
212 213 const email = try (try self.formField("email")).text(allocator); 214 defer allocator.free(email); 215 const current_password = try (try self.formField("current_password")).text(allocator); 216 defer allocator.free(current_password); 217 const new_password = try (try self.formField("new_password")).text(allocator); 218 defer allocator.free(new_password); 219 const new_password_again = try (try self.formField("new_password_again")).text(allocator); 220 defer allocator.free(new_password_again); 221 222 evt.updateUser(io, allocator, users_dir, admin_repo, &user_id, email, current_password, new_password, new_password_again) catch |err| switch (err) { 223 // the account was removed under them 224 error.NotFound => return ui.UserNotifications.logOut(self.session), 225 else => { 226 const failure = ui.Session.FormFeedback.UserFailure.fromError(err) orelse return err; 227 const aa = self.session.arena.allocator(); 228 self.session.data.form_feedback = .{ .user_settings = .{ .failure = failure, .fields = .{ .email = try aa.dupe(u8, email) } } }; 229 return; 230 }, 231 }; 232 233 // reload the page with the saved email and the password fields cleared 234 self.session.haxy_moment = try evt.currentMoment(evt.admin_repo_opts, admin_repo); 235 try self.session.loadUser(); 236 try self.session.navigate(self.session.data.current_page); 237 } 238 239 fn formScroll(self: *View) *wgt.Scroll(ui.Widget) { 240 return &self.box.children.values()[scroll_index].widget.scroll; 241 } 242 243 fn formBox(self: *View) *wgt.Box(ui.Widget) { 244 return &self.formScroll().child.center.child.box; 245 } 246 247 pub fn clearGrid(self: *View) void { 248 self.box.clearGrid(); 249 } 250 251 pub fn getGrid(self: View) ?Grid { 252 return self.box.getGrid(); 253 } 254 255 pub fn getFocus(self: *View) *Focus { 256 return self.box.getFocus(); 257 } 258 259 // up leaves the view from the first control 260 pub fn atTop(self: *View, root_focus: *Focus) bool { 261 return root_focus.grandchild_id == self.control_ids[0]; 262 } 263 }; 264