Browse Source

controllers tweaks

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
f25b1b4124
  1. 4
      app/controllers/domains_controller.rb
  2. 23
      app/controllers/ns_controller.rb
  3. 2
      app/controllers/records_controller.rb
  4. 20
      app/controllers/soas_controller.rb

4
app/controllers/domains_controller.rb

@ -2,7 +2,7 @@ class DomainsController < ApplicationController
active_scaffold :domain do |conf| active_scaffold :domain do |conf|
conf.columns = [:name, :soa_record, :ns_records, :records] conf.columns = [:name, :soa_record, :ns_records, :records]
conf.list.columns = [:name, :soa_record, :ns_records, :records] conf.list.columns = [:name, :records]
conf.create.columns = [:name, :soa_record, :ns_records] conf.create.columns = [:name, :soa_record, :ns_records]
conf.update.columns = [:name, :soa_record, :ns_records] conf.update.columns = [:name, :soa_record, :ns_records]
conf.columns[:name].description = 'domain.com' conf.columns[:name].description = 'domain.com'
@ -11,7 +11,7 @@ class DomainsController < ApplicationController
conf.list.sorting = { :name => :asc } conf.list.sorting = { :name => :asc }
conf.create.link.label = "Add Domain" conf.create.link.label = "Add Domain"
conf.columns[:records].label = 'All Records' # conf.columns[:records].label = 'All Records'
end end
protected protected

23
app/controllers/ns_controller.rb

@ -8,4 +8,27 @@ class NsController < ApplicationController
conf.actions.exclude :show conf.actions.exclude :show
end end
before_filter :ensure_nested_under_domain before_filter :ensure_nested_under_domain
protected
# override to use :mx_records instead of :records assoc
def beginning_of_chain
if nested? && nested.association && nested.association.collection? && nested.association.name == :records
nested.parent_scope.ns_records
else
super
end
end
# override, we make our own sti logic
def new_model
model = beginning_of_chain
model.new
end
# override to close create form after success
def render_parent?
nested_singular_association? # || params[:parent_sti]
end
end end

2
app/controllers/records_controller.rb

@ -12,6 +12,7 @@ class RecordsController < ApplicationController
new_sti_link.controller = Proc.new { active_scaffold_controller_for(child.to_s.camelize.constantize).controller_path } new_sti_link.controller = Proc.new { active_scaffold_controller_for(child.to_s.camelize.constantize).controller_path }
active_scaffold_config.action_links.collection.create.add(new_sti_link) active_scaffold_config.action_links.collection.create.add(new_sti_link)
end end
active_scaffold_config.action_links.collection.create.name = "Add Record"
end end
end end
@ -19,6 +20,7 @@ class RecordsController < ApplicationController
conf.sti_children = [:SOA, :NS, :MX, :A, :CNAME, :TXT] conf.sti_children = [:SOA, :NS, :MX, :A, :CNAME, :TXT]
conf.columns = [:name, :type, :content, :ttl, :prio, :change_date] conf.columns = [:name, :type, :content, :ttl, :prio, :change_date]
conf.columns[:change_date].list_ui = :timestamp conf.columns[:change_date].list_ui = :timestamp
# conf.create.link.label = "Add Record"
conf.actions.exclude :show conf.actions.exclude :show
end end
before_filter :ensure_nested_under_domain before_filter :ensure_nested_under_domain

20
app/controllers/soas_controller.rb

@ -6,4 +6,24 @@ class SoasController < ApplicationController
conf.columns[:change_date].list_ui = :timestamp conf.columns[:change_date].list_ui = :timestamp
conf.actions.exclude :delete, :show conf.actions.exclude :delete, :show
end end
before_filter :ensure_nested_under_domain
protected
# override to use :mx_records instead of :records assoc
def beginning_of_chain
super.readonly(false)
end
# override, we make our own sti logic
def new_model
model = beginning_of_chain
model.new
end
# override to close create form after success
def render_parent?
nested_singular_association? # || params[:parent_sti]
end
end end

Loading…
Cancel
Save