From 5e39ddd3ed44036d024038bc032f1ff9282b427a Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Sat, 28 Jan 2012 07:57:57 -0800 Subject: [PATCH] domains links, refactor --- app/assets/stylesheets/overrides.css.erb | 1 + app/controllers/hosts_controller.rb | 2 +- app/models/ability.rb | 5 ++-- .../domains/_list_record_columns.html.erb | 12 +++++++++- app/views/hosts/_list_record_columns.html.erb | 23 +++++++++++++++++++ 5 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 app/views/hosts/_list_record_columns.html.erb diff --git a/app/assets/stylesheets/overrides.css.erb b/app/assets/stylesheets/overrides.css.erb index 959c3b9..5a96ee2 100644 --- a/app/assets/stylesheets/overrides.css.erb +++ b/app/assets/stylesheets/overrides.css.erb @@ -26,6 +26,7 @@ body.errors #main .inner { #as_domains-active-scaffold .name-column, #as_hosts-active-scaffold .name-column { font-weight: bold; + text-shadow: none; } .flash .alert { diff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb index 024081d..1ac1292 100644 --- a/app/controllers/hosts_controller.rb +++ b/app/controllers/hosts_controller.rb @@ -2,7 +2,7 @@ class HostsController < ApplicationController active_scaffold :a do |conf| conf.columns = [:name, :host_domain, :content, :ttl, :change_date, :authentication_token] conf.list.columns = [:name, :content, :ttl, :change_date, :authentication_token] - conf.create.columns = [:name, :host_domain, :content, :ttl,] + conf.create.columns = [:name, :host_domain, :content, :ttl] conf.update.columns = [:name, :host_domain, :content, :ttl] conf.list.label = 'Hosts' conf.list.sorting = {:name => :asc} diff --git a/app/models/ability.rb b/app/models/ability.rb index 3602bac..0527f30 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,10 +1,11 @@ class Ability - CRUD = [:read, :create, :edit, :update, :destroy] + CRUD = [:read, :create, :edit, :destroy] include CanCan::Ability attr_accessor :user attr_accessor :context + # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities def initialize(options) @user = options[:user] || User.new @context = options[:context] || :application @@ -14,8 +15,6 @@ class Ability owner_abilities sharing_abilities end - - # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities end protected diff --git a/app/views/domains/_list_record_columns.html.erb b/app/views/domains/_list_record_columns.html.erb index 5f9b99e..23d515e 100644 --- a/app/views/domains/_list_record_columns.html.erb +++ b/app/views/domains/_list_record_columns.html.erb @@ -4,7 +4,17 @@ <% authorized = record.authorized_for?(:crud_type => :read, :column => column.name) -%> <% column_value = authorized ? get_column_value(record, column) : active_scaffold_config.list.empty_field_text -%> - <% if column.name == :records %> + <% if column.name == :name %> + + <% column_value = 'Manage All Records (0)' if column_value == '-' %> + <%= if authorized + link = render_list_column(column_value, column, record) + link_to link, "http://#{link}" + else + column_value + end %> + + <% elsif column.name == :records %> <% column_value = 'Manage All Records (0)' if column_value == '-' %> <%= authorized ? render_list_column(column_value, column, record) : column_value %> diff --git a/app/views/hosts/_list_record_columns.html.erb b/app/views/hosts/_list_record_columns.html.erb new file mode 100644 index 0000000..c5f0637 --- /dev/null +++ b/app/views/hosts/_list_record_columns.html.erb @@ -0,0 +1,23 @@ +<%# meaningful names for empty columns instead tiny dash "-" %> + +<% columns.each do |column| %> + <% authorized = record.authorized_for?(:crud_type => :read, :column => column.name) -%> + <% column_value = authorized ? get_column_value(record, column) : active_scaffold_config.list.empty_field_text -%> + + <% if column.name == :name %> + + <% column_value = 'Manage All Records (0)' if column_value == '-' %> + <%= if authorized + link = render_list_column(column_value, column, record) + link_to link, "http://#{link}" + else + column_value + end %> + + <% else %> + + <%= authorized ? render_list_column(column_value, column, record) : column_value %> + + <% end %> + +<% end -%>