AnnotationDocumentView.purs 6.21 KB
Newer Older
1
module AnnotationDocumentView where
2 3

import Prelude hiding (div)
4
import React (ReactElement)
5 6
import React.DOM (a, button, div, h4, h6, input, li, nav, option, p, select, span, text, ul)
import React.DOM.Props (_data, _id, _type, aria, className, href, name, onChange, onInput, placeholder, role, selected, style, value)
7 8
import Thermite (PerformAction, Render, Spec, cotransform, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce)
9 10


11 12 13 14
type State =
  {
    inputValue :: String
  }
15 16

initialState :: State
17 18 19 20
initialState =
  {
    inputValue : ""
  }
21 22


23 24 25 26
data Action
  = NoOp
  | ChangeString String
  | ChangeAnotherString String
27
  | SetInput String
28 29 30 31 32


performAction :: PerformAction _ State _ Action
performAction NoOp _ _ = pure unit

33 34 35 36
performAction (ChangeString ps) _ _ = pure unit

performAction (ChangeAnotherString ps) _ _ = pure unit

Abinaya Sudhir's avatar
Abinaya Sudhir committed
37 38
performAction (SetInput ps) _ _ = void do
  modifyState \( state) ->  state { inputValue = ps }
39

40 41 42 43 44 45 46


docview :: Spec _ State _ Action
docview = simpleSpec performAction render
  where
    render :: Render State _ Action
    render dispatch _ state _ =
47
      [
Abinaya Sudhir's avatar
Abinaya Sudhir committed
48
          div [className "container1"]
49 50 51 52
          [
            div [className "row"]
            [
              div [className "col-md-4", style {border : "1px solid black", padding : "34px"}]
53
              [
54 55 56 57
                div [className "row"]
                [
                  div [className "col-md-12 input-group mb-3"] [select [className "form-control custom-select",onChange (\e -> dispatch (ChangeString $ (unsafeCoerce e).target.value)) ] $ map optps aryPS ]
                , div [className "col-md-12 form-control input-group mb-3"] [ select [className "form-control custom-select",onChange (\e -> dispatch (ChangeAnotherString $ (unsafeCoerce e).target.value)) ] $ map optps aryPS1 ]
58
                ]
59 60 61 62
              , div [className "row", style { marginTop : "35px"}]
                [
                  nav [ ]
                  [ div [className "nav nav-tabs", _id "nav-tab",role "tablist"]
63 64 65
                    [ a [className "nav-item nav-link active",_id "nav-home-tab"   ,  _data {toggle : "tab"},href "#nav-home"   ,role "tab",aria {controls : "nav-home"}   ,aria {selected:true}] [ text "STOPLIST"]
                    , a [className "nav-item nav-link"       ,_id "nav-profile-tab",  _data {toggle : "tab"},href "#nav-profile",role "tab",aria {controls : "nav-profile"},aria {selected:true}] [ text "MAINLIST"]
                    , a [className "nav-item nav-link"       ,_id "nav-contact-tab",  _data {toggle : "tab"},href "#nav-contact",role "tab",aria {controls : "nav-contact"},aria {selected:true}] [ text "MAPLIST"]
66

67
                    ]
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
                  ]
                , div [className "tab-content" , _id "nav-tabContent"]
                  [
                    div [ className "tab-pane fade show active"
                        , role "tabpanel"
                        , aria {labelledby : "nav-home-tab"}
                        , _id "nav-home"
                        ]
                    [
                      h6 [] [text "Add a free term to STOPLIST"]
                    ,  div [className "form-group"]
                       [ input [className "form-control", _id "id_password", name "password", placeholder "Any text", _type "value",value state.inputValue,onInput \e -> dispatch (SetInput (unsafeEventValue e))] []
                       , div [className "clearfix"] []
                       ]
                    , button [className "btn btn-primary", _type "button"] [text "Create and Add"]
83 84
                    ]

85 86 87 88 89 90 91 92 93 94 95 96 97 98
                  , div [ className "tab-pane fade show"
                        , role "tabpanel"
                        , aria {labelledby : "nav-profile-tab"}
                        , _id "nav-profile"
                        ]
                    [ ]
                  , div [ className "tab-pane fade show"
                        , role "tabpanel"
                        , aria {labelledby : "nav-contact-tab"}
                        , _id "nav-contact"
                        ]
                    [ ]
                  ]
                ]
99
              ]
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
            , div [className "col-md-8"]
              [ h4 [] [text "Ultrasonic sensors in urban traffic driving-aid systems"]
              , ul [className "list-group"]
                [ li [className "list-group-item justify-content-between"]
                  [  span [] [text "Sensors (Basel, switzerland)"]
                  , span [className "badge badge-default badge-pill"] [text "source"]
                  ]
                , li [className "list-group-item justify-content-between"]
                  [  span [] [text "Luciano Alonso, Vicente Milanes, Carlos Torre-Ferarro, Jorge Godoy, Juan P oria, Teresa de pedro"]
                  , span [className "badge badge-default badge-pill"] [text "authors"]
                  ]

                , li [className "list-group-item justify-content-between"]
                  [  span [] [text "2011-01-11 0.00"]
                  , span [className "badge badge-default badge-pill"] [text "date"]
                  ]
                ]
              , span [className "badge badge-default badge-pill"] [text "abstract"]
              , p [] [text "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like)."]
              , div [className "jumbotron"]
                [ p [] [text "Empty Full Text"]
                ]
122
              ]
123 124 125
            ]
          ]
      ]
126 127 128 129 130 131 132 133 134 135 136

aryPS :: Array String
aryPS = ["STOPLIST", "MAINLIST", "MAPLIST"]

aryPS1 :: Array String
aryPS1 = ["Nothing Selected","STOPLIST", "MAINLIST", "MAPLIST"]


optps :: String -> ReactElement
optps val = option [ value  val ] [text  val]

137 138
unsafeEventValue :: forall event. event -> String
unsafeEventValue e = (unsafeCoerce e).target.value