🔥 Refactor TypeId/Any use, drop own Handle
This commit is contained in:
parent
8402b7946e
commit
169e562488
59 changed files with 137 additions and 289 deletions
|
|
@ -1,19 +1,17 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::FnActionComponent;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct AfterPrepareComponent<C: ComponentTrait> {
|
||||
f: FnActionComponent<C>,
|
||||
referer_handle: Option<Handle>,
|
||||
referer_type_id: Option<TypeId>,
|
||||
referer_id: OptionId,
|
||||
weight: Weight,
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> ActionTrait for AfterPrepareComponent<C> {
|
||||
fn referer_handle(&self) -> Option<Handle> {
|
||||
self.referer_handle
|
||||
fn referer_type_id(&self) -> Option<TypeId> {
|
||||
self.referer_type_id
|
||||
}
|
||||
|
||||
fn referer_id(&self) -> Option<String> {
|
||||
|
|
@ -29,7 +27,7 @@ impl<C: ComponentTrait> AfterPrepareComponent<C> {
|
|||
pub fn new(f: FnActionComponent<C>) -> Self {
|
||||
AfterPrepareComponent {
|
||||
f,
|
||||
referer_handle: Some(C::static_handle()),
|
||||
referer_type_id: Some(TypeId::of::<C>()),
|
||||
referer_id: OptionId::default(),
|
||||
weight: 0,
|
||||
}
|
||||
|
|
@ -48,7 +46,7 @@ impl<C: ComponentTrait> AfterPrepareComponent<C> {
|
|||
#[inline(always)]
|
||||
pub(crate) fn dispatch(component: &mut C, cx: &mut Context, referer_id: Option<String>) {
|
||||
dispatch_actions(
|
||||
(Self::static_handle(), Some(component.handle()), referer_id),
|
||||
(TypeId::of::<Self>(), Some(TypeId::of::<C>()), referer_id),
|
||||
|action| (action_ref::<AfterPrepareComponent<C>>(&**action).f)(component, cx),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::FnActionComponent;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct BeforePrepareComponent<C: ComponentTrait> {
|
||||
f: FnActionComponent<C>,
|
||||
referer_handle: Option<Handle>,
|
||||
referer_type_id: Option<TypeId>,
|
||||
referer_id: OptionId,
|
||||
weight: Weight,
|
||||
}
|
||||
|
||||
impl<C: ComponentTrait> ActionTrait for BeforePrepareComponent<C> {
|
||||
fn referer_handle(&self) -> Option<Handle> {
|
||||
self.referer_handle
|
||||
fn referer_type_id(&self) -> Option<TypeId> {
|
||||
self.referer_type_id
|
||||
}
|
||||
|
||||
fn referer_id(&self) -> Option<String> {
|
||||
|
|
@ -29,7 +27,7 @@ impl<C: ComponentTrait> BeforePrepareComponent<C> {
|
|||
pub fn new(f: FnActionComponent<C>) -> Self {
|
||||
BeforePrepareComponent {
|
||||
f,
|
||||
referer_handle: Some(C::static_handle()),
|
||||
referer_type_id: Some(TypeId::of::<C>()),
|
||||
referer_id: OptionId::default(),
|
||||
weight: 0,
|
||||
}
|
||||
|
|
@ -48,7 +46,7 @@ impl<C: ComponentTrait> BeforePrepareComponent<C> {
|
|||
#[inline(always)]
|
||||
pub(crate) fn dispatch(component: &mut C, cx: &mut Context, referer_id: Option<String>) {
|
||||
dispatch_actions(
|
||||
(Self::static_handle(), Some(component.handle()), referer_id),
|
||||
(TypeId::of::<Self>(), Some(TypeId::of::<C>()), referer_id),
|
||||
|action| (action_ref::<BeforePrepareComponent<C>>(&**action).f)(component, cx),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::FnActionPage;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct AfterPrepareBody {
|
||||
f: FnActionPage,
|
||||
weight: Weight,
|
||||
|
|
@ -27,7 +25,7 @@ impl AfterPrepareBody {
|
|||
|
||||
#[inline(always)]
|
||||
pub(crate) fn dispatch(page: &mut Page) {
|
||||
dispatch_actions((Self::static_handle(), None, None), |action| {
|
||||
dispatch_actions((TypeId::of::<Self>(), None, None), |action| {
|
||||
(action_ref::<AfterPrepareBody>(&**action).f)(page)
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::FnActionPage;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct BeforePrepareBody {
|
||||
f: FnActionPage,
|
||||
weight: Weight,
|
||||
|
|
@ -27,7 +25,7 @@ impl BeforePrepareBody {
|
|||
|
||||
#[inline(always)]
|
||||
pub(crate) fn dispatch(page: &mut Page) {
|
||||
dispatch_actions((Self::static_handle(), None, None), |action| {
|
||||
dispatch_actions((TypeId::of::<Self>(), None, None), |action| {
|
||||
(action_ref::<BeforePrepareBody>(&**action).f)(page)
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Block {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Branding {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(SmartDefault)]
|
||||
pub enum ButtonTarget {
|
||||
|
|
@ -12,7 +11,7 @@ pub enum ButtonTarget {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Button {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
use crate::core::component::{ComponentTrait, Context};
|
||||
use crate::html::{html, PrepareMarkup};
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct Error403;
|
||||
|
||||
impl ComponentTrait for Error403 {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
use crate::core::component::{ComponentTrait, Context};
|
||||
use crate::html::{html, PrepareMarkup};
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct Error404;
|
||||
|
||||
impl ComponentTrait for Error404 {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Container {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Item {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(SmartDefault)]
|
||||
pub enum ActionButtonType {
|
||||
|
|
@ -19,7 +18,7 @@ impl ToString for ActionButtonType {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct ActionButton {
|
||||
weight : Weight,
|
||||
renderable : Renderable,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Date {
|
||||
weight : Weight,
|
||||
renderable : Renderable,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(SmartDefault)]
|
||||
pub enum FormMethod {
|
||||
|
|
@ -9,7 +8,7 @@ pub enum FormMethod {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Form {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Hidden {
|
||||
weight: Weight,
|
||||
name : OptionName,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(SmartDefault)]
|
||||
pub enum InputType {
|
||||
|
|
@ -13,7 +12,7 @@ pub enum InputType {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Input {
|
||||
weight : Weight,
|
||||
renderable : Renderable,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(SmartDefault)]
|
||||
pub enum HeadingType {
|
||||
|
|
@ -40,7 +39,7 @@ impl ToString for HeadingSize {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Heading {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Html(Markup);
|
||||
|
||||
impl ComponentTrait for Html {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Icon {
|
||||
weight : Weight,
|
||||
renderable: Renderable,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
const IMG_FLUID: &str = "pt-img__fluid";
|
||||
const IMG_FIXED: &str = "pt-img__fixed";
|
||||
|
|
@ -15,7 +14,7 @@ pub enum ImageSize {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Image {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::Submenu;
|
||||
|
||||
|
|
@ -17,7 +16,7 @@ pub enum ElementType {
|
|||
// Element.
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Element {
|
||||
weight : Weight,
|
||||
renderable : Renderable,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::Element;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Group {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::{Megamenu, Submenu};
|
||||
|
||||
|
|
@ -23,7 +22,7 @@ pub enum ItemType {
|
|||
// Item.
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Item {
|
||||
weight : Weight,
|
||||
renderable : Renderable,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::Group;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Megamenu {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::Item;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Menu {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
use super::Item;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Submenu {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Paragraph {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(Default, Eq, PartialEq)]
|
||||
pub enum PoweredByLogo {
|
||||
|
|
@ -12,7 +11,7 @@ pub enum PoweredByLogo {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct PoweredBy {
|
||||
weight : Weight,
|
||||
renderable: Renderable,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(BaseHandle, SmartDefault)]
|
||||
#[derive(SmartDefault)]
|
||||
pub struct Translate(L10n);
|
||||
|
||||
impl ComponentTrait for Translate {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(SmartDefault)]
|
||||
pub enum WrapperType {
|
||||
|
|
@ -12,7 +11,7 @@ pub enum WrapperType {
|
|||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[derive(BaseHandle, ComponentClasses, SmartDefault)]
|
||||
#[derive(ComponentClasses, SmartDefault)]
|
||||
pub struct Wrapper {
|
||||
id : OptionId,
|
||||
weight : Weight,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct Basic;
|
||||
|
||||
impl PackageTrait for Basic {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct Chassis;
|
||||
|
||||
impl PackageTrait for Chassis {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use crate::prelude::*;
|
||||
use crate::BaseHandle;
|
||||
|
||||
#[derive(BaseHandle)]
|
||||
pub struct Inception;
|
||||
|
||||
impl PackageTrait for Inception {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue