Skip to content
Snippets Groups Projects
Commit 79a3745d authored by Matthias Brun's avatar Matthias Brun
Browse files

Replace archiving button with radio buttons and show current room state to unprivileged users

parent d802a5d4
No related branches found
No related tags found
No related merge requests found
......@@ -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) ->
......@@ -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
......@@ -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()
......@@ -44,16 +44,19 @@
</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}}
......
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