From a2e939cc0dda6bac605aaa2417b26fac63463932 Mon Sep 17 00:00:00 2001 From: Taco van Dijk Date: Mon, 21 Jul 2025 16:11:05 +0200 Subject: [PATCH] #50 close contribution --- priv/lib-src/elm/src/Main.elm | 53 +++++++++++-------- priv/lib-src/scss/src/blocks/status-tags.scss | 14 +++++ priv/lib/images/closed.svg | 45 ++++++++++++++++ .../_admin_edit_basics_form.contribution.tpl | 21 ++++++++ .../_ginger_edit_content_status_label.tpl | 3 +- priv/templates/comments/comments.tpl | 8 ++- priv/templates/list/list-item-kg.tpl | 6 ++- priv/templates/page.contribution.tpl | 4 +- priv/templates/page.event.tpl | 2 + priv/translations/nl.po | 12 ++++- 10 files changed, 140 insertions(+), 28 deletions(-) create mode 100644 priv/lib/images/closed.svg 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 %} -
{{ id.status_label|translate }}
+ {% if id.status_label == 'Closed' %} +
{{ id.status_label|translate }}
+ {% else %} +
{{ id.status_label|translate }}
+ {% endif %} {% endif %}
diff --git a/priv/translations/nl.po b/priv/translations/nl.po index 6984ae5..821bbc1 100644 --- a/priv/translations/nl.po +++ b/priv/translations/nl.po @@ -640,7 +640,11 @@ msgstr "Voortgang labels zijn zichtbaar in de kennisgroep" #: user/sites/kenniscloud/templates/_ginger_edit_content_status_label.tpl:20 msgid "Status labels are visible on contributions and meetups" -msgstr "Status labels zijn zichtbaar op bijdragen en meetups" +msgstr "Status labels zijn zichtbaar op bijdragen en meetups." + +#: user/sites/kenniscloud/templates/_admin_edit_basics_form.contribution.tpl +msgid "status-close-remark-reminder" +msgstr "Vergeet niet een laatste reactie te geven voor je de bijdrage sluit!" #: user/sites/kenniscloud/templates/_admin_edit_basics.acl_collaboration_group.tpl: msgid "Timeline off" @@ -734,10 +738,14 @@ msgstr "Inzichten" msgid "Discussion" msgstr "Discussie" +#priv/templates/keywords/status-tags.tpl +msgid "Closed" +msgstr "Gesloten" + #priv/templates/keywords/knowledge-lvl-tags.tpl msgid "Question" msgstr "Vraag" #priv/templates/keywords/knowledge-lvl-tags.tpl msgid "Insight" -msgstr "Inzicht" \ No newline at end of file +msgstr "Inzicht"