mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
several fixes + started work on local tags...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a8aaa01a24
commit
6cbf121cc9
@ -47,6 +47,7 @@ var MAIN_COLLECTION_TITLE = 'ALL'
|
|||||||
// XXX handle tags here???
|
// XXX handle tags here???
|
||||||
// ...keep them global or local to collection???
|
// ...keep them global or local to collection???
|
||||||
// global sounds better...
|
// global sounds better...
|
||||||
|
// XXX local tags: bookmarked, selected...
|
||||||
// XXX undo...
|
// XXX undo...
|
||||||
var CollectionActions = actions.Actions({
|
var CollectionActions = actions.Actions({
|
||||||
config: {
|
config: {
|
||||||
@ -56,6 +57,13 @@ var CollectionActions = actions.Actions({
|
|||||||
// 'none' - do not save crop state
|
// 'none' - do not save crop state
|
||||||
'collection-save-crop-state': 'all',
|
'collection-save-crop-state': 'all',
|
||||||
|
|
||||||
|
// List of tags to be stored in a collection, unique to it...
|
||||||
|
//
|
||||||
|
// XXX this is not used yet...
|
||||||
|
'collection-local-tags': [
|
||||||
|
'bookmark',
|
||||||
|
'selected',
|
||||||
|
],
|
||||||
|
|
||||||
// XXX add default collection list to config...
|
// XXX add default collection list to config...
|
||||||
'default-collections': [
|
'default-collections': [
|
||||||
@ -170,6 +178,7 @@ var CollectionActions = actions.Actions({
|
|||||||
function(title, data){
|
function(title, data){
|
||||||
return new Promise(function(resolve){ resolve(data.data) }) }],
|
return new Promise(function(resolve){ resolve(data.data) }) }],
|
||||||
|
|
||||||
|
// XXX load local_tags...
|
||||||
loadCollection: ['- Collections/',
|
loadCollection: ['- Collections/',
|
||||||
core.doc`Load collection...
|
core.doc`Load collection...
|
||||||
|
|
||||||
@ -219,27 +228,23 @@ var CollectionActions = actions.Actions({
|
|||||||
|
|
||||||
// save current collection state...
|
// save current collection state...
|
||||||
//
|
//
|
||||||
// main view -> save it...
|
// main view...
|
||||||
if(this.collection == null){
|
if(this.collection == null){
|
||||||
var main = this.collections[MAIN_COLLECTION_TITLE] = {
|
var tags = this.data.tags
|
||||||
title: MAIN_COLLECTION_TITLE,
|
|
||||||
}
|
|
||||||
|
|
||||||
// mode 'none' -> do not save crop state...
|
this.saveCollection(
|
||||||
if(crop_mode == 'none'){
|
MAIN_COLLECTION_TITLE,
|
||||||
//this.saveCollection(this.collection, 'base')
|
crop_mode == 'none' ?
|
||||||
main.data = (this.crop_stack || [])[0] || this.data
|
'base'
|
||||||
|
: 'crop',
|
||||||
|
true)
|
||||||
|
|
||||||
// modes 'all' and 'main' -> save crop state...
|
// keep the tags...
|
||||||
} else {
|
this.collections[MAIN_COLLECTION_TITLE].data.tags = tags
|
||||||
//this.saveCollection(this.collection, 'crop')
|
|
||||||
main.data = this.data
|
|
||||||
main.crop_stack = this.crop_stack
|
|
||||||
&& this.crop_stack.slice()
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(crop_mode == 'all'){
|
// collection...
|
||||||
this.saveCollection(this.collection, 'crop')
|
} else {
|
||||||
|
this.saveCollection(this.collection, crop_mode == 'all' ? 'crop': null)
|
||||||
}
|
}
|
||||||
|
|
||||||
// load collection...
|
// load collection...
|
||||||
@ -264,6 +269,9 @@ var CollectionActions = actions.Actions({
|
|||||||
|
|
||||||
data.tags = that.data.tags
|
data.tags = that.data.tags
|
||||||
|
|
||||||
|
// XXX load local_tags...
|
||||||
|
// XXX
|
||||||
|
|
||||||
// NOTE: tags and other position dependant
|
// NOTE: tags and other position dependant
|
||||||
// data needs to be updated as collections
|
// data needs to be updated as collections
|
||||||
// may contain different numbers/orders of
|
// may contain different numbers/orders of
|
||||||
@ -364,12 +372,14 @@ var CollectionActions = actions.Actions({
|
|||||||
-> this
|
-> this
|
||||||
|
|
||||||
`,
|
`,
|
||||||
function(collection, mode){
|
function(collection, mode, force){
|
||||||
var that = this
|
var that = this
|
||||||
collection = collection || this.collection
|
collection = collection || this.collection
|
||||||
collection = collection == 'current' ? this.collection : collection
|
collection = collection == 'current' ? this.collection : collection
|
||||||
|
|
||||||
if(collection == null || collection == MAIN_COLLECTION_TITLE){
|
if(!force
|
||||||
|
&& (collection == null
|
||||||
|
|| collection == MAIN_COLLECTION_TITLE)){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +390,14 @@ var CollectionActions = actions.Actions({
|
|||||||
|
|
||||||
var collections = this.collections = this.collections || {}
|
var collections = this.collections = this.collections || {}
|
||||||
|
|
||||||
|
// prepare local lags...
|
||||||
|
//var local_tags = {}
|
||||||
|
// XXX
|
||||||
|
var local_tags = (collections[collection] || {}).local_tags || {}
|
||||||
|
;(this.config['collection-local-tags'] || [])
|
||||||
|
.forEach(function(tag){
|
||||||
|
local_tags[tag] = local_tags[tag] || [] })
|
||||||
|
|
||||||
var state = collections[collection] = {
|
var state = collections[collection] = {
|
||||||
title: collection,
|
title: collection,
|
||||||
|
|
||||||
@ -393,14 +411,22 @@ var CollectionActions = actions.Actions({
|
|||||||
this.data.clone()
|
this.data.clone()
|
||||||
: this.data.clone()
|
: this.data.clone()
|
||||||
.run(function(){
|
.run(function(){
|
||||||
|
var d = this
|
||||||
this.collection = collection
|
this.collection = collection
|
||||||
|
|
||||||
|
// save local tags...
|
||||||
|
Object.keys(local_tags)
|
||||||
|
.forEach(function(tag){
|
||||||
|
local_tags[tag] = (d.tags[tag] || []).slice() })
|
||||||
|
|
||||||
// optimization:
|
// optimization:
|
||||||
// avoid processing .tags as we'll
|
// avoid processing .tags as we'll
|
||||||
// overwrite them anyway later...
|
// overwrite them anyway later...
|
||||||
delete this.tags
|
delete this.tags
|
||||||
})
|
})
|
||||||
.clear('unloaded')),
|
.clear('unloaded')),
|
||||||
|
|
||||||
|
local_tags: local_tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode == 'crop' && this.crop_stack && depth != 0){
|
if(mode == 'crop' && this.crop_stack && depth != 0){
|
||||||
@ -554,6 +580,8 @@ var CollectionActions = actions.Actions({
|
|||||||
// is copied in as-is.
|
// is copied in as-is.
|
||||||
// It is the responsibility of the extending features to transform
|
// It is the responsibility of the extending features to transform
|
||||||
// their data on load as needed.
|
// their data on load as needed.
|
||||||
|
//
|
||||||
|
// XXX handle local_tags...
|
||||||
load: [function(json){
|
load: [function(json){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
@ -626,6 +654,8 @@ var CollectionActions = actions.Actions({
|
|||||||
// NOTE: currently this only stores title and data, it is the
|
// NOTE: currently this only stores title and data, it is the
|
||||||
// responsibility of extending features to store their specific
|
// responsibility of extending features to store their specific
|
||||||
// data in collections...
|
// data in collections...
|
||||||
|
//
|
||||||
|
// XXX handle local_tags...
|
||||||
json: [function(mode){ return function(res){
|
json: [function(mode){ return function(res){
|
||||||
mode = mode || 'current'
|
mode = mode || 'current'
|
||||||
|
|
||||||
@ -634,6 +664,11 @@ var CollectionActions = actions.Actions({
|
|||||||
// NOTE: if mode is 'current' ignore collections...
|
// NOTE: if mode is 'current' ignore collections...
|
||||||
if(mode != 'current' && collections){
|
if(mode != 'current' && collections){
|
||||||
var order = this.collection_order
|
var order = this.collection_order
|
||||||
|
// NOTE: .collection_order does not return MAIN_COLLECTION_TITLE
|
||||||
|
// so we have to add it in manually...
|
||||||
|
order = MAIN_COLLECTION_TITLE in collections ?
|
||||||
|
order.concat([MAIN_COLLECTION_TITLE])
|
||||||
|
: order
|
||||||
|
|
||||||
// in base mode save the main view as current...
|
// in base mode save the main view as current...
|
||||||
if(mode == 'base' && this.collection){
|
if(mode == 'base' && this.collection){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user