Module: MultipleBoardsActions

Extended by:
ActiveSupport::Concern
Includes:
Gitlab::Utils::StrongMemoize
Included in:
Projects::BoardsController
Defined in:
app/controllers/concerns/multiple_boards_actions.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#createObject


23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/concerns/multiple_boards_actions.rb', line 23

def create
  board = Boards::CreateService.new(parent, current_user, board_params).execute

  respond_to do |format|
    format.json do
      if board.persisted?
        extra_json = { board_path: board_path(board) }
        render json: serialize_as_json(board).merge(extra_json)
      else
        render json: board.errors, status: :unprocessable_entity
      end
    end
  end
end

#destroyObject


53
54
55
56
57
58
59
60
61
# File 'app/controllers/concerns/multiple_boards_actions.rb', line 53

def destroy
  service = Boards::DestroyService.new(parent, current_user)
  service.execute(board)

  respond_to do |format|
    format.json { head :ok }
    format.html { redirect_to boards_path, status: :found }
  end
end

#recentObject


16
17
18
19
20
21
# File 'app/controllers/concerns/multiple_boards_actions.rb', line 16

def recent
  recent_visits = ::Boards::VisitsFinder.new(parent, current_user).latest(4)
  recent_boards = recent_visits.map(&:board)

  render json: serialize_as_json(recent_boards)
end

#updateObject


38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/concerns/multiple_boards_actions.rb', line 38

def update
  service = Boards::UpdateService.new(parent, current_user, board_params)

  respond_to do |format|
    format.json do
      if service.execute(board)
        extra_json = { board_path: board_path(board) }
        render json: serialize_as_json(board).merge(extra_json)
      else
        render json: board.errors, status: :unprocessable_entity
      end
    end
  end
end