Skip to content

Commit

Permalink
copied implementations from admin room info (#3773)
Browse files Browse the repository at this point in the history
  • Loading branch information
peccu authored and rodrigok committed Aug 3, 2016
1 parent af355e8 commit c7f3b95
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,37 @@ Template.channelSettings.helpers
return t('Room_archivation_state_true')
else
return t('Room_archivation_state_false')
canDeleteRoom: ->
roomType = ChatRoom.findOne(@rid, { fields: { t: 1 }})?.t
return roomType? and RocketChat.authz.hasAtLeastOnePermission("delete-#{roomType}", @rid)

Template.channelSettings.events
'click .delete': ->
swal {
title: t('Are_you_sure')
text: t('Delete_Room_Warning')
type: 'warning'
showCancelButton: true
confirmButtonColor: '#DD6B55'
confirmButtonText: t('Yes_delete_it')
cancelButtonText: t('Cancel')
closeOnConfirm: false
html: false
}, =>
swal.disableButtons()

Meteor.call 'eraseRoom', @rid, (error, result) ->
if error
handleError(error)
swal.enableButtons()
else
swal
title: t('Deleted')
text: t('Room_has_been_deleted')
type: 'success'
timer: 2000
showConfirmButton: false

'keydown input[type=text]': (e, t) ->
if e.keyCode is 13
e.preventDefault()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ <h2>{{_ "Room_Info"}}</h2>
{{/each}}
</ul>
</form>
{{#if canDeleteRoom}}
<nav>
<button class='button delete red'><span><i class='icon-trash'></i> {{_ "Delete"}}</span></button>
</nav>
{{/if}}
</div>
</div>
</template>

0 comments on commit c7f3b95

Please sign in to comment.