Class: Releaf::Builders::RefusedDestroyDialogBuilder

Inherits:
Object
  • Object
show all
Includes:
ResourceDialog
Defined in:
app/builders/releaf/builders/refused_destroy_dialog_builder.rb

Instance Attribute Summary

Attributes included from Resource

#resource

Attributes included from Template

#template

Instance Method Summary collapse

Methods included from ResourceDialog

#dialog?

Methods included from Resource

#initialize

Methods included from View

#breadcrumb_item, #breadcrumbs, #dialog?, #dialog_name, #flash_item, #flash_notices, #footer_blocks, #footer_primary_block, #footer_secondary_block, #footer_secondary_tools, #footer_tools, #header, #header_extras, #output, #section, #section_attributes, #section_blocks, #section_footer, #section_footer_class, #section_header, #section_header_extras

Methods included from Template

#initialize

Methods included from Base

#default_translation_scope, #html_escape, #icon, #layout_settings, #locale_options, #resource_title, #safe_join, #t, #tag, #template_variable, #translate_locale, #wrapper

Instance Method Details


54
55
56
57
58
# File 'app/builders/releaf/builders/refused_destroy_dialog_builder.rb', line 54

def footer_primary_tools
  [
    button(t("Ok"), "check", href: index_path, data: {type: 'cancel'})
  ]
end

#relation_description(relation, key) ⇒ Object


25
26
27
# File 'app/builders/releaf/builders/refused_destroy_dialog_builder.rb', line 25

def relation_description(relation, key)
  "#{resource.class.human_attribute_name(key)} (#{relation[:objects].count})"
end

#relation_objects(relation) ⇒ Object


29
30
31
32
33
34
35
# File 'app/builders/releaf/builders/refused_destroy_dialog_builder.rb', line 29

def relation_objects(relation)
  tag(:ul, class: "relations") do
    relation[:objects][0..2].collect do |item|
        relation_objects_item(item, relation)
    end + [(tag(:li, "...") if relation[:objects].count > 3)]
  end
end

#relation_objects_item(item, relation) ⇒ Object


37
38
39
40
41
42
43
44
45
# File 'app/builders/releaf/builders/refused_destroy_dialog_builder.rb', line 37

def relation_objects_item(item, relation)
  tag(:li) do
    if relation[:controller].nil?
      resource_title(item)
    else
      link_to(resource_title(item), controller: relation[:controller], action: "edit", id: item)
    end
  end
end

#restricted_relation(relation, key) ⇒ Object


47
48
49
50
51
52
# File 'app/builders/releaf/builders/refused_destroy_dialog_builder.rb', line 47

def restricted_relation(relation, key)
  [
    relation_description(relation, key),
    relation_objects(relation)
  ]
end

#restricted_relationsObject


15
16
17
18
19
20
21
22
23
# File 'app/builders/releaf/builders/refused_destroy_dialog_builder.rb', line 15

def restricted_relations
  tag(:ul, class: "restricted-relations") do
    template_variable("restricted_relations").collect do|key, relation|
      tag(:li) do
        restricted_relation(relation, key)
      end
    end
  end
end

#section_bodyObject


4
5
6
7
8
9
10
11
12
13
# File 'app/builders/releaf/builders/refused_destroy_dialog_builder.rb', line 4

def section_body
  message = "Deletion of %{resource} restricted due to existing relations:"
  tag(:div, class: "body") do
    [
      icon("ban"),
      tag(:div, t(message, default: message, resource: resource_title(resource)), class: "description"),
      restricted_relations
    ]
  end
end

#section_header_textObject


60
61
62
# File 'app/builders/releaf/builders/refused_destroy_dialog_builder.rb', line 60

def section_header_text
  t("Deletion refused")
end