forms

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressForm

type AddressForm struct {
	Vat              string `form:"vat"`
	Firstname        string `form:"firstname" validate:"required" conform:"ucfirst,trim"`
	Lastname         string `form:"lastname" validate:"required" conform:"ucfirst,trim"`
	MiddleName       string `form:"middlename" conform:"ucfirst,trim"`
	Title            string `form:"title" conform:"trim"`
	Salutation       string `form:"salutation" conform:"trim"`
	Street           string `form:"street" conform:"ucfirst,trim"`
	StreetNr         string `form:"streetNr" conform:"trim"`
	AddressLine1     string `form:"addressLine1" conform:"trim"`
	AddressLine2     string `form:"addressLine2" conform:"trim"`
	Company          string `form:"company" conform:"trim"`
	PostCode         string `form:"postCode" conform:"trim"`
	City             string `form:"city" conform:"ucfirst,trim"`
	State            string `form:"state" conform:"ucfirst,trim"`
	RegionCode       string `form:"regionCode" conform:"trim"`
	Country          string `form:"country" conform:"ucfirst,trim"`
	CountryCode      string `form:"countryCode" conform:"trim"`
	PhoneAreaCode    string `form:"phoneAreaCode" conform:"trim"`
	PhoneCountryCode string `form:"phoneCountryCode" conform:"trim"`
	PhoneNumber      string `form:"phoneNumber" conform:"trim"`
	Email            string `form:"email" validate:"required,email" conform:"trim,lowercase"`
}

AddressForm defines the checkout address form data

func (*AddressForm) LoadFromCartAddress

func (a *AddressForm) LoadFromCartAddress(address cart.Address)

LoadFromCartAddress - loads the form data from cart address

func (*AddressForm) LoadFromCustomerAddress

func (a *AddressForm) LoadFromCustomerAddress(address domain.Address)

LoadFromCustomerAddress - fills the form from data in the address object (from customer module)

func (*AddressForm) MapToDomainAddress

func (a *AddressForm) MapToDomainAddress() cart.Address

MapToDomainAddress - returns the cart Address Object

type BillingAddressForm

type BillingAddressForm AddressForm

BillingAddressForm the form for billing address

type BillingAddressFormController

type BillingAddressFormController struct {
	// contains filtered or unexported fields
}

BillingAddressFormController the (mini) MVC

func (*BillingAddressFormController) GetUnsubmittedForm

func (c *BillingAddressFormController) GetUnsubmittedForm(ctx context.Context, r *web.Request) (*domain.Form, error)

GetUnsubmittedForm returns unsubmitted form

func (*BillingAddressFormController) HandleFormAction

func (c *BillingAddressFormController) HandleFormAction(ctx context.Context, r *web.Request) (form *domain.Form, actionSuccessful bool, err error)

HandleFormAction return the form or error. If the form was submitted the action is performed

func (*BillingAddressFormController) Inject

func (c *BillingAddressFormController) Inject(
	responder *web.Responder,
	applicationCartService *cartApplication.CartService,
	applicationCartReceiverService *cartApplication.CartReceiverService,
	logger flamingo.Logger,
	formHandlerFactory application.FormHandlerFactory,
)

Inject dependencies

type BillingAddressFormService

type BillingAddressFormService struct {
	// contains filtered or unexported fields
}

BillingAddressFormService implements Form(Data)Provider interface of form package

func (*BillingAddressFormService) GetFormData

func (p *BillingAddressFormService) GetFormData(ctx context.Context, req *web.Request) (interface{}, error)

GetFormData provides form data

func (*BillingAddressFormService) Inject

func (p *BillingAddressFormService) Inject(
	applicationCartReceiverService *cartApplication.CartReceiverService,
	customerApplicationService *customerApplication.Service)

Inject dependencies

type DefaultPersonalDataForm

type DefaultPersonalDataForm struct {
	DateOfBirth     string      `form:"dateOfBirth"`
	PassportCountry string      `form:"passportCountry"`
	PassportNumber  string      `form:"passportNumber"`
	Address         AddressForm `form:"address" validate:"-"`
	// contains filtered or unexported fields
}

DefaultPersonalDataForm - the standard form dto for Person data (that implements PersonalDataForm)

func (DefaultPersonalDataForm) AdditionalData

func (p DefaultPersonalDataForm) AdditionalData(key string) string

AdditionalData returns the additional form data

func (*DefaultPersonalDataForm) Inject

func (p *DefaultPersonalDataForm) Inject(
	cfg *struct {
		AdditionalFormValues config.Slice `inject:"config:commerce.cart.personalDataForm.additionalFormFields,optional"`
	},
) *DefaultPersonalDataForm

Inject dependencies

func (DefaultPersonalDataForm) MapAdditionalData

func (p DefaultPersonalDataForm) MapAdditionalData() *cart.AdditionalData

MapAdditionalData - mapper

func (*DefaultPersonalDataForm) MapPerson

func (p *DefaultPersonalDataForm) MapPerson() *cart.Person

MapPerson maps the checkout form data to the cart.Person domain struct

type DefaultPersonalDataFormProvider

type DefaultPersonalDataFormProvider func() *DefaultPersonalDataForm

DefaultPersonalDataFormProvider for creating form instances

type DefaultPersonalDataFormService

type DefaultPersonalDataFormService struct {
	// contains filtered or unexported fields
}

DefaultPersonalDataFormService implements Form(Data)Provider interface of form package

func (*DefaultPersonalDataFormService) Decode

func (p *DefaultPersonalDataFormService) Decode(_ context.Context, _ *web.Request, values url.Values, _ interface{}) (interface{}, error)

Decode fills the form data from the web request

func (*DefaultPersonalDataFormService) GetFormData

func (p *DefaultPersonalDataFormService) GetFormData(ctx context.Context, req *web.Request) (interface{}, error)

GetFormData from data provider

func (*DefaultPersonalDataFormService) Inject

func (p *DefaultPersonalDataFormService) Inject(
	applicationCartReceiverService *cartApplication.CartReceiverService,
	defaultPersonalDataFormProvider DefaultPersonalDataFormProvider,
	customerApplicationService *customerApplication.Service,
	cfg *struct {
		AdditionalFormValues    config.Slice `inject:"config:commerce.cart.personalDataForm.additionalFormFields,optional"`
		DateOfBirthRequired     bool         `inject:"config:commerce.cart.personalDataForm.dateOfBirthRequired,optional"`
		MinAge                  float64      `inject:"config:commerce.cart.personalDataForm.minAge,optional"`
		PassportCountryRequired bool         `inject:"config:commerce.cart.personalDataForm.passportCountryRequired,optional"`
		PassportNumberRequired  bool         `inject:"config:commerce.cart.personalDataForm.passportNumberRequired,optional"`
	},
) *DefaultPersonalDataFormService

Inject - dependencies

func (*DefaultPersonalDataFormService) Validate

func (p *DefaultPersonalDataFormService) Validate(ctx context.Context, req *web.Request, validatorProvider domain.ValidatorProvider, formData interface{}) (*domain.ValidationInfo, error)

Validate form data

type DeliveryForm

type DeliveryForm struct {
	DeliveryAddress AddressForm `form:"deliveryAddress"`
	// UseBillingAddress - the address should be taken from billing (only relevant for type address)
	UseBillingAddress bool      `form:"useBillingAddress"`
	ShippingMethod    string    `form:"shippingMethod"`
	ShippingCarrier   string    `form:"shippingCarrier"`
	LocationCode      string    `form:"locationCode"`
	DesiredTime       time.Time `form:"desiredTime"`
}

DeliveryForm the form for billing address

func (*DeliveryForm) MapToDeliveryInfo

func (d *DeliveryForm) MapToDeliveryInfo(currentInfo cartDomain.DeliveryInfo) cartDomain.DeliveryInfo

MapToDeliveryInfo - updates some fields of the given DeliveryInfo with data from the form

type DeliveryFormController

type DeliveryFormController struct {
	// contains filtered or unexported fields
}

DeliveryFormController the (mini) MVC

func (*DeliveryFormController) GetUnsubmittedForm

func (c *DeliveryFormController) GetUnsubmittedForm(ctx context.Context, r *web.Request) (*domain.Form, error)

GetUnsubmittedForm returns the form with deliveryform data - without validation

func (*DeliveryFormController) HandleFormAction

func (c *DeliveryFormController) HandleFormAction(ctx context.Context, r *web.Request) (form *domain.Form, actionSuccessful bool, err error)

HandleFormAction handles submitted form and saves to cart

func (*DeliveryFormController) Inject

func (c *DeliveryFormController) Inject(responder *web.Responder,
	applicationCartService *cartApplication.CartService,
	applicationCartReceiverService *cartApplication.CartReceiverService,
	logger flamingo.Logger,
	formHandlerFactory application.FormHandlerFactory,
	billingAddressFormProvider *BillingAddressFormService)

Inject dependencies

type DeliveryFormService

type DeliveryFormService struct {
	// contains filtered or unexported fields
}

DeliveryFormService implements Form(Data)Provider interface of form package

func (*DeliveryFormService) GetFormData

func (p *DeliveryFormService) GetFormData(ctx context.Context, req *web.Request) (interface{}, error)

GetFormData from data provider

func (*DeliveryFormService) Inject

func (p *DeliveryFormService) Inject(applicationCartReceiverService *cartApplication.CartReceiverService)

Inject - Inject

func (*DeliveryFormService) Validate

func (p *DeliveryFormService) Validate(ctx context.Context, req *web.Request, validatorProvider domain.ValidatorProvider, formData interface{}) (*domain.ValidationInfo, error)

Validate form service

type PersonalDataForm

type PersonalDataForm interface {
	MapPerson() *cart.Person
	MapAdditionalData() *cart.AdditionalData
}

PersonalDataForm - interface for the form DTO

type PersonalDataFormController

type PersonalDataFormController struct {
	// contains filtered or unexported fields
}

PersonalDataFormController - the (mini) MVC for handling Personal Data (Purchaser)

func (*PersonalDataFormController) GetUnsubmittedForm

func (c *PersonalDataFormController) GetUnsubmittedForm(ctx context.Context, r *web.Request) (*domain.Form, error)

GetUnsubmittedForm returns a Unsubmitted form - using the registered FormService

func (*PersonalDataFormController) HandleFormAction

func (c *PersonalDataFormController) HandleFormAction(ctx context.Context, r *web.Request) (form *domain.Form, actionSuccessFull bool, err error)

HandleFormAction handles post of personal data and updates cart

func (*PersonalDataFormController) Inject

func (c *PersonalDataFormController) Inject(
	responder *web.Responder,
	applicationCartService *cartApplication.CartService,
	applicationCartReceiverService *cartApplication.CartReceiverService,
	logger flamingo.Logger,
	formHandlerFactory application.FormHandlerFactory,
) *PersonalDataFormController

Inject dependencies

type SimplePaymentForm

type SimplePaymentForm struct {
	Gateway string `form:"gateway"  validate:"required"`
	Method  string `form:"method"  validate:"required"`
}

SimplePaymentForm the form for simple select of payment gateway

type SimplePaymentFormController

type SimplePaymentFormController struct {
	// contains filtered or unexported fields
}

SimplePaymentFormController the (mini) MVC

func (*SimplePaymentFormController) GetUnsubmittedForm

func (c *SimplePaymentFormController) GetUnsubmittedForm(ctx context.Context, r *web.Request) (*domain.Form, error)

GetUnsubmittedForm returns unsubmitted

func (*SimplePaymentFormController) HandleFormAction

func (c *SimplePaymentFormController) HandleFormAction(ctx context.Context, r *web.Request) (form *domain.Form, actionSuccessFull bool, err error)

HandleFormAction return the form or error. If the form was submitted the action is performed

func (*SimplePaymentFormController) Inject

func (c *SimplePaymentFormController) Inject(responder *web.Responder,
	applicationCartService *cartApplication.CartService,
	applicationCartReceiverService *cartApplication.CartReceiverService,
	logger flamingo.Logger,
	formHandlerFactory application.FormHandlerFactory,
	simplePaymentFormService *SimplePaymentFormService,
)

Inject dependencies

type SimplePaymentFormService

type SimplePaymentFormService struct {
	// contains filtered or unexported fields
}

SimplePaymentFormService implements Form(Data)Provider interface of form package

func (*SimplePaymentFormService) GetFormData

func (p *SimplePaymentFormService) GetFormData(ctx context.Context, req *web.Request) (interface{}, error)

GetFormData from data provider

func (*SimplePaymentFormService) Inject

func (p *SimplePaymentFormService) Inject(
	applicationCartReceiverService *cartApplication.CartReceiverService,
	config *struct {
		GiftCardPaymentMethod string `inject:"config:commerce.cart.simplePaymentForm.giftCardPaymentMethod"`
	},
)

Inject dependencies

func (*SimplePaymentFormService) MapFormToPaymentSelection

func (p *SimplePaymentFormService) MapFormToPaymentSelection(f SimplePaymentForm, currentCart *cartDomain.Cart) cartDomain.PaymentSelection

MapFormToPaymentSelection maps form values to a valid payment selection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL