Nicolae Claudius
13 years ago
10 changed files with 187 additions and 73 deletions
@ -1,2 +1,31 @@
|
||||
module DomainsHelper |
||||
def domain_list_row_class(record) |
||||
cannot?(:crud_permissions, record) ? "shared-domain" : '' |
||||
end |
||||
|
||||
# Makes a link out of domain name. |
||||
# Indents and dedents to create a tree structure, |
||||
# assuming that the records are sorted in preorder. |
||||
# Adds a visual cue if the record is shared via permissions feature. |
||||
def domain_name_column(record) |
||||
elements = [] |
||||
@previous_records ||= [] |
||||
level = @previous_records.reduce(0) { |acc, r| record.subdomain_of?(r) ? acc + 1 : acc } |
||||
if level > 0 |
||||
(level - 1).times do # indent |
||||
elements << '<span class="ui-icon ui-icon-blank"></span>' |
||||
end |
||||
elements << '<span class="ui-icon ui-icon-carat-1-sw"></span>' |
||||
end |
||||
elements << link_to(record.name, "http://#{record.name}") |
||||
unless can?(:crud_permissions, record) |
||||
who = "<strong>#{record.user.name}</strong> #{mail_to(record.user.email)}" |
||||
elements << <<-HTM |
||||
<i class="icon-share" rel="popover" data-original-title="Shared domain" |
||||
data-content="This domain was shared with you by #{h who}"></i> |
||||
HTM |
||||
end |
||||
@previous_records << record |
||||
elements.join.html_safe |
||||
end |
||||
end |
@ -1,15 +0,0 @@
|
||||
<% # customize row class to highlight shared domains |
||||
|
||||
record = list_record if list_record # compat with render :partial :collection |
||||
columns ||= list_columns |
||||
tr_class = cycle("", "even-record") |
||||
tr_class += " shared-domain" if cannot?(:crud_permissions, record) |
||||
url_options = params_for(:action => :list, :id => record.id) |
||||
action_links ||= active_scaffold_config.action_links.member |
||||
-%> |
||||
|
||||
<tr class="record <%= tr_class %>" id="<%= element_row_id(:action => :list, :id => record.id) %>" data-refresh="<%= url_for(params_for(:action => :row, :id => record.id, :_method => :get)).html_safe %>"> |
||||
<%= render :partial => 'list_record_columns', :locals => {:record => record, :columns => columns} %> |
||||
<%= render :partial => 'list_actions', :locals => {:record => record, :url_options => url_options, :action_links => action_links} unless action_links.empty? %> |
||||
<%= render_nested_view(action_links, url_options, record) unless @nested_auto_open.nil? %> |
||||
</tr> |
@ -0,0 +1,26 @@
|
||||
Domain.class_exec do |
||||
def ancestor_of?(node); false end |
||||
def descendants; subdomains end |
||||
end |
||||
|
||||
class AddNestedIntervalToDomains < ActiveRecord::Migration |
||||
def change |
||||
add_column :domains, :parent_id, :integer |
||||
add_column :domains, :lftp, :integer, null: false, default: 0 |
||||
add_column :domains, :lftq, :integer, null: false, default: 0 |
||||
add_column :domains, :rgtp, :integer, null: false |
||||
add_column :domains, :rgtq, :integer, null: false |
||||
add_column :domains, :lft, :float, null: false, limit: 53 |
||||
add_column :domains, :rgt, :float, null: false, limit: 53 |
||||
|
||||
add_index :domains, :parent_id |
||||
add_index :domains, :lftp |
||||
add_index :domains, :lftq |
||||
add_index :domains, :lft |
||||
add_index :domains, :rgt |
||||
|
||||
Domain.reset_column_information |
||||
Domain.inheritance_column = "sti_disabled" |
||||
Domain.scoped.each &:save |
||||
end |
||||
end |
Loading…
Reference in new issue