diff --git a/priv/lib-src/elm/src/Main.elm b/priv/lib-src/elm/src/Main.elm index f27460f..5057823 100644 --- a/priv/lib-src/elm/src/Main.elm +++ b/priv/lib-src/elm/src/Main.elm @@ -43,8 +43,14 @@ port logError : String -> Cmd msg -- MAIN +type alias Flags = + { pageId : PageId + , now : Int + , remarkId : Maybe Int + , isClosed : Bool + } -main : Program ( PageId, Int, Maybe Int ) Model Msg +main : Program Flags Model Msg main = Browser.element { init = init @@ -76,6 +82,7 @@ type alias Model = , isOngoingTask : Bool , now : Util.Now , remarkId : Maybe PageId + , pageIsClosed: Bool } @@ -97,22 +104,21 @@ type alias IsReply = -- INIT -init : ( PageId, Int, Maybe Int ) -> ( Model, Cmd Msg ) -init ( pageId, now, remarkId ) = +init : Flags -> ( Model, Cmd Msg ) +init flags = ( { remarks = [] , group = DefaultGroup , user = Anonymous , editor = Closed - , pageId = pageId + , pageId = flags.pageId , isOngoingTask = False - , now = Util.millisToNow now - , remarkId = remarkId + , now = Util.millisToNow flags.now + , remarkId = flags.remarkId + , pageIsClosed = flags.isClosed } - , Task.attempt GotRemarksData (Api.getRemarksData pageId) + , Task.attempt GotRemarksData (Api.getRemarksData flags.pageId) ) - - -- UPDATE @@ -259,7 +265,7 @@ view : Model -> Html Msg view model = section [] [ viewRemarks model.now model.remarks model.editor model.user False - , viewParticipate model.editor model.user model.pageId + , viewParticipate model.pageIsClosed model.editor model.user model.pageId ] @@ -565,14 +571,14 @@ viewRemarkFooterLikes likes = -- CALL TO ACIONS -viewParticipate : Editor -> User -> PageId -> Html Msg -viewParticipate editor user pageId = +viewParticipate : Bool -> Editor -> User -> PageId -> Html Msg +viewParticipate pageIsClosed editor user pageId = case ( user, editor ) of ( Anonymous, _ ) -> text "" ( User profile, Closed ) -> - viewParticipateButton profile pageId + viewParticipateButton pageIsClosed profile pageId ( User profile, Open (New id) editor_ ) -> Ginger.Util.viewIf (id == pageId) <| @@ -583,12 +589,15 @@ viewParticipate editor user pageId = text "" -viewParticipateButton : Profile -> PageId -> Html Msg -viewParticipateButton profile pageId = - div [ class "status" ] - [ img [ class "avatar", src profile.userAvatarUrl ] - [] - , button - [ class "btn--new-remark", onClick (NewRemark pageId) ] - [ text "Reageer op deze bijdrage" ] - ] +viewParticipateButton : Bool -> Profile -> PageId -> Html Msg +viewParticipateButton pageIsClosed profile pageId = + if pageIsClosed then + text "" -- hide the button + else + div [ class "status" ] + [ img [ class "avatar", src profile.userAvatarUrl ] + [] + , button + [ class "btn--new-remark", onClick (NewRemark pageId) ] + [ text "Reageer op deze bijdrage" ] + ] diff --git a/priv/lib-src/scss/src/blocks/status-tags.scss b/priv/lib-src/scss/src/blocks/status-tags.scss index af45aef..700dbad 100644 --- a/priv/lib-src/scss/src/blocks/status-tags.scss +++ b/priv/lib-src/scss/src/blocks/status-tags.scss @@ -66,6 +66,16 @@ } } +.kg-intro_status--closed, +.kg-intro_status--gesloten { + border-color: $greenDarker; + background-color: rgba($greenDarker, 0.6); + + &::before { + background-image: url(/lib/images/closed.svg); + } +} + .c-contribution__lvl { background-color: $greenDarker; border: none; @@ -87,4 +97,8 @@ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); z-index: 2; pointer-events: none; + + &--closed { + background-color: $grey; + } } diff --git a/priv/lib/images/closed.svg b/priv/lib/images/closed.svg new file mode 100644 index 0000000..82fb9f9 --- /dev/null +++ b/priv/lib/images/closed.svg @@ -0,0 +1,45 @@ + + + + diff --git a/priv/templates/_admin_edit_basics_form.contribution.tpl b/priv/templates/_admin_edit_basics_form.contribution.tpl index 21a3efb..035f5a0 100644 --- a/priv/templates/_admin_edit_basics_form.contribution.tpl +++ b/priv/templates/_admin_edit_basics_form.contribution.tpl @@ -44,7 +44,28 @@ {% include "_ginger_edit_content_add_to_timeline.tpl" %} {% catinclude "_ginger_edit_content_status_label.tpl" id extraClass="col-md-6" %} + + +
+ {% javascript %} + $(document).ready(function() { + const $statusField = $('#status-label'); + const $closedContainer = $('#status-closed-container'); + function toggleClosedWarning() { + const value = $statusField.val()?.toLowerCase(); + $closedContainer.toggle(value === 'closed'); + } + + $statusField.on('change', toggleClosedWarning); + }); + {% endjavascript %} {% endwith %} + + diff --git a/priv/templates/_ginger_edit_content_status_label.tpl b/priv/templates/_ginger_edit_content_status_label.tpl index 06c11a5..a056a38 100644 --- a/priv/templates/_ginger_edit_content_status_label.tpl +++ b/priv/templates/_ginger_edit_content_status_label.tpl @@ -25,6 +25,7 @@ + - \ No newline at end of file + diff --git a/priv/templates/comments/comments.tpl b/priv/templates/comments/comments.tpl index 1299002..4dd6b67 100644 --- a/priv/templates/comments/comments.tpl +++ b/priv/templates/comments/comments.tpl @@ -17,9 +17,15 @@ hash = null }; + //ocataco: last flag is passed to indicate this page is closed, and no new remarks are allowed var app = Elm.Main.init({ node: remarksElement, - flags: [{{ id }}, now, hash] + flags: { + pageId: {{ id }}, + now: now, + remarkId: hash, + isClosed: {{id.status_label == 'Closed'}} + } }); app.ports.scrollIdIntoView.subscribe(function(domId) { diff --git a/priv/templates/list/list-item-kg.tpl b/priv/templates/list/list-item-kg.tpl index fa9267f..6e313ef 100644 --- a/priv/templates/list/list-item-kg.tpl +++ b/priv/templates/list/list-item-kg.tpl @@ -17,7 +17,11 @@ {% endif %} {% if id.status_label %} -