Skip to content

Commit 4c00951

Browse files
committed
feat/cardPanel: edit draft message
1 parent be5a556 commit 4c00951

File tree

5 files changed

+315
-84
lines changed

5 files changed

+315
-84
lines changed

Diff for: i18n/i18n.toml

+4
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,10 @@ Vous pouvez [Explorer](/explore) les organisations publiques ou créer votre [Pr
729729
en="add a role to this user"
730730
fr="Ajouter un rôle à cette utilisateur"
731731

732+
[addTensionToProject]
733+
en="Add tensions to project"
734+
fr="Ajouter des tensions au projet"
735+
732736
[invite]
733737
en="Invite"
734738
fr="Inviter"

Diff for: src/Components/Board.elm

+22-12
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type alias Model =
8484
, cardHover : String
8585
, cardEdit : String
8686
, colEdit : String
87+
, isProjectAdmin : Bool
8788

8889
-- Components
8990
, projectColumnModal : ProjectColumnModal.State
@@ -128,6 +129,7 @@ initModel projectid focus user =
128129
, cardHover = ""
129130
, cardEdit = ""
130131
, colEdit = ""
132+
, isProjectAdmin = False
131133

132134
-- Components
133135
, projectColumnModal = ProjectColumnModal.init projectid user
@@ -179,6 +181,7 @@ type Msg
179181
| FitBoard (Result Dom.Error Dom.Element)
180182
| ScrollToElement String
181183
| OnClearBoardResult
184+
| OnSetIsAdmin Bool
182185
-- Move Column
183186
| OnMoveColumn ProjectColumn
184187
| OnMoveColumnEnd
@@ -301,6 +304,9 @@ update_ apis message model =
301304
OnClearBoardResult ->
302305
( { model | board_result = NotAsked }, noOut )
303306

307+
OnSetIsAdmin isAdmin ->
308+
( { model | isProjectAdmin = isAdmin }, noOut )
309+
304310
-- Move Columns
305311
OnMoveColumn col ->
306312
if col.col_type == ProjectColumnType.NoStatusColumn then
@@ -873,7 +879,7 @@ viewBoard op model =
873879
-- @debug: allow move card in empty collumn
874880
, onDragEnter <| OnMoveEnterT { pos = 0, cardid = unwrap "" .id c1, colid = colid }
875881
]
876-
[ viewHeader (model.colEdit == colid) col ]
882+
[ viewHeader model.isProjectAdmin (model.colEdit == colid) col ]
877883
, col.cards
878884
--|> List.sortBy .createdAt
879885
--|> (\l -> ternary (model.sortFilter == defaultSortFilter) l (List.reverse l))
@@ -908,10 +914,10 @@ viewBoard op model =
908914
(case card.card of
909915
CardTension t ->
910916
-- Does lazy will work with function in argment?
911-
[ Lazy.lazy5 viewMediaTension card.id (card.id == model.cardHover) (card.id == model.cardEdit) model.node_focus t ]
917+
[ Lazy.lazy5 viewMediaTension card.id (card.id == model.cardHover && model.isProjectAdmin) (card.id == model.cardEdit) model.node_focus t ]
912918

913919
CardDraft d ->
914-
[ Lazy.lazy4 viewMediaDraft card.id (card.id == model.cardHover) (card.id == model.cardEdit) d ]
920+
[ Lazy.lazy4 viewMediaDraft card.id (card.id == model.cardHover && model.isProjectAdmin) (card.id == model.cardEdit) d ]
915921
)
916922
]
917923
)
@@ -972,7 +978,7 @@ viewBoard op model =
972978
|> List.concat
973979
|> (\x ->
974980
-- View New Col Button
975-
if model.hasNewCol then
981+
if model.hasNewCol && model.isProjectAdmin then
976982
x ++ [ viewNewCol ]
977983

978984
else
@@ -991,19 +997,23 @@ viewBoard op model =
991997
]
992998

993999

994-
viewHeader : Bool -> ProjectColumn -> Html Msg
995-
viewHeader isEdited col =
1000+
viewHeader : Bool -> Bool -> ProjectColumn -> Html Msg
1001+
viewHeader isAdmin isEdited col =
9961002
span []
9971003
[ div [ class "level" ]
9981004
[ div [ class "level-left ml-3", attribute "style" "cursor:default !important;" ]
9991005
[ span [ class "mr-3", style "color" (withDefault "lightgrey" col.color) ] [ A.icon "icon-circle1 icon-lg" ], text col.name ]
10001006
, span [ class "level-right" ]
1001-
[ span
1002-
[ class "tag is-rounded-light button-light is-w has-border mx-1"
1003-
, onClick (OnAddDraft col.id)
1004-
]
1005-
[ A.icon "icon-plus" ]
1006-
, if col.col_type /= ProjectColumnType.NoStatusColumn then
1007+
[ if isAdmin then
1008+
span
1009+
[ class "tag is-rounded-light button-light is-w has-border mx-1"
1010+
, onClick (OnAddDraft col.id)
1011+
]
1012+
[ A.icon "icon-plus" ]
1013+
1014+
else
1015+
text ""
1016+
, if col.col_type /= ProjectColumnType.NoStatusColumn && isAdmin then
10071017
B.dropdownLight
10081018
"col-ellipsis"
10091019
("mx-2 is-align-self-baseline is-right " ++ ternary isEdited "is-active" "")

0 commit comments

Comments
 (0)