forked from bofh/fetsite
themen fix + remote form für themen
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
class FragenController < ApplicationController
|
class FragenController < ApplicationController
|
||||||
# GET /fragen
|
# GET /fragen
|
||||||
# GET /fragen.json
|
# GET /fragen.json
|
||||||
@@ -42,14 +43,16 @@ class FragenController < ApplicationController
|
|||||||
# POST /fragen.json
|
# POST /fragen.json
|
||||||
def create
|
def create
|
||||||
@frage = Frage.new(params[:frage])
|
@frage = Frage.new(params[:frage])
|
||||||
|
@fragen=@frage.thema.fragen
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @frage.save
|
if @frage.save
|
||||||
format.html { redirect_to @frage.thema, notice: 'Frage was successfully created.' }
|
format.html { redirect_to @frage.thema, notice: 'Frage was successfully created.' }
|
||||||
format.json { render json: @frage, status: :created, location: @frage }
|
format.json { render json: @frage, status: :created, location: @frage }
|
||||||
|
format.js
|
||||||
else
|
else
|
||||||
format.html { render action: "new" }
|
format.html { render action: "new" }
|
||||||
format.json { render json: @frage.errors, status: :unprocessable_entity }
|
format.json { render json: @frage.errors, status: :unprocessable_entity }
|
||||||
|
format.js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -74,11 +77,16 @@ class FragenController < ApplicationController
|
|||||||
# DELETE /fragen/1.json
|
# DELETE /fragen/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@frage = Frage.find(params[:id])
|
@frage = Frage.find(params[:id])
|
||||||
|
@thema=@frage.thema
|
||||||
@frage.destroy
|
@frage.destroy
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to @frage.thema }
|
format.html { redirect_to @frage.thema }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
|
format.js {
|
||||||
|
@fragen=@thema.fragen
|
||||||
|
render :create
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class ThemenController < ApplicationController
|
|||||||
# GET /themen/1.json
|
# GET /themen/1.json
|
||||||
def show
|
def show
|
||||||
@thema = Thema.find(params[:id])
|
@thema = Thema.find(params[:id])
|
||||||
|
@fragen=@thema.fragen
|
||||||
@toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>edit_thema_path(@thema)}]
|
@toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>edit_thema_path(@thema)}]
|
||||||
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('thema.remove'), :path=>thema_path(@thema), :method=>:delete, :confirm=>I18n.t('thema.sure')}
|
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('thema.remove'), :path=>thema_path(@thema), :method=>:delete, :confirm=>I18n.t('thema.sure')}
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ class ThemengruppenController < ApplicationController
|
|||||||
# GET /themengruppen/1.json
|
# GET /themengruppen/1.json
|
||||||
def show
|
def show
|
||||||
@themengruppe = Themengruppe.find(params[:id])
|
@themengruppe = Themengruppe.find(params[:id])
|
||||||
@toolbar_elements = [{:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('thema.add'), :path=>new_themengruppe_thema_path(@themengruppe)}]
|
@toolbar_elements = []
|
||||||
@toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('themengruppe.edit'), :path=>edit_themengruppe_path(@themengruppe)}
|
@toolbar_elements << {:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('thema.add'), :path=>new_themengruppe_thema_path(@themengruppe)} if can? :new, Themengruppe
|
||||||
@toolbar_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('themengruppe.remove'), :path=>themengruppe_path(@themengruppe), :method=>:delete,:confirm=>I18n.t('themengruppe.sure')}
|
@toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('themengruppe.edit'), :path=>edit_themengruppe_path(@themengruppe)} if can? :edit, @themengruppe
|
||||||
|
@toolbar_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('themengruppe.remove'), :path=>themengruppe_path(@themengruppe), :method=>:delete,:confirm=>I18n.t('themengruppe.sure')} if can? :delete, @themengruppe
|
||||||
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
@@ -4,5 +4,5 @@
|
|||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<%= link_to 'Edit', edit_frage_path(frage) %> |
|
<%= link_to 'Edit', edit_frage_path(frage) %> |
|
||||||
<%= link_to 'Destroy',frage, method: :delete, data: { confirm: 'Are you sure?' } %>
|
<%= link_to 'Destroy',frage, method: :delete, :remote=> true , data: { confirm: 'Are you sure?' } %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
3
app/views/fragen/_liste.html.erb
Normal file
3
app/views/fragen/_liste.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<% @fragen.each do |frage| %>
|
||||||
|
<%= render frage %>
|
||||||
|
<% end %>
|
||||||
12
app/views/fragen/_rform.html.erb
Normal file
12
app/views/fragen/_rform.html.erb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<%= tinymce_assets %>
|
||||||
|
<%= semantic_form_for @frage , :remote=>true do |f| %>
|
||||||
|
<%= f.inputs do %>
|
||||||
|
<%= f.input :title %>
|
||||||
|
<%= f.input :thema %>
|
||||||
|
<%= f.input :text, :as=>:tinymce_text%>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= f.actions do %>
|
||||||
|
<%= f.action :submit, :as => :input %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
1
app/views/fragen/create.js.erb
Normal file
1
app/views/fragen/create.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$("#fragen").html("<%=escape_javascript( render :partial=>'fragen/liste' )%>")
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
</p>
|
</p>
|
||||||
<br/>
|
<br/>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% @small_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>small}]
|
<%
|
||||||
@small_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('thema.remove'), :path=>small, :method=>:delete,:confirm=>I18n.t('thema.sure')}%>
|
@small_elements = []
|
||||||
<%= render :partial=>'layouts/pretty_toolbar', :object=>@small_elements %>
|
@small_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>small} if can? :edit, small
|
||||||
|
@small_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('thema.remove'), :path=>small, :method=>:delete,:confirm=>I18n.t('thema.sure')} if can? :delete, small %>
|
||||||
|
<%= render :partial=>'layouts/pretty_toolbar', :object=>@small_elements unless @small_elements.empty? %>
|
||||||
|
|||||||
@@ -12,10 +12,11 @@
|
|||||||
<%= render :partial=>'layouts/pretty_toolbar' %>
|
<%= render :partial=>'layouts/pretty_toolbar' %>
|
||||||
|
|
||||||
<h2>FAQs:</h2>
|
<h2>FAQs:</h2>
|
||||||
<% @thema.fragen.each do |frage| %>
|
<div id="fragen">
|
||||||
<%= render frage %>
|
<%= render :partial=>'fragen/liste' %>
|
||||||
<% end %>
|
</div>
|
||||||
|
<% @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}] %>
|
<% @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=>'layouts/pretty_toolbar', :object=>@frage_elements %>
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
Reference in New Issue
Block a user