Class: Binda::BoardsController
Instance Method Summary
collapse
#bytes_to_megabytes, #fieldable_params, #return_image_details, #return_video_details, #upload_details, #upload_params
#after_sign_in_path_for, #after_sign_out_path_for
Instance Method Details
#dashboard ⇒ Object
44
45
46
47
48
49
|
# File 'app/controllers/binda/boards_controller.rb', line 44
def dashboard
@structure = Structure.friendly.find('dashboard')
@board = Board.friendly.find('dashboard')
@instance = @board
render action: :edit
end
|
#destroy ⇒ Object
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
|
#edit ⇒ Object
14
15
|
# File 'app/controllers/binda/boards_controller.rb', line 14
def edit
end
|
#new_repeater ⇒ Object
30
31
32
33
34
35
|
# File 'app/controllers/binda/boards_controller.rb', line 30
def new_repeater
@repeater_setting = FieldSetting.find( params[:repeater_setting_id] )
position = @instance.repeaters.find_all{|r| r.field_setting_id = @repeater_setting.id }.length + 1
@repeater = @instance.repeaters.create( field_setting: @repeater_setting, position: position )
render 'binda/fieldable/_form_item_new_repeater', layout: false
end
|
#show ⇒ Object
10
11
12
|
# File 'app/controllers/binda/boards_controller.rb', line 10
def show
redirect_to action: :edit
end
|
#sort_repeaters ⇒ Object
37
38
39
40
41
42
|
# File 'app/controllers/binda/boards_controller.rb', line 37
def sort_repeaters
params[:repeater].each_with_index do |id, i|
Repeater.find( id ).update({ position: i + 1 })
end
head :ok
end
|
#update ⇒ Object
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
|
#upload ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/binda/boards_controller.rb', line 51
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
|