Commit 37ee9438 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

file: filebrowser.success refactoring (bug #623648)



* success function (FileBrowser javascript class) is renamed to "callback" as it
  will be used to process errors as well.
* upload_success is renamed to upload_feedback.
* ArtefactTypeFileBase::files_form missed jserrorcallback definition.
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent 8cab3eec
......@@ -91,8 +91,8 @@ $form = pieform(array(
'autofocus' => $focuselement,
'jsform' => true,
'newiframeonsubmit' => true,
'jssuccesscallback' => 'editpost_success',
'jserrorcallback' => 'editpost_error',
'jssuccesscallback' => 'editpost_callback',
'jserrorcallback' => 'editpost_callback',
'plugintype' => 'artefact',
'pluginname' => 'blog',
'configdirs' => array(get_config('libroot') . 'form/', get_config('docroot') . 'artefact/file/form/'),
......@@ -237,12 +237,8 @@ function blogpostImageWindow(ui, v) {
t.windowManager.open(template);
}
function editpost_success(form, data) {
editpost_filebrowser.success(form, data);
};
function editpost_error(form, data) {
editpost_filebrowser.init();
function editpost_callback(form, data) {
editpost_filebrowser.callback(form, data);
};
EOF;
......
......@@ -343,10 +343,10 @@ function pieform_element_filebrowser_get_value(Pieform $form, $element) {
$replacehtml = false; // Don't replace the entire form when replying with json data.
$result['formelement'] = $prefix;
if (!empty($result['error'])) {
$result['formelementerror'] = $prefix . '.success';
$result['formelementerror'] = $prefix . '.callback';
}
else {
$result['formelementsuccess'] = $prefix . '.success';
$result['formelementsuccess'] = $prefix . '.callback';
}
$form->json_reply(empty($result['error']) ? PIEFORM_OK : PIEFORM_ERR, $result, $replacehtml);
}
......
......@@ -192,7 +192,7 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
}
}
this.upload_success = function (data) {
this.upload_feedback = function (data) {
if (data.problem) {
var image = 'images/icon_problem.gif';
}
......@@ -561,10 +561,10 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
return false;
}
this.success = function (form, data) {
this.callback = function (form, data) {
self.form = form; // ????
if (data.uploaded) {
self.upload_success(data); // Remove uploading message
if (data.uploaded || data.error) {
self.upload_feedback(data); // Remove uploading message
}
// Only update the file listing if the user hasn't changed folders yet
if (data.newlist && (data.folder == self.folderid || data.changedfolder)) {
......
......@@ -448,7 +448,8 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
'name' => 'files',
'jsform' => true,
'newiframeonsubmit' => true,
'jssuccesscallback' => 'files_success',
'jssuccesscallback' => 'files_callback',
'jserrorcallback' => 'files_callback',
'renderer' => 'oneline',
'plugintype' => 'artefact',
'pluginname' => 'file',
......@@ -476,7 +477,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
}
public static function files_js() {
return "function files_success(form, data) { files_filebrowser.success(form, data); }";
return "function files_callback(form, data) { files_filebrowser.callback(form, data); }";
}
public static function count_user_files($owner=null, $group=null, $institution=null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment