Skip to content
Snippets Groups Projects
Commit 6fdca886 authored by Gabriel Engel's avatar Gabriel Engel
Browse files

Merge pull request #1421 from RocketChat/packaged-interface

fixed cog editing bug
parents 525207cf 3dcdcc6f
No related branches found
Tags 6.0.0-rc.7
No related merge requests found
RocketChat.MessageAction = new class
buttons = new ReactiveVar {}
###
config expects the following keys (only id is mandatory):
id (mandatory)
......@@ -9,7 +9,7 @@ RocketChat.MessageAction = new class
action: function(event, instance)
validation: function(message)
order: integer
###
###
addButton = (config) ->
unless config?.id
throw new Meteor.Error "MessageAction-addButton-error", "Button id was not informed."
......@@ -29,18 +29,18 @@ RocketChat.MessageAction = new class
Tracker.nonreactive ->
btns = buttons.get()
if btns[id]
btns[id] = _.extend btns[id], config
btns[id] = _.extend btns[id], config
buttons.set btns
getButtons = (message) ->
allButtons = _.toArray buttons.get()
if message
allowedButtons = _.compact _.map allButtons, (button) ->
allowedButtons = _.compact _.map allButtons, (button) ->
if not button.validation? or button.validation(message)
return button
else
allowedButtons = allButtons
return _.sortBy allowedButtons, 'order'
resetButtons = ->
......@@ -59,7 +59,7 @@ Meteor.startup ->
i18nLabel: 'Edit'
action: (event, instance) ->
message = $(event.currentTarget).closest('.message')[0]
instance.chatMessages.edit(message)
chatMessages[Session.get('openedRoom')].edit(message)
$("\##{message.id} .message-dropdown").hide()
input = instance.find('.input-message')
Meteor.setTimeout ->
......@@ -108,7 +108,7 @@ Meteor.startup ->
timer: 1000
showConfirmButton: false
instance.chatMessages.deleteMsg(message)
chatMessages[Session.get('openedRoom')].deleteMsg(message)
validation: (message) ->
return RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid ) or RocketChat.settings.get('Message_AllowDeleting') and message.u?._id is Meteor.userId()
order: 2
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment