Class: AdminPagesMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/01_admin_pages.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/migrations/01_admin_pages.rb', line 91

def self.down(site)
  site.admin_root_pages.destroy
  site.admin_list_pages.destroy
  site.admin_tree_pages.destroy
  site.admin_editor_pages.destroy
  site.admin_settings_pages.destroy
  site.admin_sync_pages.destroy
end

.up(site) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/migrations/01_admin_pages.rb', line 2

def self.up(site)
  site.pages.create_model :admin_root_pages do |admin_root_pages|
    admin_root_pages.view_group = site.groups['Administrators']
    admin_root_pages.create_group = site.groups['Administrators']
    admin_root_pages.update_group = site.groups['Administrators']
    admin_root_pages.delete_group = site.groups['Administrators']
    admin_root_pages.allowed_children = []
    admin_root_pages.allowed_parents = []
    admin_root_pages.hide_in_admin = true
    admin_root_pages.record_class_name = 'AdminRootPage'
  end
  
  site.record_proxy_pages.create_model :admin_list_pages do |admin_list_pages|
    add_field :show_record_layout, :string, default: 'admin_list_record'
    add_field :render_form, :boolean, default: true
    add_field :show_new_button, :boolean, default: true
    add_field :partial_name, :string
    add_embed_many :columns do
      add_field :name, :string, validations: {required: {}}
      add_field :as, :string
      add_field :style, :enum, options: %w{Text Boolean Integer Float Currency Percentage Date Time DateTime Label}, default: 'Text'
      add_field :decimals, :integer
      add_field :symbol, :string, default: '$'
      add_field :true_text, :string, default: 'Yes'
      add_field :false_text, :string, default: 'No'
      add_field :format, :string
      add_embed_many :colors do
        add_field :label, :string
        add_field :color, :color
      end
      add_field :default_sort, :boolean, default: false
    end
    
    admin_list_pages.view_group = site.groups['Administrators']
    admin_list_pages.create_group = site.groups['Administrators']
    admin_list_pages.update_group = site.groups['Administrators']
    admin_list_pages.delete_group = site.groups['Administrators']
    admin_list_pages.allowed_children = []
    admin_list_pages.allowed_parents = []
    admin_list_pages.hide_in_admin = true
    admin_list_pages.record_class_name = 'AdminListPage'
  end
  
  site.pages.create_model :admin_tree_pages do |admin_tree_pages|
    add_one :root, model: :record
    admin_tree_pages.view_group = site.groups['Administrators']
    admin_tree_pages.create_group = site.groups['Administrators']
    admin_tree_pages.update_group = site.groups['Administrators']
    admin_tree_pages.delete_group = site.groups['Administrators']
    admin_tree_pages.allowed_children = []
    admin_tree_pages.allowed_parents = []
    admin_tree_pages.hide_in_admin = true
    admin_tree_pages.record_class_name = 'AdminTreePage'
  end
  
  site.pages.create_model :admin_editor_pages do |admin_editor_pages|
    admin_editor_pages.record_class_name = 'AdminEditorPage'
    admin_editor_pages.allowed_children = []
    admin_editor_pages.allowed_parents = []
    admin_editor_pages.hide_in_admin = true
    admin_editor_pages.view_group = site.groups['Administrators']
    admin_editor_pages.create_group = site.groups['Administrators']
    admin_editor_pages.update_group = site.groups['Administrators']
    admin_editor_pages.delete_group = site.groups['Administrators']
  end
  
  site.pages.create_model :admin_settings_pages do |admin_settings_pages|
    admin_settings_pages.record_class_name = 'AdminSettingsPage'
    admin_settings_pages.allowed_children = []
    admin_settings_pages.allowed_parents = []
    admin_settings_pages.hide_in_admin = true
    admin_settings_pages.view_group = site.groups['Administrators']
    admin_settings_pages.create_group = site.groups['Administrators']
    admin_settings_pages.update_group = site.groups['Administrators']
    admin_settings_pages.delete_group = site.groups['Administrators']
  end
  
  site.pages.create_model :admin_sync_pages do |admin_sync_pages|
    admin_sync_pages.record_class_name = 'AdminSyncPage'
    admin_sync_pages.allowed_children = []
    admin_sync_pages.allowed_parents = []
    admin_sync_pages.hide_in_admin = true
    admin_sync_pages.view_group = site.groups['Administrators']
    admin_sync_pages.create_group = site.groups['Administrators']
    admin_sync_pages.update_group = site.groups['Administrators']
    admin_sync_pages.delete_group = site.groups['Administrators']
  end
end