liquid_feedback_frontend
diff app/main/contact/list.lua @ 198:a9c6c11dd86c
Contact module refactored
| author | bsw |
|---|---|
| date | Mon Nov 08 15:41:14 2010 +0100 (2010-11-08) |
| parents | 80c215dbf076 |
| children | 72d8f5faa2e5 |
line diff
1.1 --- a/app/main/contact/list.lua Mon Nov 08 15:30:59 2010 +0100 1.2 +++ b/app/main/contact/list.lua Mon Nov 08 15:41:14 2010 +0100 1.3 @@ -1,9 +1,105 @@ 1.4 +local contacts_selector = Contact:build_selector{ 1.5 + member_id = app.session.member_id, 1.6 + order = "name" 1.7 +} 1.8 + 1.9 + 1.10 slot.put_into("title", _"Contacts") 1.11 1.12 + 1.13 util.help("contact.list") 1.14 1.15 -execute.view{ 1.16 - module = "contact", 1.17 - view = "_list", 1.18 - params = { contacts_selector = app.session.member:get_reference_selector("contacts") } 1.19 + 1.20 +ui.paginate{ 1.21 + selector = contacts_selector, 1.22 + content = function() 1.23 + local contacts = contacts_selector:exec() 1.24 + if #contacts == 0 then 1.25 + ui.field.text{ value = _"You didn't saved any member as contact yet." } 1.26 + else 1.27 + ui.list{ 1.28 + records = contacts, 1.29 + columns = { 1.30 + { 1.31 + label = _"Name", 1.32 + content = function(record) 1.33 + ui.link{ 1.34 + text = record.other_member.name, 1.35 + module = "member", 1.36 + view = "show", 1.37 + id = record.other_member_id 1.38 + } 1.39 + end 1.40 + }, 1.41 + { 1.42 + label = _"Published", 1.43 + content = function(record) 1.44 + ui.field.boolean{ value = record.public } 1.45 + end 1.46 + }, 1.47 + { 1.48 + content = function(record) 1.49 + if record.public then 1.50 + ui.link{ 1.51 + attr = { class = "action" }, 1.52 + text = _"Hide", 1.53 + module = "contact", 1.54 + action = "add_member", 1.55 + id = record.other_member_id, 1.56 + params = { public = false }, 1.57 + routing = { 1.58 + default = { 1.59 + mode = "redirect", 1.60 + module = request.get_module(), 1.61 + view = request.get_view(), 1.62 + id = param.get_id_cgi(), 1.63 + params = param.get_all_cgi() 1.64 + } 1.65 + } 1.66 + } 1.67 + else 1.68 + ui.link{ 1.69 + attr = { class = "action" }, 1.70 + text = _"Publish", 1.71 + module = "contact", 1.72 + action = "add_member", 1.73 + id = record.other_member_id, 1.74 + params = { public = true }, 1.75 + routing = { 1.76 + default = { 1.77 + mode = "redirect", 1.78 + module = request.get_module(), 1.79 + view = request.get_view(), 1.80 + id = param.get_id_cgi(), 1.81 + params = param.get_all_cgi() 1.82 + } 1.83 + } 1.84 + } 1.85 + end 1.86 + end 1.87 + }, 1.88 + { 1.89 + content = function(record) 1.90 + ui.link{ 1.91 + attr = { class = "action" }, 1.92 + text = _"Remove", 1.93 + module = "contact", 1.94 + action = "remove_member", 1.95 + id = record.other_member_id, 1.96 + routing = { 1.97 + default = { 1.98 + mode = "redirect", 1.99 + module = request.get_module(), 1.100 + view = request.get_view(), 1.101 + id = param.get_id_cgi(), 1.102 + params = param.get_all_cgi() 1.103 + } 1.104 + } 1.105 + } 1.106 + end 1.107 + }, 1.108 + } 1.109 + } 1.110 + end 1.111 + end 1.112 }