voluntary_brainstorming 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +3 -2
- data/app/assets/javascripts/voluntary_brainstorming/app.js.coffee +8 -0
- data/app/assets/javascripts/voluntary_brainstorming/application.js +4 -0
- data/app/assets/javascripts/voluntary_brainstorming/components/brainstorming_idea_argument_component.js.coffee +63 -0
- data/app/assets/javascripts/voluntary_brainstorming/components/brainstorming_idea_cell_component.js.coffee +34 -0
- data/app/assets/javascripts/voluntary_brainstorming/components/brainstorming_idea_vote_component.js.coffee +46 -0
- data/app/assets/javascripts/voluntary_brainstorming/controllers/brainstorming_controller.js.coffee +79 -0
- data/app/assets/javascripts/voluntary_brainstorming/controllers/user_brainstormings_controller.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_brainstorming/mixins/destroy_brainstorming.js.coffee +14 -0
- data/app/assets/javascripts/voluntary_brainstorming/mixins/pagination_controller.js.coffee +43 -0
- data/app/assets/javascripts/voluntary_brainstorming/models/brainstorming.js.coffee +6 -0
- data/app/assets/javascripts/voluntary_brainstorming/models/user.js.coffee +18 -0
- data/app/assets/javascripts/voluntary_brainstorming/router.js.coffee +9 -0
- data/app/assets/javascripts/voluntary_brainstorming/routes/brainstorming_route.js.coffee +37 -0
- data/app/assets/javascripts/voluntary_brainstorming/routes/edit_brainstorming_route.js.coffee +16 -0
- data/app/assets/javascripts/voluntary_brainstorming/routes/index_route.js.coffee +4 -0
- data/app/assets/javascripts/voluntary_brainstorming/routes/new_brainstorming_route.js.coffee +5 -0
- data/app/assets/javascripts/voluntary_brainstorming/routes/user_brainstormings_route.js.coffee +20 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/application.handlebars.erb +20 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/brainstorming.js.handlebars +77 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/brainstorming_form.js.handlebars +18 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/brainstorming_idea_form.js.handlebars +19 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/components/brainstorming-idea-argument.js.handlebars +86 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/components/brainstorming-idea-cell.js.handlebars +7 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/components/brainstorming-idea-vote.js.handlebars +6 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/edit_brainstorming.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/navigation.js.handlebars +28 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/new_brainstorming.js.handlebars +3 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/shared/_pagination.js.handlebars +23 -0
- data/app/assets/javascripts/voluntary_brainstorming/templates/user_brainstormings.js.handlebars +33 -0
- data/app/assets/stylesheets/voluntary_brainstorming/application.css +13 -0
- data/app/controllers/product/brainstorming_controller.rb +16 -0
- data/app/controllers/voluntary/api/v1/brainstorming_idea_votes_controller.rb +38 -0
- data/app/controllers/voluntary/api/v1/brainstorming_ideas_controller.rb +66 -0
- data/app/controllers/voluntary/api/v1/brainstormings_controller.rb +70 -0
- data/app/models/brainstorming.rb +18 -0
- data/app/models/brainstorming_idea.rb +53 -0
- data/app/models/brainstorming_idea_vote.rb +32 -0
- data/app/models/product/brainstorming.rb +2 -0
- data/app/serializers/brainstorming_idea_serializer.rb +15 -0
- data/app/serializers/brainstorming_idea_vote_serializer.rb +11 -0
- data/app/serializers/brainstorming_serializer.rb +7 -0
- data/app/views/product/brainstorming/index.html.erb +0 -0
- data/config/locales/resources/brainstorming/en.yml +26 -0
- data/config/locales/resources/brainstorming_idea_votes/en.yml +18 -0
- data/config/locales/resources/brainstorming_ideas/en.yml +31 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20150818181847_add_brainstorming_product.rb +51 -0
- data/lib/voluntary_brainstorming.rb +5 -1
- data/lib/voluntary_brainstorming/concerns/model/argument/publishes_changes_to_brainstorming.rb +49 -0
- data/lib/voluntary_brainstorming/concerns/model/user/has_brainstormings.rb +17 -0
- data/lib/voluntary_brainstorming/engine.rb +13 -0
- data/lib/voluntary_brainstorming/version.rb +1 -1
- metadata +322 -37
- data/MIT-LICENSE +0 -20
@@ -0,0 +1,20 @@
|
|
1
|
+
{{render 'navigation'}}
|
2
|
+
|
3
|
+
<section id="dialog">
|
4
|
+
<img alt="Ajax-loader-small" class="hide " id="dialog_body_spinner" src="<%=asset_path('voluntary/ember_js/spinner.gif')%>"/>
|
5
|
+
<div id="dialog_body"/>
|
6
|
+
</section>
|
7
|
+
|
8
|
+
<div class='container-fluid'>
|
9
|
+
<div class="row">
|
10
|
+
<div class="col-md-12">
|
11
|
+
<div id="alert" class="alert alert-dismissible" role="alert" style="display:none;">
|
12
|
+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
13
|
+
<span id="alert_message"></span>
|
14
|
+
</div>
|
15
|
+
{{outlet}}
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
{{!render modal}}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<div id="reload_alert" class="alert alert-info alert-dismissible" role="alert" style="display:none;">
|
2
|
+
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
3
|
+
<span id="reload_alert_message"></span>
|
4
|
+
<a {{action 'reload'}}><span class="glyphicon glyphicon-refresh"></span> Reload</a>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<h2>
|
8
|
+
{{model.name}}
|
9
|
+
{{#link-to 'edit_brainstorming' model.user_slug model.slug}}
|
10
|
+
<span class="glyphicon glyphicon-pencil"></span>
|
11
|
+
{{/link-to}}
|
12
|
+
<a {{action 'destroy' model.user_slug model.slug}}>
|
13
|
+
<span class="glyphicon glyphicon-remove"></span>
|
14
|
+
</a>
|
15
|
+
</h2>
|
16
|
+
|
17
|
+
<table class="table table-striped" style="margin-top:15px;">
|
18
|
+
<thead>
|
19
|
+
<tr>
|
20
|
+
<th>{{t 'general.vote'}}</th>
|
21
|
+
<th>{{t 'general.author'}}</th>
|
22
|
+
<th>{{t 'activerecord.models.brainstorming_idea_short' }}</th>
|
23
|
+
<th></th>
|
24
|
+
<th>{{t 'arguments.index.title' }}</th>
|
25
|
+
</tr>
|
26
|
+
</thead>
|
27
|
+
<tbody>
|
28
|
+
{{#if anyIdeas}}
|
29
|
+
{{#each ideas as |idea|}}
|
30
|
+
<tr>
|
31
|
+
<td style="text-align:right;">
|
32
|
+
{{brainstorming-idea-vote ideaId=idea.id count=idea.votes_count vote=idea.user_id setDirtyAction="setDirty" reloadAction='reload'}}
|
33
|
+
</td>
|
34
|
+
<td>{{#link-to 'user_brainstormings' idea.user_slug 1}}{{idea.user_name}}{{/link-to}}</td>
|
35
|
+
<td>
|
36
|
+
{{brainstorming-idea-cell selectedId=ideaId ideaId=idea.id ideaName=idea.name ideaText=idea.text leaveEditIdeaModeAction='leaveEditIdeaMode' setDirtyAction='setDirty' reloadAction='reload'}}
|
37
|
+
</td>
|
38
|
+
<td>
|
39
|
+
<a {{action 'editIdea' idea.id}} class="edit_brainstorming_idea_link">
|
40
|
+
<span class="glyphicon glyphicon-pencil"></span> {{t 'general.edit'}}
|
41
|
+
</a>
|
42
|
+
|
|
43
|
+
<a {{action 'destroyIdea' idea.id idea.user_id}} class="remove_brainstorming_idea_link">
|
44
|
+
<span class="glyphicon glyphicon-remove"></span> {{t 'general.remove'}}
|
45
|
+
</a>
|
46
|
+
</td>
|
47
|
+
<td>
|
48
|
+
<table class="table">
|
49
|
+
<tbody>
|
50
|
+
{{#each idea.arguments as |argument|}}
|
51
|
+
{{brainstorming-idea-argument argument=argument.argument selectedId=argumentId id=argument.argument.id ideaId=idea.id topicName=argument.argument.topic_name value=argument.argument.value editAction='editArgument' leaveComposeArgumentModeAction='leaveComposeArgumentMode' setDirtyAction='setDirty' reloadAction='reload'}}
|
52
|
+
{{/each}}
|
53
|
+
{{brainstorming-idea-argument selectedNewArgumentIdeaId=newArgumentIdeaId ideaId=idea.id newAction="newArgument" leaveComposeArgumentModeAction='leaveComposeArgumentMode' setDirtyAction='setDirty' reloadAction='reload'}}
|
54
|
+
</tbody>
|
55
|
+
</table>
|
56
|
+
</td>
|
57
|
+
</tr>
|
58
|
+
{{/each}}
|
59
|
+
{{else}}
|
60
|
+
<tr>
|
61
|
+
<td colspan="4">{{t 'brainstorming_ideas.index.empty_collection'}}</td>
|
62
|
+
</tr>
|
63
|
+
{{/if}}
|
64
|
+
{{#if newIdeaMode}}
|
65
|
+
<tr>
|
66
|
+
<td></td>
|
67
|
+
<td>
|
68
|
+
{{brainstorming-idea-cell userSlug=userSlug slug=slug reloadAction='reload' leaveNewIdeaModeAction='leaveNewIdeaMode' setDirtyAction='setDirty'}}
|
69
|
+
</td>
|
70
|
+
<td></td>
|
71
|
+
<td></td>
|
72
|
+
</tr>
|
73
|
+
{{/if}}
|
74
|
+
</tbody>
|
75
|
+
</table>
|
76
|
+
|
77
|
+
<a class="new_brainstorming_idea_link" {{action 'newIdea'}}><span class="glyphicon glyphicon-plus"></span> {{t 'brainstorming_ideas.new.title' }}</a>
|
data/app/assets/javascripts/voluntary_brainstorming/templates/brainstorming_form.js.handlebars
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
<form class="simple_form form-vertical" novalidate="novalidate" id="new_brainstorming" accept-charset="UTF-8" method="post">
|
2
|
+
<div class="form-group string required brainstorming_name">
|
3
|
+
<label class="string required control-label control-label" for="brainstorming_name">
|
4
|
+
<abbr title="required">*</abbr> {{t 'attributes.name' }}
|
5
|
+
</label>
|
6
|
+
{{input value=name class="string required form-control" type="text" name="brainstorming[name]" id="brainstorming_name"}}
|
7
|
+
</div>
|
8
|
+
<div class="form-group text optional brainstorming_text">
|
9
|
+
<label class="text optional control-label control-label" for="brainstorming_text">{{t 'attributes.text' }}</label>
|
10
|
+
{{textarea value=text style="width:500px; height:100px;" class="text optional form-control" name="brainstorming[text]" id="brainstorming_text"}}
|
11
|
+
</div>
|
12
|
+
|
13
|
+
{{#if slug}}
|
14
|
+
<input type="submit" name="commit" value="{{t 'brainstormings.update.title' true }}" class="btn btn-default" {{action 'save'}}/>
|
15
|
+
{{else}}
|
16
|
+
<input type="submit" name="commit" value="{{t 'brainstormings.create.title' true }}" class="btn btn-default" {{action 'save'}}/>
|
17
|
+
{{/if}}
|
18
|
+
</form>
|
data/app/assets/javascripts/voluntary_brainstorming/templates/brainstorming_idea_form.js.handlebars
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
<form class="simple_form form-vertical" novalidate="novalidate" accept-charset="UTF-8" method="post">
|
2
|
+
<div class="form-group string required brainstorming_idea_name">
|
3
|
+
<label class="string required control-label control-label" for="brainstorming_idea_name">
|
4
|
+
<abbr title="required">*</abbr> {{t 'attributes.name'}}
|
5
|
+
</label>
|
6
|
+
{{input value=ideaName class="string required form-control" type="text" name="brainstorming_idea[name]" id="brainstorming_idea_name"}}
|
7
|
+
</div>
|
8
|
+
<div class="form-group string optional brainstorming_idea_text">
|
9
|
+
<label class="string optional control-label control-label" for="brainstorming_idea_text">{{t 'attributes.text'}}</label>
|
10
|
+
{{textarea value=ideaText style="width:500px; height:100px;" class="string optional form-control" type="text" name="brainstorming_idea[text]" id="brainstorming_idea_text"}}
|
11
|
+
</div>
|
12
|
+
|
13
|
+
{{#if ideaId}}
|
14
|
+
<input type="submit" name="commit" value="{{t 'general.cancel' true}}" class="btn btn-default" {{action 'cancel'}}/>
|
15
|
+
<input type="submit" name="commit" value="{{t 'brainstorming_ideas.update.title' true}}" class="btn btn-default" {{action 'save'}}/>
|
16
|
+
{{else}}
|
17
|
+
<input type="submit" name="commit" value="{{t 'brainstorming_ideas.create.title' true}}" class="btn btn-default" {{action 'save'}}/>
|
18
|
+
{{/if}}
|
19
|
+
</form>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
{{#if composeMode}}
|
2
|
+
<td colspan="3">
|
3
|
+
<form class="simple_form form-vertical" novalidate="novalidate" accept-charset="UTF-8">
|
4
|
+
<div class="form-group radio_buttons optional argument_vote">
|
5
|
+
<label class="radio_buttons optional control-label control-label">{{t 'general.vote'}}</label>
|
6
|
+
<span class="radio">
|
7
|
+
<label for="argument_vote_pro">
|
8
|
+
<input class="radio_buttons optional" type="radio" value="1" name="argument[vote]" id="argument_vote_pro" />
|
9
|
+
{{t 'general.pro'}}
|
10
|
+
</label>
|
11
|
+
</span>
|
12
|
+
<span class="radio">
|
13
|
+
<label for="argument_vote_contra">
|
14
|
+
<input class="radio_buttons optional" readonly="readonly" type="radio" value="0" name="argument[vote]" id="argument_vote_contra" />
|
15
|
+
{{t 'general.contra'}}
|
16
|
+
</label>
|
17
|
+
</span>
|
18
|
+
<span class="radio">
|
19
|
+
<label for="argument_vote_neutral">
|
20
|
+
<input class="radio_buttons optional" readonly="readonly" type="radio" value="" name="argument[vote]" id="argument_vote_neutral" />
|
21
|
+
{{t 'general.neutral'}}
|
22
|
+
</label>
|
23
|
+
</span>
|
24
|
+
</div>
|
25
|
+
<div class="form-group string optional argument_topic_name">
|
26
|
+
<label class="string optional control-label control-label" for="argument_topic_name">
|
27
|
+
{{t 'activerecord.models.argument_topic_short'}}
|
28
|
+
</label>
|
29
|
+
{{input value=topicName class="string optional form-control" type="text" name="argument[topic_name]" id="argument_topic_name" data-autocomplete="/api/v1/argument_topics/autocomplete"}}
|
30
|
+
</div>
|
31
|
+
<div class="form-group string optional argument_value">
|
32
|
+
<label class="string optional control-label control-label" for="argument_value">
|
33
|
+
{{t 'activerecord.attributes.argument_topic.value'}}
|
34
|
+
</label>
|
35
|
+
{{input value=value class="string optional form-control" type="text" name="argument[value]" id="argument_value"}}
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<input type="submit" name="commit" value="{{t 'general.cancel' true}}" class="btn btn-default" {{action 'cancel'}}/>
|
39
|
+
{{#if argument}}
|
40
|
+
<input type="submit" name="commit" value="{{t 'arguments.update.title' true}}" class="btn btn-default" {{action 'save'}}/>
|
41
|
+
{{else}}
|
42
|
+
<input type="submit" name="commit" value="{{t 'arguments.create.title' true}}" class="btn btn-default" {{action 'save'}}/>
|
43
|
+
{{/if}}
|
44
|
+
</form>
|
45
|
+
</td>
|
46
|
+
{{else}}
|
47
|
+
{{#if argument}}
|
48
|
+
<td>
|
49
|
+
{{#if pro}}
|
50
|
+
<span class="glyphicon glyphicon-plus-sign" style="color:green"></span>
|
51
|
+
{{/if}}
|
52
|
+
{{#if contra}}
|
53
|
+
<span class="glyphicon glyphicon-minus-sign" style="color:red"></span>
|
54
|
+
{{/if}}
|
55
|
+
{{#if neutral}}
|
56
|
+
<span class="glyphicon glyphicon-question-sign" style="color:blue"></span>
|
57
|
+
{{/if}}
|
58
|
+
{{argument.topic_name}}<br/>
|
59
|
+
by
|
60
|
+
{{#if argument.user_slug}}
|
61
|
+
{{#link-to 'user_brainstormings' argument.user_slug 1}}{{argument.user_name}}{{/link-to}}
|
62
|
+
{{else}}
|
63
|
+
{{t 'general.anonymous'}}
|
64
|
+
{{/if}}
|
65
|
+
</td>
|
66
|
+
<td style="text-align:right">
|
67
|
+
{{argument.value}}
|
68
|
+
</td>
|
69
|
+
<td>
|
70
|
+
<a {{action 'edit' argument.id}} class="edit_brainstorming_idea_argument_link">
|
71
|
+
<span class="glyphicon glyphicon-pencil"></span> {{t 'general.edit'}}
|
72
|
+
</a>
|
73
|
+
|
|
74
|
+
<a {{action 'destroy' argument.id}} class="remove_brainstorming_idea_argument_link">
|
75
|
+
<span class="glyphicon glyphicon-remove"></span> {{t 'general.remove'}}
|
76
|
+
</a>
|
77
|
+
{{like-or-dislike targetType='Argument' targetId=argument.id positive=argument.positive likes=argument.likes_count dislikes=argument.dislikes_count}}
|
78
|
+
</td>
|
79
|
+
{{else}}
|
80
|
+
<td colspan="3">
|
81
|
+
<a class="new_brainstorming_idea_argument_link" {{action 'new' ideaId}}>
|
82
|
+
<span class="glyphicon glyphicon-plus"></span> {{t 'arguments.new.title' }}
|
83
|
+
</a>
|
84
|
+
</td>
|
85
|
+
{{/if}}
|
86
|
+
{{/if}}
|
@@ -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="#">Brainstorming</a>
|
5
|
+
|
6
|
+
<ul class="navbar-nav nav">
|
7
|
+
{{#if currentUser}}
|
8
|
+
<li class="dropdown">
|
9
|
+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
10
|
+
{{t 'general.account'}}
|
11
|
+
<b class="caret"></b>
|
12
|
+
</a>
|
13
|
+
<ul class="dropdown-menu">
|
14
|
+
{{#link-to 'user_brainstormings' currentUser.slug 1 tagName='li'}}<a>{{t 'brainstormings.index.your'}}</a>{{/link-to}}
|
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_brainstorming/issues">{{t 'general.issues' }}</a></li>
|
26
|
+
</ul>
|
27
|
+
</div>
|
28
|
+
</div>
|
data/app/assets/javascripts/voluntary_brainstorming/templates/shared/_pagination.js.handlebars
ADDED
@@ -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>
|
data/app/assets/javascripts/voluntary_brainstorming/templates/user_brainstormings.js.handlebars
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
<h2>{{name-with-apostrophe userName}} {{t 'brainstormings.index.title'}}</h2>
|
2
|
+
|
3
|
+
{{#if anyBrainstormings}}
|
4
|
+
<table class="table table-striped" style="margin-top:15px;">
|
5
|
+
<tbody>
|
6
|
+
{{#each brainstormings as |brainstorming|}}
|
7
|
+
<tr>
|
8
|
+
<td>
|
9
|
+
{{#link-to 'brainstorming' brainstorming.user_slug brainstorming.slug}}{{brainstorming.name}}{{/link-to}}
|
10
|
+
</td>
|
11
|
+
<td>
|
12
|
+
{{#link-to 'edit_brainstorming' brainstorming.user_slug brainstorming.slug}}
|
13
|
+
<span class="glyphicon glyphicon-pencil"></span> {{t 'general.edit'}}
|
14
|
+
{{/link-to}}
|
15
|
+
|
|
16
|
+
<a {{action 'destroy' brainstorming.user_slug brainstorming.slug}} class="remove_brainstorming_link">
|
17
|
+
<span class="glyphicon glyphicon-remove"></span> {{t 'general.remove'}}
|
18
|
+
</a>
|
19
|
+
</td>
|
20
|
+
</tr>
|
21
|
+
{{/each}}
|
22
|
+
</tbody>
|
23
|
+
</table>
|
24
|
+
{{else}}
|
25
|
+
{{t 'brainstormings.index.empty_collection'}}
|
26
|
+
{{/if}}
|
27
|
+
|
28
|
+
{{partial 'shared/pagination'}}
|
29
|
+
|
30
|
+
{{#link-to 'new_brainstorming' userSlug}}
|
31
|
+
<span class="glyphicon glyphicon-plus"></span>
|
32
|
+
{{t 'brainstormings.new.title'}}
|
33
|
+
{{/link-to}}
|
@@ -0,0 +1,13 @@
|
|
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
|
+
*/
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Product::BrainstormingController < 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_brainstorming/application']
|
11
|
+
end
|
12
|
+
|
13
|
+
def voluntary_ember_js_javascripts
|
14
|
+
['voluntary_brainstorming/application']
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Voluntary::Api::V1::BrainstormingIdeaVotesController < ActionController::Base
|
2
|
+
include Voluntary::V1::BaseController
|
3
|
+
|
4
|
+
respond_to :json
|
5
|
+
|
6
|
+
def index
|
7
|
+
idea = BrainstormingIdea.friendly.find params[:idea_id]
|
8
|
+
respond_with do |format|
|
9
|
+
format.json { render json: idea.votes.includes(:user) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
resource = current_user.brainstorming_idea_votes.create idea_id: params[:idea_id]
|
15
|
+
|
16
|
+
respond_to do |format|
|
17
|
+
format.json do
|
18
|
+
render json: resource.persisted? ? resource : { errors: resource.errors.to_hash }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def destroy
|
24
|
+
resource = current_user.brainstorming_idea_votes.where(idea_id: params[:idea_id]).first
|
25
|
+
raise ActiveRecord::RecordNotFound unless resource
|
26
|
+
resource.destroy
|
27
|
+
|
28
|
+
if resource.persisted?
|
29
|
+
raise I18n.t('activerecord.errors.models.brainstorming_idea_vote.attributes.base.deletion_failed')
|
30
|
+
end
|
31
|
+
|
32
|
+
respond_to do |format|
|
33
|
+
format.json do
|
34
|
+
render json: {}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class Voluntary::Api::V1::BrainstormingIdeasController < ActionController::Base
|
2
|
+
include Voluntary::V1::BaseController
|
3
|
+
|
4
|
+
respond_to :json
|
5
|
+
|
6
|
+
def index
|
7
|
+
user = User.friendly.find params[:user_slug]
|
8
|
+
collection = user.brainstormings.friendly.find(params[:brainstorming_slug]).ideas.order('votes_count DESC').includes(:user)
|
9
|
+
collection = collection.with_current_user_vote(current_user.id) if current_user
|
10
|
+
collection = collection.to_a
|
11
|
+
|
12
|
+
collection.each_with_index do |resource, index|
|
13
|
+
arguments = resource.arguments.includes(:user, :topic).to_a
|
14
|
+
argument_likes = Argument.likes_or_dislikes_for(current_user, arguments.map(&:id))
|
15
|
+
|
16
|
+
arguments.map! do |argument|
|
17
|
+
argument.positive = argument_likes[argument.id].try(:positive)
|
18
|
+
argument
|
19
|
+
end
|
20
|
+
|
21
|
+
resource.arguments = arguments
|
22
|
+
collection[index] = resource
|
23
|
+
end
|
24
|
+
|
25
|
+
respond_with do |format|
|
26
|
+
format.json { render json: collection }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def create
|
31
|
+
params[:brainstorming_idea][:brainstorming_id] = User.friendly.find(params[:user_slug]).brainstormings.friendly.find(params[:brainstorming_slug]).id
|
32
|
+
resource = current_user.brainstorming_ideas.create params[:brainstorming_idea]
|
33
|
+
|
34
|
+
respond_to do |format|
|
35
|
+
format.json do
|
36
|
+
render json: resource.persisted? ? resource : { errors: resource.errors.to_hash }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def update
|
42
|
+
resource = current_user.brainstorming_ideas.find params[:id]
|
43
|
+
resource.update_attributes params[:brainstorming_idea]
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
format.json do
|
47
|
+
render json: resource.valid? ? resource : { errors: resource.errors.to_hash }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def destroy
|
53
|
+
resource = current_user.brainstorming_ideas.find params[:id]
|
54
|
+
resource.destroy
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
format.json do
|
58
|
+
render json: if resource.persisted?
|
59
|
+
{ error: I18n.t('activerecord.errors.models.brainstorming_idea.attributes.base.deletion_failed') }
|
60
|
+
else
|
61
|
+
{}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|