2016-10-02 17:58:37 +08:00
|
|
|
import _ from 'lodash'
|
|
|
|
import Backbone from 'backbone'
|
2016-10-03 08:32:37 +08:00
|
|
|
try { Backbone.$ = window.$ } catch (err) {}
|
2016-10-02 17:58:37 +08:00
|
|
|
import outdent from 'outdent'
|
|
|
|
|
|
|
|
const Mapper = Backbone.Model.extend({
|
|
|
|
urlRoot: '/users',
|
|
|
|
blacklist: ['created_at', 'updated_at'],
|
2016-11-07 15:25:08 -05:00
|
|
|
toJSON: function(options) {
|
2016-10-02 17:58:37 +08:00
|
|
|
return _.omit(this.attributes, this.blacklist)
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
prepareLiForFilter: function() {
|
2016-10-02 17:58:37 +08:00
|
|
|
return outdent`
|
|
|
|
<li data-id="${this.id}">
|
|
|
|
<img src="${this.get('image')}" data-id="${this.id}" alt="${this.get('name')}" />
|
|
|
|
<p>${this.get('name')}</p>
|
|
|
|
</li>`
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export default Mapper
|