my-feedback-form 0.0.2 → 0.0.3

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.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # MyFeedbackForm v 0.0.2
1
+ # MyFeedbackForm v 0.0.3
2
2
 
3
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
4
4
 
@@ -63,6 +63,6 @@ rails g my_feedback_form:views
63
63
  If you are using Devise to authenticate users, it will be saved automatically, otherwise you must extend feedbacks controller.
64
64
 
65
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.
66
+ The next steps for this gem will be create a task to easier install.
67
67
 
68
68
 
@@ -1,14 +1,19 @@
1
1
  $('document').ready(function() {
2
+ $('#my-feedback-form-modal').on('hidden', function () {
3
+ $('#new_feedback').remove();
4
+ });
5
+
2
6
  $("#feedback-button").live('click', function (e){
3
7
  e.preventDefault
4
8
  form = $('#new_feedback');
5
9
  $.get('/my_feedback_form/feedbacks/new', function(s) {
6
10
  m = $("#my-feedback-form-modal .modal-body");
7
11
  m.html(s);
8
- $('#send-feedback').live('click', function (e) {
9
- $('#new_feedback').submit()
10
- });
11
12
  });
12
13
  });
14
+
15
+ $('#send-feedback').live('click', function (e) {
16
+ $('#new_feedback').submit();
17
+ });
13
18
  });
14
19
 
@@ -18,11 +18,13 @@ module MyFeedbackForm
18
18
 
19
19
  respond_to do |format|
20
20
  if @feedback.save
21
- format.html { redirect_to '/', notice: 'Feedback was successfully sent.' }
21
+ format.html { redirect_to(@feedback) }
22
22
  format.json { render json: @feedback, status: :created, location: @feedback }
23
+ format.js
23
24
  else
24
- format.html { render action: "new" }
25
+ format.html { render :action => "new" }
25
26
  format.json { render json: @feedback.errors, status: :unprocessable_entity }
27
+ format.js
26
28
  end
27
29
  end
28
30
  end
@@ -1,5 +1,7 @@
1
1
  module MyFeedbackForm
2
2
  class Feedback < ActiveRecord::Base
3
3
  attr_accessible :message, :title, :type, :user_id
4
+
5
+ validates_presence_of :message, :title, :type, :on => :create
4
6
  end
5
7
  end
@@ -0,0 +1,31 @@
1
+ <%= form_for(@feedback, :remote => true, :html => {:class => 'form-horizontal'}) do |f| %>
2
+ <div class="control-group <%= @feedback.errors[:type].empty? ? '' : 'error' %>">
3
+ <%= f.label :type, :class => 'control-label' %>
4
+ <div class="controls">
5
+ <%= f.collection_select :type, MyFeedbackForm::FeedbackType.all, :id, :description, {:prompt => 'Type'} %>
6
+ <% @feedback.errors[:type].each do |msg| %>
7
+ <p class="help-inline"><%= msg %></p>
8
+ <% end %>
9
+ </div>
10
+ </div>
11
+
12
+ <div class="control-group <%= @feedback.errors[:title].empty? ? '' : 'error' %>">
13
+ <%= f.label :title, :class => 'control-label' %>
14
+ <div class="controls">
15
+ <%= f.text_field :title %>
16
+ <% @feedback.errors[:title].each do |msg| %>
17
+ <p class="help-inline"><%= msg %></p>
18
+ <% end %>
19
+ </div>
20
+ </div>
21
+
22
+ <div class="control-group <%= @feedback.errors[:message].empty? ? '' : 'error' %>">
23
+ <%= f.label :message, :class => 'control-label' %>
24
+ <div class="controls">
25
+ <%= f.text_area :message, :size => "10x5" %>
26
+ <% @feedback.errors[:message].each do |msg| %>
27
+ <p class="help-inline"><%= msg %></p>
28
+ <% end %>
29
+ </div>
30
+ </div>
31
+ <% end %>
@@ -1,12 +1,12 @@
1
1
  <div id="my-feedback-form-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="feedback-form" aria-hidden="true">
2
2
  <div class="modal-header">
3
3
  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
4
- <h3 id="feedback-form">New feedback</h3>
4
+ <h3 id="feedback-form">New Feedback</h3>
5
5
  </div>
6
6
  <div class="modal-body">
7
7
  </div>
8
8
  <div class="modal-footer">
9
- <button class="btn" data-dismiss="modal" aria-hidden="true">Back</button>
9
+ <button class="btn" data-dismiss="modal" aria-hidden="true">Voltar</button>
10
10
  <button class="btn btn-primary" name="commit" type="submit" value="Submit" id="send-feedback">Submit</button>
11
11
  </div>
12
12
  </div>
@@ -0,0 +1,6 @@
1
+ $('#new_feedback').remove();
2
+ <%- if @feedback.errors.any? %>
3
+ $('#my-feedback-form-modal .modal-body').html('<%= escape_javascript(render('form')) %>');
4
+ <%- else %>
5
+ $('#my-feedback-form-modal').modal('hide');
6
+ <%- end %>
@@ -1,25 +1 @@
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>
8
-
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
-
25
-
1
+ <%= render 'form' %>
@@ -1,3 +1,3 @@
1
1
  module MyFeedbackForm
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -93,7 +93,9 @@ files:
93
93
  - app/helpers/my_feedback_form/feedbacks_helper.rb
94
94
  - app/models/my_feedback_form/feedback.rb
95
95
  - app/models/my_feedback_form/feedback_type.rb
96
+ - app/views/my_feedback_form/feedbacks/_form.html.erb
96
97
  - app/views/my_feedback_form/feedbacks/_modal.html.erb
98
+ - app/views/my_feedback_form/feedbacks/create.js.erb
97
99
  - app/views/my_feedback_form/feedbacks/new.html.erb
98
100
  - config/routes.rb
99
101
  - db/migrate/20130227125242_create_my_feedback_form_feedbacks.rb