webmcp

diff demo-app/app/main/media_type/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/media_type/show.lua	Sun Oct 25 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,63 @@
     1.4 +local media_type
     1.5 +local id = param.get_id()
     1.6 +if id then
     1.7 +  media_type = MediaType:by_id(id)
     1.8 +end
     1.9 +
    1.10 +if media_type then
    1.11 +  slot.put_into("title", encode.html(_"Media type"))
    1.12 +else
    1.13 +  slot.put_into("title", encode.html(_"New media type"))
    1.14 +end
    1.15 +
    1.16 +slot.select("actions", function()
    1.17 +  ui.link{
    1.18 +    content = _"Back",
    1.19 +    module = "media_type"
    1.20 +  }
    1.21 +  if media_type and app.session.user.write_priv 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  = "media_type",
    1.28 +      action  = "update",
    1.29 +      id      = media_type.id,
    1.30 +      params = { delete = true },
    1.31 +      routing = {
    1.32 +        default = {
    1.33 +          mode = "redirect",
    1.34 +          module = "media_type",
    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 = media_type,
    1.46 +    readonly = not app.session.user.write_priv,
    1.47 +    module = "media_type",
    1.48 +    action = "update",
    1.49 +    id = id,
    1.50 +    routing = {
    1.51 +      default = {
    1.52 +        mode = "redirect",
    1.53 +        module = "media_type",
    1.54 +        view = "index"
    1.55 +      }
    1.56 +    },
    1.57 +    content = function()
    1.58 +      if id then
    1.59 +        ui.field.integer{ label = _"Id", name = "id", readonly = true }
    1.60 +      end
    1.61 +      ui.field.text{    label = _"Name",        name = "name"                          }
    1.62 +      ui.field.text{    label = _"Description", name = "description", multiline = true }
    1.63 +      ui.submit{ text = _"Save" }
    1.64 +    end
    1.65 +  }
    1.66 +end)

Impressum / About Us