webmcp

changeset 256:4654d59a4079

Remove env/ui_deprecated
author jbe
date Sun Mar 15 00:49:16 2015 +0100 (2015-03-15)
parents 9e4be058959d
children 78a2ae40c88e
files framework/env/ui_deprecated/__init.lua framework/env/ui_deprecated/_prepare_redirect_params.lua framework/env/ui_deprecated/_stringify_table.lua framework/env/ui_deprecated/box.lua framework/env/ui_deprecated/calendar.lua framework/env/ui_deprecated/field.lua framework/env/ui_deprecated/form.lua framework/env/ui_deprecated/image.lua framework/env/ui_deprecated/input.lua framework/env/ui_deprecated/input_field/boolean.lua framework/env/ui_deprecated/input_field/date.lua framework/env/ui_deprecated/input_field/datetime.lua framework/env/ui_deprecated/input_field/number.lua framework/env/ui_deprecated/input_field/percentage.lua framework/env/ui_deprecated/input_field/reset.lua framework/env/ui_deprecated/input_field/text.lua framework/env/ui_deprecated/input_field/textarea.lua framework/env/ui_deprecated/input_field/time.lua framework/env/ui_deprecated/label.lua framework/env/ui_deprecated/link.lua framework/env/ui_deprecated/list.lua framework/env/ui_deprecated/multiselect.lua framework/env/ui_deprecated/select.lua framework/env/ui_deprecated/submit.lua framework/env/ui_deprecated/tag.lua framework/env/ui_deprecated/text.lua
line diff
     1.1 --- a/framework/env/ui_deprecated/__init.lua	Sat Mar 14 23:39:47 2015 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,2 +0,0 @@
     1.4 -ui_deprecated._form = {}
     1.5 -
     2.1 --- a/framework/env/ui_deprecated/_prepare_redirect_params.lua	Sat Mar 14 23:39:47 2015 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,26 +0,0 @@
     2.4 -function ui_deprecated._prepare_redirect_params(params, redirect_to)
     2.5 -  if redirect_to then
     2.6 -    for status, settings in pairs(redirect_to) do
     2.7 -      local module, view = settings.module, settings.view
     2.8 -      if not module then
     2.9 -        error("No redirection module specified.")
    2.10 -      end
    2.11 -      if not view then
    2.12 -        error("No redirection view specified.")
    2.13 -      end
    2.14 -      if status == "ok" then
    2.15 -        params["_webmcp_routing." .. status .. ".mode"] = "redirect"
    2.16 -      else
    2.17 -        params["_webmcp_routing." .. status .. ".mode"] = "forward"
    2.18 -      end
    2.19 -      params["_webmcp_routing." .. status .. ".module"] = settings.module
    2.20 -      params["_webmcp_routing." .. status .. ".view"]   = settings.view
    2.21 -      params["_webmcp_routing." .. status .. ".id"]     = settings.id
    2.22 -      if settings.params then
    2.23 -        for key, value in pairs(settings.params) do
    2.24 -          params["_webmcp_routing." .. status .. ".params." .. key] = value
    2.25 -        end
    2.26 -      end
    2.27 -    end
    2.28 -  end
    2.29 -end
     3.1 --- a/framework/env/ui_deprecated/_stringify_table.lua	Sat Mar 14 23:39:47 2015 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,11 +0,0 @@
     3.4 -function ui_deprecated._stringify_table(table)
     3.5 -  if not table then
     3.6 -    return ''
     3.7 -  end
     3.8 -  local string = ''
     3.9 -  for key, value in pairs(table) do
    3.10 -    string = string .. ' ' .. key .. '="' .. value ..'"'
    3.11 -  end
    3.12 -  return string
    3.13 -end
    3.14 -
     4.1 --- a/framework/env/ui_deprecated/box.lua	Sat Mar 14 23:39:47 2015 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,29 +0,0 @@
     4.4 ---[[doc: ui_deprecated.box
     4.5 -
     4.6 -Starts a box
     4.7 -
     4.8 -label (string) Label, optional
     4.9 -class (string) Style class, optional
    4.10 -content (function) or (string) The content of the box
    4.11 -
    4.12 -
    4.13 -Example:
    4.14 -
    4.15 -ui_deprecated.box{
    4.16 -  label   = 'My box label',
    4.17 -  class   = 'my_css_class',
    4.18 -  content = function() 
    4.19 -    ui_deprecated.text('My text')
    4.20 -  end
    4.21 -}
    4.22 -
    4.23 ---]]
    4.24 -
    4.25 -function ui_deprecated.box(args)
    4.26 -  if args.class then
    4.27 -    args.html_options = args.html_options or {}
    4.28 -    args.html_options.class = args.class
    4.29 -  end
    4.30 -  ui_deprecated.tag('div', args)
    4.31 -end
    4.32 -
     5.1 --- a/framework/env/ui_deprecated/calendar.lua	Sat Mar 14 23:39:47 2015 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,147 +0,0 @@
     5.4 -function ui_deprecated.calendar(args)
     5.5 -  local record = assert(slot.get_state_table(), "ui_deprecated.calender was not called within a form.").form_record
     5.6 -  local value = param.get(args.field, atom.date) or record[args.field]
     5.7 -  local year = param.get('_ui_calendar_year', atom.integer) or args.year or 2008
     5.8 -  local month = param.get('_ui_calendar_month', atom.integer) or args.month or 10
     5.9 -  local empty_days = atom.date{ year = year, month = month, day = 1 }.iso_weekday -1
    5.10 -  local enabled = not args.disabled
    5.11 -  
    5.12 -  local prev_year = year
    5.13 -  local prev_month = month - 1
    5.14 -  if prev_month == 0 then
    5.15 -    prev_month = 12
    5.16 -    prev_year = prev_year - 1
    5.17 -  end
    5.18 -
    5.19 -  local next_year = year
    5.20 -  local next_month = month + 1
    5.21 -  if next_month == 13 then
    5.22 -    next_month = 1
    5.23 -    next_year = next_year + 1
    5.24 -  end
    5.25 -  
    5.26 -  ui_deprecated.tag('div', {
    5.27 -    html_options = {
    5.28 -      class="ui_field ui_calendar"
    5.29 -    },
    5.30 -    content = function()
    5.31 -      ui_deprecated.tag('input', {
    5.32 -        html_options = {
    5.33 -          type = 'hidden',
    5.34 -          value = year,
    5.35 -          name = '_ui_calendar_year',
    5.36 -          id = '_ui_calendar_year',
    5.37 -          onchange = 'this.form.submit();'
    5.38 -        }
    5.39 -      })
    5.40 -      ui_deprecated.tag('input', {
    5.41 -        html_options = {
    5.42 -          type = 'hidden',
    5.43 -          value = month,
    5.44 -          name = '_ui_calendar_month',
    5.45 -          id = '_ui_calendar_month',
    5.46 -          onchange = 'this.form.submit();'
    5.47 -        }
    5.48 -      })
    5.49 -      ui_deprecated.tag('input', {
    5.50 -        html_options = {
    5.51 -          type = 'hidden',
    5.52 -          value = value and tostring(value) or '',
    5.53 -          name = args.field,
    5.54 -          id = '_ui_calendar_input',
    5.55 -          onchange = 'this.form.submit();'
    5.56 -        }
    5.57 -      })
    5.58 -      if args.label then
    5.59 -        ui_deprecated.tag('div', {
    5.60 -          html_options = {
    5.61 -            class="label"
    5.62 -          },
    5.63 -          content = function()
    5.64 -            ui_deprecated.text(args.label)
    5.65 -          end
    5.66 -        })
    5.67 -      end
    5.68 -      ui_deprecated.tag('div', {
    5.69 -        html_options = {
    5.70 -          class="value"
    5.71 -        },
    5.72 -        content = function()
    5.73 -          ui_deprecated.tag('div', {
    5.74 -            html_options = {
    5.75 -              class = 'next',
    5.76 -              href = '#',
    5.77 -              onclick = enabled and "document.getElementById('_ui_calendar_year').value = '" .. tostring(next_year) .. "'; document.getElementById('_ui_calendar_month').value = '" .. tostring(next_month) .. "'; document.getElementById('_ui_calendar_year').form.submit();" or '', 
    5.78 -            },
    5.79 -            content = '>>>';
    5.80 -          })
    5.81 -          ui_deprecated.tag('div', {
    5.82 -            html_options = {
    5.83 -              class = 'prev',
    5.84 -              href = '#',
    5.85 -              onclick = enabled and "document.getElementById('_ui_calendar_year').value = '" .. tostring(prev_year) .. "'; document.getElementById('_ui_calendar_month').value = '" .. tostring(prev_month) .. "'; document.getElementById('_ui_calendar_year').form.submit();" or '', 
    5.86 -            },
    5.87 -            content = '<<<';
    5.88 -          })
    5.89 -          ui_deprecated.tag('div', {
    5.90 -            html_options = {
    5.91 -              class="title"
    5.92 -            },
    5.93 -            content = function()
    5.94 -              local months = {_'January', _'February', _'March', _'April', _'May', _'June', _'July', _'August', _'September', _'October', _'November', _'December' }
    5.95 -              ui_deprecated.text(months[month])
    5.96 -              ui_deprecated.text(' ')
    5.97 -              ui_deprecated.text(tostring(year))
    5.98 -            end
    5.99 -          })
   5.100 -          ui_deprecated.tag('table', { 
   5.101 -            content = function()
   5.102 -              ui_deprecated.tag('thead', { 
   5.103 -                content = function()
   5.104 -                  ui_deprecated.tag('tr', {
   5.105 -                    content = function()
   5.106 -                      local dows = { _'Mon', _'Tue', _'Wed', _'Thu', _'Fri', _'Sat', _'Sun' }
   5.107 -                      for col = 1,7 do
   5.108 -                        ui_deprecated.tag('th', { content = dows[col] })
   5.109 -                      end
   5.110 -                    end
   5.111 -                  })
   5.112 -                end
   5.113 -              })
   5.114 -              ui_deprecated.tag('tbody', { 
   5.115 -                content = function()
   5.116 -                  for row = 1,6 do
   5.117 -                    ui_deprecated.tag('tr', {
   5.118 -                      content = function()
   5.119 -                        for col = 1,7 do
   5.120 -                          local day = (row -1) * 7 + col - empty_days
   5.121 -                          local date = atom.date.invalid
   5.122 -                          if day > 0 then
   5.123 -                            date = atom.date{ year = year, month = month, day = day }
   5.124 -                          end
   5.125 -                          ui_deprecated.tag('td', {
   5.126 -                            html_options = {
   5.127 -                              onclick = enabled and 'document.getElementById(\'_ui_calendar_input\').value = \'' .. tostring(date) .. '\'; document.getElementById(\'_ui_calendar_input\').onchange(); ' or ''
   5.128 -                            },
   5.129 -                            content = function()
   5.130 -                              if date.invalid then
   5.131 -                                slot.put('&nbsp;')
   5.132 -                              else
   5.133 -                                local selected = date == value
   5.134 -                                args.day_func(date, selected)
   5.135 -                              end
   5.136 -                            end
   5.137 -                          })
   5.138 -                        end
   5.139 -                      end
   5.140 -                    })
   5.141 -                  end
   5.142 -                end
   5.143 -              })
   5.144 -            end
   5.145 -          })
   5.146 -        end
   5.147 -      })
   5.148 -    end
   5.149 -  })
   5.150 -end
     6.1 --- a/framework/env/ui_deprecated/field.lua	Sat Mar 14 23:39:47 2015 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,34 +0,0 @@
     6.4 ---
     6.5 --- Creates an output field
     6.6 ---
     6.7 --- label      (string) The label of the field
     6.8 --- value      (atom)   The value to put out
     6.9 --- field_type (string) The type of the field (default: 'string')
    6.10 ---
    6.11 --- Example:
    6.12 ---
    6.13 ---  ui_deprecated.field({
    6.14 ---    label = _'Id',
    6.15 ---    value = myobject.id, 
    6.16 ---    field_type = 'integer'
    6.17 ---  })
    6.18 ---
    6.19 -
    6.20 -function ui_deprecated.field(args)
    6.21 -  local value_type = args.value_type or atom.string
    6.22 -  slot.put(
    6.23 -    '<div class="ui_field ui_field_', value_type.name, '">',
    6.24 -      '<div class="label">',
    6.25 -        encode.html(args.label or ''), 
    6.26 -      '</div>',
    6.27 -      '<div class="value">')
    6.28 -  if args.value then
    6.29 -    slot.put(encode.html(convert.to_human(args.value, value_type)))
    6.30 -  elseif args.link then
    6.31 -    ui_deprecated.link(args.link)
    6.32 -  end
    6.33 -  slot.put(
    6.34 -      '</div>',
    6.35 -    '</div>\n'
    6.36 -  )
    6.37 -end
     7.1 --- a/framework/env/ui_deprecated/form.lua	Sat Mar 14 23:39:47 2015 +0100
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,85 +0,0 @@
     7.4 ---
     7.5 --- Creates a formular
     7.6 ---
     7.7 --- record          (record)   Take field values from this object (optional)
     7.8 --- class           (string)   Style class (optional)
     7.9 --- method          (string)   Submit method ['post', 'get'] (optional)
    7.10 --- module          (string)   The module to submit to
    7.11 --- action          (string)   The action to submit to
    7.12 --- params          (table)    The GET parameter to be send with
    7.13 --- content         (function) Function for the content of the form
    7.14 ---
    7.15 --- Example:
    7.16 ---
    7.17 ---  ui_deprecated.form({
    7.18 ---    object = client,
    7.19 ---    class  = 'form_class',
    7.20 ---    method = 'post',
    7.21 ---    module = 'client',
    7.22 ---    action = 'update',
    7.23 ---    params = {
    7.24 ---      id = client.id
    7.25 ---    }, 
    7.26 ---    redirect_to = {
    7.27 ---      ok = {
    7.28 ---        module = 'client', 
    7.29 ---        view = 'list'
    7.30 ---        },
    7.31 ---      error = {
    7.32 ---        module = 'client', 
    7.33 ---        view = 'edit', 
    7.34 ---        params = { 
    7.35 ---          id = client.id
    7.36 ---        }
    7.37 ---      }
    7.38 ---    },
    7.39 ---  })
    7.40 -
    7.41 -function ui_deprecated.form(args)
    7.42 -  local slot_state = slot.get_state_table()
    7.43 -  if slot_state.form_opened then
    7.44 -    error("Cannot open a form inside a form.")
    7.45 -  end
    7.46 -  slot_state.form_opened = true
    7.47 -  local old_record = slot_state.form_record
    7.48 -  slot_state.form_record = args.record or {}  -- TODO: decide what really should happen when no record is specified
    7.49 -
    7.50 -  local params = {}
    7.51 -  if args.params then
    7.52 -    for key, value in pairs(args.params) do
    7.53 -      params[key] = value
    7.54 -    end
    7.55 -  end
    7.56 -  ui_deprecated._prepare_redirect_params(params, args.redirect_to)
    7.57 -
    7.58 -  local attr_action = args.url or encode.url{
    7.59 -    module = args.module,
    7.60 -    view   = args.view,
    7.61 -    action = args.action,
    7.62 -    id     = args.id,
    7.63 -    params = params
    7.64 -  }
    7.65 -
    7.66 -  local base = request.get_relative_baseurl()
    7.67 -  local attr_class = table.concat({ 'ui_form', args.class }, ' ')
    7.68 -  local attr_method = args.method or 'POST'  -- TODO: uppercase/sanatize method
    7.69 -
    7.70 -  slot.put(
    7.71 -    '<form',
    7.72 -    ' action="', attr_action, '"',
    7.73 -    ' class="',  attr_class,  '"',
    7.74 -    ' method="', attr_method, '"',
    7.75 -    '>\n'
    7.76 -  )
    7.77 -
    7.78 -  if type(args.content) == 'function' then
    7.79 -    args.content()
    7.80 -  else
    7.81 -    error('No content function')
    7.82 -  end
    7.83 -
    7.84 -  slot.put('</form>')
    7.85 -  slot_state.form_record = old_record
    7.86 -  slot_state.form_opened = false
    7.87 -
    7.88 -end
     8.1 --- a/framework/env/ui_deprecated/image.lua	Sat Mar 14 23:39:47 2015 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,22 +0,0 @@
     8.4 ---
     8.5 --- Creates an image
     8.6 ---
     8.7 --- image           (string)
     8.8 ---
     8.9 --- Example:
    8.10 ---
    8.11 ---  ui_deprecated.image({
    8.12 ---    image = 'test.png',
    8.13 ---  })
    8.14 ---
    8.15 -
    8.16 -function ui_deprecated.image(args)
    8.17 -  assert(args.image, "No image argument given.")
    8.18 -  slot.put(
    8.19 -    '<img src="',
    8.20 -    request.get_relative_baseurl(),
    8.21 -    'static/',
    8.22 -    args.image,
    8.23 -    '" />'
    8.24 -  )
    8.25 -end
     9.1 --- a/framework/env/ui_deprecated/input.lua	Sat Mar 14 23:39:47 2015 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,67 +0,0 @@
     9.4 ---
     9.5 --- Creates an input field in a form
     9.6 ---
     9.7 --- label      (string) The label of the input field
     9.8 --- field      (string) The name of the record field
     9.9 --- field_type (string) The type of the record field
    9.10 ---
    9.11 --- Example:
    9.12 ---
    9.13 ---  ui_deprecated.input({
    9.14 ---    label = _'Comment',
    9.15 ---    field = 'comment', 
    9.16 ---    field_type = 'textarea'
    9.17 ---  })
    9.18 ---
    9.19 -local field_type_to_atom_class_map = {
    9.20 -  text       = atom.string,
    9.21 -  textarea   = atom.string,
    9.22 -  number     = atom.number,
    9.23 -  percentage = atom.number,
    9.24 -}
    9.25 -
    9.26 -function ui_deprecated.input(args)
    9.27 -  local record = assert(slot.get_state_table(), "ui_deprecated.input was not called within a form.").form_record
    9.28 -
    9.29 -  local field_type = args.field_type or "text"
    9.30 -
    9.31 -  local field_func = assert(ui_deprecated.input_field[field_type], "no field helper for given type '" .. field_type .. "'")
    9.32 -
    9.33 -  local html_name = args.name or args.field
    9.34 -  local field_html
    9.35 -
    9.36 -  if args.field then
    9.37 -    local param_type = field_type_to_atom_class_map[field_type] or error('Unkown field type')
    9.38 -    field_html = field_func{
    9.39 -      name  = html_name, 
    9.40 -      value = param.get(html_name, param_type) 
    9.41 -              or record[args.field],
    9.42 -      height = args.height,
    9.43 -    }
    9.44 -
    9.45 -  elseif args.value then
    9.46 -    field_html = field_func{
    9.47 -      name  = html_name, 
    9.48 -      value = args.value,
    9.49 -      height = args.height,
    9.50 -    }
    9.51 -  
    9.52 -  else
    9.53 -    field_html = field_func{
    9.54 -      name  = html_name, 
    9.55 -      value = '',
    9.56 -      height = args.height,
    9.57 -    }
    9.58 -    
    9.59 -  end
    9.60 -  
    9.61 -  slot.put('<div class="ui_field ui_input_', field_type, '">\n')
    9.62 -  if args.label then
    9.63 -    slot.put('<div class="label">', encode.html(args.label), '</div>\n')
    9.64 -  end
    9.65 -  slot.put('<div class="value">',
    9.66 -        field_html,
    9.67 -      '</div>\n',
    9.68 -    '</div>\n'
    9.69 -  )
    9.70 -end
    13.1 --- a/framework/env/ui_deprecated/input_field/number.lua	Sat Mar 14 23:39:47 2015 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,5 +0,0 @@
    13.4 -function ui_deprecated.input_field.number(args)
    13.5 -	name = args.name or ''
    13.6 -	value = args.value or 0
    13.7 -	return '<input class="ui_input_field_number" type="text" name="' .. name .. '" value="' .. convert.to_human(value, "number") .. '" />'
    13.8 -end
    13.9 \ No newline at end of file
    14.1 --- a/framework/env/ui_deprecated/input_field/percentage.lua	Sat Mar 14 23:39:47 2015 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,5 +0,0 @@
    14.4 -function ui_deprecated.input_field.percentage(args)
    14.5 -	name = args.name or ''
    14.6 -	value = args.value or 0
    14.7 -	return '<input class="ui_input_field_percentage" type="text" name="' .. name .. '" value="' .. convert.to_human(value, "number") .. '" /> %'
    14.8 -end
    14.9 \ No newline at end of file
    16.1 --- a/framework/env/ui_deprecated/input_field/text.lua	Sat Mar 14 23:39:47 2015 +0100
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,5 +0,0 @@
    16.4 -function ui_deprecated.input_field.text(args)
    16.5 -	name = args.name or ''
    16.6 -	value = args.value or ''
    16.7 -	return '<input type="text" name="' .. name .. '" value="' .. convert.to_human(value, "string") .. '" />'
    16.8 -end
    16.9 \ No newline at end of file
    17.1 --- a/framework/env/ui_deprecated/input_field/textarea.lua	Sat Mar 14 23:39:47 2015 +0100
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,9 +0,0 @@
    17.4 -function ui_deprecated.input_field.textarea(args)
    17.5 -	local value = args.value or ''
    17.6 -	local name = assert(args.name, 'No field name given')
    17.7 -	local style = ''
    17.8 -	if args.height then
    17.9 -	  style = 'style="height:' .. args.height .. '"'
   17.10 -	end
   17.11 -	return '<textarea name="' .. name .. '" ' .. style .. '>' .. encode.html(convert.to_human(value, "string")) .. '</textarea>'
   17.12 -end
    19.1 --- a/framework/env/ui_deprecated/label.lua	Sat Mar 14 23:39:47 2015 +0100
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,5 +0,0 @@
    19.4 -function ui_deprecated.label(value)
    19.5 -  slot.put '<div class="ui_label">' 
    19.6 -  ui_deprecated.text( value )
    19.7 -  slot.put '</div>\n'
    19.8 -end
    19.9 \ No newline at end of file
    20.1 --- a/framework/env/ui_deprecated/link.lua	Sat Mar 14 23:39:47 2015 +0100
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,69 +0,0 @@
    20.4 -function ui_deprecated.link(args)
    20.5 -  if args.action then
    20.6 -    local params = {}
    20.7 -    if args.params then
    20.8 -      for key, value in pairs(args.params) do
    20.9 -        params[key] = value
   20.10 -      end
   20.11 -    end
   20.12 -    ui_deprecated._prepare_redirect_params(params, args.redirect_to)
   20.13 -
   20.14 -    local attr_action = args.url or encode.url{
   20.15 -      module = args.module or request.get_module(),
   20.16 -      action = args.action,
   20.17 -      id     = args.id,
   20.18 -      params = params
   20.19 -    }
   20.20 -    local attr_class = table.concat({ 'ui_link', args.class }, ' ')
   20.21 -    local attr_target = args.target or ''
   20.22 -    local redirect_to = args.redirect_to
   20.23 -    local unique_id = "unique_" .. multirand.string(32, "abcdefghijklmnopqrstuvwxyz0123456789")
   20.24 -    slot.put(
   20.25 -      '<form',
   20.26 -      ' id="', unique_id , '"',
   20.27 -      ' action="', attr_action,  '"',
   20.28 -      ' class="', attr_class, '"',
   20.29 -      ' target="', attr_target, '"',
   20.30 -      ' method="post"',
   20.31 -      '>\n',
   20.32 -      '<input type="submit" value="', args.label or '', '" />',
   20.33 -      '</form>',
   20.34 -      '<script>document.getElementById(\'', unique_id, '\').style.display=\'none\';document.write(\'<a href="#" class="', attr_class , '" onclick="document.getElementById(\\\'', unique_id, '\\\').submit();">'
   20.35 -    )
   20.36 -    if args.icon then
   20.37 -      ui_deprecated.image{ image = 'ui/icon/' .. args.icon }
   20.38 -    end
   20.39 -    if args.image then
   20.40 -      ui_deprecated.image{ image = args.image }
   20.41 -    end
   20.42 -    if args.label then
   20.43 -      slot.put(args.label)
   20.44 -    end
   20.45 -    slot.put("</a>');</script>")
   20.46 -  else
   20.47 -    local attr_class = table.concat({ 'ui_link', args.class }, ' ')
   20.48 -    slot.put(
   20.49 -      '<a href="',
   20.50 -      args.url or encode.url{
   20.51 -        module    = args.module or request.get_module(),
   20.52 -        view      = args.view,
   20.53 -        id        = args.id,
   20.54 -        params    = args.params,
   20.55 -      },
   20.56 -      '" ',
   20.57 -      ui_deprecated._stringify_table({ class = attr_class }),
   20.58 -      ui_deprecated._stringify_table( args.html_options or {} ),
   20.59 -      '>'
   20.60 -    )
   20.61 -    if args.icon then
   20.62 -      ui_deprecated.image{ image = 'ui/icon/' .. args.icon }
   20.63 -    end
   20.64 -    if args.image then
   20.65 -      ui_deprecated.image{ image = args.image }
   20.66 -    end
   20.67 -    if args.label then
   20.68 -      slot.put(args.label)
   20.69 -    end
   20.70 -    slot.put('</a>')
   20.71 -  end
   20.72 -end
    21.1 --- a/framework/env/ui_deprecated/list.lua	Sat Mar 14 23:39:47 2015 +0100
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,153 +0,0 @@
    21.4 ---
    21.5 --- Creates a list view of a collection
    21.6 ---
    21.7 --- Example:
    21.8 ---
    21.9 ---   ui_deprecated.list({ 
   21.10 ---     label = 'Point table',
   21.11 ---     collection = mycollection,
   21.12 ---     type = 'table' -- 'table', 'ulli'
   21.13 ---     cols = {
   21.14 ---       { 
   21.15 ---         label = _'Id',
   21.16 ---         field = 'id',
   21.17 ---         width = 100,
   21.18 ---         link = { module = 'mymodule', view = 'show' },
   21.19 ---              sort = true,
   21.20 ---       },
   21.21 ---       {
   21.22 ---         label = _'Name',
   21.23 ---         field = 'name',
   21.24 ---         width = 200,
   21.25 ---         link = { module = 'mymodule', view = 'show' },
   21.26 ---              sort = true,
   21.27 ---       },
   21.28 ---      {
   21.29 ---        label = _'Points',
   21.30 ---        func = function(record)
   21.31 ---          return record.points_a + record.points_b + record.points_c
   21.32 ---        end,
   21.33 ---        width = 300
   21.34 ---      }
   21.35 ---     }
   21.36 ---   })
   21.37 ---
   21.38 -
   21.39 -function ui_deprecated.list(args)
   21.40 -  local args = args
   21.41 -  args.type = args.type or 'table'
   21.42 -  if args.label then
   21.43 -    slot.put('<div class="ui_list_label">' .. encode.html(args.label) .. '</div>\n')
   21.44 -  end
   21.45 -  if not args or not args.collection or not args.cols then
   21.46 -    error('No args for ui_deprecated.list_end')
   21.47 -  end
   21.48 -  if args.type == 'table' then
   21.49 -    slot.put('<table class="ui_list">')
   21.50 -    slot.put('<tr class="ui_list_head">')
   21.51 -  elseif args.type == 'ulli' then
   21.52 -    slot.put('<ul class="ui_list">')
   21.53 -    slot.put('<li class="ui_list_head">')
   21.54 -  end
   21.55 -  if args.type == 'table' then
   21.56 -  elseif args.type == 'ulli' then
   21.57 -  end
   21.58 -  for j, col in ipairs(args.cols) do
   21.59 -    class_string = ''
   21.60 -    if col.align then
   21.61 -      class_string = ' class="' .. col.align .. '"'
   21.62 -    end
   21.63 -    if args.type == 'table' then
   21.64 -      slot.put('<th style="width: ' .. col.width .. ';"' .. class_string ..'>')
   21.65 -      slot.put(ui_deprecated.box({ name = 'ui_list_col_value', content = encode.html(col.label) }) )
   21.66 -      slot.put('</th>')
   21.67 -    elseif args.type == 'ulli' then
   21.68 -      slot.put('<div style="width: ' .. col.width .. ';"' .. class_string ..'>')
   21.69 -      slot.put(ui_deprecated.box({ name = 'ui_list_col_value', content = encode.html(col.label) }) )
   21.70 -      slot.put('</div>')
   21.71 -    end
   21.72 -  end
   21.73 -  if args.type == 'table' then
   21.74 -    slot.put('</tr>')
   21.75 -  elseif args.type == 'ulli' then
   21.76 -    slot.put('<br style="clear: left;" />')
   21.77 -    slot.put('</li>')
   21.78 -  end
   21.79 -  for i, obj in ipairs(args.collection) do
   21.80 -    if args.type == 'table' then
   21.81 -      slot.put('<tr>')
   21.82 -    elseif args.type == 'ulli' then
   21.83 -      slot.put('<li>')
   21.84 -    end
   21.85 -    for j, col in ipairs(args.cols) do
   21.86 -      class_string = ''
   21.87 -      if col.align then
   21.88 -        class_string = ' class="ui_list_col_align_' .. col.align .. '"'
   21.89 -      end
   21.90 -      if args.type == 'table' then
   21.91 -        slot.put('<td' .. class_string ..'>')
   21.92 -      elseif args.type == 'ulli' then
   21.93 -        slot.put('<div style="width: ' .. col.width .. ';"' .. class_string ..'>')
   21.94 -      end
   21.95 -      if col.link then
   21.96 -        local params = {}
   21.97 -        if col.link then
   21.98 -          params = col.link.params or {}
   21.99 -        end
  21.100 -        if col.link_values then
  21.101 -          for key, field in pairs(col.link_values) do
  21.102 -            params[key] = obj[field]
  21.103 -          end
  21.104 -        end
  21.105 -        local id
  21.106 -        if col.link_id_field then
  21.107 -          id = obj[col.link_id_field]
  21.108 -        end
  21.109 -        local value
  21.110 -        if col.value then
  21.111 -          value = col.value
  21.112 -        else
  21.113 -          value = obj[col.field]
  21.114 -        end
  21.115 -        ui_deprecated.link{
  21.116 -          label  = convert.to_human(value),
  21.117 -          module = col.link.module,
  21.118 -          view   = col.link.view,
  21.119 -          id     = id,
  21.120 -          params = params,
  21.121 -        }
  21.122 -      elseif col.link_func then
  21.123 -        local link = col.link_func(obj)
  21.124 -        if link then
  21.125 -	      ui_deprecated.link(link)
  21.126 -	    end
  21.127 -      else
  21.128 -        local text
  21.129 -        if col.func then
  21.130 -          text = col.func(obj)
  21.131 -        elseif col.value then
  21.132 -          text = convert.to_human(value)
  21.133 -        else
  21.134 -          text = convert.to_human(obj[col.field])
  21.135 -        end
  21.136 -        ui_deprecated.box{ name = 'ui_list_col_value', content = text }
  21.137 -      end
  21.138 -      if args.type == 'table' then
  21.139 -        slot.put('</td>')
  21.140 -      elseif args.type == 'ulli' then
  21.141 -        slot.put('</div>')
  21.142 -      end
  21.143 -    end
  21.144 -    if args.type == 'table' then
  21.145 -      slot.put('</tr>')
  21.146 -    elseif args.type == 'ulli' then
  21.147 -      slot.put('<br style="clear: left;" />')
  21.148 -      slot.put('</li>')
  21.149 -    end
  21.150 -  end
  21.151 -  if args.type == 'table' then
  21.152 -    slot.put('</table>')
  21.153 -  elseif args.type == 'ulli' then
  21.154 -    slot.put('</ul><div style="clear: left">&nbsp;</div>')
  21.155 -  end
  21.156 -end
  21.157 \ No newline at end of file
    22.1 --- a/framework/env/ui_deprecated/multiselect.lua	Sat Mar 14 23:39:47 2015 +0100
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,50 +0,0 @@
    22.4 -function ui_deprecated.multiselect(args)
    22.5 -  local record = assert(slot.get_state_table(), "ui_deprecated.multiselect was not called within a form.").form_record
    22.6 -  local name = args.name
    22.7 -  local relationship = args.relationship
    22.8 -
    22.9 -  local foreign_records = relationship.foreign_records
   22.10 -	
   22.11 -  local selector = relationship.connected_by_model:new_selector()
   22.12 -  selector:add_where{ relationship.connected_by_my_id .. ' = ?', record[relationship.my_id] }
   22.13 -  local connected_by_records = selector:exec()
   22.14 -	
   22.15 -  local connections = {}
   22.16 -  for i, connected_by_record in ipairs(connected_by_records) do
   22.17 -    connections[connected_by_record[relationship.connected_by_foreign_id]] = connected_by_record
   22.18 -  end
   22.19 -
   22.20 -  local html = {}
   22.21 -
   22.22 -  if args.type == "checkboxes" then
   22.23 -    for i, foreign_record in ipairs(foreign_records) do
   22.24 -      local selected = ''
   22.25 -      if connections[foreign_record[relationship.foreign_id]] then
   22.26 -        selected = ' checked="1"'
   22.27 -      end
   22.28 -      html[#html + 1] = '<input type="checkbox" name="' .. name .. '" value="' .. foreign_record[relationship.foreign_id] .. '"' .. selected .. '>&nbsp;' .. convert.to_human(foreign_record[relationship.foreign_name], "string") .. '<br />\n'
   22.29 -    end
   22.30 - 
   22.31 -  else
   22.32 -    html[#html + 1] = '<select name="' .. name .. '" multiple="1">'
   22.33 -    for i, foreign_record in ipairs(foreign_records) do
   22.34 -      local selected = ''
   22.35 -      if connections[foreign_record[relationship.foreign_id]] then
   22.36 -        selected = ' selected="1"'
   22.37 -      end
   22.38 -      html[#html + 1] = '<option value="' .. foreign_record[relationship.foreign_id] .. '"' .. selected .. '>' .. convert.to_human(foreign_record[relationship.foreign_name], "string") .. '</option>\n'
   22.39 -    end
   22.40 -    html[#html + 1] = '</select>'
   22.41 -
   22.42 -  end
   22.43 -  	
   22.44 -  slot.put('<div class="ui_field ui_multiselect">\n')
   22.45 -  if args.label then
   22.46 -    slot.put('<div class="label">', encode.html(args.label), '</div>\n')
   22.47 -  end
   22.48 -  slot.put('<div class="value">',
   22.49 -        table.concat(html),
   22.50 -      '</div>\n',
   22.51 -    '</div>\n'
   22.52 -  )
   22.53 -end
   22.54 \ No newline at end of file
    23.1 --- a/framework/env/ui_deprecated/select.lua	Sat Mar 14 23:39:47 2015 +0100
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,31 +0,0 @@
    23.4 -function ui_deprecated.select(args)
    23.5 -  local record = assert(slot.get_state_table(), "ui_deprecated.select was not called within a form.").form_record
    23.6 -  local value = param.get(args.field) or record[args.field]
    23.7 -  local html_options = args.html_options or {}
    23.8 -  html_options.name = args.field
    23.9 -  
   23.10 -  ui_deprecated.tag("div", { html_options = { class="ui_field ui_select" }, content = function()
   23.11 -    if args.label then
   23.12 -      ui_deprecated.tag("div", { html_options = { class="label" }, content = function()
   23.13 -        ui_deprecated.text(args.label)
   23.14 -      end })
   23.15 -    end
   23.16 -    ui_deprecated.tag("div", { html_options = { class="value" }, content = function()
   23.17 -      ui_deprecated.tag("select", { html_options = html_options, content = function()
   23.18 -        if args.include_option then
   23.19 -          ui_deprecated.tag("option", { html_options = { value = "" }, content = args.include_option })
   23.20 -        end
   23.21 -        for i, object in ipairs(args.foreign_records) do
   23.22 -          local selected = nil
   23.23 -          if tostring(object[args.foreign_id]) == tostring(value) then
   23.24 -            selected = "1"
   23.25 -          end
   23.26 -          ui_deprecated.tag("option", { html_options = { value = object[args.foreign_id], selected = selected }, content = object[args.foreign_name] })
   23.27 -        end
   23.28 -      end }) -- /select
   23.29 -    end }) -- /div
   23.30 -  end }) -- /div
   23.31 -end
   23.32 -
   23.33 -
   23.34 -
    24.1 --- a/framework/env/ui_deprecated/submit.lua	Sat Mar 14 23:39:47 2015 +0100
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,24 +0,0 @@
    24.4 ---
    24.5 --- Creates a submit buttom for a form
    24.6 ---
    24.7 --- label      (string) The label of the box
    24.8 ---
    24.9 --- Example:
   24.10 ---
   24.11 ---	ui_deprecated.submit({
   24.12 ---		label = 'Save'
   24.13 ---	})
   24.14 ---
   24.15 -
   24.16 -function ui_deprecated.submit(args)
   24.17 -  local args = args or {}
   24.18 -  args.label = args.label or 'Submit'
   24.19 -  slot.put(
   24.20 -    '<div class="ui_field ui_submit">',
   24.21 -      '<div class="label">&nbsp;</div>',
   24.22 -      '<div class="value">',
   24.23 -        '<input type="submit" value="', encode.html(args.label), '" />',
   24.24 -      '</div>',
   24.25 -    '</div>'
   24.26 -  )
   24.27 -end
    25.1 --- a/framework/env/ui_deprecated/tag.lua	Sat Mar 14 23:39:47 2015 +0100
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,20 +0,0 @@
    25.4 -function ui_deprecated.tag(name, args)
    25.5 -  
    25.6 -  local html_options = args.html_options or {}
    25.7 -   
    25.8 -  slot.put('<', name, ui_deprecated._stringify_table(html_options), '>')
    25.9 -
   25.10 -  if args.label then
   25.11 -    ui_deprecated.label(args.label)
   25.12 -  end
   25.13 -
   25.14 -  if type(args.content) == 'function' then
   25.15 -    args.content()
   25.16 -  else
   25.17 -    ui_deprecated.text(args.content)
   25.18 -  end
   25.19 -
   25.20 -  slot.put('</', name, '>')
   25.21 -
   25.22 -
   25.23 -end
   25.24 \ No newline at end of file
    26.1 --- a/framework/env/ui_deprecated/text.lua	Sat Mar 14 23:39:47 2015 +0100
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,4 +0,0 @@
    26.4 -
    26.5 -function ui_deprecated.text(value)
    26.6 -  slot.put(encode.html(convert.to_human(value)))
    26.7 -end
    26.8 \ No newline at end of file

Impressum / About Us