refinerycms-llama_widgets 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/refinery/widgets.js.coffee.erb +14 -3
- data/app/assets/stylesheets/refinery/widgets.scss +28 -1
- data/app/decorators/models/refinery/page.rb +15 -0
- data/app/models/refinery/widgets/widget.rb +4 -3
- data/app/overrides/refinery/admin/pages/_form.rb +10 -0
- data/app/views/refinery/admin/pages/_form_actions.html.erb +5 -0
- data/app/views/refinery/admin/pages/_form_page_parts.html.erb +2 -2
- data/app/views/refinery/admin/pages/_template_changer.html.erb +10 -0
- data/app/views/refinery/admin/pages/_widget_fields.slim +20 -14
- data/app/views/refinery/widgets/admin/templates/_widget_fields.slim +13 -3
- data/app/views/refinery/widgets/admin/widgets/new.slim +24 -23
- data/config/locales/en.yml +3 -0
- data/db/migrate/7_add_reuse_to_refinery_widgets.rb +7 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: babae46015255950c2cab92f3712deae0cbd4de4
|
4
|
+
data.tar.gz: 67327dc7fbce7ee44589d408b1c58ff67b2fe331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e29a16c27971626bc13ac9a32703e58c1f09fa0d17f504a386734324fd4344c5fdd8b850384da0fcc72ecf69ba826a0004de285d01d63a5374d6bbe3d4cf41d5
|
7
|
+
data.tar.gz: 3e091d5a45cb6f813123fb6bf8383a6cb158ec6dafd43f13d90c17608c3ee6ddd94c5f84c2d7037bba6e96da6715947f25658d3e934a0c39ca38cadca40b10d2
|
@@ -1,4 +1,14 @@
|
|
1
1
|
jQuery ->
|
2
|
+
$('[data-disabled-master]').each (index,element) ->
|
3
|
+
$(element).change (event) ->
|
4
|
+
if ($(this).is(':checked'))
|
5
|
+
if $(this).is('[data-disabled-warning]')
|
6
|
+
alert $(this).attr('data-disabled-warning')
|
7
|
+
$(this).parents('[data-disabled-container]').find('[data-disabled-slave]').removeAttr('disabled')
|
8
|
+
else
|
9
|
+
$(this).parents('[data-disabled-container]').find('[data-disabled-slave]').attr('disabled', true)
|
10
|
+
|
11
|
+
|
2
12
|
if $('#new_widget #widget_type').length > 0
|
3
13
|
$('#new_widget #widget_type.template').change (event) ->
|
4
14
|
selected = $(this).val()
|
@@ -66,9 +76,10 @@ window.linkFromDialog = (linkUrl) ->
|
|
66
76
|
window.parent.refinery_dialog_success()
|
67
77
|
|
68
78
|
window.removeWidget = (link) ->
|
69
|
-
|
70
|
-
|
71
|
-
|
79
|
+
if window.confirm("Are you sure you want to remove this widget?")
|
80
|
+
widget = $(link).parents('.widget')
|
81
|
+
widget.find('input[data-meta="destroy"]').val('1')
|
82
|
+
widget.hide()
|
72
83
|
|
73
84
|
window.toggleWidget = (link) ->
|
74
85
|
widgetInner = $(link).parents('.widget').find('.inner')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
.inline{ float:left; margin-top: 5px; margin-right:
|
1
|
+
.inline{ float:left; margin-top: 5px; margin-right: 10px; }
|
2
2
|
.tab-area{ border: 1px solid #CCC; padding: 10px; }
|
3
3
|
.reuseable-block{ border: 1px solid #CCC }
|
4
4
|
.widgets.ui-sortable {
|
@@ -37,6 +37,9 @@
|
|
37
37
|
.clear {
|
38
38
|
clear: both;
|
39
39
|
}
|
40
|
+
.locked {
|
41
|
+
background-color: #DDDDDD;
|
42
|
+
}
|
40
43
|
table.existing_widgets, table.select_template {
|
41
44
|
border-collapse: collapse;
|
42
45
|
border-spacing: 0;
|
@@ -50,7 +53,9 @@ table.existing_widgets, table.select_template {
|
|
50
53
|
}
|
51
54
|
}
|
52
55
|
}
|
56
|
+
|
53
57
|
.sub-title { font-size: 0.9em; opacity: 0.8; }
|
58
|
+
select.inline { margin-top: 5px; }
|
54
59
|
|
55
60
|
form fieldset {
|
56
61
|
margin: 5px;
|
@@ -63,6 +68,26 @@ form fieldset {
|
|
63
68
|
.l-margin { margin-top: 20px; margin-bottom: 20px; }
|
64
69
|
.xl-margin { margin-top: 40px; margin-bottom: 40px; }
|
65
70
|
|
71
|
+
.s-top-pad { padding-top: 5px; }
|
72
|
+
.m-top-pad { padding-top: 10px; }
|
73
|
+
.l-top-pad { padding-top: 20px; }
|
74
|
+
.xl-top-pad { padding-top: 40px; }
|
75
|
+
|
76
|
+
.s-top-margin { margin-top: 5px; }
|
77
|
+
.m-top-margin { margin-top: 10px; }
|
78
|
+
.l-top-margin { margin-top: 20px; }
|
79
|
+
.xl-top-margin { margin-top: 40px; }
|
80
|
+
|
81
|
+
.s-bottom-pad { padding-bottom: 5px; }
|
82
|
+
.m-bottom-pad { padding-bottom: 10px; }
|
83
|
+
.l-bottom-pad { padding-bottom: 20px; }
|
84
|
+
.xl-bottom-pad { padding-bottom: 40px; }
|
85
|
+
|
86
|
+
.s-bottom-margin { margin-bottom: 5px; }
|
87
|
+
.m-bottom-margin { margin-bottom: 10px; }
|
88
|
+
.l-bottom-margin { margin-bottom: 20px; }
|
89
|
+
.xl-bottom-margin { margin-bottom: 40px; }
|
90
|
+
|
66
91
|
.row { padding-left: 15px; }
|
67
92
|
.row:before,.row:after{content:" ";display:table;}
|
68
93
|
.row:after{clear:both;}
|
@@ -93,3 +118,5 @@ span.label-sup {
|
|
93
118
|
margin-left: 20px;
|
94
119
|
font-size: 0.9em;
|
95
120
|
}
|
121
|
+
|
122
|
+
input.checkbox { margin-top: 8px; }
|
@@ -5,6 +5,8 @@ Refinery::Page.class_eval do
|
|
5
5
|
|
6
6
|
before_validation :validate_widgets
|
7
7
|
|
8
|
+
before_save :change_template
|
9
|
+
|
8
10
|
def self.find_by_widget_class(widget_class)
|
9
11
|
instance = widget_class.first
|
10
12
|
return nil if instance.nil?
|
@@ -17,6 +19,10 @@ Refinery::Page.class_eval do
|
|
17
19
|
parts.collect(&:widgets).flatten
|
18
20
|
end
|
19
21
|
|
22
|
+
def ordered_parts
|
23
|
+
(::Refinery::Pages.default_parts.collect{|dp| parts.find{|p| p.title == dp } } + parts).uniq
|
24
|
+
end
|
25
|
+
|
20
26
|
private
|
21
27
|
|
22
28
|
def validate_widgets
|
@@ -25,4 +31,13 @@ Refinery::Page.class_eval do
|
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
34
|
+
def change_template
|
35
|
+
if changes.has_key?(:template_id)
|
36
|
+
widgets.each{|w| w.destroy if w.layout == true}
|
37
|
+
template.template_parts.each do |tp|
|
38
|
+
tp.sychronize_widgets!(self)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
28
43
|
end
|
@@ -10,15 +10,16 @@ module Refinery
|
|
10
10
|
attr_accessor :widget_attributes
|
11
11
|
attr_accessible :name, :position, :container_type, :container_id,
|
12
12
|
:display, :master_id, :sub_type, :locked, :widget_attributes,
|
13
|
-
:widget_id, :layout, :container
|
13
|
+
:widget_id, :layout, :container, :reuse
|
14
14
|
|
15
|
-
|
16
15
|
validate :validate_widget
|
17
16
|
|
17
|
+
validates :name, :presence => {:if => Proc.new{|o| o.reuse? }}
|
18
|
+
|
18
19
|
before_validation :update_widget
|
19
20
|
|
20
21
|
def self.reusable
|
21
|
-
where(widget_id: nil)
|
22
|
+
where(widget_id: nil, reuse: true)
|
22
23
|
end
|
23
24
|
|
24
25
|
def self.has_name
|
@@ -2,3 +2,13 @@ Deface::Override.new(virtual_path: 'refinery/admin/pages/_form',
|
|
2
2
|
name: 'insert_template_id_field_to_pages_admin_form',
|
3
3
|
insert_after: "erb[loud]:contains('form_for')",
|
4
4
|
text: "<%= f.hidden_field :template_id -%>")
|
5
|
+
|
6
|
+
Deface::Override.new(virtual_path: 'refinery/admin/pages/_form',
|
7
|
+
name: 'remove_preview_and_continue_links',
|
8
|
+
replace: "erb[loud]:contains('admin/form_actions')",
|
9
|
+
partial: 'refinery/admin/pages/form_actions')
|
10
|
+
|
11
|
+
Deface::Override.new(virtual_path: 'refinery/admin/pages/_form',
|
12
|
+
name: 'insert_template_changer',
|
13
|
+
insert_after: "erb[loud]:contains('admin/locale_picker')",
|
14
|
+
partial: 'refinery/admin/pages/template_changer')
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<%= render '/refinery/admin/form_actions', :f => f,
|
2
|
+
:continue_editing => false,
|
3
|
+
:delete_title => t('delete', :scope => 'refinery.admin.pages'),
|
4
|
+
:delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @page.title),
|
5
|
+
:cancel_url => refinery.admin_pages_path %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class='field'>
|
2
2
|
<div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
|
3
3
|
<ul id='page_parts'>
|
4
|
-
<% f.object.
|
4
|
+
<% f.object.ordered_parts.each_with_index do |part, index| %>
|
5
5
|
<li class="ui-state-default <%= 'ui-state-active' if index == 0 %>">
|
6
6
|
<%= link_to "#{part.title.to_s.humanize}", "\##{part.title}" %>
|
7
7
|
</li>
|
@@ -17,7 +17,7 @@
|
|
17
17
|
</ul>
|
18
18
|
|
19
19
|
<div id='page_part_editors'>
|
20
|
-
<% f.object.
|
20
|
+
<% f.object.ordered_parts.each_with_index do |part,index| %>
|
21
21
|
<div class='page_part' id="<%= part.title %>">
|
22
22
|
<%= render 'page_part', :f => f, :field => part.title, :part => part %>
|
23
23
|
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class='field row' data-disabled-container='true'>
|
2
|
+
<div class='col-6'>
|
3
|
+
<%= label_tag :change_template, 'Check this box to select a different template for this page', class: 'inline' %>
|
4
|
+
<%= check_box_tag :change_template, '1', false, :class => 'checkbox', 'data-disabled-master' => true, 'data-disabled-warning' => 'Please note that changing the template will affect the widgets in use on this page. After changing the template press save and come back and check the widget order is correct.' %>
|
5
|
+
</div>
|
6
|
+
<div class='col-6'>
|
7
|
+
<%= f.label :template_id, nil, class: 'inline' %>
|
8
|
+
<%= f.collection_select :template_id, ::Refinery::Widgets::Template.order(:name), :id, :name, {}, :disabled => 'disabled', 'data-disabled-slave' => true, :class => 'inline' %>
|
9
|
+
</div>
|
10
|
+
</div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
.widget data-sort-item='widget'
|
1
|
+
.widget data-sort-item='widget' class=('locked' if f.object.locked?)
|
2
2
|
.banner
|
3
3
|
.left
|
4
4
|
span.handle title="Reorder"
|
@@ -14,34 +14,40 @@
|
|
14
14
|
= refinery_icon_tag('lock')
|
15
15
|
- else
|
16
16
|
= f.label :display, :class => 'inline'
|
17
|
-
= f.check_box :display, :class => '
|
17
|
+
= f.check_box :display, :class => 'checkbox'
|
18
18
|
= link_to_function(refinery_icon_tag('bin_closed'), 'removeWidget(this)', :title => "Remove widget" )
|
19
19
|
= link_to_function(refinery_icon_tag('edit'), 'showWidgetEdit(this)', :title => "Edit widget" ) unless local_assigns.has_key?(:mode) && mode == 'edit'
|
20
20
|
= link_to_function(refinery_icon_tag('zoom'), 'toggleWidget(this)', :title => "Toggle details")
|
21
|
-
.inner.clear style="margin-top:40px;"
|
21
|
+
.inner.clear style="margin-top:40px; #{'display:none;' if f.object.locked?}"
|
22
22
|
.previewing style=("display:none;" if local_assigns.has_key?(:mode) && mode == 'edit')
|
23
|
-
.field
|
24
|
-
= f.label :name
|
25
|
-
= f.object.name
|
26
23
|
= f.fields_for f.object.widget_type.association_name do |j|
|
27
24
|
= render "refinery/widgets/admin/widgets/#{f.object.widget_type.admin_preview_partial}", :f => j
|
28
25
|
|
29
26
|
.editing style=("display:none;" unless local_assigns.has_key?(:mode) && mode == 'edit')
|
30
|
-
.
|
27
|
+
.clear
|
31
28
|
= f.hidden_field :sub_type
|
32
29
|
= f.hidden_field :_destroy, 'data-meta' => 'destroy'
|
33
30
|
= f.hidden_field :position, 'data-meta' => 'position'
|
34
31
|
= f.hidden_field :widget_id
|
35
32
|
= f.hidden_field :locked
|
36
33
|
= f.hidden_field :layout
|
37
|
-
|
38
|
-
|
39
|
-
= text_field_tag :name, f.object.name, :disabled => true
|
40
|
-
= f.hidden_field :name
|
41
|
-
- else
|
42
|
-
= f.text_field :name
|
43
|
-
span.label-sup If you would like to reuse this widget enter a name here
|
34
|
+
|
35
|
+
|
44
36
|
= f.fields_for f.object.widget_type.association_name do |j|
|
45
37
|
= render "refinery/widgets/admin/widgets/#{f.object.widget_type.admin_partial}", :f => j
|
38
|
+
|
39
|
+
- if f.object.locked?
|
40
|
+
= f.hidden_field :name
|
41
|
+
- else
|
42
|
+
.row.field.l-top-margin.m-bottom-margin data-disabled-container = true
|
43
|
+
.col-4
|
44
|
+
= f.check_box :reuse, :class => 'checkbox', 'data-disabled-master' => true
|
45
|
+
= f.label :reuse, nil, :class => 'inline'
|
46
|
+
.col-8
|
47
|
+
= f.label :name, nil, :class => 'inline'
|
48
|
+
- if f.object.reuse?
|
49
|
+
= f.text_field :name, 'data-disabled-slave' => true
|
50
|
+
- else
|
51
|
+
= f.text_field :name, :disabled => true, 'data-disabled-slave' => true
|
46
52
|
.clear
|
47
53
|
|
@@ -12,15 +12,25 @@
|
|
12
12
|
= link_to_function(refinery_icon_tag('bin_closed'), 'removeWidget(this)', :title => "Remove widget" )
|
13
13
|
= link_to_function(refinery_icon_tag('zoom'), 'toggleWidget(this)', :title => "Toggle details")
|
14
14
|
.inner.clear style="margin-top:40px;"
|
15
|
-
.
|
15
|
+
.clear
|
16
16
|
= f.hidden_field :sub_type
|
17
17
|
= f.hidden_field :_destroy, 'data-meta' => 'destroy'
|
18
18
|
= f.hidden_field :position, 'data-meta' => 'position'
|
19
19
|
= f.hidden_field :widget_id
|
20
20
|
= f.hidden_field :locked
|
21
|
-
|
22
|
-
= f.text_field :name
|
21
|
+
|
23
22
|
= f.fields_for f.object.widget_type.association_name do |j|
|
24
23
|
= render "refinery/widgets/admin/widgets/#{f.object.widget_type.admin_partial}", :f => j
|
24
|
+
|
25
|
+
.row.field.l-top-margin.m-bottom-margin data-disabled-container = true
|
26
|
+
.col-4
|
27
|
+
= f.check_box :reuse, :class => 'checkbox', 'data-disabled-master' => true
|
28
|
+
= f.label :reuse, nil, :class => 'inline'
|
29
|
+
.col-8
|
30
|
+
= f.label :name, nil, :class => 'inline'
|
31
|
+
- if f.object.reuse?
|
32
|
+
= f.text_field :name, 'data-disabled-slave' => true
|
33
|
+
- else
|
34
|
+
= f.text_field :name, :disabled => true, 'data-disabled-slave' => true
|
25
35
|
.clear
|
26
36
|
|
@@ -2,30 +2,31 @@
|
|
2
2
|
h3 Add new
|
3
3
|
= select_tag :widget_type, options_for_select([['Select type...', nil]] + Refinery::Widgets::WidgetType.all.sort_by(&:name).map{|t| [t.name, t.klass_as_string] }), :class => current_page?(refinery.url_for(:action => 'page')) ? 'page' : 'template'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
th Pages
|
13
|
-
- else
|
14
|
-
th Templates
|
15
|
-
th  
|
16
|
-
tbody
|
17
|
-
- @widgets.each do |widget|
|
18
|
-
tr class = cycle('dark', 'light')
|
19
|
-
td = widget.name
|
20
|
-
td = widget.widget_type.name
|
5
|
+
- if @widgets.any?
|
6
|
+
h3 Select existing
|
7
|
+
table.existing_widgets
|
8
|
+
thead
|
9
|
+
tr.titles
|
10
|
+
th Name
|
11
|
+
th Type
|
21
12
|
- if current_page?(refinery.url_for(action: 'page'))
|
22
|
-
|
23
|
-
= widget.pages.collect{|p| p.title }.to_sentence
|
13
|
+
th Pages
|
24
14
|
- else
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
th Templates
|
16
|
+
th  
|
17
|
+
tbody
|
18
|
+
- @widgets.each do |widget|
|
19
|
+
tr class = cycle('dark', 'light')
|
20
|
+
td = widget.name
|
21
|
+
td = widget.widget_type.name
|
28
22
|
- if current_page?(refinery.url_for(action: 'page'))
|
29
|
-
|
23
|
+
td
|
24
|
+
= widget.pages.collect{|p| p.title }.to_sentence
|
30
25
|
- else
|
31
|
-
|
26
|
+
td
|
27
|
+
= widget.templates.collect{|p| p.name }.to_sentence
|
28
|
+
td
|
29
|
+
- if current_page?(refinery.url_for(action: 'page'))
|
30
|
+
= link_to_function('Select', "selectExistingWidgetForPage(#{widget.id})")
|
31
|
+
- else
|
32
|
+
= link_to_function('Select', "selectExistingWidgetForTemplate(#{widget.id})")
|
data/config/locales/en.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-llama_widgets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Bolt
|
@@ -114,6 +114,8 @@ files:
|
|
114
114
|
- app/views/refinery/admin/pages/_page_part.slim
|
115
115
|
- app/views/refinery/admin/pages/_widget_fields.slim
|
116
116
|
- app/views/refinery/admin/pages/_link_url.html.erb
|
117
|
+
- app/views/refinery/admin/pages/_template_changer.html.erb
|
118
|
+
- app/views/refinery/admin/pages/_form_actions.html.erb
|
117
119
|
- app/views/refinery/admin/_image_picker.html.erb
|
118
120
|
- app/views/refinery/admin/_nested_image_picker.html.erb
|
119
121
|
- app/controllers/refinery/widgets/admin/widget_types_controller.rb
|
@@ -156,6 +158,7 @@ files:
|
|
156
158
|
- db/migrate/4_create_widgets_content_block_widgets.rb
|
157
159
|
- db/migrate/6_add_locked_to_refinery_page_parts.rb
|
158
160
|
- db/migrate/3_create_widgets_widgets.rb
|
161
|
+
- db/migrate/7_add_reuse_to_refinery_widgets.rb
|
159
162
|
- db/migrate/5_add_template_id_to_refinery_pages.rb
|
160
163
|
- lib/tasks/refinery/widgets.rake
|
161
164
|
- lib/refinery/widgets/configuration.rb
|