Created
December 5, 2012 23:59
-
-
Save kneipp/4220683 to your computer and use it in GitHub Desktop.
formtastic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
ActiveAdmin.register Task do | |
scope :all, :default => true | |
scope :desta_semana do |tasks| | |
tasks.where('final_date >= ? and final_date < ?', -1.day.from_now, 1.week.from_now) | |
end | |
scope :atrasadas do |tasks| | |
tasks.where('final_date < ? and is_done = ?', -1.day.from_now, false) | |
end | |
scope :minhas do |tasks| | |
tasks.where(:admin_user_id => current_admin_user.id) | |
end | |
index do | |
column :title | |
column { |task| status_tag (task.is_done ? "OK" : "Pendente"), (task.is_done ? :ok : :error) } | |
column :final_date | |
default_actions | |
end | |
#New/Edit forms | |
form html: { enctype: "multipart/form-data" } do |f| | |
f.inputs "Detalhes da Tarefa" do | |
f.input :project | |
f.input :admin_user # puts <AdminUser:0x007fef37e6a518> | |
f.input :title | |
f.input :description | |
f.input :is_done | |
f.input :final_date | |
end | |
f.buttons | |
end | |
show do | |
panel "Detalhes da Tarefa" do | |
attributes_table_for task do | |
row("Status") { status_tag (task.is_done ? "OK" : "Pendente"), (task.is_done ? :ok : :error) } | |
row("Título") { task.title } | |
row("Projeto") { link_to task.project.title, admin_project_path(task.project) } | |
row("Responsável") { link_to task.admin_user.email, admin_admin_user_path(task.admin_user) } | |
row("Prazo") { task.final_date? ? l(task.final_date, :format => :long) : '-' } | |
end | |
end | |
active_admin_comments | |
end | |
sidebar "Outras Tarefas Desse Usuário", :only => :show do | |
table_for current_admin_user.tasks.where(:project_id => task.project) do |t| | |
t.column("Status") { |task| status_tag (task.is_done ? "OK" : "Pendente"), (task.is_done ? :ok : :error) } | |
t.column("Título") { |task| link_to task.title, admin_task_path(task) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RT @synt4x: @kneipp try something like what's written here: http://github.com/justinfrench/f… (the :member_label part)