alchemy_cms 6.0.0.b1 → 6.0.0.pre.b5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/README.md +14 -2
- data/Rakefile +37 -23
- data/alchemy_cms.gemspec +1 -1
- data/app/assets/stylesheets/alchemy/_extends.scss +15 -2
- data/app/assets/stylesheets/alchemy/archive.scss +16 -1
- data/app/assets/stylesheets/alchemy/fonts.scss +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.svg +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.ttf +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce-small.woff +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.svg +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.ttf +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/fonts/tinymce.woff +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/img/anchor.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/img/loader.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/img/object.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/img/trans.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/alchemy/skin.min.css.scss +0 -0
- data/app/controllers/alchemy/admin/attachments_controller.rb +3 -3
- data/app/controllers/alchemy/admin/elements_controller.rb +1 -0
- data/app/controllers/alchemy/admin/pages_controller.rb +1 -9
- data/app/controllers/alchemy/admin/pictures_controller.rb +21 -8
- data/app/controllers/alchemy/admin/resources_controller.rb +84 -10
- data/app/controllers/alchemy/api/elements_controller.rb +12 -8
- data/app/controllers/alchemy/api/pages_controller.rb +4 -2
- data/app/decorators/alchemy/element_editor.rb +7 -4
- data/app/decorators/alchemy/ingredient_editor.rb +5 -1
- data/app/helpers/alchemy/elements_block_helper.rb +14 -6
- data/app/models/alchemy/attachment.rb +24 -7
- data/app/models/alchemy/element/element_essences.rb +14 -3
- data/app/models/alchemy/element/element_ingredients.rb +11 -3
- data/app/models/alchemy/element/presenters.rb +18 -1
- data/app/models/alchemy/element.rb +0 -14
- data/app/models/alchemy/ingredient.rb +21 -62
- data/app/models/alchemy/page/page_natures.rb +1 -10
- data/app/models/alchemy/page/page_scopes.rb +4 -0
- data/app/models/alchemy/page.rb +13 -4
- data/app/models/alchemy/page_version.rb +1 -1
- data/app/models/alchemy/picture.rb +14 -38
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +1 -1
- data/app/views/alchemy/admin/attachments/index.html.erb +2 -3
- data/app/views/alchemy/admin/elements/create.js.erb +1 -1
- data/app/views/alchemy/admin/elements/destroy.js.erb +1 -3
- data/app/views/alchemy/admin/elements/fold.js.erb +2 -2
- data/app/views/alchemy/admin/elements/update.js.erb +1 -1
- data/app/views/alchemy/admin/pages/_toolbar.html.erb +1 -1
- data/app/views/alchemy/admin/pages/edit.html.erb +1 -1
- data/app/views/alchemy/admin/pages/index.html.erb +2 -9
- data/app/views/alchemy/admin/partials/_search_form.html.erb +9 -0
- data/app/views/alchemy/admin/pictures/_archive.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +4 -2
- data/app/views/alchemy/admin/pictures/index.html.erb +8 -3
- data/app/views/alchemy/admin/resources/_filter.html.erb +12 -0
- data/app/views/alchemy/admin/resources/_filter_bar.html.erb +14 -17
- data/app/views/alchemy/admin/resources/_form.html.erb +2 -0
- data/app/views/alchemy/admin/resources/_table_header.html.erb +15 -0
- data/app/views/alchemy/admin/resources/index.html.erb +3 -11
- data/app/views/alchemy/ingredients/_boolean_editor.html.erb +1 -1
- data/app/views/alchemy/ingredients/_file_editor.html.erb +3 -1
- data/app/views/alchemy/ingredients/_headline_editor.html.erb +1 -1
- data/app/views/alchemy/ingredients/_html_editor.html.erb +1 -1
- data/app/views/alchemy/ingredients/_link_editor.html.erb +8 -8
- data/app/views/alchemy/ingredients/_node_editor.html.erb +1 -0
- data/app/views/alchemy/ingredients/_page_editor.html.erb +1 -0
- data/app/views/alchemy/ingredients/_picture_editor.html.erb +7 -6
- data/app/views/alchemy/ingredients/_select_editor.html.erb +1 -0
- data/app/views/alchemy/ingredients/_text_editor.html.erb +5 -4
- data/config/locales/alchemy.en.yml +85 -49
- data/lib/alchemy/forms/builder.rb +21 -1
- data/lib/alchemy/resource_filter.rb +40 -0
- data/lib/alchemy/resources_helper.rb +1 -16
- data/lib/alchemy/test_support/shared_ingredient_examples.rb +21 -4
- data/lib/alchemy/tinymce.rb +4 -0
- data/lib/alchemy/upgrader/tasks/ingredients_migrator.rb +18 -7
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +1 -0
- data/lib/generators/alchemy/menus/templates/node.html.erb +1 -1
- data/lib/generators/alchemy/menus/templates/node.html.haml +1 -1
- data/lib/generators/alchemy/menus/templates/node.html.slim +1 -1
- data/lib/generators/alchemy/menus/templates/wrapper.html.erb +1 -1
- data/lib/generators/alchemy/menus/templates/wrapper.html.haml +1 -1
- data/lib/generators/alchemy/menus/templates/wrapper.html.slim +1 -1
- data/package.json +1 -1
- metadata +7 -7
- data/app/views/alchemy/admin/attachments/_filter_bar.html.erb +0 -29
- data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +0 -30
@@ -21,10 +21,7 @@
|
|
21
21
|
dialog: false,
|
22
22
|
if_permitted_to: [:index, resource_model]
|
23
23
|
) %>
|
24
|
-
<%= render 'alchemy/admin/partials/search_form'
|
25
|
-
resource_has_filters ? :filter : nil,
|
26
|
-
resource_has_tags ? :tagged_with : nil
|
27
|
-
].compact %>
|
24
|
+
<%= render 'alchemy/admin/partials/search_form' %>
|
28
25
|
<% end %>
|
29
26
|
|
30
27
|
<div id="archive_all" class="resources-table-wrapper<%= ' with_tag_filter' if resource_has_tags || resource_has_filters %>">
|
@@ -33,13 +30,8 @@
|
|
33
30
|
|
34
31
|
<% if resource_has_tags || resource_has_filters %>
|
35
32
|
<div id="library_sidebar">
|
36
|
-
|
37
|
-
|
38
|
-
<% end %>
|
39
|
-
|
40
|
-
<% if resource_has_tags %>
|
41
|
-
<%= render 'tag_list' %>
|
42
|
-
<% end %>
|
33
|
+
<%= render 'filter_bar' if resource_has_filters %>
|
34
|
+
<%= render 'tag_list' if resource_has_tags %>
|
43
35
|
</div>
|
44
36
|
<% end %>
|
45
37
|
</div>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
data: boolean_editor.data_attributes do %>
|
4
4
|
<%= element_form.fields_for(:ingredients, boolean_editor.ingredient) do |f| %>
|
5
5
|
<%= f.label :value, style: "display: inline-block" do %>
|
6
|
-
<%= f.check_box :value %>
|
6
|
+
<%= f.check_box :value, id: nil %>
|
7
7
|
<%= render_ingredient_role(boolean_editor) %>
|
8
8
|
<% end %>
|
9
9
|
<%= render_hint_for(boolean_editor) %>
|
@@ -44,7 +44,9 @@
|
|
44
44
|
},
|
45
45
|
title: Alchemy.t(:edit_file_properties) %>
|
46
46
|
</div>
|
47
|
-
<%= f.hidden_field :attachment_id,
|
47
|
+
<%= f.hidden_field :attachment_id,
|
48
|
+
value: file_editor.attachment&.id,
|
49
|
+
id: file_editor.form_field_id(:attachment_id) %>
|
48
50
|
</div>
|
49
51
|
<% end %>
|
50
52
|
<% end %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
data: headline_editor.data_attributes do %>
|
4
4
|
<%= element_form.fields_for(:ingredients, headline_editor.ingredient) do |f| %>
|
5
5
|
<%= ingredient_label(headline_editor) %>
|
6
|
-
<%= f.text_field :value %>
|
6
|
+
<%= f.text_field :value, id: nil %>
|
7
7
|
|
8
8
|
<div class="input-row">
|
9
9
|
<% if headline_editor.level_options.length > 1 %>
|
@@ -4,15 +4,15 @@
|
|
4
4
|
<%= element_form.fields_for(:ingredients, link_editor.ingredient) do |f| %>
|
5
5
|
<%= ingredient_label(link_editor) %>
|
6
6
|
<%= f.text_field :value,
|
7
|
-
class: "thin_border text_with_icon
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
class: "thin_border text_with_icon readonly",
|
8
|
+
id: link_editor.form_field_id,
|
9
|
+
"data-link-value": true,
|
10
|
+
readonly: true,
|
11
|
+
tabindex: -1
|
11
12
|
%>
|
12
|
-
<%= f.hidden_field :
|
13
|
-
<%= f.hidden_field :
|
14
|
-
<%= f.hidden_field :
|
15
|
-
<%= f.hidden_field :link_target, "data-link-target": true %>
|
13
|
+
<%= f.hidden_field :link_title, "data-link-title": true, id: nil %>
|
14
|
+
<%= f.hidden_field :link_class_name, "data-link-class": true, id: nil %>
|
15
|
+
<%= f.hidden_field :link_target, "data-link-target": true, id: nil %>
|
16
16
|
<% end %>
|
17
17
|
<%= render "alchemy/ingredients/shared/link_tools", ingredient_editor: link_editor %>
|
18
18
|
<% end %>
|
@@ -44,16 +44,17 @@
|
|
44
44
|
</div>
|
45
45
|
<% end %>
|
46
46
|
<%= f.hidden_field :picture_id, value: picture_editor.picture&.id,
|
47
|
+
id: picture_editor.form_field_id(:picture_id),
|
47
48
|
data: {
|
48
49
|
picture_id: true,
|
49
50
|
image_file_width: picture_editor.image_file_width,
|
50
51
|
image_file_height: picture_editor.image_file_height
|
51
52
|
} %>
|
52
|
-
<%= f.hidden_field :link, data: { link_value: true } %>
|
53
|
-
<%= f.hidden_field :link_title, data: { link_title: true } %>
|
54
|
-
<%= f.hidden_field :link_class_name, data: { link_class: true } %>
|
55
|
-
<%= f.hidden_field :link_target, data: { link_target: true } %>
|
56
|
-
<%= f.hidden_field :crop_from, data: { crop_from: true } %>
|
57
|
-
<%= f.hidden_field :crop_size, data: { crop_size: true } %>
|
53
|
+
<%= f.hidden_field :link, data: { link_value: true }, id: nil %>
|
54
|
+
<%= f.hidden_field :link_title, data: { link_title: true }, id: nil %>
|
55
|
+
<%= f.hidden_field :link_class_name, data: { link_class: true }, id: nil %>
|
56
|
+
<%= f.hidden_field :link_target, data: { link_target: true }, id: nil %>
|
57
|
+
<%= f.hidden_field :crop_from, data: { crop_from: true }, id: nil %>
|
58
|
+
<%= f.hidden_field :crop_size, data: { crop_size: true }, id: nil %>
|
58
59
|
<% end %>
|
59
60
|
<% end %>
|
@@ -7,12 +7,13 @@
|
|
7
7
|
<%= ingredient_label(text_editor) %>
|
8
8
|
<%= f.text_field :value,
|
9
9
|
class: text_editor.settings[:linkable] ? "text_with_icon" : "",
|
10
|
+
id: nil,
|
10
11
|
type: text_editor.settings[:input_type] || "text" %>
|
11
12
|
<% if text_editor.settings[:linkable] %>
|
12
|
-
<%= f.hidden_field :link, "data-link-value": true %>
|
13
|
-
<%= f.hidden_field :link_title, "data-link-title": true %>
|
14
|
-
<%= f.hidden_field :link_class_name, "data-link-class": true%>
|
15
|
-
<%= f.hidden_field :link_target, "data-link-target": true %>
|
13
|
+
<%= f.hidden_field :link, "data-link-value": true, id: nil %>
|
14
|
+
<%= f.hidden_field :link_title, "data-link-title": true, id: nil %>
|
15
|
+
<%= f.hidden_field :link_class_name, "data-link-class": true, id: nil %>
|
16
|
+
<%= f.hidden_field :link_target, "data-link-target": true, id: nil %>
|
16
17
|
<%= render "alchemy/ingredients/shared/link_tools", ingredient_editor: text_editor %>
|
17
18
|
<% end %>
|
18
19
|
<% end %>
|
@@ -57,6 +57,90 @@ en:
|
|
57
57
|
main_menu: Main Menu
|
58
58
|
footer_menu: Footer Menu
|
59
59
|
|
60
|
+
# == Mime Types translations
|
61
|
+
# These are human readable mime types used for the document-type row in archive files.
|
62
|
+
#
|
63
|
+
mime_types: &mime_types
|
64
|
+
application/msexcel: Excel Spreadsheet
|
65
|
+
application/mspowerpoint: PowerPoint Presentation
|
66
|
+
application/msword: Word Document
|
67
|
+
application/pdf: PDF Document
|
68
|
+
application/rtf: RTF Document
|
69
|
+
application/vcard: vCard
|
70
|
+
application/vnd:
|
71
|
+
ms-excel: Excel Spreadsheet
|
72
|
+
ms-powerpoint: PowerPoint Presentation
|
73
|
+
ms-word: Word Document
|
74
|
+
openxmlformats-officedocument:
|
75
|
+
presentationml:
|
76
|
+
presentation: PowerPoint 2007 Presentation
|
77
|
+
spreadsheetml:
|
78
|
+
sheet: Excel 2007 Spreadsheet
|
79
|
+
wordprocessingml:
|
80
|
+
document: Word 2007 Document
|
81
|
+
application/x-flash-video: Flash Video
|
82
|
+
application/x-rar: RAR Archive
|
83
|
+
application/x-shockwave-flash: Flash Movie
|
84
|
+
application/zip: ZIP Archive
|
85
|
+
audio/mp4: MPEG-4 Audio
|
86
|
+
audio/mpeg: MP3 Audio
|
87
|
+
audio/wav: WAV Audio
|
88
|
+
audio/x-wav: WAV Audio
|
89
|
+
image/gif: GIF Image
|
90
|
+
image/jpeg: JPG Image
|
91
|
+
image/png: PNG Image
|
92
|
+
image/tiff: TIFF Image
|
93
|
+
image/x-psd: Photoshop File
|
94
|
+
image/svg+xml: SVG Image
|
95
|
+
text/plain: Plain Text Document
|
96
|
+
text/x-vcard: vCard
|
97
|
+
video/mp4: MPEG-4 Video
|
98
|
+
video/mpeg: MPEG Video
|
99
|
+
video/quicktime: Quicktime Video
|
100
|
+
video/x-flv: Flash Video
|
101
|
+
video/x-ms-wmv: Windows Media Video
|
102
|
+
video/x-msvideo: AVI Video
|
103
|
+
|
104
|
+
# === Translations for filter names and values
|
105
|
+
# Used in the right filter column in case the model has `alchemy_resource_filters` defined.
|
106
|
+
#
|
107
|
+
filters:
|
108
|
+
page:
|
109
|
+
by_page_layout:
|
110
|
+
name: Page Type
|
111
|
+
status:
|
112
|
+
name: Status
|
113
|
+
values:
|
114
|
+
not_public: Unpublished
|
115
|
+
published: Published
|
116
|
+
restricted: Restricted
|
117
|
+
picture:
|
118
|
+
by_file_format:
|
119
|
+
name: File Type
|
120
|
+
values:
|
121
|
+
gif: GIF Image
|
122
|
+
jpeg: JPG Image
|
123
|
+
png: PNG Image
|
124
|
+
tiff: TIFF Image
|
125
|
+
misc:
|
126
|
+
name: Miscellaneous
|
127
|
+
values:
|
128
|
+
last_upload: Last upload only
|
129
|
+
recent: Recently uploaded only
|
130
|
+
without_tag: Without tag
|
131
|
+
attachment:
|
132
|
+
by_file_type:
|
133
|
+
name: File Type
|
134
|
+
values:
|
135
|
+
<<: *mime_types
|
136
|
+
misc:
|
137
|
+
name: Miscellaneous
|
138
|
+
values:
|
139
|
+
last_upload: Last upload only
|
140
|
+
recent: Recently uploaded only
|
141
|
+
without_tag: Without tag
|
142
|
+
deletable: Not linked by file content
|
143
|
+
|
60
144
|
# === Translations for content validations
|
61
145
|
# Used when a user did not enter (correct) values to the content field.
|
62
146
|
#
|
@@ -132,49 +216,6 @@ en:
|
|
132
216
|
editor: "Editor"
|
133
217
|
admin: "Administrator"
|
134
218
|
|
135
|
-
# == Mime Types translations
|
136
|
-
# These are human readable mime types used for the document-type row in archive files.
|
137
|
-
mime_types:
|
138
|
-
application/msexcel: Excel Spreadsheet
|
139
|
-
application/mspowerpoint: PowerPoint Presentation
|
140
|
-
application/msword: Word Document
|
141
|
-
application/pdf: PDF Document
|
142
|
-
application/rtf: RTF Document
|
143
|
-
application/vcard: vCard
|
144
|
-
application/vnd:
|
145
|
-
ms-excel: Excel Spreadsheet
|
146
|
-
ms-powerpoint: PowerPoint Presentation
|
147
|
-
ms-word: Word Document
|
148
|
-
openxmlformats-officedocument:
|
149
|
-
presentationml:
|
150
|
-
presentation: PowerPoint 2007 Presentation
|
151
|
-
spreadsheetml:
|
152
|
-
sheet: Excel 2007 Spreadsheet
|
153
|
-
wordprocessingml:
|
154
|
-
document: Word 2007 Document
|
155
|
-
application/x-flash-video: Flash Video
|
156
|
-
application/x-rar: RAR Archive
|
157
|
-
application/x-shockwave-flash: Flash Movie
|
158
|
-
application/zip: ZIP Archive
|
159
|
-
audio/mp4: MPEG-4 Audio
|
160
|
-
audio/mpeg: MP3 Audio
|
161
|
-
audio/wav: WAV Audio
|
162
|
-
audio/x-wav: WAV Audio
|
163
|
-
image/gif: GIF Image
|
164
|
-
image/jpeg: JPG Image
|
165
|
-
image/png: PNG Image
|
166
|
-
image/tiff: TIFF Image
|
167
|
-
image/x-psd: Photoshop File
|
168
|
-
image/svg+xml: SVG Image
|
169
|
-
text/plain: Plain Text Document
|
170
|
-
text/x-vcard: vCard
|
171
|
-
video/mp4: MPEG-4 Video
|
172
|
-
video/mpeg: MPEG Video
|
173
|
-
video/quicktime: Quicktime Video
|
174
|
-
video/x-flv: Flash Video
|
175
|
-
video/x-ms-wmv: Windows Media Video
|
176
|
-
video/x-msvideo: AVI Video
|
177
|
-
|
178
219
|
link_target_options:
|
179
220
|
default: Same Window
|
180
221
|
blank: New Window/Tab
|
@@ -403,6 +444,7 @@ en:
|
|
403
444
|
female: "Female"
|
404
445
|
file: "File"
|
405
446
|
file_rename_error: "Error renaming file."
|
447
|
+
filtered_by: "Filtered by"
|
406
448
|
from_at: "from %{by} at %{at}"
|
407
449
|
height: "Height"
|
408
450
|
help:
|
@@ -435,7 +477,6 @@ en:
|
|
435
477
|
javascript_disabled_text: "Alchemy needs Javascript to run smoothly. Please enable it in your browser settings."
|
436
478
|
language_code_placeholder: 'i.e. en'
|
437
479
|
language_pages_copied: "Language tree successfully copied."
|
438
|
-
last_upload_only: "Last upload only"
|
439
480
|
left: "left"
|
440
481
|
legacy_url_info_text: "A link is a redirect from an old URL to the current URL of this page. This redirect happens with a <a href='https://support.google.com/webmasters/answer/93633' target='_blank'>301 status code</a>."
|
441
482
|
link_image: "Link this image."
|
@@ -519,11 +560,6 @@ en:
|
|
519
560
|
comma_seperated: "Separate by comma"
|
520
561
|
password: "Password"
|
521
562
|
paste: "paste"
|
522
|
-
picture_library:
|
523
|
-
filter:
|
524
|
-
last_upload: "from last upload"
|
525
|
-
recent: "that where recently uploaded"
|
526
|
-
without_tag: "without tag"
|
527
563
|
pictures_in_page: "%{page} in %{pictures}"
|
528
564
|
place_link: "Link text"
|
529
565
|
player_version: "Flash Player version"
|
@@ -18,11 +18,31 @@ module Alchemy
|
|
18
18
|
super
|
19
19
|
end
|
20
20
|
|
21
|
+
# Renders a simple_form input that displays a datepicker
|
22
|
+
#
|
23
|
+
def datepicker(attribute_name, options = {})
|
24
|
+
options[:wrapper] = :alchemy
|
25
|
+
|
26
|
+
type = options[:as] || :date
|
27
|
+
value = options.fetch(:input_html, {}).delete(:value)
|
28
|
+
date = value || object.send(attribute_name.to_sym).presence
|
29
|
+
date = Time.zone.parse(date) if date.is_a?(String)
|
30
|
+
|
31
|
+
input_options = {
|
32
|
+
type: :text,
|
33
|
+
class: type,
|
34
|
+
data: { datepicker_type: type },
|
35
|
+
value: date&.iso8601,
|
36
|
+
}.merge(options[:input_html] || {})
|
37
|
+
|
38
|
+
input attribute_name, as: :string, input_html: input_options
|
39
|
+
end
|
40
|
+
|
21
41
|
# Renders a button tag wrapped in a div with 'submit' class.
|
22
42
|
#
|
23
43
|
def submit(label, options = {})
|
24
44
|
options = {
|
25
|
-
wrapper_html: {class: "submit"},
|
45
|
+
wrapper_html: { class: "submit" },
|
26
46
|
}.update(options)
|
27
47
|
template.content_tag("div", options.delete(:wrapper_html)) do
|
28
48
|
template.content_tag("button", label, options.delete(:input_html))
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Alchemy
|
4
|
+
class ResourceFilter
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(filter, resource_name)
|
8
|
+
@filter = filter
|
9
|
+
@name = filter[:name]
|
10
|
+
@resource_name = resource_name
|
11
|
+
@values = filter[:values].presence || []
|
12
|
+
end
|
13
|
+
|
14
|
+
def options_for_select
|
15
|
+
translated_values.zip(values)
|
16
|
+
end
|
17
|
+
|
18
|
+
def values
|
19
|
+
if translated?
|
20
|
+
@values.map { |v| v[1] }
|
21
|
+
else
|
22
|
+
@values
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def translated?
|
29
|
+
@values.first.is_a?(Array)
|
30
|
+
end
|
31
|
+
|
32
|
+
def translated_values
|
33
|
+
if translated?
|
34
|
+
@values.map { |a| a[0] }
|
35
|
+
else
|
36
|
+
@values.map { |v| Alchemy.t(v.to_sym, scope: ["filters", @resource_name, @name, "values"]) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -107,12 +107,10 @@ module Alchemy
|
|
107
107
|
when "boolean"
|
108
108
|
options
|
109
109
|
when "date", "time", "datetime"
|
110
|
-
date = resource_instance_variable.send(attribute[:name]) || Time.current
|
111
110
|
options.merge(
|
112
111
|
as: "string",
|
113
112
|
input_html: {
|
114
|
-
|
115
|
-
value: date ? date.iso8601 : nil,
|
113
|
+
data: { datepicker_type: input_type },
|
116
114
|
},
|
117
115
|
)
|
118
116
|
when "text"
|
@@ -171,18 +169,5 @@ module Alchemy
|
|
171
169
|
def resource_has_tags
|
172
170
|
resource_model.respond_to?(:tag_counts) && resource_model.tag_counts.any?
|
173
171
|
end
|
174
|
-
|
175
|
-
def resource_has_filters
|
176
|
-
resource_model.respond_to?(:alchemy_resource_filters)
|
177
|
-
end
|
178
|
-
|
179
|
-
def resource_filter_select
|
180
|
-
resource_model.alchemy_resource_filters.map do |filter_scope|
|
181
|
-
[
|
182
|
-
Alchemy.t(filter_scope.to_sym, scope: ["resources", resource_name, "filters"]),
|
183
|
-
filter_scope,
|
184
|
-
]
|
185
|
-
end
|
186
|
-
end
|
187
172
|
end
|
188
173
|
end
|
@@ -16,7 +16,6 @@ RSpec.shared_examples_for "an alchemy ingredient" do
|
|
16
16
|
it { is_expected.to belong_to(:related_object).optional }
|
17
17
|
it { is_expected.to validate_presence_of(:role) }
|
18
18
|
it { is_expected.to validate_presence_of(:type) }
|
19
|
-
it { expect(subject.data).to eq({}) }
|
20
19
|
|
21
20
|
describe "#settings" do
|
22
21
|
subject { ingredient.settings }
|
@@ -28,6 +27,16 @@ RSpec.shared_examples_for "an alchemy ingredient" do
|
|
28
27
|
end
|
29
28
|
|
30
29
|
context "with element" do
|
30
|
+
before do
|
31
|
+
expect(element).to receive(:ingredient_definition_for) do
|
32
|
+
{
|
33
|
+
settings: {
|
34
|
+
linkable: true,
|
35
|
+
},
|
36
|
+
}.with_indifferent_access
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
it { is_expected.to eq({ linkable: true }.with_indifferent_access) }
|
32
41
|
end
|
33
42
|
end
|
@@ -42,15 +51,23 @@ RSpec.shared_examples_for "an alchemy ingredient" do
|
|
42
51
|
end
|
43
52
|
|
44
53
|
context "with element" do
|
45
|
-
|
46
|
-
|
54
|
+
let(:definition) do
|
55
|
+
{
|
47
56
|
role: "headline",
|
48
57
|
type: "Text",
|
49
58
|
default: "Hello World",
|
50
59
|
settings: {
|
51
60
|
linkable: true,
|
52
61
|
},
|
53
|
-
}.with_indifferent_access
|
62
|
+
}.with_indifferent_access
|
63
|
+
end
|
64
|
+
|
65
|
+
before do
|
66
|
+
expect(element).to receive(:ingredient_definition_for) { definition }
|
67
|
+
end
|
68
|
+
|
69
|
+
it "returns ingredient definition" do
|
70
|
+
is_expected.to eq(definition)
|
54
71
|
end
|
55
72
|
end
|
56
73
|
end
|