From e466ed567940e7a9ed0c9f5eeae2f6f55e1ce1d0 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Mon, 10 Feb 2014 19:27:41 +0100 Subject: [PATCH 1/9] no alerts sort_all --- app/views/themengruppen/sort_themengruppen.js.erb | 1 - app/views/themes/2003/themengruppen/verwalten_all.html.erb | 1 - 2 files changed, 2 deletions(-) diff --git a/app/views/themengruppen/sort_themengruppen.js.erb b/app/views/themengruppen/sort_themengruppen.js.erb index b6aee38..e69de29 100644 --- a/app/views/themengruppen/sort_themengruppen.js.erb +++ b/app/views/themengruppen/sort_themengruppen.js.erb @@ -1 +0,0 @@ -alert("tt") \ No newline at end of file diff --git a/app/views/themes/2003/themengruppen/verwalten_all.html.erb b/app/views/themes/2003/themengruppen/verwalten_all.html.erb index ca6d0ad..827bd69 100644 --- a/app/views/themes/2003/themengruppen/verwalten_all.html.erb +++ b/app/views/themes/2003/themengruppen/verwalten_all.html.erb @@ -18,7 +18,6 @@ $( document ).ready(function(){ data: $('#themengruppen').sortable('serialize'), dataType: 'script', complete: function(request){ - alert("complete"); } }) } From 87d7cc247a7dbff131ebb2fe8121e7c0a71cb243 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sun, 16 Feb 2014 15:32:04 +0100 Subject: [PATCH 2/9] themengruppen verwalten form --- app/controllers/attachments_controller.rb | 9 +++- app/controllers/fragen_controller.rb | 14 ++++-- app/controllers/themen_controller.rb | 14 +++++- app/views/fragen/_frage.html.erb | 2 +- app/views/fragen/create.js.erb | 3 +- app/views/layouts/_pretty_toolbar.html.erb | 2 +- app/views/themen/_form.html.erb | 51 +++++++++------------- app/views/themen/_select.html.erb | 5 ++- app/views/themen/edit.html.erb | 4 +- app/views/themen/show.html.erb | 12 ++--- app/views/themengruppen/verwalten.html.erb | 12 ++++- config/routes.rb | 6 +-- 12 files changed, 78 insertions(+), 56 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 40494fa..7fcb94b 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -32,6 +32,7 @@ class AttachmentsController < ApplicationController respond_to do |format| format.html # new.html.erb format.json { render json: @attachment } + format.js end end @@ -46,15 +47,17 @@ class AttachmentsController < ApplicationController def create @attachment = Attachment.new(params[:attachment]) @thema = Thema.find(params[:thema_id]) - @attachment.thema_id = @thema.id - + @attachment.thema_id = @thema.id + respond_to do |format| if @attachment.save format.html { redirect_to @thema, notice: 'Attachment was successfully created.' } format.json { render json: @thema, status: :created, location: @thema } + format.js { @attachment = Attachment.new } else format.html { render action: "new" } format.json { render json: @attachment.errors, status: :unprocessable_entity } + format.js { render action: "new"} end end end @@ -69,9 +72,11 @@ class AttachmentsController < ApplicationController if @attachment.update_attributes(params[:attachment]) format.html { redirect_to @thema, notice: 'Attachment was successfully updated.' } format.json { head :no_content } + format.js {@attachment=Attachment.new; render action:"create"} else format.html { render action: "edit" } format.json { render json: @attachment.errors, status: :unprocessable_entity } + format.js { render action: "new"} end end end diff --git a/app/controllers/fragen_controller.rb b/app/controllers/fragen_controller.rb index 8e0eddc..223373a 100644 --- a/app/controllers/fragen_controller.rb +++ b/app/controllers/fragen_controller.rb @@ -31,28 +31,34 @@ class FragenController < ApplicationController respond_to do |format| format.html format.json { render json: @frage } + format.js end end - + # GET /fragen/1/edit def edit @frage = Frage.find(params[:id]) + respond_to do |format| + format.html + format.js {render action: :new} + end end # POST /fragen # POST /fragen.json def create @frage = Frage.new(params[:frage]) + thema=@frage.thema @fragen=@frage.thema.fragen respond_to do |format| if @frage.save format.html { redirect_to @frage.thema, notice: 'Frage was successfully created.' } format.json { render json: @frage, status: :created, location: @frage } - format.js + format.js {@frage=Frage.new ; @frage.thema=thema} else format.html { render action: "new" } format.json { render json: @frage.errors, status: :unprocessable_entity } - format.js + format.js end end end @@ -66,9 +72,11 @@ class FragenController < ApplicationController if @frage.update_attributes(params[:frage]) format.html { redirect_to @frage, notice: 'Frage was successfully updated.' } format.json { head :no_content } + format.js {@frage=Frage.new; render action: "new"} else format.html { render action: "edit" } format.json { render json: @frage.errors, status: :unprocessable_entity } + format.js {render action: "edit"} end end end diff --git a/app/controllers/themen_controller.rb b/app/controllers/themen_controller.rb index 51a24dc..8a653f2 100644 --- a/app/controllers/themen_controller.rb +++ b/app/controllers/themen_controller.rb @@ -40,6 +40,10 @@ class ThemenController < ApplicationController # GET /themen/1/edit def edit @thema = Thema.find(params[:id]) + respond_to do |format| + format.html + format.js + end end # POST /themen @@ -57,7 +61,13 @@ class ThemenController < ApplicationController end end end - + def fragen + @thema = Thema.find(params[:thema_id]) + @fragen=@thema.fragen + respond_to do |format| + format.js + end + end # PUT /themen/1 # PUT /themen/1.json def update @@ -67,9 +77,11 @@ class ThemenController < ApplicationController if @thema.update_attributes(params[:thema]) format.html { redirect_to @thema, notice: 'Thema was successfully updated.' } format.json { head :no_content } + format.js else format.html { render action: "edit" } format.json { render json: @thema.errors, status: :unprocessable_entity } + format.js { render action: "edit" } end end end diff --git a/app/views/fragen/_frage.html.erb b/app/views/fragen/_frage.html.erb index 1fbc55a..1197db7 100644 --- a/app/views/fragen/_frage.html.erb +++ b/app/views/fragen/_frage.html.erb @@ -3,6 +3,6 @@ <%= raw(frage.text) %>
-<%= link_to 'Edit', edit_frage_path(frage) %> | +<%= link_to 'Edit', edit_frage_path(frage),:remote=>true %> | <%= link_to 'Destroy',frage, method: :delete, :remote=> true , data: { confirm: 'Are you sure?' } %>

diff --git a/app/views/fragen/create.js.erb b/app/views/fragen/create.js.erb index e57d3a9..fbf24b8 100644 --- a/app/views/fragen/create.js.erb +++ b/app/views/fragen/create.js.erb @@ -1 +1,2 @@ -$("#fragen").html("<%=escape_javascript( render :partial=>'fragen/liste' )%>") \ No newline at end of file +$("#fragen").html("<%=escape_javascript( render :partial=>'fragen/liste' )%>") +$("#fragenform").html("<%=escape_javascript( render :partial=>'fragen/rform' )%>") \ No newline at end of file diff --git a/app/views/layouts/_pretty_toolbar.html.erb b/app/views/layouts/_pretty_toolbar.html.erb index f0c82cb..1a1f7c2 100644 --- a/app/views/layouts/_pretty_toolbar.html.erb +++ b/app/views/layouts/_pretty_toolbar.html.erb @@ -10,7 +10,7 @@ Verwendung: Aufruf mit <% toolbar_elements.each do |t| %> <% unless t[:method]==:versions %> <% text=''.html_safe+t[:text] %> - <%= link_to text, t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") %> + <%= link_to text, t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") ,:remote=>(t[:remote])?true : false %> <% else %>
diff --git a/app/views/themen/_form.html.erb b/app/views/themen/_form.html.erb index b967041..759daf2 100644 --- a/app/views/themen/_form.html.erb +++ b/app/views/themen/_form.html.erb @@ -1,41 +1,32 @@ <%= tinymce_assets %> -<%= semantic_form_for @thema do |f| %> +
+ + +<%= semantic_form_for @thema, :remote=>true do |f| %> <%= f.inputs do %> +
+
<%= f.input :title %> +
+
<%= f.input :themengruppe %> - <%= f.input :text, :as=>:tinymce_text%> - <% end %> -<%= tinymce %> +
+
+
+ <%= f.input :text, :as=>:tinymce_text,:label=>false %> +
+
-

Attachments:

-<%= render :partial => "themen/select", :object => @thema,:locals =>{ :editor => :true} %> +
<%= f.actions do %> <%= f.action :submit, :as => :input %> -<% end %> - - - diff --git a/app/views/themen/_select.html.erb b/app/views/themen/_select.html.erb index fb91bcb..2ddb1f9 100644 --- a/app/views/themen/_select.html.erb +++ b/app/views/themen/_select.html.erb @@ -24,8 +24,9 @@
<% unless @thema.id.nil? %> -<% @att_elements = [{:icon=>:plus, :hicon=>'icon-plus', :text=>I18n.t('attachment.add'), :path=>new_thema_attachment_path(@thema)}] %> - +<% @att_elements = [{:icon=>:plus, :hicon=>'icon-plus', :text=>I18n.t('attachment.add'), :path=>new_thema_attachment_path(@thema),:remote=>true}] %> +
+
<%= render :partial=>'layouts/pretty_toolbar', :object=>@att_elements %> <% end %>
diff --git a/app/views/themen/edit.html.erb b/app/views/themen/edit.html.erb index 5376cfb..de6c7a3 100644 --- a/app/views/themen/edit.html.erb +++ b/app/views/themen/edit.html.erb @@ -1,5 +1,5 @@ +

Editing thema

- <%= render 'form' %> - +

<%= link_to 'Back', @thema %> diff --git a/app/views/themen/show.html.erb b/app/views/themen/show.html.erb index 27e38a9..041efab 100644 --- a/app/views/themen/show.html.erb +++ b/app/views/themen/show.html.erb @@ -11,18 +11,14 @@ --> <%= render :partial=>'layouts/pretty_toolbar' %> -

FAQs:

-
-<%= render :partial=>'fragen/liste' %> -
-<% @frage=Frage.new; @frage.thema=@thema %> -<%= render :partial=>'fragen/rform' %> -<% @frage_elements = [{:icon=>:plus, :hicon=>'icon-plus', :text=>I18n.t('frage.add'), :path=>new_frage_path}] %> -<%= render :partial=>'layouts/pretty_toolbar', :object=>@frage_elements %> +<%= render :partial=>'themen/fragen' %>

<%= I18n.t('attachment.title')%>:

+
+
+<%= link_to new_thema_attachment_path(@thema) ,:remote=>true do %> new Attachment <% end %> <%= render :partial => "themen/select", :object => @thema, :locals=>{:editor => :false} %> diff --git a/app/views/themengruppen/verwalten.html.erb b/app/views/themengruppen/verwalten.html.erb index b828f3e..ee14704 100644 --- a/app/views/themengruppen/verwalten.html.erb +++ b/app/views/themengruppen/verwalten.html.erb @@ -2,18 +2,26 @@ #themen { list-style-type: none; margin: 0; padding: 0; margin-bottom: 15px;zoom: 1; } #themen li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 95%; } +
+
+
+
    <% @themen.each do |thema| %> -
  • <%= thema.title %>

  • +
  • <%= thema.title %>

    <%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %> <%= link_to thema_fragen_path(thema),:remote=>true do %> Fragen <% end %>
  • <% end %>
- +
+
+
+