my-feedback-form 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +45 -6
- data/app/assets/javascripts/{my-feedback-form → my_feedback_form}/application.js +0 -0
- data/app/assets/javascripts/my_feedback_form/feedbacks.js +14 -2
- data/app/assets/stylesheets/{my-feedback-form → my_feedback_form}/application.css +0 -0
- data/app/controllers/my_feedback_form/feedbacks_controller.rb +8 -10
- data/app/views/my_feedback_form/feedbacks/_modal.html.erb +13 -0
- data/app/views/my_feedback_form/feedbacks/new.html.erb +23 -29
- data/lib/generators/my_feedback_form/USAGE +8 -0
- data/lib/generators/my_feedback_form/views_generator.rb +19 -0
- data/lib/my-feedback-form/version.rb +1 -1
- metadata +23 -6
- data/app/views/layouts/my-feedback-form/application.html.erb +0 -14
- data/app/views/my_feedback_form/feedbacks/_form.html.erb +0 -29
data/README.md
CHANGED
@@ -1,24 +1,46 @@
|
|
1
|
-
# MyFeedbackForm
|
1
|
+
# MyFeedbackForm v 0.0.2
|
2
|
+
|
3
|
+
The gem does not have a server side interface, it has only the client side, unfortunatly you need to implement a way to see the feedbacks you received
|
2
4
|
|
3
5
|
# Installation
|
4
6
|
|
5
7
|
## Specify Gem dependencies
|
6
8
|
|
7
9
|
```ruby
|
8
|
-
gem 'my-feedback-form'
|
10
|
+
gem 'my-feedback-form'
|
9
11
|
```
|
10
12
|
|
11
13
|
Then run bundle
|
12
14
|
|
13
|
-
|
14
15
|
## Hooking into an application
|
15
|
-
Mount the routes in the rails app routes.rb file
|
16
|
+
Mount the routes in the rails app routes.rb file.
|
16
17
|
|
17
18
|
```ruby
|
18
19
|
mount MyFeedbackForm::Engine => "/my_feedback_form"
|
19
20
|
```
|
20
21
|
|
21
|
-
|
22
|
+
Add in the head of your rails app layout the link to gem javascript and stylesheets.
|
23
|
+
|
24
|
+
```erb
|
25
|
+
<%= stylesheet_link_tag "my_feedback_form/application", :media => "all" %>
|
26
|
+
<%= javascript_include_tag "my_feedback_form/application" %>
|
27
|
+
```
|
28
|
+
|
29
|
+
Also add in your layout the feedback modal. You may want to add a condition to insert this modal on your page. If you use devise you can use the same condition.
|
30
|
+
|
31
|
+
```erb
|
32
|
+
<% if user_signed_in? %>
|
33
|
+
<%= render 'my_feedback_form/feedbacks/new' %>
|
34
|
+
<% end %>
|
35
|
+
```
|
36
|
+
|
37
|
+
Add a button where you want to access the feedback modal. The button must be like the folowing.
|
38
|
+
|
39
|
+
```html
|
40
|
+
<button type="button" id="feedback-button" data-toggle="modal" data-target="#my-feedback-form-modal">Feedback</button>
|
41
|
+
```
|
42
|
+
|
43
|
+
Setup the app database.
|
22
44
|
|
23
45
|
```ruby
|
24
46
|
rake railties:install:migrations
|
@@ -26,4 +48,21 @@ rake railties:install:migrations
|
|
26
48
|
rake db:migrate
|
27
49
|
|
28
50
|
rake setup_feedback_type
|
29
|
-
```
|
51
|
+
```
|
52
|
+
|
53
|
+
## View Customisation
|
54
|
+
|
55
|
+
If you want to customise My Feedback Form views, you can copy over the views using the (Devise-inspired) generator.
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
rails g my_feedback_form:views
|
59
|
+
```
|
60
|
+
|
61
|
+
## User Authentication
|
62
|
+
|
63
|
+
If you are using Devise to authenticate users, it will be saved automatically, otherwise you must extend feedbacks controller.
|
64
|
+
|
65
|
+
#Next Steps
|
66
|
+
The next steps for this gem will be add validations to the feedback modell and create a task to easier install.
|
67
|
+
|
68
|
+
|
File without changes
|
@@ -1,2 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
$('document').ready(function() {
|
2
|
+
$("#feedback-button").live('click', function (e){
|
3
|
+
e.preventDefault
|
4
|
+
form = $('#new_feedback');
|
5
|
+
$.get('/my_feedback_form/feedbacks/new', function(s) {
|
6
|
+
m = $("#my-feedback-form-modal .modal-body");
|
7
|
+
m.html(s);
|
8
|
+
$('#send-feedback').live('click', function (e) {
|
9
|
+
$('#new_feedback').submit()
|
10
|
+
});
|
11
|
+
});
|
12
|
+
});
|
13
|
+
});
|
14
|
+
|
File without changes
|
@@ -1,26 +1,24 @@
|
|
1
|
-
require_dependency "my_feedback_form/application_controller"
|
2
|
-
|
3
1
|
module MyFeedbackForm
|
4
2
|
class FeedbacksController < ApplicationController
|
5
3
|
# GET /feedbacks/new
|
6
4
|
# GET /feedbacks/new.json
|
7
5
|
def new
|
8
|
-
@feedback = Feedback.new
|
9
|
-
|
10
|
-
respond_to do |format|
|
11
|
-
format.html # new.html.erb
|
12
|
-
format.json { render json: @feedback }
|
13
|
-
end
|
6
|
+
@feedback = MyFeedbackForm::Feedback.new
|
7
|
+
render "new", layout: false
|
14
8
|
end
|
15
9
|
|
16
10
|
# POST /feedbacks
|
17
11
|
# POST /feedbacks.json
|
18
12
|
def create
|
19
|
-
|
13
|
+
unless current_user.nil?
|
14
|
+
params[:feedback][:user_id] = current_user.id
|
15
|
+
end
|
16
|
+
|
17
|
+
@feedback = MyFeedbackForm::Feedback.new(params[:feedback])
|
20
18
|
|
21
19
|
respond_to do |format|
|
22
20
|
if @feedback.save
|
23
|
-
format.html { redirect_to
|
21
|
+
format.html { redirect_to '/', notice: 'Feedback was successfully sent.' }
|
24
22
|
format.json { render json: @feedback, status: :created, location: @feedback }
|
25
23
|
else
|
26
24
|
format.html { render action: "new" }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div id="my-feedback-form-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="feedback-form" aria-hidden="true">
|
2
|
+
<div class="modal-header">
|
3
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
4
|
+
<h3 id="feedback-form">New feedback</h3>
|
5
|
+
</div>
|
6
|
+
<div class="modal-body">
|
7
|
+
</div>
|
8
|
+
<div class="modal-footer">
|
9
|
+
<button class="btn" data-dismiss="modal" aria-hidden="true">Back</button>
|
10
|
+
<button class="btn btn-primary" name="commit" type="submit" value="Submit" id="send-feedback">Submit</button>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
|
@@ -1,31 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<%= form_for(@feedback, :html => {:class => 'form-horizontal'}) do |f| %>
|
2
|
+
<div class="control-group">
|
3
|
+
<%= f.label :type, :class => 'control-label' %>
|
4
|
+
<div class="controls">
|
5
|
+
<%= f.collection_select :type, MyFeedbackForm::FeedbackType.all, :id, :description, {:prompt => 'Type'} %>
|
6
|
+
</div>
|
7
|
+
</div>
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
<div class="control-group">
|
10
|
+
<%= f.label :title, :class => 'control-label' %>
|
11
|
+
<div class="controls">
|
12
|
+
<%= f.text_field :title %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="control-group">
|
17
|
+
<%= f.label :message, :class => 'control-label' %>
|
18
|
+
<div class="controls">
|
19
|
+
<%= f.text_area :message, :size => "10x5" %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
|
14
25
|
|
15
|
-
<div class="field">
|
16
|
-
<%= f.label :type %><br />
|
17
|
-
<%= f.collection_select :type, MyFeedbackForm::FeedbackType.all, :id, :description, {:prompt => 'Type'} %>
|
18
|
-
</div>
|
19
|
-
<div class="field">
|
20
|
-
<%= f.label :title %><br />
|
21
|
-
<%= f.text_field :title %>
|
22
|
-
</div>
|
23
|
-
<div class="field">
|
24
|
-
<%= f.label :message %><br />
|
25
|
-
<%= f.text_field :message %>
|
26
|
-
</div>
|
27
|
-
<div class="actions">
|
28
|
-
<%= f.submit %>
|
29
|
-
</div>
|
30
|
-
<% end %>
|
31
|
-
<%= link_to 'Back', feedbacks_path %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module MyFeedbackForm
|
3
|
+
module Generators
|
4
|
+
class ViewsGenerator < Rails::Generators::Base #:nodoc:
|
5
|
+
source_root File.expand_path("../../../../app/views/my_feedback_form", __FILE__)
|
6
|
+
desc "Used to copy my-feedback-form's views to your application's views."
|
7
|
+
|
8
|
+
def copy_views
|
9
|
+
view_directory :feedbacks
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def view_directory(name)
|
15
|
+
directory name.to_s, "app/views/my_feedback_form/#{name}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my-feedback-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: twitter-bootstrap-rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: sqlite3
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,9 +82,9 @@ executables: []
|
|
66
82
|
extensions: []
|
67
83
|
extra_rdoc_files: []
|
68
84
|
files:
|
69
|
-
- app/assets/javascripts/
|
85
|
+
- app/assets/javascripts/my_feedback_form/application.js
|
70
86
|
- app/assets/javascripts/my_feedback_form/feedbacks.js
|
71
|
-
- app/assets/stylesheets/
|
87
|
+
- app/assets/stylesheets/my_feedback_form/application.css
|
72
88
|
- app/assets/stylesheets/my_feedback_form/feedbacks.css
|
73
89
|
- app/assets/stylesheets/scaffold.css
|
74
90
|
- app/controllers/my_feedback_form/application_controller.rb
|
@@ -77,12 +93,13 @@ files:
|
|
77
93
|
- app/helpers/my_feedback_form/feedbacks_helper.rb
|
78
94
|
- app/models/my_feedback_form/feedback.rb
|
79
95
|
- app/models/my_feedback_form/feedback_type.rb
|
80
|
-
- app/views/
|
81
|
-
- app/views/my_feedback_form/feedbacks/_form.html.erb
|
96
|
+
- app/views/my_feedback_form/feedbacks/_modal.html.erb
|
82
97
|
- app/views/my_feedback_form/feedbacks/new.html.erb
|
83
98
|
- config/routes.rb
|
84
99
|
- db/migrate/20130227125242_create_my_feedback_form_feedbacks.rb
|
85
100
|
- db/migrate/20130227174853_create_my_feedback_form_feedback_types.rb
|
101
|
+
- lib/generators/my_feedback_form/USAGE
|
102
|
+
- lib/generators/my_feedback_form/views_generator.rb
|
86
103
|
- lib/my-feedback-form/engine.rb
|
87
104
|
- lib/my-feedback-form/version.rb
|
88
105
|
- lib/my-feedback-form.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>MyFeedbackForm</title>
|
5
|
-
<%= stylesheet_link_tag "my-feedback-form/application", :media => "all" %>
|
6
|
-
<%= javascript_include_tag "my-feedback-form/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<%= form_for(@feedback) do |f| %>
|
2
|
-
<% if @feedback.errors.any? %>
|
3
|
-
<div id="error_explanation">
|
4
|
-
<h2><%= pluralize(@feedback.errors.count, "error") %> prohibited this feedback from being saved:</h2>
|
5
|
-
|
6
|
-
<ul>
|
7
|
-
<% @feedback.errors.full_messages.each do |msg| %>
|
8
|
-
<li><%= msg %></li>
|
9
|
-
<% end %>
|
10
|
-
</ul>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<div class="field">
|
15
|
-
<%= f.label :type %><br />
|
16
|
-
<%= f.number_field :type %>
|
17
|
-
</div>
|
18
|
-
<div class="field">
|
19
|
-
<%= f.label :title %><br />
|
20
|
-
<%= f.text_field :title %>
|
21
|
-
</div>
|
22
|
-
<div class="field">
|
23
|
-
<%= f.label :message %><br />
|
24
|
-
<%= f.text_field :message %>
|
25
|
-
</div>
|
26
|
-
<div class="actions">
|
27
|
-
<%= f.submit %>
|
28
|
-
</div>
|
29
|
-
<% end %>
|