liquid_feedback_frontend

changeset 595:bc6934411019

Added unit editor, small fixes at admin section
author bsw
date Sun Jun 24 20:41:50 2012 +0200 (2012-06-24)
parents 487cca534fbe
children 2baaac8b62c4
files app/main/admin/_action/area_update.lua app/main/admin/_action/policy_update.lua app/main/admin/_action/unit_update.lua app/main/admin/area_list.lua app/main/admin/unit_edit.lua app/main/admin/unit_list.lua env/ui/actions.lua
line diff
     1.1 --- a/app/main/admin/_action/area_update.lua	Sat Jun 23 20:56:52 2012 +0200
     1.2 +++ b/app/main/admin/_action/area_update.lua	Sun Jun 24 20:41:50 2012 +0200
     1.3 @@ -35,5 +35,3 @@
     1.4      pol:save()
     1.5    end
     1.6  end
     1.7 -
     1.8 -slot.put_into("notice", _"Area successfully updated")
     2.1 --- a/app/main/admin/_action/policy_update.lua	Sat Jun 23 20:56:52 2012 +0200
     2.2 +++ b/app/main/admin/_action/policy_update.lua	Sun Jun 24 20:41:50 2012 +0200
     2.3 @@ -12,5 +12,3 @@
     2.4  )
     2.5  
     2.6  policy:save()
     2.7 -
     2.8 -slot.put_into("notice", _"Policy successfully updated")
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/app/main/admin/_action/unit_update.lua	Sun Jun 24 20:41:50 2012 +0200
     3.3 @@ -0,0 +1,5 @@
     3.4 +local unit = Unit:by_id(param.get_id()) or Unit:new()
     3.5 +
     3.6 +param.update(unit, "parent_id", "name", "description", "active")
     3.7 +
     3.8 +unit:save()
     4.1 --- a/app/main/admin/area_list.lua	Sat Jun 23 20:56:52 2012 +0200
     4.2 +++ b/app/main/admin/area_list.lua	Sun Jun 24 20:41:50 2012 +0200
     4.3 @@ -6,21 +6,13 @@
     4.4  local areas = Area:build_selector{ unit_id = unit_id, active = not show_not_in_use }:exec()
     4.5  
     4.6  
     4.7 -slot.put_into("title", _("Area list of '#{unit_name}'", { unit_name = unit.name}))
     4.8 +ui.title(_("Area list of '#{unit_name}'", { unit_name = unit.name }))
     4.9  
    4.10  
    4.11 -slot.select("actions", function()
    4.12 -
    4.13 -  ui.link{
    4.14 -    attr = { class = { "admin_only" } },
    4.15 -    text = _"Back to unit list",
    4.16 -    module = "admin",
    4.17 -    view = "unit_list"
    4.18 -  }
    4.19 +ui.actions(function()
    4.20  
    4.21    if show_not_in_use then
    4.22      ui.link{
    4.23 -      attr = { class = { "admin_only" } },
    4.24        text = _"Show areas in use",
    4.25        module = "admin",
    4.26        view = "area_list",
    4.27 @@ -29,14 +21,15 @@
    4.28  
    4.29    else
    4.30      ui.link{
    4.31 -      attr = { class = { "admin_only" } },
    4.32        text = _"Create new area",
    4.33        module = "admin",
    4.34        view = "area_show",
    4.35        params = { unit_id = unit_id }
    4.36      }
    4.37 +
    4.38 +    slot.put(" · ")
    4.39 +
    4.40      ui.link{
    4.41 -      attr = { class = { "admin_only" } },
    4.42        text = _"Show areas not in use",
    4.43        module = "admin",
    4.44        view = "area_list",
     5.1 --- a/app/main/admin/unit_edit.lua	Sat Jun 23 20:56:52 2012 +0200
     5.2 +++ b/app/main/admin/unit_edit.lua	Sun Jun 24 20:41:50 2012 +0200
     5.3 @@ -2,53 +2,46 @@
     5.4  
     5.5  local unit = Unit:by_id(id)
     5.6  
     5.7 -if member then
     5.8 +if unit then
     5.9    slot.put_into("title", encode.html(_("Unit: '#{name}'", { name = unit.name })))
    5.10  else
    5.11    slot.put_into("title", encode.html(_"Add new unit"))
    5.12  end
    5.13  
    5.14 -local units_selector = Unit:new_selector()
    5.15 -  
    5.16 -if member then
    5.17 -  units_selector
    5.18 -    :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id })
    5.19 -    :add_field("privilege.voting_right", "voting_right")
    5.20 +local units = {
    5.21 +  { id = nil, name = "" }
    5.22 +}
    5.23 +
    5.24 +for i, unit in ipairs(Unit:get_flattened_tree()) do
    5.25 +  units[#units+1] = { id = unit.id, name = unit.name }
    5.26  end
    5.27  
    5.28 -local units = units_selector:exec()
    5.29 -  
    5.30  ui.form{
    5.31    attr = { class = "vertical" },
    5.32    module = "admin",
    5.33 -  action = "member_update",
    5.34 -  id = member and member.id,
    5.35 -  record = member,
    5.36 -  readonly = not app.session.member.admin,
    5.37 +  action = "unit_update",
    5.38 +  id = unit and unit.id,
    5.39 +  record = unit,
    5.40    routing = {
    5.41      default = {
    5.42        mode = "redirect",
    5.43        modules = "admin",
    5.44 -      view = "member_list"
    5.45 +      view = "unit_list"
    5.46      }
    5.47    },
    5.48    content = function()
    5.49 -    ui.field.text{     label = _"Identification", name = "identification" }
    5.50 -    ui.field.text{     label = _"Notification email", name = "notify_email" }
    5.51 -    ui.field.boolean{  label = _"Admin?",       name = "admin" }
    5.52 +    ui.field.select{
    5.53 +      label = _"Parent unit",
    5.54 +      name = "parent_id",
    5.55 +      foreign_records = units,
    5.56 +      foreign_id      = "id",
    5.57 +      foreign_name    = "name"
    5.58 +    }
    5.59 +    ui.field.text{     label = _"Name",         name = "name" }
    5.60 +    ui.field.text{     label = _"Description",  name = "description", multiline = true }
    5.61 +    ui.field.boolean{  label = _"Active?",      name = "active" }
    5.62  
    5.63      slot.put("<br />")
    5.64 -    
    5.65 -    for i, unit in ipairs(units) do
    5.66 -      ui.field.boolean{
    5.67 -        name = "unit_" .. unit.id,
    5.68 -        label = unit.name,
    5.69 -        value = unit.voting_right
    5.70 -      }
    5.71 -    end
    5.72 -    slot.put("<br /><br />")
    5.73 -
    5.74 -    ui.field.boolean{  label = _"Send invite?",       name = "invite_member" }
    5.75      ui.submit{         text  = _"Save" }
    5.76    end
    5.77  }
     6.1 --- a/app/main/admin/unit_list.lua	Sat Jun 23 20:56:52 2012 +0200
     6.2 +++ b/app/main/admin/unit_list.lua	Sun Jun 24 20:41:50 2012 +0200
     6.3 @@ -1,10 +1,9 @@
     6.4  local units = Unit:get_flattened_tree{ active = true }
     6.5  
     6.6 -slot.put_into("title", _"Unit list")
     6.7 +ui.title(_"Unit list")
     6.8  
     6.9 -slot.select("actions", function()
    6.10 +ui.actions(function()
    6.11    ui.link{
    6.12 -    attr = { class = { "admin_only" } },
    6.13      text = _"Create new unit",
    6.14      module = "admin",
    6.15      view = "unit_edit"
    6.16 @@ -21,12 +20,11 @@
    6.17      {
    6.18        content = function(unit)
    6.19          ui.link{
    6.20 -          attr = { class = "action admin_only" },
    6.21            text = _"Edit unit",
    6.22            module = "admin", view = "unit_edit", id = unit.id
    6.23          }
    6.24 +        slot.put(" ")
    6.25          ui.link{
    6.26 -          attr = { class = "action admin_only" },
    6.27            text = _"Edit areas",
    6.28            module = "admin", view = "area_list", params = { unit_id = unit.id }
    6.29          }
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/env/ui/actions.lua	Sun Jun 24 20:41:50 2012 +0200
     7.3 @@ -0,0 +1,5 @@
     7.4 +function ui.actions(content)
     7.5 +  slot.select("head", function()
     7.6 +    ui.container{ attr = { class = "actions" }, content = content }
     7.7 +  end)
     7.8 +end
     7.9 \ No newline at end of file

Impressum / About Us