MDL-31000 Respect sortorder of repositories when displaying the filepicker
This commit is contained in:
@@ -797,16 +797,22 @@ M.core_filepicker.init = function(Y, options) {
|
||||
Y.on('contentready', function(el) {
|
||||
var list = Y.one(el);
|
||||
var count = 0;
|
||||
// Resort the repositories by sortorder
|
||||
var sorted_repositories = new Array();
|
||||
for (var i in r) {
|
||||
var id = 'repository-'+client_id+'-'+r[i].id;
|
||||
sorted_repositories[r[i].sortorder - 1] = r[i];
|
||||
}
|
||||
for (var i in sorted_repositories){
|
||||
repository = sorted_repositories[i];
|
||||
var id = 'repository-'+client_id+'-'+repository.id;
|
||||
var link_id = id + '-link';
|
||||
list.append('<li id="'+id+'"><a class="fp-repo-name" id="'+link_id+'" href="###">'+r[i].name+'</a></li>');
|
||||
Y.one('#'+link_id).prepend('<img src="'+r[i].icon+'" width="16" height="16" /> ');
|
||||
list.append('<li id="'+id+'"><a class="fp-repo-name" id="'+link_id+'" href="###">'+repository.name+'</a></li>');
|
||||
Y.one('#'+link_id).prepend('<img src="'+repository.icon+'" width="16" height="16" /> ');
|
||||
Y.one('#'+link_id).on('click', function(e, scope, repository_id) {
|
||||
YAHOO.util.Cookie.set('recentrepository', repository_id);
|
||||
scope.repository_id = repository_id;
|
||||
this.list({'repo_id':repository_id});
|
||||
}, this /*handler running scope*/, this/*second argument*/, r[i].id/*third argument of handler*/);
|
||||
}, this /*handler running scope*/, this/*second argument*/, repository.id/*third argument of handler*/);
|
||||
count++;
|
||||
}
|
||||
if (count==0) {
|
||||
|
||||
@@ -826,6 +826,7 @@ abstract class repository {
|
||||
$options['visible'] = $record->visible;
|
||||
$options['type'] = $record->repositorytype;
|
||||
$options['typeid'] = $record->typeid;
|
||||
$options['sortorder'] = $record->sortorder;
|
||||
// tell instance what file types will be accepted by file picker
|
||||
$classname = 'repository_' . $record->repositorytype;
|
||||
|
||||
@@ -1447,6 +1448,7 @@ abstract class repository {
|
||||
$meta->icon = $OUTPUT->pix_url('icon', 'repository_'.$meta->type)->out(false);
|
||||
$meta->supported_types = $ft->get_extensions($this->supported_filetypes());
|
||||
$meta->return_types = $this->supported_returntypes();
|
||||
$meta->sortorder = $this->options['sortorder'];
|
||||
return $meta;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user