webmcp
view demo-app/app/main/genre/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 genre
2 local id = param.get_id()
3 if id then
4 genre = Genre:by_id(id)
5 end
7 if genre then
8 slot.put_into("title", encode.html(_"Genre"))
9 else
10 slot.put_into("title", encode.html(_"New genre"))
11 end
13 slot.select("actions", function()
14 ui.link{
15 content = _"Back",
16 module = "genre"
17 }
18 if genre and app.session.user.write_priv then
19 ui.link{
20 content = _"Delete",
21 form_attr = {
22 onsubmit = "return confirm('" .. _'Are you sure?' .. "');"
23 },
24 module = "genre",
25 action = "update",
26 id = genre.id,
27 params = { delete = true },
28 routing = {
29 default = {
30 mode = "redirect",
31 module = "genre",
32 view = "index"
33 }
34 }
35 }
36 end
37 end)
39 slot.select("main", function()
40 ui.form{
41 attr = { class = "vertical" },
42 record = genre,
43 readonly = not app.session.user.write_priv,
44 module = "genre",
45 action = "update",
46 id = id,
47 routing = {
48 default = {
49 mode = "redirect",
50 module = "genre",
51 view = "index"
52 }
53 },
54 content = function()
55 if id then
56 ui.field.integer{ label = _"Id", name = "id", readonly = true }
57 end
58 ui.field.text{ label = _"Name", name = "name" }
59 ui.field.text{ label = _"Description", name = "description", multiline = true }
60 ui.submit{ text = _"Save" }
61 end
62 }
63 end)
