From f4e13cb6ce16805f2f9c7e227601211ff3148b7e Mon Sep 17 00:00:00 2001 From: Raphael Gauthier Date: Tue, 28 Sep 2021 14:54:09 +0200 Subject: [PATCH] Work in progress --- .../src/main/elm/rules/sources/View.elm | 76 ++++++++----------- 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/webapp/sources/rudder/rudder-web/src/main/elm/rules/sources/View.elm b/webapp/sources/rudder/rudder-web/src/main/elm/rules/sources/View.elm index e3357dc2a46..7b1813412fc 100644 --- a/webapp/sources/rudder/rudder-web/src/main/elm/rules/sources/View.elm +++ b/webapp/sources/rudder/rudder-web/src/main/elm/rules/sources/View.elm @@ -13,6 +13,7 @@ import ViewRulesTable exposing (..) import ViewRuleDetails exposing (..) import ViewCategoryDetails exposing (..) + view : Model -> Html Msg view model = let @@ -38,19 +39,13 @@ view model = ruleTreeCategory : (Category Rule) -> Html Msg ruleTreeCategory item = let - categories = getSubElems item - |> List.sortBy .name - |> List.map ruleTreeCategory - rules = item.elems - |> List.sortBy .name - |> List.map ruleTreeElem - - childsList = ul[class "jstree-children"] (List.concat [ categories, rules] ) - + categories = List.map ruleTreeCategory (getSubElems item) + rules = List.map ruleTreeElem item.elems + childsList = ul[class "jstree-children"](categories ++ rules) in li[class "jstree-node jstree-open"] [ i[class "jstree-icon jstree-ocl"][] - , a[class "jstree-anchor", onClick (OpenCategoryDetails item.id True)] + , a[href "#", class "jstree-anchor", onClick (OpenCategoryDetails item)] [ i [class "jstree-icon jstree-themeicon fa fa-folder jstree-themeicon-custom"][] , span [class "treeGroupCategoryName tooltipable"][text item.name] ] @@ -60,43 +55,38 @@ view model = templateMain = case model.mode of Loading -> text "loading" RuleTable -> - let - thClass : SortBy -> String - thClass sortBy = - if sortBy == model.ui.ruleFilters.sortBy then - if(model.ui.ruleFilters.sortOrder == True) then - "sorting_asc" - else - "sorting_desc" - else - "sorting" - in - div [class "main-details"] - [ div [class "main-table"] - [ table [ class "no-footer dataTable"] - [ thead [] - [ tr [class "head"] - [ th [class (thClass Name ) , rowspan 1, colspan 1, onClick (UpdateRuleFilters Name )][text "Name" ] - , th [class (thClass Parent ) , rowspan 1, colspan 1, onClick (UpdateRuleFilters Parent )][text "Category" ] - , th [class (thClass Status ) , rowspan 1, colspan 1, onClick (UpdateRuleFilters Status )][text "Status" ] - , th [class (thClass Compliance) , rowspan 1, colspan 1, onClick (UpdateRuleFilters Compliance)][text "Compliance" ] - , th [class "" , rowspan 1, colspan 1][text "Recent changes"] - ] + div [class "main-details"] + [ div [class "main-table"] + [ table [ class "no-footer dataTable"] + [ thead [] + [ tr [class "head"] + [ th [class "sorting_asc", rowspan 1, colspan 1][text "Name" ] + , th [class "sorting" , rowspan 1, colspan 1][text "Category" ] + , th [class "sorting" , rowspan 1, colspan 1][text "Status" ] + , th [class "sorting" , rowspan 1, colspan 1][text "Compliance" ] + , th [class "sorting" , rowspan 1, colspan 1][text "Recent changes"] ] - , tbody [] (buildRulesTable model) ] + , tbody [] (buildRulesTable model) ] ] + ] + + EditRule details -> + (editionTemplate model details False) + + CreateRule details -> + (editionTemplate model details True) - RuleForm details -> - (editionTemplate model details) + EditCategory details -> + (editionTemplateCat model details False) - CategoryForm details -> - (editionTemplateCat model details) + CreateCategory details -> + (editionTemplateCat model details True) - modal = case model.ui.modal of - NoModal -> text "" - DeletionValidation rule -> + modal = case model.modal of + Nothing -> text "" + Just (DeletionValidation rule) -> div [ tabindex -1, class "modal fade in", style "z-index" "1050", style "display" "block" ] [ div [ class "modal-dialog" ] [ div [ class "modal-content" ] [ @@ -117,7 +107,7 @@ view model = ] ] ] - DeactivationValidation rule -> + Just (DeactivationValidation rule) -> let txtDisable = if rule.enabled == True then "Disable" else "Enable" in @@ -143,7 +133,7 @@ view model = ] ] ] - DeletionValidationCat category -> + Just (DeletionValidationCat category) -> div [ tabindex -1, class "modal fade in", style "z-index" "1050", style "display" "block" ] [ div [ class "modal-dialog" ] [ div [ class "modal-content" ] [ @@ -172,7 +162,7 @@ view model = [ h1[] [ span[][text "Rules"] ] - , ( if model.ui.hasWriteRights then + , ( if model.hasWriteRights == True then div [class "header-buttons"] [ button [class "btn btn-default", type_ "button", onClick (GenerateId (\s -> NewCategory s ))][text "Add Category"] , button [class "btn btn-success", type_ "button", onClick (GenerateId (\s -> NewRule (RuleId s) ))][text "Create"]