popup

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentPopupIsntMatchingWithGivenId = fmt.Errorf("given id is not matching with the current popup")
View Source
var NoCurrentPopup = fmt.Errorf("no active current popup")
View Source
var PopupOptionRedirectTargetKey = "redirectTo"

Functions

This section is empty.

Types

type PopupAnswerResponse

type PopupAnswerResponse struct {
	Id    string `json:"id"`
	Value string `json:"value"`
}

PopupAnswerResponse is the container of the data to validate/answer shown popup form.

type PopupAnswerValidationResult

type PopupAnswerValidationResult struct {
	Id              string `json:"id"`
	ValidationError string `json:"validationError"`
}

PopupAnswerValidationResult is the type passed from the frontend to validate the popup.

type PopupForm

type PopupForm interface {
	// GetMetadata return the metadata type needed to show the form to frontend
	GetMetadata() PopupFormMetadata
	// Validate receives the input from frontend and returns validation result
	Validate(req *PopupAnswerResponse) string
}

PopupForm is an abstract interface to represent the type to define the form shown from backend to frontend.

type PopupFormMetadata

type PopupFormMetadata struct {
	// The title of this form
	Title string
	// Type of input field. Currently, only `text` or `popup_redirect` is the supported value.
	Type string
	// Description of this form.
	Description string
	Placeholder string

	// The other option values of the request.
	Options map[string]string `json:"options"`
}

PopupFormMetadata contains data needed for showing input ui on frontend side.

type PopupFormRequest

type PopupFormRequest struct {
	Id          string            `json:"id"`
	Title       string            `json:"title"`
	Type        string            `json:"type"`
	Description string            `json:"description"`
	Placeholder string            `json:"placeholder"`
	Options     map[string]string `json:"options"`
}

PopupFormRequest is a popup display request that is actually passed to the frontend.

type PopupManager

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

PopupManager receives questions shown to user from frontend.

var Instance *PopupManager = NewPopupManager()

func NewPopupManager

func NewPopupManager() *PopupManager

func (*PopupManager) Answer

func (p *PopupManager) Answer(request *PopupAnswerResponse) error

Answer determine the result of the form. This method assume the request is already validated before.

func (*PopupManager) GetCurrentPopup

func (p *PopupManager) GetCurrentPopup() *PopupFormRequest

GetCurrentPopup returns currently active popup request data needed in frontend side to show the popup

func (*PopupManager) ShowPopup

func (p *PopupManager) ShowPopup(popup PopupForm) (string, error)

ShowPopup shows the popup UI on frontend side and wait until receiving the input.

func (*PopupManager) Validate

Validate receives form input and check if the request is valid to receive. If it was not valid, it returns validation error in string.

Jump to

Keyboard shortcuts

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