From 4dd57eab4360f56a57f1caac1a4f2e69a2108cfa Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Mon, 4 Apr 2022 20:32:37 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1ade=20referencias=20a=20todos=20los=20m?= =?UTF-8?q?=C3=A9todos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El proyecto compila, pendiente de una solución para los contenedores. --- pagetop-user/src/lib.rs | 8 ++--- pagetop/src/base/component/block.rs | 20 +++++++------ pagetop/src/base/component/chunck.rs | 12 ++++---- pagetop/src/base/component/container.rs | 12 ++++---- pagetop/src/base/component/form/button.rs | 28 ++++++++++-------- pagetop/src/base/component/form/date.rs | 30 +++++++++---------- pagetop/src/base/component/form/form.rs | 18 ++++++------ pagetop/src/base/component/form/hidden.rs | 11 ++++--- pagetop/src/base/component/form/input.rs | 36 +++++++++++------------ pagetop/src/base/component/grid/column.rs | 12 ++++---- pagetop/src/base/component/grid/row.rs | 12 ++++---- pagetop/src/base/component/image.rs | 18 +++++++----- 12 files changed, 115 insertions(+), 102 deletions(-) diff --git a/pagetop-user/src/lib.rs b/pagetop-user/src/lib.rs index 414fb3e4..06b0dd1a 100644 --- a/pagetop-user/src/lib.rs +++ b/pagetop-user/src/lib.rs @@ -32,7 +32,7 @@ impl ModuleTrait for UserModule { } fn form_login() -> ArcComponent { - Form::new() + Form::new()/* .with_id("user-login") .add(form::Input::textfield() .with_name("name") @@ -49,7 +49,7 @@ fn form_login() -> ArcComponent { .with_help_text(l("password_help").as_str()) .arc() ) - .add(form::Button::submit(l("login").as_str()).arc()) + .add(form::Button::submit(l("login").as_str()).arc())*/ .arc() } @@ -57,11 +57,11 @@ async fn login() -> app::Result { Page::new() .with_title( "Identificación del usuario" - ) + )/* .add_to("content", Container::new() .with_id("welcome") .add(form_login()) .arc() - ) + )*/ .render() } diff --git a/pagetop/src/base/component/block.rs b/pagetop/src/base/component/block.rs index a1bf8745..64dd8d7c 100644 --- a/pagetop/src/base/component/block.rs +++ b/pagetop/src/base/component/block.rs @@ -51,47 +51,49 @@ impl PageComponent for Block { impl Block { pub fn with(html: Markup) -> Self { - Block::new().add(html) + let mut block = Block::new(); + block.add(html); + block } // Block BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } - pub fn with_title(mut self, title: &str) -> Self { + pub fn with_title(&mut self, title: &str) -> &Self { self.title.with_value(title); self } - pub fn add(mut self, html: Markup) -> Self { + pub fn add(&mut self, html: Markup) -> &Self { self.html.push(html); self } - pub fn with_id(mut self, id: &str) -> Self { + pub fn with_id(&mut self, id: &str) -> &Self { self.id.with_value(id); self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/chunck.rs b/pagetop/src/base/component/chunck.rs index dc909a89..7589ea4a 100644 --- a/pagetop/src/base/component/chunck.rs +++ b/pagetop/src/base/component/chunck.rs @@ -36,27 +36,29 @@ impl PageComponent for Chunck { impl Chunck { pub fn with(html: Markup) -> Self { - Chunck::new().add(html) + let mut chunck = Chunck::new(); + chunck.add(html); + chunck } // Chunck BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } - pub fn add(mut self, html: Markup) -> Self { + pub fn add(&mut self, html: Markup) -> &Self { self.html.push(html); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/container.rs b/pagetop/src/base/component/container.rs index 2e48ba10..79f9b7a5 100644 --- a/pagetop/src/base/component/container.rs +++ b/pagetop/src/base/component/container.rs @@ -99,12 +99,12 @@ impl Container { // Container BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } @@ -114,22 +114,22 @@ impl Container { self } - pub fn with_id(mut self, id: &str) -> Self { + pub fn with_id(&mut self, id: &str) -> &Self { self.id.with_value(id); self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/form/button.rs b/pagetop/src/base/component/form/button.rs index f99f06d3..f6fd474d 100644 --- a/pagetop/src/base/component/form/button.rs +++ b/pagetop/src/base/component/form/button.rs @@ -68,44 +68,48 @@ impl PageComponent for Button { impl Button { pub fn button(value: &str) -> Self { - Button::new().with_value(value) + let mut button = Button::new(); + button.with_value(value); + button } pub fn reset(value: &str) -> Self { - let mut button = Button::new().with_value(value); + let mut button = Button::new(); + button.with_value(value); button.button_type = ButtonType::Reset; button } pub fn submit(value: &str) -> Self { - let mut button = Button::new().with_value(value); + let mut button = Button::new(); + button.with_value(value); button.button_type = ButtonType::Submit; button } // Button BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } - pub fn with_name(mut self, name: &str) -> Self { + pub fn with_name(&mut self, name: &str) -> &Self { self.name.with_value(name); self } - pub fn with_value(mut self, value: &str) -> Self { + pub fn with_value(&mut self, value: &str) -> &Self { self.value.with_value(value); self } - pub fn with_autofocus(mut self, toggle: bool) -> Self { + pub fn with_autofocus(&mut self, toggle: bool) -> &Self { self.autofocus.with_value(match toggle { true => "autofocus", false => "", @@ -113,7 +117,7 @@ impl Button { self } - pub fn with_disabled(mut self, toggle: bool) -> Self { + pub fn with_disabled(&mut self, toggle: bool) -> &Self { self.disabled.with_value(match toggle { true => "disabled", false => "", @@ -121,17 +125,17 @@ impl Button { self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/form/date.rs b/pagetop/src/base/component/form/date.rs index 40c2f784..bc355a2a 100644 --- a/pagetop/src/base/component/form/date.rs +++ b/pagetop/src/base/component/form/date.rs @@ -95,37 +95,37 @@ impl Date { // Date BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } - pub fn with_name(mut self, name: &str) -> Self { + pub fn with_name(&mut self, name: &str) -> &Self { self.name.with_value(name); self } - pub fn with_value(mut self, value: &str) -> Self { + pub fn with_value(&mut self, value: &str) -> &Self { self.value.with_value(value); self } - pub fn with_label(mut self, label: &str) -> Self { + pub fn with_label(&mut self, label: &str) -> &Self { self.label.with_value(label); self } - pub fn with_placeholder(mut self, placeholder: &str) -> Self { + pub fn with_placeholder(&mut self, placeholder: &str) -> &Self { self.placeholder.with_value(placeholder); self } - pub fn with_autofocus(mut self, toggle: bool) -> Self { + pub fn with_autofocus(&mut self, toggle: bool) -> &Self { self.autofocus.with_value(match toggle { true => "autofocus", false => "", @@ -133,7 +133,7 @@ impl Date { self } - pub fn with_autocomplete(mut self, toggle: bool) -> Self { + pub fn with_autocomplete(&mut self, toggle: bool) -> &Self { self.autocomplete.with_value(match toggle { true => "", false => "off", @@ -141,7 +141,7 @@ impl Date { self } - pub fn with_disabled(mut self, toggle: bool) -> Self { + pub fn with_disabled(&mut self, toggle: bool) -> &Self { self.disabled.with_value(match toggle { true => "disabled", false => "", @@ -149,7 +149,7 @@ impl Date { self } - pub fn with_readonly(mut self, toggle: bool) -> Self { + pub fn with_readonly(&mut self, toggle: bool) -> &Self { self.readonly.with_value(match toggle { true => "readonly", false => "", @@ -157,7 +157,7 @@ impl Date { self } - pub fn with_required(mut self, toggle: bool) -> Self { + pub fn with_required(&mut self, toggle: bool) -> &Self { self.required.with_value(match toggle { true => "required", false => "", @@ -165,22 +165,22 @@ impl Date { self } - pub fn with_help_text(mut self, help_text: &str) -> Self { + pub fn with_help_text(&mut self, help_text: &str) -> &Self { self.help_text.with_value(help_text); self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/form/form.rs b/pagetop/src/base/component/form/form.rs index 9317f9eb..3685d9a1 100644 --- a/pagetop/src/base/component/form/form.rs +++ b/pagetop/src/base/component/form/form.rs @@ -60,27 +60,27 @@ impl Form { // Form BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } - pub fn with_action(mut self, action: &str) -> Self { + pub fn with_action(&mut self, action: &str) -> &Self { self.action.with_value(action); self } - pub fn with_charset(mut self, charset: &str) -> Self { + pub fn with_charset(&mut self, charset: &str) -> &Self { self.charset.with_value(charset); self } - pub fn with_method(mut self, method: FormMethod) -> Self { + pub fn with_method(&mut self, method: FormMethod) -> &Self { self.method = method; self } @@ -90,22 +90,22 @@ impl Form { self } - pub fn with_id(mut self, id: &str) -> Self { + pub fn with_id(&mut self, id: &str) -> &Self { self.id.with_value(id); self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/form/hidden.rs b/pagetop/src/base/component/form/hidden.rs index f4734ba0..0e6e56c3 100644 --- a/pagetop/src/base/component/form/hidden.rs +++ b/pagetop/src/base/component/form/hidden.rs @@ -32,22 +32,25 @@ impl PageComponent for Hidden { impl Hidden { pub fn set(name: &str, value: &str) -> Self { - Hidden::new().with_name(name).with_value(value) + let mut hidden = Hidden::new(); + hidden.with_name(name); + hidden.with_value(value); + hidden } // Hidden BUILDER. - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } - pub fn with_name(mut self, name: &str) -> Self { + pub fn with_name(&mut self, name: &str) -> &Self { self.name.with_value(name); self } - pub fn with_value(mut self, value: &str) -> Self { + pub fn with_value(&mut self, value: &str) -> &Self { self.value.with_value(value); self } diff --git a/pagetop/src/base/component/form/input.rs b/pagetop/src/base/component/form/input.rs index 9d6e1afd..c468cdfe 100644 --- a/pagetop/src/base/component/form/input.rs +++ b/pagetop/src/base/component/form/input.rs @@ -149,52 +149,52 @@ impl Input { // Input BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } - pub fn with_name(mut self, name: &str) -> Self { + pub fn with_name(&mut self, name: &str) -> &Self { self.name.with_value(name); self } - pub fn with_value(mut self, value: &str) -> Self { + pub fn with_value(&mut self, value: &str) -> &Self { self.value.with_value(value); self } - pub fn with_label(mut self, label: &str) -> Self { + pub fn with_label(&mut self, label: &str) -> &Self { self.label.with_value(label); self } - pub fn with_size(mut self, size: Option) -> Self { + pub fn with_size(&mut self, size: Option) -> &Self { self.size = size; self } - pub fn with_minlength(mut self, minlength: Option) -> Self { + pub fn with_minlength(&mut self, minlength: Option) -> &Self { self.minlength = minlength; self } - pub fn with_maxlength(mut self, maxlength: Option) -> Self { + pub fn with_maxlength(&mut self, maxlength: Option) -> &Self { self.maxlength = maxlength; self } - pub fn with_placeholder(mut self, placeholder: &str) -> Self { + pub fn with_placeholder(&mut self, placeholder: &str) -> &Self { self.placeholder.with_value(placeholder); self } - pub fn with_autofocus(mut self, toggle: bool) -> Self { + pub fn with_autofocus(&mut self, toggle: bool) -> &Self { self.autofocus.with_value(match toggle { true => "autofocus", false => "", @@ -202,7 +202,7 @@ impl Input { self } - pub fn with_autocomplete(mut self, toggle: bool) -> Self { + pub fn with_autocomplete(&mut self, toggle: bool) -> &Self { self.autocomplete.with_value(match toggle { true => "", false => "off", @@ -210,7 +210,7 @@ impl Input { self } - pub fn with_disabled(mut self, toggle: bool) -> Self { + pub fn with_disabled(&mut self, toggle: bool) -> &Self { self.disabled.with_value(match toggle { true => "disabled", false => "", @@ -218,7 +218,7 @@ impl Input { self } - pub fn with_readonly(mut self, toggle: bool) -> Self { + pub fn with_readonly(&mut self, toggle: bool) -> &Self { self.readonly.with_value(match toggle { true => "readonly", false => "", @@ -226,7 +226,7 @@ impl Input { self } - pub fn with_required(mut self, toggle: bool) -> Self { + pub fn with_required(&mut self, toggle: bool) -> &Self { self.required.with_value(match toggle { true => "required", false => "", @@ -234,22 +234,22 @@ impl Input { self } - pub fn with_help_text(mut self, help_text: &str) -> Self { + pub fn with_help_text(&mut self, help_text: &str) -> &Self { self.help_text.with_value(help_text); self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/grid/column.rs b/pagetop/src/base/component/grid/column.rs index a007c83b..e4e5525a 100644 --- a/pagetop/src/base/component/grid/column.rs +++ b/pagetop/src/base/component/grid/column.rs @@ -46,12 +46,12 @@ impl Column { // Column BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } @@ -61,22 +61,22 @@ impl Column { self } - pub fn with_id(mut self, id: &str) -> Self { + pub fn with_id(&mut self, id: &str) -> &Self { self.id.with_value(id); self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/grid/row.rs b/pagetop/src/base/component/grid/row.rs index 2a185894..30a5f351 100644 --- a/pagetop/src/base/component/grid/row.rs +++ b/pagetop/src/base/component/grid/row.rs @@ -46,12 +46,12 @@ impl Row { // Row BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } @@ -61,22 +61,22 @@ impl Row { self } - pub fn with_id(mut self, id: &str) -> Self { + pub fn with_id(&mut self, id: &str) -> &Self { self.id.with_value(id); self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self } diff --git a/pagetop/src/base/component/image.rs b/pagetop/src/base/component/image.rs index 1384f4df..30cca8f3 100644 --- a/pagetop/src/base/component/image.rs +++ b/pagetop/src/base/component/image.rs @@ -41,42 +41,44 @@ impl PageComponent for Image { impl Image { pub fn image(source: &str) -> Self { - Image::new().with_source(source) + let mut image = Image::new(); + image.with_source(source); + image } // Image BUILDER. - pub fn with_renderable(mut self, renderable: fn() -> bool) -> Self { + pub fn with_renderable(&mut self, renderable: fn() -> bool) -> &Self { self.renderable = renderable; self } - pub fn with_weight(mut self, weight: i8) -> Self { + pub fn with_weight(&mut self, weight: i8) -> &Self { self.weight = weight; self } - pub fn with_source(mut self, source: &str) -> Self { + pub fn with_source(&mut self, source: &str) -> &Self { self.source.with_value(source); self } - pub fn with_id(mut self, id: &str) -> Self { + pub fn with_id(&mut self, id: &str) -> &Self { self.id.with_value(id); self } - pub fn set_classes(mut self, classes: &str) -> Self { + pub fn set_classes(&mut self, classes: &str) -> &Self { self.classes.set_classes(classes); self } - pub fn add_classes(mut self, classes: &str) -> Self { + pub fn add_classes(&mut self, classes: &str) -> &Self { self.classes.add_classes(classes); self } - pub fn using_template(mut self, template: &str) -> Self { + pub fn using_template(&mut self, template: &str) -> &Self { self.template = template.to_owned(); self }