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
@@ -0,0 +1,29 @@
|
|
1
|
+
<form class="simple_form form-vertical" novalidate="novalidate" id="new_community" action="/" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="✓" /><input type="hidden" name="authenticity_token" value="S/2IhDP+fivIazYOP45n9nH1UZWIMjh5KEY4j7M4k5zmohHqb50iEp5uZWrgYGqbYhxYEfB9ZGEjc4ahrXu9uw==" />
|
2
|
+
<div class="form-group select required community_organization_id">
|
3
|
+
<label class="select required control-label control-label" for="community_organization_id">
|
4
|
+
<abbr title="required">*</abbr> {{t 'activerecord.models.organization'}}
|
5
|
+
</label>
|
6
|
+
<select class="select required form-control" name="community[organization_id]" id="community_organization_id">
|
7
|
+
{{#each organizations as |organization|}}
|
8
|
+
<option value="{{organization.id}}">{{organization.name}}</option>
|
9
|
+
{{/each}}
|
10
|
+
</select>
|
11
|
+
</div>
|
12
|
+
<div class="form-group string required community_name">
|
13
|
+
<label class="string required control-label control-label" for="community_name">
|
14
|
+
<abbr title="required">*</abbr> {{t 'attributes.name'}}
|
15
|
+
</label>
|
16
|
+
{{input value=name class="string required form-control" type="text" name="community[name]" id="community_name"}}
|
17
|
+
</div>
|
18
|
+
<div class="form-group text required community_text">
|
19
|
+
<label class="text required control-label control-label" for="community_text">
|
20
|
+
{{t 'attributes.text'}}
|
21
|
+
</label>
|
22
|
+
{{textarea value=text style="width: 500px; height:300px;" class="text required form-control" name="community[text]" id="community_text"}}
|
23
|
+
</div>
|
24
|
+
{{#if slug}}
|
25
|
+
<input type="submit" name="commit" value="{{t 'communities.update.title' true }}" class="btn btn-default" {{action 'save'}}/>
|
26
|
+
{{else}}
|
27
|
+
<input type="submit" name="commit" value="{{t 'communities.create.title' true }}" class="btn btn-default" {{action 'save'}}/>
|
28
|
+
{{/if}}
|
29
|
+
</form>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{{#if editMode}}
|
2
|
+
<form class="simple_form form-vertical" novalidate="novalidate" accept-charset="UTF-8">
|
3
|
+
<div class="form-group text required reply_text">
|
4
|
+
<label class="text required control-label control-label" for="reply_text">
|
5
|
+
<abbr title="required">*</abbr> {{t 'attributes.text'}}
|
6
|
+
</label>
|
7
|
+
{{textarea value=text class="text required form-control" name="reply[text]" id="reply_text"}}
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<p></p>
|
11
|
+
|
12
|
+
<input type="submit" name="commit" value="{{t 'general.cancel' true}}" class="btn btn-default" {{action 'cancel'}}/>
|
13
|
+
|
14
|
+
{{#if id}}
|
15
|
+
<input type="submit" name="commit" value="{{t 'replies.update.title' true }}" class="btn btn-default" {{action 'save'}}/>
|
16
|
+
{{else}}
|
17
|
+
<input type="submit" name="commit" value="{{t 'replies.create.title' true }}" class="btn btn-default" {{action 'save'}}/>
|
18
|
+
{{/if}}
|
19
|
+
</form>
|
20
|
+
{{else}}
|
21
|
+
{{#if id}}
|
22
|
+
{{text}}
|
23
|
+
|
24
|
+
{{#if your}}
|
25
|
+
<a {{action 'edit'}} class="edit_reply_link">
|
26
|
+
<span class="glyphicon glyphicon-pencil"></span> {{t 'general.edit'}}
|
27
|
+
</a>
|
28
|
+
|
|
29
|
+
<a {{action 'destroy'}} class="remove_reply_link">
|
30
|
+
<span class="glyphicon glyphicon-remove"></span> {{t 'general.remove'}}
|
31
|
+
</a>
|
32
|
+
{{/if}}
|
33
|
+
{{/if}}
|
34
|
+
{{/if}}
|
data/app/assets/javascripts/voluntary_feedback/templates/components/reply-comments.js.handlebars
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
<a {{action 'add'}}>{{t 'activerecord.models.comment'}}</a>
|
2
|
+
|
3
|
+
<table class="table">
|
4
|
+
{{#if new}}
|
5
|
+
<tr>
|
6
|
+
<td style="width:150px; padding-top:15px;"></td>
|
7
|
+
<td style="padding-top:15px;">
|
8
|
+
{{reply-cell replyId=replyId reloadAction='reload' leaveNewReplyModeAction='leaveNewReplyCommentMode'}}
|
9
|
+
</td>
|
10
|
+
</tr>
|
11
|
+
{{/if}}
|
12
|
+
|
13
|
+
{{#each collection as |reply|}}
|
14
|
+
<tr>
|
15
|
+
<td style="width:150px; padding-top:15px;">{{reply.user_name}}</td>
|
16
|
+
<td style="text-align:right; padding-top:15px;">{{formatted-datetime reply.created_at}}</td>
|
17
|
+
</tr>
|
18
|
+
<tr>
|
19
|
+
<td></td>
|
20
|
+
<td class="reply_text">
|
21
|
+
{{reply-cell userId=reply.user_id replyId=replyId selectedId=selectedReplyId id=reply.id text=reply.text editAction='editReply' leaveEditReplyModeAction='leaveEditReplyMode' reloadAction='reload'}}
|
22
|
+
<br/>
|
23
|
+
{{like-or-dislike targetType='Reply' targetId=reply.id positive=reply.positive likes=reply.likes_count dislikes=reply.dislikes_count}}
|
24
|
+
</td>
|
25
|
+
</tr>
|
26
|
+
{{/each}}
|
27
|
+
</table>
|
@@ -0,0 +1,91 @@
|
|
1
|
+
<form class="simple_form form-vertical" novalidate="novalidate" accept-charset="UTF-8">
|
2
|
+
<div class="form-group select optional feedback_feedback_type">
|
3
|
+
<label class="select optional control-label control-label" for="feedback_feedback_type">
|
4
|
+
{{t 'activerecord.attributes.feedback.feedback_type'}}
|
5
|
+
</label>
|
6
|
+
<select class="select optional form-control" name="feedback[feedback_type]" id="feedback_feedback_type">
|
7
|
+
<option value="Problem">{{t 'feedbacks.show.problem'}}</option>
|
8
|
+
<option value="Question">{{t 'feedbacks.show.question'}}</option>
|
9
|
+
<option value="Idea">{{t 'feedbacks.show.idea'}}</option>
|
10
|
+
<option value="Praise">{{t 'feedbacks.show.praise'}}</option>
|
11
|
+
<option value="Announcement">{{t 'feedbacks.show.announcement'}}</option>
|
12
|
+
</select>
|
13
|
+
</div>
|
14
|
+
<div class="form-group string required feedback_name">
|
15
|
+
<label class="string required control-label control-label" for="feedback_name">
|
16
|
+
<abbr title="required">*</abbr> {{t 'activerecord.attributes.feedback.name'}}
|
17
|
+
</label>
|
18
|
+
{{input value=name class="string required form-control" type="text" name="feedback[name]" id="feedback_name"}}
|
19
|
+
</div>
|
20
|
+
<div class="form-group text required feedback_text">
|
21
|
+
<label class="text required control-label control-label" for="feedback_text">
|
22
|
+
<abbr title="required">*</abbr> {{t 'attributes.text'}}
|
23
|
+
</label>
|
24
|
+
{{textarea value=text class="text required form-control" name="feedback[text]" id="feedback_text"}}
|
25
|
+
</div>
|
26
|
+
<fieldset class="form-inline">
|
27
|
+
<div class="form-group radio_buttons optional feedback_mood_type">
|
28
|
+
<label class="radio_buttons optional control-label control-label">
|
29
|
+
{{t 'activerecord.attributes.feedback.mood_type'}}
|
30
|
+
|
31
|
+
</label>
|
32
|
+
<span class="radio">
|
33
|
+
<label for="feedback_mood_type_0">
|
34
|
+
<input class="radio_buttons optional" type="radio" value="0" name="feedback[mood_type]" id="feedback_mood_type_0" />
|
35
|
+
|
36
|
+
<img src="http://twemoji.maxcdn.com/72x72/1f600.png" style="width:32px; height:32px;"/>
|
37
|
+
|
38
|
+
</label>
|
39
|
+
</span>
|
40
|
+
<span class="radio">
|
41
|
+
<label for="feedback_mood_type_1">
|
42
|
+
<input class="radio_buttons optional" type="radio" value="1" name="feedback[mood_type]" id="feedback_mood_type_1" />
|
43
|
+
|
44
|
+
<img src="http://twemoji.maxcdn.com/72x72/1f60b.png" style="width:32px; height:32px;"/>
|
45
|
+
|
46
|
+
</label>
|
47
|
+
</span>
|
48
|
+
<span class="radio">
|
49
|
+
<label for="feedback_mood_type_2">
|
50
|
+
<input class="radio_buttons optional" type="radio" value="2" name="feedback[mood_type]" id="feedback_mood_type_1" />
|
51
|
+
|
52
|
+
<img src="http://twemoji.maxcdn.com/72x72/1f610.png" style="width:32px; height:32px;"/>
|
53
|
+
|
54
|
+
</label>
|
55
|
+
</span>
|
56
|
+
<span class="radio">
|
57
|
+
<label for="feedback_mood_type_3">
|
58
|
+
<input class="radio_buttons optional" type="radio" value="3" name="feedback[mood_type]" id="feedback_mood_type_1" />
|
59
|
+
|
60
|
+
<img src="http://twemoji.maxcdn.com/72x72/1f61f.png" style="width:32px; height:32px;"/>
|
61
|
+
|
62
|
+
</label>
|
63
|
+
</span>
|
64
|
+
</div>
|
65
|
+
<div class="form-group string optional feedback_mood_text">
|
66
|
+
<label class="string optional control-label control-label" for="feedback_mood_text">
|
67
|
+
{{t 'activerecord.attributes.feedback.mood_text'}}
|
68
|
+
</label>
|
69
|
+
|
70
|
+
{{input value=moodText class="string optional form-control" type="text" name="feedback[mood_text]" id="feedback_mood_text"}}
|
71
|
+
</div>
|
72
|
+
</fieldset>
|
73
|
+
|
74
|
+
<div class="form-group string optional feedback_categories">
|
75
|
+
<label class="string optional control-label control-label" for="feedback_categories">
|
76
|
+
{{t 'community_categories.index.title'}}
|
77
|
+
</label>
|
78
|
+
|
79
|
+
{{#each categories as |category|}}
|
80
|
+
<input type="checkbox" name="category_ids[]" value="{{category.id}}"/> {{category.name}}
|
81
|
+
{{/each}}
|
82
|
+
</div>
|
83
|
+
|
84
|
+
<p></p>
|
85
|
+
|
86
|
+
{{#if slug}}
|
87
|
+
<input type="submit" name="commit" value="{{t 'feedbacks.update.title' true }}" class="btn btn-default" {{action 'save'}}/>
|
88
|
+
{{else}}
|
89
|
+
<input type="submit" name="commit" value="{{t 'feedbacks.create.title' true }}" class="btn btn-default" {{action 'save'}}/>
|
90
|
+
{{/if}}
|
91
|
+
</form>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<div class="navbar navbar-inverse navbar-fixed-top">
|
2
|
+
<div class="container">
|
3
|
+
<a id="plattform_brand" class="navbar-brand" href="/">Volontari.at /</a>
|
4
|
+
<a id="product_brand" class="navbar-brand" href="#">Feedback</a>
|
5
|
+
|
6
|
+
<ul class="navbar-nav nav">
|
7
|
+
{{#link-to 'communities' 1 tagName='li'}}<a>{{t 'communities.index.title'}}</a>{{/link-to}}
|
8
|
+
{{#if currentUser}}
|
9
|
+
<li class="dropdown">
|
10
|
+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
11
|
+
{{t 'general.account'}}
|
12
|
+
<b class="caret"></b>
|
13
|
+
</a>
|
14
|
+
<ul class="dropdown-menu">
|
15
|
+
<li>
|
16
|
+
<a {{action 'signOut'}}>{{t 'general.sign_out'}}</a>
|
17
|
+
</li>
|
18
|
+
</ul>
|
19
|
+
</li>
|
20
|
+
{{else}}
|
21
|
+
<li>
|
22
|
+
<a href="/users/sign_in">{{t 'general.authentication'}}</a>
|
23
|
+
</li>
|
24
|
+
{{/if}}
|
25
|
+
<li><a href="http://GitHub.com/Volontariat/voluntary_feedback/issues">{{t 'general.issues' }}</a></li>
|
26
|
+
</ul>
|
27
|
+
</div>
|
28
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<nav>
|
2
|
+
<ul class="pagination">
|
3
|
+
{{#if controller.showFirstPageLink}}
|
4
|
+
<li class="first"><a {{action 'goToPage' 1}}>« First</a></li>
|
5
|
+
{{/if}}
|
6
|
+
|
7
|
+
{{#if controller.showPreviousPageLink}}
|
8
|
+
<li class="prev"><a {{action 'goToPage' controller.previousPage}}>« Previous</a></li>
|
9
|
+
{{/if}}
|
10
|
+
|
11
|
+
{{#each controller.pages as |currentPage|}}
|
12
|
+
<li class="{{if currentPage.isCurrent 'active'}}"><a href="#" {{action 'goToPage' currentPage.number}}>{{currentPage.number}}</a></li>
|
13
|
+
{{/each}}
|
14
|
+
|
15
|
+
{{#if controller.showNextPageLink}}
|
16
|
+
<li class="next_page"><a {{action 'goToPage' controller.nextPage}}>Next »</a></li>
|
17
|
+
{{/if}}
|
18
|
+
|
19
|
+
{{#if controller.showLastPageLink}}
|
20
|
+
<li class="last next"><a {{action 'goToPage' controller.totalPages}}>Last »</a></li>
|
21
|
+
{{/if}}
|
22
|
+
</ul>
|
23
|
+
</nav>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require voluntary/ember_js/application
|
12
|
+
*= require_self
|
13
|
+
*/
|
14
|
+
|
15
|
+
.reply_text .ember-view { display:inline; }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Product::FeedbackController < Voluntary::EmberJs::ApplicationController
|
2
|
+
layout Proc.new { |controller| controller.request.xhr? || request.format.try('json?') ? false : 'voluntary/ember_js' }
|
3
|
+
|
4
|
+
def index
|
5
|
+
end
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def voluntary_ember_js_stylesheets
|
10
|
+
['voluntary_feedback/application']
|
11
|
+
end
|
12
|
+
|
13
|
+
def voluntary_ember_js_javascripts
|
14
|
+
['voluntary_feedback/application']
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class Voluntary::Api::V1::CommunitiesController < ActionController::Base
|
2
|
+
include Voluntary::V1::BaseController
|
3
|
+
|
4
|
+
respond_to :json
|
5
|
+
|
6
|
+
def index
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
options[:json] = Community.paginate page: params[:page], per_page: 10
|
10
|
+
|
11
|
+
options[:meta] = {
|
12
|
+
pagination: {
|
13
|
+
total_pages: options[:json].total_pages, current_page: options[:json].current_page,
|
14
|
+
previous_page: options[:json].previous_page, next_page: options[:json].next_page
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
respond_with do |format|
|
19
|
+
format.json { render options }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def show
|
24
|
+
respond_to do |format|
|
25
|
+
format.json do
|
26
|
+
render json: Community.friendly.find(params[:id])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def create
|
32
|
+
current_user.organizations.find(params[:community][:organization_id])
|
33
|
+
resource = Community.create params[:community]
|
34
|
+
|
35
|
+
respond_to do |format|
|
36
|
+
format.json do
|
37
|
+
render json: resource.persisted? ? resource : { errors: resource.errors.to_hash }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def update
|
43
|
+
resource = current_user.communities.friendly.find params[:id]
|
44
|
+
resource.update_attributes params[:community]
|
45
|
+
|
46
|
+
respond_to do |format|
|
47
|
+
format.json do
|
48
|
+
render json: resource.valid? ? resource : { errors: resource.errors.to_hash }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def destroy
|
54
|
+
resource = current_user.communities.friendly.find params[:id]
|
55
|
+
resource.destroy
|
56
|
+
|
57
|
+
respond_to do |format|
|
58
|
+
format.json do
|
59
|
+
render json: if resource.persisted?
|
60
|
+
{ error: I18n.t('activerecord.errors.models.community.attributes.base.deletion_failed') }
|
61
|
+
else
|
62
|
+
{}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
class Voluntary::Api::V1::CommunityCategoriesController < ActionController::Base
|
2
|
+
include Voluntary::V1::BaseController
|
3
|
+
|
4
|
+
respond_to :json
|
5
|
+
|
6
|
+
def index
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
community = Community.friendly.find(params[:community_slug])
|
10
|
+
|
11
|
+
collection = if params[:feedback_slug]
|
12
|
+
community.feedbacks.friendly.find(params[:feedback_slug]).categories
|
13
|
+
else
|
14
|
+
community.categories
|
15
|
+
end
|
16
|
+
|
17
|
+
options[:json] = collection.paginate page: params[:page], per_page: params[:feedback_slug] ? 50 : 10
|
18
|
+
|
19
|
+
options[:meta] = {
|
20
|
+
pagination: {
|
21
|
+
total_pages: options[:json].total_pages, current_page: options[:json].current_page,
|
22
|
+
previous_page: options[:json].previous_page, next_page: options[:json].next_page
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
respond_with do |format|
|
27
|
+
format.json { render options }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def show
|
32
|
+
respond_to do |format|
|
33
|
+
format.json do
|
34
|
+
render json: Community.friendly.find(params[:community_slug]).categories.friendly.find(params[:id])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def create
|
40
|
+
community = Community.friendly.find(params[:community_category][:community_slug])
|
41
|
+
|
42
|
+
raise CanCan::AccessDenied unless community.organization.user_id == current_user.id
|
43
|
+
|
44
|
+
resource = community.categories.new params[:community_category]
|
45
|
+
resource.save
|
46
|
+
|
47
|
+
respond_to do |format|
|
48
|
+
format.json do
|
49
|
+
render json: resource.persisted? ? resource : { errors: resource.errors.to_hash }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def update
|
55
|
+
community = Community.friendly.find(params[:community_category][:community_slug])
|
56
|
+
|
57
|
+
raise CanCan::AccessDenied unless community.organization.user_id == current_user.id
|
58
|
+
|
59
|
+
resource = community.categories.friendly.find(params[:id])
|
60
|
+
resource.update_attributes params[:community_category]
|
61
|
+
|
62
|
+
respond_to do |format|
|
63
|
+
format.json do
|
64
|
+
render json: resource.valid? ? resource : { errors: resource.errors.to_hash }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def destroy
|
70
|
+
community = Community.friendly.find(params[:community_slug])
|
71
|
+
|
72
|
+
raise CanCan::AccessDenied unless community.organization.user_id == current_user.id
|
73
|
+
|
74
|
+
resource = community.categories.friendly.find(params[:id])
|
75
|
+
resource.destroy
|
76
|
+
|
77
|
+
respond_to do |format|
|
78
|
+
format.json do
|
79
|
+
render json: if resource.persisted?
|
80
|
+
{ error: I18n.t('activerecord.errors.models.community_category.attributes.base.deletion_failed') }
|
81
|
+
else
|
82
|
+
{}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|