liquid_feedback_frontend

changeset 1493:6b4deab5160a

Updated search result page
author bsw
date Mon Aug 26 15:55:48 2019 +0200 (2019-08-26)
parents faaf9ec3e09c
children 3e9b0f1adec3
files app/main/index/search.lua app/main/issue/_list.lua
line diff
     1.1 --- a/app/main/index/search.lua	Mon Aug 26 15:49:37 2019 +0200
     1.2 +++ b/app/main/index/search.lua	Mon Aug 26 15:55:48 2019 +0200
     1.3 @@ -7,98 +7,70 @@
     1.4    ui.title ( _"Search" )
     1.5  end
     1.6  
     1.7 -ui.form{
     1.8 -  method = "get", module = "index", view = "search",
     1.9 -  routing = { default = { mode = "redirect",
    1.10 -    module = "index", view = "search", search_for = search_for, q = search_string
    1.11 -  } },
    1.12 -  attr = { class = "vertical section" },
    1.13 -  content = function()
    1.14 -  
    1.15 -    ui.sectionHead( function()
    1.16 -      ui.heading { level = 1, content = _"Search" }
    1.17 +ui.grid{ content = function()
    1.18 +  ui.cell_main{ content = function()
    1.19 +
    1.20 +    if not search_string then
    1.21 +      return
    1.22 +    end
    1.23 +
    1.24 +    local issues_selector = Issue:get_search_selector(search_string)
    1.25 +    local count = issues_selector:count()
    1.26 +    local text
    1.27 +    if count == 0 then
    1.28 +      text = _"No matching issues found"
    1.29 +    elseif count == 1 then
    1.30 +      text = _"1 matching issue found"
    1.31 +    else
    1.32 +      text = _"#{count} matching issues found"
    1.33 +    end
    1.34 +        
    1.35 +    ui.section( function()
    1.36 +      ui.sectionHead( function()
    1.37 +        ui.heading { level = 1, content = _(text, { count = count }) }
    1.38 +      end )
    1.39 +      if count > 0 then
    1.40 +        execute.view{
    1.41 +          module = "issue",
    1.42 +          view = "_list",
    1.43 +          params = {
    1.44 +            search = search_string,
    1.45 +            no_filter = true
    1.46 +          },
    1.47 +        }
    1.48 +      end
    1.49      end)
    1.50 -  
    1.51 -    ui.sectionRow( function()
    1.52 -      ui.tag { content =  _"Search term (only complete words)" }
    1.53 -      ui.tag {
    1.54 -        tag = "input",
    1.55 -        attr = { 
    1.56 -          name = "q",
    1.57 -          value = search_string
    1.58 -        }
    1.59 -      }
    1.60 -      ui.tag{ 
    1.61 -        tag = "input",
    1.62 -        attr = { 
    1.63 -          class = "btn btn-search",
    1.64 -          type = "submit",
    1.65 -          value = _"search"
    1.66 -        }
    1.67 -      }
    1.68 -    end )
    1.69 -  end
    1.70 -}
    1.71 +
    1.72 +    slot.put("<br />")
    1.73  
    1.74 -
    1.75 -if not search_string then
    1.76 -  return
    1.77 -end
    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 = {
    1.98 +              members_selector = members_selector,
    1.99 +              no_filter = true
   1.100 +            },
   1.101 +          }
   1.102 +        end
   1.103 +      end )
   1.104 +    end
   1.105  
   1.106  
   1.107 -local members_selector = Member:get_search_selector(search_string)
   1.108 -local count = members_selector:count()
   1.109 -local text
   1.110 -if count == 0 then
   1.111 -  text = _"No matching members found"
   1.112 -elseif count == 1 then
   1.113 -  text = _"1 matching member found"
   1.114 -else
   1.115 -  text = _"#{count} matching members found"
   1.116 -end
   1.117 -if app.session:has_access("everything") then
   1.118 -  ui.section( function()
   1.119 -    ui.sectionHead( function()
   1.120 -      ui.heading { level = 1, content = _(text, { count = count }) }
   1.121 -    end )
   1.122 -    if count > 0 then
   1.123 -      execute.view{
   1.124 -        module = "member",
   1.125 -        view = "_list",
   1.126 -        params = {
   1.127 -          members_selector = members_selector,
   1.128 -          no_filter = true
   1.129 -        },
   1.130 -      }
   1.131 -    end
   1.132 -  end )
   1.133 -end
   1.134 -
   1.135 -slot.put("<br />")
   1.136 -
   1.137 -local issues_selector = Issue:get_search_selector(search_string)
   1.138 -local count = issues_selector:count()
   1.139 -local text
   1.140 -if count == 0 then
   1.141 -  text = _"No matching issues found"
   1.142 -elseif count == 1 then
   1.143 -  text = _"1 matching issue found"
   1.144 -else
   1.145 -  text = _"#{count} matching issues found"
   1.146 -end
   1.147 -    
   1.148 -ui.section( function()
   1.149 -  ui.sectionHead( function()
   1.150 -    ui.heading { level = 1, content = _(text, { count = count }) }
   1.151 -  end )
   1.152 -  if count > 0 then
   1.153 -    execute.view{
   1.154 -      module = "issue",
   1.155 -      view = "_list",
   1.156 -      params = {
   1.157 -        search = search_string,
   1.158 -        no_filter = true
   1.159 -      },
   1.160 -    }
   1.161 -  end
   1.162 -end)
   1.163 +  end }
   1.164 +end }
     2.1 --- a/app/main/issue/_list.lua	Mon Aug 26 15:49:37 2019 +0200
     2.2 +++ b/app/main/issue/_list.lua	Mon Aug 26 15:55:48 2019 +0200
     2.3 @@ -395,7 +395,9 @@
     2.4        selector:add_order_by ( "CASE WHEN issue.accepted ISNULL THEN " .. admission_order_field .. " ELSE NULL END" )
     2.5        selector:add_order_by ( "id" )
     2.6      end
     2.7 -    execute.view{ module = "index", view = "_head" }
     2.8 +    if not search then
     2.9 +      execute.view{ module = "index", view = "_head" }
    2.10 +    end
    2.11      ui.paginate{
    2.12        selector = selector,
    2.13        per_page = 25,

Impressum / About Us