removed .tagged(..) + tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-12-02 02:02:20 +03:00
parent 7426177b05
commit 9e4ba0c86e
2 changed files with 29 additions and 31 deletions

View File

@ -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(){},

View File

@ -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)