bsw@198: local contacts_selector = Contact:build_selector{ bsw@198: member_id = app.session.member_id, bsw@198: order = "name" bsw@198: } bsw@198: bsw@564: ui.title(_"Contacts") bsw/jbe@0: bsw@198: bsw@198: ui.paginate{ bsw@198: selector = contacts_selector, bsw@198: content = function() bsw@198: local contacts = contacts_selector:exec() bsw@198: if #contacts == 0 then jbe@233: ui.field.text{ value = _"You didn't save any member as contact yet." } bsw@198: else bsw@198: ui.list{ bsw@198: records = contacts, bsw@198: columns = { bsw@198: { bsw@198: label = _"Name", bsw@198: content = function(record) bsw@198: ui.link{ bsw@198: text = record.other_member.name, bsw@198: module = "member", bsw@198: view = "show", bsw@198: id = record.other_member_id bsw@198: } bsw@198: end bsw@198: }, bsw@198: { bsw@198: label = _"Published", bsw@198: content = function(record) bsw@198: ui.field.boolean{ value = record.public } bsw@198: end bsw@198: }, bsw@198: { bsw@198: content = function(record) bsw@198: if record.public then bsw@198: ui.link{ bsw@198: attr = { class = "action" }, bsw@198: text = _"Hide", bsw@198: module = "contact", bsw@198: action = "add_member", bsw@198: id = record.other_member_id, bsw@198: params = { public = false }, bsw@198: routing = { bsw@198: default = { bsw@198: mode = "redirect", bsw@198: module = request.get_module(), bsw@198: view = request.get_view(), bsw@1145: id = request.get_id_string(), bsw@1145: params = request.get_param_strings() bsw@198: } bsw@198: } bsw@198: } bsw@198: else bsw@198: ui.link{ bsw@198: attr = { class = "action" }, bsw@198: text = _"Publish", bsw@198: module = "contact", bsw@198: action = "add_member", bsw@198: id = record.other_member_id, bsw@198: params = { public = true }, bsw@198: routing = { bsw@198: default = { bsw@198: mode = "redirect", bsw@198: module = request.get_module(), bsw@198: view = request.get_view(), bsw@1145: id = request.get_id_string(), bsw@1145: params = request.get_param_strings() bsw@198: } bsw@198: } bsw@198: } bsw@198: end bsw@198: end bsw@198: }, bsw@198: { bsw@198: content = function(record) bsw@198: ui.link{ bsw@198: attr = { class = "action" }, bsw@198: text = _"Remove", bsw@198: module = "contact", bsw@198: action = "remove_member", bsw@198: id = record.other_member_id, bsw@198: routing = { bsw@198: default = { bsw@198: mode = "redirect", bsw@198: module = request.get_module(), bsw@198: view = request.get_view(), bsw@1145: id = request.get_id_string(), bsw@1145: params = request.get_param_strings() bsw@198: } bsw@198: } bsw@198: } bsw@198: end bsw@198: }, bsw@198: } bsw@198: } bsw@198: end bsw@198: end bsw/jbe@0: }