File: redhopper_issues_controller.rb

package info (click to toggle)
redmine-plugin-redhopper 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 300 kB
  • sloc: ruby: 709; javascript: 76; makefile: 2
file content (67 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
# Redhopper - Kanban boards for Redmine, inspired by Jira Agile (formerly known as
# Greenhopper), but following its own path.
# Copyright (C) 2015-2019 infoPiiaf <contact@infopiiaf.fr>
#
# This file is part of Redhopper.
#
# Redhopper is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Redhopper is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Redhopper.  If not, see <http://www.gnu.org/licenses/>.
#
class RedhopperIssuesController < ApplicationController
  def create
    redhopper_issue = RedhopperIssue.create(issue: Issue.find(params[:issue_id]))

    redirect_to project_kanbans_path(redhopper_issue.issue.project)
  end

  def move
    issue_to_move = RedhopperIssue.find(params[:id])
    target_issue = RedhopperIssue.find(params[:target_id])

    new_position = target_issue.position
    if params[:insert] == "after" && target_issue.position < issue_to_move.position
      new_position += 1
    end
    issue_to_move.insert_at new_position

    redirect_to project_kanbans_path(issue_to_move.issue.project)
  end

  def block
    issue_to_block = RedhopperIssue.find(params[:id])
    issue_to_block.blocked = true

    issue_to_block.save

    redirect_to project_kanbans_path(issue_to_block.issue.project)
  end

  def unblock
    issue_to_unblock = RedhopperIssue.find(params[:id])
    issue_to_unblock.blocked = false

    issue_to_unblock.save

    redirect_to project_kanbans_path(issue_to_unblock.issue.project)
  end

  def delete
    issue_to_delete = RedhopperIssue.find(params[:id])
    project = issue_to_delete.issue.project

    issue_to_delete.destroy

    redirect_to project_kanbans_path(project)
  end
end