tweaked the loader -- needs refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-02-15 04:21:40 +03:00
parent f204503464
commit 70a5d4fe26
4 changed files with 43 additions and 3 deletions

View File

@ -599,19 +599,26 @@ actions.Actions({
// actions if that info is needed.
// NOTE: to make things clean, this is triggered in action handlers
// below...
// XXX do we need a vertical shift event??
shiftImage: ['- Interface/Image shift (do not use directly)',
core.notUserCallable(function(gid){
// This is the image shift protocol root function
//
// Not for direct use.
})],
shiftImageOrder: ['- Interface/Image horizontal shift (do not use directly)',
core.notUserCallable(function(gid){
// This is the image shift protocol root function
//
// Not for direct use.
})],
// XXX to be used for things like mark/place and dragging...
// XXX revise...
// XXX undo...
shiftImageTo: ['- Edit|Sort|Image/',
{undo: function(a){ this.shiftImageTo(a.args[1], a.args[0]) }},
function(target, to){ this.data.shiftImageTo(target, to) }],
function(target, to){ this.data.shiftImage(target, to) }],
shiftImageUp: ['Edit|Image/Shift image up',
'If implicitly shifting current image (i.e. no arguments), focus '
@ -862,6 +869,19 @@ module.Base = core.ImageGridFeatures.Feature({
'shiftImageRight',
],
function(){ this.shiftImage.apply(this, [].slice(arguments, 1))}],
// horizontal shifting...
[[
'shiftImageLeft',
'shiftImageRight',
],
function(){ this.shiftImageOrder.apply(this, [].slice(arguments, 1))}],
['shiftImageTo.pre',
function(a){
var i = this.data.getImageOrder(a)
return function(){
// only trigger if order changed...
i != this.data.getImageOrder(a)
&& this.shiftImageOrder.apply(this, [].slice(arguments, 1)) } }],
// manage changes...
// everything changed...

View File

@ -391,7 +391,7 @@ module.SortActions = actions.Actions({
if(order){
this.data.order = order.slice()
this.sortImages('update' + (reverse ? ' reverse' : ''))
this.data.sort_method = mode
this.data.sort_method = title
}
}],
@ -409,7 +409,8 @@ module.SortActions = actions.Actions({
// Store/load sort data:
// .data.sort_method - current sort mode (optional)
// .data.sort_cache - manual sort order (optional)
// .data.sort_order - saved sort order (optional)
// .data.sort_cache - cached sort order (optional)
load: [function(data){
return function(){
if(data.data && data.data.sort_method){
@ -493,6 +494,15 @@ module.Sort = core.ImageGridFeatures.Feature({
// manage changes...
['sortImages',
function(_, target){ this.markChanged('data') }],
// NOTE: this always saves to 'Manual' this is correct regardless
// of save mode as in the current logic, the only mode that
// results from a manual shift is a manual sort...
// XXX this may pose a problem with saved sorts, the question
// is whether a saved mode can be edited or just saved or
// updated...
['shiftImageOrder',
function(){ this.markChanged('sort_order', ['Manual']) }],
['saveOrder',
function(_, title){ this.markChanged('sort_order', [title]) }],
['cacheOrder',

View File

@ -2587,6 +2587,7 @@ var DataPrototype = {
// load initial state...
if(json != null){
this.loadJSON(json)
} else {
this._reset()
}

View File

@ -827,6 +827,15 @@ module.buildIndex = function(index, base_path){
img.forEach(function(_, img){ img.base_path = base_path })
}
// extra stuff...
// ...this will restore stuff stored in the data but not explicitly
// restored above...
Object.keys(index.data).forEach(function(k){
if(d[k] === undefined){
d[k] = index.data[k]
}
})
res.data = d
res.images = img