annotate app/main/member/settings_applications.lua @ 1719:9b8dc1828f1f
If only one policy is available, choose it automatically
 | author | 
 bsw | 
 | date | 
 Mon Sep 27 13:07:56 2021 +0200 (2021-09-27) | 
 | parents | 
 afff8198bd98  | 
 | children | 
  | 
 
 | rev | 
   line source | 
| 
bsw/jbe@1309
 | 
     1 ui.titleMember(_"Connected applications")
 | 
| 
bsw/jbe@1309
 | 
     2 
 | 
| 
bsw/jbe@1309
 | 
     3 ui.grid{ content = function()
 | 
| 
bsw/jbe@1309
 | 
     4   ui.cell_main{ content = function()
 | 
| 
bsw/jbe@1309
 | 
     5 
 | 
| 
bsw/jbe@1309
 | 
     6     ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
     7       ui.container{ attr = { class = "mdl-card__title mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
     8         ui.heading { attr = { class = "mdl-card__title-text" }, level = 2, content = _"Connected applications" }
 | 
| 
bsw/jbe@1309
 | 
     9       end }
 | 
| 
bsw/jbe@1309
 | 
    10 
 | 
| 
bsw/jbe@1309
 | 
    11       local applications = MemberApplication:by_member_id(app.session.member_id)
 | 
| 
bsw/jbe@1309
 | 
    12       
 | 
| 
bsw@1645
 | 
    13       if #applications == 0 then
 | 
| 
bsw@1645
 | 
    14         ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = _"No applications connected" }
 | 
| 
bsw@1645
 | 
    15           
 | 
| 
bsw@1645
 | 
    16       end
 | 
| 
bsw@1645
 | 
    17       
 | 
| 
bsw/jbe@1309
 | 
    18       for i, application in ipairs(applications) do
 | 
| 
bsw/jbe@1309
 | 
    19         ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function()
 | 
| 
bsw/jbe@1309
 | 
    20           if application.system_application_id then
 | 
| 
bsw/jbe@1309
 | 
    21             ui.heading{ level = 2, content = application.system_application.name }
 | 
| 
bsw/jbe@1309
 | 
    22           else
 | 
| 
bsw/jbe@1309
 | 
    23             ui.heading{ level = 2, content = application.domain }
 | 
| 
bsw/jbe@1309
 | 
    24           end
 | 
| 
bsw/jbe@1309
 | 
    25           local scopes = {}
 | 
| 
bsw/jbe@1309
 | 
    26           for scope in string.gmatch(application.scope, "[^ ]+") do
 | 
| 
bsw/jbe@1309
 | 
    27             scopes[#scopes+1] = util.scope_name(scope)
 | 
| 
bsw/jbe@1309
 | 
    28           end
 | 
| 
bsw/jbe@1309
 | 
    29           local scopes_string = table.concat(scopes, ", ")
 | 
| 
bsw/jbe@1309
 | 
    30           ui.container{ content = scopes_string }
 | 
| 
bsw/jbe@1309
 | 
    31           ui.link{ content = _"Remove application", module = "member", action = "remove_application", id = application.id }
 | 
| 
bsw/jbe@1309
 | 
    32         end }
 | 
| 
bsw/jbe@1309
 | 
    33       end
 | 
| 
bsw/jbe@1309
 | 
    34     
 | 
| 
bsw/jbe@1309
 | 
    35     end }
 | 
| 
bsw/jbe@1309
 | 
    36   end }
 | 
| 
bsw/jbe@1309
 | 
    37 
 | 
| 
bsw/jbe@1309
 | 
    38   ui.cell_sidebar{ content = function()
 | 
| 
bsw/jbe@1309
 | 
    39     execute.view {
 | 
| 
bsw/jbe@1309
 | 
    40       module = "member", view = "_sidebar_whatcanido", params = {
 | 
| 
bsw/jbe@1309
 | 
    41         member = app.session.member
 | 
| 
bsw/jbe@1309
 | 
    42       }
 | 
| 
bsw/jbe@1309
 | 
    43     }
 | 
| 
bsw/jbe@1309
 | 
    44   end }
 | 
| 
bsw/jbe@1309
 | 
    45 
 | 
| 
bsw/jbe@1309
 | 
    46 end }
 |