1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Generated by CoffeeScript 1.6.3
(function() {
requirejs.config({
baseUrl: "" + baseUrl + "/javascripts",
paths: {
'jquery': 'third-party/jquery',
'backbone': 'third-party/backbone',
'backbone.marionette': 'third-party/backbone.marionette',
'handlebars': 'third-party/handlebars',
'moment': 'third-party/moment',
'select-list': 'common/select-list'
},
shim: {
'backbone.marionette': {
deps: ['backbone'],
exports: 'Marionette'
},
'backbone': {
exports: 'Backbone'
},
'handlebars': {
exports: 'Handlebars'
},
'moment': {
exports: 'moment'
},
'select-list': {
exports: 'SelectList'
}
}
});
requirejs(['backbone', 'backbone.marionette', 'handlebars', 'quality-gate/collections/quality-gates', 'quality-gate/collections/metrics', 'quality-gate/views/quality-gate-sidebar-list-view', 'quality-gate/views/quality-gate-actions-view', 'quality-gate/views/quality-gate-edit-view', 'quality-gate/router', 'quality-gate/layout', 'common/handlebars-extensions'], function(Backbone, Marionette, Handlebars, QualityGates, Metrics, QualityGateSidebarListItemView, QualityGateActionsView, QualityGateEditView, QualityGateRouter, QualityGateLayout) {
var App, appXHR, qualityGatesXHR,
_this = this;
jQuery.ajaxSetup({
error: function(jqXHR) {
var errorBox, text, _ref;
text = jqXHR.responseText;
errorBox = jQuery('.modal-error');
if (((_ref = jqXHR.responseJSON) != null ? _ref.errors : void 0) != null) {
text = _.pluck(jqXHR.responseJSON.errors, 'msg').join('. ');
}
if (errorBox.length > 0) {
return errorBox.show().text(text);
} else {
return alert(text);
}
}
});
jQuery('html').addClass('navigator-page quality-gates-page');
App = new Marionette.Application;
App.metrics = new Metrics;
App.qualityGates = new QualityGates;
App.openFirstQualityGate = function() {
if (this.qualityGates.length > 0) {
return this.router.navigate("show/" + (this.qualityGates.models[0].get('id')), {
trigger: true
});
} else {
return App.layout.detailsRegion.reset();
}
};
App.deleteQualityGate = function(id) {
App.qualityGates.remove(id);
return App.openFirstQualityGate();
};
App.unsetDefaults = function(id) {
return App.qualityGates.each(function(gate) {
if (gate.id !== id) {
return gate.set('default', false);
}
});
};
App.addInitializer(function() {
this.layout = new QualityGateLayout({
app: this
});
return jQuery('body').append(this.layout.render().el);
});
App.addInitializer(function() {
this.qualityGateActionsView = new QualityGateActionsView({
app: this
});
return this.layout.actionsRegion.show(this.qualityGateActionsView);
});
App.addInitializer(function() {
this.qualityGateSidebarListView = new QualityGateSidebarListItemView({
collection: this.qualityGates,
app: this
});
return this.layout.listRegion.show(this.qualityGateSidebarListView);
});
App.addInitializer(function() {
this.qualityGateEditView = new QualityGateEditView({
app: this
});
return this.qualityGateEditView.render();
});
App.addInitializer(function() {
this.router = new QualityGateRouter({
app: this
});
return Backbone.history.start();
});
App.addInitializer(function() {
var initial;
initial = Backbone.history.fragment === '';
if (initial) {
return App.openFirstQualityGate();
}
});
appXHR = jQuery.ajax({
url: "" + baseUrl + "/api/qualitygates/app"
}).done(function(r) {
App.canEdit = r.edit;
App.periods = r.periods;
return window.messages = r.messages;
});
qualityGatesXHR = App.qualityGates.fetch();
return jQuery.when(App.metrics.fetch(), qualityGatesXHR, appXHR).done(function() {
jQuery('.quality-gate-page-loader').remove();
return App.start();
});
});
}).call(this);
|