diff --git a/app/controllers/action/nodes_controller.rb b/app/controllers/action/nodes_controller.rb index f8219ca8d..c995513da 100644 --- a/app/controllers/action/nodes_controller.rb +++ b/app/controllers/action/nodes_controller.rb @@ -1,12 +1,13 @@ 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] def index @node_types = Action::NodeType.all @no_type_nodes = Action::Node.where(action_node_types_id: nil) 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 end end @@ -16,6 +17,7 @@ class Action::NodesController < ApplicationController if params.require(:node).present? && params.require(:node)[:link_type_array].present? @node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") end + @node.user_id = current_user.id respond_to do |format| if @node.save 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? @node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") end + @node.user_id = current_user.id if @node.user_id.blank? @node.update(node_params) respond_to do |format| format.html { redirect_to action_nodes_path, notice: '更新成功.' } diff --git a/app/views/action/nodes/index.html.erb b/app/views/action/nodes/index.html.erb index ce603590b..60ad9489a 100644 --- a/app/views/action/nodes/index.html.erb +++ b/app/views/action/nodes/index.html.erb @@ -5,6 +5,15 @@

>>前往模板配置

说明:该界面适用于action 节点配置参数配置

+
+ <%= form_tag(action_nodes_path, method: :get, class: 'form-inline search-form flex-1') do %> + <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '关键字检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + + <% end %> + <%= link_to "新增", new_action_node_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %> +
+