liquid_feedback_frontend

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

Imported LiquidFeedback Frontend 3.0 branch
author bsw
date Thu Jul 10 01:19:48 2014 +0200 (2014-07-10)
parents cf0b64e101d9
children 904f6807f7fa
line diff
     1.1 --- a/app/main/index/index.lua	Thu Jul 10 01:02:43 2014 +0200
     1.2 +++ b/app/main/index/index.lua	Thu Jul 10 01:19:48 2014 +0200
     1.3 @@ -1,132 +1,114 @@
     1.4 -if app.session.member_id then
     1.5 -  util.help("index.index", _"Home")
     1.6 +function getIssuesSelector()
     1.7 +  return Issue:new_selector()
     1.8 +    :add_order_by([[
     1.9 +      coalesce(
    1.10 +        issue.fully_frozen + issue.voting_time, 
    1.11 +        issue.half_frozen + issue.verification_time, 
    1.12 +        issue.accepted + issue.discussion_time, 
    1.13 +        issue.created + issue.admission_time
    1.14 +      ) - now()
    1.15 +    ]])
    1.16 +end
    1.17  
    1.18 -  execute.view{
    1.19 -    module = "index", view = "_index_member"
    1.20 -  }
    1.21 +--[[
    1.22 +ui.title( function ()
    1.23 +  ui.link { attr = { class = "home" }, module = "index", view = "index", text = _"Home" }
    1.24 +end)
    1.25 +--]]
    1.26 +
    1.27 +ui.title()
    1.28  
    1.29 -elseif app.session:has_access("anonymous") then
    1.30 -  if config.motd_public then
    1.31 -    local help_text = config.motd_public
    1.32 -    ui.container{
    1.33 -      attr = { class = "wiki motd" },
    1.34 -      content = function()
    1.35 -        slot.put(format.wiki_text(help_text))
    1.36 -      end
    1.37 -    }
    1.38 -  end
    1.39 +if false then
    1.40 +slot.select ( "tabs", function ()
    1.41    
    1.42 -  local open_issues_selector = Issue:new_selector()
    1.43 -    :add_where("issue.closed ISNULL")
    1.44 -    :add_order_by("coalesce(issue.fully_frozen + issue.voting_time, issue.half_frozen + issue.verification_time, issue.accepted + issue.discussion_time, issue.created + issue.admission_time) - now()")
    1.45 -
    1.46 -  local closed_issues_selector = Issue:new_selector()
    1.47 -    :add_where("issue.closed NOTNULL")
    1.48 -    :add_order_by("issue.closed DESC")
    1.49 -
    1.50 +  ui.tag {
    1.51 +    attr = { onclick = "showTab(0);" },
    1.52 +    content = "units",
    1.53 +  }
    1.54 +  slot.put ( " " )
    1.55 +  ui.tag {
    1.56 +    attr = { onclick = "showTab(1);" },
    1.57 +    content = "timeline"
    1.58 +  }
    1.59 +  slot.put ( " " )
    1.60 +  ui.tag {
    1.61 +    attr = { onclick = "showTab(2);" },
    1.62 +    content = "what"
    1.63 +  }
    1.64 +  slot.put ( " " )
    1.65 +  ui.tag {
    1.66 +    attr = { onclick = "showTab(3);" },
    1.67 +    content = "members"
    1.68 +  }
    1.69    
    1.70 -  local tabs = {
    1.71 -    module = "index",
    1.72 -    view = "index"
    1.73 -  }
    1.74 -
    1.75 -  tabs[#tabs+1] = {
    1.76 -    name = "units",
    1.77 -    label = _"Units",
    1.78 -    module = "unit",
    1.79 -    view = "_list"
    1.80 -  }
    1.81 +end )
    1.82  
    1.83 -  tabs[#tabs+1] = {
    1.84 -    name = "timeline",
    1.85 -    label = _"Latest events",
    1.86 -    module = "event",
    1.87 -    view = "_list",
    1.88 -    params = { global = true }
    1.89 -  }
    1.90 +ui.script { script = [[
    1.91 +  
    1.92 +  var tabs = ["tab1", "main", "tab2", "tab3"]
    1.93 +  var currentId;
    1.94 +  
    1.95 +  function showTab(id) {
    1.96 +    var tabId = tabs[id];
    1.97 +    $('.tab').hide();
    1.98 +    $('.main').hide();
    1.99 +    $('.' + tabId).show();
   1.100 +    currentId = id;
   1.101 +  };
   1.102 +  
   1.103 +  showTab(0);
   1.104 +  
   1.105 +  $(function(){
   1.106 +    // Bind the swipeHandler callback function to the swipe event on div.box
   1.107 +    $( "body" ).on( "swiperight", function swipeHandler( event ) {
   1.108 +      newId = currentId - 1;
   1.109 +      if (newId < 0) return;
   1.110 +      showTab(newId);
   1.111 +    } )
   1.112 +    $( "body" ).on( "swipeleft", function swipeHandler( event ) {
   1.113 +      newId = currentId + 1;
   1.114 +      if (newId > tabs.length - 1) return;
   1.115 +      showTab(newId);
   1.116 +    } )
   1.117 +  });
   1.118 +  
   1.119 +]]}
   1.120 +end
   1.121  
   1.122 -  tabs[#tabs+1] = {
   1.123 -    name = "open",
   1.124 -    label = _"Open issues",
   1.125 -    module = "issue",
   1.126 -    view = "_list",
   1.127 -    params = {
   1.128 -      for_state = "open",
   1.129 -      issues_selector = open_issues_selector
   1.130 +
   1.131 +if app.session.member then
   1.132 +  execute.view{ module = "index", view = "_sidebar_motd_intern" }
   1.133 +else
   1.134 +  execute.view{ module = "index", view = "_sidebar_motd_public" }
   1.135 +end
   1.136 +
   1.137 +if app.session:has_access("anonymous") then
   1.138 +  -- show the units the member has voting privileges for
   1.139 +  execute.view {
   1.140 +    module = "index", view = "_sidebar_units", params = {
   1.141 +      member = app.session.member
   1.142      }
   1.143    }
   1.144 -  tabs[#tabs+1] = {
   1.145 -    name = "closed",
   1.146 -    label = _"Closed issues",
   1.147 -    module = "issue",
   1.148 -    view = "_list",
   1.149 -    params = {
   1.150 -      for_state = "closed",
   1.151 -      issues_selector = closed_issues_selector
   1.152 -    }
   1.153 -  }
   1.154 -
   1.155 -  if app.session:has_access('all_pseudonymous') then
   1.156 -    tabs[#tabs+1] = {
   1.157 -      name = "members",
   1.158 -      label = _"Members",
   1.159 -      module = 'member',
   1.160 -      view   = '_list',
   1.161 -      params = { members_selector = Member:new_selector():add_where("active") }
   1.162 -    }
   1.163 -  end
   1.164 -
   1.165 -  ui.tabs(tabs)
   1.166 -  
   1.167 -else
   1.168 -
   1.169 -  if config.motd_public then
   1.170 -    local help_text = config.motd_public
   1.171 -    ui.container{
   1.172 -      attr = { class = "wiki motd" },
   1.173 -      content = function()
   1.174 -        slot.put(format.wiki_text(help_text))
   1.175 -      end
   1.176 -    }
   1.177 -  end
   1.178 -
   1.179 -  ui.tag{ tag = "p", content = _"Closed user group, please login to participate." }
   1.180 +end
   1.181  
   1.182 -  ui.form{
   1.183 -  attr = { class = "login" },
   1.184 -  module = 'index',
   1.185 -  action = 'login',
   1.186 -  routing = {
   1.187 -    ok = {
   1.188 -      mode   = 'redirect',
   1.189 -      module = param.get("redirect_module") or "index",
   1.190 -      view = param.get("redirect_view") or "index",
   1.191 -      id = param.get("redirect_id"),
   1.192 -    },
   1.193 -    error = {
   1.194 -      mode   = 'forward',
   1.195 -      module = 'index',
   1.196 -      view   = 'login',
   1.197 -    }
   1.198 -  },
   1.199 -  content = function()
   1.200 -    ui.field.text{
   1.201 -      attr = { id = "username_field" },
   1.202 -      label     = _'login name',
   1.203 -      html_name = 'login',
   1.204 -      value     = ''
   1.205 -    }
   1.206 -    ui.script{ script = 'document.getElementById("username_field").focus();' }
   1.207 -    ui.field.password{
   1.208 -      label     = _'Password',
   1.209 -      html_name = 'password',
   1.210 -      value     = ''
   1.211 -    }
   1.212 -    ui.submit{
   1.213 -      text = _'Login'
   1.214 -    }
   1.215 -  end
   1.216 -}
   1.217 +-- show the user what can be done
   1.218 +execute.view { module = "index", view = "_sidebar_whatcanido" }
   1.219  
   1.220 +-- show active members
   1.221 +if app.session:has_access("all_pseudonymous") then
   1.222 +  execute.view{ module = "index", view = "_sidebar_members" }
   1.223  end
   1.224  
   1.225 +if app.session:has_access("anonymous") then
   1.226 +  
   1.227 +  if not app.session.member then
   1.228 +--    execute.view {
   1.229 +--      module = "slideshow", view = "_index"
   1.230 +--    }
   1.231 +  end
   1.232 +  
   1.233 +  execute.view {
   1.234 +    module = "issue", view = "_list2", params = { }
   1.235 +  }
   1.236 +  
   1.237 +end -- if app.session:has_access "anonymous"
   1.238 \ No newline at end of file

Impressum / About Us