Skip to content

Commit

Permalink
Merge pull request #2008 from matthias-brun/improve-archiving-function
Browse files Browse the repository at this point in the history
Improve archiving function
  • Loading branch information
engelgabriel committed Jan 27, 2016
2 parents 4481b51 + a059b05 commit 22ed7d6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ Template.channelSettings.helpers
return ChatRoom.findOne(@rid)?.name
roomTopic: ->
return ChatRoom.findOne(@rid)?.topic
archived: ->
archivationState: ->
return ChatRoom.findOne(@rid)?.archived
archivationStateDescription: ->
archivationState = ChatRoom.findOne(@rid)?.archived
if archivationState is true
return t('Room_archivation_state_true')
else
return t('Room_archivation_state_false')

Template.channelSettings.events
'keydown input[type=text]': (e, t) ->
Expand All @@ -41,20 +47,6 @@ Template.channelSettings.events
e.preventDefault()
t.saveSetting()

'click .archive': (e, t) ->
e.preventDefault()

Meteor.call 'archiveRoom', t.data.rid, true, (err, results) ->
return toastr.error err.reason if err
toastr.success TAPi18n.__ 'Room_archived'

'click .unarchive': (e, t) ->
e.preventDefault()

Meteor.call 'unarchiveRoom', t.data.rid, true, (err, results) ->
return toastr.error err.reason if err
toastr.success TAPi18n.__ 'Room_unarchived'

Template.channelSettings.onCreated ->
@editing = new ReactiveVar

Expand Down Expand Up @@ -106,4 +98,15 @@ Template.channelSettings.onCreated ->
return toastr.error TAPi18n.__(err.reason, err.details.roomType)
return toastr.error TAPi18n.__(err.reason)
toastr.success TAPi18n.__ 'Room_type_changed_successfully'
when 'archivationState'
if @$('input[name=archivationState]:checked').val() is 'true'
if ChatRoom.findOne(@data.rid)?.archived isnt true
Meteor.call 'archiveRoom', @data?.rid, (err, results) ->
return toastr.error err.reason if err
toastr.success TAPi18n.__ 'Room_archived'
else
if ChatRoom.findOne(@data.rid)?.archived is true
Meteor.call 'unarchiveRoom', @data?.rid, (err, results) ->
return toastr.error err.reason if err
toastr.success TAPi18n.__ 'Room_unarchived'
@editing.set()
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ <h2>{{_ "Room_Info"}}</h2>
{{/if}}
{{#if notDirect}}
<li>
<label>{{_ "Archive_Unarchive"}}</label>
{{#if archived}}
<button class="button unarchive"><span>{{_ "Unarchive"}}</span></button>
{{else}}
<button class="button archive"><span>{{_ "Archive"}}</span></button>
{{/if}}
<label>{{_ "Room_archivation_state"}}</label>
<div>
{{#if editing 'archivationState'}}
<label><input type="radio" name="archivationState" class="editing" value="true" checked="{{$eq archivationState true}}" /> {{_ "Room_archivation_state_true"}}</label>
<label><input type="radio" name="archivationState" value="false" checked="{{$neq archivationState true}}" /> {{_ "Room_archivation_state_false"}}</label>
<button type="button" class="button secondary cancel">{{_ "Cancel"}}</button>
<button type="button" class="button primary save">{{_ "Save"}}</button>
{{else}}
<span>{{archivationStateDescription}}{{#if canEdit}} <i class="octicon octicon-pencil" data-edit="archivationState"></i>{{/if}}</span>
{{/if}}
</div>
</li>
{{/if}}
{{#each channelSettings}}
Expand Down
5 changes: 4 additions & 1 deletion packages/rocketchat-channel-settings/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
"Save" : "Save",
"Topic" : "Topic",
"Type" : "Type",
"Room_archivation_state" : "State",
"Room_archivation_state_false" : "Active",
"Room_archivation_state_true" : "Archived",
"Room_Info" : "Room Info",
"room_changed_privacy" : "Room type changed to: <em>__room_type__</em> by <em>__user_by__</em>",
"room_changed_topic" : "Room topic changed to: <em>__room_topic__</em> by <em>__user_by__</em>",
"Room_topic_changed_successfully" : "Room topic changed successfully",
"Room_type_changed_successfully" : "Room type changed successfully"
}
}

0 comments on commit 22ed7d6

Please sign in to comment.