mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added 'sort as current' method/action...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c05970bde5
commit
67e414358c
@ -295,6 +295,14 @@ var CollectionActions = actions.Actions({
|
|||||||
`,
|
`,
|
||||||
function(collection){
|
function(collection){
|
||||||
var that = this
|
var that = this
|
||||||
|
collection = collection
|
||||||
|
|| MAIN_COLLECTION_TITLE
|
||||||
|
|
||||||
|
// main collection shorthand...
|
||||||
|
// XXX revise...
|
||||||
|
if(this.collection == null
|
||||||
|
&& collection == MAIN_COLLECTION_TITLE){
|
||||||
|
return Promise.resolve(this) }
|
||||||
|
|
||||||
var running = this.__running_collection_ensure =
|
var running = this.__running_collection_ensure =
|
||||||
this.__running_collection_ensure || {}
|
this.__running_collection_ensure || {}
|
||||||
@ -2762,22 +2770,50 @@ var UICollectionActions = actions.Actions({
|
|||||||
}],
|
}],
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
// XXX need to force show MAIN_COLLECTION_TITLE...
|
|
||||||
// -> mixedModeCollectionAction(..)
|
collectionSort: ['- Collections/',
|
||||||
// -> .browseCollections(..)
|
core.doc`Sort collection A (sorted) as collection B (sort_as)...
|
||||||
// XXX might be a good idea to add a reverse of this, i.e. .sortCollectionAsThis(..)
|
|
||||||
// XXX do we need to have an option/shorthand to .sortAs(..) and .inplaceSortAs(..) ???
|
|
||||||
|
NOTE: if sorted and sort_as are the same collection this will do nothing.
|
||||||
|
`,
|
||||||
|
function(sorted, sort_as, mode='in-place'){
|
||||||
|
var that = this
|
||||||
|
var sort = mode == 'in-place' ?
|
||||||
|
'inplaceSortAs'
|
||||||
|
: 'sortAs'
|
||||||
|
if(sorted == sort_as){
|
||||||
|
return Promise.resolve() }
|
||||||
|
// NOTE: need to update view if the sorted collection is loaded...
|
||||||
|
var loaded = sorted == this.collection
|
||||||
|
return Promise.all([
|
||||||
|
this.ensureCollection(sorted),
|
||||||
|
this.ensureCollection(sort_as),
|
||||||
|
]).then(function([sorted, sort_as]){
|
||||||
|
sorted.data.order[sort](sort_as.data.order)
|
||||||
|
sorted.data.updateImagePositions()
|
||||||
|
loaded
|
||||||
|
&& that.sortImages('update') }) }],
|
||||||
|
|
||||||
|
// XXX revise naming...
|
||||||
sortAsCollection: ['Collections/Sort as collection...',
|
sortAsCollection: ['Collections/Sort as collection...',
|
||||||
|
core.doc`Sort current collection as selected.`,
|
||||||
{sortMethod: true,
|
{sortMethod: true,
|
||||||
mode: function(){
|
mode: function(){
|
||||||
return this.collections_length > 0 || 'disabled' }, },
|
return this.collections_length > 0 || 'disabled' }, },
|
||||||
mixedModeCollectionAction(
|
mixedModeCollectionAction(
|
||||||
function(title){
|
function(sort_as){
|
||||||
var that = this
|
return this.collectionSort(this.collection, sort_as) },
|
||||||
this.ensureCollection(title)
|
null,
|
||||||
.then(function(collection){
|
{ show_main: function(){
|
||||||
that.data.order.inplaceSortAs(collection.data.order)
|
return !!this.collection } })],
|
||||||
that.sortImages('update') }) },
|
sortCollectionAsThis: ['- Collections/Sort collection as current...',
|
||||||
|
core.doc`Sort selected collection as current.`,
|
||||||
|
{sortMethod: true,
|
||||||
|
mode: 'sortAsCollection', },
|
||||||
|
mixedModeCollectionAction(
|
||||||
|
function(sorted){
|
||||||
|
return this.collectionSort(sorted, this.collection) },
|
||||||
null,
|
null,
|
||||||
{ show_main: function(){
|
{ show_main: function(){
|
||||||
return !!this.collection } })],
|
return !!this.collection } })],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user