This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BusinessUnitsView extends MIBaseView | |
events: | |
'click #generate': "generate" | |
generate: (e) => | |
e.preventDefault() | |
identifiers = _.map( $('input:checked'), (check) -> | |
{Uid: $(check).val(), Title: $(check).parents("tr:eq(0)").find("label").html()} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App | |
init: -> | |
vent = _.extend({}, Backbone.Events) | |
businessUnitsView = new BusinessUnitsView({vent: vent, el: $('#businessUnits')}) | |
managementView = new ManagementReportView({vent: vent, el: $('#managementReport')}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BusinessUnitsView extends MIBaseView | |
initialize: (options) -> | |
@vent = options.vent | |
options.vent.bind('showBusinessUnits', @showBusinessUnits) | |
events: | |
'click #generate': "generate" | |
generate: (e) => | |
e.preventDefault() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ManagementReportView extends MIBaseView | |
initialize: (options) -> | |
options.vent.bind("reportbusinessunitview:unload", @onClose) | |
options.vent.bind("reportbusinessunitview:load", @load) | |
@vent = options.vent | |
load: (businessUnits) => | |
@collection = businessUnits | |
@collection.bind 'reset', @render | |
@collection.fetch() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BusinessUnit extends Backbone.Model | |
class BusinessUnits extends Backbone.Collection | |
model: BusinessUnit | |
url: -> | |
"#{_getBusinessUnitScores}#{@getUids()}" | |
getUids: -> | |
@pluck("Uid").join(',') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReportBusinessUnitView extends MIBaseView | |
initialize: (options) -> | |
@vent = options.vent | |
@template = _.template($('#businessunit_template').html()) | |
events: | |
"click .individualBu": "showBusinessUnitDetail" | |
showBusinessUnitDetail: (e) => | |
e.preventDefault() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/template" id="businessunit_template"> | |
<tr data-uid="{{Uid}}"> | |
<td class="first"><span>{{Name}}</span></td> | |
<td class="{{StatusClass}} tac">{{OverallScore}}%</td> | |
<td> | |
<a class="impactanalysis individualBu" href="#"> </a> | |
</td> | |
</tr> | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseView | |
constructor: (options) -> | |
@bindings = [] | |
Backbone.View.apply(@, [options]) | |
_.extend(BaseView.prototype, Backbone.View.prototype, { | |
bindTo: (model, ev, callback) -> | |
model.bind(ev, callback, @) | |
@bindings.push({model: model, ev: ev, callback: callback}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseView | |
constructor: (options) -> | |
Backbone.View.apply(@, [options]) | |
_.extend(BaseView.prototype, Backbone.View.prototype, { | |
renderView: (el, func, view) -> | |
$.fn[func].call(el, view.render().el) | |
@views ||= [] | |
@views.push view |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unbindFromAll: -> | |
_.each(@bindings, (binding) -> | |
binding.model.unbind(binding.ev, binding.callback) | |
) | |
@bindings = [] | |
dispose: () -> | |
@disposeViews() | |
@unbindFromAll() |