Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Read more about this program in the official Elm guide:
- -- https://guide.elm-lang.org/architecture/user_input/buttons.html
- import Html exposing (beginnerProgram, div, button, text,input)
- import Html.Events exposing (onClick, onInput)
- import Html.Attributes exposing (style)
- main =
- beginnerProgram { model = init , update = update, view = view} -- co sie stanie jak wyjebie stad model?
- type alias Records = {
- name: String,
- date: String,
- priority: Int
- }
- --fajnie by bylo jakby od razu sortowalo po priority
- type alias Model = {
- input : String,
- tasks : List Records
- }
- init : Model
- init = Model "" []
- type Msg =
- Add
- | Del
- | DelCheckbox String
- | Input String
- update msg model=
- case msg of
- Del ->
- (model.input (List.filter (\x-> x/=model.input) [model.tasks]))
- Add ->
- (model.input (List.append model.input [model.input]))
- -- Input str -> zero idea wat da fuck it is doing
- -- (model str model.tasks)
- DelCheckbox str -> --jak zmienic aby str bylo Records-em?
- (model.input (List.filter (\x-> x/= str) [model.tasks]))
- view : Model -> Html.Html Msg
- view model =
- div []
- [ input [ onInput Input] []
- , button [onClick Add] [text "Add"]
- , button [onClick Del] [text "Delete"]
- , div [style [("padding", "50px")]] (List.map viewCheckbox model.tasks)
- ]
- viewMessage : String -> Html.Html msg
- viewMessage msg =
- div [] [ text msg ]
- viewCheckbox : Records -> Html.Html Msg
- viewCheckbox msg =
- div [] [ input [ Html.Attributes.type_ "checkbox", onClick (DelCheckbox msg)] []
- , text msg
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement