diff --git a/app/controllers/feedback_controller.rb b/app/controllers/feedback_controller.rb new file mode 100644 index 00000000..1e4be46f --- /dev/null +++ b/app/controllers/feedback_controller.rb @@ -0,0 +1,20 @@ +class FeedbackController < ApplicationController + + def new + render :update do |page| + page.replace_html :ajax_box, :partial => "new" + page.show :ajax_box + end + end + + def create + unless params[:message].blank? + Mailer.deliver_feedback(current_user, params[:message]) + end + + render :update do |page| + page.replace_html :ajax_box, :partial => "success" + end + end + +end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 55fa7991..482c400c 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -58,6 +58,15 @@ class Mailer < ActionMailer::Base :transaction => transaction end + def feedback(user, message) + subject "[Foodsoft] Feeback von #{user.email}" + recipients Foodsoft.config[:notification]["error_recipients"] + from "#{user.nick} <#{user.email}>" + headers 'Sender' => Foodsoft.config[:notification]["sender_address"], + 'Errors-To' => Foodsoft.config[:notification]["sender_address"] + body :user => user, :message => message + end + protected def prepare_system_message(recipient) diff --git a/app/views/feedback/_new.html.haml b/app/views/feedback/_new.html.haml new file mode 100644 index 00000000..8d5eb16b --- /dev/null +++ b/app/views/feedback/_new.html.haml @@ -0,0 +1,8 @@ +%h2 Fehler gefunden? Vorschlag? Idee? Kritik? + +- form_remote_tag :url => {:action => "create"}, :before => "Element.show('loader')", :success => "Element.hide('loader')" do + %p + = text_area_tag :message, nil, :size => "40x15" + = submit_tag "Absenden" + oder + = link_to_function "Abbrechen", "Element.hide('ajax_box')" \ No newline at end of file diff --git a/app/views/feedback/_success.html.haml b/app/views/feedback/_success.html.haml new file mode 100644 index 00000000..39c18ae2 --- /dev/null +++ b/app/views/feedback/_success.html.haml @@ -0,0 +1,4 @@ +%h2 Nachricht wurde verschickt! + +%p Vielen Dank, Deine Nachricht wurde soeben dem Foodcooft Team zugestellt. +%p= link_to_function "Schließen", "Element.hide('ajax_box')" \ No newline at end of file diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index a137eaeb..25880429 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -23,6 +23,7 @@ %span{:style => "color:white; font-size:45%; letter-spacing: -1px;"}= Foodsoft.config[:name] #nav= render :partial => 'layouts/main_tabnav' + #ajax_box(style="display:none") #main #content - if flash[:notice] diff --git a/app/views/mailer/feedback.erb b/app/views/mailer/feedback.erb new file mode 100644 index 00000000..97cc7b85 --- /dev/null +++ b/app/views/mailer/feedback.erb @@ -0,0 +1,3 @@ +<%= @user.nick %> schrieb am <%= I18n.l Time.now, :format => :short %>: + +<%= @message %> diff --git a/app/views/shared/_loginInfo.haml b/app/views/shared/_loginInfo.haml index ce5c4830..83e574a0 100644 --- a/app/views/shared/_loginInfo.haml +++ b/app/views/shared/_loginInfo.haml @@ -1,8 +1,10 @@ %ul %li - = image_tag 'b_user.png' , :size => '7x10', :border => 0, :alt => _("User") - = link_to h(@current_user.nick), my_profile_path, { :title => _("User Settings") } + = image_tag 'b_user.png' , :size => '7x10', :border => 0, :alt => "Profil" + = link_to h(@current_user.nick), my_profile_path, { :title => "Profil bearbeiten" } - if Foodsoft.config[:homepage] %li= link_to Foodsoft.config[:name], Foodsoft.config[:homepage], { :title => _("Go to your FoodCoop-Hompage") } - %li= link_to _("Hilfe"), 'http://dev.foodcoops.net/wiki/FoodsoftDoku' - %li= link_to _("Logout"), :controller => '/login', :action => 'logout' \ No newline at end of file + %li= link_to "Hilfe", 'http://dev.foodcoops.net/wiki/FoodsoftDoku' + %li= link_to_remote "Feedback", :url => {:controller => "/feedback", :action => "new"}, | + :method => :get, :html => {:title => "Fehler gefunden? Vorschlag? Idee? Kritik?"} | + %li= link_to "Abmelden", logout_path \ No newline at end of file diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 85036f26..b5202c78 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -295,7 +295,7 @@ div.edit_form { margin: 5px 0; color: black; } -#edit_article, #edit_box { +#edit_article, #edit_box, #ajax_box { position: fixed; top: 5em; left: 10em; diff --git a/public/stylesheets/print.css b/public/stylesheets/print.css index 2dee312b..8076a13b 100644 --- a/public/stylesheets/print.css +++ b/public/stylesheets/print.css @@ -295,7 +295,7 @@ div.edit_form { margin: 5px 0; color: black; } -#edit_article, #edit_box { +#edit_article, #edit_box, #ajax_box { position: fixed; top: 5em; left: 10em; diff --git a/public/stylesheets/sass/main.sass b/public/stylesheets/sass/main.sass index 021bb87f..d28c1f6e 100644 --- a/public/stylesheets/sass/main.sass +++ b/public/stylesheets/sass/main.sass @@ -322,7 +322,7 @@ div.edit_form :margin 5px 0 :color black -#edit_article, #edit_box +#edit_article, #edit_box, #ajax_box :position fixed :top 5em :left 10em diff --git a/test/functional/feedback_controller_test.rb b/test/functional/feedback_controller_test.rb new file mode 100644 index 00000000..b212d075 --- /dev/null +++ b/test/functional/feedback_controller_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class FeebackControllerTest < ActionController::TestCase + # Replace this with your real tests. + test "the truth" do + assert true + end +end diff --git a/test/unit/helpers/feeback_helper_test.rb b/test/unit/helpers/feeback_helper_test.rb new file mode 100644 index 00000000..ff40044f --- /dev/null +++ b/test/unit/helpers/feeback_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class FeebackHelperTest < ActionView::TestCase +end