Browse Source

domains links, refactor

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
5e39ddd3ed
  1. 1
      app/assets/stylesheets/overrides.css.erb
  2. 2
      app/controllers/hosts_controller.rb
  3. 5
      app/models/ability.rb
  4. 12
      app/views/domains/_list_record_columns.html.erb
  5. 23
      app/views/hosts/_list_record_columns.html.erb

1
app/assets/stylesheets/overrides.css.erb

@ -26,6 +26,7 @@ body.errors #main .inner {
#as_domains-active-scaffold .name-column, #as_domains-active-scaffold .name-column,
#as_hosts-active-scaffold .name-column { #as_hosts-active-scaffold .name-column {
font-weight: bold; font-weight: bold;
text-shadow: none;
} }
.flash .alert { .flash .alert {

2
app/controllers/hosts_controller.rb

@ -2,7 +2,7 @@ class HostsController < ApplicationController
active_scaffold :a do |conf| active_scaffold :a do |conf|
conf.columns = [:name, :host_domain, :content, :ttl, :change_date, :authentication_token] conf.columns = [:name, :host_domain, :content, :ttl, :change_date, :authentication_token]
conf.list.columns = [:name, :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.update.columns = [:name, :host_domain, :content, :ttl]
conf.list.label = 'Hosts' conf.list.label = 'Hosts'
conf.list.sorting = {:name => :asc} conf.list.sorting = {:name => :asc}

5
app/models/ability.rb

@ -1,10 +1,11 @@
class Ability class Ability
CRUD = [:read, :create, :edit, :update, :destroy] CRUD = [:read, :create, :edit, :destroy]
include CanCan::Ability include CanCan::Ability
attr_accessor :user attr_accessor :user
attr_accessor :context attr_accessor :context
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
def initialize(options) def initialize(options)
@user = options[:user] || User.new @user = options[:user] || User.new
@context = options[:context] || :application @context = options[:context] || :application
@ -14,8 +15,6 @@ class Ability
owner_abilities owner_abilities
sharing_abilities sharing_abilities
end end
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
end end
protected protected

12
app/views/domains/_list_record_columns.html.erb

@ -4,7 +4,17 @@
<% authorized = record.authorized_for?(:crud_type => :read, :column => column.name) -%> <% 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 -%> <% column_value = authorized ? get_column_value(record, column) : active_scaffold_config.list.empty_field_text -%>
<% if column.name == :records %> <% if column.name == :name %>
<td class="<%= column_class(column, column_value, record) %>" >
<% 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 %>
</td>
<% elsif column.name == :records %>
<td class="<%= column_class(column, column_value, record) %>" > <td class="<%= column_class(column, column_value, record) %>" >
<% column_value = 'Manage All Records (0)' if column_value == '-' %> <% column_value = 'Manage All Records (0)' if column_value == '-' %>
<%= authorized ? render_list_column(column_value, column, record) : column_value %> <%= authorized ? render_list_column(column_value, column, record) : column_value %>

23
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 %>
<td class="<%= column_class(column, column_value, record) %>" >
<% 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 %>
</td>
<% else %>
<td class="<%= column_class(column, column_value, record) %>" >
<%= authorized ? render_list_column(column_value, column, record) : column_value %>
</td>
<% end %>
<% end -%>
Loading…
Cancel
Save