Skip to content

Commit

Permalink
feature 3077 : always sort categories by global rank
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@28540 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
mistic100 committed May 26, 2014
1 parent 2f62865 commit 1b60baf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion admin/themes/default/js/LocalStorageCache.js
@@ -1,5 +1,5 @@
var LocalStorageCache = function(options) {
this.key = options.key + '-' + options.serverId;
this.key = options.key + '_' + options.serverId;
this.serverKey = options.serverKey;
this.lifetime = options.lifetime ? options.lifetime*1000 : 3600*1000;
this.loader = options.loader;
Expand Down
5 changes: 3 additions & 2 deletions admin/themes/default/js/addAlbum.js
Expand Up @@ -8,7 +8,7 @@ jQuery.fn.pwgAddAlbum = function(options) {
$popup.find('[name="category_parent"]').selectize({
valueField: 'id',
labelField: 'fullname',
sortField: 'fullname',
sortField: 'global_rank',
searchField: ['fullname'],
plugins: ['remove_button'],
onInitialize: function() {
Expand Down Expand Up @@ -107,7 +107,8 @@ jQuery.fn.pwgAddAlbum = function(options) {
options.cache.get(function(categories) {
categories.push({
id: 0,
fullname: '------------'
fullname: '------------',
global_rank: 0
});

albumParent.selectize.load(function(callback) {
Expand Down
6 changes: 1 addition & 5 deletions admin/themes/default/template/batch_manager_global.tpl
Expand Up @@ -134,16 +134,12 @@ jQuery(document).ready(function() {ldelim}
jQuery('[data-selectize=categories]').selectize({
valueField: 'id',
labelField: 'fullname',
sortField: 'fullname',
sortField: 'global_rank',
searchField: ['fullname'],
plugins: ['remove_button']
});

categoriesCache.get(function(categories) {
categories.sort(function(a, b) {
return a.fullname.localeCompare(b.fullname);
});

jQuery('[data-selectize=categories]').each(function() {
this.selectize.load(function(callback) {
callback(categories);
Expand Down
13 changes: 5 additions & 8 deletions admin/themes/default/template/cat_modify.tpl
Expand Up @@ -20,26 +20,23 @@ var categoriesCache = new LocalStorageCache({
jQuery('[data-selectize=categories]').selectize({
valueField: 'id',
labelField: 'fullname',
sortField: 'fullname',
sortField: 'global_rank',
searchField: ['fullname'],
plugins: ['remove_button']
});

categoriesCache.get(function(categories) {
categories.push({
id: 0,
fullname: '------------'
fullname: '------------',
global_rank: 0
});

// remove itself and children
categories = jQuery.grep(categories, function(cat) {
return !(/\b{$CAT_ID}\b/.test(cat.uppercats));
});

categories.sort(function(a, b) {
return a.fullname.localeCompare(b.fullname);
});

jQuery('[data-selectize=categories]').each(function() {
this.selectize.load(function(callback) {
callback(categories);
Expand All @@ -51,11 +48,11 @@ categoriesCache.get(function(categories) {

// prevent empty value
if (this.selectize.getValue() == '') {
this.selectize.setValue(categories[0].id);
this.selectize.setValue(0);
}
this.selectize.on('dropdown_close', function() {
if (this.getValue() == '') {
this.setValue(categories[0].id);
this.setValue(0);
}
});
});
Expand Down
6 changes: 1 addition & 5 deletions admin/themes/default/template/photos_add_direct.tpl
Expand Up @@ -31,7 +31,7 @@ var categoriesCache = new LocalStorageCache({
jQuery('[data-selectize=categories]').selectize({
valueField: 'id',
labelField: 'fullname',
sortField: 'fullname',
sortField: 'global_rank',
searchField: ['fullname'],
plugins: ['remove_button']
});
Expand All @@ -40,10 +40,6 @@ categoriesCache.get(function(categories) {
if (categories.length > 0) {
jQuery("#albumSelection").show();
}

categories.sort(function(a, b) {
return a.fullname.localeCompare(b.fullname);
});

jQuery('[data-selectize=categories]').each(function() {
this.selectize.load(function(callback) {
Expand Down
2 changes: 1 addition & 1 deletion admin/themes/default/template/picture_modify.tpl
Expand Up @@ -25,7 +25,7 @@ var categoriesCache = new LocalStorageCache({
jQuery('[data-selectize=categories]').selectize({
valueField: 'id',
labelField: 'fullname',
sortField: 'fullname',
sortField: 'global_rank',
searchField: ['fullname'],
plugins: ['remove_button']
});
Expand Down

0 comments on commit 1b60baf

Please sign in to comment.