liquid_feedback_frontend
view app/main/admin/index.lua @ 1475:91f6498ba545
Added breadcrumbs to admin index view
| author | bsw | 
|---|---|
| date | Thu Oct 18 17:45:37 2018 +0200 (2018-10-18) | 
| parents | 1d5469ca60dc | 
| children | 22bb5e2b6548 | 
 line source
     1 local inactive = param.get("inactive", atom.boolean)
     3 local units = Unit:get_flattened_tree{ include_inactive = inactive }
     5 local policies = Policy:build_selector{}:add_order_by("index"):exec()
     7 ui.titleAdmin()
     9 ui.grid{ content = function()
    11   ui.cell_main{ content = function()
    12     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    13       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    14         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Organizational units and subject areas" }
    15       end }
    16       ui.container{ attr = { class = "mdl-card__content" }, content = function()
    18         for i_unit, unit in ipairs(units) do
    19           ui.container { 
    20             attr = { style = "margin-left: " .. ((unit.depth - 1)* 2) .. "em;" },
    21             content = function ()
    22               ui.heading { level = 1, content = function ()
    23                 local class
    24                 if unit.active == false then
    25                   class = "inactive"
    26                 end
    27                 ui.link{ attr = { class = class }, text = unit.name, module = "admin", view = "unit_edit", id = unit.id }
    28               end }
    29               ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
    30                 local areas
    31                 if not inactive then
    32                   areas = unit:get_reference_selector("areas"):add_order_by("name"):add_where("active"):exec()
    33                 else
    34                   areas = unit:get_reference_selector("areas"):add_order_by("name"):exec()
    35                 end
    36                 for i, area in ipairs(areas) do
    37                   ui.tag { tag = "li", content = function ()
    38                     local class
    39                     if area.active == false then
    40                       class = "inactive"
    41                     end
    42                     ui.link{ attr = { class = class }, text = area.name, module = "admin", view = "area_show", id = area.id }
    43                   end }
    44                 end
    45                 ui.tag { tag = "li", content = function ()
    46                   ui.link { module = "admin", view = "area_show", params = { unit_id = unit.id }, content = _"+ add new subject area" }
    47                 end }
    48                 slot.put("<br />")
    49               end }
    50             end
    51           }
    52         end
    54         slot.put("<br />")
    55         ui.link { module = "admin", view = "unit_edit", content = _"Create new unit" }
    56         slot.put("<br />")
    57         slot.put("<br />")
    59         if (not inactive) then
    60           ui.link { module = "admin", view = "index", params = { inactive = true }, content = _"Show inactive" }
    61         else
    62           ui.link { module = "admin", view = "index", content = _"Hide inactive" }
    63         end
    65       end }
    66     end }
    67   end }
    69   ui.cell_sidebar{ content = function()
    71     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
    72       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
    73         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Members" }
    74       end }
    75       ui.container{ attr = { class = "mdl-card__content" }, content = function()
    76         ui.tag { tag = "ul", attr = { class = "ul" }, content = function()
    77           ui.tag { tag = "li", content = function()
    78             ui.form{
    79               module = "admin", view = "member_list",
    80               content = function()
    82                 ui.field.text{ container_attr = { style = "display: inline-block;" }, label = _"search", name = "search" }
    84                 ui.submit{ value = _"search" }
    86               end
    87             }
    88           end }
    89         end }
    90         ui.sidebarSection( "moreLink", function()
    91           ui.link{
    92             text = _"Register new member",
    93             module = "admin",
    94             view = "member_edit"
    95           }
    96         end )
    97       end }
    98     end }
   100     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
   101       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
   102         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Policies" }
   103       end }
   104       ui.container{ attr = { class = "mdl-card__content" }, content = function()
   105         ui.tag { tag = "ul", attr = { class = "ul" }, content = function()
   106           for i, policy in ipairs(policies) do
   107             ui.tag { tag = "li", content = function()
   108               ui.link{
   109                 content = policy.name,
   110                 module = "admin",
   111                 view = "policy_show",
   112                 id = policy.id
   113               }
   114             end }
   115           end
   116         end }
   118         ui.link{
   119           text = _"Create new policy",
   120           module = "admin",
   121           view = "policy_show"
   122         }
   123         slot.put("   ")
   124         ui.link{
   125           text = _"Show policies not in use",
   126           module = "admin",
   127           view = "policy_list",
   128           params = { show_not_in_use = true }
   129         }
   130       end }
   131     end }
   133     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
   134       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
   135         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Newsletter" }
   136       end }
   137       ui.container{ attr = { class = "mdl-card__content" }, content = function()
   138         ui.link{
   139           text = _"Create a newsletter",
   140           module = "admin",
   141           view = "newsletter_edit"
   142         }
   143         slot.put("   ")
   144         ui.link{
   145           text = _"Manage newsletters",
   146           module = "admin",
   147           view = "newsletter_list"
   148         }
   149       end }
   150     end }
   152     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
   153       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
   154         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Cancel issue" }
   155       end }
   156       ui.container{ attr = { class = "mdl-card__content" }, content = function()
   157         ui.form{
   158           module = "admin",
   159           view = "cancel_issue",
   160           content = function()
   161             ui.tag { tag = "ul", attr = { class = "ul" }, content = function()
   162               ui.tag { tag = "li", content = function()
   163                 ui.field.text{ label = _"Issue #", name = "id" }
   164                 ui.submit{ text = _"cancel issue" }
   165               end }
   166             end }
   167           end
   168         }
   169       end }
   170     end }
   172   end }
   173 end }
