* [pdm-devel] [PATCH yew-comp/yew-widget-toolkit 0/2] fix user self-editing
@ 2025-11-26 13:51 Shannon Sterz
2025-11-26 13:51 ` [pdm-devel] [PATCH yew-widget-toolkit 1/1] form context: add method to check dirtiness of single fields Shannon Sterz
2025-11-26 13:51 ` [pdm-devel] [PATCH yew-comp 1/1] user panel: update user expiration only if it changed Shannon Sterz
0 siblings, 2 replies; 3+ messages in thread
From: Shannon Sterz @ 2025-11-26 13:51 UTC (permalink / raw)
To: pdm-devel
these patches submit the expiration date of an account only if it was
actually changed. currently the expiration date is always submitted,
which means that users that don't have permissions to edit the
expiration date of their account, can't edit it at all.
proxmox-yew-widget-toolkit:
Shannon Sterz (1):
form context: add helper to check dirtiness of single fields
src/widget/form/context.rs | 11 +++++++++++
1 file changed, 11 insertions(+)
proxmox-yew-comp:
Shannon Sterz (1):
user panel: update user expiration only if it changed
src/user_panel.rs | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
Summary over all repositories:
2 files changed, 18 insertions(+), 5 deletions(-)
--
Generated by git-murpp 0.8.1
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pdm-devel] [PATCH yew-widget-toolkit 1/1] form context: add method to check dirtiness of single fields
2025-11-26 13:51 [pdm-devel] [PATCH yew-comp/yew-widget-toolkit 0/2] fix user self-editing Shannon Sterz
@ 2025-11-26 13:51 ` Shannon Sterz
2025-11-26 13:51 ` [pdm-devel] [PATCH yew-comp 1/1] user panel: update user expiration only if it changed Shannon Sterz
1 sibling, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2025-11-26 13:51 UTC (permalink / raw)
To: pdm-devel
this allows checking whether a specific field has been updated or not
instead of only checking for the whole form.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
src/widget/form/context.rs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/widget/form/context.rs b/src/widget/form/context.rs
index 85de6734..8bdf5789 100644
--- a/src/widget/form/context.rs
+++ b/src/widget/form/context.rs
@@ -690,6 +690,17 @@ impl FormContextState {
self.version += 1;
}
+ /// Check if the field identified by `name` has been changed.
+ ///
+ /// If the there is no field with `name`, `None` will be returned.
+ pub fn is_field_dirty(&self, name: impl IntoPropValue<AttrValue>) -> Option<bool> {
+ let name = name.into_prop_value();
+ self.fields
+ .iter()
+ .find(|(_key, f)| &f.name == &name)
+ .map(|(_key, f)| f.is_dirty())
+ }
+
pub fn is_dirty(&self) -> bool {
for (_name, group) in self.groups.clone().iter() {
if group.radio_count > 0 && group.default != group.value {
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pdm-devel] [PATCH yew-comp 1/1] user panel: update user expiration only if it changed
2025-11-26 13:51 [pdm-devel] [PATCH yew-comp/yew-widget-toolkit 0/2] fix user self-editing Shannon Sterz
2025-11-26 13:51 ` [pdm-devel] [PATCH yew-widget-toolkit 1/1] form context: add method to check dirtiness of single fields Shannon Sterz
@ 2025-11-26 13:51 ` Shannon Sterz
1 sibling, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2025-11-26 13:51 UTC (permalink / raw)
To: pdm-devel
otherwise users cannot edit their own account at all if they don't
have sufficient permissions to adjust the expiration date, as it will
always be send to the api. no matter whether it actually changed or
not.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
src/user_panel.rs | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/user_panel.rs b/src/user_panel.rs
index 4950a2f..d364df8 100644
--- a/src/user_panel.rs
+++ b/src/user_panel.rs
@@ -69,11 +69,13 @@ async fn create_user(form_ctx: FormContext) -> Result<(), Error> {
async fn update_user(form_ctx: FormContext) -> Result<(), Error> {
let mut data = form_ctx.get_submit_data();
- let expire = form_ctx.read().get_field_text("expire");
- if let Ok(epoch) = proxmox_time::parse_rfc3339(&expire) {
- data["expire"] = epoch.into();
- } else {
- data["expire"] = 0i64.into();
+ if Some(true) == form_ctx.read().is_field_dirty("expire") {
+ let expire = form_ctx.read().get_field_text("expire");
+ if let Ok(epoch) = proxmox_time::parse_rfc3339(&expire) {
+ data["expire"] = epoch.into();
+ } else {
+ data["expire"] = 0i64.into();
+ }
}
let data = delete_empty_values(&data, &["firstname", "lastname", "email", "comment"], true);
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-26 13:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-26 13:51 [pdm-devel] [PATCH yew-comp/yew-widget-toolkit 0/2] fix user self-editing Shannon Sterz
2025-11-26 13:51 ` [pdm-devel] [PATCH yew-widget-toolkit 1/1] form context: add method to check dirtiness of single fields Shannon Sterz
2025-11-26 13:51 ` [pdm-devel] [PATCH yew-comp 1/1] user panel: update user expiration only if it changed Shannon Sterz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.