use bigdecimal::BigDecimal;
use chrono::{DateTime, FixedOffset, NaiveDate, NaiveTime};
use enum_assoc::Assoc;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use crate::internal::serde_helper::{option_stringified, stringified};
use crate::model::Entity;
use crate::model::record::FieldType;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Assoc)]
#[serde(tag = "type", rename_all = "SCREAMING_SNAKE_CASE")]
#[func(pub const fn field_type(&self) -> FieldType)]
#[func(pub fn field_code(&self) -> &str)]
#[non_exhaustive]
pub enum FieldProperty {
#[assoc(field_type = FieldType::Calc)]
#[assoc(field_code = &_0.code)]
Calc(CalcFieldProperty),
#[assoc(field_type = FieldType::SingleLineText)]
#[assoc(field_code = &_0.code)]
SingleLineText(SingleLineTextFieldProperty),
#[assoc(field_type = FieldType::MultiLineText)]
#[assoc(field_code = &_0.code)]
MultiLineText(MultiLineTextFieldProperty),
#[assoc(field_type = FieldType::RichText)]
#[assoc(field_code = &_0.code)]
RichText(RichTextFieldProperty),
#[assoc(field_type = FieldType::Number)]
#[assoc(field_code = &_0.code)]
Number(NumberFieldProperty),
#[assoc(field_type = FieldType::Date)]
#[assoc(field_code = &_0.code)]
Date(DateFieldProperty),
#[assoc(field_type = FieldType::Time)]
#[assoc(field_code = &_0.code)]
Time(TimeFieldProperty),
#[assoc(field_type = FieldType::Datetime)]
#[assoc(field_code = &_0.code)]
DateTime(DateTimeFieldProperty),
#[assoc(field_type = FieldType::RadioButton)]
#[assoc(field_code = &_0.code)]
RadioButton(RadioButtonFieldProperty),
#[assoc(field_type = FieldType::CheckBox)]
#[assoc(field_code = &_0.code)]
CheckBox(CheckBoxFieldProperty),
#[assoc(field_type = FieldType::MultiSelect)]
#[assoc(field_code = &_0.code)]
MultiSelect(MultiSelectFieldProperty),
#[assoc(field_type = FieldType::DropDown)]
#[assoc(field_code = &_0.code)]
DropDown(DropDownFieldProperty),
#[assoc(field_type = FieldType::File)]
#[assoc(field_code = &_0.code)]
File(FileFieldProperty),
#[assoc(field_type = FieldType::Link)]
#[assoc(field_code = &_0.code)]
Link(LinkFieldProperty),
#[assoc(field_type = FieldType::UserSelect)]
#[assoc(field_code = &_0.code)]
UserSelect(UserSelectFieldProperty),
#[assoc(field_type = FieldType::OrganizationSelect)]
#[assoc(field_code = &_0.code)]
OrganizationSelect(OrganizationSelectFieldProperty),
#[assoc(field_type = FieldType::GroupSelect)]
#[assoc(field_code = &_0.code)]
GroupSelect(GroupSelectFieldProperty),
#[assoc(field_type = FieldType::ReferenceTable)]
#[assoc(field_code = &_0.code)]
ReferenceTable(ReferenceTableFieldProperty),
#[assoc(field_type = FieldType::Group)]
#[assoc(field_code = &_0.code)]
Group(GroupFieldProperty),
#[assoc(field_type = FieldType::Subtable)]
#[assoc(field_code = &_0.code)]
Subtable(SubtableFieldProperty),
#[assoc(field_type = FieldType::RecordNumber)]
#[assoc(field_code = &_0.code)]
RecordNumber(RecordNumberFieldProperty),
#[assoc(field_type = FieldType::Category)]
#[assoc(field_code = &_0.code)]
Category(CategoryFieldProperty),
#[assoc(field_type = FieldType::Status)]
#[assoc(field_code = &_0.code)]
Status(StatusFieldProperty),
#[assoc(field_type = FieldType::StatusAssignee)]
#[assoc(field_code = &_0.code)]
StatusAssignee(StatusAssigneeFieldProperty),
#[assoc(field_type = FieldType::CreatedTime)]
#[assoc(field_code = &_0.code)]
CreatedTime(CreatedTimeFieldProperty),
#[assoc(field_type = FieldType::UpdatedTime)]
#[assoc(field_code = &_0.code)]
UpdatedTime(UpdatedTimeFieldProperty),
#[assoc(field_type = FieldType::Creator)]
#[assoc(field_code = &_0.code)]
Creator(CreatorFieldProperty),
#[assoc(field_type = FieldType::Modifier)]
#[assoc(field_code = &_0.code)]
Modifier(ModifierFieldProperty),
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum Alignment {
Horizontal,
Vertical,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum UnitPosition {
Before,
After,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum DisplayFormat {
Number,
NumberDigit,
DateTime,
Date,
Time,
HourMinute,
DayHourMinute,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum LinkProtocol {
Web,
Call,
Mail,
}
impl Default for LinkProtocol {
fn default() -> Self {
Self::Web
}
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FieldOption {
pub label: String,
#[serde(with = "stringified")]
pub index: u64,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CalcFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub expression: String,
pub format: Option<DisplayFormat>,
pub display_scale: Option<i64>,
pub hide_expression: bool,
pub unit: Option<String>,
pub unit_position: Option<UnitPosition>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SingleLineTextFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub unique: bool,
#[serde(with = "option_stringified")]
pub max_length: Option<u64>,
#[serde(with = "option_stringified")]
pub min_length: Option<u64>,
pub default_value: Option<String>,
pub expression: Option<String>,
pub hide_expression: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MultiLineTextFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Option<String>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RichTextFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Option<String>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NumberFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub unique: bool,
pub max_value: Option<BigDecimal>,
pub min_value: Option<BigDecimal>,
pub default_value: Option<BigDecimal>,
pub digit: bool,
#[serde(with = "option_stringified")]
pub display_scale: Option<u64>,
pub unit: Option<String>,
pub unit_position: Option<UnitPosition>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DateFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub unique: bool,
pub default_value: Option<NaiveDate>,
pub default_now_value: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TimeFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Option<NaiveTime>,
pub default_now_value: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DateTimeFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub unique: bool,
pub default_value: Option<DateTime<FixedOffset>>,
pub default_now_value: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RadioButtonFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Option<String>,
pub align: Option<Alignment>,
pub options: BTreeMap<String, FieldOption>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CheckBoxFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Vec<String>,
pub align: Option<Alignment>,
pub options: BTreeMap<String, FieldOption>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MultiSelectFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Vec<String>,
pub options: BTreeMap<String, FieldOption>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DropDownFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Option<String>,
pub options: BTreeMap<String, FieldOption>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FileFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
#[serde(with = "option_stringified")]
pub thumbnail_size: Option<u64>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LinkFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub unique: bool,
pub default_value: Option<String>,
#[serde(with = "option_stringified")]
pub max_length: Option<u64>,
#[serde(with = "option_stringified")]
pub min_length: Option<u64>,
pub protocol: LinkProtocol,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserSelectFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Vec<Entity>,
pub entities: Vec<Entity>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OrganizationSelectFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Vec<Entity>,
pub entities: Vec<Entity>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GroupSelectFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub required: bool,
pub default_value: Vec<Entity>,
pub entities: Vec<Entity>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReferenceTableFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub reference_table: ReferenceTable,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReferenceTable {
pub related_app: RelatedApp,
pub condition: ReferenceCondition,
pub filter_cond: Option<String>,
pub display_fields: Vec<String>,
pub sort: Option<String>,
#[serde(with = "option_stringified")]
pub size: Option<u64>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RelatedApp {
#[serde(with = "option_stringified")]
pub app: Option<u64>,
pub code: Option<String>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReferenceCondition {
pub field: String,
pub related_field: String,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LookupSetting {
pub related_app: RelatedApp,
pub related_key_field: String,
pub field_mappings: Vec<FieldMapping>,
pub lookup_picker_fields: Vec<String>,
pub filter_cond: Option<String>,
pub sort: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FieldMapping {
pub field: String,
pub related_field: String,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GroupFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub open_group: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubtableFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
pub fields: BTreeMap<String, FieldProperty>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LookupFieldProperty {
pub code: String,
#[serde(rename = "type")]
pub field_type: FieldType,
pub label: String,
pub no_label: Option<bool>,
pub required: Option<bool>,
pub lookup: LookupSetting,
}
impl Default for LookupFieldProperty {
fn default() -> Self {
Self {
code: String::default(),
field_type: FieldType::SingleLineText,
label: String::default(),
no_label: None,
required: None,
lookup: LookupSetting::default(),
}
}
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RecordNumberFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CategoryFieldProperty {
pub code: String,
pub label: String,
pub enabled: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StatusFieldProperty {
pub code: String,
pub label: String,
pub enabled: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StatusAssigneeFieldProperty {
pub code: String,
pub label: String,
pub enabled: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreatedTimeFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdatedTimeFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreatorFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ModifierFieldProperty {
pub code: String,
pub label: String,
pub no_label: bool,
}
impl From<CalcFieldProperty> for FieldProperty {
fn from(property: CalcFieldProperty) -> Self {
FieldProperty::Calc(property)
}
}
impl From<SingleLineTextFieldProperty> for FieldProperty {
fn from(property: SingleLineTextFieldProperty) -> Self {
FieldProperty::SingleLineText(property)
}
}
impl From<MultiLineTextFieldProperty> for FieldProperty {
fn from(property: MultiLineTextFieldProperty) -> Self {
FieldProperty::MultiLineText(property)
}
}
impl From<RichTextFieldProperty> for FieldProperty {
fn from(property: RichTextFieldProperty) -> Self {
FieldProperty::RichText(property)
}
}
impl From<NumberFieldProperty> for FieldProperty {
fn from(property: NumberFieldProperty) -> Self {
FieldProperty::Number(property)
}
}
impl From<DateFieldProperty> for FieldProperty {
fn from(property: DateFieldProperty) -> Self {
FieldProperty::Date(property)
}
}
impl From<TimeFieldProperty> for FieldProperty {
fn from(property: TimeFieldProperty) -> Self {
FieldProperty::Time(property)
}
}
impl From<DateTimeFieldProperty> for FieldProperty {
fn from(property: DateTimeFieldProperty) -> Self {
FieldProperty::DateTime(property)
}
}
impl From<RadioButtonFieldProperty> for FieldProperty {
fn from(property: RadioButtonFieldProperty) -> Self {
FieldProperty::RadioButton(property)
}
}
impl From<CheckBoxFieldProperty> for FieldProperty {
fn from(property: CheckBoxFieldProperty) -> Self {
FieldProperty::CheckBox(property)
}
}
impl From<MultiSelectFieldProperty> for FieldProperty {
fn from(property: MultiSelectFieldProperty) -> Self {
FieldProperty::MultiSelect(property)
}
}
impl From<DropDownFieldProperty> for FieldProperty {
fn from(property: DropDownFieldProperty) -> Self {
FieldProperty::DropDown(property)
}
}
impl From<FileFieldProperty> for FieldProperty {
fn from(property: FileFieldProperty) -> Self {
FieldProperty::File(property)
}
}
impl From<LinkFieldProperty> for FieldProperty {
fn from(property: LinkFieldProperty) -> Self {
FieldProperty::Link(property)
}
}
impl From<UserSelectFieldProperty> for FieldProperty {
fn from(property: UserSelectFieldProperty) -> Self {
FieldProperty::UserSelect(property)
}
}
impl From<OrganizationSelectFieldProperty> for FieldProperty {
fn from(property: OrganizationSelectFieldProperty) -> Self {
FieldProperty::OrganizationSelect(property)
}
}
impl From<GroupSelectFieldProperty> for FieldProperty {
fn from(property: GroupSelectFieldProperty) -> Self {
FieldProperty::GroupSelect(property)
}
}
impl From<ReferenceTableFieldProperty> for FieldProperty {
fn from(property: ReferenceTableFieldProperty) -> Self {
FieldProperty::ReferenceTable(property)
}
}
impl From<GroupFieldProperty> for FieldProperty {
fn from(property: GroupFieldProperty) -> Self {
FieldProperty::Group(property)
}
}
impl From<SubtableFieldProperty> for FieldProperty {
fn from(property: SubtableFieldProperty) -> Self {
FieldProperty::Subtable(property)
}
}
impl From<RecordNumberFieldProperty> for FieldProperty {
fn from(property: RecordNumberFieldProperty) -> Self {
FieldProperty::RecordNumber(property)
}
}
impl From<CategoryFieldProperty> for FieldProperty {
fn from(property: CategoryFieldProperty) -> Self {
FieldProperty::Category(property)
}
}
impl From<StatusFieldProperty> for FieldProperty {
fn from(property: StatusFieldProperty) -> Self {
FieldProperty::Status(property)
}
}
impl From<StatusAssigneeFieldProperty> for FieldProperty {
fn from(property: StatusAssigneeFieldProperty) -> Self {
FieldProperty::StatusAssignee(property)
}
}
impl From<CreatedTimeFieldProperty> for FieldProperty {
fn from(property: CreatedTimeFieldProperty) -> Self {
FieldProperty::CreatedTime(property)
}
}
impl From<UpdatedTimeFieldProperty> for FieldProperty {
fn from(property: UpdatedTimeFieldProperty) -> Self {
FieldProperty::UpdatedTime(property)
}
}
impl From<CreatorFieldProperty> for FieldProperty {
fn from(property: CreatorFieldProperty) -> Self {
FieldProperty::Creator(property)
}
}
impl From<ModifierFieldProperty> for FieldProperty {
fn from(property: ModifierFieldProperty) -> Self {
FieldProperty::Modifier(property)
}
}
pub fn calc_field_property(code: impl Into<String>) -> CalcFieldPropertyBuilder {
CalcFieldPropertyBuilder {
property: CalcFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
expression: String::new(),
format: None,
display_scale: None,
hide_expression: false,
unit: None,
unit_position: None,
},
}
}
#[derive(Debug, Clone)]
pub struct CalcFieldPropertyBuilder {
property: CalcFieldProperty,
}
impl CalcFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn expression(mut self, expression: impl Into<String>) -> Self {
self.property.expression = expression.into();
self
}
pub fn format(mut self, format: DisplayFormat) -> Self {
self.property.format = Some(format);
self
}
pub fn display_scale(mut self, display_scale: i64) -> Self {
self.property.display_scale = Some(display_scale);
self
}
pub fn hide_expression(mut self, hide_expression: bool) -> Self {
self.property.hide_expression = hide_expression;
self
}
pub fn unit(mut self, unit: impl Into<String>) -> Self {
self.property.unit = Some(unit.into());
self
}
pub fn unit_position(mut self, unit_position: UnitPosition) -> Self {
self.property.unit_position = Some(unit_position);
self
}
pub fn build(self) -> CalcFieldProperty {
self.property
}
}
impl From<CalcFieldPropertyBuilder> for CalcFieldProperty {
fn from(builder: CalcFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn single_line_text_field_property(
code: impl Into<String>,
) -> SingleLineTextFieldPropertyBuilder {
SingleLineTextFieldPropertyBuilder {
property: SingleLineTextFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
unique: false,
max_length: None,
min_length: None,
default_value: None,
expression: None,
hide_expression: false,
},
}
}
#[derive(Debug, Clone)]
pub struct SingleLineTextFieldPropertyBuilder {
property: SingleLineTextFieldProperty,
}
impl SingleLineTextFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn unique(mut self, unique: bool) -> Self {
self.property.unique = unique;
self
}
pub fn max_length(mut self, max_length: u64) -> Self {
self.property.max_length = Some(max_length);
self
}
pub fn min_length(mut self, min_length: u64) -> Self {
self.property.min_length = Some(min_length);
self
}
pub fn default_value(mut self, default_value: impl Into<String>) -> Self {
self.property.default_value = Some(default_value.into());
self
}
pub fn expression(mut self, expression: impl Into<String>) -> Self {
self.property.expression = Some(expression.into());
self
}
pub fn hide_expression(mut self, hide_expression: bool) -> Self {
self.property.hide_expression = hide_expression;
self
}
pub fn build(self) -> SingleLineTextFieldProperty {
self.property
}
}
impl From<SingleLineTextFieldPropertyBuilder> for SingleLineTextFieldProperty {
fn from(builder: SingleLineTextFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn number_field_property(code: impl Into<String>) -> NumberFieldPropertyBuilder {
NumberFieldPropertyBuilder {
property: NumberFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
unique: false,
max_value: None,
min_value: None,
default_value: None,
digit: false,
display_scale: None,
unit: None,
unit_position: None,
},
}
}
#[derive(Debug, Clone)]
pub struct NumberFieldPropertyBuilder {
property: NumberFieldProperty,
}
impl NumberFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn unique(mut self, unique: bool) -> Self {
self.property.unique = unique;
self
}
pub fn max_value(mut self, max_value: BigDecimal) -> Self {
self.property.max_value = Some(max_value);
self
}
pub fn min_value(mut self, min_value: BigDecimal) -> Self {
self.property.min_value = Some(min_value);
self
}
pub fn default_value(mut self, default_value: BigDecimal) -> Self {
self.property.default_value = Some(default_value);
self
}
pub fn digit(mut self, digit: bool) -> Self {
self.property.digit = digit;
self
}
pub fn display_scale(mut self, display_scale: u64) -> Self {
self.property.display_scale = Some(display_scale);
self
}
pub fn unit(mut self, unit: impl Into<String>) -> Self {
self.property.unit = Some(unit.into());
self
}
pub fn unit_position(mut self, unit_position: UnitPosition) -> Self {
self.property.unit_position = Some(unit_position);
self
}
pub fn build(self) -> NumberFieldProperty {
self.property
}
}
impl From<NumberFieldPropertyBuilder> for NumberFieldProperty {
fn from(builder: NumberFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn multi_line_text_field_property(
code: impl Into<String>,
) -> MultiLineTextFieldPropertyBuilder {
MultiLineTextFieldPropertyBuilder {
property: MultiLineTextFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: None,
},
}
}
#[derive(Debug, Clone)]
pub struct MultiLineTextFieldPropertyBuilder {
property: MultiLineTextFieldProperty,
}
impl MultiLineTextFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: impl Into<String>) -> Self {
self.property.default_value = Some(default_value.into());
self
}
pub fn build(self) -> MultiLineTextFieldProperty {
self.property
}
}
impl From<MultiLineTextFieldPropertyBuilder> for MultiLineTextFieldProperty {
fn from(builder: MultiLineTextFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn date_field_property(code: impl Into<String>) -> DateFieldPropertyBuilder {
DateFieldPropertyBuilder {
property: DateFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
unique: false,
default_value: None,
default_now_value: false,
},
}
}
#[derive(Debug, Clone)]
pub struct DateFieldPropertyBuilder {
property: DateFieldProperty,
}
impl DateFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn unique(mut self, unique: bool) -> Self {
self.property.unique = unique;
self
}
pub fn default_value(mut self, default_value: NaiveDate) -> Self {
self.property.default_value = Some(default_value);
self
}
pub fn default_now_value(mut self, default_now_value: bool) -> Self {
self.property.default_now_value = default_now_value;
self
}
pub fn build(self) -> DateFieldProperty {
self.property
}
}
impl From<DateFieldPropertyBuilder> for DateFieldProperty {
fn from(builder: DateFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn rich_text_field_property(code: impl Into<String>) -> RichTextFieldPropertyBuilder {
RichTextFieldPropertyBuilder {
property: RichTextFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: None,
},
}
}
#[derive(Debug, Clone)]
pub struct RichTextFieldPropertyBuilder {
property: RichTextFieldProperty,
}
impl RichTextFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: impl Into<String>) -> Self {
self.property.default_value = Some(default_value.into());
self
}
pub fn build(self) -> RichTextFieldProperty {
self.property
}
}
impl From<RichTextFieldPropertyBuilder> for RichTextFieldProperty {
fn from(builder: RichTextFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn time_field_property(code: impl Into<String>) -> TimeFieldPropertyBuilder {
TimeFieldPropertyBuilder {
property: TimeFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: None,
default_now_value: false,
},
}
}
#[derive(Debug, Clone)]
pub struct TimeFieldPropertyBuilder {
property: TimeFieldProperty,
}
impl TimeFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: NaiveTime) -> Self {
self.property.default_value = Some(default_value);
self
}
pub fn default_now_value(mut self, default_now_value: bool) -> Self {
self.property.default_now_value = default_now_value;
self
}
pub fn build(self) -> TimeFieldProperty {
self.property
}
}
impl From<TimeFieldPropertyBuilder> for TimeFieldProperty {
fn from(builder: TimeFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn date_time_field_property(code: impl Into<String>) -> DateTimeFieldPropertyBuilder {
DateTimeFieldPropertyBuilder {
property: DateTimeFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
unique: false,
default_value: None,
default_now_value: false,
},
}
}
#[derive(Debug, Clone)]
pub struct DateTimeFieldPropertyBuilder {
property: DateTimeFieldProperty,
}
impl DateTimeFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn unique(mut self, unique: bool) -> Self {
self.property.unique = unique;
self
}
pub fn default_value(mut self, default_value: DateTime<FixedOffset>) -> Self {
self.property.default_value = Some(default_value);
self
}
pub fn default_now_value(mut self, default_now_value: bool) -> Self {
self.property.default_now_value = default_now_value;
self
}
pub fn build(self) -> DateTimeFieldProperty {
self.property
}
}
impl From<DateTimeFieldPropertyBuilder> for DateTimeFieldProperty {
fn from(builder: DateTimeFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn radio_button_field_property(code: impl Into<String>) -> RadioButtonFieldPropertyBuilder {
RadioButtonFieldPropertyBuilder {
property: RadioButtonFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: None,
align: None,
options: BTreeMap::new(),
},
}
}
#[derive(Debug, Clone)]
pub struct RadioButtonFieldPropertyBuilder {
property: RadioButtonFieldProperty,
}
impl RadioButtonFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: impl Into<String>) -> Self {
self.property.default_value = Some(default_value.into());
self
}
pub fn align(mut self, align: Alignment) -> Self {
self.property.align = Some(align);
self
}
pub fn options(mut self, options: BTreeMap<String, FieldOption>) -> Self {
self.property.options = options;
self
}
pub fn add_option(
mut self,
value: impl Into<String>,
label: impl Into<String>,
index: u64,
) -> Self {
let option = FieldOption {
label: label.into(),
index,
};
self.property.options.insert(value.into(), option);
self
}
pub fn build(self) -> RadioButtonFieldProperty {
self.property
}
}
impl From<RadioButtonFieldPropertyBuilder> for RadioButtonFieldProperty {
fn from(builder: RadioButtonFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn checkbox_field_property(code: impl Into<String>) -> CheckBoxFieldPropertyBuilder {
CheckBoxFieldPropertyBuilder {
property: CheckBoxFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: Vec::new(),
align: None,
options: BTreeMap::new(),
},
}
}
#[derive(Debug, Clone)]
pub struct CheckBoxFieldPropertyBuilder {
property: CheckBoxFieldProperty,
}
impl CheckBoxFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: Vec<String>) -> Self {
self.property.default_value = default_value;
self
}
pub fn align(mut self, align: Alignment) -> Self {
self.property.align = Some(align);
self
}
pub fn options(mut self, options: BTreeMap<String, FieldOption>) -> Self {
self.property.options = options;
self
}
pub fn add_option(
mut self,
value: impl Into<String>,
label: impl Into<String>,
index: u64,
) -> Self {
let option = FieldOption {
label: label.into(),
index,
};
self.property.options.insert(value.into(), option);
self
}
pub fn build(self) -> CheckBoxFieldProperty {
self.property
}
}
impl From<CheckBoxFieldPropertyBuilder> for CheckBoxFieldProperty {
fn from(builder: CheckBoxFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn multi_select_field_property(code: impl Into<String>) -> MultiSelectFieldPropertyBuilder {
MultiSelectFieldPropertyBuilder {
property: MultiSelectFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: Vec::new(),
options: BTreeMap::new(),
},
}
}
#[derive(Debug, Clone)]
pub struct MultiSelectFieldPropertyBuilder {
property: MultiSelectFieldProperty,
}
impl MultiSelectFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: Vec<String>) -> Self {
self.property.default_value = default_value;
self
}
pub fn options(mut self, options: BTreeMap<String, FieldOption>) -> Self {
self.property.options = options;
self
}
pub fn add_option(
mut self,
value: impl Into<String>,
label: impl Into<String>,
index: u64,
) -> Self {
let option = FieldOption {
label: label.into(),
index,
};
self.property.options.insert(value.into(), option);
self
}
pub fn build(self) -> MultiSelectFieldProperty {
self.property
}
}
impl From<MultiSelectFieldPropertyBuilder> for MultiSelectFieldProperty {
fn from(builder: MultiSelectFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn dropdown_field_property(code: impl Into<String>) -> DropDownFieldPropertyBuilder {
DropDownFieldPropertyBuilder {
property: DropDownFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: None,
options: BTreeMap::new(),
},
}
}
#[derive(Debug, Clone)]
pub struct DropDownFieldPropertyBuilder {
property: DropDownFieldProperty,
}
impl DropDownFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: impl Into<String>) -> Self {
self.property.default_value = Some(default_value.into());
self
}
pub fn options(mut self, options: BTreeMap<String, FieldOption>) -> Self {
self.property.options = options;
self
}
pub fn add_option(
mut self,
value: impl Into<String>,
label: impl Into<String>,
index: u64,
) -> Self {
let option = FieldOption {
label: label.into(),
index,
};
self.property.options.insert(value.into(), option);
self
}
pub fn build(self) -> DropDownFieldProperty {
self.property
}
}
impl From<DropDownFieldPropertyBuilder> for DropDownFieldProperty {
fn from(builder: DropDownFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn file_field_property(code: impl Into<String>) -> FileFieldPropertyBuilder {
FileFieldPropertyBuilder {
property: FileFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
thumbnail_size: None,
},
}
}
#[derive(Debug, Clone)]
pub struct FileFieldPropertyBuilder {
property: FileFieldProperty,
}
impl FileFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn thumbnail_size(mut self, thumbnail_size: u64) -> Self {
self.property.thumbnail_size = Some(thumbnail_size);
self
}
pub fn build(self) -> FileFieldProperty {
self.property
}
}
impl From<FileFieldPropertyBuilder> for FileFieldProperty {
fn from(builder: FileFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn link_field_property(code: impl Into<String>) -> LinkFieldPropertyBuilder {
LinkFieldPropertyBuilder {
property: LinkFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
unique: false,
default_value: None,
max_length: None,
min_length: None,
protocol: LinkProtocol::default(),
},
}
}
#[derive(Debug, Clone)]
pub struct LinkFieldPropertyBuilder {
property: LinkFieldProperty,
}
impl LinkFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn unique(mut self, unique: bool) -> Self {
self.property.unique = unique;
self
}
pub fn default_value(mut self, default_value: impl Into<String>) -> Self {
self.property.default_value = Some(default_value.into());
self
}
pub fn max_length(mut self, max_length: u64) -> Self {
self.property.max_length = Some(max_length);
self
}
pub fn min_length(mut self, min_length: u64) -> Self {
self.property.min_length = Some(min_length);
self
}
pub fn protocol(mut self, protocol: LinkProtocol) -> Self {
self.property.protocol = protocol;
self
}
pub fn build(self) -> LinkFieldProperty {
self.property
}
}
impl From<LinkFieldPropertyBuilder> for LinkFieldProperty {
fn from(builder: LinkFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn user_select_field_property(code: impl Into<String>) -> UserSelectFieldPropertyBuilder {
UserSelectFieldPropertyBuilder {
property: UserSelectFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: Vec::new(),
entities: Vec::new(),
},
}
}
#[derive(Debug, Clone)]
pub struct UserSelectFieldPropertyBuilder {
property: UserSelectFieldProperty,
}
impl UserSelectFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: Vec<Entity>) -> Self {
self.property.default_value = default_value;
self
}
pub fn entities(mut self, entities: Vec<Entity>) -> Self {
self.property.entities = entities;
self
}
pub fn add_entity(
mut self,
code: impl Into<String>,
entity_type: crate::model::EntityType,
) -> Self {
let entity = Entity {
code: code.into(),
entity_type,
};
self.property.entities.push(entity);
self
}
pub fn build(self) -> UserSelectFieldProperty {
self.property
}
}
impl From<UserSelectFieldPropertyBuilder> for UserSelectFieldProperty {
fn from(builder: UserSelectFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn organization_select_field_property(
code: impl Into<String>,
) -> OrganizationSelectFieldPropertyBuilder {
OrganizationSelectFieldPropertyBuilder {
property: OrganizationSelectFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: Vec::new(),
entities: Vec::new(),
},
}
}
#[derive(Debug, Clone)]
pub struct OrganizationSelectFieldPropertyBuilder {
property: OrganizationSelectFieldProperty,
}
impl OrganizationSelectFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: Vec<Entity>) -> Self {
self.property.default_value = default_value;
self
}
pub fn entities(mut self, entities: Vec<Entity>) -> Self {
self.property.entities = entities;
self
}
pub fn add_entity(
mut self,
code: impl Into<String>,
entity_type: crate::model::EntityType,
) -> Self {
let entity = Entity {
code: code.into(),
entity_type,
};
self.property.entities.push(entity);
self
}
pub fn build(self) -> OrganizationSelectFieldProperty {
self.property
}
}
impl From<OrganizationSelectFieldPropertyBuilder> for OrganizationSelectFieldProperty {
fn from(builder: OrganizationSelectFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn group_select_field_property(code: impl Into<String>) -> GroupSelectFieldPropertyBuilder {
GroupSelectFieldPropertyBuilder {
property: GroupSelectFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
required: false,
default_value: Vec::new(),
entities: Vec::new(),
},
}
}
#[derive(Debug, Clone)]
pub struct GroupSelectFieldPropertyBuilder {
property: GroupSelectFieldProperty,
}
impl GroupSelectFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn required(mut self, required: bool) -> Self {
self.property.required = required;
self
}
pub fn default_value(mut self, default_value: Vec<Entity>) -> Self {
self.property.default_value = default_value;
self
}
pub fn entities(mut self, entities: Vec<Entity>) -> Self {
self.property.entities = entities;
self
}
pub fn add_entity(
mut self,
code: impl Into<String>,
entity_type: crate::model::EntityType,
) -> Self {
let entity = Entity {
code: code.into(),
entity_type,
};
self.property.entities.push(entity);
self
}
pub fn build(self) -> GroupSelectFieldProperty {
self.property
}
}
impl From<GroupSelectFieldPropertyBuilder> for GroupSelectFieldProperty {
fn from(builder: GroupSelectFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn reference_table_field_property(
code: impl Into<String>,
) -> ReferenceTableFieldPropertyBuilder {
ReferenceTableFieldPropertyBuilder {
property: ReferenceTableFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
reference_table: ReferenceTable::default(),
},
}
}
#[derive(Debug, Clone)]
pub struct ReferenceTableFieldPropertyBuilder {
property: ReferenceTableFieldProperty,
}
impl ReferenceTableFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn reference_table(mut self, reference_table: ReferenceTable) -> Self {
self.property.reference_table = reference_table;
self
}
pub fn build(self) -> ReferenceTableFieldProperty {
self.property
}
}
impl From<ReferenceTableFieldPropertyBuilder> for ReferenceTableFieldProperty {
fn from(builder: ReferenceTableFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn group_field_property(code: impl Into<String>) -> GroupFieldPropertyBuilder {
GroupFieldPropertyBuilder {
property: GroupFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
open_group: false,
},
}
}
#[derive(Debug, Clone)]
pub struct GroupFieldPropertyBuilder {
property: GroupFieldProperty,
}
impl GroupFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn open_group(mut self, open_group: bool) -> Self {
self.property.open_group = open_group;
self
}
pub fn build(self) -> GroupFieldProperty {
self.property
}
}
impl From<GroupFieldPropertyBuilder> for GroupFieldProperty {
fn from(builder: GroupFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn subtable_field_property(code: impl Into<String>) -> SubtableFieldPropertyBuilder {
SubtableFieldPropertyBuilder {
property: SubtableFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
fields: BTreeMap::new(),
},
}
}
#[derive(Debug, Clone)]
pub struct SubtableFieldPropertyBuilder {
property: SubtableFieldProperty,
}
impl SubtableFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn fields(mut self, fields: BTreeMap<String, FieldProperty>) -> Self {
self.property.fields = fields;
self
}
pub fn add_field(mut self, code: impl Into<String>, field: FieldProperty) -> Self {
self.property.fields.insert(code.into(), field);
self
}
pub fn build(self) -> SubtableFieldProperty {
self.property
}
}
impl From<SubtableFieldPropertyBuilder> for SubtableFieldProperty {
fn from(builder: SubtableFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn record_number_field_property(code: impl Into<String>) -> RecordNumberFieldPropertyBuilder {
RecordNumberFieldPropertyBuilder {
property: RecordNumberFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
},
}
}
#[derive(Debug, Clone)]
pub struct RecordNumberFieldPropertyBuilder {
property: RecordNumberFieldProperty,
}
impl RecordNumberFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn build(self) -> RecordNumberFieldProperty {
self.property
}
}
impl From<RecordNumberFieldPropertyBuilder> for RecordNumberFieldProperty {
fn from(builder: RecordNumberFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn category_field_property(code: impl Into<String>) -> CategoryFieldPropertyBuilder {
CategoryFieldPropertyBuilder {
property: CategoryFieldProperty {
code: code.into(),
label: String::new(),
enabled: true,
},
}
}
#[derive(Debug, Clone)]
pub struct CategoryFieldPropertyBuilder {
property: CategoryFieldProperty,
}
impl CategoryFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn enabled(mut self, enabled: bool) -> Self {
self.property.enabled = enabled;
self
}
pub fn build(self) -> CategoryFieldProperty {
self.property
}
}
impl From<CategoryFieldPropertyBuilder> for CategoryFieldProperty {
fn from(builder: CategoryFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn status_field_property(code: impl Into<String>) -> StatusFieldPropertyBuilder {
StatusFieldPropertyBuilder {
property: StatusFieldProperty {
code: code.into(),
label: String::new(),
enabled: true,
},
}
}
#[derive(Debug, Clone)]
pub struct StatusFieldPropertyBuilder {
property: StatusFieldProperty,
}
impl StatusFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn enabled(mut self, enabled: bool) -> Self {
self.property.enabled = enabled;
self
}
pub fn build(self) -> StatusFieldProperty {
self.property
}
}
impl From<StatusFieldPropertyBuilder> for StatusFieldProperty {
fn from(builder: StatusFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn status_assignee_field_property(
code: impl Into<String>,
) -> StatusAssigneeFieldPropertyBuilder {
StatusAssigneeFieldPropertyBuilder {
property: StatusAssigneeFieldProperty {
code: code.into(),
label: String::new(),
enabled: true,
},
}
}
#[derive(Debug, Clone)]
pub struct StatusAssigneeFieldPropertyBuilder {
property: StatusAssigneeFieldProperty,
}
impl StatusAssigneeFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn enabled(mut self, enabled: bool) -> Self {
self.property.enabled = enabled;
self
}
pub fn build(self) -> StatusAssigneeFieldProperty {
self.property
}
}
impl From<StatusAssigneeFieldPropertyBuilder> for StatusAssigneeFieldProperty {
fn from(builder: StatusAssigneeFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn created_time_field_property(code: impl Into<String>) -> CreatedTimeFieldPropertyBuilder {
CreatedTimeFieldPropertyBuilder {
property: CreatedTimeFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
},
}
}
#[derive(Debug, Clone)]
pub struct CreatedTimeFieldPropertyBuilder {
property: CreatedTimeFieldProperty,
}
impl CreatedTimeFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn build(self) -> CreatedTimeFieldProperty {
self.property
}
}
impl From<CreatedTimeFieldPropertyBuilder> for CreatedTimeFieldProperty {
fn from(builder: CreatedTimeFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn updated_time_field_property(code: impl Into<String>) -> UpdatedTimeFieldPropertyBuilder {
UpdatedTimeFieldPropertyBuilder {
property: UpdatedTimeFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
},
}
}
#[derive(Debug, Clone)]
pub struct UpdatedTimeFieldPropertyBuilder {
property: UpdatedTimeFieldProperty,
}
impl UpdatedTimeFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn build(self) -> UpdatedTimeFieldProperty {
self.property
}
}
impl From<UpdatedTimeFieldPropertyBuilder> for UpdatedTimeFieldProperty {
fn from(builder: UpdatedTimeFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn creator_field_property(code: impl Into<String>) -> CreatorFieldPropertyBuilder {
CreatorFieldPropertyBuilder {
property: CreatorFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
},
}
}
#[derive(Debug, Clone)]
pub struct CreatorFieldPropertyBuilder {
property: CreatorFieldProperty,
}
impl CreatorFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn build(self) -> CreatorFieldProperty {
self.property
}
}
impl From<CreatorFieldPropertyBuilder> for CreatorFieldProperty {
fn from(builder: CreatorFieldPropertyBuilder) -> Self {
builder.build()
}
}
pub fn modifier_field_property(code: impl Into<String>) -> ModifierFieldPropertyBuilder {
ModifierFieldPropertyBuilder {
property: ModifierFieldProperty {
code: code.into(),
label: String::new(),
no_label: false,
},
}
}
#[derive(Debug, Clone)]
pub struct ModifierFieldPropertyBuilder {
property: ModifierFieldProperty,
}
impl ModifierFieldPropertyBuilder {
pub fn label(mut self, label: impl Into<String>) -> Self {
self.property.label = label.into();
self
}
pub fn no_label(mut self, no_label: bool) -> Self {
self.property.no_label = no_label;
self
}
pub fn build(self) -> ModifierFieldProperty {
self.property
}
}
impl From<ModifierFieldPropertyBuilder> for ModifierFieldProperty {
fn from(builder: ModifierFieldPropertyBuilder) -> Self {
builder.build()
}
}