Fix problems with chosen multiselect

This commit is contained in:
Michael Gapczynski 2012-12-28 17:38:24 -05:00
parent 595e72ade8
commit 442a045ef6
1 changed files with 31 additions and 15 deletions

View File

@ -39,6 +39,8 @@ OC.MountConfig={
var isPersonal = false;
var oldGroups = $(tr).find('.applicable').data('applicable-groups');
var oldUsers = $(tr).find('.applicable').data('applicable-users');
var groups = [];
var users = [];
$.each(multiselect, function(index, value) {
var pos = value.indexOf('(group)');
if (pos != -1) {
@ -47,12 +49,14 @@ OC.MountConfig={
if ($.inArray(applicable, oldGroups) != -1) {
oldGroups.splice($.inArray(applicable, oldGroups), 1);
}
groups.push(applicable);
} else {
var mountType = 'user';
var applicable = value;
if ($.inArray(applicable, oldUsers) != -1) {
oldUsers.splice($.inArray(applicable, oldUsers), 1);
}
users.push(applicable);
}
$.post(OC.filePath('files_external', 'ajax', 'addMountPoint.php'), { mountPoint: mountPoint, class: backendClass, classOptions: classOptions, mountType: mountType, applicable: applicable, isPersonal: isPersonal }, function(result) {
statusSpan.removeClass();
@ -63,6 +67,8 @@ OC.MountConfig={
}
});
});
$(tr).find('.applicable').data('applicable-groups', groups);
$(tr).find('.applicable').data('applicable-users', users);
var mountType = 'group';
$.each(oldGroups, function(index, applicable) {
$.post(OC.filePath('files_external', 'ajax', 'removeMountPoint.php'), { mountPoint: mountPoint, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
@ -128,7 +134,11 @@ $(document).ready(function() {
return false;
}
});
$('.chz-select').chosen();
// Reset chosen
var chosen = $(tr).find('.applicable select');
chosen.parent().find('div').remove();
chosen.removeAttr('id').removeClass('chzn-done').css({display:'inline-block'});
chosen.chosen();
$(tr).find('td').last().attr('class', 'remove');
$(tr).find('td').last().removeAttr('style');
$(tr).removeAttr('id');
@ -171,9 +181,9 @@ $(document).ready(function() {
var timer;
$('#externalStorage td').live('keyup', function() {
$('#externalStorage td input').live('keyup', function() {
clearTimeout(timer);
var tr = $(this).parent();
var tr = $(this).parent().parent();
if ($(this).val) {
timer = setTimeout(function() {
OC.MountConfig.saveStorage(tr);
@ -181,6 +191,10 @@ $(document).ready(function() {
}
});
$('.applicable .chzn-select').live('change', function() {
OC.MountConfig.saveStorage($(this).parent().parent());
});
$('td.remove>img').live('click', function() {
var tr = $(this).parent().parent();
var mountPoint = $(tr).find('.mountPoint input').val();
@ -193,6 +207,7 @@ $(document).ready(function() {
if ($('#externalStorage').data('admin') === true) {
var isPersonal = false;
var multiselect = $(tr).find('.chzn-select').val();
if (multiselect != null) {
$.each(multiselect, function(index, value) {
var pos = value.indexOf('(group)');
if (pos != -1) {
@ -204,12 +219,13 @@ $(document).ready(function() {
}
$.post(OC.filePath('files_external', 'ajax', 'removeMountPoint.php'), { mountPoint: mountPoint, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
});
}
} else {
var mountType = 'user';
var applicable = OC.currentUser;
var isPersonal = true;
}
$.post(OC.filePath('files_external', 'ajax', 'removeMountPoint.php'), { mountPoint: mountPoint, mountType: mountType, applicable: applicable, isPersonal: isPersonal });
}
$(tr).remove();
});