diff --git a/ui (gen4)/features/collections.js b/ui (gen4)/features/collections.js index 628b713b..74cd7607 100755 --- a/ui (gen4)/features/collections.js +++ b/ui (gen4)/features/collections.js @@ -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... diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index f6881634..f485e13f 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -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') }) }) diff --git a/ui (gen4)/imagegrid/data.js b/ui (gen4)/imagegrid/data.js index bb7de218..9cf1239e 100755 --- a/ui (gen4)/imagegrid/data.js +++ b/ui (gen4)/imagegrid/data.js @@ -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(){ diff --git a/ui (gen4)/imagegrid/formats.js b/ui (gen4)/imagegrid/formats.js index ed9e7e4d..ccf5d1db 100755 --- a/ui (gen4)/imagegrid/formats.js +++ b/ui (gen4)/imagegrid/formats.js @@ -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 }) diff --git a/ui (gen4)/imagegrid/tags.js b/ui (gen4)/imagegrid/tags.js index 38377fc2..7230d354 100755 --- a/ui (gen4)/imagegrid/tags.js +++ b/ui (gen4)/imagegrid/tags.js @@ -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()