From 9e4ba0c86ead234c49ca38d8776ce488356e2cb0 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 2 Dec 2018 02:02:20 +0300 Subject: [PATCH] removed .tagged(..) + tweaking... Signed-off-by: Alex A. Naanou --- ui (gen4)/imagegrid/data.js | 20 ++++++++++++++++++- ui (gen4)/imagegrid/tags.js | 40 ++++++++++--------------------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/ui (gen4)/imagegrid/data.js b/ui (gen4)/imagegrid/data.js index dd041132..0191f792 100755 --- a/ui (gen4)/imagegrid/data.js +++ b/ui (gen4)/imagegrid/data.js @@ -3289,7 +3289,7 @@ var DataWithTags2Prototype = { return (this.__tags = this.__tags || new tags.Tags()) }, hasTag: function(gid, ...tags){ - return this.tags.tagged(this.getImage(gid), ...tags) }, + return this.tags.tags(this.getImage(gid), ...tags) }, getTags: function(gids){ var that = this gids = arguments.length > 1 ? [...arguments] @@ -3306,8 +3306,26 @@ var DataWithTags2Prototype = { }, tag: function(tags, gids){ + var that = this + gids = gids == null || gids == 'current' ? this.getImage() : gids + gids = gids instanceof Array ? gids : [gids] + + gids + .forEach(function(gid){ + this.tags.tag(tags, gid) }) + + return this }, untag: function(tags, gids){ + var that = this + gids = gids == null || gids == 'current' ? this.getImage() : gids + gids = gids instanceof Array ? gids : [gids] + + gids + .forEach(function(gid){ + this.tags.untag(tags, gid) }) + + return this }, toggleTag: function(){}, diff --git a/ui (gen4)/imagegrid/tags.js b/ui (gen4)/imagegrid/tags.js index f352761d..97c44b65 100755 --- a/ui (gen4)/imagegrid/tags.js +++ b/ui (gen4)/imagegrid/tags.js @@ -247,6 +247,10 @@ var TagsPrototype = { // XXX Q: should this be .normalizeTags(..) ??? normalize: function(...tags){ return this.constructor.normalize.call(this, ...tags) }, + // NOTE: the query parser is generic and thus is implemented in the + // constructor... + parseQuery: function(query){ + return this.constructor.parseQuery.call(this, query) }, // Match tags... // @@ -391,13 +395,13 @@ var TagsPrototype = { tags = tags.length == 1 && tags[0] instanceof Array ? tags.shift() : tags - // XXX is this the new version??? var u = this.tags(value) - return tags - .reduce(function(res, tag){ - return res === false ? - res - : that.match(tag, u).length > 0 }, true) + while(tags.length > 0){ + if(this.match(tags.shift(), u).length == 0){ + return false + } + } + return true // get tags of specific value... } else if(value){ @@ -456,26 +460,6 @@ var TagsPrototype = { } return false }, - // - // Check if value is tagged by tag/tags... - // .tagged(value, tag) - // .tagged(value, tag, ..) - // .tagged(value, [tag, ..]) - // -> bool - // - // XXX not sure if this is optimal... - tagged: function(value, ...tags){ - tags = tags.length == 1 && tags[0] instanceof Array ? - tags.shift() - : tags - var u = this.tags(value) - while(tags.length > 0){ - if(this.match(tags.shift(), u).length == 0){ - return false - } - } - return true - }, // Add/Remove/Modify tags API... @@ -646,10 +630,6 @@ var TagsPrototype = { __query_ns_special: { values: function(...args){ return args }, }, - // NOTE: the query parser is generic and thus is implemented in the - // constructor... - parseQuery: function(query){ - return this.constructor.parseQuery.call(this, query) }, // // Execute query... // .query(query)