Added i18nCoverage backend support.
This commit is contained in:
parent
36ea415dbf
commit
0dc050abca
7 changed files with 26 additions and 1 deletions
app
server
|
@ -284,6 +284,7 @@ class CocoModel extends Backbone.Model
|
||||||
if schema.items and _.isArray data
|
if schema.items and _.isArray data
|
||||||
sum += @populateI18N(value, schema.items, path+'/'+index) for value, index in data
|
sum += @populateI18N(value, schema.items, path+'/'+index) for value, index in data
|
||||||
|
|
||||||
|
@updateI18NCoverage()
|
||||||
sum
|
sum
|
||||||
|
|
||||||
@getReferencedModel: (data, schema) ->
|
@getReferencedModel: (data, schema) ->
|
||||||
|
|
|
@ -253,6 +253,7 @@ c.extendSearchableProperties LevelSchema
|
||||||
c.extendVersionedProperties LevelSchema, 'level'
|
c.extendVersionedProperties LevelSchema, 'level'
|
||||||
c.extendPermissionsProperties LevelSchema, 'level'
|
c.extendPermissionsProperties LevelSchema, 'level'
|
||||||
c.extendPatchableProperties LevelSchema
|
c.extendPatchableProperties LevelSchema
|
||||||
|
c.extendTranslationCoverageProperties LevelSchema
|
||||||
|
|
||||||
module.exports = LevelSchema
|
module.exports = LevelSchema
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,10 @@ me.getLanguageCodeArray = ->
|
||||||
return Language.languageCodes
|
return Language.languageCodes
|
||||||
|
|
||||||
me.getLanguagesObject = -> return Language
|
me.getLanguagesObject = -> return Language
|
||||||
|
|
||||||
|
me.extendTranslationCoverageProperties = (schema) ->
|
||||||
|
schema.properties = {} unless schema.properties?
|
||||||
|
schema.properties.i18nCoverage = { title: 'i18n Coverage', type: 'array', items: { type: 'string' }}
|
||||||
|
|
||||||
# OTHER
|
# OTHER
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ LevelSchema.plugin(plugins.PermissionsPlugin)
|
||||||
LevelSchema.plugin(plugins.VersionedPlugin)
|
LevelSchema.plugin(plugins.VersionedPlugin)
|
||||||
LevelSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']})
|
LevelSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']})
|
||||||
LevelSchema.plugin(plugins.PatchablePlugin)
|
LevelSchema.plugin(plugins.PatchablePlugin)
|
||||||
|
LevelSchema.plugin(plugins.TranslationCoveragePlugin)
|
||||||
|
|
||||||
LevelSchema.post 'init', (doc) ->
|
LevelSchema.post 'init', (doc) ->
|
||||||
if _.isString(doc.get('nextLevel'))
|
if _.isString(doc.get('nextLevel'))
|
||||||
|
|
|
@ -9,5 +9,6 @@ ThangTypeSchema.plugin plugins.NamedPlugin
|
||||||
ThangTypeSchema.plugin plugins.VersionedPlugin
|
ThangTypeSchema.plugin plugins.VersionedPlugin
|
||||||
ThangTypeSchema.plugin plugins.SearchablePlugin, {searchable: ['name']}
|
ThangTypeSchema.plugin plugins.SearchablePlugin, {searchable: ['name']}
|
||||||
ThangTypeSchema.plugin plugins.PatchablePlugin
|
ThangTypeSchema.plugin plugins.PatchablePlugin
|
||||||
|
ThangTypeSchema.plugin plugins.TranslationCoveragePlugin
|
||||||
|
|
||||||
module.exports = mongoose.model('thang.type', ThangTypeSchema)
|
module.exports = mongoose.model('thang.type', ThangTypeSchema)
|
||||||
|
|
|
@ -35,6 +35,7 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
|
||||||
'rasterIcon'
|
'rasterIcon'
|
||||||
'featureImage'
|
'featureImage'
|
||||||
'spriteType'
|
'spriteType'
|
||||||
|
'i18nCoverage'
|
||||||
]
|
]
|
||||||
|
|
||||||
hasAccess: (req) ->
|
hasAccess: (req) ->
|
||||||
|
|
|
@ -281,7 +281,7 @@ module.exports.SearchablePlugin = (schema, options) ->
|
||||||
|
|
||||||
searchable = options.searchable
|
searchable = options.searchable
|
||||||
unless searchable
|
unless searchable
|
||||||
throw Error('SearchablePlugin options must include list of searchable properties.')
|
throw new Error('SearchablePlugin options must include list of searchable properties.')
|
||||||
|
|
||||||
index = {}
|
index = {}
|
||||||
|
|
||||||
|
@ -307,3 +307,19 @@ module.exports.SearchablePlugin = (schema, options) ->
|
||||||
@index = @getOwner() unless access
|
@index = @getOwner() unless access
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|
||||||
|
module.exports.TranslationCoveragePlugin = (schema, options) ->
|
||||||
|
|
||||||
|
schema.uses_coco_translation_coverage = true
|
||||||
|
schema.set('autoIndex', true)
|
||||||
|
|
||||||
|
index = {}
|
||||||
|
|
||||||
|
if schema.uses_coco_versions
|
||||||
|
if not schema.uses_coco_names
|
||||||
|
throw Error('If using translation coverage and versioning, should also use names for indexing.')
|
||||||
|
index.slug = 1
|
||||||
|
|
||||||
|
index.i18nCoverage = 1
|
||||||
|
|
||||||
|
schema.index(index, {sparse: true, name: 'translation coverage index', background: true})
|
Reference in a new issue