mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
more post-tag-migration fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
b6e0867f44
commit
64095d10b5
@ -2034,17 +2034,20 @@ module.CollectionTags = core.ImageGridFeatures.Feature({
|
||||
function(_, gids, title){
|
||||
var that = this
|
||||
var local_tag_names = this.config['collection-local-tags'] || []
|
||||
gids = gids || this.current
|
||||
gids = gids instanceof Array ? gids : [gids]
|
||||
|
||||
// prevent global tag removal...
|
||||
var tags = this.data.tags
|
||||
delete this.data.tags
|
||||
var tags = this.data.tags.__index
|
||||
// XXX do we need this??? (leftover from prev tak implementation)
|
||||
//delete this.data.tags
|
||||
|
||||
return function(){
|
||||
// update local tags...
|
||||
local_tag_names.forEach(function(tag){
|
||||
tags[tag] = that.data.makeSparseImages(tags[tag], true) })
|
||||
tags[tag] = tags[tag].subtract(gids) })
|
||||
|
||||
this.data.tags = tags
|
||||
//this.data.tags.__index = tags
|
||||
}
|
||||
}],
|
||||
// save .local_tags to json...
|
||||
|
||||
@ -396,6 +396,8 @@ var FileSystemLoaderActions = actions.Actions({
|
||||
that.loadOrRecover(index)
|
||||
.then(function(){
|
||||
force_full_save
|
||||
// XXX remove as soon as merged index save is done...
|
||||
&& loaded.length == 1
|
||||
&& that.markChanged('all')
|
||||
})
|
||||
})
|
||||
|
||||
@ -3557,7 +3557,7 @@ var DataWithTags2Prototype = {
|
||||
// XXX test...
|
||||
split: function(){
|
||||
var res = DataWithTags2Prototype.__proto__.split.apply(this, arguments)
|
||||
res.tags = res.tags.filter(res.order)
|
||||
res.tags = res.tags.keep(res.order)
|
||||
return res
|
||||
},
|
||||
clone: function(){
|
||||
|
||||
@ -42,7 +42,6 @@ function(data){
|
||||
module.VERSIONS['2.0'] =
|
||||
function(data, cmp){
|
||||
//data = data.version < '2.0' ? module.VERSIONS['2.0'](data) : data
|
||||
console.log('Updating data to: ', '2.0')
|
||||
|
||||
var res = {
|
||||
data: {
|
||||
@ -103,8 +102,6 @@ function(data){
|
||||
|
||||
var res = {}
|
||||
res.version = '3.0'
|
||||
console.log('Updating data to: ', res.version)
|
||||
|
||||
res.current = data.current
|
||||
res.order = data.order.slice()
|
||||
res.ribbon_order = data.ribbon_order == null ? [] : data.ribbon_order.slice()
|
||||
@ -137,7 +134,6 @@ function(data){
|
||||
var res = data.version < '3.0' ? module.VERSIONS['3.0'](data) : data
|
||||
|
||||
res.version = '3.1'
|
||||
console.log('Updating data to: ', res.version)
|
||||
|
||||
data.tags
|
||||
&& (res.tags = { tags: data.tags })
|
||||
|
||||
@ -633,6 +633,60 @@ var TagsPrototype = {
|
||||
: null) }) },
|
||||
|
||||
|
||||
// Tag set/list API...
|
||||
//
|
||||
// XXX should this be join or add???
|
||||
join: function(...others){
|
||||
var that = this
|
||||
var index = this.__index || {}
|
||||
others
|
||||
.forEach(function(other){
|
||||
Object.entries(other.__index || {})
|
||||
.forEach(function(e){
|
||||
index[e[0]] = new Set([...(index[e[0]] || []), ...e[1]]) }) })
|
||||
Object.keys(index).length > 0
|
||||
&& this.__index == null
|
||||
&& (this.__index = index)
|
||||
return this
|
||||
},
|
||||
// Keep only the given values...
|
||||
//
|
||||
// .keep(value, ..)
|
||||
// .keep([value, ..])
|
||||
// -> this
|
||||
//
|
||||
keep: function(...values){
|
||||
values = (values.length == 1 && values[0] instanceof Array) ?
|
||||
values.pop()
|
||||
: values
|
||||
var res = this.clone()
|
||||
|
||||
Object.entries(res.__index || {})
|
||||
.forEach(function(e){
|
||||
res.__index[e[0]] = e[1].intersect(values) })
|
||||
|
||||
return res
|
||||
},
|
||||
// Remove the given values...
|
||||
//
|
||||
// .remove(value, ..)
|
||||
// .remove([value, ..])
|
||||
// -> this
|
||||
//
|
||||
remove: function(...values){
|
||||
values = (values.length == 1 && values[0] instanceof Array) ?
|
||||
values.pop()
|
||||
: values
|
||||
var res = this.clone()
|
||||
|
||||
Object.entries(res.__index || {})
|
||||
.forEach(function(e){
|
||||
res.__index[e[0]] = e[1].subtract(values) })
|
||||
|
||||
return res
|
||||
},
|
||||
|
||||
|
||||
// Query API...
|
||||
//
|
||||
// The language (JS):
|
||||
@ -752,30 +806,6 @@ var TagsPrototype = {
|
||||
},
|
||||
|
||||
|
||||
join: function(...others){
|
||||
var that = this
|
||||
var index = this.__index || {}
|
||||
others
|
||||
.forEach(function(other){
|
||||
Object.entries(other.__index || {})
|
||||
.forEach(function(e){
|
||||
index[e[0]] = new Set([...(index[e[0]] || []), ...e[1]]) }) })
|
||||
Object.keys(index).length > 0
|
||||
&& this.__index == null
|
||||
&& (this.__index = index)
|
||||
return this
|
||||
},
|
||||
// XXX create a new tagset with only the given values...
|
||||
// XXX this should support a function...
|
||||
filter: function(values){
|
||||
var res = this.clone()
|
||||
Object.values(res.__index || {})
|
||||
.forEach(function(s){
|
||||
values.forEach(function(v){ s.delete(v) }) })
|
||||
return res
|
||||
},
|
||||
|
||||
|
||||
// Object utility API...
|
||||
//
|
||||
// .clone()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user