Something went wrong. Try again.
A simple convention app I decided to make for myself and share dhershman.tngl.io/con-goer
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287module Types exposing ( Editing(..) , ListFilter(..) , LogSheet , Model , Msg(..) , Screen(..) , SheetTarget(..) , Transfer , TransferNote(..) , TransferScope(..) , activeConvention , conventionsInScope , draftText , filterLabel , withDraft )
{-| Application state: what is on screen, what is half-typed, what is open
This is separate from Data on purpose, Data is the stuff worth saving.
Everything here is throwaway UI state that should not survive a reload,with the single exception of which convention is active.
It also lives in its own module so that Main and the `View.*` modules canboth see Msg without importing each other
-}
import Data exposing (Condition, Convention, ConventionId, ItemId, Priority)import Date exposing (Date)import File exposing (File)
type alias Model = { conventions : List Convention , active : Maybe ConventionId , screen : Screen , sheet : Maybe LogSheet , editing : Editing , loadError : Maybe String , today : Date , nextConventionId : Int
-- Which convention the shelf is asking you to confirm removing -- Armed by one tap, fired by a second, cleared by doing anything else , confirmDelete : Maybe ConventionId
-- Section and page you were last looking at in the binder -- Keep things speedy and fresh , binderSpot : ( Int, Int )
-- The move-data-between-devices panel, when it is open , transfer : Maybe Transfer }
type Screen = Shelf | Binder Int Int | ListView ListFilter String | Lookup String
type ListFilter = AllItems | MustFindOnly | OpenOnly | FoundOnly
filterLabel : ListFilter -> StringfilterLabel filter = case filter of AllItems -> "All"
MustFindOnly -> "Must find"
OpenOnly -> "Open"
FoundOnly -> "Found"
-- MOVING DATA BETWEEN DEVICES
{-| The open transfer panel
Lives here rather than in Data because none of it is worth saving! Close thepanel and there is nothing left to remember, bye bye!
-}type alias Transfer = { scope : TransferScope , paste : String , note : Maybe TransferNote , copied : Maybe Bool }
{-| What you are sending outAre we sending out a single convention, or all of them?-}type TransferScope = WholeShelf | JustConvention ConventionId
{-| How the last import went. Shown in the panel and nowhere else-}type TransferNote = Imported Int | ImportFailed String
-- LOG SHEET
{-| The bottom sheet for recording a find-}type alias LogSheet = { target : SheetTarget , name : String , priority : Priority , lowText : String , highText : String , paidText : String , quantity : Int , condition : Condition , booth : String , note : String }
type SheetTarget = NewItem Int | ExistingItem ItemId
-- INLINE EDITING
type Editing = NotEditing | EditingName String | EditingBudget String | EditingVenue String | EditingDate String | EditingSection Int String
{-| The half-typed text inside whichever editor is open-}draftText : Editing -> StringdraftText editing = case editing of NotEditing -> ""
EditingName text -> text
EditingBudget text -> text
EditingVenue text -> text
EditingDate text -> text
EditingSection _ text -> text
{-| Replace the draft text, keeping whichever editor is open-}withDraft : String -> Editing -> EditingwithDraft text editing = case editing of NotEditing -> NotEditing
EditingName _ -> EditingName text
EditingBudget _ -> EditingBudget text
EditingVenue _ -> EditingVenue text
EditingDate _ -> EditingDate text
EditingSection index _ -> EditingSection index text
-- HELPERS
activeConvention : Model -> Maybe ConventionactiveConvention model = model.active |> Maybe.andThen (\id -> model.conventions |> List.filter (\convention -> convention.id == id) |> List.head )
{-| The conventions a transfer would send-}conventionsInScope : Model -> TransferScope -> List ConventionconventionsInScope model scope = case scope of WholeShelf -> model.conventions
JustConvention id -> List.filter (\convention -> convention.id == id) model.conventions
-- MESSAGES
type Msg = NoOp -- Navigation | GoToShelf | OpenConvention ConventionId | SetScreen Screen | SelectSection Int | SelectPage Int | SetListFilter ListFilter | SetListSearch String | SetLookupQuery String -- The convention itself | StartEditing Editing | EditDraft String | CommitEditing | CancelEditing | CycleStatus | CreateConvention | ConfirmDelete ConventionId | DeleteConvention ConventionId | AddSection -- The log sheet | OpenNewItem Int | OpenItem ItemId | CloseSheet | SheetName String | SheetPriority Priority | SheetLow String | SheetHigh String | SheetPaid String | SheetQuantity Int | SheetCondition Condition | SheetBooth String | SheetNote String | CommitSheet | PassItem | ResumeHunting | DeleteItem -- Moving data between devices | OpenTransfer TransferScope | CloseTransfer | SaveTransferFile | PickImportFile | ImportFileSelected File | EditImportPaste String | ImportNow String | CopyText String | CopyFinished Bool