|
|
@@ -1,12 +1,13 @@ |
|
|
class Action::NodesController < ApplicationController |
|
|
class Action::NodesController < ApplicationController |
|
|
before_action :require_admin, except: [:index] |
|
|
|
|
|
|
|
|
# before_action :require_admin, except: [:index] |
|
|
|
|
|
before_action :require_login |
|
|
before_action :find_action_node, except: [:index, :create, :new] |
|
|
before_action :find_action_node, except: [:index, :create, :new] |
|
|
|
|
|
|
|
|
def index |
|
|
def index |
|
|
@node_types = Action::NodeType.all |
|
|
@node_types = Action::NodeType.all |
|
|
@no_type_nodes = Action::Node.where(action_node_types_id: nil) |
|
|
@no_type_nodes = Action::Node.where(action_node_types_id: nil) |
|
|
respond_to do |format| |
|
|
respond_to do |format| |
|
|
format.html { @nodes = Action::Node.all } |
|
|
|
|
|
|
|
|
format.html { @nodes = Action::Node.where("name LIKE :search OR full_name LIKE :search", :search => "%#{params[:search]}%") } |
|
|
format.json |
|
|
format.json |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
@@ -16,6 +17,7 @@ class Action::NodesController < ApplicationController |
|
|
if params.require(:node).present? && params.require(:node)[:link_type_array].present? |
|
|
if params.require(:node).present? && params.require(:node)[:link_type_array].present? |
|
|
@node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") |
|
|
@node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") |
|
|
end |
|
|
end |
|
|
|
|
|
@node.user_id = current_user.id |
|
|
respond_to do |format| |
|
|
respond_to do |format| |
|
|
if @node.save |
|
|
if @node.save |
|
|
format.html { redirect_to action_nodes_path, notice: '创建成功.' } |
|
|
format.html { redirect_to action_nodes_path, notice: '创建成功.' } |
|
|
@@ -45,6 +47,7 @@ class Action::NodesController < ApplicationController |
|
|
if params.require(:node).present? && params.require(:node)[:link_type_array].present? |
|
|
if params.require(:node).present? && params.require(:node)[:link_type_array].present? |
|
|
@node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") |
|
|
@node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") |
|
|
end |
|
|
end |
|
|
|
|
|
@node.user_id = current_user.id if @node.user_id.blank? |
|
|
@node.update(node_params) |
|
|
@node.update(node_params) |
|
|
respond_to do |format| |
|
|
respond_to do |format| |
|
|
format.html { redirect_to action_nodes_path, notice: '更新成功.' } |
|
|
format.html { redirect_to action_nodes_path, notice: '更新成功.' } |
|
|
|