voluntary_feedback 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +16 -0
- data/README.md +3 -2
- data/app/assets/javascripts/voluntary_feedback/app.js.coffee +9 -0
- data/app/assets/javascripts/voluntary_feedback/application.js +3 -0
- data/app/assets/javascripts/voluntary_feedback/components/reply_cell_component.js.coffee +44 -0
- data/app/assets/javascripts/voluntary_feedback/components/reply_comments_component.js.coffee +17 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/categories_controller.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/category_controller.js.coffee +1 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/communities_controller.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/community_controller.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/edit_category_controller.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/edit_community_controller.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/edit_feedback_controller.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/feedback_controller.js.coffee +25 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/feedbacks_controller.js.coffee +11 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/new_category_controller.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/new_community_controller.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_feedback/controllers/community/new_feedback_controller.js.coffee +2 -0
- data/app/assets/javascripts/voluntary_feedback/helpers/mood_icon_helper.js.coffee +11 -0
- data/app/assets/javascripts/voluntary_feedback/mixins/community_category_persistence.js.coffee +29 -0
- data/app/assets/javascripts/voluntary_feedback/mixins/community_persistence.js.coffee +33 -0
- data/app/assets/javascripts/voluntary_feedback/mixins/feedback_persistence.js.coffee +39 -0
- data/app/assets/javascripts/voluntary_feedback/mixins/pagination_controller.js.coffee +56 -0
- data/app/assets/javascripts/voluntary_feedback/models/community.js.coffee +7 -0
- data/app/assets/javascripts/voluntary_feedback/models/community_category.js.coffee +4 -0
- data/app/assets/javascripts/voluntary_feedback/models/feedback.js.coffee +12 -0
- data/app/assets/javascripts/voluntary_feedback/models/reply.js.coffee +6 -0
- data/app/assets/javascripts/voluntary_feedback/models/user.js.coffee +18 -0
- data/app/assets/javascripts/voluntary_feedback/router.js.coffee +34 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/categories_route.js.coffee +10 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/category_route.js.coffee +7 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/communities_route.js.coffee +9 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/community_route.js.coffee +4 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/edit_category_route.js.coffee +9 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/edit_community_route.js.coffee +16 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/edit_feedback_route.js.coffee +29 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/feedback_route.js.coffee +28 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/feedbacks_route.js.coffee +42 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/new_category_route.js.coffee +3 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/new_community_route.js.coffee +7 -0
- data/app/assets/javascripts/voluntary_feedback/routes/community/new_feedback_route.js.coffee +8 -0
- data/app/assets/javascripts/voluntary_feedback/templates/application.handlebars.erb +20 -0
- data/app/assets/javascripts/voluntary_feedback/templates/category_form.js.handlebars +13 -0
- data/app/assets/javascripts/voluntary_feedback/templates/communities.js.handlebars +32 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community.js.handlebars +24 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community/categories.js.handlebars +32 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community/category.js.handlebars +11 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community/edit_category.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community/edit_feedback.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community/feedback.js.handlebars +68 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community/feedbacks.js.handlebars +51 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community/new_category.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community/new_feedback.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_feedback/templates/community_form.js.handlebars +29 -0
- data/app/assets/javascripts/voluntary_feedback/templates/components/reply-cell.js.handlebars +34 -0
- data/app/assets/javascripts/voluntary_feedback/templates/components/reply-comments.js.handlebars +27 -0
- data/app/assets/javascripts/voluntary_feedback/templates/edit_community.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_feedback/templates/feedback_form.js.handlebars +91 -0
- data/app/assets/javascripts/voluntary_feedback/templates/navigation.js.handlebars +28 -0
- data/app/assets/javascripts/voluntary_feedback/templates/new_community.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_feedback/templates/shared/_pagination.js.handlebars +23 -0
- data/app/assets/stylesheets/voluntary_feedback/application.css +15 -0
- data/app/controllers/product/feedback_controller.rb +16 -0
- data/app/controllers/voluntary/api/v1/communities_controller.rb +67 -0
- data/app/controllers/voluntary/api/v1/community_categories_controller.rb +87 -0
- data/app/controllers/voluntary/api/v1/feedbacks_controller.rb +83 -0
- data/app/controllers/voluntary/api/v1/replies_controller.rb +91 -0
- data/app/models/community.rb +21 -0
- data/app/models/community_category.rb +21 -0
- data/app/models/community_category_feedback.rb +7 -0
- data/app/models/feedback.rb +54 -0
- data/app/models/product/feedback.rb +2 -0
- data/app/models/reply.rb +16 -0
- data/app/serializers/community_category_serializer.rb +3 -0
- data/app/serializers/community_serializer.rb +11 -0
- data/app/serializers/feedback_serializer.rb +11 -0
- data/app/serializers/reply_serializer.rb +19 -0
- data/app/views/product/feedback/index.html.erb +0 -0
- data/config/locales/resources/community/en.yml +36 -0
- data/config/locales/resources/community_category/en.yml +26 -0
- data/config/locales/resources/feedback/en.yml +42 -0
- data/config/locales/resources/reply/en.yml +29 -0
- data/config/routes.rb +11 -1
- data/db/migrate/20150825160004_add_feedback_product.rb +79 -0
- data/lib/voluntary_feedback.rb +3 -1
- data/lib/voluntary_feedback/concerns/model/organization/has_communities.rb +15 -0
- data/lib/voluntary_feedback/concerns/model/user/has_communities.rb +15 -0
- data/lib/voluntary_feedback/engine.rb +13 -0
- data/lib/voluntary_feedback/version.rb +2 -2
- metadata +353 -20
- data/MIT-LICENSE +0 -20
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YTcwMTNjZTQzZDI1ZTg5ZjA0YjFjZjFjODUxZDQ0NzQ3YjM1N2MzMQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac7a1425fe91a9793eec6e4a02181bc647f40c43
|
4
|
+
data.tar.gz: d9a8043a58ea38d20ba880beea3b8f1d2bb5ef9d
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZDNlYWQ5MTcwYWFiNTZkZWNmZGJmNjRkNWZkZDY4YzY1OTc4ZWMwZTZlODc5
|
11
|
-
OTNlYzE3ZDMzZjcxNWQ0YzkxZjI2Nzc1NzE5ODFiYjY5NjUxODY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZjFhY2U0Mjc4NmYyMTg0OTI5YmVjZWNiM2NiNzlkZTBhOTQzZmFmZDg4MThi
|
14
|
-
ZjE3ZjA0NjlhNWJhY2I2NDI5MDg2NWI0YmZkMjcxMGNlYTg4ZDQ1NzRhNzAy
|
15
|
-
Mjg0OTY2NmFkZWUwNmFkNDIyYTgzOGRiOWY2NDdmZTZlNjExYTg=
|
6
|
+
metadata.gz: df9eda344322c90adc35f926da878100775aa893f6c77d1d4c6cc9c89137e419aff46f145b19f5dc3a29896a063b41b948ee254da2f53a552e8b27c190235df7
|
7
|
+
data.tar.gz: b7970e06e94069ec58fc27390dca5212b46185e32cb6e0206d1e42c7e1854d86c68fb46d3bde11e00a34c90bb876c66f8211f16d94a0365e0a6b39c2a0842a28
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## unreleased ##
|
2
|
+
|
3
|
+
## 0.1.0 (September 2, 2015) ##
|
4
|
+
|
5
|
+
* [#10](https://github.com/volontariat/voluntary_feedback/issues/10) Reply on reply.
|
6
|
+
* [#9](https://github.com/volontariat/voluntary_feedback/issues/9) Liking/Disliking of feedbacks and replies.
|
7
|
+
* [#8](https://github.com/volontariat/voluntary_feedback/issues/8) Categorize feedback.
|
8
|
+
* [#7](https://github.com/volontariat/voluntary_feedback/issues/7) Community owner can post announcements.
|
9
|
+
* [#6](https://github.com/volontariat/voluntary_feedback/issues/6) Manage community categories.
|
10
|
+
* [#5](https://github.com/volontariat/voluntary_feedback/issues/5) Manage replies.
|
11
|
+
* [#4](https://github.com/volontariat/voluntary_feedback/issues/4) Manage feedbacks.
|
12
|
+
* [#3](https://github.com/volontariat/voluntary_feedback/issues/3) Manage communities.
|
13
|
+
|
14
|
+
## 0.0.1 (March 17, 2015) ##
|
15
|
+
|
16
|
+
* Initial version.
|
data/README.md
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
# voluntary_feedback
|
2
|
-
|
1
|
+
# voluntary_feedback [![Build Status](https://travis-ci.org/volontariat/voluntary_feedback.svg?branch=master)](https://travis-ci.org/volontariat/voluntary_feedback) [![Code Climate](https://codeclimate.com/github/volontariat/voluntary_feedback/badges/gpa.svg)](https://codeclimate.com/github/volontariat/voluntary_feedback) [![Test Coverage](https://codeclimate.com/github/volontariat/voluntary_feedback/badges/coverage.svg)](https://codeclimate.com/github/volontariat/voluntary_feedback) [![Dependency Status](https://gemnasium.com/volontariat/voluntary_feedback.png)](https://gemnasium.com/volontariat/voluntary_feedback)
|
2
|
+
|
3
|
+
Plugin for crowdsourcing management system voluntary where users can post feedback like questions, problems, praise and ideas to a community.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Volontariat.ReplyCellComponent = Ember.Component.extend
|
2
|
+
editMode: (-> @get('selectedId') == @get('id')).property('selectedId', 'id')
|
3
|
+
your: (-> Volontariat.User.current() != undefined && Volontariat.User.current().id == @get('userId')).property('userId')
|
4
|
+
|
5
|
+
actions:
|
6
|
+
|
7
|
+
edit: ->
|
8
|
+
@sendAction 'editAction', @get('id')
|
9
|
+
|
10
|
+
cancel: ->
|
11
|
+
if @get 'id'
|
12
|
+
@sendAction 'leaveEditReplyModeAction'
|
13
|
+
else
|
14
|
+
@sendAction 'leaveNewReplyModeAction'
|
15
|
+
|
16
|
+
save: ->
|
17
|
+
$.ajax(
|
18
|
+
type: if @get('id') then 'PUT' else 'POST'
|
19
|
+
url: '/api/v1/replies' + if @get('id') then "/#{@get('id')}" else '',
|
20
|
+
data: {
|
21
|
+
reply: { feedback_id: @get('feedbackId'), reply_id: @get('replyId'), text: $('#reply_text').val() }
|
22
|
+
}
|
23
|
+
).success((data) =>
|
24
|
+
if data.errors
|
25
|
+
alert "#{Volontariat.t('replies.save.failed')}: #{JSON.stringify(data.errors)}"
|
26
|
+
else
|
27
|
+
if @get('id')
|
28
|
+
@sendAction 'leaveEditReplyModeAction'
|
29
|
+
else
|
30
|
+
@sendAction 'leaveNewReplyModeAction'
|
31
|
+
@set 'text', ''
|
32
|
+
|
33
|
+
@sendAction 'reloadAction'
|
34
|
+
).fail((data) =>
|
35
|
+
alert "#{Volontariat.t('replies.save.failed')}!"
|
36
|
+
)
|
37
|
+
|
38
|
+
destroy: ->
|
39
|
+
if confirm(Volontariat.t('replies.destroy.confirmation'))
|
40
|
+
$.ajax("/api/v1/replies/#{@get('id')}", type: 'DELETE').done((data) =>
|
41
|
+
@sendAction 'reloadAction'
|
42
|
+
).fail((data) ->
|
43
|
+
alert Volontariat.t('activerecord.errors.models.reply.attributes.base.deletion_failed')
|
44
|
+
)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Volontariat.ReplyCommentsComponent = Ember.Component.extend
|
2
|
+
actions:
|
3
|
+
|
4
|
+
add: ->
|
5
|
+
@set 'new', true
|
6
|
+
|
7
|
+
leaveNewReplyCommentMode: ->
|
8
|
+
@set 'new', false
|
9
|
+
|
10
|
+
editReply: (id) ->
|
11
|
+
@sendAction 'editAction', id
|
12
|
+
|
13
|
+
leaveEditReplyMode: ->
|
14
|
+
@sendAction 'leaveEditReplyModeAction'
|
15
|
+
|
16
|
+
reload: ->
|
17
|
+
@sendAction 'reloadAction'
|
data/app/assets/javascripts/voluntary_feedback/controllers/community/categories_controller.js.coffee
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Volontariat.CommunityCategoriesController = Volontariat.Controller.extend(Volontariat.PaginationController, Volontariat.CommunityCategoryPersistence,
|
2
|
+
paginationResource: 'community_category', paginationRoute: 'community.categories'
|
3
|
+
|
4
|
+
anyItems: (-> @get('content.length') > 0).property('content')
|
5
|
+
)
|
data/app/assets/javascripts/voluntary_feedback/controllers/community/category_controller.js.coffee
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Volontariat.CommunityCategoryController = Volontariat.Controller.extend(Volontariat.CommunityCategoryPersistence)
|
data/app/assets/javascripts/voluntary_feedback/controllers/community/feedback_controller.js.coffee
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Volontariat.CommunityFeedbackController = Volontariat.Controller.extend(Volontariat.PaginationController, Volontariat.FeedbackPersistence,
|
2
|
+
paginationRoute: 'community.feedback', paginationResource: 'reply', replies: [], newReplyMode: false
|
3
|
+
anyReplies: (-> @get('replies.length') > 0).property('replies')
|
4
|
+
feedbackTypeRoute: (-> "community.#{@get('feedbackType').pluralize().toLowerCase()}").property('feedbackType')
|
5
|
+
|
6
|
+
actions:
|
7
|
+
|
8
|
+
newReply: ->
|
9
|
+
@set 'replyId', null
|
10
|
+
@set 'newReplyMode', true
|
11
|
+
|
12
|
+
leaveNewReplyMode: ->
|
13
|
+
@set 'newReplyMode', false
|
14
|
+
|
15
|
+
editReply: (id) ->
|
16
|
+
@set 'newReplyMode', false
|
17
|
+
@set 'replyId', id
|
18
|
+
|
19
|
+
leaveEditReplyMode: ->
|
20
|
+
@set 'replyId', null
|
21
|
+
|
22
|
+
reload: ->
|
23
|
+
@transitionToRoute 'no_data'
|
24
|
+
@transitionToRoute 'community.feedback', @get('communitySlug'), @get('slug'), @get('page')
|
25
|
+
)
|
data/app/assets/javascripts/voluntary_feedback/controllers/community/feedbacks_controller.js.coffee
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Volontariat.CommunityFeedbacksController = Volontariat.Controller.extend(Volontariat.PaginationController, Volontariat.FeedbackPersistence,
|
2
|
+
paginationResource: 'feedback'
|
3
|
+
|
4
|
+
anyItems: (-> @get('content.length') > 0).property('content')
|
5
|
+
feedbackClass: (-> if @get('feedbackType') == 'Feedback' then 'active' else '').property('feedbackType')
|
6
|
+
problemClass: (-> if @get('feedbackType') == 'Problem' then 'active' else '').property('feedbackType')
|
7
|
+
questionClass: (-> if @get('feedbackType') == 'Question' then 'active' else '').property('feedbackType')
|
8
|
+
ideaClass: (-> if @get('feedbackType') == 'Idea' then 'active' else '').property('feedbackType')
|
9
|
+
praiseClass: (-> if @get('feedbackType') == 'Praise' then 'active' else '').property('feedbackType')
|
10
|
+
announcementClass: (-> if @get('feedbackType') == 'Announcement' then 'active' else '').property('feedbackType')
|
11
|
+
)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Ember.Handlebars.helper 'mood-icon', (index, options) ->
|
2
|
+
if index == 0
|
3
|
+
new (Ember.Handlebars.SafeString)('<img src="http://twemoji.maxcdn.com/72x72/1f600.png" style="width:16px; height:16px;"/>')
|
4
|
+
else if index == 1
|
5
|
+
new (Ember.Handlebars.SafeString)('<img src="http://twemoji.maxcdn.com/72x72/1f60b.png" style="width:16px; height:16px;"/>')
|
6
|
+
else if index == 2
|
7
|
+
new (Ember.Handlebars.SafeString)('<img src="http://twemoji.maxcdn.com/72x72/1f610.png" style="width:16px; height:16px;"/>')
|
8
|
+
else if index == 2
|
9
|
+
new (Ember.Handlebars.SafeString)('<img src="http://twemoji.maxcdn.com/72x72/1f61f.png" style="width:16px; height:16px;"/>')
|
10
|
+
else
|
11
|
+
'-'
|
data/app/assets/javascripts/voluntary_feedback/mixins/community_category_persistence.js.coffee
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Volontariat.CommunityCategoryPersistence = Em.Mixin.create
|
2
|
+
actions:
|
3
|
+
|
4
|
+
save: ->
|
5
|
+
$.ajax(
|
6
|
+
type: if @get('categorySlug') then 'PUT' else 'POST'
|
7
|
+
url: '/api/v1/community_categories' + if @get('categorySlug') then "/#{@get('categorySlug')}" else '',
|
8
|
+
data: {
|
9
|
+
community_category: { community_slug: @get('communitySlug'), name: $('#community_category_name').val() }
|
10
|
+
}
|
11
|
+
).success((data) =>
|
12
|
+
if data.errors
|
13
|
+
Volontariat.alert 'danger', "#{Volontariat.t('community_categories.save.failed')}: #{JSON.stringify(data.errors)}"
|
14
|
+
else
|
15
|
+
@transitionToRoute 'community.category.feedbacks', @get('communitySlug'), data.community_category.slug, 1
|
16
|
+
Volontariat.alert 'success', Volontariat.t('community_categories.save.successful')
|
17
|
+
).fail((data) =>
|
18
|
+
Volontariat.alert 'danger', "#{Volontariat.t('community_categories.save.failed')}!"
|
19
|
+
)
|
20
|
+
|
21
|
+
destroy: (slug) ->
|
22
|
+
if confirm(Volontariat.t('community_categories.destroy.confirmation'))
|
23
|
+
$.ajax("/api/v1/community_categories/#{slug}?community_slug=#{@get('communitySlug')}", type: 'DELETE').done((data) =>
|
24
|
+
@set 'categorySlug', null
|
25
|
+
@transitionToRoute 'no_data'
|
26
|
+
@transitionToRoute 'community.categories', @get('communitySlug'), 1
|
27
|
+
).fail((data) ->
|
28
|
+
Volontariat.alert 'danger', Volontariat.t('activerecord.errors.models.community_category.attributes.base.deletion_failed')
|
29
|
+
)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Volontariat.CommunityPersistence = Em.Mixin.create
|
2
|
+
organizations: []
|
3
|
+
|
4
|
+
actions:
|
5
|
+
|
6
|
+
save: ->
|
7
|
+
$.ajax(
|
8
|
+
type: if @get('slug') then 'PUT' else 'POST'
|
9
|
+
url: '/api/v1/communities' + if @get('slug') then "/#{@get('slug')}" else '',
|
10
|
+
data: {
|
11
|
+
community: {
|
12
|
+
organization_id: $('#community_organization_id').val(), name: $('#community_name').val(),
|
13
|
+
text: $('#community_text').val()
|
14
|
+
}
|
15
|
+
}
|
16
|
+
).success((data) =>
|
17
|
+
if data.errors
|
18
|
+
Volontariat.alert 'danger', "#{Volontariat.t('communities.save.failed')}: #{JSON.stringify(data.errors)}"
|
19
|
+
else
|
20
|
+
@transitionToRoute 'community.feedbacks', data.community.slug, 1
|
21
|
+
Volontariat.alert 'success', Volontariat.t('communities.save.successful')
|
22
|
+
).fail((data) =>
|
23
|
+
Volontariat.alert 'danger', "#{Volontariat.t('communities.save.failed')}!"
|
24
|
+
)
|
25
|
+
|
26
|
+
destroy: (slug) ->
|
27
|
+
if confirm(Volontariat.t('communities.destroy.confirmation'))
|
28
|
+
$.ajax("/api/v1/communities/#{slug}", type: 'DELETE').done((data) =>
|
29
|
+
@transitionToRoute 'no_data'
|
30
|
+
@transitionToRoute 'communities', 1
|
31
|
+
).fail((data) ->
|
32
|
+
Volontariat.alert 'danger', Volontariat.t('activerecord.errors.models.community.attributes.base.deletion_failed')
|
33
|
+
)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Volontariat.FeedbackPersistence = Em.Mixin.create
|
2
|
+
categories: []
|
3
|
+
|
4
|
+
actions:
|
5
|
+
|
6
|
+
save: ->
|
7
|
+
categoryIds = jQuery.map($('input[name="category_ids[]"]:checked'), (categoryField) ->
|
8
|
+
$(categoryField).val()
|
9
|
+
)
|
10
|
+
|
11
|
+
$.ajax(
|
12
|
+
type: if @get('slug') then 'PUT' else 'POST'
|
13
|
+
url: '/api/v1/feedbacks' + if @get('slug') then "/#{@get('slug')}" else '',
|
14
|
+
data: {
|
15
|
+
feedback: {
|
16
|
+
community_slug: @get('communitySlug'), feedback_type: $('#feedback_feedback_type').val()
|
17
|
+
name: $('#feedback_name').val(), text: $('#feedback_text').val(),
|
18
|
+
mood_type: $('input[name="feedback[mood_type]"]:checked').val(), mood_text: $('#feedback_mood_text').val(),
|
19
|
+
category_ids: categoryIds
|
20
|
+
}
|
21
|
+
}
|
22
|
+
).success((data) =>
|
23
|
+
if data.errors
|
24
|
+
Volontariat.alert 'danger', "#{Volontariat.t('feedbacks.save.failed')}: #{JSON.stringify(data.errors)}"
|
25
|
+
else
|
26
|
+
@transitionToRoute 'community.feedback', @get('communitySlug'), data.feedback.slug, 1
|
27
|
+
Volontariat.alert 'success', Volontariat.t('feedbacks.save.successful')
|
28
|
+
).fail((data) =>
|
29
|
+
Volontariat.alert 'danger', "#{Volontariat.t('feedbacks.save.failed')}!"
|
30
|
+
)
|
31
|
+
|
32
|
+
destroy: (slug) ->
|
33
|
+
if confirm(Volontariat.t('feedbacks.destroy.confirmation'))
|
34
|
+
$.ajax("/api/v1/feedbacks/#{slug}?community_slug=#{@get('communitySlug')}", type: 'DELETE').done((data) =>
|
35
|
+
@transitionToRoute 'no_data'
|
36
|
+
@transitionToRoute 'community.feedbacks', @get('communitySlug'), 1
|
37
|
+
).fail((data) ->
|
38
|
+
Volontariat.alert 'danger', Volontariat.t('activerecord.errors.models.feedback.attributes.base.deletion_failed')
|
39
|
+
)
|
@@ -0,0 +1,56 @@
|
|
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
|
+
|
15
|
+
if @get('metadata')
|
16
|
+
@set 'totalPages', @get('metadata').pagination.total_pages
|
17
|
+
else if @store.metadataFor(@get('paginationResource')).pagination
|
18
|
+
@set 'totalPages', @store.metadataFor(@get('paginationResource')).pagination.total_pages
|
19
|
+
else
|
20
|
+
@set 'totalPages', 1
|
21
|
+
|
22
|
+
pages = []; i = page - 4
|
23
|
+
|
24
|
+
while i <= page
|
25
|
+
pages.push i if i > 0
|
26
|
+
i += 1
|
27
|
+
|
28
|
+
i = page + 1
|
29
|
+
|
30
|
+
while i <= page + 4
|
31
|
+
pages.push i if i <= @get('totalPages')
|
32
|
+
i += 1
|
33
|
+
|
34
|
+
pages = pages.map((item) ->
|
35
|
+
number: item
|
36
|
+
isCurrent: item is page
|
37
|
+
)
|
38
|
+
|
39
|
+
@set('pages', pages)
|
40
|
+
|
41
|
+
actions:
|
42
|
+
goToPage: (page) ->
|
43
|
+
@_goToPage(page)
|
44
|
+
|
45
|
+
switch @get('paginationRoute')
|
46
|
+
when 'community.categories'
|
47
|
+
@transitionToRoute @get('paginationRoute'), @get('communitySlug'), page
|
48
|
+
when 'community.feedbacks', 'community.problems', 'community.questions', 'community.ideas', 'community.praises', 'community.announcements'
|
49
|
+
@transitionToRoute @get('paginationRoute'), @get('communitySlug'), page
|
50
|
+
when 'community.category.feedbacks', 'community.category.problems', 'community.category.questions', 'community.category.ideas', 'community.category.praises', 'community.category.announcements'
|
51
|
+
@transitionToRoute @get('paginationRoute'), @get('communitySlug'), @get('categorySlug'), page
|
52
|
+
when 'community.feedback'
|
53
|
+
@transitionToRoute @get('paginationRoute'), @get('communitySlug'), @get('slug'), page
|
54
|
+
|
55
|
+
goToPageWithoutRedirect: (page) ->
|
56
|
+
@_goToPage(page)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Volontariat.Feedback = DS.Model.extend
|
2
|
+
feedbackType: DS.attr('string')
|
3
|
+
userId: DS.attr('number')
|
4
|
+
userName: DS.attr('string')
|
5
|
+
userSlug: DS.attr('string')
|
6
|
+
slug: DS.attr('string')
|
7
|
+
name: DS.attr('string')
|
8
|
+
text: DS.attr('string')
|
9
|
+
moodType: DS.attr('number')
|
10
|
+
moodText: DS.attr('string')
|
11
|
+
likesCount: DS.attr('number')
|
12
|
+
dislikesCount: DS.attr('number')
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Volontariat.User.reopenClass Volontariat.Singleton,
|
2
|
+
createCurrent: ->
|
3
|
+
userJson = PreloadStore.get("currentUser")
|
4
|
+
|
5
|
+
return userJson
|
6
|
+
|
7
|
+
# TODO: build record from JSON to save find query without posting it after next store commit
|
8
|
+
#return Volontariat.__container__.lookup('store:main').createRecord(userJson) if userJson
|
9
|
+
|
10
|
+
if userJson
|
11
|
+
return Volontariat.__container__.lookup('store:main').query('user', userJson.id)
|
12
|
+
|
13
|
+
Volontariat.__container__.lookup('store:main').query('user', userJson.id).then (current_user) ->
|
14
|
+
Volontariat.currentUser = current_user
|
15
|
+
|
16
|
+
return Volontariat.currentUser
|
17
|
+
|
18
|
+
null
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Volontariat.Router.reopen location: 'hash'
|
2
|
+
|
3
|
+
Volontariat.Router.map ->
|
4
|
+
@_super
|
5
|
+
|
6
|
+
@route 'communities', path: '/communities/page/:page'
|
7
|
+
|
8
|
+
@resource 'community', path: '/communities/:slug', ->
|
9
|
+
@route 'categories', path: 'categories/page/:page'
|
10
|
+
|
11
|
+
@route 'category', path: 'categories/:category_slug', ->
|
12
|
+
@route 'feedbacks', path: 'feedbacks/page/:page'
|
13
|
+
@route 'problems', path: 'problems/page/:page'
|
14
|
+
@route 'questions', path: 'questions/page/:page'
|
15
|
+
@route 'ideas', path: 'ideas/page/:page'
|
16
|
+
@route 'praises', path: 'praises/page/:page'
|
17
|
+
@route 'announcements', path: 'announcements/page/:page'
|
18
|
+
|
19
|
+
@route 'new_category', path: 'categories/new'
|
20
|
+
@route 'edit_category', path: 'categories/:category_slug/edit'
|
21
|
+
|
22
|
+
@route 'feedbacks', path: 'feedbacks/page/:page'
|
23
|
+
@route 'problems', path: 'problems/page/:page'
|
24
|
+
@route 'questions', path: 'questions/page/:page'
|
25
|
+
@route 'ideas', path: 'ideas/page/:page'
|
26
|
+
@route 'praises', path: 'praises/page/:page'
|
27
|
+
@route 'announcements', path: 'announcements/page/:page'
|
28
|
+
|
29
|
+
@route 'new_feedback', path: 'feedbacks/new'
|
30
|
+
@route 'feedback', path: 'feedbacks/:feedback_slug/page/:page'
|
31
|
+
@route 'edit_feedback', path: 'feedbacks/:feedback_slug/edit'
|
32
|
+
|
33
|
+
@route 'new_community', path: '/communities/new'
|
34
|
+
@route 'edit_community', path: '/communities/:slug/edit'
|