all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH datacenter-manager 1/2] ui: view configuration: unify create and edit input panel
@ 2025-11-27 11:22 Dominik Csapak
  2025-11-27 11:22 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: view configuration: change include all to a large field Dominik Csapak
  2025-11-27 20:54 ` [pdm-devel] applied: [PATCH datacenter-manager 1/2] ui: view configuration: unify create and edit input panel Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Csapak @ 2025-11-27 11:22 UTC (permalink / raw)
  To: pdm-devel

even though the implementation is not big, the two variants did diverge
already (boxlabel on the include all checkbox). To avoid that, unify the
two methods into one so most changes to one node will be reflected in
the other.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/configuration/views.rs | 61 +++++++++++++++++------------------
 1 file changed, 29 insertions(+), 32 deletions(-)

diff --git a/ui/src/configuration/views.rs b/ui/src/configuration/views.rs
index 71cadc68..41969fdd 100644
--- a/ui/src/configuration/views.rs
+++ b/ui/src/configuration/views.rs
@@ -162,7 +162,7 @@ impl ViewGridComp {
         let props = ctx.props();
         let store = self.store.clone();
         EditWindow::new(tr!("Add") + ": " + &tr!("View"))
-            .renderer(move |form_ctx: &FormContext| add_view_input_panel(form_ctx, store.clone()))
+            .renderer(move |form_ctx| input_panel(form_ctx, InputPanelMode::Create(store.clone())))
             .on_submit({
                 let base_url = props.base_url.clone();
                 let store = self.store.clone();
@@ -176,7 +176,7 @@ impl ViewGridComp {
         let props = ctx.props();
         let id = selection.to_string();
         EditWindow::new(tr!("Edit") + ": " + &tr!("View"))
-            .renderer(move |form_ctx| edit_view_input_panel(form_ctx, id.clone()))
+            .renderer(move |form_ctx| input_panel(form_ctx, InputPanelMode::Edit(id.clone())))
             .on_submit({
                 let base_url = props.base_url.clone();
                 move |form| update_view(base_url.clone(), form)
@@ -322,23 +322,39 @@ impl LoadableComponent for ViewGridComp {
     }
 }
 
-fn add_view_input_panel(form_ctx: &FormContext, store: Store<ViewConfig>) -> Html {
+enum InputPanelMode {
+    Create(Store<ViewConfig>),
+    Edit(String), // id
+}
+
+fn input_panel(form_ctx: &FormContext, mode: InputPanelMode) -> Html {
     let include_all = form_ctx.read().get_field_checked("include-all");
-    InputPanel::new()
-        .padding(4)
-        .with_field(tr!("Name"), Field::new().name("id").required(true))
-        .with_right_field(
-            tr!("Copy Layout from"),
-            ViewSelector::new(store)
-                .placeholder(tr!("None"))
-                .name("copy-from"),
-        )
+    let is_create = matches!(mode, InputPanelMode::Create(_));
+    let mut input_panel = InputPanel::new().padding(4);
+
+    match mode {
+        InputPanelMode::Create(store) => {
+            input_panel.add_field(tr!("Name"), Field::new().name("id").required(true));
+            input_panel.add_right_field(
+                tr!("Copy Layout from"),
+                ViewSelector::new(store)
+                    .placeholder(tr!("None"))
+                    .name("copy-from"),
+            );
+        }
+        InputPanelMode::Edit(id) => input_panel.add_field(
+            tr!("Name"),
+            DisplayField::new().name("id").value(id.clone()),
+        ),
+    }
+
+    input_panel
         .with_field(
             tr!("Include All"),
             Checkbox::new()
                 .name("include-all")
                 .box_label(tr!("Include all remotes and their resources."))
-                .default(true),
+                .default(is_create),
         )
         .with_field_and_options(
             pwt::widget::FieldPosition::Large,
@@ -352,22 +368,3 @@ fn add_view_input_panel(form_ctx: &FormContext, store: Store<ViewConfig>) -> Htm
         .with_large_field(tr!("Exclude"), ViewFilterSelector::new().name("exclude"))
         .into()
 }
-
-fn edit_view_input_panel(form_ctx: &FormContext, id: String) -> Html {
-    let include_all = form_ctx.read().get_field_checked("include-all");
-    InputPanel::new()
-        .padding(4)
-        .with_field(tr!("Name"), DisplayField::new().name("id").value(id))
-        .with_field(tr!("Include All"), Checkbox::new().name("include-all"))
-        .with_field_and_options(
-            pwt::widget::FieldPosition::Large,
-            false,
-            include_all,
-            tr!("Include"),
-            ViewFilterSelector::new()
-                .name("include")
-                .disabled(include_all),
-        )
-        .with_large_field(tr!("Exclude"), ViewFilterSelector::new().name("exclude"))
-        .into()
-}
-- 
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-27 20:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-27 11:22 [pdm-devel] [PATCH datacenter-manager 1/2] ui: view configuration: unify create and edit input panel Dominik Csapak
2025-11-27 11:22 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: view configuration: change include all to a large field Dominik Csapak
2025-11-27 20:54 ` [pdm-devel] applied: [PATCH datacenter-manager 1/2] ui: view configuration: unify create and edit input panel Thomas Lamprecht

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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal