Make entry for submittable

This commit is contained in:
Paul Brinkmeier 2023-08-20 18:45:04 +02:00
parent 8cb62dbacb
commit cb41e61c47
4 changed files with 76 additions and 23 deletions

View File

@ -96,7 +96,7 @@ view model taxGroup =
] ]
, div [ class "form-input" ] , div [ class "form-input" ]
[ label [ for "calculator-tax" ] [ text "Gebindepreis ist" ] [ label [ for "calculator-tax" ] [ text "Gebindepreis ist" ]
, Select.view SetTax model.tax , Select.view [] SetTax model.tax
] ]
] ]

View File

@ -210,32 +210,32 @@ view { globals, state } = case state of
] ]
] ]
ItemEditor model -> ItemEditor model ->
Html.form [] Html.form [ method "POST", action "/entry/add-to-cart" ]
[ fieldset [] [ fieldset []
[ legend [] [ text "Neuer Inventareintrag" ] [ legend [] [ text "Neuer Inventareintrag" ]
, div [ class "form-input" ] , div [ class "form-input" ]
[ label [ for "barcode" ] [ text "Barcode" ] [ 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" ] , div [ class "form-input" ]
[ label [ for "name" ] [ text "Name" ] [ 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" ] , div [ class "form-input" ]
[ label [ for "sales-units" ] [ text "Stückzahl" ] [ 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" ] , div [ class "form-input" ]
[ label [ for "group" ] [ text "Gruppe" ] [ label [ for "group" ] [ text "Gruppe" ]
, Select.view SetGroup model.group , Select.view [ name "group", id "group" ] SetGroup model.group
] ]
, div [ class "form-input" ] , div [ class "form-input" ]
[ label [ for "location" ] [ text "Raum" ] [ label [ for "location" ] [ text "Raum" ]
, Select.view SetLocation model.location , Select.view [ name "location", id "location" ] SetLocation model.location
] ]
, div [ class "form-input" ] , div [ class "form-input" ]
[ label [ for "tax-group" ] [ text "Steuergruppe" ] [ 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) , Html.map CalculatorMsg <| Calculator.view model.calculator (Select.get model.taxGroup)
, div [ class "form-input" ] , div [ class "form-input" ]
@ -244,6 +244,7 @@ view { globals, state } = case state of
[ value <| NumberInput.show model.netUnitPrice [ value <| NumberInput.show model.netUnitPrice
, onInput SetNetUnitPrice , onInput SetNetUnitPrice
, type_ "number" , type_ "number"
, name "net-unit-price"
, id "net-unit-price" , id "net-unit-price"
, step "0.01" , step "0.01"
] ]
@ -256,12 +257,14 @@ view { globals, state } = case state of
[ value <| NumberInput.show model.grossUnitPrice [ value <| NumberInput.show model.grossUnitPrice
, onInput SetGrossUnitPrice , onInput SetGrossUnitPrice
, type_ "number" , type_ "number"
, name "gross-unit-price"
, id "gross-unit-price" , id "gross-unit-price"
, step "0.01" , step "0.01"
] ]
[] []
, viewSetSuggestedPriceButton model , viewSetSuggestedPriceButton model
] ]
, button [] [ text "In den Warenkorb" ]
] ]
] ]

View File

@ -1,6 +1,6 @@
module Select exposing (..) 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.Attributes exposing (selected, value)
import Html.Events exposing (onInput) import Html.Events exposing (onInput)
@ -20,15 +20,15 @@ update key model =
Nothing -> model Nothing -> model
Just x -> { model | selected = x } Just x -> { model | selected = x }
view : (String -> m) -> Model a -> Html m view : List (Attribute m) -> (String -> m) -> Model a -> Html m
view msg model = view attributes msg model =
let let
viewOption x = viewOption x =
option option
[ selected <| model.identify model.selected == model.identify x, value <| model.identify x ] [ selected <| model.identify model.selected == model.identify x, value <| model.identify x ]
[ text <| model.show x ] [ text <| model.show x ]
in in
select [ onInput msg ] <| List.map viewOption model.options select ([ onInput msg ] ++ attributes) <| List.map viewOption model.options
get : Model a -> a get : Model a -> a
get = .selected get = .selected

View File

@ -11458,6 +11458,12 @@ var $author$project$Entry$SetTaxGroup = function (a) {
return {$: 'SetTaxGroup', a: a}; return {$: 'SetTaxGroup', a: a};
}; };
var $author$project$Entry$SubmitSearch = {$: 'SubmitSearch'}; 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$json$Json$Encode$bool = _Json_wrap;
var $elm$html$Html$Attributes$boolProperty = F2( var $elm$html$Html$Attributes$boolProperty = F2(
function (key, bool) { 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$label = _VirtualDom_node('label');
var $elm$html$Html$legend = _VirtualDom_node('legend'); 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) { var $elm$html$Html$Events$alwaysPreventDefault = function (msg) {
return _Utils_Tuple2(msg, true); 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$option = _VirtualDom_node('option');
var $elm$html$Html$select = _VirtualDom_node('select'); var $elm$html$Html$select = _VirtualDom_node('select');
var $elm$html$Html$Attributes$selected = $elm$html$Html$Attributes$boolProperty('selected'); var $elm$html$Html$Attributes$selected = $elm$html$Html$Attributes$boolProperty('selected');
var $author$project$Select$view = F2( var $author$project$Select$view = F3(
function (msg, model) { function (attributes, msg, model) {
var viewOption = function (x) { var viewOption = function (x) {
return A2( return A2(
$elm$html$Html$option, $elm$html$Html$option,
@ -11641,10 +11649,12 @@ var $author$project$Select$view = F2(
}; };
return A2( return A2(
$elm$html$Html$select, $elm$html$Html$select,
_Utils_ap(
_List_fromArray( _List_fromArray(
[ [
$elm$html$Html$Events$onInput(msg) $elm$html$Html$Events$onInput(msg)
]), ]),
attributes),
A2($elm$core$List$map, viewOption, model.options)); A2($elm$core$List$map, viewOption, model.options));
}); });
var $author$project$Calculator$view = F2( var $author$project$Calculator$view = F2(
@ -11756,7 +11766,7 @@ var $author$project$Calculator$view = F2(
[ [
$elm$html$Html$text('Gebindepreis ist') $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; var model = state.a;
return A2( return A2(
$elm$html$Html$form, $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( _List_fromArray(
[ [
A2( A2(
@ -12037,6 +12051,7 @@ var $author$project$Entry$view = function (_v0) {
$elm$html$Html$Events$onInput($author$project$Entry$SetBarcode), $elm$html$Html$Events$onInput($author$project$Entry$SetBarcode),
$elm$html$Html$Attributes$value(model.barcode), $elm$html$Html$Attributes$value(model.barcode),
$elm$html$Html$Attributes$disabled(true), $elm$html$Html$Attributes$disabled(true),
$elm$html$Html$Attributes$name('barcode'),
$elm$html$Html$Attributes$id('barcode') $elm$html$Html$Attributes$id('barcode')
]), ]),
_List_Nil) _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$Events$onInput($author$project$Entry$SetName),
$elm$html$Html$Attributes$value(model.name), $elm$html$Html$Attributes$value(model.name),
$elm$html$Html$Attributes$name('name'),
$elm$html$Html$Attributes$id('name') $elm$html$Html$Attributes$id('name')
]), ]),
_List_Nil) _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$Events$onInput($author$project$Entry$SetSalesUnits),
$elm$html$Html$Attributes$value( $elm$html$Html$Attributes$value(
$author$project$NumberInput$show(model.salesUnits)), $author$project$NumberInput$show(model.salesUnits)),
$elm$html$Html$Attributes$name('sales-units'),
$elm$html$Html$Attributes$id('sales-units'), $elm$html$Html$Attributes$id('sales-units'),
$elm$html$Html$Attributes$type_('number') $elm$html$Html$Attributes$type_('number')
]), ]),
@ -12117,7 +12134,15 @@ var $author$project$Entry$view = function (_v0) {
[ [
$elm$html$Html$text('Gruppe') $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( A2(
$elm$html$Html$div, $elm$html$Html$div,
@ -12137,7 +12162,15 @@ var $author$project$Entry$view = function (_v0) {
[ [
$elm$html$Html$text('Raum') $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( A2(
$elm$html$Html$div, $elm$html$Html$div,
@ -12157,7 +12190,15 @@ var $author$project$Entry$view = function (_v0) {
[ [
$elm$html$Html$text('Steuergruppe') $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( A2(
$elm$html$Html$map, $elm$html$Html$map,
@ -12192,6 +12233,7 @@ var $author$project$Entry$view = function (_v0) {
$author$project$NumberInput$show(model.netUnitPrice)), $author$project$NumberInput$show(model.netUnitPrice)),
$elm$html$Html$Events$onInput($author$project$Entry$SetNetUnitPrice), $elm$html$Html$Events$onInput($author$project$Entry$SetNetUnitPrice),
$elm$html$Html$Attributes$type_('number'), $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$id('net-unit-price'),
$elm$html$Html$Attributes$step('0.01') $elm$html$Html$Attributes$step('0.01')
]), ]),
@ -12224,11 +12266,19 @@ var $author$project$Entry$view = function (_v0) {
$author$project$NumberInput$show(model.grossUnitPrice)), $author$project$NumberInput$show(model.grossUnitPrice)),
$elm$html$Html$Events$onInput($author$project$Entry$SetGrossUnitPrice), $elm$html$Html$Events$onInput($author$project$Entry$SetGrossUnitPrice),
$elm$html$Html$Attributes$type_('number'), $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$id('gross-unit-price'),
$elm$html$Html$Attributes$step('0.01') $elm$html$Html$Attributes$step('0.01')
]), ]),
_List_Nil), _List_Nil),
$author$project$Entry$viewSetSuggestedPriceButton(model) $author$project$Entry$viewSetSuggestedPriceButton(model)
])),
A2(
$elm$html$Html$button,
_List_Nil,
_List_fromArray(
[
$elm$html$Html$text('In den Warenkorb')
])) ]))
])) ]))
])); ]));