Skip to content

Commit

Permalink
Merge branch 'wip-MDL-31838-master' of git://github.com/marinaglancy/…
Browse files Browse the repository at this point in the history
…moodle
Aparup Banerjee committed Mar 13, 2012

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
2 parents 42c8e4d + 7f9358f commit 66da1ab
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions repository/filepicker.js
Original file line number Diff line number Diff line change
@@ -72,6 +72,7 @@ M.core_filepicker.init = function(Y, options) {

Y.extend(FilePickerHelper, Y.Base, {
api: M.cfg.wwwroot+'/repository/repository_ajax.php',
cached_responses: {},

initializer: function(options) {
this.options = options;
@@ -163,6 +164,11 @@ M.core_filepicker.init = function(Y, options) {
if (data.msg) {
scope.print_msg(data.msg, 'info');
}
// cache result if applicable
if (args.action != 'upload' && data.allowcaching) {
scope.cached_responses[params] = data;
}
// invoke callback
args.callback(id,data,p);
}
}
@@ -179,9 +185,15 @@ M.core_filepicker.init = function(Y, options) {
if (args.form) {
cfg.form = args.form;
}
Y.io(api, cfg);
if (redraw) {
this.wait('load');
// check if result of the same request has been already cached. If not, request it
// (never applicable in case of form submission and/or upload action):
if (!args.form && args.action != 'upload' && scope.cached_responses[params]) {
args.callback(null, scope.cached_responses[params], {scope: scope})
} else {
Y.io(api, cfg);
if (redraw) {
this.wait('load');
}
}
},
process_existing_file: function(data) {
1 change: 1 addition & 0 deletions repository/upload/lib.php
Original file line number Diff line number Diff line change
@@ -223,6 +223,7 @@ public function get_listing() {
$ret['list'] = array();
$ret['dynload'] = false;
$ret['upload'] = array('label'=>get_string('attachment', 'repository'), 'id'=>'repo-form');
$ret['allowcaching'] = true; // indicates that result of get_listing() can be cached in filepicker.js
return $ret;
}

0 comments on commit 66da1ab

Please sign in to comment.