2014-08-14 17:48:38 +04:00
|
|
|
/* global Handlebars */
|
|
|
|
|
|
|
|
Handlebars.registerHelper('score', function() {
|
|
|
|
if(this.score) {
|
|
|
|
var score = Math.round( this.score / 10 );
|
|
|
|
var imageName = 'rating/s' + score + '.png';
|
|
|
|
|
|
|
|
return new Handlebars.SafeString('<img src="' + OC.imagePath('core', imageName) + '">');
|
|
|
|
}
|
|
|
|
return new Handlebars.SafeString('');
|
|
|
|
});
|
2011-08-23 03:40:13 +04:00
|
|
|
|
2012-08-04 22:12:18 +04:00
|
|
|
OC.Settings = OC.Settings || {};
|
|
|
|
OC.Settings.Apps = OC.Settings.Apps || {
|
2014-08-14 17:48:38 +04:00
|
|
|
setupGroupsSelect: function($elements) {
|
|
|
|
OC.Settings.setupGroupsSelect($elements, {
|
2014-09-09 20:00:53 +04:00
|
|
|
placeholder: t('core', 'All')
|
|
|
|
});
|
|
|
|
},
|
2014-01-17 17:05:39 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
State: {
|
|
|
|
currentCategory: null,
|
|
|
|
apps: null
|
|
|
|
},
|
|
|
|
|
|
|
|
loadCategories: function() {
|
|
|
|
var categories = [
|
|
|
|
{displayName: 'Enabled', id: '0'}
|
|
|
|
];
|
|
|
|
|
|
|
|
var source = $("#categories-template").html();
|
|
|
|
var template = Handlebars.compile(source);
|
|
|
|
var html = template(categories);
|
|
|
|
$('#apps-categories').html(html);
|
|
|
|
|
|
|
|
OC.Settings.Apps.loadCategory(0);
|
|
|
|
|
|
|
|
$.ajax(OC.generateUrl('settings/apps/categories'), {
|
|
|
|
data:{},
|
|
|
|
type:'GET',
|
|
|
|
success:function (jsondata) {
|
|
|
|
var html = template(jsondata);
|
|
|
|
$('#apps-categories').html(html);
|
|
|
|
$('#app-category-' + OC.Settings.Apps.State.currentCategory).addClass('active');
|
|
|
|
},
|
|
|
|
complete: function() {
|
|
|
|
$('#app-navigation').removeClass('icon-loading');
|
2014-05-26 00:14:46 +04:00
|
|
|
}
|
2014-08-14 17:48:38 +04:00
|
|
|
});
|
2014-01-17 17:05:39 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
},
|
2014-01-17 17:05:39 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
loadCategory: function(categoryId) {
|
|
|
|
if (OC.Settings.Apps.State.currentCategory === categoryId) {
|
|
|
|
return;
|
2013-01-21 23:40:23 +04:00
|
|
|
}
|
2014-08-14 17:48:38 +04:00
|
|
|
$('#apps-list')
|
|
|
|
.addClass('icon-loading')
|
|
|
|
.html('');
|
|
|
|
$('#app-category-' + OC.Settings.Apps.State.currentCategory).removeClass('active');
|
|
|
|
$('#app-category-' + categoryId).addClass('active');
|
|
|
|
OC.Settings.Apps.State.currentCategory = categoryId;
|
2013-01-21 23:40:23 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
$.ajax(OC.generateUrl('settings/apps/list?category={categoryId}', {
|
|
|
|
categoryId: categoryId
|
|
|
|
}), {
|
|
|
|
data:{},
|
|
|
|
type:'GET',
|
|
|
|
success:function (apps) {
|
|
|
|
OC.Settings.Apps.State.apps = _.indexBy(apps.apps, 'id');
|
|
|
|
var source = $("#app-template").html();
|
|
|
|
var template = Handlebars.compile(source);
|
|
|
|
|
|
|
|
_.each(apps.apps, function(app) {
|
|
|
|
OC.Settings.Apps.renderApp(app, template, null);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
complete: function() {
|
|
|
|
$('#apps-list').removeClass('icon-loading');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
renderApp: function(app, template, selector) {
|
|
|
|
if (!template) {
|
|
|
|
var source = $("#app-template").html();
|
|
|
|
template = Handlebars.compile(source);
|
|
|
|
}
|
|
|
|
if (typeof app === 'string') {
|
|
|
|
app = OC.Settings.Apps.State.apps[app];
|
2014-05-31 19:50:39 +04:00
|
|
|
}
|
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
var html = template(app);
|
|
|
|
if (selector) {
|
|
|
|
selector.html(html);
|
2012-08-05 01:48:09 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
$('#apps-list').append(html);
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
var page = $('#app-' + app.id);
|
|
|
|
|
|
|
|
// image loading kung-fu
|
|
|
|
if (app.preview) {
|
|
|
|
var currentImage = new Image();
|
|
|
|
currentImage.src = app.preview;
|
|
|
|
|
|
|
|
currentImage.onload = function() {
|
|
|
|
page.find('.app-image')
|
|
|
|
.append(this)
|
|
|
|
.fadeIn();
|
|
|
|
};
|
2013-08-18 15:49:34 +04:00
|
|
|
}
|
2014-04-18 16:29:45 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
// set group select properly
|
2014-04-28 15:27:32 +04:00
|
|
|
if(OC.Settings.Apps.isType(app, 'filesystem') || OC.Settings.Apps.isType(app, 'prelogin') ||
|
|
|
|
OC.Settings.Apps.isType(app, 'authentication') || OC.Settings.Apps.isType(app, 'logging')) {
|
2014-08-14 17:48:38 +04:00
|
|
|
page.find(".groups-enable").hide();
|
|
|
|
page.find("label[for='groups_enable-"+app.id+"']").hide();
|
|
|
|
page.find(".groups-enable").attr('checked', null);
|
2014-04-28 15:27:32 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
page.find('#group_select').val((app.groups || []).join(','));
|
2014-04-28 15:27:32 +04:00
|
|
|
if (app.active) {
|
|
|
|
if (app.groups.length) {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.setupGroupsSelect(page.find('#group_select'));
|
|
|
|
page.find(".groups-enable").attr('checked','checked');
|
2014-04-28 15:27:32 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
page.find(".groups-enable").attr('checked', null);
|
2014-04-28 15:27:32 +04:00
|
|
|
}
|
2014-08-14 17:48:38 +04:00
|
|
|
page.find(".groups-enable").show();
|
|
|
|
page.find("label[for='groups_enable-"+app.id+"']").show();
|
2014-04-28 15:27:32 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
page.find(".groups-enable").hide();
|
|
|
|
page.find("label[for='groups_enable-"+app.id+"']").hide();
|
2014-04-28 15:27:32 +04:00
|
|
|
}
|
2014-04-18 16:29:45 +04:00
|
|
|
}
|
2012-08-05 01:48:09 +04:00
|
|
|
},
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
isType: function(app, type){
|
|
|
|
return app.types && app.types.indexOf(type) !== -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
enableApp:function(appId, active, element, groups) {
|
|
|
|
OC.Settings.Apps.hideErrorMessage(appId);
|
2014-04-18 16:29:45 +04:00
|
|
|
groups = groups || [];
|
2014-08-14 17:48:38 +04:00
|
|
|
var appItem = $('div#app-'+appId+'');
|
2013-01-21 23:40:23 +04:00
|
|
|
element.val(t('settings','Please wait....'));
|
2014-04-18 16:29:45 +04:00
|
|
|
if(active && !groups.length) {
|
2014-08-14 17:48:38 +04:00
|
|
|
$.post(OC.filePath('settings','ajax','disableapp.php'),{appid:appId},function(result) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if(!result || result.status !== 'success') {
|
2013-08-06 19:19:18 +04:00
|
|
|
if (result.data && result.data.message) {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(appId, result.data.message);
|
|
|
|
appItem.data('errormsg', result.data.message);
|
2013-08-06 19:19:18 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while disabling app'));
|
|
|
|
appItem.data('errormsg', t('settings', 'Error while disabling app'));
|
2013-08-06 19:19:18 +04:00
|
|
|
}
|
2013-08-18 15:49:34 +04:00
|
|
|
element.val(t('settings','Disable'));
|
2014-08-14 17:48:38 +04:00
|
|
|
appItem.addClass('appwarning');
|
|
|
|
} else {
|
|
|
|
appItem.data('active',false);
|
|
|
|
appItem.data('groups', '');
|
2013-09-20 22:29:15 +04:00
|
|
|
element.data('active',false);
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.removeNavigation(appId);
|
|
|
|
appItem.removeClass('active');
|
2012-08-05 01:48:09 +04:00
|
|
|
element.val(t('settings','Enable'));
|
2014-08-14 17:48:38 +04:00
|
|
|
element.parent().find(".groups-enable").hide();
|
|
|
|
element.parent().find("#groups_enable-"+appId).hide();
|
|
|
|
element.parent().find("label[for='groups_enable-"+appId+"']").hide();
|
|
|
|
element.parent().find('#group_select').hide().val(null);
|
|
|
|
OC.Settings.Apps.State.apps[appId].active = false;
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
|
|
|
},'json');
|
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
$.post(OC.filePath('settings','ajax','enableapp.php'),{appid: appId, groups: groups},function(result) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if(!result || result.status !== 'success') {
|
2013-08-06 19:19:18 +04:00
|
|
|
if (result.data && result.data.message) {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(appId, result.data.message);
|
|
|
|
appItem.data('errormsg', result.data.message);
|
2013-08-06 19:19:18 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while enabling app'));
|
|
|
|
appItem.data('errormsg', t('settings', 'Error while disabling app'));
|
2013-08-06 19:19:18 +04:00
|
|
|
}
|
|
|
|
element.val(t('settings','Enable'));
|
2014-08-14 17:48:38 +04:00
|
|
|
appItem.addClass('appwarning');
|
2013-08-06 19:19:18 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.addNavigation(appId);
|
|
|
|
appItem.data('active',true);
|
2013-09-20 22:29:15 +04:00
|
|
|
element.data('active',true);
|
2014-08-14 17:48:38 +04:00
|
|
|
appItem.addClass('active');
|
2012-08-05 01:48:09 +04:00
|
|
|
element.val(t('settings','Disable'));
|
2014-08-14 17:48:38 +04:00
|
|
|
var app = OC.Settings.Apps.State.apps[appId];
|
2014-05-06 14:41:06 +04:00
|
|
|
app.active = true;
|
2014-08-14 17:48:38 +04:00
|
|
|
|
2014-05-06 14:41:06 +04:00
|
|
|
if (OC.Settings.Apps.isType(app, 'filesystem') || OC.Settings.Apps.isType(app, 'prelogin') ||
|
|
|
|
OC.Settings.Apps.isType(app, 'authentication') || OC.Settings.Apps.isType(app, 'logging')) {
|
2014-08-14 17:48:38 +04:00
|
|
|
element.parent().find(".groups-enable").attr('checked', null);
|
|
|
|
element.parent().find("#groups_enable-"+appId).hide();
|
|
|
|
element.parent().find("label[for='groups_enable-"+appId+"']").hide();
|
|
|
|
element.parent().find(".groups-enable").hide();
|
|
|
|
element.parent().find("#groups_enable-"+appId).hide();
|
|
|
|
element.parent().find("label[for='groups_enable-"+appId+"']").hide();
|
|
|
|
element.parent().find('#group_select').hide().val(null);
|
2014-04-18 16:29:45 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
element.parent().find("#groups_enable-"+appId).show();
|
|
|
|
element.parent().find("label[for='groups_enable-"+appId+"']").show();
|
2014-05-06 14:41:06 +04:00
|
|
|
if (groups) {
|
2014-08-14 17:48:38 +04:00
|
|
|
appItem.data('groups', JSON.stringify(groups));
|
2014-05-06 14:41:06 +04:00
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
appItem.data('groups', '');
|
2014-05-06 14:41:06 +04:00
|
|
|
}
|
2014-04-18 16:29:45 +04:00
|
|
|
}
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
2013-03-23 15:19:43 +04:00
|
|
|
},'json')
|
2014-08-14 17:48:38 +04:00
|
|
|
.fail(function() {
|
|
|
|
OC.Settings.Apps.showErrorMessage(appId, t('settings', 'Error while enabling app'));
|
|
|
|
appItem.data('errormsg', t('settings', 'Error while enabling app'));
|
|
|
|
appItem.data('active',false);
|
|
|
|
appItem.addClass('appwarning');
|
|
|
|
OC.Settings.Apps.removeNavigation(appId);
|
|
|
|
element.val(t('settings','Enable'));
|
|
|
|
});
|
2012-08-05 01:48:09 +04:00
|
|
|
}
|
|
|
|
},
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
updateApp:function(appId, element) {
|
|
|
|
var oldButtonText = element.val();
|
2013-02-01 03:51:00 +04:00
|
|
|
element.val(t('settings','Updating....'));
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.hideErrorMessage(appId);
|
|
|
|
$.post(OC.filePath('settings','ajax','updateapp.php'),{appid:appId},function(result) {
|
2013-04-17 17:32:03 +04:00
|
|
|
if(!result || result.status !== 'success') {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(appId, t('settings','Error while updating app'));
|
|
|
|
element.val(oldButtonText);
|
2013-01-21 23:40:23 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
element.val(t('settings','Updated'));
|
|
|
|
element.hide();
|
|
|
|
}
|
|
|
|
},'json');
|
|
|
|
},
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
uninstallApp:function(appId, element) {
|
|
|
|
OC.Settings.Apps.hideErrorMessage(appId);
|
2014-05-31 19:50:39 +04:00
|
|
|
element.val(t('settings','Uninstalling ....'));
|
2014-08-14 17:48:38 +04:00
|
|
|
$.post(OC.filePath('settings','ajax','uninstallapp.php'),{appid:appId},function(result) {
|
2014-05-31 19:50:39 +04:00
|
|
|
if(!result || result.status !== 'success') {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.showErrorMessage(appId, t('settings','Error while uninstalling app'));
|
2014-05-31 19:50:39 +04:00
|
|
|
element.val(t('settings','Uninstall'));
|
|
|
|
} else {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.removeNavigation(appId);
|
|
|
|
element.parent().fadeOut(function() {
|
|
|
|
element.remove();
|
|
|
|
});
|
2014-05-31 19:50:39 +04:00
|
|
|
}
|
|
|
|
},'json');
|
|
|
|
},
|
2013-01-21 23:40:23 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
removeNavigation: function(appId){
|
|
|
|
$.getJSON(OC.filePath('settings', 'ajax', 'navigationdetect.php'), {app: appId}).done(function(response){
|
2012-10-26 22:12:14 +04:00
|
|
|
if(response.status === 'success'){
|
|
|
|
var navIds=response.nav_ids;
|
|
|
|
for(var i=0; i< navIds.length; i++){
|
2014-06-04 20:22:40 +04:00
|
|
|
$('#apps ul').children('li[data-id="'+navIds[i]+'"]').remove();
|
2012-10-26 22:12:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
addNavigation: function(appid){
|
2012-10-28 21:52:18 +04:00
|
|
|
$.getJSON(OC.filePath('settings', 'ajax', 'navigationdetect.php'), {app: appid}).done(function(response){
|
2012-10-26 22:12:14 +04:00
|
|
|
if(response.status === 'success'){
|
|
|
|
var navEntries=response.nav_entries;
|
|
|
|
for(var i=0; i< navEntries.length; i++){
|
|
|
|
var entry = navEntries[i];
|
2014-06-04 20:22:40 +04:00
|
|
|
var container = $('#apps ul');
|
2012-10-26 22:12:14 +04:00
|
|
|
|
|
|
|
if(container.children('li[data-id="'+entry.id+'"]').length === 0){
|
2013-02-05 14:30:18 +04:00
|
|
|
var li=$('<li></li>');
|
2012-10-26 22:12:14 +04:00
|
|
|
li.attr('data-id', entry.id);
|
2014-08-05 16:23:25 +04:00
|
|
|
var img= $('<img class="app-icon"/>').attr({ src: entry.icon});
|
2013-01-31 10:22:56 +04:00
|
|
|
var a=$('<a></a>').attr('href', entry.href);
|
2013-06-29 00:10:40 +04:00
|
|
|
var filename=$('<span></span>');
|
2013-04-12 16:45:59 +04:00
|
|
|
filename.text(entry.name);
|
|
|
|
a.prepend(filename);
|
2013-02-03 19:02:25 +04:00
|
|
|
a.prepend(img);
|
2012-10-26 22:12:14 +04:00
|
|
|
li.append(a);
|
2014-02-26 13:34:38 +04:00
|
|
|
|
|
|
|
// append the new app as last item in the list
|
2014-06-04 20:22:40 +04:00
|
|
|
// which is the "add apps" entry with the id
|
|
|
|
// #apps-management
|
|
|
|
$('#apps-management').before(li);
|
2014-02-26 13:34:38 +04:00
|
|
|
|
|
|
|
// scroll the app navigation down
|
|
|
|
// so the newly added app is seen
|
|
|
|
$('#navigation').animate({
|
|
|
|
scrollTop: $('#navigation').height()
|
|
|
|
}, 'slow');
|
|
|
|
|
|
|
|
// draw attention to the newly added app entry
|
|
|
|
// by flashing it twice
|
2014-06-04 20:22:40 +04:00
|
|
|
$('#header .menutoggle')
|
2014-06-05 12:52:06 +04:00
|
|
|
.animate({opacity: 0.5})
|
2014-02-26 13:34:38 +04:00
|
|
|
.animate({opacity: 1})
|
2014-06-05 12:52:06 +04:00
|
|
|
.animate({opacity: 0.5})
|
2014-06-04 20:22:40 +04:00
|
|
|
.animate({opacity: 1})
|
2014-06-05 12:52:06 +04:00
|
|
|
.animate({opacity: 0.75});
|
2013-08-07 23:54:28 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
if (!OC.Util.hasSVGSupport() && entry.icon.match(/\.svg$/i)) {
|
2013-06-29 00:10:40 +04:00
|
|
|
$(img).addClass('svg');
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Util.replaceSVG();
|
2013-06-29 00:10:40 +04:00
|
|
|
}
|
2012-10-26 22:12:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-08-18 15:49:34 +04:00
|
|
|
},
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
showErrorMessage: function(appId, message) {
|
|
|
|
$('div#app-'+appId+' .warning')
|
|
|
|
.show()
|
|
|
|
.text(message);
|
2014-04-28 15:27:32 +04:00
|
|
|
},
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
hideErrorMessage: function(appId) {
|
|
|
|
$('div#app-'+appId+' .warning')
|
|
|
|
.hide()
|
|
|
|
.text('');
|
2012-08-04 22:12:18 +04:00
|
|
|
}
|
2014-08-14 17:48:38 +04:00
|
|
|
|
2012-09-06 00:17:33 +04:00
|
|
|
};
|
2012-08-04 22:12:18 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
$(document).ready(function () {
|
|
|
|
OC.Settings.Apps.loadCategories();
|
2012-08-04 22:12:18 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
$(document).on('click', 'ul#apps-categories li', function () {
|
|
|
|
var categoryId = $(this).data('categoryId');
|
|
|
|
OC.Settings.Apps.loadCategory(categoryId);
|
2011-08-10 14:20:43 +04:00
|
|
|
});
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
$(document).on('click', '#apps-list input.enable', function () {
|
|
|
|
var appId = $(this).data('appid');
|
2012-05-15 01:52:40 +04:00
|
|
|
var element = $(this);
|
2014-08-14 17:48:38 +04:00
|
|
|
var active = $(this).data('active');
|
|
|
|
|
|
|
|
OC.Settings.Apps.enableApp(appId, active, element);
|
2011-08-10 14:20:43 +04:00
|
|
|
});
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
$(document).on('click', '#apps-list input.uninstall', function () {
|
|
|
|
var appId = $(this).data('appid');
|
2013-01-21 23:40:23 +04:00
|
|
|
var element = $(this);
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
OC.Settings.Apps.uninstallApp(appId, element);
|
2013-01-21 23:40:23 +04:00
|
|
|
});
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
$(document).on('click', '#apps-list input.update', function () {
|
|
|
|
var appId = $(this).data('appid');
|
2014-05-31 19:50:39 +04:00
|
|
|
var element = $(this);
|
2014-08-14 17:48:38 +04:00
|
|
|
|
|
|
|
OC.Settings.Apps.updateApp(appId, element);
|
2014-05-31 19:50:39 +04:00
|
|
|
});
|
2012-08-04 22:12:18 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
$(document).on('change', '#group_select', function() {
|
|
|
|
var element = $(this).parent().find('input.enable');
|
|
|
|
var groups = $(this).val();
|
|
|
|
if (groups && groups !== '') {
|
|
|
|
groups = groups.split(',');
|
|
|
|
} else {
|
|
|
|
groups = [];
|
2014-04-18 16:29:45 +04:00
|
|
|
}
|
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
var appId = element.data('appid');
|
|
|
|
if (appId) {
|
|
|
|
OC.Settings.Apps.enableApp(appId, false, element, groups);
|
|
|
|
OC.Settings.Apps.State.apps[appId].groups = groups;
|
2012-06-25 07:02:01 +04:00
|
|
|
}
|
2014-08-14 17:48:38 +04:00
|
|
|
});
|
2014-04-18 16:29:45 +04:00
|
|
|
|
2014-08-14 17:48:38 +04:00
|
|
|
$(document).on('change', ".groups-enable", function() {
|
|
|
|
var $select = $(this).parent().find('#group_select');
|
2014-09-09 20:00:53 +04:00
|
|
|
$select.val('');
|
2014-08-14 17:48:38 +04:00
|
|
|
|
2014-04-18 16:29:45 +04:00
|
|
|
if (this.checked) {
|
2014-08-14 17:48:38 +04:00
|
|
|
OC.Settings.Apps.setupGroupsSelect($select);
|
|
|
|
} else {
|
2014-09-09 20:00:53 +04:00
|
|
|
$select.select2('destroy');
|
|
|
|
}
|
2014-08-14 17:48:38 +04:00
|
|
|
|
2014-09-09 20:00:53 +04:00
|
|
|
$select.change();
|
2014-04-18 16:29:45 +04:00
|
|
|
});
|
2014-08-14 17:48:38 +04:00
|
|
|
|
2011-08-10 14:20:43 +04:00
|
|
|
});
|