locomotive_cms 2.0.0.rc9 → 2.0.0.rc10
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -5
- data/app/assets/javascripts/locomotive/inline_editor.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/models/custom_field_select_option.js.coffee +3 -0
- data/app/assets/javascripts/locomotive/models/site.js.coffee +2 -1
- data/app/assets/javascripts/locomotive/views/content_entries/_form_view.js.coffee +27 -0
- data/app/assets/javascripts/locomotive/views/content_entries/_popup_form_view.js.coffee +7 -1
- data/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee +4 -1
- data/app/assets/javascripts/locomotive/views/content_types/select_options_view.js.coffee +5 -1
- data/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee +0 -2
- data/app/assets/javascripts/locomotive/views/pages/edit_view.js.coffee +3 -0
- data/app/assets/javascripts/locomotive/views/shared/fields/select_view.js.coffee +83 -0
- data/app/assets/stylesheets/locomotive/backoffice/application.css.scss +13 -0
- data/app/assets/stylesheets/locomotive/backoffice/formtastic_changes.css.scss +25 -95
- data/app/assets/stylesheets/locomotive/inline_editor/toolbar.css.scss +1 -1
- data/app/assets/stylesheets/locomotive/shared/_helpers.css.scss +98 -0
- data/app/assets/stylesheets/locomotive/shared/common.css.scss +1 -1
- data/app/controllers/locomotive/current_site_controller.rb +6 -0
- data/app/helpers/locomotive/base_helper.rb +14 -0
- data/app/models/locomotive/content_entry.rb +42 -3
- data/app/models/locomotive/content_type.rb +6 -1
- data/app/models/locomotive/editable_element.rb +9 -0
- data/app/models/locomotive/editable_short_text.rb +9 -0
- data/app/models/locomotive/extensions/page/tree.rb +3 -4
- data/app/presenters/locomotive/content_entry_presenter.rb +4 -2
- data/app/views/locomotive/content_entries/_form.html.haml +2 -1
- data/app/views/locomotive/custom_fields/_form.html.haml +4 -18
- data/app/views/locomotive/custom_fields/_select_templates.html.haml +16 -0
- data/app/views/locomotive/custom_fields/types/_has_many.html.haml +3 -3
- data/app/views/locomotive/custom_fields/types/_select.html.haml +30 -1
- data/app/views/locomotive/notifications/new_content_entry.html.haml +3 -1
- data/app/views/locomotive/public/pages/show_toolbar.html.haml +4 -1
- data/config/locales/admin_ui.de.yml +3 -4
- data/config/locales/admin_ui.en.yml +1 -1
- data/config/locales/admin_ui.fr.yml +4 -4
- data/config/locales/admin_ui.nb.yml +0 -1
- data/config/locales/admin_ui.ru.yml +0 -1
- data/lib/locomotive/custom_fields.rb +12 -0
- data/lib/locomotive/liquid/drops/content_entry.rb +2 -2
- data/lib/locomotive/liquid/drops/content_types.rb +2 -0
- data/lib/locomotive/liquid/tags/editable/short_text.rb +4 -0
- data/lib/locomotive/liquid/tags/inline_editor.rb +14 -12
- data/lib/locomotive/middlewares/inline_editor.rb +20 -15
- data/lib/locomotive/render.rb +94 -40
- data/lib/locomotive/version.rb +1 -1
- data/vendor/assets/javascripts/locomotive/form_submit_notification.js +1 -1
- data/vendor/assets/javascripts/locomotive/toggle.js +9 -8
- data/vendor/assets/stylesheets/locomotive/liquid_mode.css +3 -5
- data/vendor/assets/stylesheets/locomotive/toggle.css.scss +33 -10
- metadata +13 -12
- data/app/assets/stylesheets/locomotive/backoffice/formtastic_changes.css.css +0 -0
data/Gemfile
CHANGED
@@ -12,6 +12,7 @@ group :development do
|
|
12
12
|
# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc' # Branch on Github
|
13
13
|
|
14
14
|
# gem 'locomotive-aloha-rails', :path => '../gems/aloha-rails' # for Developers
|
15
|
+
# gem 'locomotive_liquid', :path => '../gems/liquid' # for Developers
|
15
16
|
|
16
17
|
gem 'rspec-rails', '~> 2.8.0' # In order to have rspec tasks and generators
|
17
18
|
gem 'rspec-cells'
|
@@ -34,18 +35,18 @@ group :test do
|
|
34
35
|
|
35
36
|
# gem 'growl-glue'
|
36
37
|
|
37
|
-
gem 'cucumber-rails',
|
38
|
-
gem 'poltergeist'
|
39
|
-
gem 'rspec-rails',
|
38
|
+
gem 'cucumber-rails', :require => false
|
39
|
+
gem 'poltergeist', '~> 0.7.0'
|
40
|
+
gem 'rspec-rails', '~> 2.8.0'
|
40
41
|
gem 'shoulda-matchers'
|
41
42
|
|
42
43
|
gem 'factory_girl_rails', '~> 1.6.0'
|
43
44
|
gem 'pickle'
|
44
|
-
gem 'mocha',
|
45
|
+
gem 'mocha', '0.9.12' # :git => 'git://github.com/floehopper/mocha.git'
|
45
46
|
|
46
47
|
gem 'capybara'
|
47
48
|
|
48
|
-
gem 'xpath',
|
49
|
+
gem 'xpath', '~> 0.1.4'
|
49
50
|
|
50
51
|
gem 'json_spec'
|
51
52
|
|
@@ -13,7 +13,8 @@ class Locomotive.Models.Site extends Backbone.Model
|
|
13
13
|
|
14
14
|
@set domains: domains, memberships: memberships
|
15
15
|
|
16
|
-
includes_domain: (
|
16
|
+
includes_domain: (name_with_port) ->
|
17
|
+
name = name_with_port.replace(/:[0-9]*/, '')
|
17
18
|
name == @domain_with_domain() || _.any(@get('domains'), (domain) -> domain.get('name') == name)
|
18
19
|
|
19
20
|
domain_with_domain: ->
|
@@ -6,6 +6,8 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|
6
6
|
|
7
7
|
el: '#content'
|
8
8
|
|
9
|
+
_select_field_view: null
|
10
|
+
|
9
11
|
_file_field_views: []
|
10
12
|
|
11
13
|
_has_many_field_views: []
|
@@ -16,6 +18,8 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|
16
18
|
'submit': 'save'
|
17
19
|
|
18
20
|
initialize: ->
|
21
|
+
@content_type ||= new Locomotive.Models.ContentType(@options.content_type)
|
22
|
+
|
19
23
|
@model ||= new Locomotive.Models.ContentEntry(@options.content_entry)
|
20
24
|
|
21
25
|
Backbone.ModelBinding.bind @
|
@@ -29,6 +33,8 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|
29
33
|
|
30
34
|
@enable_richtexteditor()
|
31
35
|
|
36
|
+
@enable_select_fields()
|
37
|
+
|
32
38
|
@enable_file_fields()
|
33
39
|
|
34
40
|
@enable_has_many_fields()
|
@@ -60,6 +66,26 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|
60
66
|
|
61
67
|
$(textarea).tinymce(settings)
|
62
68
|
|
69
|
+
enable_select_fields: ->
|
70
|
+
@_select_field_view = new Locomotive.Views.Shared.Fields.SelectView model: @content_type
|
71
|
+
|
72
|
+
_.each @model.get('select_custom_fields'), (name) =>
|
73
|
+
$input_wrapper = @$("##{@model.paramRoot}_#{name}_id_input")
|
74
|
+
|
75
|
+
$input_wrapper.append(ich.edit_select_options_button())
|
76
|
+
|
77
|
+
$input_wrapper.find('a.edit-options-button').bind 'click', (event) =>
|
78
|
+
event.stopPropagation() & event.preventDefault()
|
79
|
+
|
80
|
+
@_select_field_view.render_for name, (options) =>
|
81
|
+
# refresh the options of the select box
|
82
|
+
$select = $input_wrapper.find('select')
|
83
|
+
$select.find('option[value!=""]').remove()
|
84
|
+
|
85
|
+
_.each options, (option) =>
|
86
|
+
unless option.destroyed()
|
87
|
+
$select.append(new Option(option.get('name'), option.get('id'), false, option.get('id') == @model.get("#{name}_id")))
|
88
|
+
|
63
89
|
enable_file_fields: ->
|
64
90
|
_.each @model.get('file_custom_fields'), (name) =>
|
65
91
|
view = new Locomotive.Views.Shared.Fields.FileView model: @model, name: name
|
@@ -107,6 +133,7 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|
107
133
|
@$('li.input.toggle input[type=checkbox]').checkToggle('sync')
|
108
134
|
|
109
135
|
remove: ->
|
136
|
+
@_select_field_view.remove()
|
110
137
|
_.each @_file_field_views, (view) => view.remove()
|
111
138
|
_.each @_has_many_field_views, (view) => view.remove()
|
112
139
|
_.each @_many_to_many_field_views, (view) => view.remove()
|
@@ -34,7 +34,13 @@ class Locomotive.Views.ContentEntries.PopupFormView extends Locomotive.Views.Con
|
|
34
34
|
actions = @$('.dialog-actions').appendTo($(@el).parent()).addClass('ui-dialog-buttonpane ui-widget-content ui-helper-clearfix')
|
35
35
|
|
36
36
|
actions.find('#close-link').click (event) => @close(event)
|
37
|
-
actions.find('input[type=submit]').click (event) =>
|
37
|
+
actions.find('input[type=submit]').click (event) =>
|
38
|
+
# since the submit buttons are outside the form, we have to mimic the behaviour of a basic form
|
39
|
+
$form = @el.find('form'); $buttons_pane = $(event.target).parent()
|
40
|
+
|
41
|
+
$.rails.disableFormElements($buttons_pane)
|
42
|
+
|
43
|
+
$form.trigger('submit').bind 'ajax:complete', => $.rails.enableFormElements($buttons_pane)
|
38
44
|
|
39
45
|
open: (event, ui, extra) =>
|
40
46
|
$(@el).dialog('overlayEl').bind 'click', => @close()
|
@@ -45,9 +45,12 @@ class Locomotive.Views.ContentTypes.FormView extends Locomotive.Views.Shared.For
|
|
45
45
|
lineNumbers: false
|
46
46
|
passDelay: 50
|
47
47
|
tabMode: 'shift'
|
48
|
-
theme: 'default
|
48
|
+
theme: 'default'
|
49
49
|
onChange: (editor) => @model.set(raw_item_template: editor.getValue())
|
50
50
|
|
51
|
+
after_inputs_fold: ->
|
52
|
+
@editor.refresh()
|
53
|
+
|
51
54
|
enable_public_submission_checkbox: ->
|
52
55
|
@_enable_checkbox 'public_submission_enabled',
|
53
56
|
on_callback: => @$('#content_type_public_submission_accounts_input').show()
|
@@ -10,6 +10,7 @@ class Locomotive.Views.ContentTypes.SelectOptionsView extends Backbone.View
|
|
10
10
|
'click a.add': 'add_entry'
|
11
11
|
'click span.name': 'edit_entry'
|
12
12
|
'click a.remove': 'remove_entry'
|
13
|
+
'click a.drag': 'do_nothing'
|
13
14
|
|
14
15
|
initialize: ->
|
15
16
|
_.bindAll(@, 'refresh_position_entries', '_insert_entry')
|
@@ -41,6 +42,9 @@ class Locomotive.Views.ContentTypes.SelectOptionsView extends Backbone.View
|
|
41
42
|
select_option = @collection.getByCid($(view_dom).attr('data-cid'))
|
42
43
|
select_option.set position: index
|
43
44
|
|
45
|
+
do_nothing: (event) ->
|
46
|
+
event.stopPropagation() & event.preventDefault()
|
47
|
+
|
44
48
|
add_entry: (event) ->
|
45
49
|
event.stopPropagation() & event.preventDefault()
|
46
50
|
|
@@ -67,7 +71,7 @@ class Locomotive.Views.ContentTypes.SelectOptionsView extends Backbone.View
|
|
67
71
|
view_dom = link.closest('li')
|
68
72
|
select_option = @collection.getByCid(view_dom.attr('data-cid'))
|
69
73
|
|
70
|
-
if confirm(link.attr('
|
74
|
+
if confirm(link.attr('data-confirm'))
|
71
75
|
if select_option.isNew()
|
72
76
|
@collection.remove(select_option)
|
73
77
|
else
|
@@ -20,8 +20,6 @@ class Locomotive.Views.InlineEditor.ToolbarView extends Backbone.View
|
|
20
20
|
@
|
21
21
|
|
22
22
|
notify: (aloha_editable) ->
|
23
|
-
window.bar = aloha_editable
|
24
|
-
|
25
23
|
element_id = aloha_editable.obj.attr('data-element-id')
|
26
24
|
@model.get('editable_elements').get(element_id).set
|
27
25
|
content: aloha_editable.getContents()
|
@@ -20,6 +20,9 @@ class Locomotive.Views.Pages.EditView extends Locomotive.Views.Pages.FormView
|
|
20
20
|
else
|
21
21
|
@refresh_editable_elements()
|
22
22
|
|
23
|
+
# refresh the show link
|
24
|
+
@$('#local-actions-bar > a.show').attr('href', "/#{@model.get('fullpath')}")
|
25
|
+
|
23
26
|
error: (model, xhr) =>
|
24
27
|
form.trigger('ajax:complete')
|
25
28
|
|
@@ -0,0 +1,83 @@
|
|
1
|
+
Locomotive.Views.Shared ||= {}
|
2
|
+
Locomotive.Views.Shared.Fields ||= {}
|
3
|
+
|
4
|
+
class Locomotive.Views.Shared.Fields.SelectView extends Backbone.View
|
5
|
+
|
6
|
+
el: '#edit-select-option-entries'
|
7
|
+
|
8
|
+
select_options_view: null
|
9
|
+
|
10
|
+
initialize: ->
|
11
|
+
_.bindAll(@, 'save', 'on_save')
|
12
|
+
|
13
|
+
@create_dialog()
|
14
|
+
|
15
|
+
super()
|
16
|
+
|
17
|
+
render: ->
|
18
|
+
@render_select_options_view()
|
19
|
+
|
20
|
+
@open()
|
21
|
+
|
22
|
+
render_for: (name, callback) ->
|
23
|
+
@name = name; @on_save_callback = callback
|
24
|
+
|
25
|
+
@custom_field = @model.get('entries_custom_fields').find((field) => field.get('name') == @name)
|
26
|
+
|
27
|
+
@render()
|
28
|
+
|
29
|
+
create_dialog: ->
|
30
|
+
@dialog = $(@el).dialog
|
31
|
+
autoOpen: false
|
32
|
+
modal: true
|
33
|
+
zIndex: window.application_view.unique_dialog_zindex()
|
34
|
+
width: 770,
|
35
|
+
create: (event, ui) =>
|
36
|
+
$(@el).prev().find('.ui-dialog-title').html(@$('h2').html())
|
37
|
+
@$('h2').remove()
|
38
|
+
|
39
|
+
@$form = @$('.placeholder').formSubmitNotification() # fake form
|
40
|
+
@$buttons_pane = @$('.dialog-actions').appendTo($(@el).parent()).addClass('ui-dialog-buttonpane ui-widget-content ui-helper-clearfix')
|
41
|
+
|
42
|
+
@$buttons_pane.find('#close-link').click (event) => @close(event)
|
43
|
+
@$buttons_pane.find('input[type=submit]').click @save
|
44
|
+
|
45
|
+
open: (event, ui, extra) =>
|
46
|
+
$(@el).dialog('overlayEl').bind 'click', => @close()
|
47
|
+
# nothing to do
|
48
|
+
|
49
|
+
save: (event) ->
|
50
|
+
event.stopPropagation() & event.preventDefault()
|
51
|
+
|
52
|
+
@$form.trigger 'ajax:beforeSend'
|
53
|
+
$.rails.disableFormElements(@$buttons_pane)
|
54
|
+
|
55
|
+
@model.save {}, success: @on_save, error: @on_save
|
56
|
+
|
57
|
+
on_save: (model, response, xhr) =>
|
58
|
+
$.rails.enableFormElements(@$buttons_pane)
|
59
|
+
model._normalize()
|
60
|
+
@$form.trigger('ajax:complete')
|
61
|
+
@on_save_callback(@custom_field.get('select_options').sortBy((option) -> option.get('position'))) if @on_save_callback?
|
62
|
+
@close()
|
63
|
+
|
64
|
+
render_select_options_view: ->
|
65
|
+
@select_options_view.remove() if @select_options_view?
|
66
|
+
|
67
|
+
@select_options_view = new Locomotive.Views.ContentTypes.SelectOptionsView
|
68
|
+
model: @custom_field
|
69
|
+
collection: @custom_field.get('select_options')
|
70
|
+
|
71
|
+
@$('.placeholder').append(@select_options_view.render().el)
|
72
|
+
|
73
|
+
open: ->
|
74
|
+
$(@el).dialog('open')
|
75
|
+
|
76
|
+
close: (event) ->
|
77
|
+
event.stopPropagation() & event.preventDefault() if event?
|
78
|
+
$(@el).dialog('overlayEl').unbind('click')
|
79
|
+
$(@el).dialog('close')
|
80
|
+
|
81
|
+
center: ->
|
82
|
+
$(@el).dialog('option', 'position', 'center')
|
83
|
+
|
@@ -328,3 +328,16 @@ p span.code {
|
|
328
328
|
color: #8B8D9A;
|
329
329
|
@include single-text-shadow(#fff, 0px, 0px, 1px);
|
330
330
|
}
|
331
|
+
|
332
|
+
/* ___ dialog box to edit select options ___ */
|
333
|
+
|
334
|
+
#edit-select-option-entries {
|
335
|
+
.placeholder {
|
336
|
+
@include tiny-buttons-group;
|
337
|
+
@include select-options-edit-style;
|
338
|
+
|
339
|
+
.list {
|
340
|
+
height: auto;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
}
|
@@ -121,56 +121,7 @@ form.formtastic {
|
|
121
121
|
top: 0px;
|
122
122
|
right: 10px;
|
123
123
|
|
124
|
-
|
125
|
-
@include gray-button;
|
126
|
-
|
127
|
-
padding-left: 10px;
|
128
|
-
}
|
129
|
-
|
130
|
-
a.edit, a.remove, a.toggle, a.drag {
|
131
|
-
display: inline-block;
|
132
|
-
width: 16px;
|
133
|
-
height: 16px;
|
134
|
-
|
135
|
-
position: relative;
|
136
|
-
top: 4px;
|
137
|
-
|
138
|
-
outline: none;
|
139
|
-
text-indent: -9999px;
|
140
|
-
|
141
|
-
&.edit {
|
142
|
-
background: transparent image-url("locomotive/list/icons/pencil_off.png") repeat 0 0;
|
143
|
-
&:hover {
|
144
|
-
background-image: image-url("locomotive/list/icons/pencil.png");
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
&.remove {
|
149
|
-
background: transparent image-url("locomotive/list/icons/trash_off.png") repeat 0 0;
|
150
|
-
&:hover {
|
151
|
-
background-image: image-url("locomotive/list/icons/trash.png");
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
&.toggle {
|
156
|
-
background: transparent image-url("locomotive/list/icons/toggle_off.png") repeat 0 0;
|
157
|
-
&:hover {
|
158
|
-
background-image: image-url("locomotive/list/icons/toggle.png");
|
159
|
-
}
|
160
|
-
&.open {
|
161
|
-
@include rotate(180deg);
|
162
|
-
}
|
163
|
-
@include single-transition(transform, 0.5s);
|
164
|
-
}
|
165
|
-
|
166
|
-
&.drag {
|
167
|
-
cursor: move;
|
168
|
-
background: transparent image-url("locomotive/list/icons/move_off.png") repeat 0 0;
|
169
|
-
&:hover {
|
170
|
-
background-image: image-url("locomotive/list/icons/move.png");
|
171
|
-
}
|
172
|
-
}
|
173
|
-
}
|
124
|
+
@include tiny-buttons-group;
|
174
125
|
}
|
175
126
|
|
176
127
|
&:last-child {
|
@@ -306,6 +257,14 @@ form.formtastic {
|
|
306
257
|
|
307
258
|
} // li.text
|
308
259
|
|
260
|
+
&.select {
|
261
|
+
@include locomotive-link;
|
262
|
+
|
263
|
+
a.edit-options-button {
|
264
|
+
margin-left: 10px;
|
265
|
+
}
|
266
|
+
} // li.select_with_edit
|
267
|
+
|
309
268
|
&.locale, &.locales {
|
310
269
|
.list {
|
311
270
|
margin-left: 150px;
|
@@ -528,46 +487,7 @@ form.formtastic {
|
|
528
487
|
} // li.no-label
|
529
488
|
|
530
489
|
&.select-options {
|
531
|
-
|
532
|
-
line-height: auto;
|
533
|
-
|
534
|
-
ul, li, > span.actions {
|
535
|
-
float: left;
|
536
|
-
}
|
537
|
-
|
538
|
-
ul {
|
539
|
-
width: 558px;
|
540
|
-
min-height: 34px;
|
541
|
-
|
542
|
-
li.entry {
|
543
|
-
background: #c2e0f0;
|
544
|
-
@include border-radius(2px);
|
545
|
-
|
546
|
-
padding: 0 55px 0 8px;
|
547
|
-
margin: 2px 10px 8px 0;
|
548
|
-
height: auto;
|
549
|
-
|
550
|
-
color: #29739b;
|
551
|
-
line-height: 24px;
|
552
|
-
|
553
|
-
span.name {
|
554
|
-
cursor: pointer;
|
555
|
-
@include text-shadow(#fff 0px 1px 1px);
|
556
|
-
}
|
557
|
-
|
558
|
-
span.actions {
|
559
|
-
line-height: 20px;
|
560
|
-
right: 8px;
|
561
|
-
}
|
562
|
-
}
|
563
|
-
} // .list ul
|
564
|
-
|
565
|
-
> span.actions {
|
566
|
-
position: static;
|
567
|
-
margin-left: 15px;
|
568
|
-
line-height: 24px;
|
569
|
-
} // .list .actions
|
570
|
-
}
|
490
|
+
@include select-options-edit-style;
|
571
491
|
} // li.select-options
|
572
492
|
|
573
493
|
&.relationship {
|
@@ -700,17 +620,15 @@ form.formtastic {
|
|
700
620
|
}
|
701
621
|
|
702
622
|
.required-input {
|
703
|
-
|
704
|
-
|
705
|
-
width: auto;
|
706
|
-
|
623
|
+
span {
|
624
|
+
color: #585A69;
|
707
625
|
font-weight: normal;
|
708
626
|
}
|
709
627
|
|
710
628
|
.toggleSwitch {
|
711
629
|
display: inline-block;
|
712
630
|
position: relative;
|
713
|
-
top:
|
631
|
+
top: 5px;
|
714
632
|
|
715
633
|
margin-left: 5px;
|
716
634
|
}
|
@@ -766,6 +684,18 @@ form.formtastic {
|
|
766
684
|
}
|
767
685
|
} // li.string, li.password
|
768
686
|
|
687
|
+
&.toggle {
|
688
|
+
label {
|
689
|
+
width: 174px;
|
690
|
+
padding-top: 0px;
|
691
|
+
line-height: 24px;
|
692
|
+
}
|
693
|
+
|
694
|
+
.toggleSwitch {
|
695
|
+
top: 3px;
|
696
|
+
}
|
697
|
+
} // li.toggle
|
698
|
+
|
769
699
|
p.inline-hints {
|
770
700
|
margin-left: 174px;
|
771
701
|
}
|