webmcp
view demo-app/app/main/user/show.lua @ 3:795b764629ca
Version 1.0.3
Important bugfix related to internal forwards (Bug was introduced by the restriction of views with underscore prefix in Version 1.0.2)
Important bugfix related to internal forwards (Bug was introduced by the restriction of views with underscore prefix in Version 1.0.2)
author | jbe |
---|---|
date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
parents | 9fdfb27f8e67 |
children |
line source
1 local user
2 local id = param.get_id()
3 if id then
4 user = User:by_id(id)
5 end
7 if user then
8 slot.put_into("title", encode.html(_"User"))
9 else
10 slot.put_into("title", encode.html(_"New user"))
11 end
13 slot.select("actions", function()
14 ui.link{
15 content = _"Back",
16 module = "user"
17 }
18 if user then
19 ui.link{
20 content = _"Delete",
21 form_attr = {
22 onsubmit = "return confirm('" .. _'Are you sure?' .. "');"
23 },
24 module = "user",
25 action = "update",
26 id = user.id,
27 params = { delete = true },
28 routing = {
29 default = {
30 mode = "redirect",
31 module = "user",
32 view = "index"
33 }
34 }
35 }
36 end
37 end)
39 slot.select("main", function()
40 ui.form{
41 attr = { class = "vertical" },
42 record = user,
43 module = "user",
44 action = "update",
45 id = id,
46 routing = {
47 default = {
48 mode = "redirect",
49 module = "user",
50 view = "index"
51 }
52 },
53 content = function()
54 if id then
55 ui.field.integer{ label = _"Id", name = "id", readonly = true }
56 end
57 ui.field.text{ label = _"Ident", name = "ident" }
58 ui.field.text{ label = _"Password", name = "password" }
59 ui.field.text{ label = _"Name", name = "name" }
60 ui.field.boolean{ label = _"Write Priv", name = "write_priv" }
61 ui.field.boolean{ label = _"Admin", name = "admin" }
62 ui.submit{ text = _"Save" }
63 end
64 }
65 end)