♻️ Rename smart pointers components for clarity
This commit is contained in:
parent
9a5618ef4b
commit
d80a594cf5
18 changed files with 151 additions and 155 deletions
|
|
@ -2,8 +2,8 @@ use crate::prelude::*;
|
|||
|
||||
use super::Submenu;
|
||||
|
||||
type Content = ArcTypedComponent<Html>;
|
||||
type SubmenuItems = ArcTypedComponent<Submenu>;
|
||||
type Content = TypedComponent<Html>;
|
||||
type SubmenuItems = TypedComponent<Submenu>;
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub enum ElementType {
|
||||
|
|
@ -52,14 +52,14 @@ impl ComponentTrait for Element {
|
|||
impl Element {
|
||||
pub fn html(content: Html) -> Self {
|
||||
Element {
|
||||
element_type: ElementType::Html(Content::new(content)),
|
||||
element_type: ElementType::Html(Content::with(content)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn submenu(submenu: Submenu) -> Self {
|
||||
Element {
|
||||
element_type: ElementType::Submenu(SubmenuItems::new(submenu)),
|
||||
element_type: ElementType::Submenu(SubmenuItems::with(submenu)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ pub struct Group {
|
|||
id : OptionId,
|
||||
weight : Weight,
|
||||
renderable: Renderable,
|
||||
elements : TypedComponents<Element>,
|
||||
elements : VectorComponents<Element>,
|
||||
}
|
||||
|
||||
impl ComponentTrait for Group {
|
||||
|
|
@ -60,19 +60,19 @@ impl Group {
|
|||
|
||||
#[rustfmt::skip]
|
||||
pub fn add_element(mut self, element: Element) -> Self {
|
||||
self.elements.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(element)));
|
||||
self.elements.alter_value(TypedOp::Add(TypedComponent::with(element)));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_elements(&mut self, op: ArcTypedOp<Element>) -> &mut Self {
|
||||
pub fn alter_elements(&mut self, op: TypedOp<Element>) -> &mut Self {
|
||||
self.elements.alter_value(op);
|
||||
self
|
||||
}
|
||||
|
||||
// Group GETTERS.
|
||||
|
||||
pub fn elements(&self) -> &TypedComponents<Element> {
|
||||
pub fn elements(&self) -> &VectorComponents<Element> {
|
||||
&self.elements
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ use crate::prelude::*;
|
|||
use super::{Megamenu, Submenu};
|
||||
|
||||
type Label = L10n;
|
||||
type Content = ArcTypedComponent<Html>;
|
||||
type SubmenuItems = ArcTypedComponent<Submenu>;
|
||||
type MegamenuGroups = ArcTypedComponent<Megamenu>;
|
||||
type Content = TypedComponent<Html>;
|
||||
type SubmenuItems = TypedComponent<Submenu>;
|
||||
type MegamenuGroups = TypedComponent<Megamenu>;
|
||||
|
||||
#[derive(AutoDefault)]
|
||||
pub enum ItemType {
|
||||
|
|
@ -135,21 +135,21 @@ impl Item {
|
|||
|
||||
pub fn html(content: Html) -> Self {
|
||||
Item {
|
||||
item_type: ItemType::Html(Content::new(content)),
|
||||
item_type: ItemType::Html(Content::with(content)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn submenu(label: L10n, submenu: Submenu) -> Self {
|
||||
Item {
|
||||
item_type: ItemType::Submenu(label, SubmenuItems::new(submenu)),
|
||||
item_type: ItemType::Submenu(label, SubmenuItems::with(submenu)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn megamenu(label: L10n, megamenu: Megamenu) -> Self {
|
||||
Item {
|
||||
item_type: ItemType::Megamenu(label, MegamenuGroups::new(megamenu)),
|
||||
item_type: ItemType::Megamenu(label, MegamenuGroups::with(megamenu)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ pub struct Megamenu {
|
|||
id : OptionId,
|
||||
weight : Weight,
|
||||
renderable: Renderable,
|
||||
groups : TypedComponents<Group>,
|
||||
groups : VectorComponents<Group>,
|
||||
}
|
||||
|
||||
impl ComponentTrait for Megamenu {
|
||||
|
|
@ -60,19 +60,19 @@ impl Megamenu {
|
|||
|
||||
#[rustfmt::skip]
|
||||
pub fn add_group(mut self, group: Group) -> Self {
|
||||
self.groups.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(group)));
|
||||
self.groups.alter_value(TypedOp::Add(TypedComponent::with(group)));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_groups(&mut self, op: ArcTypedOp<Group>) -> &mut Self {
|
||||
pub fn alter_groups(&mut self, op: TypedOp<Group>) -> &mut Self {
|
||||
self.groups.alter_value(op);
|
||||
self
|
||||
}
|
||||
|
||||
// Megamenu GETTERS.
|
||||
|
||||
pub fn groups(&self) -> &TypedComponents<Group> {
|
||||
pub fn groups(&self) -> &VectorComponents<Group> {
|
||||
&self.groups
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ pub struct Menu {
|
|||
id : OptionId,
|
||||
weight : Weight,
|
||||
renderable: Renderable,
|
||||
items : TypedComponents<Item>,
|
||||
items : VectorComponents<Item>,
|
||||
}
|
||||
|
||||
impl ComponentTrait for Menu {
|
||||
|
|
@ -88,19 +88,19 @@ impl Menu {
|
|||
|
||||
#[rustfmt::skip]
|
||||
pub fn add_item(mut self, item: Item) -> Self {
|
||||
self.items.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(item)));
|
||||
self.items.alter_value(TypedOp::Add(TypedComponent::with(item)));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_items(&mut self, op: ArcTypedOp<Item>) -> &mut Self {
|
||||
pub fn alter_items(&mut self, op: TypedOp<Item>) -> &mut Self {
|
||||
self.items.alter_value(op);
|
||||
self
|
||||
}
|
||||
|
||||
// Menu GETTERS.
|
||||
|
||||
pub fn items(&self) -> &TypedComponents<Item> {
|
||||
pub fn items(&self) -> &VectorComponents<Item> {
|
||||
&self.items
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ pub struct Submenu {
|
|||
weight : Weight,
|
||||
renderable: Renderable,
|
||||
title : OptionTranslated,
|
||||
items : TypedComponents<Item>,
|
||||
items : VectorComponents<Item>,
|
||||
}
|
||||
|
||||
impl ComponentTrait for Submenu {
|
||||
|
|
@ -72,12 +72,12 @@ impl Submenu {
|
|||
|
||||
#[rustfmt::skip]
|
||||
pub fn add_item(mut self, item: Item) -> Self {
|
||||
self.items.alter_value(ArcTypedOp::Add(ArcTypedComponent::new(item)));
|
||||
self.items.alter_value(TypedOp::Add(TypedComponent::with(item)));
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_items(&mut self, op: ArcTypedOp<Item>) -> &mut Self {
|
||||
pub fn alter_items(&mut self, op: TypedOp<Item>) -> &mut Self {
|
||||
self.items.alter_value(op);
|
||||
self
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ impl Submenu {
|
|||
&self.title
|
||||
}
|
||||
|
||||
pub fn items(&self) -> &TypedComponents<Item> {
|
||||
pub fn items(&self) -> &VectorComponents<Item> {
|
||||
&self.items
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue