# HG changeset patch # User bsw # Date 1340563310 -7200 # Node ID bc69344110193307b01db4d22658cf3e166bf739 # Parent 487cca534fbe1712d599561c17e36f9301522c29 Added unit editor, small fixes at admin section diff -r 487cca534fbe -r bc6934411019 app/main/admin/_action/area_update.lua --- a/app/main/admin/_action/area_update.lua Sat Jun 23 20:56:52 2012 +0200 +++ b/app/main/admin/_action/area_update.lua Sun Jun 24 20:41:50 2012 +0200 @@ -35,5 +35,3 @@ pol:save() end end - -slot.put_into("notice", _"Area successfully updated") diff -r 487cca534fbe -r bc6934411019 app/main/admin/_action/policy_update.lua --- a/app/main/admin/_action/policy_update.lua Sat Jun 23 20:56:52 2012 +0200 +++ b/app/main/admin/_action/policy_update.lua Sun Jun 24 20:41:50 2012 +0200 @@ -12,5 +12,3 @@ ) policy:save() - -slot.put_into("notice", _"Policy successfully updated") diff -r 487cca534fbe -r bc6934411019 app/main/admin/_action/unit_update.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/admin/_action/unit_update.lua Sun Jun 24 20:41:50 2012 +0200 @@ -0,0 +1,5 @@ +local unit = Unit:by_id(param.get_id()) or Unit:new() + +param.update(unit, "parent_id", "name", "description", "active") + +unit:save() diff -r 487cca534fbe -r bc6934411019 app/main/admin/area_list.lua --- a/app/main/admin/area_list.lua Sat Jun 23 20:56:52 2012 +0200 +++ b/app/main/admin/area_list.lua Sun Jun 24 20:41:50 2012 +0200 @@ -6,21 +6,13 @@ local areas = Area:build_selector{ unit_id = unit_id, active = not show_not_in_use }:exec() -slot.put_into("title", _("Area list of '#{unit_name}'", { unit_name = unit.name})) +ui.title(_("Area list of '#{unit_name}'", { unit_name = unit.name })) -slot.select("actions", function() - - ui.link{ - attr = { class = { "admin_only" } }, - text = _"Back to unit list", - module = "admin", - view = "unit_list" - } +ui.actions(function() if show_not_in_use then ui.link{ - attr = { class = { "admin_only" } }, text = _"Show areas in use", module = "admin", view = "area_list", @@ -29,14 +21,15 @@ else ui.link{ - attr = { class = { "admin_only" } }, text = _"Create new area", module = "admin", view = "area_show", params = { unit_id = unit_id } } + + slot.put(" · ") + ui.link{ - attr = { class = { "admin_only" } }, text = _"Show areas not in use", module = "admin", view = "area_list", diff -r 487cca534fbe -r bc6934411019 app/main/admin/unit_edit.lua --- a/app/main/admin/unit_edit.lua Sat Jun 23 20:56:52 2012 +0200 +++ b/app/main/admin/unit_edit.lua Sun Jun 24 20:41:50 2012 +0200 @@ -2,53 +2,46 @@ local unit = Unit:by_id(id) -if member then +if unit then slot.put_into("title", encode.html(_("Unit: '#{name}'", { name = unit.name }))) else slot.put_into("title", encode.html(_"Add new unit")) end -local units_selector = Unit:new_selector() - -if member then - units_selector - :left_join("privilege", nil, { "privilege.member_id = ? AND privilege.unit_id = unit.id", member.id }) - :add_field("privilege.voting_right", "voting_right") +local units = { + { id = nil, name = "" } +} + +for i, unit in ipairs(Unit:get_flattened_tree()) do + units[#units+1] = { id = unit.id, name = unit.name } end -local units = units_selector:exec() - ui.form{ attr = { class = "vertical" }, module = "admin", - action = "member_update", - id = member and member.id, - record = member, - readonly = not app.session.member.admin, + action = "unit_update", + id = unit and unit.id, + record = unit, routing = { default = { mode = "redirect", modules = "admin", - view = "member_list" + view = "unit_list" } }, content = function() - ui.field.text{ label = _"Identification", name = "identification" } - ui.field.text{ label = _"Notification email", name = "notify_email" } - ui.field.boolean{ label = _"Admin?", name = "admin" } + ui.field.select{ + label = _"Parent unit", + name = "parent_id", + foreign_records = units, + foreign_id = "id", + foreign_name = "name" + } + ui.field.text{ label = _"Name", name = "name" } + ui.field.text{ label = _"Description", name = "description", multiline = true } + ui.field.boolean{ label = _"Active?", name = "active" } slot.put("
") - - for i, unit in ipairs(units) do - ui.field.boolean{ - name = "unit_" .. unit.id, - label = unit.name, - value = unit.voting_right - } - end - slot.put("

") - - ui.field.boolean{ label = _"Send invite?", name = "invite_member" } ui.submit{ text = _"Save" } end } diff -r 487cca534fbe -r bc6934411019 app/main/admin/unit_list.lua --- a/app/main/admin/unit_list.lua Sat Jun 23 20:56:52 2012 +0200 +++ b/app/main/admin/unit_list.lua Sun Jun 24 20:41:50 2012 +0200 @@ -1,10 +1,9 @@ local units = Unit:get_flattened_tree{ active = true } -slot.put_into("title", _"Unit list") +ui.title(_"Unit list") -slot.select("actions", function() +ui.actions(function() ui.link{ - attr = { class = { "admin_only" } }, text = _"Create new unit", module = "admin", view = "unit_edit" @@ -21,12 +20,11 @@ { content = function(unit) ui.link{ - attr = { class = "action admin_only" }, text = _"Edit unit", module = "admin", view = "unit_edit", id = unit.id } + slot.put(" ") ui.link{ - attr = { class = "action admin_only" }, text = _"Edit areas", module = "admin", view = "area_list", params = { unit_id = unit.id } } diff -r 487cca534fbe -r bc6934411019 env/ui/actions.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/env/ui/actions.lua Sun Jun 24 20:41:50 2012 +0200 @@ -0,0 +1,5 @@ +function ui.actions(content) + slot.select("head", function() + ui.container{ attr = { class = "actions" }, content = content } + end) +end \ No newline at end of file