liquid_feedback_frontend

changeset 134:de6b80867eb7

make user names clickable

simplify pseudonym code by having one place to generate ui.field.text
author Daniel Poelzleithner <poelzi@poelzi.org>
date Tue Oct 05 20:56:41 2010 +0200 (2010-10-05)
parents fa55c8ded9fd
children 02e24b4dd21c
files app/main/draft/_list.lua app/main/draft/_show.lua app/main/opinion/_list.lua app/main/suggestion/_opinions.lua app/main/suggestion/_suggestion.lua model/member.lua
line diff
     1.1 --- a/app/main/draft/_list.lua	Tue Oct 05 16:18:39 2010 +0200
     1.2 +++ b/app/main/draft/_list.lua	Tue Oct 05 20:56:41 2010 +0200
     1.3 @@ -15,10 +15,8 @@
     1.4          {
     1.5            label = _"Author",
     1.6            content = function(record)
     1.7 -            if app.session.member_id or config.public_access == "pseudonym" then
     1.8 -              ui.field.text{ readonly = true, value = record.author.name }
     1.9 -            else
    1.10 -              ui.field.text{ readonly = true, value = _"[not displayed public]" }
    1.11 +            if record.author then
    1.12 +              return record.author:ui_field_text()
    1.13              end
    1.14            end
    1.15          },
     2.1 --- a/app/main/draft/_show.lua	Tue Oct 05 16:18:39 2010 +0200
     2.2 +++ b/app/main/draft/_show.lua	Tue Oct 05 20:56:41 2010 +0200
     2.3 @@ -7,15 +7,30 @@
     2.4    content = function()
     2.5  
     2.6      if app.session.member_id or config.public_access == "pseudonym" then
     2.7 -      ui.field.text{
     2.8 -        label = _"Last author",
     2.9 -        value = _(
    2.10 -          "#{author} at #{date}", {
    2.11 -            author = draft.author_name,
    2.12 -            date = format.timestamp(draft.created)
    2.13 -          }
    2.14 -        )
    2.15 -      }
    2.16 +      if draft.author then
    2.17 +        -- ugly workaround for getting html into a replaced string und to the user
    2.18 +        ui.container{label = _"Last author", label_attr={class="ui_field_label"}, content = function()
    2.19 +            local str = _("#{author} at #{date}",
    2.20 +                            {author = string.format('<a href="%s">%s</a>',
    2.21 +                                                    encode.url{
    2.22 +                                                      module    = "member",
    2.23 +                                                      view      = "show",
    2.24 +                                                      id        = draft.author.id,
    2.25 +                                                    },
    2.26 +                                                    encode.html(draft.author.name)),
    2.27 +                             date = encode.html(format.timestamp(draft.created))
    2.28 +                            }
    2.29 +                        )
    2.30 +            slot.put("<span>", str, "</span>")
    2.31 +          end
    2.32 +        }
    2.33 +      else
    2.34 +        text = _("#{author} at #{date}", {
    2.35 +          author = encode.html(draft.author_name),
    2.36 +          date = format.timestamp(draft.created)
    2.37 +        })
    2.38 +        ui.field.text{label = _"Last author", value = text }
    2.39 +      end
    2.40      else
    2.41        ui.field.text{
    2.42          label = _"Last author",
     3.1 --- a/app/main/opinion/_list.lua	Tue Oct 05 16:18:39 2010 +0200
     3.2 +++ b/app/main/opinion/_list.lua	Tue Oct 05 20:56:41 2010 +0200
     3.3 @@ -5,7 +5,7 @@
     3.4    columns = {
     3.5      {
     3.6        label = _"Member name",
     3.7 -      name = "member_name"
     3.8 +      content = function(arg) return Member.object.ui_field_text(arg.member) end
     3.9      },
    3.10      {
    3.11        label = _"Degree",
     4.1 --- a/app/main/suggestion/_opinions.lua	Tue Oct 05 16:18:39 2010 +0200
     4.2 +++ b/app/main/suggestion/_opinions.lua	Tue Oct 05 20:56:41 2010 +0200
     4.3 @@ -5,7 +5,6 @@
     4.4    view = "_list",
     4.5    params = { 
     4.6      opinions_selector = Opinion:new_selector()
     4.7 -      :add_field("member.name", "member_name")
     4.8        :add_where{ "suggestion_id = ?", suggestion.id }
     4.9        :join("member", nil, "member.id = opinion.member_id")
    4.10        :add_order_by("member.id DESC")
     5.1 --- a/app/main/suggestion/_suggestion.lua	Tue Oct 05 16:18:39 2010 +0200
     5.2 +++ b/app/main/suggestion/_suggestion.lua	Tue Oct 05 20:56:41 2010 +0200
     5.3 @@ -5,10 +5,8 @@
     5.4    record = suggestion,
     5.5    readonly = true,
     5.6    content = function()
     5.7 -    if app.session.member_id or config.public_access == "pseudonym" then
     5.8 -      ui.field.text{ label = _"Author",      value = suggestion.author.name }
     5.9 -    else
    5.10 -      ui.field.text{ label = _"Author",      value = _"[not displayed public]" }
    5.11 +    if suggestion.author then 
    5.12 +      suggestion.author:ui_field_text{label=_"Author"} 
    5.13      end
    5.14      ui.field.text{ label = _"Title",        name = "name" }
    5.15      ui.container{
     6.1 --- a/model/member.lua	Tue Oct 05 16:18:39 2010 +0200
     6.2 +++ b/model/member.lua	Tue Oct 05 20:56:41 2010 +0200
     6.3 @@ -367,4 +367,23 @@
     6.4        :add_where("notify_email_lock_expiry > now()")
     6.5        :count() == 1
     6.6    )
     6.7 -end
     6.8 \ No newline at end of file
     6.9 +end
    6.10 +
    6.11 +function Member.object:ui_field_text(args)
    6.12 +  args = args or {}
    6.13 +  if app.session.member_id or config.public_access == "pseudonym" then
    6.14 +    -- ugly workaround for getting html into a replaced string and to the user
    6.15 +    ui.container{label = args.label, label_attr={class="ui_field_label"}, content = function()
    6.16 +        slot.put(string.format('<span><a href="%s">%s</a></span>',
    6.17 +                                                encode.url{
    6.18 +                                                  module    = "member",
    6.19 +                                                  view      = "show",
    6.20 +                                                  id        = self.id,
    6.21 +                                                },
    6.22 +                                                encode.html(self.name)))
    6.23 +      end
    6.24 +    }
    6.25 +  else
    6.26 +    ui.field.text{ label = args.label,      value = _"[not displayed public]" }
    6.27 +  end
    6.28 +end

Impressum / About Us