arma-server-web-admin/public/js/app/views/mods/list.js
Björn Dahlgren 5aa1a80c0e Filter mods
2022-09-04 22:48:30 +02:00

38 lines
978 B
JavaScript

var _ = require('underscore')
var Marionette = require('marionette')
var ListItemView = require('app/views/mods/list_item')
var tpl = require('tpl/mods/list.html')
var template = _.template(tpl)
module.exports = Marionette.CompositeView.extend({
childView: ListItemView,
childViewContainer: 'tbody',
template: template,
initialize: function (options) {
this.filterValue = options.filterValue
},
filter: function (child, index, collection) {
var name = child.get('name').toLowerCase()
if (name.indexOf(this.filterValue.toLowerCase()) >= 0) {
return true
}
var modFile = child.get('modFile')
if (modFile && modFile.name && modFile.name.toLowerCase().indexOf(this.filterValue.toLowerCase()) >= 0) {
return true
}
var steamMeta = child.get('steamMeta')
if (steamMeta && steamMeta.name && steamMeta.name.toLowerCase().indexOf(this.filterValue.toLowerCase()) >= 0) {
return true
}
return false
}
})