liquid_feedback_frontend
view app/main/member/settings_agent.lua @ 1416:b06da8ab308d
Do not show identification twice in profile, made form labels distinctive
author | bsw |
---|---|
date | Thu Aug 30 10:42:48 2018 +0200 (2018-08-30) |
parents | 32cc544d5a5b |
children | 678c7146f27b |
line source
1 if not app.session.member.role then
2 return
3 end
5 ui.titleMember(_"Account access")
7 ui.grid{ content = function()
9 ui.cell_main{ content = function()
10 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
11 ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
12 ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Agents" }
13 end }
14 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
16 local agents = Agent:new_selector()
17 :add_where{ "controlled_id = ?", app.session.member_id }
18 :exec()
20 if #(agents) > 0 then
21 ui.list{
22 records = agents,
23 columns = {
24 {
25 label = _"Account access by member",
26 content = function(record)
27 ui.tag{ content = record.controller.name }
28 end
29 },
30 {
31 label = _"Status",
32 content = function(record)
33 local text
34 if record.accepted then
35 text = _"accepted"
36 elseif record.accepted == false then
37 text = _"rejected"
38 else
39 text = _"not decided yet"
40 end
41 ui.tag{ content = text }
42 end
43 },
44 {
45 content = function(record)
46 ui.link{ content = _"Revoke", module = "member", action = "update_agent", params = { delete = true, controller_id = record.controller_id } }
47 end
48 },
49 }
50 }
51 else
52 ui.container{ content = _"No other members are allowed to use this account." }
53 end
55 end }
56 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
58 ui.form{
59 attr = { class = "wide" },
60 module = "member",
61 action = "update_agent",
62 routing = {
63 ok = {
64 mode = "redirect",
65 module = "member",
66 view = "settings_agent"
67 }
68 },
69 content = function()
71 ui.container{ content = _"Add new account access privilege" }
73 local contact_members = Member:build_selector{
74 is_contact_of_member_id = app.session.member_id,
75 active = true,
76 order = "name"
77 }:add_where("NOT member.role"):exec()
79 ui.field.select{
80 name = "controller_id",
81 foreign_records = contact_members,
82 foreign_id = "id",
83 foreign_name = "name"
84 }
85 slot.put("<br />")
87 ui.tag{
88 tag = "input",
89 attr = {
90 type = "submit",
91 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored",
92 value = _"Grant account access"
93 },
94 content = ""
95 }
96 slot.put(" ")
97 ui.link {
98 attr = { class = "mdl-button mdl-js-button mdl-button--raised" },
99 module = "member", view = "show", id = app.session.member_id,
100 content = _"Cancel"
101 }
102 end
103 }
105 end }
106 end }
107 end }
109 ui.cell_sidebar{ content = function()
110 execute.view {
111 module = "member", view = "_sidebar_whatcanido", params = {
112 member = app.session.member
113 }
114 }
115 end }
117 end }