themengruppen verwalten form
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
<%= raw(frage.text) %>
|
||||
<br/>
|
||||
|
||||
<%= 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?' } %>
|
||||
</p>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
$("#fragen").html("<%=escape_javascript( render :partial=>'fragen/liste' )%>")
|
||||
$("#fragen").html("<%=escape_javascript( render :partial=>'fragen/liste' )%>")
|
||||
$("#fragenform").html("<%=escape_javascript( render :partial=>'fragen/rform' )%>")
|
||||
@@ -10,7 +10,7 @@ Verwendung: Aufruf mit
|
||||
<% toolbar_elements.each do |t| %>
|
||||
<% unless t[:method]==:versions %>
|
||||
<% text='<i class="'.html_safe+ t[:hicon].to_s.html_safe + '"></i>'.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 %>
|
||||
<div class="btn-group">
|
||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
|
||||
@@ -1,41 +1,32 @@
|
||||
<%= tinymce_assets %>
|
||||
<%= semantic_form_for @thema do |f| %>
|
||||
<div class="container-fluid">
|
||||
|
||||
|
||||
<%= semantic_form_for @thema, :remote=>true do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<%= f.input :title %>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<%= f.input :themengruppe %>
|
||||
<%= f.input :text, :as=>:tinymce_text%>
|
||||
<% end %>
|
||||
<%= tinymce %>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<%= f.input :text, :as=>:tinymce_text,:label=>false %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h2>Attachments:</h2>
|
||||
<%= render :partial => "themen/select", :object => @thema,:locals =>{ :editor => :true} %>
|
||||
</div>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
<% end %>
|
||||
|
||||
<!--
|
||||
<% @thema.attachments.each do |attachment| %>
|
||||
<ul>
|
||||
<li>
|
||||
<%= link_to attachment.name, edit_thema_attachment_path(@thema,attachment) %>
|
||||
<button type="button" onclick="insertAttachment(<%="\"" + attachment.datei.url + "\""%>,<%="\""+attachment.name+"\""%>)">Insert Me!</button>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<%= f.action :cancel, :as => :link %>
|
||||
<% end %>
|
||||
<% end %><% end %>
|
||||
<%= tinymce %>
|
||||
<h2>Attachments:</h2>
|
||||
<%= render :partial => "themen/select", :object => @thema,:locals =>{ :editor => :true} %>
|
||||
|
||||
|
||||
<% end %>
|
||||
-->
|
||||
<!--
|
||||
|
||||
<script>
|
||||
function insertAttachment(url) {
|
||||
|
||||
tinymce.activeEditor.setContent(tinymce.activeEditor.getContent({format : 'raw'}) + "Test");
|
||||
//editor.setContent(editor.getContent + "<img src=\"" + url + "\">")
|
||||
}
|
||||
</script>
|
||||
|
||||
-->
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
</br>
|
||||
|
||||
<% 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}] %>
|
||||
<div id="attachmentform">
|
||||
</div>
|
||||
<%= render :partial=>'layouts/pretty_toolbar', :object=>@att_elements %>
|
||||
<% end %>
|
||||
<br/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="themaview">
|
||||
<h1>Editing thema</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
</div>
|
||||
</br><%= link_to 'Back', @thema %>
|
||||
|
||||
@@ -11,18 +11,14 @@
|
||||
-->
|
||||
<%= render :partial=>'layouts/pretty_toolbar' %>
|
||||
|
||||
<h2>FAQs:</h2>
|
||||
<div id="fragen">
|
||||
<%= render :partial=>'fragen/liste' %>
|
||||
</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}] %>
|
||||
<%= render :partial=>'layouts/pretty_toolbar', :object=>@frage_elements %>
|
||||
<%= render :partial=>'themen/fragen' %>
|
||||
<!--
|
||||
<%= link_to 'Neue Frage', new_frage_path %> <br/>
|
||||
-->
|
||||
<br/>
|
||||
|
||||
<h2><%= I18n.t('attachment.title')%>:</h2>
|
||||
<div id="attachmentform">
|
||||
</div>
|
||||
<%= link_to new_thema_attachment_path(@thema) ,:remote=>true do %> new Attachment <% end %>
|
||||
<%= render :partial => "themen/select", :object => @thema, :locals=>{:editor => :false} %>
|
||||
|
||||
@@ -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%; }
|
||||
</style>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
|
||||
<ul id="themen" class="sort" >
|
||||
<% @themen.each do |thema| %>
|
||||
<li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox" ><h2><%= thema.title %></h2> </div></li>
|
||||
<li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox handle" ><h2><%= thema.title %></h2> </div> <%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %> <%= link_to thema_fragen_path(thema),:remote=>true do %> Fragen <% end %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="span8">
|
||||
<div id="themaview"></div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
$( document ).ready(function(){
|
||||
$("#themen").sortable({
|
||||
cursor: 'crosshair',
|
||||
drag:true,
|
||||
handle: '.handle',
|
||||
update: function(){
|
||||
$.ajax({
|
||||
url: '<%= themengruppe_sort_themen_path(@themengruppe) %>',
|
||||
|
||||
@@ -104,9 +104,9 @@ end
|
||||
|
||||
resources :beispiele
|
||||
resources :themen do
|
||||
|
||||
resources :attachments
|
||||
end
|
||||
get :fragen
|
||||
resources :attachments
|
||||
end
|
||||
|
||||
resources :themengruppen do
|
||||
get :verwalten
|
||||
|
||||
Reference in New Issue
Block a user