🎨 Recupera el prefijo "alter_" en lugar de "set_"

This commit is contained in:
Manuel Cillero 2024-12-05 19:49:36 +01:00
parent 3e4fc097e1
commit 602108f561
17 changed files with 70 additions and 66 deletions

View file

@ -34,7 +34,7 @@ impl<C: ComponentTrait> AfterRender<C> {
}
pub fn filter_by_referer_id(mut self, id: impl Into<String>) -> Self {
self.referer_id.set_value(id);
self.referer_id.alter_value(id);
self
}

View file

@ -34,7 +34,7 @@ impl<C: ComponentTrait> BeforeRender<C> {
}
pub fn filter_by_referer_id(mut self, id: impl Into<String>) -> Self {
self.referer_id.set_value(id);
self.referer_id.alter_value(id);
self
}

View file

@ -34,7 +34,7 @@ impl<C: ComponentTrait> IsRenderable<C> {
}
pub fn filter_by_referer_id(mut self, id: impl Into<String>) -> Self {
self.referer_id.set_value(id);
self.referer_id.alter_value(id);
self
}

View file

@ -18,7 +18,7 @@ impl Fluent {
Fluent(l10n)
}
pub fn set_l10n(&mut self, l10n: L10n) -> &mut Self {
pub fn alter_l10n(&mut self, l10n: L10n) -> &mut Self {
self.0 = l10n;
self
}

View file

@ -18,7 +18,7 @@ impl Html {
Html(html)
}
pub fn set_html(&mut self, html: Markup) -> &mut Self {
pub fn alter_html(&mut self, html: Markup) -> &mut Self {
self.0 = html;
self
}

View file

@ -102,7 +102,7 @@ impl Children {
// Children BUILDER.
#[fn_builder]
pub fn set_value(&mut self, op: ChildOp) -> &mut Self {
pub fn alter_value(&mut self, op: ChildOp) -> &mut Self {
match op {
ChildOp::Add(any) => self.add(any),
ChildOp::InsertAfterId(id, any) => self.insert_after_id(id, any),
@ -116,7 +116,7 @@ impl Children {
}
#[fn_builder]
pub fn set_typed<C: ComponentTrait + Default>(&mut self, op: TypedOp<C>) -> &mut Self {
pub fn alter_typed<C: ComponentTrait + Default>(&mut self, op: TypedOp<C>) -> &mut Self {
match op {
TypedOp::Add(typed) => self.add(typed.to_child()),
TypedOp::InsertAfterId(id, typed) => self.insert_after_id(id, typed.to_child()),

View file

@ -6,14 +6,14 @@ pub trait ComponentClassesOp {
}
pub trait ComponentClasses: ComponentBase + ComponentClassesOp {
fn set_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self;
fn alter_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self;
fn classes(&self) -> &OptionClasses;
}
impl<C: ComponentBase + ComponentClasses> ComponentClassesOp for C {
fn with_classes(mut self, op: ClassesOp, classes: impl Into<String>) -> Self {
self.set_classes(op, classes);
self.alter_classes(op, classes);
self
}
}

View file

@ -74,7 +74,7 @@ impl Context {
}
}
pub fn set_assets(&mut self, op: AssetsOp) -> &mut Self {
pub fn alter_assets(&mut self, op: AssetsOp) -> &mut Self {
match op {
AssetsOp::LangId(langid) => {
self.langid = langid;
@ -109,12 +109,16 @@ impl Context {
self
}
pub fn set_in_region(&mut self, region: &'static str, op: ChildOp) -> &mut Self {
self.regions.set_in_region(region, op);
pub fn alter_in_region(&mut self, region: &'static str, op: ChildOp) -> &mut Self {
self.regions.alter_in_region(region, op);
self
}
pub fn set_param<T: FromStr + ToString>(&mut self, key: &'static str, value: &T) -> &mut Self {
pub fn alter_param<T: FromStr + ToString>(
&mut self,
key: &'static str,
value: &T,
) -> &mut Self {
self.params.insert(key, value.to_string());
self
}

View file

@ -24,9 +24,9 @@ impl ChildrenInRegions {
}
#[fn_builder]
pub fn set_in_region(&mut self, region: &'static str, op: ChildOp) -> &mut Self {
pub fn alter_in_region(&mut self, region: &'static str, op: ChildOp) -> &mut Self {
if let Some(region) = self.0.get_mut(region) {
region.set_value(op);
region.alter_value(op);
} else {
self.0.insert(region, Children::new().with_value(op));
}
@ -56,18 +56,18 @@ impl InRegion {
COMMON_REGIONS
.write()
.unwrap()
.set_in_region("content", ChildOp::Add(child));
.alter_in_region("content", ChildOp::Add(child));
}
InRegion::Named(name) => {
COMMON_REGIONS
.write()
.unwrap()
.set_in_region(name, ChildOp::Add(child));
.alter_in_region(name, ChildOp::Add(child));
}
InRegion::OfLayout(region, layout) => {
let mut regions = LAYOUT_REGIONS.write().unwrap();
if let Some(r) = regions.get_mut(&layout.type_id()) {
r.set_in_region(region, ChildOp::Add(child));
r.alter_in_region(region, ChildOp::Add(child));
} else {
regions.insert(layout.type_id(), ChildrenInRegions::with(region, child));
}

View file

@ -31,7 +31,7 @@ impl OptionClasses {
// OptionClasses BUILDER.
#[fn_builder]
pub fn set_value(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
pub fn alter_value(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
let classes: String = classes.into();
let classes: Vec<&str> = classes.split_ascii_whitespace().collect();

View file

@ -18,7 +18,7 @@ impl<C: ComponentTrait> OptionComponent<C> {
// OptionComponent BUILDER.
#[fn_builder]
pub fn set_value(&mut self, component: Option<C>) -> &mut Self {
pub fn alter_value(&mut self, component: Option<C>) -> &mut Self {
if let Some(component) = component {
self.0 = Some(TypedComponent::with(component));
} else {

View file

@ -11,7 +11,7 @@ impl OptionId {
// OptionId BUILDER.
#[fn_builder]
pub fn set_value(&mut self, value: impl Into<String>) -> &mut Self {
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
self.0 = Some(value.into().trim().replace(' ', "_"));
self
}

View file

@ -11,7 +11,7 @@ impl OptionName {
// OptionName BUILDER.
#[fn_builder]
pub fn set_value(&mut self, value: impl Into<String>) -> &mut Self {
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
self.0 = Some(value.into().trim().replace(' ', "_"));
self
}

View file

@ -11,7 +11,7 @@ impl OptionString {
// OptionString BUILDER.
#[fn_builder]
pub fn set_value(&mut self, value: impl Into<String>) -> &mut Self {
pub fn alter_value(&mut self, value: impl Into<String>) -> &mut Self {
self.0 = Some(value.into().trim().to_owned());
self
}

View file

@ -13,7 +13,7 @@ impl OptionTranslated {
// OptionTranslated BUILDER.
#[fn_builder]
pub fn set_value(&mut self, value: L10n) -> &mut Self {
pub fn alter_value(&mut self, value: L10n) -> &mut Self {
self.0 = value;
self
}

View file

@ -44,68 +44,68 @@ impl Page {
// Page BUILDER.
#[fn_builder]
pub fn set_title(&mut self, title: L10n) -> &mut Self {
self.title.set_value(title);
pub fn alter_title(&mut self, title: L10n) -> &mut Self {
self.title.alter_value(title);
self
}
#[fn_builder]
pub fn set_description(&mut self, description: L10n) -> &mut Self {
self.description.set_value(description);
pub fn alter_description(&mut self, description: L10n) -> &mut Self {
self.description.alter_value(description);
self
}
#[fn_builder]
pub fn set_metadata(&mut self, name: &'static str, content: &'static str) -> &mut Self {
pub fn alter_metadata(&mut self, name: &'static str, content: &'static str) -> &mut Self {
self.metadata.push((name, content));
self
}
#[fn_builder]
pub fn set_property(&mut self, property: &'static str, content: &'static str) -> &mut Self {
pub fn alter_property(&mut self, property: &'static str, content: &'static str) -> &mut Self {
self.metadata.push((property, content));
self
}
#[fn_builder]
pub fn set_assets(&mut self, op: AssetsOp) -> &mut Self {
self.context.set_assets(op);
pub fn alter_assets(&mut self, op: AssetsOp) -> &mut Self {
self.context.alter_assets(op);
self
}
#[fn_builder]
pub fn set_body_id(&mut self, id: impl Into<String>) -> &mut Self {
self.body_id.set_value(id);
pub fn alter_body_id(&mut self, id: impl Into<String>) -> &mut Self {
self.body_id.alter_value(id);
self
}
#[fn_builder]
pub fn set_body_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
self.body_classes.set_value(op, classes);
pub fn alter_body_classes(&mut self, op: ClassesOp, classes: impl Into<String>) -> &mut Self {
self.body_classes.alter_value(op, classes);
self
}
#[fn_builder]
pub fn set_body_skip_to(&mut self, id: impl Into<String>) -> &mut Self {
self.body_skip_to.set_value(id);
pub fn alter_body_skip_to(&mut self, id: impl Into<String>) -> &mut Self {
self.body_skip_to.alter_value(id);
self
}
#[fn_builder]
pub fn set_layout(&mut self, layout: &'static str) -> &mut Self {
self.context.set_assets(AssetsOp::Layout(layout));
pub fn alter_layout(&mut self, layout: &'static str) -> &mut Self {
self.context.alter_assets(AssetsOp::Layout(layout));
self
}
#[fn_builder]
pub fn set_in_region(&mut self, region: &'static str, op: ChildOp) -> &mut Self {
self.context.set_in_region(region, op);
pub fn alter_in_region(&mut self, region: &'static str, op: ChildOp) -> &mut Self {
self.context.alter_in_region(region, op);
self
}
pub fn with_component(mut self, component: impl ComponentTrait) -> Self {
self.context
.set_in_region("content", ChildOp::Add(ChildComponent::with(component)));
.alter_in_region("content", ChildOp::Add(ChildComponent::with(component)));
self
}
@ -115,7 +115,7 @@ impl Page {
component: impl ComponentTrait,
) -> Self {
self.context
.set_in_region(region, ChildOp::Add(ChildComponent::with(component)));
.alter_in_region(region, ChildOp::Add(ChildComponent::with(component)));
self
}