liquid_feedback_frontend

diff app/main/index/search.lua @ 1045:701a5cf6b067

Imported LiquidFeedback Frontend 3.0 branch
author bsw
date Thu Jul 10 01:19:48 2014 +0200 (2014-07-10)
parents 3e8b50739577
children 32cc544d5a5b
line diff
     1.1 --- a/app/main/index/search.lua	Thu Jul 10 01:02:43 2014 +0200
     1.2 +++ b/app/main/index/search.lua	Thu Jul 10 01:19:48 2014 +0200
     1.3 @@ -1,65 +1,104 @@
     1.4  local search_for = param.get("search_for", atom.string) or "global"
     1.5 -local search_string = param.get("search", atom.string)
     1.6 +local search_string = param.get("q", atom.string)
     1.7  
     1.8  if search_string then
     1.9 -  slot.put_into("title", encode.html(_("Search results for: '#{search}'", { search  = search_string })))
    1.10 +  ui.title ( _("Search results for: '#{search}'", { search  = search_string } ) )
    1.11  else
    1.12 -  slot.put_into("title", encode.html(_"Search"))
    1.13 +  ui.title ( _"Search" )
    1.14  end
    1.15  
    1.16  ui.form{
    1.17    method = "get", module = "index", view = "search",
    1.18    routing = { default = { mode = "redirect",
    1.19 -    module = "index", view = "search", search_for = search_for, search = search_string
    1.20 +    module = "index", view = "search", search_for = search_for, q = search_string
    1.21    } },
    1.22 -  attr = { class = "vertical" },
    1.23 +  attr = { class = "vertical section" },
    1.24    content = function()
    1.25 -    
    1.26 -    if app.session:has_access("everything") then
    1.27 -      ui.field.select{
    1.28 -        label = _"Search context",
    1.29 -        name = "search_for",
    1.30 -        value = search_for,
    1.31 -        foreign_records = {
    1.32 -          { id = "global", name = _"Global search" },
    1.33 -          { id = "member", name = _"Search for members" },
    1.34 -          { id = "issue", name = _"Search for issues" }
    1.35 -        },
    1.36 -        foreign_id = "id",
    1.37 -        foreign_name = "name",
    1.38 +  
    1.39 +    ui.sectionHead( function()
    1.40 +      ui.heading { level = 1, content = _"Search" }
    1.41 +    end)
    1.42 +  
    1.43 +    ui.sectionRow( function()
    1.44 +      ui.tag { content =  _"Search term (only complete words)" }
    1.45 +      ui.tag {
    1.46 +        tag = "input",
    1.47 +        attr = { 
    1.48 +          name = "q",
    1.49 +          value = search_string
    1.50 +        }
    1.51        }
    1.52 -    end
    1.53 -    ui.field.text{ label = _"Search term (only complete words)", name = "search", value = search_string }
    1.54 -    ui.submit{ value = _"Start search" }
    1.55 +      ui.tag{ 
    1.56 +        tag = "input",
    1.57 +        attr = { 
    1.58 +          class = "btn btn-search",
    1.59 +          type = "submit",
    1.60 +          value = _"search"
    1.61 +        }
    1.62 +      }
    1.63 +    end )
    1.64    end
    1.65  }
    1.66  
    1.67 -slot.put("<br />")
    1.68  
    1.69 -if search_string then
    1.70 +if not search_string then
    1.71 +  return
    1.72 +end
    1.73 +
    1.74  
    1.75 -  if app.session:has_access("everything") then
    1.76 -    if search_for == "global" or search_for == "member" then
    1.77 -      local members_selector = Member:get_search_selector(search_string)
    1.78 +local members_selector = Member:get_search_selector(search_string)
    1.79 +local count = members_selector:count()
    1.80 +local text
    1.81 +if count == 0 then
    1.82 +  text = _"No matching members found"
    1.83 +elseif count == 1 then
    1.84 +  text = _"1 matching member found"
    1.85 +else
    1.86 +  text = _"#{count} matching members found"
    1.87 +end
    1.88 +if app.session:has_access("everything") then
    1.89 +  ui.section( function()
    1.90 +    ui.sectionHead( function()
    1.91 +      ui.heading { level = 1, content = _(text, { count = count }) }
    1.92 +    end )
    1.93 +    if count > 0 then
    1.94        execute.view{
    1.95          module = "member",
    1.96          view = "_list",
    1.97 -        params = { members_selector = members_selector },
    1.98 +        params = {
    1.99 +          members_selector = members_selector,
   1.100 +          no_filter = true
   1.101 +        },
   1.102        }
   1.103      end
   1.104 -  end
   1.105 +  end )
   1.106 +end
   1.107 +
   1.108 +slot.put("<br />")
   1.109 +
   1.110 +local issues_selector = Issue:get_search_selector(search_string)
   1.111 +local count = issues_selector:count()
   1.112 +local text
   1.113 +if count == 0 then
   1.114 +  text = _"No matching issues found"
   1.115 +elseif count == 1 then
   1.116 +  text = _"1 matching issue found"
   1.117 +else
   1.118 +  text = _"#{count} matching issues found"
   1.119 +end
   1.120      
   1.121 -  if search_for == "global" or search_for == "issue" then
   1.122 -    local issues_selector = Issue:get_search_selector(search_string)
   1.123 +ui.section( function()
   1.124 +  ui.sectionHead( function()
   1.125 +    ui.heading { level = 1, content = _(text, { count = count }) }
   1.126 +  end )
   1.127 +  if count > 0 then
   1.128      execute.view{
   1.129        module = "issue",
   1.130 -      view = "_list",
   1.131 +      view = "_list2",
   1.132        params = {
   1.133 -        issues_selector = issues_selector,
   1.134 -        highlight_string = search_string,
   1.135 +        search = search_string,
   1.136          no_filter = true
   1.137        },
   1.138      }
   1.139    end
   1.140 -  
   1.141 -end
   1.142 +end)

Impressum / About Us