Class: PushType::Admin::NodesController

Inherits:
PushType::AdminController show all
Defined in:
app/controllers/push_type/admin/nodes_controller.rb

Instance Method Summary collapse

Methods inherited from PushType::AdminController

#info

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 20

def create
  if @node.save
    flash[:notice] = "#{ @node.type } successfully created."
    redirect_to redirect_path
  else
    render 'new'
  end
end

#destroyObject



41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 41

def destroy
  if @node.trashed?
    @node.destroy
    flash[:notice] = "#{ @node.type } permanently deleted."
    redirect_to redirect_path
  else
    @node.trash!
    flash[:notice] = "#{ @node.type } trashed."
    redirect_to redirect_path(true)
  end
end

#editObject



29
30
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 29

def edit
end

#emptyObject



67
68
69
70
71
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 67

def empty
  PushType::Node.trashed.destroy_all
  flash[:notice] = 'Trash successfully emptied.'
  redirect_to push_type_admin.nodes_path
end

#indexObject



9
10
11
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 9

def index
  @nodes = node_scope.not_trash.page(params[:page]).per(per_page_param)
end

#newObject



17
18
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 17

def new
end

#positionObject



53
54
55
56
57
58
59
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 53

def position
  if reorder_node
    head :ok
  else
    render json: @node.errors, status: :unprocessable_entity
  end
end

#restoreObject



61
62
63
64
65
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 61

def restore
  @node.restore!
  flash[:notice] = "#{ @node.type } successfully restored."
  redirect_to redirect_path
end

#trashObject



13
14
15
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 13

def trash
  @nodes = PushType::Node.all.trashed.page(params[:page]).per(per_page_param).reorder(deleted_at: :desc)
end

#updateObject



32
33
34
35
36
37
38
39
# File 'app/controllers/push_type/admin/nodes_controller.rb', line 32

def update
  if @node.update_attributes node_params.merge(updater: push_type_user)
    flash[:notice] = "#{ @node.type } successfully updated."
    redirect_to redirect_path
  else
    render 'edit'
  end
end