Inherit receivers when cloning

This commit is contained in:
Akinori MUSHA 2017-07-19 11:25:02 +09:00
parent 3ffe667f9e
commit ef82bfabb7
2 changed files with 2 additions and 2 deletions

View file

@ -294,7 +294,7 @@ class Agent < ActiveRecord::Base
class << self
def build_clone(original)
new(original.slice(:type, :options, :service_id, :schedule, :controller_ids, :control_target_ids,
:source_ids, :keep_events_for, :propagate_immediately, :scenario_ids)) { |clone|
:source_ids, :receiver_ids, :keep_events_for, :propagate_immediately, :scenario_ids)) { |clone|
# Give it a unique name
2.step do |i|
name = '%s (%d)' % [original.name, i]

View file

@ -106,7 +106,7 @@
<div class="event-related-region">
<% eventTargets = (current_user.agents - [@agent]).find_all { |a| a.can_receive_events? } %>
<%= f.select(:receiver_ids,
options_for_select(eventTargets.map {|s| [s.name, s.id] },
options_for_select(eventTargets.pluck(:name, :id),
@agent.receiver_ids),
{}, { :multiple => true, :size => 5, :class => 'select2-linked-tags form-control', data: {url_prefix: '/agents'} }) %>
<span class='cannot-create-events text-info'>This type of Agent cannot create events.</span>