issues_controller.diff

zhiguo Zhu, 2014-05-19 10:25

Download (2.17 KB)

View differences:

app/controllers/issues_controller.rb
54 54

  
55 55
  def index
56 56
    retrieve_query
57
    @prev = params[:prev]
58
    @next = params[:next]
59
    @pos  = params[:pos]
60
    @count = params[:count]
61

  
57 62
    sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
58 63
    sort_update(@query.sortable_columns)
59 64
    @query.sort_criteria = sort_criteria.to_a
......
104 109
  end
105 110

  
106 111
  def show
112
    @prev = params[:prev]
113
    @next = params[:next]
114
    @pos  = params[:pos]
115
    @count = params[:count]
116

  
107 117
    @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
108 118
    @journals.each_with_index {|j,i| j.indice = i+1}
109 119
    @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
......
182 192

  
183 193
  def update
184 194
    return unless update_issue_from_params
195
    retrieve_previous_and_next_issue_ids
185 196
    @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
186 197
    saved = false
187 198
    begin
......
199 210
      flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
200 211

  
201 212
      respond_to do |format|
202
        format.html { redirect_back_or_default issue_path(@issue) }
213
        format.html { redirect_back_or_default issue_path(@issue) + "?next=#@next_issue_id&prev=#@prev_issue_id&pos=#@issue_position&count=#@issue_count" }
203 214
        format.api  { render_api_ok }
204 215
      end
205 216
    else
......
365 376
        end
366 377
        @prev_issue_id = issue_ids[idx - 1] if idx > 0
367 378
        @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
379
      else
380
        @prev_issue_id  = @prev
381
        @next_issue_id  = @next
382
        @issue_position = @pos
383
        @issue_count    = @count
368 384
      end
369 385
    end
370 386
  end