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.json
|
||||
load_and_authorize_resource
|
||||
|
||||
acts_as_flagable
|
||||
def index
|
||||
@survey_questions = Survey::Question.all
|
||||
respond_to do |format|
|
||||
|
||||
@@ -6,6 +6,7 @@ class Survey::Question < ActiveRecord::Base
|
||||
include IsCommentable
|
||||
FLAG_ICONS={"delete" => "fa fa-trash"}
|
||||
scope :templates, ->{ where(flag_template:true)}
|
||||
acts_as_flagable
|
||||
|
||||
def add_yesno_choices
|
||||
c=Survey::Choice.new(title: "Ja")
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
</p>
|
||||
<%= render partial: "neuigkeit_view", object: @neuigkeit %>
|
||||
</div>
|
||||
<% @neuigkeit.questions.each do |q| %>
|
||||
<%= render q%>
|
||||
<% end %>
|
||||
<% @neuigkeit.questions.each do |q| %>
|
||||
<%= render q if can? :show, q %>
|
||||
<% end %>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -16,9 +16,9 @@ module Flagable
|
||||
module LocalInstanceMethods
|
||||
|
||||
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
|
||||
authorize! lflag, @obj
|
||||
unless params[:flag].nil? || params[:flag].empty? || params[:value].nil?
|
||||
@@ -53,7 +53,7 @@ module Flagable
|
||||
v
|
||||
end
|
||||
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
|
||||
@@ -62,9 +62,10 @@ module Flagable
|
||||
def flag_link(obj, flag, text="")
|
||||
flag=flag.to_s
|
||||
fi = obj.class::FLAG_ICONS
|
||||
fc = obj.class::FLAG_CONFIRM
|
||||
value=obj.send("flag_"+flag)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user