liquid_feedback_frontend
view app/main/admin/index.lua @ 1329:1a55c68445d4
Allow empty selection for unit registration field
| author | bsw | 
|---|---|
| date | Fri Aug 03 17:07:06 2018 +0200 (2018-08-03) | 
| parents | c0fd12b97d65 | 
| children | b86558a65a20 | 
 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.sidebar( "tab-members", function()
    10   ui.sidebarHead( function()
    11     ui.heading { level = 2, content = _"Members" }
    12   end )
    14   ui.sidebarSection( function()
    15     ui.tag { tag = "ul", attr = { class = "ul" }, content = function()
    16       ui.tag { tag = "li", content = function()
    17         ui.form{
    18           module = "admin", view = "member_list",
    19           content = function()
    21             ui.field.text{ label = _"search", name = "search" }
    23             ui.submit{ value = _"search" }
    25           end
    26         }
    27       end }
    28     end }
    29   end )
    30   ui.sidebarSection( "moreLink", function()
    31     ui.link{
    32       text = _"Register new member",
    33       module = "admin",
    34       view = "member_edit"
    35     }
    36   end )
    37 end )
    39 ui.sidebar( "tab-whatcanido", function()
    40   ui.sidebarHead( function()
    41     ui.heading { level = 2, content = _"Newsletter" }
    42   end )
    44   ui.sidebarSection( "moreLink", function()
    45     ui.link{
    46       text = _"Create a newsletter",
    47       module = "admin",
    48       view = "newsletter_edit"
    49     }
    50   end )
    51   ui.sidebarSection( "moreLink", function()
    52     ui.link{
    53       text = _"Manage newsletters",
    54       module = "admin",
    55       view = "newsletter_list"
    56     }
    57   end )
    58 end )
    60 ui.sidebar( "tab-whatcanido", function()
    61   ui.sidebarHead( function()
    62     ui.heading { level = 2, content = _"Cancel issue" }
    63   end )
    65   ui.sidebarSection( function()
    66     ui.form{
    67       module = "admin",
    68       view = "cancel_issue",
    69       content = function()
    70         ui.tag { tag = "ul", attr = { class = "ul" }, content = function()
    71           ui.tag { tag = "li", content = function()
    72             ui.field.text{ label = _"Issue #", name = "id" }
    73             ui.submit{ text = _"cancel issue" }
    74           end }
    75         end }
    76       end
    77     }
    78   end )
    79 end )
    81 ui.sidebar("tab-whatcanido", function()
    82   ui.sidebarHead( function()
    83     ui.heading { level = 2, content = _"Policies" }
    84   end )
    86   ui.sidebarSection( function()
    87     ui.tag { tag = "ul", attr = { class = "ul" }, content = function()
    88       for i, policy in ipairs(policies) do
    89         ui.tag { tag = "li", content = function()
    90           ui.link{
    91             content = policy.name,
    92             module = "admin",
    93             view = "policy_show",
    94             id = policy.id
    95           }
    96         end }
    97       end
    98     end }
    99   end )
   100   ui.sidebarSection( "moreLink", function()
   101     ui.link{
   102       text = _"Create new policy",
   103       module = "admin",
   104       view = "policy_show"
   105     }
   106   end )
   107   ui.sidebarSection( "moreLink", function()
   108     ui.link{
   109       text = _"Show policies not in use",
   110       module = "admin",
   111       view = "policy_list",
   112       params = { show_not_in_use = true }
   113     }
   114   end )
   115 end )
   118 ui.section( function()
   119   ui.sectionHead( function()
   120     ui.heading { level = 1, content = _"Organizational units and subject areas" }
   121   end )
   122   ui.sectionRow( function()
   124     for i_unit, unit in ipairs(units) do
   125       ui.container { 
   126         attr = { style = "margin-left: " .. ((unit.depth - 1)* 2) .. "em;" },
   127         content = function ()
   128           ui.heading { level = 1, content = function ()
   129             local class
   130             if unit.active == false then
   131               class = "inactive"
   132             end
   133             ui.link{ attr = { class = class }, text = unit.name, module = "admin", view = "unit_edit", id = unit.id }
   134           end }
   135           ui.tag { tag = "ul", attr = { class = "ul" }, content = function ()
   136             local areas
   137             if not inactive then
   138               areas = unit:get_reference_selector("areas"):add_order_by("name"):add_where("active"):exec()
   139             else
   140               areas = unit:get_reference_selector("areas"):add_order_by("name"):exec()
   141             end
   142             for i, area in ipairs(areas) do
   143               ui.tag { tag = "li", content = function ()
   144                 local class
   145                 if area.active == false then
   146                   class = "inactive"
   147                 end
   148                 ui.link{ attr = { class = class }, text = area.name, module = "admin", view = "area_show", id = area.id }
   149               end }
   150             end
   151             ui.tag { tag = "li", content = function ()
   152               ui.link { module = "admin", view = "area_show", params = { unit_id = unit.id }, content = _"+ add new subject area" }
   153             end }
   154             slot.put("<br />")
   155           end }
   156         end
   157       }
   158     end
   160     slot.put("<br />")
   161     ui.link { module = "admin", view = "unit_edit", content = _"Create new unit" }
   162     slot.put("<br />")
   163     slot.put("<br />")
   165     if (not inactive) then
   166       ui.link { module = "admin", view = "index", params = { inactive = true }, content = _"Show inactive" }
   167     else
   168       ui.link { module = "admin", view = "index", content = _"Hide inactive" }
   169     end
   171   end)
   172 end)
