AutoCommit Sam Aug 1 13:03:01 CEST 2015
This commit is contained in:
@@ -53,8 +53,11 @@ before_filter :decode_commentable_type
|
||||
c = params[:comment][:commentable_type].constantize.find(params[:comment][:commentable_id]) unless params[:comment][:commentable_type].nil? or params[:comment][:commentable_id].nil?
|
||||
|
||||
@comment = Comment.build_for(c, current_user,"", params_new)
|
||||
@comments=@comment.parent_object.comments.order(:created_at).roots.page(params[:page]).per(Comment::NUM[params[:commentable_type]]).reverse_order
|
||||
|
||||
if @comment.parent_object.class==Comment
|
||||
@comments= @comment.parent_object.children
|
||||
else
|
||||
@comments=@comment.parent_object.comments.order(:created_at).roots.page(params[:page]).per(Comment::NUM[params[:commentable_type]]).reverse_order
|
||||
end
|
||||
respond_to do |format|
|
||||
if @comment
|
||||
format.html { redirect_to @comment.commentable, notice: 'Comment was successfully created.', show_comments: true }
|
||||
|
||||
@@ -35,6 +35,10 @@ class Survey::ChoicesController < ApplicationController
|
||||
# GET /survey/choices/1/edit
|
||||
def edit
|
||||
@choice = Survey::Choice.find(params[:id])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# POST /survey/choices
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
class Survey::Choice < ActiveRecord::Base
|
||||
belongs_to :question, class_name: 'Survey::Question'
|
||||
attr_accessible :picture, :sort, :text
|
||||
attr_accessible :picture, :sort, :text, :icon, :picture_cache
|
||||
has_many :answers, class_name: 'Survey::Answer'
|
||||
include ActionView::Helpers::TagHelper
|
||||
mount_uploader :picture, PictureUploader
|
||||
def to_s
|
||||
self.text
|
||||
end
|
||||
def html
|
||||
content_tag("i","", class: self.picture ) + self.text
|
||||
content_tag("i","", class: self.icon ) + self.text
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,19 +39,3 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= link_to "comment" , new_comment_path( commentable_type: "Beispiel", commentable_id: beispiel.id), remote:true if can? :comment, beispiel %>
|
||||
<%= link_to "comments:.."+beispiel.comments.count().to_s, comments_path(commentable_type: "Beispiel", commentable_id: beispiel.id), remote:true, id: Comment.switchshowid_for(beispiel) %>
|
||||
<div id="<%= Comment.formid_for(beispiel) %>">
|
||||
</div>
|
||||
<% unless beispiel.comments.roots.empty? %>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div id="<%= Comment.wrapid_for(beispiel)%>">
|
||||
<%= render partial:"comments/comments", object: beispiel.comments.order(:created_at).roots.reverse_order if params[:show_comments] %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
|
||||
<div id="<%= divid_for(comment,"newform") %>">
|
||||
</div>
|
||||
<div id="<%= Comment.wrapid_for( comment)%>">
|
||||
|
||||
<%= render partial:"comments/comments", object: comment.children.order(:created_at).reverse_order if comment.children.size >0 %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<%= link_to "Comment" , new_comment_path( commentable_type: comments_block.class.to_s.gsub("::","_"), commentable_id: comments_block.id), remote:true if can? :comment, comments_block %> <%# This is the button to add a new comment %>
|
||||
<%= link_to "comments:.."+ comments_block.comments.count().to_s, comments_path(commentable_type: "Survey_Question", commentable_id: comments_block.id), remote:true, id: Comment.switchshowid_for( comments_block) %> <%# load the comments in the comments block %>
|
||||
<%= link_to "comments:.."+ comments_block.comments.count().to_s, comments_path(commentable_type: comments_block.class.to_s.gsub("::","_"), commentable_id: comments_block.id), remote:true, id: Comment.switchshowid_for( comments_block) %> <%# load the comments in the comments block %>
|
||||
<div id="<%= divid_for(comments_block,"newform") %>">
|
||||
</div>
|
||||
<% unless comments_block.comments.roots.empty? %>
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
|
||||
<div id="<%= Comment.wrapid_for( comments_block)%>">
|
||||
<%= render partial:"comments/comments", object: comments_block.comments.order(:created_at).roots.reverse_order if params[:show_comments] %><%# can? fehlt!%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
<div id="choice_<%= choice.id %>"
|
||||
|
||||
<%= div_tag_for(choice) do %>
|
||||
|
||||
<%
|
||||
if current_user.nil?
|
||||
t=choice.text
|
||||
else
|
||||
value=(current_user.id.nil?)? false : choice.answers.where(user_id: current_user.id).count>0
|
||||
cstyle=(value) ? "true" :"false"
|
||||
t= link_to raw("" + choice.html), answer_survey_question_path(choice.question, params: {survey_question: {selected: [choice.id]}}),class: "choice-"+cstyle
|
||||
t= link_to(raw("" + choice.html+ (( choice.picture.nil?) ? "":image_tag(choice.picture.thumb.url))), answer_survey_question_path(choice.question, params: {survey_question: {selected: [choice.id]}}),class: "choice-"+cstyle )
|
||||
end
|
||||
|
||||
%>
|
||||
|
||||
|
||||
<%= t %> <%= link_to fa_icon("pencil"), edit_survey_choice_path(choice) , class: "btn btn-link navbar-btn"
|
||||
<%= t %> <%= link_to fa_icon("pencil"), edit_survey_choice_path(choice) , class: "btn btn-link navbar-btn" , remote: true
|
||||
%>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
<%= semantic_form_for @choice do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :text %>
|
||||
<i id="icon" style="font-size:2em" class="<%= @choice.icon %>"></i><a href="#" id="openselect" onclick=""> Choose Icon</a>
|
||||
|
||||
<%= f.input :icon, :input_html=>{:id=>"iconfield"},:as=>:hidden %>
|
||||
|
||||
<label>Bild</label>
|
||||
<%= image_tag(@choice.picture.thumb.url) unless @choice.picture.nil? %>
|
||||
<%= f.file_field :picture %>
|
||||
<%= f.hidden_field :picture_cache %>
|
||||
|
||||
<%= f.input :sort %>
|
||||
<%= f.input :picture, :input_html=>{:id=>"iconfield"} %>
|
||||
<% end %>
|
||||
<i id="icon" style="font-size:2em" class="<%= @choice.picture %>"></i><a href="#" id="openselect" onclick=""> Choose Icon</a>
|
||||
|
||||
<%= f.actions do %>
|
||||
<%= f.action :submit, :as => :input %>
|
||||
|
||||
1
app/views/survey/choices/edit.js.erb
Normal file
1
app/views/survey/choices/edit.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$('#<%= divid_for( @choice) %>').replaceWith("<%= escape_javascript( render partial:"form", object: @choice )%>");
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="container_question_<%= answeredquestion.id %>" style="min-width: 310px; max-width: 800px; height: <%= (100+answeredquestion.choices.count * 50).to_s%>px; margin: 0 auto" class="contentbox">
|
||||
<div id="container_question_<%= answeredquestion.id %>" style="min-width: 310px; max-width: 800px; height: <%= (100+answeredquestion.choices.count * 90).to_s%>px; margin: 0 auto" class="contentbox">
|
||||
<div style="background:red"><b><%= answeredquestion.title%></b>
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -27,4 +27,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render_comments_for(beispiel) %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user