webmcp
diff demo-app/app/main/user/show.lua @ 0:9fdfb27f8e67
Version 1.0.0
author | jbe/bsw |
---|---|
date | Sun Oct 25 12:00:00 2009 +0100 (2009-10-25) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/demo-app/app/main/user/show.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +local user 1.5 +local id = param.get_id() 1.6 +if id then 1.7 + user = User:by_id(id) 1.8 +end 1.9 + 1.10 +if user then 1.11 + slot.put_into("title", encode.html(_"User")) 1.12 +else 1.13 + slot.put_into("title", encode.html(_"New user")) 1.14 +end 1.15 + 1.16 +slot.select("actions", function() 1.17 + ui.link{ 1.18 + content = _"Back", 1.19 + module = "user" 1.20 + } 1.21 + if user then 1.22 + ui.link{ 1.23 + content = _"Delete", 1.24 + form_attr = { 1.25 + onsubmit = "return confirm('" .. _'Are you sure?' .. "');" 1.26 + }, 1.27 + module = "user", 1.28 + action = "update", 1.29 + id = user.id, 1.30 + params = { delete = true }, 1.31 + routing = { 1.32 + default = { 1.33 + mode = "redirect", 1.34 + module = "user", 1.35 + view = "index" 1.36 + } 1.37 + } 1.38 + } 1.39 + end 1.40 +end) 1.41 + 1.42 +slot.select("main", function() 1.43 + ui.form{ 1.44 + attr = { class = "vertical" }, 1.45 + record = user, 1.46 + module = "user", 1.47 + action = "update", 1.48 + id = id, 1.49 + routing = { 1.50 + default = { 1.51 + mode = "redirect", 1.52 + module = "user", 1.53 + view = "index" 1.54 + } 1.55 + }, 1.56 + content = function() 1.57 + if id then 1.58 + ui.field.integer{ label = _"Id", name = "id", readonly = true } 1.59 + end 1.60 + ui.field.text{ label = _"Ident", name = "ident" } 1.61 + ui.field.text{ label = _"Password", name = "password" } 1.62 + ui.field.text{ label = _"Name", name = "name" } 1.63 + ui.field.boolean{ label = _"Write Priv", name = "write_priv" } 1.64 + ui.field.boolean{ label = _"Admin", name = "admin" } 1.65 + ui.submit{ text = _"Save" } 1.66 + end 1.67 + } 1.68 +end)