Skip to content

Commit

Permalink
Replace archiving button with radio buttons and show current room sta…
Browse files Browse the repository at this point in the history
…te to unprivileged users
  • Loading branch information
matthias-brun committed Jan 22, 2016
1 parent d802a5d commit 79a3745
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 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,13 @@ 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'
Meteor.call 'archiveRoom', @data?.rid, (err, results) ->
return toastr.error err.reason if err
toastr.success TAPi18n.__ 'Room_archived'
else
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 @@ -44,16 +44,19 @@ <h2>{{_ "Room_Info"}}</h2>
</li>
{{/if}}
{{#if notDirect}}
{{#if canEdit}}
<li>
<label>{{_ "Archive_Unarchive"}}</label>
{{#if archived}}
<button class="button unarchive"><span>{{_ "Unarchive"}}</span></button>
<li>
<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}}
<button class="button archive"><span>{{_ "Archive"}}</span></button>
<span>{{archivationStateDescription}}{{#if canEdit}} <i class="octicon octicon-pencil" data-edit="archivationState"></i>{{/if}}</span>
{{/if}}
</li>
{{/if}}
</div>
</li>
{{/if}}
{{#each channelSettings}}
{{> Template.dynamic template=template data=data}}
Expand Down

0 comments on commit 79a3745

Please sign in to comment.