Elimina before_render() en la def. de componentes

This commit is contained in:
Manuel Cillero 2022-05-16 18:41:51 +02:00
parent 18bec0543c
commit 658d88a383
2 changed files with 5 additions and 25 deletions

View file

@ -47,7 +47,6 @@ impl ComponentTrait for Input {
classes : Classes::new_with_default("form-item"),
template : "default".to_owned(),
}
.with_classes("form-type-textfield", ClassesOp::AddFirst)
}
fn handler(&self) -> &'static str {
@ -62,13 +61,6 @@ impl ComponentTrait for Input {
self.weight
}
fn before_render(&mut self, _: &mut InContext) {
if let Some(name) = self.name() {
let class = concat_string!("form-item-", name);
self.alter_classes(class.as_str(), ClassesOp::AddFirst);
}
}
fn default_render(&self, _: &mut InContext) -> Markup {
let type_input = match self.input_type() {
InputType::Email => "email",
@ -134,36 +126,31 @@ impl Input {
}
pub fn password() -> Self {
let mut input = Input::new()
.with_classes("form-type-password", ClassesOp::Replace("form-type-textfield"));
let mut input = Input::new();
input.input_type = InputType::Password;
input
}
pub fn search() -> Self {
let mut input = Input::new()
.with_classes("form-type-search", ClassesOp::Replace("form-type-textfield"));
let mut input = Input::new();
input.input_type = InputType::Search;
input
}
pub fn email() -> Self {
let mut input = Input::new()
.with_classes("form-type-email", ClassesOp::Replace("form-type-textfield"));
let mut input = Input::new();
input.input_type = InputType::Email;
input
}
pub fn telephone() -> Self {
let mut input = Input::new()
.with_classes("form-type-telephone", ClassesOp::Replace("form-type-textfield"));
let mut input = Input::new();
input.input_type = InputType::Telephone;
input
}
pub fn url() -> Self {
let mut input = Input::new()
.with_classes("form-type-url", ClassesOp::Replace("form-type-textfield"));
let mut input = Input::new();
input.input_type = InputType::Url;
input
}

View file

@ -26,10 +26,6 @@ pub trait ComponentTrait: AnyComponent + Send + Sync {
0
}
#[allow(unused_variables)]
fn before_render(&mut self, context: &mut InContext) {
}
#[allow(unused_variables)]
fn default_render(&self, context: &mut InContext) -> Markup {
html! {}
@ -49,9 +45,6 @@ pub fn component_mut<C: 'static>(component: &mut dyn ComponentTrait) -> &mut C {
}
pub fn render_component(component: &mut dyn ComponentTrait, context: &mut InContext) -> Markup {
// Acciones del componente antes de renderizar.
component.before_render(context);
// Acciones de los módulos antes de renderizar el componente.
run_hooks(
BEFORE_RENDER_COMPONENT_HOOK,