voluntary 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -1
- data/app/assets/javascripts/voluntary/lib/jquery-competitive_list.js +533 -0
- data/app/controllers/comments_controller.rb +1 -3
- data/app/controllers/concerns/voluntary/v1/base_controller.rb +1 -5
- data/app/controllers/home_controller.rb +0 -1
- data/app/controllers/workflow/project_owner_controller.rb +17 -15
- data/app/controllers/workflow/tasks_controller.rb +1 -1
- data/app/models/ability.rb +3 -7
- data/app/models/comment.rb +1 -1
- data/app/models/product/music_metadata_enrichment.rb +2 -0
- data/app/models/product.rb +0 -27
- data/app/models/project.rb +0 -1
- data/app/models/project_user.rb +2 -3
- data/app/models/user.rb +4 -3
- data/app/views/layouts/application.html.erb +0 -4
- data/app/views/layouts/shared/_flash_messages.html.erb +2 -2
- data/app/views/workflow/project_owner/index.html.erb +7 -7
- data/config/locales/en.yml +1 -2
- data/config/locales/general/en.yml +2 -8
- data/config/locales/workflow/en.yml +1 -5
- data/config/routes/workflow.rb +0 -25
- data/config/routes.rb +0 -35
- data/db/migrate/20131018143613_replace_user_by_polymorphic_resource_in_candidatures.rb +4 -4
- data/db/migrate/20150802141840_drop_recruiting_unless_recruiting_plugin_present.rb +59 -0
- data/lib/generators/voluntary/install/templates/features/support/paths.rb +0 -14
- data/lib/generators/voluntary/product_dummy/templates/config/main_navigation.rb +1 -260
- data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_steps.rb +1 -1
- data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/custom_web_steps.rb +5 -0
- data/lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_controller.rb +1 -1
- data/lib/generators/voluntary/product_dummy/templates/features/support/paths.rb +0 -14
- data/lib/voluntary/navigation.rb +34 -74
- data/lib/voluntary/test/rspec_helpers/factories.rb +10 -17
- data/lib/voluntary/version.rb +1 -1
- data/lib/voluntary.rb +1 -2
- metadata +37 -44
- data/app/assets/javascripts/voluntary/lib/competitive_list.js +0 -484
- data/app/controllers/candidatures_controller.rb +0 -84
- data/app/controllers/vacancies_controller.rb +0 -88
- data/app/controllers/workflow/candidatures_controller.rb +0 -20
- data/app/controllers/workflow/vacancies_controller.rb +0 -17
- data/app/models/candidature.rb +0 -38
- data/app/models/state_machines/candidature.rb +0 -64
- data/app/models/state_machines/vacancy.rb +0 -49
- data/app/models/vacancy.rb +0 -43
- data/app/views/candidatures/_form.html.erb +0 -13
- data/app/views/candidatures/edit.html.erb +0 -3
- data/app/views/candidatures/index.html.erb +0 -11
- data/app/views/candidatures/new.html.erb +0 -3
- data/app/views/candidatures/show.html.erb +0 -18
- data/app/views/vacancies/_form.html.erb +0 -15
- data/app/views/vacancies/edit.html.erb +0 -3
- data/app/views/vacancies/index.html.erb +0 -7
- data/app/views/vacancies/new.html.erb +0 -3
- data/app/views/vacancies/show.html.erb +0 -15
- data/app/views/workflow/project_owner/_candidatures.html.erb +0 -32
- data/app/views/workflow/project_owner/_vacancies.html.erb +0 -27
- data/config/locales/resources/candidature/en.yml +0 -19
- data/config/locales/resources/vacancy/en.yml +0 -29
- data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/candidature_steps.rb +0 -34
- data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84618c24e02dcb9f224841b3bb6526e93f1bda6f
|
4
|
+
data.tar.gz: 1b6fe36335714062ee0fd318c3dd156caed931bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9867508b65ab5394f5ffa28c656820efab9f9d42aca93d4adbba19d02fc46f7029fdf3e7dd82ab1c1144b73eeff3a1c2a03c3085004b97788efaac0b97c5c6aa
|
7
|
+
data.tar.gz: 0b468d36ac2ac429aa34db0a4eaa87de902510f794fadfd32dcdfbe3d00ef1bc6209edd7c1a112d70ac559ea6fa1612ece31f2bedb9c1992053fe73696e0d0a9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## unreleased ##
|
2
2
|
|
3
|
+
## 0.4.0 (August 3, 2015) ##
|
4
|
+
|
5
|
+
* #47 Refactoring: outsource recruiting to voluntary_recruiting gemRefactoring: outsource recruiting to voluntary_recruiting gem.
|
6
|
+
* #81 Removes fork me on GitHub links.
|
7
|
+
* #80 Fixes twitter bootstrap style of flash messages.
|
8
|
+
* #79 Replace competitive_list.js by jquery-competitive_list.js.
|
9
|
+
* Removes Capistrano as a dependency.
|
10
|
+
* Introduction of User.by_slug_or_id.
|
11
|
+
|
3
12
|
## 0.3.0 (April 8, 2015) ##
|
4
13
|
|
5
14
|
* #40 Rails 4.2.1 upgrade.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Voluntary [![Build Status](https://travis-ci.org/volontariat/voluntary.svg?branch=master)](https://travis-ci.org/volontariat/voluntary) [![Code Climate](https://codeclimate.com/github/volontariat/voluntary/badges/gpa.svg)](https://codeclimate.com/github/volontariat/voluntary) [![Test Coverage](https://codeclimate.com/github/volontariat/voluntary/badges/coverage.svg)](https://codeclimate.com/github/volontariat/voluntary)
|
1
|
+
# Voluntary [![Build Status](https://travis-ci.org/volontariat/voluntary.svg?branch=master)](https://travis-ci.org/volontariat/voluntary) [![Code Climate](https://codeclimate.com/github/volontariat/voluntary/badges/gpa.svg)](https://codeclimate.com/github/volontariat/voluntary) [![Test Coverage](https://codeclimate.com/github/volontariat/voluntary/badges/coverage.svg)](https://codeclimate.com/github/volontariat/voluntary) [![Dependency Status](https://gemnasium.com/volontariat/voluntary.png)](https://gemnasium.com/volontariat/voluntary)
|
2
2
|
|
3
3
|
This is a gem which turns your rails application into a crowdsourcing platform to run on your intranet or on the internet.
|
4
4
|
|
@@ -0,0 +1,533 @@
|
|
1
|
+
(function() {
|
2
|
+
(function($, window) {
|
3
|
+
var CompetitiveList;
|
4
|
+
CompetitiveList = CompetitiveList = (function() {
|
5
|
+
CompetitiveList.prototype.jqueryInstanceMethodName = 'competitiveList';
|
6
|
+
|
7
|
+
CompetitiveList.prototype.defaults = {};
|
8
|
+
|
9
|
+
CompetitiveList.prototype.id = null;
|
10
|
+
|
11
|
+
CompetitiveList.prototype.competitors = [];
|
12
|
+
|
13
|
+
CompetitiveList.prototype.competitorsOfCompetitor = {};
|
14
|
+
|
15
|
+
CompetitiveList.prototype.defeatedCompetitorsByCompetitor = {};
|
16
|
+
|
17
|
+
CompetitiveList.prototype.outmatchedCompetitorsByCompetitor = {};
|
18
|
+
|
19
|
+
CompetitiveList.prototype.matches = [];
|
20
|
+
|
21
|
+
CompetitiveList.prototype.matchesLeft = 0;
|
22
|
+
|
23
|
+
CompetitiveList.prototype.currentMatch = null;
|
24
|
+
|
25
|
+
CompetitiveList.prototype.currentMatchIndex = 0;
|
26
|
+
|
27
|
+
CompetitiveList.prototype.currentAutoWinnerMatches = [];
|
28
|
+
|
29
|
+
CompetitiveList.prototype.movingCompetitorToPosition = false;
|
30
|
+
|
31
|
+
function CompetitiveList(el, options) {
|
32
|
+
if (el) {
|
33
|
+
this.init(el, options);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
CompetitiveList.prototype.init = function(el, options) {
|
38
|
+
this.options = $.extend({}, this.defaults, options);
|
39
|
+
this.$el = $(el);
|
40
|
+
this.id = this.$el.attr('id');
|
41
|
+
$.data(el, this.constructor.prototype.jqueryInstanceMethodName, this);
|
42
|
+
this.$el.find('.competitive_list_start_link').on('click', (function(_this) {
|
43
|
+
return function(event) {
|
44
|
+
event.preventDefault();
|
45
|
+
return _this.start();
|
46
|
+
};
|
47
|
+
})(this));
|
48
|
+
this.$el.find('.save_match_results_link').on('click', (function(_this) {
|
49
|
+
return function(event) {
|
50
|
+
event.preventDefault();
|
51
|
+
_this.sortByMostWins();
|
52
|
+
return _this.$el.find('.save_match_results_link').hide();
|
53
|
+
};
|
54
|
+
})(this));
|
55
|
+
$(document.body).on('click', '#bootstrap_modal .cancel_tournament_button', (function(_this) {
|
56
|
+
return function(event) {
|
57
|
+
event.preventDefault();
|
58
|
+
return _this.cancelTournament();
|
59
|
+
};
|
60
|
+
})(this));
|
61
|
+
return $(document.body).on('click', '#bootstrap_modal .select_winner_button', (function(_this) {
|
62
|
+
return function(event) {
|
63
|
+
event.preventDefault();
|
64
|
+
return _this.appointWinnerOfMatchByInput();
|
65
|
+
};
|
66
|
+
})(this));
|
67
|
+
};
|
68
|
+
|
69
|
+
CompetitiveList.meaningOfLife = function() {
|
70
|
+
return 42;
|
71
|
+
};
|
72
|
+
|
73
|
+
CompetitiveList.prototype.start = function() {
|
74
|
+
var matchesAlreadyExist, matchesWithoutWinner;
|
75
|
+
matchesAlreadyExist = false;
|
76
|
+
this.matches || (this.matches = []);
|
77
|
+
if (this.matches.length > 0) {
|
78
|
+
matchesAlreadyExist = true;
|
79
|
+
}
|
80
|
+
this.setCompetitors();
|
81
|
+
this.competitorsOfCompetitor = {};
|
82
|
+
this.defeatedCompetitorsByCompetitor = {};
|
83
|
+
this.outmatchedCompetitorsByCompetitor = {};
|
84
|
+
if (matchesAlreadyExist) {
|
85
|
+
if (confirm('Remove previous results and start over?')) {
|
86
|
+
this.matches = [];
|
87
|
+
} else {
|
88
|
+
this.removeMatchesOfNonExistingCompetitors();
|
89
|
+
}
|
90
|
+
}
|
91
|
+
this.generateMatches();
|
92
|
+
matchesWithoutWinner = jQuery.map(this.matches, function(m) {
|
93
|
+
if (m['winner'] === void 0) {
|
94
|
+
return m;
|
95
|
+
}
|
96
|
+
});
|
97
|
+
this.matchesLeft = matchesWithoutWinner.length;
|
98
|
+
if (this.nextMatch(true)) {
|
99
|
+
return $('#bootstrap_modal').modal('show');
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
CompetitiveList.prototype.setCompetitors = function() {
|
104
|
+
return this.competitors = jQuery.map(this.$el.find('.competitive_list li'), function(c) {
|
105
|
+
return $(c).data('id');
|
106
|
+
});
|
107
|
+
};
|
108
|
+
|
109
|
+
CompetitiveList.prototype.removeMatchesOfNonExistingCompetitors = function() {
|
110
|
+
return $.each(this.matches, (function(_this) {
|
111
|
+
return function(index, match) {
|
112
|
+
var base, base1, loserId, name, name1, notExistingCompetitors;
|
113
|
+
notExistingCompetitors = jQuery.map(match['competitors'], function(c) {
|
114
|
+
if ($.inArray(c, _this.competitors) === -1) {
|
115
|
+
return c;
|
116
|
+
}
|
117
|
+
});
|
118
|
+
if (notExistingCompetitors.length > 0) {
|
119
|
+
return _this.matches = _this.removeItemFromArray(_this.matches, match);
|
120
|
+
} else {
|
121
|
+
(base = _this.competitorsOfCompetitor)[name = match['competitors'][0]] || (base[name] = []);
|
122
|
+
_this.competitorsOfCompetitor[match['competitors'][0]].push(match['competitors'][1]);
|
123
|
+
(base1 = _this.competitorsOfCompetitor)[name1 = match['competitors'][1]] || (base1[name1] = []);
|
124
|
+
_this.competitorsOfCompetitor[match['competitors'][1]].push(match['competitors'][0]);
|
125
|
+
if (match['winner'] !== void 0) {
|
126
|
+
loserId = _this.otherCompetitorOfMatch(match, match['winner']);
|
127
|
+
return _this.updateDefeatedAndOutmatchedCompetitorsByCompetitor(match['winner'], loserId);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
};
|
131
|
+
})(this));
|
132
|
+
};
|
133
|
+
|
134
|
+
CompetitiveList.prototype.removeItemFromArray = function(array, item) {
|
135
|
+
var list;
|
136
|
+
list = [];
|
137
|
+
jQuery.each(array, function(index, workingItem) {
|
138
|
+
if (JSON.stringify(workingItem) !== JSON.stringify(item)) {
|
139
|
+
return list.push(workingItem);
|
140
|
+
}
|
141
|
+
});
|
142
|
+
return list;
|
143
|
+
};
|
144
|
+
|
145
|
+
CompetitiveList.prototype.generateMatches = function() {
|
146
|
+
return $.each(this.competitors, (function(_this) {
|
147
|
+
return function(index, competitorId) {
|
148
|
+
var base;
|
149
|
+
(base = _this.competitorsOfCompetitor)[competitorId] || (base[competitorId] = []);
|
150
|
+
return $.each(_this.competitors, function(index, otherCompetitorId) {
|
151
|
+
var base1;
|
152
|
+
(base1 = _this.competitorsOfCompetitor)[otherCompetitorId] || (base1[otherCompetitorId] = []);
|
153
|
+
if (competitorId !== otherCompetitorId && $.inArray(otherCompetitorId, _this.competitorsOfCompetitor[competitorId]) === -1) {
|
154
|
+
_this.matches.push({
|
155
|
+
competitors: [competitorId, otherCompetitorId]
|
156
|
+
});
|
157
|
+
_this.competitorsOfCompetitor[competitorId].push(otherCompetitorId);
|
158
|
+
return _this.competitorsOfCompetitor[otherCompetitorId].push(competitorId);
|
159
|
+
}
|
160
|
+
});
|
161
|
+
};
|
162
|
+
})(this));
|
163
|
+
};
|
164
|
+
|
165
|
+
CompetitiveList.prototype.nextMatch = function(from_start) {
|
166
|
+
var autoWinnerMatchesHtml, competitorStrings, html, i, modalBodyHtml, modalFooterHtml, modalTitle, radioButtons, rows;
|
167
|
+
autoWinnerMatchesHtml = '';
|
168
|
+
if (this.currentAutoWinnerMatches.length > 0) {
|
169
|
+
this.currentMatch = this.matches[this.currentMatchIndex];
|
170
|
+
rows = "";
|
171
|
+
$.each(this.currentAutoWinnerMatches, (function(_this) {
|
172
|
+
return function(index, match) {
|
173
|
+
var even_or_odd, manualWinnerChangedHtml;
|
174
|
+
even_or_odd = '';
|
175
|
+
if (index % 2 === 0) {
|
176
|
+
even_or_odd = 'even';
|
177
|
+
} else {
|
178
|
+
even_or_odd = 'odd';
|
179
|
+
}
|
180
|
+
manualWinnerChangedHtml = '';
|
181
|
+
if (match['manual_winner_changed'] === true) {
|
182
|
+
manualWinnerChangedHtml = "<a class=\"bootstrap_tooltip\" href=\"#\" data-toggle=\"tooltip\" title=\"The winner you once have set has been changed automatically!\">\n <i class='icon-warning-sign'/>\n</a>";
|
183
|
+
}
|
184
|
+
return rows += "<tr class=\"" + even_or_odd + "\">\n <td>\n " + manualWinnerChangedHtml + "\n </td>\n <td style=\"width:200px\">" + (_this.nameOfCompetitor(match['winner'], false)) + "</td>\n <td><input type=\"radio\" checked=\"checked\" disabled=\"disabled\"/></td>\n <td> VS. </td>\n <td><input type=\"radio\" disabled=\"disabled\"/></td>\n <td> </td>\n <td style=\"width:200px\">" + (_this.nameOfCompetitor(_this.otherCompetitorOfMatch(match, match['winner']), false)) + "</td>\n <td style=\"text-align:center\">\n <a class=\"bootstrap_tooltip\" href=\"#\" data-toggle=\"tooltip\" data-html=\"true\" title=\"" + match['auto_winner_reason'] + "\">\n <i class=\"icon-question-sign\"/>\n </a>\n </td>\n <td style=\"width:200px\">" + (_this.nameOfCompetitor(match['foot_note_competitor'], false)) + "</td>\n</tr> ";
|
185
|
+
};
|
186
|
+
})(this));
|
187
|
+
autoWinnerMatchesHtml = "<h4>Auto Winners due to Result of last Match</h4>\n<table>\n <tr>\n <td><strong>Last Match was: </strong></td>\n <td>" + (this.nameOfCompetitor(this.currentMatch['winner'], false)) + "</td>\n <td> <input type=\"radio\" checked=\"checked\" disabled=\"disabled\"/></td>\n <td> VS. </td>\n <td><input type=\"radio\" disabled=\"disabled\"/></td>\n <td> </td>\n <td>" + (this.nameOfCompetitor(this.otherCompetitorOfMatch(this.currentMatch, this.currentMatch['winner']), false)) + "</td>\n </tr>\n</table>\n<table class=\"table table-striped\">\n <thead>\n <tr class=\"odd\">\n <th></th>\n <th>Winner</th>\n <th></th>\n <th></th>\n <th></th>\n <th></th>\n <th>Loser</th>\n <th>Reason</th>\n <th>[1]</th>\n </tr>\n </thead>\n <tbody>\n " + rows + "\n </tbody>\n</table> ";
|
188
|
+
}
|
189
|
+
this.currentMatch = null;
|
190
|
+
$.each(this.matches, (function(_this) {
|
191
|
+
return function(index, match) {
|
192
|
+
if (match['winner'] === void 0) {
|
193
|
+
_this.currentMatch = match;
|
194
|
+
_this.currentMatchIndex = index;
|
195
|
+
return false;
|
196
|
+
}
|
197
|
+
};
|
198
|
+
})(this));
|
199
|
+
if (from_start === true && this.currentMatch === null) {
|
200
|
+
alert('No matches to rate left.');
|
201
|
+
return false;
|
202
|
+
} else {
|
203
|
+
this.$el.find('.save_match_results_link').show();
|
204
|
+
}
|
205
|
+
modalBodyHtml = '';
|
206
|
+
modalTitle = '';
|
207
|
+
modalFooterHtml = '';
|
208
|
+
if (this.currentMatch === null) {
|
209
|
+
modalTitle = 'No matches to rate left.';
|
210
|
+
modalFooterHtml = "<p>\n <button type=\"button\" class=\"cancel_tournament_button\" class=\"btn\">Save match results and close window</button>\n</p> ";
|
211
|
+
} else {
|
212
|
+
modalTitle = "Appoint Winner (" + this.matchesLeft + " matches left)";
|
213
|
+
radioButtons = [];
|
214
|
+
competitorStrings = [];
|
215
|
+
i = 0;
|
216
|
+
$.each(this.currentMatch['competitors'], (function(_this) {
|
217
|
+
return function(index, competitorId) {
|
218
|
+
var checked;
|
219
|
+
checked = ' checked="checked"';
|
220
|
+
if (i === 1) {
|
221
|
+
checked = '';
|
222
|
+
}
|
223
|
+
radioButtons.push('<input type="radio" ' + checked + ' name="winner" value="' + competitorId + '" style="position:relative; top:-5px "/>');
|
224
|
+
competitorStrings.push(_this.nameOfCompetitor(competitorId, true));
|
225
|
+
return i += 1;
|
226
|
+
};
|
227
|
+
})(this));
|
228
|
+
modalBodyHtml += "<div class=\"controls\" style=\"margin-left:50px\">\n <table>\n <tr> \n <td style=\"width:325px; text-align:right;\">\n " + competitorStrings[0] + "\n </td>\n <td> </td>\n <td>" + radioButtons[0] + "</td>\n <td> VS. </td>\n <td>" + radioButtons[1] + "</td>\n <td>\n \n </td>\n <td style=\"width:325px\">\n " + competitorStrings[1] + "\n </td>\n </tr>\n </table>\n</div> ";
|
229
|
+
modalFooterHtml = "<p>\n <button type=\"button\" class=\"cancel_tournament_button\" class=\"btn\">Save match results and close window</button> \n <button type=\"button\" class=\"select_winner_button\" class=\"btn btn-primary\">Submit</button>\n</p>";
|
230
|
+
}
|
231
|
+
modalBodyHtml += autoWinnerMatchesHtml;
|
232
|
+
html = "<form class=\"form-inline\" style=\"margin:0px;\">\n <div class=\"modal-header\">\n <button type=\"button\" id=\"close_bootstrap_modal_button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\">×</button>\n <h3>" + modalTitle + "</h3>\n </div>\n <div class=\"modal-body\" style=\"overflow-y:auto;\">\n " + modalBodyHtml + "\n </div>\n <div class=\"modal-footer\" style=\"text-align:left;\">\n " + modalFooterHtml + "\n </div>\n</form>";
|
233
|
+
$('#bootstrap_modal').html(html);
|
234
|
+
$('.bootstrap_tooltip').tooltip();
|
235
|
+
this.currentAutoWinnerMatches = [];
|
236
|
+
return true;
|
237
|
+
};
|
238
|
+
|
239
|
+
CompetitiveList.prototype.otherCompetitorOfMatch = function(match, competitorId) {
|
240
|
+
var otherCompetitors;
|
241
|
+
otherCompetitors = jQuery.map(match['competitors'], function(c) {
|
242
|
+
if (c !== competitorId) {
|
243
|
+
return c;
|
244
|
+
}
|
245
|
+
});
|
246
|
+
return otherCompetitors[0];
|
247
|
+
};
|
248
|
+
|
249
|
+
CompetitiveList.prototype.nameOfCompetitor = function(competitorId, considerProc) {
|
250
|
+
var competitorDomElement;
|
251
|
+
competitorDomElement = $('#competitor_' + competitorId);
|
252
|
+
if (considerProc === false || this.options['competitor_name_proc'] === void 0 || $(competitorDomElement).find('.competitor_name').data('proc-argument') === void 0) {
|
253
|
+
return $(competitorDomElement).find('.competitor_name').html();
|
254
|
+
} else {
|
255
|
+
return this.options['competitor_name_proc']($(competitorDomElement).find('.competitor_name').data('proc-argument'));
|
256
|
+
}
|
257
|
+
};
|
258
|
+
|
259
|
+
CompetitiveList.prototype.cancelTournament = function() {
|
260
|
+
this.sortByMostWins();
|
261
|
+
this.$el.find('.save_match_results_link').hide();
|
262
|
+
return $('#bootstrap_modal').modal('hide');
|
263
|
+
};
|
264
|
+
|
265
|
+
CompetitiveList.prototype.appointWinnerOfMatchByInput = function() {
|
266
|
+
var loserId, winnerId;
|
267
|
+
winnerId = parseInt($("input[name='winner']:checked").val());
|
268
|
+
loserId = this.otherCompetitorOfMatch(this.currentMatch, winnerId);
|
269
|
+
this.appointWinnerOfMatch(this.currentMatchIndex, winnerId, loserId, true);
|
270
|
+
return this.nextMatch(false);
|
271
|
+
};
|
272
|
+
|
273
|
+
CompetitiveList.prototype.appointWinnerOfMatch = function(matchIndex, winnerId, loserId, decrementMatchesLeft) {
|
274
|
+
if (this.movingCompetitorToPosition === true) {
|
275
|
+
delete this.matches[matchIndex]['manual_winner_changed'];
|
276
|
+
delete this.matches[matchIndex]['auto_winner'];
|
277
|
+
delete this.matches[matchIndex]['foot_note_competitor'];
|
278
|
+
delete this.matches[matchIndex]['auto_winner_type'];
|
279
|
+
delete this.matches[matchIndex]['auto_winner_recursion'];
|
280
|
+
delete this.matches[matchIndex]['auto_winner_reason'];
|
281
|
+
}
|
282
|
+
this.matches[matchIndex]['winner'] = winnerId;
|
283
|
+
if (decrementMatchesLeft) {
|
284
|
+
this.matchesLeft = this.matchesLeft - 1;
|
285
|
+
}
|
286
|
+
this.updateDefeatedAndOutmatchedCompetitorsByCompetitor(winnerId, loserId);
|
287
|
+
this.letWinnerWinMatchesAgainstCompetitorsWhichLoseAgainstLoser(winnerId, loserId);
|
288
|
+
return this.letOutMatchedCompetitorsOfWinnerWinAgainstLoser(winnerId, loserId);
|
289
|
+
};
|
290
|
+
|
291
|
+
CompetitiveList.prototype.updateDefeatedAndOutmatchedCompetitorsByCompetitor = function(winnerId, loserId) {
|
292
|
+
var base, base1;
|
293
|
+
(base = this.defeatedCompetitorsByCompetitor)[winnerId] || (base[winnerId] = []);
|
294
|
+
this.defeatedCompetitorsByCompetitor[winnerId].push(loserId);
|
295
|
+
(base1 = this.outmatchedCompetitorsByCompetitor)[loserId] || (base1[loserId] = []);
|
296
|
+
return this.outmatchedCompetitorsByCompetitor[loserId].push(winnerId);
|
297
|
+
};
|
298
|
+
|
299
|
+
CompetitiveList.prototype.letWinnerWinMatchesAgainstCompetitorsWhichLoseAgainstLoser = function(winnerId, loserId) {
|
300
|
+
var base;
|
301
|
+
(base = this.defeatedCompetitorsByCompetitor)[loserId] || (base[loserId] = []);
|
302
|
+
return $.each(this.matches, (function(_this) {
|
303
|
+
return function(index, match) {
|
304
|
+
var manual_winner_changed, matchCompetitorsWhichHaveBeenDefeatedByLoser, otherLoserId;
|
305
|
+
if (match['winner'] === winnerId || $.inArray(winnerId, match['competitors']) === -1) {
|
306
|
+
return true;
|
307
|
+
}
|
308
|
+
matchCompetitorsWhichHaveBeenDefeatedByLoser = jQuery.map(match['competitors'], function(c) {
|
309
|
+
if ($.inArray(c, _this.defeatedCompetitorsByCompetitor[loserId]) > -1) {
|
310
|
+
return c;
|
311
|
+
}
|
312
|
+
});
|
313
|
+
if (matchCompetitorsWhichHaveBeenDefeatedByLoser.length === 0) {
|
314
|
+
return true;
|
315
|
+
}
|
316
|
+
otherLoserId = _this.otherCompetitorOfMatch(match, winnerId);
|
317
|
+
manual_winner_changed = false;
|
318
|
+
if (match['winner'] !== void 0) {
|
319
|
+
_this.removeCompetitorsComparisonResult(winnerId, otherLoserId);
|
320
|
+
if (!(_this.movingCompetitorToPosition === true || match['auto_winner'] === true)) {
|
321
|
+
manual_winner_changed = true;
|
322
|
+
}
|
323
|
+
}
|
324
|
+
_this.appointWinnerOfMatch(index, winnerId, otherLoserId, match['winner'] === void 0);
|
325
|
+
if (_this.movingCompetitorToPosition === true) {
|
326
|
+
return true;
|
327
|
+
}
|
328
|
+
_this.matches[index]['manual_winner_changed'] = manual_winner_changed;
|
329
|
+
_this.matches[index]['auto_winner'] = true;
|
330
|
+
_this.matches[index]['foot_note_competitor'] = loserId;
|
331
|
+
_this.matches[index]['auto_winner_type'] = 0;
|
332
|
+
if (winnerId === _this.currentMatch['winner'] && loserId === _this.otherCompetitorOfMatch(_this.currentMatch, _this.currentMatch['winner'])) {
|
333
|
+
_this.matches[index]['auto_winner_recursion'] = false;
|
334
|
+
_this.matches[index]['auto_winner_reason'] = 'loser has been defeated because he loses against the loser <sup>[1]</sup> of last match';
|
335
|
+
} else {
|
336
|
+
_this.matches[index]['auto_winner_recursion'] = true;
|
337
|
+
_this.matches[index]['auto_winner_reason'] = 'loser has been defeated because he loses against the loser <sup>[1]</sup> of last auto winner match';
|
338
|
+
}
|
339
|
+
return _this.currentAutoWinnerMatches.push(_this.matches[index]);
|
340
|
+
};
|
341
|
+
})(this));
|
342
|
+
};
|
343
|
+
|
344
|
+
CompetitiveList.prototype.removeCompetitorsComparisonResult = function(winnerId, loserId) {
|
345
|
+
var base;
|
346
|
+
(base = this.outmatchedCompetitorsByCompetitor)[winnerId] || (base[winnerId] = []);
|
347
|
+
this.outmatchedCompetitorsByCompetitor[winnerId] = this.removeItemFromArray(this.outmatchedCompetitorsByCompetitor[winnerId], loserId);
|
348
|
+
return this.defeatedCompetitorsByCompetitor[loserId] = this.removeItemFromArray(this.defeatedCompetitorsByCompetitor[loserId], winnerId);
|
349
|
+
};
|
350
|
+
|
351
|
+
CompetitiveList.prototype.letOutMatchedCompetitorsOfWinnerWinAgainstLoser = function(winnerId, loserId) {
|
352
|
+
var base;
|
353
|
+
(base = this.outmatchedCompetitorsByCompetitor)[winnerId] || (base[winnerId] = []);
|
354
|
+
return $.each(this.outmatchedCompetitorsByCompetitor[winnerId], (function(_this) {
|
355
|
+
return function(index, competitorId) {
|
356
|
+
return $.each(_this.matches, function(index, match) {
|
357
|
+
var manual_winner_changed;
|
358
|
+
if ($.inArray(competitorId, match['competitors']) > -1 && $.inArray(loserId, match['competitors']) > -1 && match['winner'] !== competitorId) {
|
359
|
+
manual_winner_changed = false;
|
360
|
+
if (match['winner'] !== void 0) {
|
361
|
+
_this.removeCompetitorsComparisonResult(competitorId, loserId);
|
362
|
+
if (!(_this.movingCompetitorToPosition === true || match['auto_winner'] === true)) {
|
363
|
+
manual_winner_changed = true;
|
364
|
+
}
|
365
|
+
}
|
366
|
+
_this.appointWinnerOfMatch(index, competitorId, loserId, match['winner'] === void 0);
|
367
|
+
if (_this.movingCompetitorToPosition === true) {
|
368
|
+
return true;
|
369
|
+
}
|
370
|
+
_this.matches[index]['manual_winner_changed'] = manual_winner_changed;
|
371
|
+
_this.matches[index]['auto_winner'] = true;
|
372
|
+
_this.matches[index]['auto_winner_type'] = 1;
|
373
|
+
_this.matches[index]['foot_note_competitor'] = winnerId;
|
374
|
+
if (winnerId === _this.currentMatch['winner'] && loserId === _this.otherCompetitorOfMatch(_this.currentMatch, _this.currentMatch['winner'])) {
|
375
|
+
_this.matches[index]['auto_winner_recursion'] = false;
|
376
|
+
_this.matches[index]['auto_winner_reason'] = "loser of last match has been defeated by outmatched competitor of<br/>winner <sup>[1]</sup>";
|
377
|
+
} else {
|
378
|
+
_this.matches[index]['auto_winner_recursion'] = true;
|
379
|
+
_this.matches[index]['auto_winner_reason'] = "loser of last auto winner match has been defeated by outmatched competitor of winner <sup>[1]</sup>";
|
380
|
+
}
|
381
|
+
_this.currentAutoWinnerMatches.push(match);
|
382
|
+
return false;
|
383
|
+
}
|
384
|
+
});
|
385
|
+
};
|
386
|
+
})(this));
|
387
|
+
};
|
388
|
+
|
389
|
+
CompetitiveList.prototype.moveCompetitorToPosition = function(competitorId, position, after_update_request_proc) {
|
390
|
+
var defeatedCompetitor, outmatchedCompetitor, positionOfdefeatedCompetitor, positions;
|
391
|
+
if (after_update_request_proc == null) {
|
392
|
+
after_update_request_proc = null;
|
393
|
+
}
|
394
|
+
this.movingCompetitorToPosition = true;
|
395
|
+
this.setCompetitors();
|
396
|
+
this.competitorsOfCompetitor = {};
|
397
|
+
this.removeMatchesOfNonExistingCompetitors();
|
398
|
+
this.generateMatches();
|
399
|
+
positions = this.getPositions();
|
400
|
+
outmatchedCompetitor = null;
|
401
|
+
defeatedCompetitor = null;
|
402
|
+
positionOfdefeatedCompetitor = positions[position] === competitorId ? position + 1 : position;
|
403
|
+
if (position > Object.keys(positions).length) {
|
404
|
+
alert('This position is not available!');
|
405
|
+
if (after_update_request_proc !== null) {
|
406
|
+
after_update_request_proc();
|
407
|
+
}
|
408
|
+
this.movingCompetitorToPosition = false;
|
409
|
+
return;
|
410
|
+
}
|
411
|
+
if (!(position === 1 || (position - 1) > Object.keys(positions).length)) {
|
412
|
+
outmatchedCompetitor = positions[position - 1];
|
413
|
+
}
|
414
|
+
if (!(positionOfdefeatedCompetitor > Object.keys(positions).length)) {
|
415
|
+
defeatedCompetitor = positions[positionOfdefeatedCompetitor];
|
416
|
+
}
|
417
|
+
$.each(this.matches, (function(_this) {
|
418
|
+
return function(index, match) {
|
419
|
+
var loserId, otherCompetitorId, winnerId;
|
420
|
+
if ($.inArray(competitorId, match['competitors']) === -1) {
|
421
|
+
return true;
|
422
|
+
}
|
423
|
+
winnerId = null;
|
424
|
+
loserId = null;
|
425
|
+
otherCompetitorId = _this.otherCompetitorOfMatch(match, competitorId);
|
426
|
+
if (otherCompetitorId === outmatchedCompetitor && match['winner'] !== otherCompetitorId) {
|
427
|
+
winnerId = otherCompetitorId;
|
428
|
+
loserId = competitorId;
|
429
|
+
outmatchedCompetitor = null;
|
430
|
+
} else if (otherCompetitorId === defeatedCompetitor && match['winner'] !== competitorId) {
|
431
|
+
winnerId = competitorId;
|
432
|
+
loserId = otherCompetitorId;
|
433
|
+
defeatedCompetitor = null;
|
434
|
+
}
|
435
|
+
if (winnerId === null) {
|
436
|
+
return true;
|
437
|
+
}
|
438
|
+
if (match['winner'] !== void 0) {
|
439
|
+
_this.removeCompetitorsComparisonResult(winnerId, loserId);
|
440
|
+
}
|
441
|
+
_this.currentMatch = match;
|
442
|
+
_this.currentMatchIndex = index;
|
443
|
+
_this.appointWinnerOfMatch(index, winnerId, loserId, false);
|
444
|
+
if (outmatchedCompetitor === null && defeatedCompetitor === null) {
|
445
|
+
return false;
|
446
|
+
}
|
447
|
+
};
|
448
|
+
})(this));
|
449
|
+
this.sortByMostWins(after_update_request_proc);
|
450
|
+
return this.movingCompetitorToPosition = false;
|
451
|
+
};
|
452
|
+
|
453
|
+
CompetitiveList.prototype.sortByMostWins = function(after_update_request_proc) {
|
454
|
+
var $wrapper, data, positions, winsByCompetitor;
|
455
|
+
if (after_update_request_proc == null) {
|
456
|
+
after_update_request_proc = null;
|
457
|
+
}
|
458
|
+
winsByCompetitor = {};
|
459
|
+
$.each(this.competitors, (function(_this) {
|
460
|
+
return function(index, competitorId) {
|
461
|
+
return winsByCompetitor[competitorId] = 0;
|
462
|
+
};
|
463
|
+
})(this));
|
464
|
+
$.each(this.matches, (function(_this) {
|
465
|
+
return function(index, match) {
|
466
|
+
delete _this.matches[index]['auto_winner_reason'];
|
467
|
+
return winsByCompetitor[match['winner']] += 1;
|
468
|
+
};
|
469
|
+
})(this));
|
470
|
+
$.each(Object.keys(winsByCompetitor), function(index, competitorId) {
|
471
|
+
return $('#competitor_' + competitorId).data('wins', winsByCompetitor[competitorId]);
|
472
|
+
});
|
473
|
+
$wrapper = this.$el.find('.competitive_list');
|
474
|
+
$wrapper.find('li').sort(function(a, b) {
|
475
|
+
return +parseInt($(b).data('wins')) - +parseInt($(a).data('wins'));
|
476
|
+
}).appendTo($wrapper);
|
477
|
+
positions = this.getPositions();
|
478
|
+
if ($wrapper.data('update-all-positions-path') !== void 0) {
|
479
|
+
data = {
|
480
|
+
_method: 'put',
|
481
|
+
positions: positions,
|
482
|
+
matches: JSON.stringify(this.matches)
|
483
|
+
};
|
484
|
+
return $.post($wrapper.data('update-all-positions-path'), data).always((function(_this) {
|
485
|
+
return function() {
|
486
|
+
if (after_update_request_proc !== null) {
|
487
|
+
return after_update_request_proc();
|
488
|
+
}
|
489
|
+
};
|
490
|
+
})(this));
|
491
|
+
}
|
492
|
+
};
|
493
|
+
|
494
|
+
CompetitiveList.prototype.getPositions = function() {
|
495
|
+
var currentPosition, positions;
|
496
|
+
positions = {};
|
497
|
+
currentPosition = 1;
|
498
|
+
$.each(this.$el.find('.competitive_list li'), function(index, element) {
|
499
|
+
positions[currentPosition] = $(element).data('id');
|
500
|
+
$(element).data('position', currentPosition);
|
501
|
+
$(element).find('.competitor_position').html(currentPosition);
|
502
|
+
return currentPosition += 1;
|
503
|
+
});
|
504
|
+
return positions;
|
505
|
+
};
|
506
|
+
|
507
|
+
return CompetitiveList;
|
508
|
+
|
509
|
+
})();
|
510
|
+
$.pluginFactory = function(plugin) {
|
511
|
+
return $.fn[plugin.prototype.jqueryInstanceMethodName] = function(options) {
|
512
|
+
var after, args;
|
513
|
+
args = $.makeArray(arguments);
|
514
|
+
after = args.slice(1);
|
515
|
+
return this.each(function() {
|
516
|
+
var instance;
|
517
|
+
instance = $.data(this, plugin.prototype.jqueryInstanceMethodName);
|
518
|
+
if (instance) {
|
519
|
+
if (typeof options === 'string') {
|
520
|
+
return instance[options].apply(instance, after);
|
521
|
+
} else if (instance.update) {
|
522
|
+
return instance.update.apply(instance, args);
|
523
|
+
}
|
524
|
+
} else {
|
525
|
+
return new plugin(this, options);
|
526
|
+
}
|
527
|
+
});
|
528
|
+
};
|
529
|
+
};
|
530
|
+
return $.pluginFactory(CompetitiveList);
|
531
|
+
})(window.jQuery, window);
|
532
|
+
|
533
|
+
}).call(this);
|
@@ -61,9 +61,7 @@ class CommentsController < ApplicationController
|
|
61
61
|
@commentable = @comment.commentable ? @comment.commentable : find_parent(Comment::COMMENTABLE_TYPES)
|
62
62
|
eval("@#{@commentable.class.name.tableize.singularize} = @commentable")
|
63
63
|
|
64
|
-
if @commentable.is_a?(
|
65
|
-
@vacancy = @commentable.vacancy
|
66
|
-
elsif @commentable.is_a?(Project)
|
64
|
+
if @commentable.is_a?(Project)
|
67
65
|
@twitter_sidenav_level = 4
|
68
66
|
end
|
69
67
|
end
|
@@ -9,7 +9,7 @@ module Voluntary
|
|
9
9
|
rescue_from Mongoid::Errors::DocumentNotFound, with: :not_found
|
10
10
|
|
11
11
|
helper_method :parent, :application_navigation, :navigation_product_path, :navigation_product_name, :voluntary_application_stylesheets
|
12
|
-
helper_method :voluntary_application_javascripts
|
12
|
+
helper_method :voluntary_application_javascripts
|
13
13
|
end
|
14
14
|
|
15
15
|
def voluntary_application_stylesheets
|
@@ -19,10 +19,6 @@ module Voluntary
|
|
19
19
|
def voluntary_application_javascripts
|
20
20
|
['voluntary/application', 'application']
|
21
21
|
end
|
22
|
-
|
23
|
-
def voluntary_application_repository_path
|
24
|
-
'volontariat/voluntary'
|
25
|
-
end
|
26
22
|
|
27
23
|
def parent
|
28
24
|
@parent
|
@@ -1,23 +1,25 @@
|
|
1
1
|
class Workflow::ProjectOwnerController < ApplicationController
|
2
|
+
@@extra_tabs = []
|
3
|
+
@@tabs_data = []
|
4
|
+
|
5
|
+
def self.extra_tabs
|
6
|
+
@@extra_tabs
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.tabs_data
|
10
|
+
@@tabs_data
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.add_tabs_data(tabs, code)
|
14
|
+
@@extra_tabs += tabs
|
15
|
+
@@tabs_data << code
|
16
|
+
end
|
17
|
+
|
2
18
|
def index
|
3
19
|
@stories = {}
|
4
20
|
@tasks = {}
|
5
|
-
@vacancies = {}
|
6
|
-
@candidatures = {}
|
7
21
|
|
8
|
-
|
9
|
-
query = 'offeror_id = :user_id'
|
10
|
-
query += ' OR author_id = :user_id' if controller == :vacancies
|
11
|
-
query = "(#{query}) AND state = :state"
|
12
|
-
|
13
|
-
states.each do |state|
|
14
|
-
# eval("@#{controller}[state] = current_user.offeror_#{controller}.where(state: state).limit(5)")
|
15
|
-
collection = controller.to_s.classify.constantize.where(
|
16
|
-
query, user_id: current_user.id, state: state
|
17
|
-
).order('created_at DESC').limit(5)
|
18
|
-
eval("@#{controller}[state] = collection")
|
19
|
-
end
|
20
|
-
end
|
22
|
+
Workflow::ProjectOwnerController.tabs_data.each {|code| instance_exec &code }
|
21
23
|
|
22
24
|
{ stories: [:completed, :active], tasks: [:under_supervision] }.each do |controller, states|
|
23
25
|
states.each do |state|
|