diff --git a/CHANGELOG.md b/CHANGELOG.md index f27a2795..a428dd0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.10.0-beta.3] - Unreleased ### Fixed +- Enter key press behavior: close confirm message instead of reloading page. - Accept `/*` as a valid Data Trigger path. - Do not show inconsistent data while showing an existing trigger. diff --git a/src/elm/Page/InterfaceBuilder.elm b/src/elm/Page/InterfaceBuilder.elm index e85cf431..8d7e98e2 100644 --- a/src/elm/Page/InterfaceBuilder.elm +++ b/src/elm/Page/InterfaceBuilder.elm @@ -3,6 +3,7 @@ module Page.InterfaceBuilder exposing (Model, Msg, init, update, view, subscript import Dict exposing (Dict) import Html exposing (Html, text, h5, p, br, b, i, small) import Html.Attributes exposing (class, value, for, selected) +import Html.Events exposing (onSubmit) import Navigation import Task import Time exposing (Time) @@ -142,10 +143,8 @@ type ModalResult type Msg = GetInterfaceDone Interface - | AddInterface | AddInterfaceDone String | DeleteInterfaceDone String - | UpdateInterface | UpdateInterfaceDone String | RemoveMapping InterfaceMapping | ShowDeleteModal @@ -241,32 +240,12 @@ update session msg model = , ExternalMsg.Noop ) - AddInterface -> - ( model - , AstarteApi.addNewInterface model.interface - session - AddInterfaceDone - (ShowError "Cannot install interface.") - RedirectToLogin - , ExternalMsg.Noop - ) - AddInterfaceDone response -> ( model , Navigation.modifyUrl <| Route.toString (Route.Realm Route.ListInterfaces) , ExternalMsg.AddFlashMessage FlashMessage.Notice "Interface succesfully installed." ) - UpdateInterface -> - ( model - , AstarteApi.updateInterface model.interface - session - UpdateInterfaceDone - (ShowError "Cannot apply changes.") - RedirectToLogin - , ExternalMsg.Noop - ) - UpdateInterfaceDone response -> ( { model | minMinor = model.interface.minor @@ -294,15 +273,21 @@ update session msg model = CloseDeleteModal modalResult -> case modalResult of ModalOk -> - ( { model | deleteModalVisibility = Modal.hidden } - , AstarteApi.deleteInterface model.interface.name - model.interface.major - session - DeleteInterfaceDone - (ShowError "") - RedirectToLogin - , ExternalMsg.Noop - ) + if model.interface.name == model.confirmInterfaceName then + ( { model | deleteModalVisibility = Modal.hidden } + , AstarteApi.deleteInterface model.interface.name + model.interface.major + session + DeleteInterfaceDone + (ShowError "") + RedirectToLogin + , ExternalMsg.Noop + ) + else + ( model + , Cmd.none + , ExternalMsg.Noop + ) ModalCancel -> ( { model | deleteModalVisibility = Modal.hidden } @@ -1350,7 +1335,7 @@ renderDeleteInterfaceModal model = |> Modal.large |> Modal.h5 [] [ text "Confirmation Required" ] |> Modal.body [] - [ Form.form [] + [ Form.form [ onSubmit (CloseDeleteModal ModalOk) ] [ Form.row [] [ Form.col [ Col.sm12 ] [ text "You are going to remove " diff --git a/src/elm/Page/TriggerBuilder.elm b/src/elm/Page/TriggerBuilder.elm index 9401336d..b675838f 100644 --- a/src/elm/Page/TriggerBuilder.elm +++ b/src/elm/Page/TriggerBuilder.elm @@ -3,6 +3,7 @@ module Page.TriggerBuilder exposing (Model, Msg, init, update, view, subscriptio import Regex exposing (regex) import Html exposing (Html, text, h5, b, i) import Html.Attributes exposing (class, value, readonly, selected, for) +import Html.Events exposing (onSubmit) import Navigation import Task import Time @@ -734,14 +735,20 @@ update session msg model = CloseDeleteModal result -> case result of ModalOk -> - ( { model | deleteModalVisibility = Modal.hidden } - , AstarteApi.deleteTrigger model.trigger.name - session - DeleteTriggerDone - (ShowError "Cannot delete trigger.") - RedirectToLogin - , ExternalMsg.Noop - ) + if (model.trigger.name == model.confirmTriggerName) then + ( { model | deleteModalVisibility = Modal.hidden } + , AstarteApi.deleteTrigger model.trigger.name + session + DeleteTriggerDone + (ShowError "Cannot delete trigger.") + RedirectToLogin + , ExternalMsg.Noop + ) + else + ( model + , Cmd.none + , ExternalMsg.Noop + ) ModalCancel -> ( { model | deleteModalVisibility = Modal.hidden } @@ -1259,7 +1266,7 @@ renderDeleteTriggerModal model = |> Modal.large |> Modal.h5 [] [ text "Confirmation Required" ] |> Modal.body [] - [ Form.form [] + [ Form.form [ onSubmit (CloseDeleteModal ModalOk) ] [ Form.row [] [ Form.col [ Col.sm12 ] [ text "You are going to remove "