mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	started new tags integration (experementing)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									fcd670cf8b
								
							
						
					
					
						commit
						67901ddc56
					
				| @ -16,6 +16,7 @@ var sha1 = require('ext-lib/sha1') | |||||||
| 
 | 
 | ||||||
| var object = require('lib/object') | var object = require('lib/object') | ||||||
| 
 | 
 | ||||||
|  | var tags = require('imagegrid/tags') | ||||||
| var formats = require('imagegrid/formats') | var formats = require('imagegrid/formats') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -3280,6 +3281,50 @@ var DataWithTagsPrototype = { | |||||||
| DataWithTagsPrototype.__proto__ = DataPrototype | DataWithTagsPrototype.__proto__ = DataPrototype | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // XXX use tags...
 | ||||||
|  | var DataWithTags2Prototype = { | ||||||
|  | 	__proto__: DataPrototype, | ||||||
|  | 
 | ||||||
|  | 	get tags(){ | ||||||
|  | 		return (this.__tags = this.__tags || new tags.Tags()) }, | ||||||
|  | 
 | ||||||
|  | 	hasTag: function(gid, ...tags){ | ||||||
|  | 		return this.tags.tagged(this.getImage(gid), ...tags) }, | ||||||
|  | 	getTags: function(gids){ | ||||||
|  | 		var that = this | ||||||
|  | 		gids = arguments.length > 1 ? [...arguments]  | ||||||
|  | 			: gids == null || gids == 'current' ? this.getImage()  | ||||||
|  | 			: gids | ||||||
|  | 		gids = gids == null ? [] : gids | ||||||
|  | 		gids = gids instanceof Array ? gids : [gids] | ||||||
|  | 
 | ||||||
|  | 		return gids | ||||||
|  | 			.map(function(gid){ | ||||||
|  | 				return that.tags.tags(gid) }) | ||||||
|  | 			.flat() | ||||||
|  | 			.unique() | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  | 	tag: function(tags, gids){ | ||||||
|  | 	}, | ||||||
|  | 	untag: function(tags, gids){ | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  | 	toggleTag: function(){}, | ||||||
|  | 
 | ||||||
|  | 	// XXX should these be .tags.query(..) ???
 | ||||||
|  | 	tagQuery: function(query){}, | ||||||
|  | 
 | ||||||
|  | 	// Utils...
 | ||||||
|  | 	tagsFromImages: function(){}, | ||||||
|  | 	tagsToImages: function(){}, | ||||||
|  | 
 | ||||||
|  | 	// XXX serialization...
 | ||||||
|  | 
 | ||||||
|  | 	// XXX init...
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -436,6 +436,25 @@ var TagsPrototype = { | |||||||
| 		} | 		} | ||||||
| 		return false | 		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){ | ||||||
|  | 		var that = this | ||||||
|  | 		tags = tags.length == 1 && tags[0] instanceof Array ? | ||||||
|  | 			tags.shift() | ||||||
|  | 			: tags | ||||||
|  | 		return tags | ||||||
|  | 			.reduce(function(res, tag){  | ||||||
|  | 				return res === false ? | ||||||
|  | 					res | ||||||
|  | 					// XXX do not like the back and forth set conversion here... 
 | ||||||
|  | 					: new Set(that.values(tag)).has(value) }, true) }, | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// Add/Remove/Modify tags API...
 | 	// Add/Remove/Modify tags API...
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user