Setup edit groups functionality
This commit is contained in:
Родитель
ae6a734df7
Коммит
1174105402
|
@ -63,16 +63,21 @@ class SettingsController extends Controller{
|
|||
'admin',
|
||||
[
|
||||
'wopi_url' => $this->appConfig->getAppValue('wopi_url'),
|
||||
'edit_groups' => $this->appConfig->getAppValue('edit_groups')
|
||||
],
|
||||
'blank'
|
||||
);
|
||||
}
|
||||
|
||||
public function setSettings($wopi_url){
|
||||
public function setSettings($wopi_url, $edit_groups){
|
||||
if (!is_null($wopi_url)){
|
||||
$this->appConfig->setAppValue('wopi_url', $wopi_url);
|
||||
}
|
||||
|
||||
if (!is_null($edit_groups)){
|
||||
$this->appConfig->setAppValue('edit_groups', $edit_groups);
|
||||
}
|
||||
|
||||
$richMemCache = \OC::$server->getMemCacheFactory()->create('richdocuments');
|
||||
$richMemCache->clear('discovery.xml');
|
||||
|
||||
|
|
91
js/admin.js
91
js/admin.js
|
@ -1,27 +1,80 @@
|
|||
/*global OC, $ */
|
||||
|
||||
$(document).ready(function(){
|
||||
var documentsSettings = {
|
||||
save : function() {
|
||||
$('#wopi_apply').attr('disabled', true);
|
||||
var data = {
|
||||
wopi_url : $('#wopi_url').val()
|
||||
};
|
||||
|
||||
var documentsSettings = {
|
||||
save : function() {
|
||||
$('#wopi_apply').attr('disabled', true);
|
||||
var data = {
|
||||
wopi_url : $('#wopi_url').val()
|
||||
};
|
||||
OC.msg.startAction('#documents-admin-msg', t('richdocuments', 'Saving...'));
|
||||
$.post(
|
||||
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||
data,
|
||||
documentsSettings.afterSave
|
||||
);
|
||||
},
|
||||
|
||||
OC.msg.startAction('#documents-admin-msg', t('richdocuments', 'Saving...'));
|
||||
$.post(
|
||||
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||
data,
|
||||
documentsSettings.afterSave
|
||||
);
|
||||
},
|
||||
saveGroups: function(groups) {
|
||||
var data = {
|
||||
'edit_groups': groups.join('|')
|
||||
};
|
||||
|
||||
afterSave : function(response){
|
||||
$('#wopi_apply').attr('disabled', false);
|
||||
OC.msg.finishedAction('#documents-admin-msg', response);
|
||||
console.log('posting to setSettings');
|
||||
$.post(
|
||||
OC.filePath('richdocuments', 'ajax', 'admin.php'),
|
||||
data
|
||||
);
|
||||
},
|
||||
|
||||
afterSave : function(response){
|
||||
$('#wopi_apply').attr('disabled', false);
|
||||
OC.msg.finishedAction('#documents-admin-msg', response);
|
||||
},
|
||||
|
||||
initEditGroups: function() {
|
||||
var groups = $('#edit_group_select').val().split('|');
|
||||
if (groups.length) {
|
||||
OC.Settings.setupGroupsSelect($('#edit_group_select'));
|
||||
$('.edit-groups-enable').attr('checked', 'checked');
|
||||
} else {
|
||||
$('.edit-groups-enable').attr('checked', null);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
$('#wopi_apply').on('click', documentsSettings.save);
|
||||
initialize: function() {
|
||||
$('#wopi_apply').on('click', documentsSettings.save);
|
||||
documentsSettings.initEditGroups();
|
||||
|
||||
$(document).on('change', '#edit_group_select', function() {
|
||||
var element = $(this).parent().find('input.edit-groups-enable');
|
||||
var groups = $(this).val();
|
||||
if (groups && groups !== '') {
|
||||
groups = groups.split('|');
|
||||
} else {
|
||||
groups = [];
|
||||
}
|
||||
|
||||
documentsSettings.saveGroups(groups);
|
||||
});
|
||||
|
||||
$(document).on('change', '.edit-groups-enable', function() {
|
||||
var $select = $(this).parent().find('#edit_group_select');
|
||||
$select.val('');
|
||||
|
||||
if (this.checked) {
|
||||
OC.Settings.setupGroupsSelect($select, {
|
||||
placeholder: t('core', 'All')
|
||||
});
|
||||
} else {
|
||||
$select.select2('destroy');
|
||||
}
|
||||
|
||||
$select.change();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function(){
|
||||
documentsSettings.initialize();
|
||||
});
|
||||
|
|
|
@ -8,4 +8,9 @@ script('richdocuments', 'admin');
|
|||
<br /><em><?php p($l->t('URL (and port) of the Collabora Online server that provides the editing functionality as a WOPI client.')) ?></em>
|
||||
<br /><button type="button" id="wopi_apply"><?php p($l->t('Apply')) ?></button>
|
||||
<span id="documents-admin-msg" class="msg"></span>
|
||||
<br/>
|
||||
<input type="checkbox" class="edit-groups-enable" id="edit_groups_enable-richdocuments" data-appid="richdocuments" />
|
||||
<label for="edit_groups_enable-richdocuments"><?php p($l->t('Enable edit for specific groups')) ?></label>
|
||||
<br/>
|
||||
<input type="hidden" id="edit_group_select" value="<?php p($_['edit_groups'])?>" title="<?php p($l->t('All')); ?>" style="width: 200px">
|
||||
</div>
|
||||
|
|
Загрузка…
Ссылка в новой задаче