Fix categories delete fallback when there is no app specific ajax categories delete function

This commit is contained in:
Bart Visscher 2012-04-12 22:25:40 +02:00
parent 815649dbd7
commit bc81179163
2 changed files with 12 additions and 16 deletions

View File

@ -17,7 +17,7 @@ function debug($msg) {
require_once('../../../lib/base.php'); require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn(); OC_JSON::checkLoggedIn();
$app = isset($_GET['app'])?$_GET['app']:null; $app = isset($_POST['app'])?$_POST['app']:null;
$categories = isset($_POST['categories'])?$_POST['categories']:null; $categories = isset($_POST['categories'])?$_POST['categories']:null;
if(is_null($app)) { if(is_null($app)) {
bailOut(OC_Contacts_App::$l10n->t('Application name not provided.')); bailOut(OC_Contacts_App::$l10n->t('Application name not provided.'));

View File

@ -53,25 +53,21 @@ OCCategories={
} }
}); });
}, },
_processDeleteResult:function(jsondata, status, xhr){
if(jsondata.status == 'success'){
OCCategories._update(jsondata.data.categories);
} else {
OC.dialogs.alert(jsondata.data.message, 'Error');
}
},
doDelete:function(){ doDelete:function(){
var categories = $('#categorylist').find('input[type="checkbox"]').serialize(); var categories = $('#categorylist').find('input[type="checkbox"]').serialize();
categories += '&app=' + OCCategories.app; categories += '&app=' + OCCategories.app;
console.log('OCCategories.delete: ' + categories); console.log('OCCategories.delete: ' + categories);
$.post(OC.filePath(OCCategories.app, 'ajax', 'categories/delete.php'),categories,function(jsondata, status, xhr){ $.post(OC.filePath(OCCategories.app, 'ajax', 'categories/delete.php'), categories, OCCategories._processDeleteResult)
if (status == 'error' && xhr.status == 404) { .error(function(xhr){
$.post(OC.filePath('core', 'ajax', 'vcategories/delete.php'),categories,function(jsondata, status, xhr){ if (xhr.status == 404) {
if(jsondata.status == 'success'){ $.post(OC.filePath('core', 'ajax', 'vcategories/delete.php'), categories, OCCategories._processDeleteResult);
OCCategories._update(jsondata.data.categories);
} else {
OC.dialogs.alert(jsondata.data.message, 'Error');
}
});
return;
}
if(jsondata.status == 'success'){
OCCategories._update(jsondata.data.categories);
} else {
OC.dialogs.alert(jsondata.data.message, 'Error');
} }
}); });
}, },