Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGauthier committed Sep 28, 2021
1 parent 3c048dd commit f4e13cb
Showing 1 changed file with 33 additions and 43 deletions.
Expand Up @@ -13,6 +13,7 @@ import ViewRulesTable exposing (..)
import ViewRuleDetails exposing (..)
import ViewCategoryDetails exposing (..)


view : Model -> Html Msg
view model =
let
Expand All @@ -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]
]
Expand All @@ -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" ] [
Expand All @@ -117,7 +107,7 @@ view model =
]
]
]
DeactivationValidation rule ->
Just (DeactivationValidation rule) ->
let
txtDisable = if rule.enabled == True then "Disable" else "Enable"
in
Expand All @@ -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" ] [
Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit f4e13cb

Please sign in to comment.