caboose-cms 0.4.144 → 0.4.145

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjFiMGQwYWEzNjk4OGYxNTk2MzYwMTJkZGM0OTZiNjQ5M2M5MWJjNQ==
4
+ M2VjNzUxMTk0ZmYxNGUwMzMyNjI2MGQ4YTgyMzVkNjM5NWU1NmRlNg==
5
5
  data.tar.gz: !binary |-
6
- MDg4OGFlYmU5ODM0MzEzNjAwZTI1MDEwM2MyOGJjZDdjYzMzNWJkNQ==
6
+ MWRjZjczNGU2NmUxMDA2OTM0OTI4NTdjNTMwMmEyN2MxOTI1ZjY3MA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTI1YzM3Mzc1N2IyZWNjNzU3ZDNkZDI5ZGRiYzQ3MWE1NzBjMjdlMTBlMjI2
10
- Y2FjNzlhODYzMDg3YzdjYzAxNTA2ZWU1ZDM2OWRlNjQzODI0ZmU3OTk5MWQx
11
- ZDZmZGIzOWRlYWY5MzRmYjNlMTBlNDg2MzA4NDgxNWIxOWQwNDk=
9
+ OTFhNjIwYWVmMjllMWQyODNkMGE3ZjVjY2U5YWVjOTM5YzEzOGZkZGJiZGNl
10
+ ZDBiMWI4OWZhNDU5MDUzY2VjMzQyZDBhNmUzMjY4NmMxNzliNDBlNTc4YzU3
11
+ M2QyYzNlN2NlMWI4MWNmMTUzMTg4ZTk5MmEzM2I2ZjZhYWI4ZTY=
12
12
  data.tar.gz: !binary |-
13
- YmE4YjUzYmNmOGEzZGUxNGQwZWRjNWQ3YzBmNzA3MGUyMmM4MzI2MjA5NDI2
14
- Nzk1YTFiMzI5MTY2MGVkYTFkOTVhZTJlMTY5YTQ1MWM5MWJhZGI2YzU4NDk2
15
- YjJkYjdmZDVjZmZlNzJmYzBjODdmM2E4N2MyZDc3YWYzMzAwYmE=
13
+ YmVmYjQxNjRjYmIwNzIxNGQ1ZWFhOWIxODZjNGRjNDAwYzRkZWUxOWMxOWI0
14
+ ODdkOTA2YTY3MTYxNDhhZTRlNDdiYjgxODQ4MzVlMGU5ZDlkZWVlZmMzNzc1
15
+ ODViZGExMjZkMGY5M2E4Y2MzOWI2NjdiYWUxZjJiNzVhODQ0ODA=
@@ -36,6 +36,13 @@ module Caboose
36
36
  render :layout => 'caboose/admin'
37
37
  end
38
38
 
39
+ # GET /admin/block-types/:id/icon
40
+ def admin_edit_icon
41
+ return unless user_is_allowed('pages', 'edit')
42
+ @block_type = BlockType.find(params[:id])
43
+ render :layout => 'caboose/modal'
44
+ end
45
+
39
46
  # POST /admin/block-types
40
47
  def admin_create
41
48
  return unless user_is_allowed('pages', 'add')
@@ -69,6 +76,7 @@ module Caboose
69
76
 
70
77
  params.each do |k,v|
71
78
  case k
79
+ when 'site_id' then bt.site_id = v
72
80
  when 'parent_id' then bt.parent_id = v
73
81
  when 'name' then bt.name = v
74
82
  when 'description' then bt.description = v
@@ -123,6 +131,19 @@ module Caboose
123
131
  render :json => options
124
132
  end
125
133
 
134
+ # GET /admin/block-types/site-options
135
+ def admin_site_options
136
+ return unless user_is_allowed('pages', 'edit')
137
+ options = [{ 'value' => -1, 'text' => 'Global'}]
138
+ Site.reorder("description, name").all.each do |s|
139
+ options << {
140
+ 'value' => s.id,
141
+ 'text' => s.description && s.description.strip.length > 0 ? s.description : s.name
142
+ }
143
+ end
144
+ render :json => options
145
+ end
146
+
126
147
  # GET /admin/block-types/:id/options
127
148
  def admin_value_options
128
149
  return unless user_is_allowed('pages', 'edit')
@@ -2,11 +2,13 @@
2
2
  class Caboose::BlockType < ActiveRecord::Base
3
3
  self.table_name = "block_types"
4
4
 
5
+ belongs_to :site, :class_name => 'Caboose::Site'
5
6
  belongs_to :default_child_block_type, :foreign_key => 'default_child_block_type_id', :class_name => 'Caboose::BlockType'
6
7
  belongs_to :block_type_category
7
8
  belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Caboose::BlockType'
8
9
  has_many :children, :foreign_key => 'parent_id', :class_name => 'Caboose::BlockType', :dependent => :destroy
9
10
  attr_accessible :id,
11
+ :site_id,
10
12
  :parent_id,
11
13
  :name,
12
14
  :description,
@@ -104,6 +104,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
104
104
  [ :image , :attachment ]
105
105
  ],
106
106
  Caboose::BlockType => [
107
+ [ :site_id , :integer ],
107
108
  [ :parent_id , :integer ],
108
109
  [ :name , :string ],
109
110
  [ :description , :string ],
@@ -9,6 +9,7 @@ bt = @block_type
9
9
  <h1>Edit Block Type</h1>
10
10
  <p><div id='blocktype_<%= bt.id %>_description' ></div></p>
11
11
  <p><div id='blocktype_<%= bt.id %>_name' ></div></p>
12
+ <p><div id='blocktype_<%= bt.id %>_site_id' ></div></p>
12
13
  <p><div id='blocktype_<%= bt.id %>_parent_id' ></div></p>
13
14
  <p><div id='blocktype_<%= bt.id %>_block_type_category_id' ></div></p>
14
15
  <p><div id='blocktype_<%= bt.id %>_field_type' ></div></p>
@@ -47,30 +48,19 @@ bt = @block_type
47
48
  <p>This type of page block doesn't have any fields.</p>
48
49
  <% end %>
49
50
 
50
- <h2>Icon</h2>
51
- <div class='icons'>
52
- <% Caboose::BlockTypeIcons.names.each do |icon| %>
53
- <a href='#' id='icon_<%= icon %>' <% if bt.icon == icon %>class='selected'<% end %>><span class='icon-<%= icon %>'></span></a>
54
- <% end %>
55
- </div>
56
-
57
51
  <div id='message'></div>
58
52
  <p>
59
53
  <input type='button' value='< Back' onclick="window.location='/admin/block-types<%= bt.parent_id && bt.parent_id > 0 ? "/#{bt.parent_id}/edit" : '' %>';" />
54
+ <input type='button' value='Edit Icon' onclick="caboose_modal_url('/admin/block-types/<%= @block_type.id %>/icon');" />
60
55
  <input type='button' value='Delete Block Type' onclick="delete_block_type(<%= @block_type.id %>);" />
61
56
  </p>
57
+ <br />
62
58
 
63
59
  <% content_for :caboose_css do %>
64
60
  <%= stylesheet_link_tag 'caboose/icomoon_fonts' %>
65
61
  <style type='text/css'>
66
62
  #blocktype_<%= bt.id %>_render_function { font-family: Courier; font-size: 80%; width: 100%; }
67
63
  #blocktype_<%= bt.id %>_options_function { font-family: Courier; font-size: 80%; width: 100%; }
68
- div.icons { height: 400px; width: 80%; overflow-y: scroll; }
69
- div.icons span { display: block; float: left; padding: 10px 20px; font-size: 24pt; }
70
- div.icons a span { color: #000; border: #fff 1px solid; }
71
- div.icons a:hover span { background: #efefef; color: #000; border: #666 1px solid; }
72
- div.icons a.selected span,
73
- div.icons a.selected:hover span { background: #fff69f; color: #000; border: #ff0000 1px solid; }
74
64
  </style>
75
65
  <% end %>
76
66
  <% content_for :caboose_js do %>
@@ -124,6 +114,7 @@ $(document).ready(function() {
124
114
  update_url: '/admin/block-types/<%= @block_type.id %>',
125
115
  authenticity_token: '<%= form_authenticity_token %>',
126
116
  attributes: [
117
+ { name: 'site_id' , nice_name: 'Site' , type: 'select' , value: <%= raw Caboose.json(bt.site_id ? bt.site_id : -1) %>, width: 400, options_url: '/admin/block-types/site-options' },
127
118
  { name: 'parent_id' , nice_name: 'Parent' , type: 'select' , value: <%= raw Caboose.json(bt.parent_id) %>, width: 400, options_url: '/admin/block-types/tree-options' },
128
119
  { name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(bt.name) %>, width: 400 },
129
120
  { name: 'description' , nice_name: 'Description' , type: 'text' , value: <%= raw Caboose.json(bt.description) %>, width: 400 },
@@ -0,0 +1,55 @@
1
+ <%
2
+ bt = @block_type
3
+ %>
4
+
5
+ <h1>Edit Block Type Icon</h1>
6
+ <p><input type='button' value='Close' onclick="modal.close();" /></p>
7
+
8
+ <div class='icons'>
9
+ <% Caboose::BlockTypeIcons.names.each do |icon| %>
10
+ <a href='#' id='icon_<%= icon %>' <% if bt.icon == icon %>class='selected'<% end %>><span class='icon-<%= icon %>'></span></a>
11
+ <% end %>
12
+ </div>
13
+
14
+ <div id='message'></div>
15
+ <p><input type='button' value='Close' onclick="modal.close();" /></p>
16
+
17
+ <% content_for :caboose_css do %>
18
+ <%= stylesheet_link_tag 'caboose/icomoon_fonts' %>
19
+ <style type='text/css'>
20
+ div.icons { height: 500px; overflow-y: scroll; }
21
+ div.icons span { display: block; float: left; width: 75px; margin: 1px; padding: 14px 0; font-size: 24pt; text-align: center; }
22
+ div.icons a span { color: #fff; border: #fff 1px solid; }
23
+ div.icons a:hover span { background: #efefef; color: #000; border: #666 1px solid; }
24
+ div.icons a.selected span,
25
+ div.icons a.selected:hover span { background: #fff69f; color: #000; border: #ff0000 1px solid; }
26
+ </style>
27
+ <% end %>
28
+ <% content_for :caboose_js do %>
29
+ <%= javascript_include_tag "caboose/model/all" %>
30
+ <script type="text/javascript">
31
+
32
+ function select_icon(icon)
33
+ {
34
+ $.ajax({
35
+ url: '/admin/block-types/<%= @block_type.id %>',
36
+ type: 'put',
37
+ data: { icon: icon },
38
+ success: function(resp) {
39
+ $('div.icons a.selected').removeClass('selected');
40
+ $('#icon_' + icon).addClass('selected');
41
+ }
42
+ });
43
+ }
44
+
45
+ var modal = false;
46
+ $(document).ready(function() {
47
+ modal = new CabooseModal(600);
48
+ $('div.icons a').click(function(e) {
49
+ e.preventDefault();
50
+ select_icon($(this).attr('id').substr(5));
51
+ });
52
+ });
53
+
54
+ </script>
55
+ <% end %>
@@ -14,11 +14,13 @@
14
14
 
15
15
  <table class='data'>
16
16
  <tr>
17
+ <th>Site</th>
17
18
  <th>Name</th>
18
19
  <th>Description</th>
19
20
  </tr>
20
21
  <% @block_types.each do |bt| %>
21
22
  <tr onclick="window.location='/admin/block-types/<%= bt.id %>/edit';">
23
+ <td><%= bt.site_id ? (bt.site.description && bt.site.description.strip.length > 0 ? bt.site.description : bt.site.name) : 'Global' %></td>
22
24
  <td><%= bt.name %></td>
23
25
  <td><%= bt.description %></td>
24
26
  </tr>
@@ -24,7 +24,7 @@ b = @block
24
24
  <div class='icons'>
25
25
  <% Caboose::BlockTypeCategory.reorder(:name).all.each do |cat| %>
26
26
  <% next if cat.parent_id.nil? && cat.name == 'Layouts' %>
27
- <% kids = cat.block_types.where("parent_id is null").reorder(:name).all %>
27
+ <% kids = cat.block_types.where("parent_id is null and (site_id is null or site_id = ?)", @site.id).reorder(:name).all %>
28
28
  <% if kids && kids.count > 0 %>
29
29
  <h2 onclick="$('#cat<%= cat.id %>_container').slideToggle();"><%= cat.name %></h3>
30
30
  <div id='cat<%= cat.id %>_container'>
@@ -9,6 +9,7 @@
9
9
  <option value=''>-- Select a layout --</option>
10
10
  <% cat_ids = Caboose::BlockTypeCategory.layouts.collect{ |cat| cat.id } %>
11
11
  <% Caboose::BlockType.where("block_type_category_id in (?)", cat_ids).reorder(:description).all.each do |bt| %>
12
+ <% next if bt.site_id && bt.site_id != @site.id %>
12
13
  <option value="<%= bt.id %>"><%= bt.description %></option>
13
14
  <% end %>
14
15
  </select></p>
data/config/routes.rb CHANGED
@@ -177,12 +177,14 @@ Caboose::Engine.routes.draw do
177
177
  get "admin/block-types/store/:block_type_summary_id" => "block_type_store#admin_details"
178
178
  get "admin/block-types/store" => "block_type_store#admin_index"
179
179
 
180
+ get "admin/block-types/site-options" => "block_types#admin_site_options"
180
181
  get "admin/block-types/field-type-options" => "block_types#admin_field_type_options"
181
182
  get "admin/block-types/tree-options" => "block_types#admin_tree_options"
182
183
  get "admin/block-types/options" => "block_types#admin_options"
183
184
  get "admin/block-types/new" => "block_types#admin_new"
184
185
  get "admin/block-types/:id/new" => "block_types#admin_new"
185
186
  get "admin/block-types/:id/options" => "block_types#admin_value_options"
187
+ get "admin/block-types/:id/icon" => "block_types#admin_edit_icon"
186
188
  get "admin/block-types/:id/edit" => "block_types#admin_edit"
187
189
  get "admin/block-types/:id" => "block_types#admin_show"
188
190
  get "admin/block-types" => "block_types#admin_index"
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.4.144'
2
+ VERSION = '0.4.145'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.144
4
+ version: 0.4.145
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-10 00:00:00.000000000 Z
11
+ date: 2014-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -355,6 +355,7 @@ files:
355
355
  - app/views/caboose/block_type_store/admin_details.html.erb
356
356
  - app/views/caboose/block_type_store/admin_index.html.erb
357
357
  - app/views/caboose/block_types/admin_edit.html.erb
358
+ - app/views/caboose/block_types/admin_edit_icon.html.erb
358
359
  - app/views/caboose/block_types/admin_index.html.erb
359
360
  - app/views/caboose/block_types/admin_new.html.erb
360
361
  - app/views/caboose/blocks/_block.html.erb