flex-tasks
Safe HaskellNone
LanguageHaskell2010

FlexTask.InputTypes

Description

Premade data types for specific form needs.

Synopsis

Documentation

newtype MultipleChoice a Source #

Wrapper representing zero or more selected values in a multiple-choice field.

Constructors

MultipleChoice 

Fields

Instances

Instances details
Parse MultipleChoiceSelection Source # 
Instance details

Defined in FlexTask.Parser.Internal

Formify (MultipleChoice a) Source # 
Instance details

Defined in FlexTask.Form.Formify

Associated Types

type FormTypes (MultipleChoice a) 
Instance details

Defined in FlexTask.Form.Formify

Methods

formDefaults :: Maybe (MultipleChoice a) -> TypeList (FormTypes (MultipleChoice a))

Generic (MultipleChoice a) Source # 
Instance details

Defined in FlexTask.InputTypes

Associated Types

type Rep (MultipleChoice a) 
Instance details

Defined in FlexTask.InputTypes

type Rep (MultipleChoice a) = D1 ('MetaData "MultipleChoice" "FlexTask.InputTypes" "flex-tasks-0.1-1PNyq9qaMlVqATQpg44xv" 'True) (C1 ('MetaCons "MultipleChoice" 'PrefixI 'True) (S1 ('MetaSel ('Just "getChoices") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a])))
Show a => Show (MultipleChoice a) Source # 
Instance details

Defined in FlexTask.InputTypes

Eq a => Eq (MultipleChoice a) Source # 
Instance details

Defined in FlexTask.InputTypes

type FormTypes (MultipleChoice a) Source # 
Instance details

Defined in FlexTask.Form.Formify

type Rep (MultipleChoice a) Source # 
Instance details

Defined in FlexTask.InputTypes

type Rep (MultipleChoice a) = D1 ('MetaData "MultipleChoice" "FlexTask.InputTypes" "flex-tasks-0.1-1PNyq9qaMlVqATQpg44xv" 'True) (C1 ('MetaCons "MultipleChoice" 'PrefixI 'True) (S1 ('MetaSel ('Just "getChoices") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a])))

newtype Hidden a Source #

Wrapper type for generating hidden fields. This can be used to transfer static information through the form to parsing. Note that the generated field still has a label. If the label is not left blank, then it will be displayed as normal.

The user can inspect and modify the contents of a hidden field. Do not use hidden fields for sensitive information or values whose integrity must be trusted.

Example

Expand
>>> printWidget "en" $ formify (Just $ Hidden 3) $ basic ""
<div class="flex-form-div form-group">
...
    <label for="flexident1">
    </label>
    <input type="hidden" id="flexident1" ... value="3">
...
</div>

Constructors

Hidden 

Fields

Instances

Instances details
(Formify a, PathPiece a) => BaseField (Hidden a) Source # 
Instance details

Defined in FlexTask.Form.Core

Formify (Hidden a) Source # 
Instance details

Defined in FlexTask.Form.Formify

Associated Types

type FormTypes (Hidden a) 
Instance details

Defined in FlexTask.Form.Formify

Methods

formDefaults :: Maybe (Hidden a) -> TypeList (FormTypes (Hidden a))

Show a => Show (Hidden a) Source # 
Instance details

Defined in FlexTask.InputTypes

Methods

showsPrec :: Int -> Hidden a -> ShowS #

show :: Hidden a -> String #

showList :: [Hidden a] -> ShowS #

Eq a => Eq (Hidden a) Source # 
Instance details

Defined in FlexTask.InputTypes

Methods

(==) :: Hidden a -> Hidden a -> Bool #

(/=) :: Hidden a -> Hidden a -> Bool #

PathPiece a => PathPiece (Hidden a) Source # 
Instance details

Defined in FlexTask.InputTypes

type FormTypes (Hidden a) Source # 
Instance details

Defined in FlexTask.Form.Formify

newtype SingleInputList a Source #

Wrapper type for lists. Use for a single field list input. Normally, lists are interpreted as multiple fields instead.

Example

Expand
>>> printWidget "en" $ formify @(SingleInputList String) Nothing $ basic "Input comma separated sentences"
<div class="flex-form-div form-group">
...
    <label for="flexident1">
      Input comma separated sentences
    </label>
    <input id="flexident1" ... type="text" ...>
...
</div>

Note that this does not actually enforce any kind of input syntax. The generated input itself is a simple text field. The comma separation is checked only when parsing with the matching formParser.

Constructors

SingleInputList 

Fields

Instances

Instances details
Show a => BaseField (SingleInputList a) Source # 
Instance details

Defined in FlexTask.Form.Core

Formify (SingleInputList a) Source # 
Instance details

Defined in FlexTask.Form.Formify

Associated Types

type FormTypes (SingleInputList a) 
Instance details

Defined in FlexTask.Form.Formify

Parse (SingleInputList Text) Source # 
Instance details

Defined in FlexTask.Parser.Internal

Parse (SingleInputList Textarea) Source # 
Instance details

Defined in FlexTask.Parser.Internal

Parse (SingleInputList Integer) Source # 
Instance details

Defined in FlexTask.Parser.Internal

Parse (SingleInputList String) Source # 
Instance details

Defined in FlexTask.Parser.Internal

Parse (SingleInputList Bool) Source # 
Instance details

Defined in FlexTask.Parser.Internal

Parse (SingleInputList Double) Source # 
Instance details

Defined in FlexTask.Parser.Internal

Parse (SingleInputList Int) Source # 
Instance details

Defined in FlexTask.Parser.Internal

Show a => Show (SingleInputList a) Source # 
Instance details

Defined in FlexTask.InputTypes

Eq a => Eq (SingleInputList a) Source # 
Instance details

Defined in FlexTask.InputTypes

type FormTypes (SingleInputList a) Source # 
Instance details

Defined in FlexTask.Form.Formify

data SingleChoiceSelection Source #

Generic single choice answer type. Use if both of the following are true:

  • You want an input that presents multiple answer choices, but only allows a single selection.
  • There's no specific data type associated with this selection.

Instances

Instances details
Formify SingleChoiceSelection Source # 
Instance details

Defined in FlexTask.Form.Formify

Parse MultipleChoiceSelection Source # 
Instance details

Defined in FlexTask.Parser.Internal

Parse SingleChoiceSelection Source # 
Instance details

Defined in FlexTask.Parser.Internal

Generic SingleChoiceSelection Source # 
Instance details

Defined in FlexTask.InputTypes

Associated Types

type Rep SingleChoiceSelection 
Instance details

Defined in FlexTask.InputTypes

type Rep SingleChoiceSelection = D1 ('MetaData "SingleChoiceSelection" "FlexTask.InputTypes" "flex-tasks-0.1-1PNyq9qaMlVqATQpg44xv" 'True) (C1 ('MetaCons "SingleChoiceSelection" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAnswer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))
Show SingleChoiceSelection Source # 
Instance details

Defined in FlexTask.InputTypes

Eq SingleChoiceSelection Source # 
Instance details

Defined in FlexTask.InputTypes

type FormTypes SingleChoiceSelection Source # 
Instance details

Defined in FlexTask.Form.Formify

type Rep SingleChoiceSelection Source # 
Instance details

Defined in FlexTask.InputTypes

type Rep SingleChoiceSelection = D1 ('MetaData "SingleChoiceSelection" "FlexTask.InputTypes" "flex-tasks-0.1-1PNyq9qaMlVqATQpg44xv" 'True) (C1 ('MetaCons "SingleChoiceSelection" 'PrefixI 'True) (S1 ('MetaSel ('Just "getAnswer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

singleChoiceAnswer :: Int -> SingleChoiceSelection Source #

Value with given number option selected.

singleChoiceEmpty :: SingleChoiceSelection Source #

Deprecated: This function only existed to satisfy a legacy interface in Autotool. It will be removed in a future version.

Value with no option selected.

getAnswer :: SingleChoiceSelection -> Int Source #

Retrieve the selected option. (The first selectable option is 1)

getAnswerAsIndex :: SingleChoiceSelection -> Int Source #

Same as getAnswer but the selections are counted from 0 instead of from 1. Use if you want to pass the selected answer to an indexing function like !! or !?.

type MultipleChoiceSelection = MultipleChoice SingleChoiceSelection Source #

Same as SingleChoiceSelection, but for multiple choice input. Use if both of the following are true:

  • You want an input that presents multiple answer choices and allows selecting any number of them.
  • There's no specific data type associated with this selection.

multipleChoiceAnswer :: [Int] -> MultipleChoiceSelection Source #

Value with given list of options selected. Sorts the input list and removes duplicates.

multipleChoiceEmpty :: MultipleChoiceSelection Source #

Value with no options selected.

getAnswers :: MultipleChoiceSelection -> [Int] Source #

Retrieve the list of selected options. The first selectable option is 1. [] if none are selected.

getAnswersAsIndices :: MultipleChoiceSelection -> [Int] Source #

Same as getAnswers but the selections are counted from 0 instead of from 1. Use if you want to pass the selected answers to an indexing function like !! or !?.