avoid the mapping gets deleted problem
This commit is contained in:
parent
a6bb688d0c
commit
839ff66bcf
9 changed files with 29 additions and 25 deletions
|
@ -2,10 +2,11 @@
|
||||||
class Events::SynapseAddedToMap < Event
|
class Events::SynapseAddedToMap < Event
|
||||||
# after_create :notify_users!
|
# after_create :notify_users!
|
||||||
|
|
||||||
def self.publish!(mapping, user)
|
def self.publish!(synapse, map, user, meta)
|
||||||
create!(kind: 'synapse_added_to_map',
|
create!(kind: 'synapse_added_to_map',
|
||||||
eventable: mapping,
|
eventable: synapse,
|
||||||
map: mapping.map,
|
map: map,
|
||||||
user: user)
|
user: user,
|
||||||
|
meta: meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
class Events::SynapseRemovedFromMap < Event
|
class Events::SynapseRemovedFromMap < Event
|
||||||
# after_create :notify_users!
|
# after_create :notify_users!
|
||||||
|
|
||||||
def self.publish!(synapse, map, user)
|
def self.publish!(synapse, map, user, meta)
|
||||||
create!(kind: 'synapse_removed_from_map',
|
create!(kind: 'synapse_removed_from_map',
|
||||||
eventable: synapse,
|
eventable: synapse,
|
||||||
map: map,
|
map: map,
|
||||||
user: user)
|
user: user,
|
||||||
|
meta: meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
class Events::TopicAddedToMap < Event
|
class Events::TopicAddedToMap < Event
|
||||||
# after_create :notify_users!
|
# after_create :notify_users!
|
||||||
|
|
||||||
def self.publish!(mapping, user, meta)
|
def self.publish!(topic, map, user, meta)
|
||||||
create!(kind: 'topic_added_to_map',
|
create!(kind: 'topic_added_to_map',
|
||||||
eventable: mapping,
|
eventable: topic,
|
||||||
map: mapping.map,
|
map: map,
|
||||||
user: user,
|
user: user,
|
||||||
meta: meta)
|
meta: meta)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
class Events::TopicMovedOnMap < Event
|
class Events::TopicMovedOnMap < Event
|
||||||
# after_create :notify_users!
|
# after_create :notify_users!
|
||||||
|
|
||||||
def self.publish!(mapping, user, meta)
|
def self.publish!(topic, map, user, meta)
|
||||||
create!(kind: 'topic_moved_on_map',
|
create!(kind: 'topic_moved_on_map',
|
||||||
eventable: mapping,
|
eventable: topic,
|
||||||
map: mapping.map,
|
map: map,
|
||||||
user: user,
|
user: user,
|
||||||
meta: meta)
|
meta: meta)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
class Events::TopicRemovedFromMap < Event
|
class Events::TopicRemovedFromMap < Event
|
||||||
# after_create :notify_users!
|
# after_create :notify_users!
|
||||||
|
|
||||||
def self.publish!(topic, map, user)
|
def self.publish!(topic, map, user, meta)
|
||||||
create!(kind: 'topic_removed_from_map',
|
create!(kind: 'topic_removed_from_map',
|
||||||
eventable: topic,
|
eventable: topic,
|
||||||
map: map,
|
map: map,
|
||||||
user: user)
|
user: user,
|
||||||
|
meta: meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,17 +30,17 @@ class Mapping < ApplicationRecord
|
||||||
|
|
||||||
def after_created
|
def after_created
|
||||||
if mappable_type == 'Topic'
|
if mappable_type == 'Topic'
|
||||||
meta = {'x': xloc, 'y': yloc}
|
meta = {'x': xloc, 'y': yloc, 'mapping_id': id}
|
||||||
Events::TopicAddedToMap.publish!(self, user, meta)
|
Events::TopicAddedToMap.publish!(mappable, map, user, meta)
|
||||||
elsif mappable_type == 'Synapse'
|
elsif mappable_type == 'Synapse'
|
||||||
Events::SynapseAddedToMap.publish!(self, user)
|
Events::SynapseAddedToMap.publish!(mappable, map, user, meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_updated
|
def after_updated
|
||||||
if mappable_type == 'Topic' and (xloc_changed? or yloc_changed?)
|
if mappable_type == 'Topic' and (xloc_changed? or yloc_changed?)
|
||||||
meta = {'x': xloc, 'y': yloc}
|
meta = {'x': xloc, 'y': yloc, 'mapping_id': id}
|
||||||
Events::TopicMovedOnMap.publish!(self, user, meta)
|
Events::TopicMovedOnMap.publish!(mappable, map, user, meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,10 +51,11 @@ class Mapping < ApplicationRecord
|
||||||
mappable.save
|
mappable.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
meta = {'mapping_id': id}
|
||||||
if mappable_type == 'Topic'
|
if mappable_type == 'Topic'
|
||||||
Events::TopicRemovedFromMap.publish!(mappable, map, user)
|
Events::TopicRemovedFromMap.publish!(mappable, map, user, meta)
|
||||||
elsif mappable_type == 'Synapse'
|
elsif mappable_type == 'Synapse'
|
||||||
Events::SynapseRemovedFromMap.publish!(mappable, map, user)
|
Events::SynapseRemovedFromMap.publish!(mappable, map, user, meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
|
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
|
||||||
def text
|
def text
|
||||||
connector = eventable.mappable.desc.empty? ? '->' : eventable.mappable.desc
|
connector = eventable.desc.empty? ? '->' : eventable.desc
|
||||||
"\"*#{eventable.mappable.topic1.name}* #{connector} *#{eventable.mappable.topic2.name}*\" was added as a connection by *#{event.user.name}* to the map *#{view_map_on_metamaps}*"
|
"\"*#{eventable.topic1.name}* #{connector} *#{eventable.topic2.name}*\" was added as a connection by *#{event.user.name}* to the map *#{view_map_on_metamaps}*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
class Webhooks::Slack::TopicAddedToMap < Webhooks::Slack::Base
|
class Webhooks::Slack::TopicAddedToMap < Webhooks::Slack::Base
|
||||||
def text
|
def text
|
||||||
"*#{eventable.mappable.name}* was added by *#{event.user.name}* to the map *#{view_map_on_metamaps}*"
|
"*#{eventable.name}* was added by *#{event.user.name}* to the map *#{view_map_on_metamaps}*"
|
||||||
end
|
end
|
||||||
# TODO: it would be sweet if it sends it with the metacode as the icon_url
|
# TODO: it would be sweet if it sends it with the metacode as the icon_url
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
class Webhooks::Slack::TopicMovedOnMap < Webhooks::Slack::Base
|
class Webhooks::Slack::TopicMovedOnMap < Webhooks::Slack::Base
|
||||||
def text
|
def text
|
||||||
"*#{eventable.mappable.name}* was moved by *#{event.user.name}* on the map *#{view_map_on_metamaps}*"
|
"*#{eventable.name}* was moved by *#{event.user.name}* on the map *#{view_map_on_metamaps}*"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue