Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-31000 Respect sortorder of repositories when displaying the filep…

…icker
  • Loading branch information...
commit 36ef66430e483bf1e58bfbc392ecc071545bc405 1 parent 60e9909
@andrewnicols andrewnicols authored
Showing with 12 additions and 4 deletions.
  1. +10 −4 repository/filepicker.js
  2. +2 −0  repository/lib.php
View
14 repository/filepicker.js
@@ -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" />&nbsp;');
+ 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" />&nbsp;');
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) {
View
2  repository/lib.php
@@ -826,6 +826,7 @@ public static function get_instances($args = array()) {
$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 @@ public function supported_returntypes() {
$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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.