diff --git a/app/controllers/action/nodes_controller.rb b/app/controllers/action/nodes_controller.rb index ebccf8efe..2664ff95a 100644 --- a/app/controllers/action/nodes_controller.rb +++ b/app/controllers/action/nodes_controller.rb @@ -13,6 +13,9 @@ class Action::NodesController < ApplicationController def create @node = Action::Node.new(node_params) + if params.require(:node).present? && params.require(:node)[:link_type_array].present? + @node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") + end respond_to do |format| if @node.save format.html { redirect_to action_nodes_path, notice: '创建成功.' } @@ -33,10 +36,15 @@ class Action::NodesController < ApplicationController end def edit - + if @node.link_type.present? + @node.link_type_array = @node.link_type.to_s.split(",") + end end def update + if params.require(:node).present? && params.require(:node)[:link_type_array].present? + @node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",") + end @node.update(node_params) respond_to do |format| format.html { redirect_to action_nodes_path, notice: '更新成功.' } @@ -62,10 +70,10 @@ class Action::NodesController < ApplicationController def node_params if params.require(:action_node) params.require(:action_node).permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, - :is_local, :local_url, :yaml, :sort_no, :type, :is_mutil_link, :link_type) + :is_local, :local_url, :yaml, :sort_no, :node_type, :is_mutil_link, :link_type, :link_type_array) else params.permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, - :yaml, :sort_no, :type, :is_mutil_link, :link_type) + :yaml, :sort_no, :node_type, :is_mutil_link, :link_type, :link_type_array) end end end diff --git a/app/controllers/api/v1/projects/pipelines_controller.rb b/app/controllers/api/v1/projects/pipelines_controller.rb index 68f15d152..532b33d7e 100644 --- a/app/controllers/api/v1/projects/pipelines_controller.rb +++ b/app/controllers/api/v1/projects/pipelines_controller.rb @@ -101,6 +101,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController job_nodes.each do |job| node = Action::Node.find_by(name: job["data"]["name"]) node.label = job["data"]["label"] if job["data"]["label"].present? + node.node_id = job["data"]["id"] if job["data"]["id"].present? next if node.blank? next_edge_nodes = JSON.parse(demo2.to_json)["edges"].select { |edge| edge["source"]["cell"].include?(job["id"]) } node_ids = next_edge_nodes.map { |t| t["target"]["cell"] } @@ -150,6 +151,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController node = Action::Node.find_by(name: input_node["data"]["name"]) next if node.blank? node.label = input_node["data"]["label"] if input_node["data"]["label"].present? + node.node_id = input_node["data"]["id"] if input_node["data"]["id"].present? run_values = {} input_values = {} if input_node["data"]["inputs"].present? @@ -182,6 +184,7 @@ class Api::V1::Projects::PipelinesController < Api::V1::BaseController node = Action::Node.find_by(name: input_node["data"]["name"]) return nil if node.blank? node.label = input_node["data"]["label"] if input_node["data"]["label"].present? + node.node_id = input_node["data"]["id"] if input_node["data"]["id"].present? run_values = {} input_values = {} if input_node["data"]["inputs"].present? diff --git a/app/models/action/node.rb b/app/models/action/node.rb index 8d2620d06..b92837b7b 100644 --- a/app/models/action/node.rb +++ b/app/models/action/node.rb @@ -38,7 +38,7 @@ class Action::Node < ApplicationRecord belongs_to :user, optional: true - attr_accessor :cust_name, :run_values, :input_values, :sub_nodes + attr_accessor :cust_name, :run_values, :input_values, :sub_nodes, :link_type_array, :node_id validates :name, presence: { message: "不能为空" } validates :full_name, length: { maximum: 200, too_long: "不能超过200个字符" } diff --git a/app/views/action/nodes/_form.html.erb b/app/views/action/nodes/_form.html.erb index 0ecee56ed..7b21bb20f 100644 --- a/app/views/action/nodes/_form.html.erb +++ b/app/views/action/nodes/_form.html.erb @@ -11,7 +11,7 @@ <%# end %>