voluntary_ranking 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/voluntary_ranking/app.js +11 -0
- data/app/assets/javascripts/voluntary_ranking/application.js +4 -0
- data/app/assets/javascripts/voluntary_ranking/base.js.coffee +3 -0
- data/app/assets/javascripts/voluntary_ranking/components/modal_dialog_component.js.coffee +6 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/arguments/index_controller.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/arguments/new_controller.js.coffee +16 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/compare_things/arguments_controller.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/compare_things_controller.js.coffee +8 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/controller.js.coffee +1 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/index_controller.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/profile/rankings_controller.js.coffee +3 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/ranking_item_controller.js.coffee +7 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/rankings/index_controller.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/rankings/show_controller.js.coffee +6 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/thing_controller.js.coffee +10 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/user/rankings/show_controller.js.coffee +92 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/user_controller.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_ranking/controllers/user_ranking_controller.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_ranking/helpers/name_with_apostrophe_helper.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_ranking/helpers/stars_html_helper.js.coffee +29 -0
- data/app/assets/javascripts/voluntary_ranking/mixins/has_current_user.js.coffee +4 -0
- data/app/assets/javascripts/voluntary_ranking/mixins/pagination_controller.js.coffee +51 -0
- data/app/assets/javascripts/voluntary_ranking/mixins/ranking_controller.js.coffee +31 -0
- data/app/assets/javascripts/voluntary_ranking/mixins/singleton.js.coffee +17 -0
- data/app/assets/javascripts/voluntary_ranking/models/argument.js.coffee +7 -0
- data/app/assets/javascripts/voluntary_ranking/models/movie.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_ranking/models/ranking.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_ranking/models/ranking_item.js.coffee +26 -0
- data/app/assets/javascripts/voluntary_ranking/models/thing.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_ranking/models/user.js.coffee +18 -0
- data/app/assets/javascripts/voluntary_ranking/models/user/ranking_item.js.coffee +33 -0
- data/app/assets/javascripts/voluntary_ranking/router.js.coffee +30 -0
- data/app/assets/javascripts/voluntary_ranking/routes/arguments/index_route.js.coffee +24 -0
- data/app/assets/javascripts/voluntary_ranking/routes/compare_things/arguments_route.js.coffee +16 -0
- data/app/assets/javascripts/voluntary_ranking/routes/compare_things/compare_things_route.js.coffee +9 -0
- data/app/assets/javascripts/voluntary_ranking/routes/profile/rankings_route.js.coffee +29 -0
- data/app/assets/javascripts/voluntary_ranking/routes/ranking_item_route.js.coffee +25 -0
- data/app/assets/javascripts/voluntary_ranking/routes/rankings/index_route.js.coffee +10 -0
- data/app/assets/javascripts/voluntary_ranking/routes/rankings/show_route.js.coffee +19 -0
- data/app/assets/javascripts/voluntary_ranking/routes/thing_route.js.coffee +7 -0
- data/app/assets/javascripts/voluntary_ranking/routes/user_ranking_route.js.coffee +27 -0
- data/app/assets/javascripts/voluntary_ranking/routes/user_route.js.coffee +20 -0
- data/app/assets/javascripts/voluntary_ranking/templates/application.handlebars.erb +16 -0
- data/app/assets/javascripts/voluntary_ranking/templates/arguments.js.handlebars +1 -0
- data/app/assets/javascripts/voluntary_ranking/templates/arguments/index.js.handlebars +27 -0
- data/app/assets/javascripts/voluntary_ranking/templates/arguments/new.js.handlebars +17 -0
- data/app/assets/javascripts/voluntary_ranking/templates/compare_things.js.handlebars +22 -0
- data/app/assets/javascripts/voluntary_ranking/templates/compare_things/arguments.js.handlebars +26 -0
- data/app/assets/javascripts/voluntary_ranking/templates/components/modal-dialog.js.handlebars +9 -0
- data/app/assets/javascripts/voluntary_ranking/templates/components/rankings-component.handlebars +17 -0
- data/app/assets/javascripts/voluntary_ranking/templates/index.js.handlebars +1 -0
- data/app/assets/javascripts/voluntary_ranking/templates/navigation.js.handlebars +28 -0
- data/app/assets/javascripts/voluntary_ranking/templates/ranking_item.js.handlebars +31 -0
- data/app/assets/javascripts/voluntary_ranking/templates/ranking_items/_collection.js.handlebars +84 -0
- data/app/assets/javascripts/voluntary_ranking/templates/ranking_items/_form.js.handlebars +30 -0
- data/app/assets/javascripts/voluntary_ranking/templates/rankings/_form.js.handlebars +38 -0
- data/app/assets/javascripts/voluntary_ranking/templates/rankings/index.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_ranking/templates/rankings/show.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_ranking/templates/shared/_pagination.js.handlebars +23 -0
- data/app/assets/javascripts/voluntary_ranking/templates/shared/_stars.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_ranking/templates/thing.js.handlebars +13 -0
- data/app/assets/javascripts/voluntary_ranking/templates/thing/index.js.handlebars +0 -0
- data/app/assets/javascripts/voluntary_ranking/templates/things/show.arguments.js.handlebars +1 -0
- data/app/assets/javascripts/voluntary_ranking/templates/things/show.js.handlebars +1 -0
- data/app/assets/javascripts/voluntary_ranking/templates/user.js.handlebars +5 -0
- data/app/assets/javascripts/voluntary_ranking/templates/user/rankings/details.js.handlebars +7 -0
- data/app/assets/javascripts/voluntary_ranking/views/application/index_view.js.coffee +1 -0
- data/app/assets/javascripts/voluntary_ranking/views/arguments/new_view.js.coffee +9 -0
- data/app/assets/javascripts/voluntary_ranking/views/index_view.js.coffee +1 -0
- data/app/assets/javascripts/voluntary_ranking/views/ranking_items/colllection_view.js.coffee +25 -0
- data/app/assets/javascripts/voluntary_ranking/views/shared/pagination.js +4 -0
- data/app/assets/stylesheets/voluntary_ranking/application.css +17 -0
- data/app/assets/stylesheets/voluntary_ranking/base.css.sass +6 -0
- data/app/assets/stylesheets/voluntary_ranking/bootstrap_and_overrides.css.sass +0 -0
- data/app/assets/stylesheets/voluntary_ranking/stars.css.sass +31 -0
- data/app/assets/stylesheets/voluntary_ranking/twitter-typeahead.css.sass +29 -0
- data/app/controllers/api/v1/argument_topics_controller.rb +12 -0
- data/app/controllers/api/v1/arguments_controller.rb +32 -0
- data/app/controllers/api/v1/ranking_items_controller.rb +43 -0
- data/app/controllers/api/v1/rankings_controller.rb +29 -0
- data/app/controllers/api/v1/things/arguments_controller.rb +40 -0
- data/app/controllers/api/v1/things_controller.rb +26 -0
- data/app/controllers/api/v1/user_ranking_items_controller.rb +94 -0
- data/app/controllers/api/v1/users_controller.rb +9 -0
- data/app/controllers/product/ranking_controller.rb +16 -0
- data/app/models/argument.rb +48 -0
- data/app/models/argument_topic.rb +7 -0
- data/app/models/product/ranking.rb +2 -0
- data/app/models/ranking.rb +97 -0
- data/app/models/ranking_item.rb +30 -0
- data/app/models/user_ranking_item.rb +136 -0
- data/app/serializers/argument_serializer.rb +11 -0
- data/app/serializers/base_ranking_item_serializer.rb +23 -0
- data/app/serializers/ranking_item_serializer.rb +2 -0
- data/app/serializers/user_ranking_item_serializer.rb +7 -0
- data/app/views/product/ranking/index.html.erb +0 -0
- data/config/locales/en.yml +10 -0
- data/config/locales/resources/ranking/en.yml +10 -0
- data/config/routes.rb +41 -0
- data/db/migrate/20130817115303_add_ranking_product.rb +50 -0
- data/db/migrate/20140926102943_create_arguments.rb +20 -0
- data/lib/concerns/controller/base_ranking_items_controller.rb +10 -0
- data/lib/concerns/model/base_ranking_item.rb +29 -0
- data/lib/concerns/model/user/ranking.rb +48 -0
- data/lib/tasks/voluntary_ranking_tasks.rake +4 -0
- data/lib/voluntary_ranking.rb +12 -0
- data/lib/voluntary_ranking/ability.rb +11 -0
- data/lib/voluntary_ranking/engine.rb +16 -0
- data/lib/voluntary_ranking/version.rb +3 -0
- metadata +436 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d80fd9aec98a0b73c549d41c107d7100ad624e39
|
4
|
+
data.tar.gz: a83b2e05f8141fc6f10580edf245dada93bf5050
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f3009b243c9933459f5d0edf5db082040269f71c279cefac15f15a94aa060152d71eda5492e0982b1065492b3a3af38b9904734b250fd6eda1e5727c43119342
|
7
|
+
data.tar.gz: dd9f56bb4e2e6d460e620796d79fa1db2d8b056dbca6e0b8888399fad41d38014f0e06761dfb38c4095236cbf6a49118d1286eff3db297dcd5791399fc64aa2d
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 Mathias Gawlista
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'VoluntaryRanking'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
//= require_tree ./mixins
|
2
|
+
//= require_tree ./models
|
3
|
+
//= require_tree ./controllers
|
4
|
+
//= require_tree ./components
|
5
|
+
//= require_tree ./views
|
6
|
+
//= require_tree ./helpers
|
7
|
+
//= require_tree ./templates
|
8
|
+
//= require ./router.js.coffee
|
9
|
+
//= require_tree ./routes
|
10
|
+
//= require_self
|
11
|
+
//= require ./base.js.coffee
|
data/app/assets/javascripts/voluntary_ranking/controllers/arguments/index_controller.js.coffee
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Volontariat.ArgumentsIndexController = Ember.Controller.extend(Volontariat.HasCurrentUser, Volontariat.PaginationController,
|
2
|
+
paginationResource: 'argument', paginationRoute: 'arguments.index', thingName: ''
|
3
|
+
|
4
|
+
anyItems: (-> @get('content.length') > 0).property('content')
|
5
|
+
)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Volontariat.ArgumentsNewController = Ember.Controller.extend
|
2
|
+
topicName: '', value: ''
|
3
|
+
|
4
|
+
actions:
|
5
|
+
|
6
|
+
create: ->
|
7
|
+
# TODO: replace manual ajax logic by createRecord usage if the thingId can be passed
|
8
|
+
#argument = @store.createRecord('argument', topicName: @get('topicName'), thingId: $('#thing_id').val(), value: @get('value'))
|
9
|
+
#argument.save()
|
10
|
+
$.post('/api/v1/arguments', { argument: { topic_name: @get('topicName'), thing_name: $('#thing_name').val(), value: @get('value') } }).success =>
|
11
|
+
@send "closeModal"
|
12
|
+
@transitionToRoute('no_data')
|
13
|
+
@transitionToRoute('arguments.index', $('#thing_name').val(), 1)
|
14
|
+
|
15
|
+
close: ->
|
16
|
+
@send "closeModal"
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Volontariat.CompareThingsArgumentsController = Ember.Controller.extend(Volontariat.HasCurrentUser, Volontariat.PaginationController,
|
2
|
+
paginationResource: 'argument', paginationRoute: 'compare_things.arguments', side: 'both', leftThingName: '', rightThingName: ''
|
3
|
+
|
4
|
+
anyItems: (-> @get('content.length') > 0).property('content')
|
5
|
+
)
|
@@ -0,0 +1 @@
|
|
1
|
+
Volontariat.Controller = Ember.Controller.extend(Volontariat.HasCurrentUser)
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Volontariat.IndexController = Volontariat.Controller.extend(Volontariat.RankingController,
|
2
|
+
yourRanking: false
|
3
|
+
yourRankingClass: 'your_ranking_button btn-default btn', globalRankingClass: 'global_ranking_button btn-default btn active'
|
4
|
+
adjective: '', negativeAdjective: '', topic: '', scope: ''
|
5
|
+
)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Volontariat.RankingItemController = Ember.Controller.extend(Volontariat.HasCurrentUser, Volontariat.RankingController, Volontariat.PaginationController,
|
2
|
+
position: null, yourRankingClass: 'your_ranking_button btn btn-default', globalRankingClass: 'global_ranking_button btn btn-default active',
|
3
|
+
userRankingItems: []
|
4
|
+
paginationResource: null, paginationRoute: 'ranking_item'
|
5
|
+
|
6
|
+
anyUserRankingItems: (-> @get('userRankingItems').length > 0).property('userRankingItems')
|
7
|
+
)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
Volontariat.RankingsShowController = Volontariat.Controller.extend(Volontariat.RankingController, Volontariat.PaginationController,
|
2
|
+
yourRanking: false, routeName: ''
|
3
|
+
yourRankingClass: 'your_ranking_button btn btn-default', globalRankingClass: 'global_ranking_button btn btn-default active'
|
4
|
+
adjective: '', negativeAdjective: '', topic: '', scope: ''
|
5
|
+
paginationResource: 'ranking_item', paginationRoute: 'rankings.show'
|
6
|
+
)
|
data/app/assets/javascripts/voluntary_ranking/controllers/user/rankings/show_controller.js.coffee
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
Volontariat.UserRankingsShowController = Volontariat.Controller.extend(Volontariat.RankingController, Volontariat.PaginationController,
|
2
|
+
yourRanking: true, routeName: ''
|
3
|
+
yourRankingClass: 'your_ranking_button btn btn-default active', globalRankingClass: 'global_ranking_button btn-default btn'
|
4
|
+
adjective: '', negativeAdjective: '', topic: '', scope: ''
|
5
|
+
thingName: '', best: true, stars: 3
|
6
|
+
isBestClass: 'btn btn-default active', isWorstClass: 'btn btn-default'
|
7
|
+
is1Star: '', is2Star: '', is3Star: 'active', is4Star: '', is5Star: ''
|
8
|
+
paginationResource: 'user_ranking_item', paginationRoute: 'profile.rankings'
|
9
|
+
|
10
|
+
_setBest: (without_stars) ->
|
11
|
+
return if @get('best')
|
12
|
+
@set('best', true); @set('isBestClass', 'btn btn-default active'); @set('isWorstClass', 'btn btn-default')
|
13
|
+
@_setStars(3) if !without_stars and @get('stars') <= 2
|
14
|
+
|
15
|
+
_setWorst: (without_stars) ->
|
16
|
+
return unless @get('best', 'btn active')
|
17
|
+
@set('best', false); @set('isBestClass', 'btn btn-default'); @set('isWorstClass', 'btn btn-default active')
|
18
|
+
@_setStars(0) if !without_stars and @get('stars') > 0
|
19
|
+
|
20
|
+
_setStars: (stars) ->
|
21
|
+
if @get('stars') == stars
|
22
|
+
@set('stars', stars - 1)
|
23
|
+
$.each [1,2,3,4,5], (index, value) => @set('is' + value + 'Star', if value < stars then 'active' else '')
|
24
|
+
else
|
25
|
+
@set('stars', stars)
|
26
|
+
$.each [1,2,3,4,5], (index, value) => @set('is' + value + 'Star', if value <= stars then 'active' else '')
|
27
|
+
|
28
|
+
if stars >= 3 and !@get('best')
|
29
|
+
@_setBest(true)
|
30
|
+
else if stars <= 2 and @get('best')
|
31
|
+
@_setWorst(true)
|
32
|
+
|
33
|
+
actions:
|
34
|
+
|
35
|
+
setBest: -> @_setBest()
|
36
|
+
setWorst: -> @_setWorst()
|
37
|
+
|
38
|
+
set1Star: -> @_setStars(1)
|
39
|
+
set2Star: -> @_setStars(2)
|
40
|
+
set3Star: -> @_setStars(3)
|
41
|
+
set4Star: -> @_setStars(4)
|
42
|
+
set5Star: -> @_setStars(5)
|
43
|
+
|
44
|
+
addItem: ->
|
45
|
+
if !@get('thingName').trim() || !@get('adjective').trim() || !@get('negativeAdjective').trim() || !@get('topic').trim() || !@get('scope').trim()
|
46
|
+
alert 'Please set thing, adjective, negative adjective, topic and scope.'
|
47
|
+
return
|
48
|
+
|
49
|
+
user_ranking_item = @store.createRecord(
|
50
|
+
'user_ranking_item',
|
51
|
+
thingName: @get('thingName'), best: @get('best'), stars: @get('stars'),
|
52
|
+
adjective: @get('adjective'), negativeAdjective: @get('negativeAdjective'), topic: @get('topic'), scope: @get('scope')
|
53
|
+
)
|
54
|
+
user_ranking_item.save().then =>
|
55
|
+
@send('getRanking')
|
56
|
+
|
57
|
+
updateStars: (id, stars_was, stars) ->
|
58
|
+
stars -= 1 if stars_was == stars
|
59
|
+
|
60
|
+
@store.find('user_ranking_item', id).then (user_ranking_item) =>
|
61
|
+
user_ranking_item.set 'stars', stars
|
62
|
+
user_ranking_item.save().then =>
|
63
|
+
@send('getRanking')
|
64
|
+
|
65
|
+
destroy: (id) ->
|
66
|
+
$.ajax("/api/v1/user_ranking_items/#{id}", type: 'DELETE').done((data) =>
|
67
|
+
@send('getRanking')
|
68
|
+
).fail((data) ->
|
69
|
+
alert 'Removing item failed!'
|
70
|
+
)
|
71
|
+
|
72
|
+
moveToPreviousPage: (id) ->
|
73
|
+
if @get('previousPage') <= 0
|
74
|
+
alert 'No previous page available.'
|
75
|
+
return
|
76
|
+
|
77
|
+
$.post '/api/v1/user_ranking_items/' + id + '/move_to_page', { _method: 'put', page: @get('previousPage') }, (data) =>
|
78
|
+
@transitionToRoute('profile.rankings', @get('adjective'), @get('negativeAdjective'), @get('topic'), @get('scope'), @get('previousPage'))
|
79
|
+
@send('getRanking')
|
80
|
+
return
|
81
|
+
|
82
|
+
|
83
|
+
moveToNextPage: (id) ->
|
84
|
+
if @get('nextPage') > @get('totalPages')
|
85
|
+
alert 'No next page available.'
|
86
|
+
return
|
87
|
+
|
88
|
+
$.post '/api/v1/user_ranking_items/' + id + '/move_to_page', { _method: 'put', page: @get('nextPage') }, (data) =>
|
89
|
+
@transitionToRoute('profile.rankings', @get('adjective'), @get('negativeAdjective'), @get('topic'), @get('scope'), @get('nextPage'))
|
90
|
+
@send('getRanking')
|
91
|
+
return
|
92
|
+
)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Ember.Handlebars.helper 'stars-html', (value, options) ->
|
2
|
+
text = ''
|
3
|
+
|
4
|
+
if value == 5
|
5
|
+
text += '<span class="active"></span>'
|
6
|
+
else
|
7
|
+
text += '<span></span>'
|
8
|
+
|
9
|
+
if value >= 4
|
10
|
+
text += '<span class="active"></span>'
|
11
|
+
else
|
12
|
+
text += '<span></span>'
|
13
|
+
|
14
|
+
if value >= 3
|
15
|
+
text += '<span class="active"></span>'
|
16
|
+
else
|
17
|
+
text += '<span></span>'
|
18
|
+
|
19
|
+
if value >= 2
|
20
|
+
text += '<span class="active"></span>'
|
21
|
+
else
|
22
|
+
text += '<span></span>'
|
23
|
+
|
24
|
+
if value >= 1
|
25
|
+
text += '<span class="active"></span>'
|
26
|
+
else
|
27
|
+
text += '<span></span>'
|
28
|
+
|
29
|
+
new (Ember.Handlebars.SafeString)(text)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Volontariat.PaginationController = Em.Mixin.create
|
2
|
+
pages: [], totalPages: 1, page: 1, metadata: null
|
3
|
+
|
4
|
+
showFirstPageLink: (-> @get('page') != 1).property('page')
|
5
|
+
showPreviousPageLink: (-> @get('page') - 1 > 0).property('page')
|
6
|
+
previousPage: (-> @get('page') - 1).property('page')
|
7
|
+
showNextPageLink: (-> @get('page') + 1 <= @get('totalPages')).property('page')
|
8
|
+
nextPage: (-> @get('page') + 1).property('page')
|
9
|
+
showLastPageLink: (-> @get('page') != @get('totalPages')).property('page')
|
10
|
+
|
11
|
+
_goToPage: (page) ->
|
12
|
+
page = parseInt(page)
|
13
|
+
@set('page', page)
|
14
|
+
@set('totalPages', (@get('metadata') || @store.metadataFor(@get('paginationResource'))).pagination.total_pages)
|
15
|
+
pages = []; i = page - 4
|
16
|
+
|
17
|
+
while i <= page
|
18
|
+
pages.push i if i > 0
|
19
|
+
i += 1
|
20
|
+
|
21
|
+
i = page + 1
|
22
|
+
|
23
|
+
while i <= page + 4
|
24
|
+
pages.push i if i <= @get('totalPages')
|
25
|
+
i += 1
|
26
|
+
|
27
|
+
pages = pages.map((item) ->
|
28
|
+
number: item
|
29
|
+
isCurrent: item is page
|
30
|
+
)
|
31
|
+
|
32
|
+
@set('pages', pages)
|
33
|
+
|
34
|
+
actions:
|
35
|
+
goToPage: (page) ->
|
36
|
+
@_goToPage(page)
|
37
|
+
|
38
|
+
switch @get('paginationRoute')
|
39
|
+
when 'rankings.show', 'profile.rankings'
|
40
|
+
@transitionToRoute @get('paginationRoute'), @get('adjective'), @get('negativeAdjective'), @get('topic'), @get('scope'), page
|
41
|
+
when 'rankings.index', 'arguments.index'
|
42
|
+
@transitionToRoute @get('paginationRoute'), @get('thingName'), page
|
43
|
+
when 'compare_things.arguments'
|
44
|
+
@transitionToRoute @get('paginationRoute'), @get('leftThingName'), @get('rightThingName'), @get('side'), page
|
45
|
+
when 'ranking_item'
|
46
|
+
@transitionToRoute @get('paginationRoute'), @get('thingName'), @get('positiveOrNegativeAdjective'), @get('topic'), @get('scope'), page
|
47
|
+
when 'user'
|
48
|
+
@transitionToRoute @get('paginationRoute'), @get('name'), page
|
49
|
+
|
50
|
+
goToPageWithoutRedirect: (page) ->
|
51
|
+
@_goToPage(page)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Volontariat.RankingController = Em.Mixin.create
|
2
|
+
page: 1
|
3
|
+
|
4
|
+
anyItems: (-> @get('content.length') > 0).property('content')
|
5
|
+
|
6
|
+
actions:
|
7
|
+
setGlobalRanking: ->
|
8
|
+
@set('yourRanking', false); @set('yourRankingClass', 'your_ranking_button btn-default btn'); @set('globalRankingClass', 'global_ranking_button btn btn-default active')
|
9
|
+
|
10
|
+
unless @get('adjective') == undefined || @get('adjective').toString().trim() == '' ||
|
11
|
+
@get('negativeAdjective') == undefined || @get('negativeAdjective').toString().trim() == '' ||
|
12
|
+
@get('topic') == undefined || @get('topic').toString().trim() == '' ||
|
13
|
+
@get('scope') == undefined || @get('scope').toString().trim() == ''
|
14
|
+
@send 'getRanking'
|
15
|
+
|
16
|
+
setYourRanking: ->
|
17
|
+
@set('yourRanking', true); @set('yourRankingClass', 'your_ranking_button btn btn-default active'); @set('globalRankingClass', 'global_ranking_button btn btn-default')
|
18
|
+
|
19
|
+
unless @get('adjective') == undefined || @get('adjective').toString().trim() == '' ||
|
20
|
+
@get('negativeAdjective') == undefined || @get('negativeAdjective').toString().trim() == '' ||
|
21
|
+
@get('topic') == undefined || @get('topic').toString().trim() == '' ||
|
22
|
+
@get('scope') == undefined || @get('scope').toString().trim() == ''
|
23
|
+
@send 'getRanking'
|
24
|
+
|
25
|
+
getRanking: ->
|
26
|
+
@transitionToRoute 'no_data'
|
27
|
+
|
28
|
+
if @get('yourRanking')
|
29
|
+
@transitionToRoute('profile.rankings', @get('adjective'), @get('negativeAdjective'), @get('topic'), @get('scope'), @get('page'))
|
30
|
+
else
|
31
|
+
@transitionToRoute('rankings.show', @get('adjective'), @get('negativeAdjective'), @get('topic'), @get('scope'), @get('page'))
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Volontariat.Singleton = Em.Mixin.create(
|
2
|
+
current: ->
|
3
|
+
@_current = @createCurrent() unless @_current
|
4
|
+
@_current
|
5
|
+
|
6
|
+
createCurrent: ->
|
7
|
+
@create {}
|
8
|
+
|
9
|
+
currentProp: (property, value) ->
|
10
|
+
instance = @current()
|
11
|
+
return unless instance
|
12
|
+
if typeof (value) isnt "undefined"
|
13
|
+
instance.set property, value
|
14
|
+
value
|
15
|
+
else
|
16
|
+
instance.get property
|
17
|
+
)
|