Added a progress bar to the i18n home view. Sorting models by completion so documents needing translation go to the top.

This commit is contained in:
Scott Erickson 2014-10-28 11:28:31 -07:00
parent 7477633909
commit e5ea4f70e9
2 changed files with 15 additions and 1 deletions

View file

@ -1,6 +1,9 @@
extends /templates/base
block content
.progress
.progress-bar.progress-bar-info(role="progressbar" aria-valuenow=progress aria-valuemin="0" aria-valuemax="100" style="width: "+progress+"%")= progress+"%"
table.table.table-condensed
tr
th

View file

@ -23,6 +23,11 @@ module.exports = class I18NHomeView extends RootView
#-
@aggregateModels = new Backbone.Collection()
@aggregateModels.comparator = (m) ->
return 2 if m.specificallyCovered
return 1 if m.generallyCovered
return 0
project = ['name', 'components.original', 'i18nCoverage', 'slug']
@thangTypes = new CocoCollection([], { url: '/db/thang.type?view=i18n-coverage', project: project, model: ThangType })
@ -58,6 +63,11 @@ module.exports = class I18NHomeView extends RootView
c.languages = languages
c.selectedLanguage = @selectedLanguage
c.collection = @aggregateModels
covered = (m for m in @aggregateModels.models when m.specificallyCovered).length
total = @aggregateModels.models.length
c.progress = if total then parseInt(100 * covered / total) else 100
c
updateCoverage: ->
@ -66,7 +76,8 @@ module.exports = class I18NHomeView extends RootView
for model in @aggregateModels.models
@updateCoverageForModel(model, relatedLanguages)
model.generallyCovered = true if @selectedLanguage.startsWith 'en'
@aggregateModels.sort()
updateCoverageForModel: (model, relatedLanguages) ->
model.specificallyCovered = true
model.generallyCovered = true