formats

package
v0.0.0-...-15e6d3b Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncIndentedJson

func EncIndentedJson(w io.Writer, e interface{}) error

func EncJsonToFile

func EncJsonToFile(fileName string, e interface{}) (err error)

Types

type AjfForm

type AjfForm struct {
	StringIdentifier []Tag                  `json:"stringIdentifier,omitempty"`
	ChoicesOrigins   []ChoicesOrigin        `json:"choicesOrigins,omitempty"`
	Slides           []Node                 `json:"nodes"`
	Translations     map[string]Translation `json:"translations,omitempty"`
}

func Convert

func Convert(xls *XlsForm) (*AjfForm, error)

type Choice

type Choice map[string]string

Choice has fields "value", "label" and possibly others defined by the user to be used in choice filters.

type ChoiceType

type ChoiceType string
const CtString ChoiceType = "string"

type ChoicesOrigin

type ChoicesOrigin struct {
	Type        OriginType `json:"type"`
	Name        string     `json:"name"`
	ChoicesType ChoiceType `json:"choicesType"`
	Choices     []Choice   `json:"choices"`
}

type ChoicesRow

type ChoicesRow struct{ Row }

func MakeChoicesRow

func MakeChoicesRow(keyVals ...string) ChoicesRow

func (ChoicesRow) Label

func (r ChoicesRow) Label(lang string) string

func (ChoicesRow) ListName

func (r ChoicesRow) ListName() string

func (ChoicesRow) Name

func (r ChoicesRow) Name() string

func (ChoicesRow) UserDefCells

func (r ChoicesRow) UserDefCells() map[string]string

type Condition

type Condition struct {
	Condition string `json:"condition"`
}

type FieldType

type FieldType int
var (
	FtString         FieldType = 0
	FtText           FieldType = 1
	FtNumber         FieldType = 2
	FtBoolean        FieldType = 3
	FtSingleChoice   FieldType = 4
	FtMultipleChoice FieldType = 5
	FtFormula        FieldType = 6
	FtNote           FieldType = 7
	FtDate           FieldType = 9
	FtTime           FieldType = 10
	FtTable          FieldType = 11
	FtGeolocation    FieldType = 12
	FtBarcode        FieldType = 13
	FtFile           FieldType = 14
	FtImage          FieldType = 15
	FtVideoUrl       FieldType = 16
	FtRange          FieldType = 17
	FtSignature      FieldType = 18
)

type FieldValidation

type FieldValidation struct {
	NotEmpty    bool                  `json:"notEmpty,omitempty"`
	NotEmptyMsg string                `json:"notEmptyMessage,omitempty"`
	Conditions  []ValidationCondition `json:"conditions,omitempty"`
}

type File

type File interface {
	io.Reader
	io.ReaderAt
	io.Seeker
}

type Formula

type Formula struct {
	Formula  string `json:"formula"`
	Editable *bool  `json:"editable,omitempty"`
}

type Node

type Node struct {
	Previous   int      `json:"parent"`
	Id         int      `json:"id"`
	Name       string   `json:"name"`
	Label      string   `json:"label"`
	Hint       string   `json:"hint,omitempty"`
	DefaultVal *Formula `json:"defaultValue,omitempty"`
	Editable   *bool    `json:"editable,omitempty"`
	Type       NodeType `json:"nodeType"`

	FieldType        *FieldType       `json:"fieldType,omitempty"`
	RangeStart       *int             `json:"start,omitempty"`
	RangeEnd         *int             `json:"end,omitempty"`
	RangeStep        *int             `json:"step,omitempty"`
	ChoicesOriginRef string           `json:"choicesOriginRef,omitempty"`
	ChoicesFilter    *Formula         `json:"choicesFilter,omitempty"`
	ForceNarrow      bool             `json:"forceNarrow,omitempty"`
	HTML             string           `json:"HTML,omitempty"`
	MaxReps          *int             `json:"maxReps,omitempty"`
	Formula          *Formula         `json:"formula,omitempty"`
	ColumnTypes      []string         `json:"columnTypes,omitempty"`
	ColumnLabels     []string         `json:"columnLabels,omitempty"`
	RowLabels        []string         `json:"rowLabels,omitempty"`
	Validation       *FieldValidation `json:"validation,omitempty"`
	Visibility       *Condition       `json:"visibility,omitempty"`
	ReadOnly         *Condition       `json:"readonly,omitempty"`
	Rows             [][]interface{}  `json:"rows,omitempty"`
	Nodes            []Node           `json:"nodes,omitempty"`
}

type NodeType

type NodeType int
const (
	NtField NodeType = iota

	NtGroup
	NtSlide
	NtRepeatingSlide
)

type OriginType

type OriginType string
const OtFixed OriginType = "fixed"

type Row

type Row struct {
	LineNum int
	// contains filtered or unexported fields
}

type SettingsRow

type SettingsRow struct{ Row }

func MakeSettingsRow

func MakeSettingsRow(keyVals ...string) SettingsRow

func (SettingsRow) TagLabel

func (r SettingsRow) TagLabel() string

func (SettingsRow) TagValue

func (r SettingsRow) TagValue() string

type SurveyRow

type SurveyRow struct {
	Row
	// Type is kept here as an optimization,
	// to avoid accessing Row.cells["type"] too frequently.
	Type string
}

func MakeSurveyRow

func MakeSurveyRow(keyVals ...string) SurveyRow

func (SurveyRow) Appearance

func (r SurveyRow) Appearance() string

func (SurveyRow) Calculation

func (r SurveyRow) Calculation() string

func (SurveyRow) ChoiceFilter

func (r SurveyRow) ChoiceFilter() string

func (SurveyRow) Constraint

func (r SurveyRow) Constraint() string

func (SurveyRow) ConstraintMsg

func (r SurveyRow) ConstraintMsg(lang string) string

func (SurveyRow) Default

func (r SurveyRow) Default() string

func (SurveyRow) Hint

func (r SurveyRow) Hint(lang string) string

func (SurveyRow) Label

func (r SurveyRow) Label(lang string) string

func (SurveyRow) Name

func (r SurveyRow) Name() string

func (SurveyRow) Parameters

func (r SurveyRow) Parameters() string

func (SurveyRow) ReadOnly

func (r SurveyRow) ReadOnly() string

func (SurveyRow) Relevant

func (r SurveyRow) Relevant() string

func (SurveyRow) RepeatCount

func (r SurveyRow) RepeatCount() string

func (SurveyRow) Required

func (r SurveyRow) Required() string

func (SurveyRow) RequiredMessage

func (r SurveyRow) RequiredMessage(lang string) string

type Tag

type Tag struct {
	Label string    `json:"label"`
	Value [1]string `json:"value"`
}

type Translation

type Translation = map[string]string

type ValidationCondition

type ValidationCondition struct {
	Condition        string `json:"condition"`
	ClientValidation bool   `json:"clientValidation"` // always true
	ErrorMessage     string `json:"errorMessage,omitempty"`
}

type WorkBook

type WorkBook interface {
	Rows(sheetName string) [][]string
}

func NewWorkBook

func NewWorkBook(f File, ext string, size int64) (WorkBook, error)

type XlsForm

type XlsForm struct {
	Survey   []SurveyRow
	Choices  []ChoicesRow
	Settings []SettingsRow
	Tables   map[string][][]string
	LangSet  map[string]bool
}

func DecXlsFromFile

func DecXlsFromFile(fileName string) (*XlsForm, error)

func DecXlsform

func DecXlsform(wb WorkBook) (*XlsForm, error)

Jump to

Keyboard shortcuts

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