liquid_feedback_frontend

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

Imported LiquidFeedback Frontend 3.0 branch
author bsw
date Thu Jul 10 01:19:48 2014 +0200 (2014-07-10)
parents 3b74187efaa3
children b79085a2f92e
line diff
     1.1 --- a/app/main/draft/diff.lua	Thu Jul 10 01:02:43 2014 +0200
     1.2 +++ b/app/main/draft/diff.lua	Thu Jul 10 01:19:48 2014 +0200
     1.3 @@ -1,13 +1,20 @@
     1.4  local old_draft_id = param.get("old_draft_id", atom.integer)
     1.5  local new_draft_id = param.get("new_draft_id", atom.integer)
     1.6 +local initiative_id = param.get("initiative_id", atom.number)
     1.7  
     1.8 -if not old_draft_id or not new_draft_id then
     1.9 -  slot.put( _"Please choose two versions of the draft to compare")
    1.10 -  return
    1.11 -end
    1.12 -
    1.13 -if old_draft_id == new_draft_id then
    1.14 -  slot.put( _"Please choose two different versions of the draft to compare")
    1.15 +if not old_draft_id 
    1.16 +  or not new_draft_id 
    1.17 +  or old_draft_id == new_draft_id
    1.18 +then
    1.19 +  slot.reset_all()
    1.20 +  slot.select("error", function()
    1.21 +    ui.tag{ content = _"Please choose two different versions of the draft to compare" }
    1.22 +  end )
    1.23 +  request.redirect{
    1.24 +    module = "draft", view = "list", params = {
    1.25 +      initiative_id = initiative_id
    1.26 +    }
    1.27 +  }
    1.28    return
    1.29  end
    1.30  
    1.31 @@ -20,40 +27,46 @@
    1.32  local old_draft = Draft:by_id(old_draft_id)
    1.33  local new_draft = Draft:by_id(new_draft_id)
    1.34  
    1.35 -execute.view{
    1.36 -  module = "draft",
    1.37 -  view = "_head",
    1.38 -  params = { draft = new_draft}
    1.39 +local initiative = new_draft.initiative
    1.40 +
    1.41 +if app.session.member then
    1.42 +  initiative:load_everything_for_member_id(app.session.member_id)
    1.43 +  initiative.issue:load_everything_for_member_id(app.session.member_id)
    1.44 +end
    1.45 +
    1.46 +
    1.47 +execute.view{ module = "issue", view = "_sidebar_state", params = {
    1.48 +  initiative = initiative
    1.49 +} }
    1.50 +
    1.51 +execute.view { 
    1.52 +  module = "issue", view = "_sidebar_issue", 
    1.53 +  params = {
    1.54 +    issue = initiative.issue,
    1.55 +    highlight_initiative_id = initiative.id
    1.56 +  }
    1.57  }
    1.58  
    1.59 -ui.title(_"Diff")
    1.60 +execute.view {
    1.61 +  module = "issue", view = "_sidebar_whatcanido",
    1.62 +  params = { initiative = initiative }
    1.63 +}
    1.64  
    1.65 -if app.session.member_id and not new_draft.initiative.revoked then
    1.66 -  local supporter = Supporter:new_selector():add_where{"member_id = ?", app.session.member_id}:count()
    1.67 -  if supporter then
    1.68 -    ui.container{
    1.69 -      attr = { class = "draft_updated_info" },
    1.70 -      content = function()
    1.71 -        slot.put(_"The draft of this initiative has been updated!")
    1.72 -        slot.put(" ")
    1.73 -        ui.link{
    1.74 -          text   = _"Refresh support to current draft",
    1.75 -          module = "initiative",
    1.76 -          action = "add_support",
    1.77 -          id     = new_draft.initiative.id,
    1.78 -          routing = {
    1.79 -            default = {
    1.80 -              mode = "redirect",
    1.81 -              module = "initiative",
    1.82 -              view = "show",
    1.83 -              id = new_draft.initiative.id
    1.84 -            }
    1.85 -          }
    1.86 -        }
    1.87 -      end
    1.88 -    }
    1.89 -  end
    1.90 -end
    1.91 +execute.view { 
    1.92 +  module = "issue", view = "_sidebar_members", params = {
    1.93 +    issue = initiative.issue, initiative = initiative
    1.94 +  }
    1.95 +}
    1.96 +
    1.97 +
    1.98 +
    1.99 +execute.view {
   1.100 +  module = "issue", view = "_head", params = {
   1.101 +    issue = initiative.issue
   1.102 +  }
   1.103 +}
   1.104 +
   1.105 +
   1.106  
   1.107  local old_draft_content = string.gsub(string.gsub(old_draft.content, "\n", " ###ENTER###\n"), " ", "\n")
   1.108  local new_draft_content = string.gsub(string.gsub(new_draft.content, "\n", " ###ENTER###\n"), " ", "\n")
   1.109 @@ -111,17 +124,87 @@
   1.110    end
   1.111  end
   1.112  
   1.113 -if not status then
   1.114 -  ui.field.text{ value = _"The drafts do not differ" }
   1.115 -else
   1.116 -  ui.container{
   1.117 -    tag = "div",
   1.118 -    attr = { class = "diff" },
   1.119 -    content = function()
   1.120 -      output = output:gsub("[^\n\r]+", function(line)
   1.121 -        process_line(line)
   1.122 -      end)
   1.123 +ui.section( function()
   1.124 +  ui.sectionHead( function()
   1.125 +    ui.link{
   1.126 +      module = "initiative", view = "show", id = initiative.id,
   1.127 +      content = function ()
   1.128 +        ui.heading { 
   1.129 +          level = 1,
   1.130 +          content = initiative.display_name
   1.131 +        }
   1.132 +      end
   1.133 +    }
   1.134 +    ui.heading{ level = 2, content = _("Comparision of revisions #{id1} and #{id2}", {
   1.135 +      id1 = old_draft.id,
   1.136 +      id2 = new_draft.id 
   1.137 +    } ) }
   1.138 +  end )
   1.139 +
   1.140 +  if app.session.member_id and not new_draft.initiative.revoked then
   1.141 +    local supporter = app.session.member:get_reference_selector("supporters")
   1.142 +      :add_where{ "initiative_id = ?", new_draft.initiative_id }
   1.143 +      :optional_object_mode()
   1.144 +      :exec()
   1.145 +    if supporter and supporter.draft_id ~= new_draft.id then
   1.146 +      ui.sectionRow("draft_updated_info", function()
   1.147 +        ui.container{ 
   1.148 +          attr = { class = "info" },
   1.149 +          content = _"The draft of this initiative has been updated!"
   1.150 +        }
   1.151 +        slot.put(" ")
   1.152 +        ui.link{
   1.153 +          text   = _"refresh my support",
   1.154 +          module = "initiative",
   1.155 +          action = "add_support",
   1.156 +          id     = new_draft.initiative.id,
   1.157 +          params = { draft_id = new_draft.id },
   1.158 +          routing = {
   1.159 +            default = {
   1.160 +              mode = "redirect",
   1.161 +              module = "initiative",
   1.162 +              view = "show",
   1.163 +              id = new_draft.initiative.id
   1.164 +            }
   1.165 +          }
   1.166 +        }
   1.167 +
   1.168 +        slot.put(" · ")
   1.169 +         
   1.170 +        ui.link{
   1.171 +          text   = _"remove my support",
   1.172 +          module = "initiative",
   1.173 +          action = "remove_support",
   1.174 +          id     = new_draft.initiative.id,
   1.175 +          routing = {
   1.176 +            default = {
   1.177 +              mode = "redirect",
   1.178 +              module = "initiative",
   1.179 +              view = "show",
   1.180 +              id = new_draft.initiative.id
   1.181 +            }
   1.182 +          }
   1.183 +        }        
   1.184 +        
   1.185 +      end )
   1.186      end
   1.187 -  }
   1.188 -end 
   1.189 +  end
   1.190 +
   1.191 +  ui.sectionRow( function()
   1.192  
   1.193 +    if not status then
   1.194 +      ui.field.text{ value = _"The drafts do not differ" }
   1.195 +    else
   1.196 +      ui.container{
   1.197 +        tag = "div",
   1.198 +        attr = { class = "diff" },
   1.199 +        content = function()
   1.200 +          output = output:gsub("[^\n\r]+", function(line)
   1.201 +            process_line(line)
   1.202 +          end)
   1.203 +        end
   1.204 +      }
   1.205 +    end 
   1.206 +
   1.207 +  end )
   1.208 +end )
   1.209 \ No newline at end of file

Impressum / About Us