Module: Admin::Resources::DataTypes::HasOneHelper
- Defined in:
- app/helpers/admin/resources/data_types/has_one_helper.rb
Instance Method Summary collapse
- #build_add_new_for_has_one(klass, field, options = {}) ⇒ Object
- #set_has_one_resource_actions ⇒ Object
- #typus_form_has_one(field) ⇒ Object
Instance Method Details
#build_add_new_for_has_one(klass, field, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/admin/resources/data_types/has_one_helper.rb', line 21 def build_add_new_for_has_one(klass, field, = {}) if admin_user.can?("create", klass) = { :controller => "/admin/#{klass.to_resource}", :action => "new", :_popup => true } link_to Typus::I18n.t("Add New"), .merge(), { :class => "iframe_with_page_reload" } end end |
#set_has_one_resource_actions ⇒ Object
31 32 33 34 |
# File 'app/helpers/admin/resources/data_types/has_one_helper.rb', line 31 def set_has_one_resource_actions @resource_actions = [["Edit", { :action => "edit" }, {}], ["Trash", { :action => "destroy" }, { :confirm => "Trash?" }]] end |
#typus_form_has_one(field) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/admin/resources/data_types/has_one_helper.rb', line 3 def typus_form_has_one(field) setup_relationship(field) = @item.send(field) @items = ? [] : [] set_has_one_resource_actions locals = { :association_name => @association_name, :table => build_relationship_table, :add_new => nil } if @items.empty? = { "resource[#{@reflection.foreign_key}]" => @item.id } locals[:add_new] = build_add_new_for_has_one(@model_to_relate, field, ) end render "admin/templates/has_one", locals end |