Class: Binda::BoardsController

Inherits:
ApplicationController show all
Includes:
FieldableHelpers
Defined in:
app/controllers/binda/boards_controller.rb

Instance Method Summary collapse

Methods included from FieldableHelpers

#bytes_to_megabytes, #fieldable_params, #nested_fieldable_params, #return_audio_details, #return_image_details, #return_svg_details, #return_video_details, #upload_details, #upload_params

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #set_locale

Instance Method Details

#dashboardObject



41
42
43
44
45
46
# File 'app/controllers/binda/boards_controller.rb', line 41

def dashboard
  @structure = Structure.friendly.find('dashboard')
  @board = Board.friendly.find('dashboard')
  @instance = @board
  render action: :edit
end

#destroyObject



25
26
27
28
# File 'app/controllers/binda/boards_controller.rb', line 25

def destroy
  @board.destroy
  redirect_to root_url, notice: 'Setting was successfully destroyed.'
end

#editObject



14
15
# File 'app/controllers/binda/boards_controller.rb', line 14

def edit
end

#new_repeaterObject



30
31
32
33
34
# File 'app/controllers/binda/boards_controller.rb', line 30

def new_repeater
  @repeater_setting = FieldSetting.find(params[:repeater_setting_id])
  @repeater = @instance.repeaters.create(field_setting: @repeater_setting)
  render 'binda/fieldable/_form_item_new_repeater', layout: false
end

#showObject



10
11
12
# File 'app/controllers/binda/boards_controller.rb', line 10

def show
  redirect_to action: :edit
end

#sort_repeatersObject



36
37
38
39
# File 'app/controllers/binda/boards_controller.rb', line 36

def sort_repeaters
  sort_repeaters_by(params["form--list-item"])
  render json: { id: "##{params[:id]}" }, status: 200
end

#updateObject



17
18
19
20
21
22
23
# File 'app/controllers/binda/boards_controller.rb', line 17

def update
  if @board.update(board_params)
    redirect_to structure_board_path(@structure.slug, @board.slug), notice: 'Setting was successfully updated.'
  else
    render :edit, flash: { alert: @board.errors }
  end
end

#uploadObject



48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/binda/boards_controller.rb', line 48

def upload
  if @board.update(upload_params(:board))
    respond_to do |format|
      format.json { render json: upload_details }
    end
  else
    logger.debug("The upload process has failed. #{ @board.errors }")
    head :bad_request 
  end
end