diff --git a/frontend/Calculator.elm b/frontend/Calculator.elm index 71043ee..3231ee8 100644 --- a/frontend/Calculator.elm +++ b/frontend/Calculator.elm @@ -96,7 +96,7 @@ view model taxGroup = ] , div [ class "form-input" ] [ label [ for "calculator-tax" ] [ text "Gebindepreis ist" ] - , Select.view SetTax model.tax + , Select.view [] SetTax model.tax ] ] diff --git a/frontend/Entry.elm b/frontend/Entry.elm index d0e1bad..b512f26 100644 --- a/frontend/Entry.elm +++ b/frontend/Entry.elm @@ -210,32 +210,32 @@ view { globals, state } = case state of ] ] ItemEditor model -> - Html.form [] + Html.form [ method "POST", action "/entry/add-to-cart" ] [ fieldset [] [ legend [] [ text "Neuer Inventareintrag" ] , div [ class "form-input" ] [ label [ for "barcode" ] [ text "Barcode" ] - , input [ onInput SetBarcode, value model.barcode, disabled True, id "barcode" ] [] + , input [ onInput SetBarcode, value model.barcode, disabled True, name "barcode", id "barcode" ] [] ] , div [ class "form-input" ] [ label [ for "name" ] [ text "Name" ] - , input [ onInput SetName, value model.name, id "name" ] [] + , input [ onInput SetName, value model.name, name "name", id "name" ] [] ] , div [ class "form-input" ] [ label [ for "sales-units" ] [ text "Stückzahl" ] - , input [ onInput SetSalesUnits, value <| NumberInput.show model.salesUnits, id "sales-units", type_ "number" ] [] + , input [ onInput SetSalesUnits, value <| NumberInput.show model.salesUnits, name "sales-units", id "sales-units", type_ "number" ] [] ] , div [ class "form-input" ] [ label [ for "group" ] [ text "Gruppe" ] - , Select.view SetGroup model.group + , Select.view [ name "group", id "group" ] SetGroup model.group ] , div [ class "form-input" ] [ label [ for "location" ] [ text "Raum" ] - , Select.view SetLocation model.location + , Select.view [ name "location", id "location" ] SetLocation model.location ] , div [ class "form-input" ] [ label [ for "tax-group" ] [ text "Steuergruppe" ] - , Select.view SetTaxGroup model.taxGroup + , Select.view [ name "tax-group", id "tax-group" ] SetTaxGroup model.taxGroup ] , Html.map CalculatorMsg <| Calculator.view model.calculator (Select.get model.taxGroup) , div [ class "form-input" ] @@ -244,6 +244,7 @@ view { globals, state } = case state of [ value <| NumberInput.show model.netUnitPrice , onInput SetNetUnitPrice , type_ "number" + , name "net-unit-price" , id "net-unit-price" , step "0.01" ] @@ -256,12 +257,14 @@ view { globals, state } = case state of [ value <| NumberInput.show model.grossUnitPrice , onInput SetGrossUnitPrice , type_ "number" + , name "gross-unit-price" , id "gross-unit-price" , step "0.01" ] [] , viewSetSuggestedPriceButton model ] + , button [] [ text "In den Warenkorb" ] ] ] diff --git a/frontend/Select.elm b/frontend/Select.elm index 495f86d..26bb473 100644 --- a/frontend/Select.elm +++ b/frontend/Select.elm @@ -1,6 +1,6 @@ module Select exposing (..) -import Html exposing (Html, option, select, text) +import Html exposing (Attribute, Html, option, select, text) import Html.Attributes exposing (selected, value) import Html.Events exposing (onInput) @@ -20,15 +20,15 @@ update key model = Nothing -> model Just x -> { model | selected = x } -view : (String -> m) -> Model a -> Html m -view msg model = +view : List (Attribute m) -> (String -> m) -> Model a -> Html m +view attributes msg model = let viewOption x = option [ selected <| model.identify model.selected == model.identify x, value <| model.identify x ] [ text <| model.show x ] in - select [ onInput msg ] <| List.map viewOption model.options + select ([ onInput msg ] ++ attributes) <| List.map viewOption model.options get : Model a -> a get = .selected diff --git a/jon/static/entry.js b/jon/static/entry.js index 0de63ed..f42209a 100644 --- a/jon/static/entry.js +++ b/jon/static/entry.js @@ -11458,6 +11458,12 @@ var $author$project$Entry$SetTaxGroup = function (a) { return {$: 'SetTaxGroup', a: a}; }; var $author$project$Entry$SubmitSearch = {$: 'SubmitSearch'}; +var $elm$html$Html$Attributes$action = function (uri) { + return A2( + $elm$html$Html$Attributes$stringProperty, + 'action', + _VirtualDom_noJavaScriptUri(uri)); +}; var $elm$json$Json$Encode$bool = _Json_wrap; var $elm$html$Html$Attributes$boolProperty = F2( function (key, bool) { @@ -11475,6 +11481,8 @@ var $author$project$Select$get = function ($) { }; var $elm$html$Html$label = _VirtualDom_node('label'); var $elm$html$Html$legend = _VirtualDom_node('legend'); +var $elm$html$Html$Attributes$method = $elm$html$Html$Attributes$stringProperty('method'); +var $elm$html$Html$Attributes$name = $elm$html$Html$Attributes$stringProperty('name'); var $elm$html$Html$Events$alwaysPreventDefault = function (msg) { return _Utils_Tuple2(msg, true); }; @@ -11619,8 +11627,8 @@ var $elm$html$Html$Attributes$placeholder = $elm$html$Html$Attributes$stringProp var $elm$html$Html$option = _VirtualDom_node('option'); var $elm$html$Html$select = _VirtualDom_node('select'); var $elm$html$Html$Attributes$selected = $elm$html$Html$Attributes$boolProperty('selected'); -var $author$project$Select$view = F2( - function (msg, model) { +var $author$project$Select$view = F3( + function (attributes, msg, model) { var viewOption = function (x) { return A2( $elm$html$Html$option, @@ -11641,10 +11649,12 @@ var $author$project$Select$view = F2( }; return A2( $elm$html$Html$select, - _List_fromArray( - [ - $elm$html$Html$Events$onInput(msg) - ]), + _Utils_ap( + _List_fromArray( + [ + $elm$html$Html$Events$onInput(msg) + ]), + attributes), A2($elm$core$List$map, viewOption, model.options)); }); var $author$project$Calculator$view = F2( @@ -11756,7 +11766,7 @@ var $author$project$Calculator$view = F2( [ $elm$html$Html$text('Gebindepreis ist') ])), - A2($author$project$Select$view, $author$project$Calculator$SetTax, model.tax) + A3($author$project$Select$view, _List_Nil, $author$project$Calculator$SetTax, model.tax) ])) ])); }); @@ -11997,7 +12007,11 @@ var $author$project$Entry$view = function (_v0) { var model = state.a; return A2( $elm$html$Html$form, - _List_Nil, + _List_fromArray( + [ + $elm$html$Html$Attributes$method('POST'), + $elm$html$Html$Attributes$action('/entry/add-to-cart') + ]), _List_fromArray( [ A2( @@ -12037,6 +12051,7 @@ var $author$project$Entry$view = function (_v0) { $elm$html$Html$Events$onInput($author$project$Entry$SetBarcode), $elm$html$Html$Attributes$value(model.barcode), $elm$html$Html$Attributes$disabled(true), + $elm$html$Html$Attributes$name('barcode'), $elm$html$Html$Attributes$id('barcode') ]), _List_Nil) @@ -12065,6 +12080,7 @@ var $author$project$Entry$view = function (_v0) { [ $elm$html$Html$Events$onInput($author$project$Entry$SetName), $elm$html$Html$Attributes$value(model.name), + $elm$html$Html$Attributes$name('name'), $elm$html$Html$Attributes$id('name') ]), _List_Nil) @@ -12094,6 +12110,7 @@ var $author$project$Entry$view = function (_v0) { $elm$html$Html$Events$onInput($author$project$Entry$SetSalesUnits), $elm$html$Html$Attributes$value( $author$project$NumberInput$show(model.salesUnits)), + $elm$html$Html$Attributes$name('sales-units'), $elm$html$Html$Attributes$id('sales-units'), $elm$html$Html$Attributes$type_('number') ]), @@ -12117,7 +12134,15 @@ var $author$project$Entry$view = function (_v0) { [ $elm$html$Html$text('Gruppe') ])), - A2($author$project$Select$view, $author$project$Entry$SetGroup, model.group) + A3( + $author$project$Select$view, + _List_fromArray( + [ + $elm$html$Html$Attributes$name('group'), + $elm$html$Html$Attributes$id('group') + ]), + $author$project$Entry$SetGroup, + model.group) ])), A2( $elm$html$Html$div, @@ -12137,7 +12162,15 @@ var $author$project$Entry$view = function (_v0) { [ $elm$html$Html$text('Raum') ])), - A2($author$project$Select$view, $author$project$Entry$SetLocation, model.location) + A3( + $author$project$Select$view, + _List_fromArray( + [ + $elm$html$Html$Attributes$name('location'), + $elm$html$Html$Attributes$id('location') + ]), + $author$project$Entry$SetLocation, + model.location) ])), A2( $elm$html$Html$div, @@ -12157,7 +12190,15 @@ var $author$project$Entry$view = function (_v0) { [ $elm$html$Html$text('Steuergruppe') ])), - A2($author$project$Select$view, $author$project$Entry$SetTaxGroup, model.taxGroup) + A3( + $author$project$Select$view, + _List_fromArray( + [ + $elm$html$Html$Attributes$name('tax-group'), + $elm$html$Html$Attributes$id('tax-group') + ]), + $author$project$Entry$SetTaxGroup, + model.taxGroup) ])), A2( $elm$html$Html$map, @@ -12192,6 +12233,7 @@ var $author$project$Entry$view = function (_v0) { $author$project$NumberInput$show(model.netUnitPrice)), $elm$html$Html$Events$onInput($author$project$Entry$SetNetUnitPrice), $elm$html$Html$Attributes$type_('number'), + $elm$html$Html$Attributes$name('net-unit-price'), $elm$html$Html$Attributes$id('net-unit-price'), $elm$html$Html$Attributes$step('0.01') ]), @@ -12224,11 +12266,19 @@ var $author$project$Entry$view = function (_v0) { $author$project$NumberInput$show(model.grossUnitPrice)), $elm$html$Html$Events$onInput($author$project$Entry$SetGrossUnitPrice), $elm$html$Html$Attributes$type_('number'), + $elm$html$Html$Attributes$name('gross-unit-price'), $elm$html$Html$Attributes$id('gross-unit-price'), $elm$html$Html$Attributes$step('0.01') ]), _List_Nil), $author$project$Entry$viewSetSuggestedPriceButton(model) + ])), + A2( + $elm$html$Html$button, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('In den Warenkorb') ])) ])) ]));