forked from bofh/fetsite
AutoCommit Mit Aug 5 11:03:06 CEST 2015
This commit is contained in:
@@ -2,7 +2,7 @@ class Survey::QuestionsController < ApplicationController
|
|||||||
# GET /survey/questions
|
# GET /survey/questions
|
||||||
# GET /survey/questions.json
|
# GET /survey/questions.json
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
acts_as_flagable
|
||||||
def index
|
def index
|
||||||
@survey_questions = Survey::Question.all
|
@survey_questions = Survey::Question.all
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class Survey::Question < ActiveRecord::Base
|
|||||||
include IsCommentable
|
include IsCommentable
|
||||||
FLAG_ICONS={"delete" => "fa fa-trash"}
|
FLAG_ICONS={"delete" => "fa fa-trash"}
|
||||||
scope :templates, ->{ where(flag_template:true)}
|
scope :templates, ->{ where(flag_template:true)}
|
||||||
|
acts_as_flagable
|
||||||
|
|
||||||
def add_yesno_choices
|
def add_yesno_choices
|
||||||
c=Survey::Choice.new(title: "Ja")
|
c=Survey::Choice.new(title: "Ja")
|
||||||
|
|||||||
@@ -35,9 +35,9 @@
|
|||||||
</p>
|
</p>
|
||||||
<%= render partial: "neuigkeit_view", object: @neuigkeit %>
|
<%= render partial: "neuigkeit_view", object: @neuigkeit %>
|
||||||
</div>
|
</div>
|
||||||
<% @neuigkeit.questions.each do |q| %>
|
<% @neuigkeit.questions.each do |q| %>
|
||||||
<%= render q%>
|
<%= render q if can? :show, q %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ module Flagable
|
|||||||
module LocalInstanceMethods
|
module LocalInstanceMethods
|
||||||
|
|
||||||
def flag
|
def flag
|
||||||
fi = controller_name.classify.constantize::FLAG_ICONS
|
fi = controller_path.classify.constantize::FLAG_ICONS
|
||||||
|
|
||||||
@obj=controller_name.classify.constantize.find(params[:id])
|
@obj=controller_path.classify.constantize.find(params[:id])
|
||||||
lflag=("flag_"+params[:flag]).to_sym
|
lflag=("flag_"+params[:flag]).to_sym
|
||||||
authorize! lflag, @obj
|
authorize! lflag, @obj
|
||||||
unless params[:flag].nil? || params[:flag].empty? || params[:value].nil?
|
unless params[:flag].nil? || params[:flag].empty? || params[:value].nil?
|
||||||
@@ -53,7 +53,7 @@ module Flagable
|
|||||||
v
|
v
|
||||||
end
|
end
|
||||||
def flaglinkid(flag)
|
def flaglinkid(flag)
|
||||||
return self.class.to_s + "_" + self.id.to_s + "_flag_"+flag.to_s
|
return self.class.to_s.gsub("::","_") + "_" + self.id.to_s + "_flag_"+flag.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -62,9 +62,10 @@ module Flagable
|
|||||||
def flag_link(obj, flag, text="")
|
def flag_link(obj, flag, text="")
|
||||||
flag=flag.to_s
|
flag=flag.to_s
|
||||||
fi = obj.class::FLAG_ICONS
|
fi = obj.class::FLAG_ICONS
|
||||||
|
fc = obj.class::FLAG_CONFIRM
|
||||||
value=obj.send("flag_"+flag)
|
value=obj.send("flag_"+flag)
|
||||||
cstyle=(value) ? "true" :"false"
|
cstyle=(value) ? "true" :"false"
|
||||||
link_to ff_icon(fi[flag]), url_for({controller: obj.class.name.tableize,action: :flag, flag: flag, value: !value, theme: nil, locale: nil, id: obj.id}), remote: true, class:("flag-"+cstyle +" flag-"+flag + "-"+cstyle ), id: obj.flaglinkid(flag)
|
link_to ff_icon(fi[flag]), url_for({controller: obj.class.name.tableize,action: :flag, flag: flag, value: !value, theme: nil, locale: nil, id: obj.id}), remote: true, class:("flag-"+cstyle +" flag-"+flag + "-"+cstyle ), id: obj.flaglinkid(flag), data: { confirm: (((!fc.nil? && fc["flag_"+flag].nil?) ? fc["flag_"+flag].nil? : nil)) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user