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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c960938b7e577abd1031dc1ff066eea2bc9636f2a94d61cab753ae42e1058768
|
4
|
+
data.tar.gz: d3dff1ab8a69b2dcfc2374aa78ecbbaad3c76d97fe66c23ede57d33e8f019f49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73e65f16a6c35dd438645b36f359745db42d657ca6d7de7082714f879105c97ac296861790dc15f6c3411f25970519f2d01dc5c3b2525e88e8fc25a2fca38b80
|
7
|
+
data.tar.gz: 78dedcd0ca764496af5abc4a8800675205ef6f78deb511bf8cf2f4bb5025f4e6cfe7315dc9a4d54d114a33efbb6d5ad2b53fc4de881686c8df158c7d7dfa83dd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,49 @@
|
|
1
|
+
## 6.0.0-b5 (2021-08-27)
|
2
|
+
|
3
|
+
- Remove spec that tests default data store value [#2184](https://github.com/AlchemyCMS/alchemy_cms/pull/2184) ([tvdeyen](https://github.com/tvdeyen))
|
4
|
+
- Remove data store accessor from ingredient base class [#2183](https://github.com/AlchemyCMS/alchemy_cms/pull/2183) ([tvdeyen](https://github.com/tvdeyen))
|
5
|
+
|
6
|
+
## 6.0.0-b4 (2021-08-27)
|
7
|
+
|
8
|
+
- Load custom Tinymce config for ingredients [#2182](https://github.com/AlchemyCMS/alchemy_cms/pull/2182) ([tvdeyen](https://github.com/tvdeyen))
|
9
|
+
- Fix ingredient editor selector in element update callback [#2181](https://github.com/AlchemyCMS/alchemy_cms/pull/2181) ([tvdeyen](https://github.com/tvdeyen))
|
10
|
+
- Ingredient by role block level helper [#2180](https://github.com/AlchemyCMS/alchemy_cms/pull/2180) ([tvdeyen](https://github.com/tvdeyen))
|
11
|
+
- Fixes caching [#2179](https://github.com/AlchemyCMS/alchemy_cms/pull/2179) ([tvdeyen](https://github.com/tvdeyen))
|
12
|
+
- make images non-executable [#2176](https://github.com/AlchemyCMS/alchemy_cms/pull/2176) ([mensfeld](https://github.com/mensfeld))
|
13
|
+
- Release task [#2173](https://github.com/AlchemyCMS/alchemy_cms/pull/2173) ([tvdeyen](https://github.com/tvdeyen))
|
14
|
+
|
15
|
+
## 6.0.0.b3 (2021-08-12)
|
16
|
+
|
17
|
+
### Fixes
|
18
|
+
|
19
|
+
- Simplify ingredient creation [#2171](https://github.com/AlchemyCMS/alchemy_cms/pull/2171) ([tvdeyen](https://github.com/tvdeyen))
|
20
|
+
- Return ingredients value if element asked for ingredient [#2170](https://github.com/AlchemyCMS/alchemy_cms/pull/2170) ([tvdeyen](https://github.com/tvdeyen))
|
21
|
+
- Fix ingredient form field DOM ids [#2167](https://github.com/AlchemyCMS/alchemy_cms/pull/2167) ([tvdeyen](https://github.com/tvdeyen))
|
22
|
+
- Ensure resource table ends before the filter/tag sidebar [#2166](https://github.com/AlchemyCMS/alchemy_cms/pull/2166) ([robinboening](https://github.com/robinboening))
|
23
|
+
- Return fully namespaced ingredient constant [#2164](https://github.com/AlchemyCMS/alchemy_cms/pull/2164) ([tvdeyen](https://github.com/tvdeyen))
|
24
|
+
- (Re)-init Tinymce for elements with ingredients [#2163](https://github.com/AlchemyCMS/alchemy_cms/pull/2163) ([tvdeyen](https://github.com/tvdeyen))
|
25
|
+
|
26
|
+
## 6.0.0.b2 (2021-08-05)
|
27
|
+
|
28
|
+
### Features
|
29
|
+
|
30
|
+
- Add datepicker simple form input [#2162](https://github.com/AlchemyCMS/alchemy_cms/pull/2162) ([tvdeyen](https://github.com/tvdeyen))
|
31
|
+
- Feature flexible resource filters [#2091](https://github.com/AlchemyCMS/alchemy_cms/pull/2091) ([robinboening](https://github.com/robinboening))
|
32
|
+
|
33
|
+
### Changes
|
34
|
+
|
35
|
+
- Require alchemy/version [#2159](https://github.com/AlchemyCMS/alchemy_cms/pull/2159) ([tvdeyen](https://github.com/tvdeyen))
|
36
|
+
- Make ingredient examples usable without elements.yml [#2158](https://github.com/AlchemyCMS/alchemy_cms/pull/2158) ([tvdeyen](https://github.com/tvdeyen))
|
37
|
+
- Fix ingredient migrator (again) [#2155](https://github.com/AlchemyCMS/alchemy_cms/pull/2155) ([tvdeyen](https://github.com/tvdeyen))
|
38
|
+
- Respect additional essence attributes during ingredients migration [#2154](https://github.com/AlchemyCMS/alchemy_cms/pull/2154) ([tvdeyen](https://github.com/tvdeyen))
|
39
|
+
- Improve cache key defaults for menus [#2153](https://github.com/AlchemyCMS/alchemy_cms/pull/2153) ([oneiros](https://github.com/oneiros))
|
40
|
+
- Make element preview text work with ingredients [#2152](https://github.com/AlchemyCMS/alchemy_cms/pull/2152) ([tvdeyen](https://github.com/tvdeyen))
|
41
|
+
- Do not leak all records for guest users in API controllers [#2145](https://github.com/AlchemyCMS/alchemy_cms/pull/2145) ([tvdeyen](https://github.com/tvdeyen))
|
42
|
+
|
43
|
+
### Misc
|
44
|
+
|
45
|
+
- [ruby - main] Upgrade shoulda-matchers to version 5.0.0 [#2161](https://github.com/AlchemyCMS/alchemy_cms/pull/2161) ([depfu](https://github.com/apps/depfu))
|
46
|
+
|
1
47
|
## 6.0.0.b1 (2021-07-05)
|
2
48
|
|
3
49
|
### Features
|
data/README.md
CHANGED
@@ -339,6 +339,10 @@ $ bin/rails s
|
|
339
339
|
|
340
340
|
## 📦 Releasing
|
341
341
|
|
342
|
+
### Bump version
|
343
|
+
|
344
|
+
Bump the version number in both `lib/alchemy/version.rb` and `./package.json`. Make sure both are exactly the same and follow [SemVer format](https://semver.org/#semantic-versioning-specification-semver).
|
345
|
+
|
342
346
|
### Update the changelog
|
343
347
|
|
344
348
|
```bash
|
@@ -346,12 +350,20 @@ $ export GITHUB_ACCESS_TOKEN=...
|
|
346
350
|
$ PREVIOUS_VERSION=4.1.0 bundle exec rake alchemy:changelog:update
|
347
351
|
```
|
348
352
|
|
349
|
-
###
|
353
|
+
### Commit version bump
|
350
354
|
|
351
355
|
```bash
|
352
|
-
$
|
356
|
+
$ git commit -am "Bump version to vX.Y.Z"
|
353
357
|
```
|
354
358
|
|
359
|
+
### Release a new version
|
360
|
+
|
361
|
+
This task will publish both the ruby gem and the npm package.
|
362
|
+
It also tags the latest commit.
|
363
|
+
|
364
|
+
```bash
|
365
|
+
$ bundle exec rake alchemy:release
|
366
|
+
```
|
355
367
|
|
356
368
|
## ❓Getting Help
|
357
369
|
|
data/Rakefile
CHANGED
@@ -1,37 +1,37 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "bundler/setup"
|
3
3
|
rescue LoadError
|
4
|
-
puts
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
5
5
|
end
|
6
6
|
|
7
7
|
begin
|
8
|
-
require
|
8
|
+
require "rdoc/task"
|
9
9
|
rescue LoadError
|
10
|
-
require
|
11
|
-
require
|
10
|
+
require "rdoc/rdoc"
|
11
|
+
require "rake/rdoctask"
|
12
12
|
RDoc::Task = Rake::RDocTask
|
13
13
|
end
|
14
14
|
|
15
|
-
desc
|
15
|
+
desc "Generate documentation for Alchemy CMS."
|
16
16
|
RDoc::Task.new(:rdoc) do |rdoc|
|
17
|
-
rdoc.rdoc_dir =
|
18
|
-
rdoc.title
|
19
|
-
rdoc.options <<
|
20
|
-
rdoc.rdoc_files.include(
|
21
|
-
rdoc.rdoc_files.include(
|
22
|
-
rdoc.rdoc_files.include(
|
23
|
-
rdoc.rdoc_files.include(
|
17
|
+
rdoc.rdoc_dir = "rdoc"
|
18
|
+
rdoc.title = "Alchemy CMS"
|
19
|
+
rdoc.options << "--line-numbers" << "--inline-source"
|
20
|
+
rdoc.rdoc_files.include("README.md")
|
21
|
+
rdoc.rdoc_files.include("config/alchemy/*.yml")
|
22
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
23
|
+
rdoc.rdoc_files.include("app/**/*.rb")
|
24
24
|
end
|
25
25
|
|
26
|
-
APP_RAKEFILE = File.expand_path(
|
27
|
-
load
|
26
|
+
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
|
27
|
+
load "rails/tasks/engine.rake"
|
28
28
|
|
29
|
-
require
|
30
|
-
require
|
29
|
+
require "rspec/core"
|
30
|
+
require "rspec/core/rake_task"
|
31
31
|
|
32
32
|
RSpec::Core::RakeTask.new(:spec)
|
33
33
|
|
34
|
-
task default: [
|
34
|
+
task default: ["alchemy:spec:prepare", :spec]
|
35
35
|
|
36
36
|
Bundler::GemHelper.install_tasks
|
37
37
|
|
@@ -56,11 +56,11 @@ namespace :alchemy do
|
|
56
56
|
namespace :changelog do
|
57
57
|
desc "Update CHANGELOG from GitHub (Set GITHUB_ACCESS_TOKEN and PREVIOUS_VERSION to a version you want to write changelog changes for)"
|
58
58
|
task :update do
|
59
|
-
original_file =
|
60
|
-
new_file = original_file +
|
61
|
-
backup = original_file +
|
62
|
-
changes = `git rev-list v#{ENV[
|
63
|
-
File.open(new_file,
|
59
|
+
original_file = "./CHANGELOG.md"
|
60
|
+
new_file = original_file + ".new"
|
61
|
+
backup = original_file + ".old"
|
62
|
+
changes = `git rev-list v#{ENV["PREVIOUS_VERSION"]}..HEAD | bundle exec github_fast_changelog AlchemyCMS/alchemy_cms`
|
63
|
+
File.open(new_file, "w") do |fo|
|
64
64
|
fo.puts changes
|
65
65
|
File.foreach(original_file) do |li|
|
66
66
|
fo.puts li
|
@@ -72,4 +72,18 @@ namespace :alchemy do
|
|
72
72
|
File.delete(backup)
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
desc "Release a new Ruby gem and npm package in one command"
|
77
|
+
task :release do
|
78
|
+
require "json"
|
79
|
+
require_relative "lib/alchemy/version"
|
80
|
+
package = File.read("package.json")
|
81
|
+
unless JSON.parse(package)["version"] == Alchemy.version
|
82
|
+
abort "Ruby gem and npm package versions are out of sync! Please fix."
|
83
|
+
end
|
84
|
+
# Release the Ruby gem with bundler
|
85
|
+
Rake::Task["release"].invoke
|
86
|
+
# Publish npm package via CLI
|
87
|
+
system "npm publish"
|
88
|
+
end
|
75
89
|
end
|
data/alchemy_cms.gemspec
CHANGED
@@ -65,7 +65,7 @@ Gem::Specification.new do |gem|
|
|
65
65
|
gem.add_development_dependency "simplecov", ["~> 0.20"]
|
66
66
|
gem.add_development_dependency "webdrivers", ["~> 4.0"]
|
67
67
|
gem.add_development_dependency "webmock", ["~> 3.3"]
|
68
|
-
gem.add_development_dependency "shoulda-matchers", ["~>
|
68
|
+
gem.add_development_dependency "shoulda-matchers", ["~> 5.0"]
|
69
69
|
gem.add_development_dependency "timecop", ["~> 0.9"]
|
70
70
|
|
71
71
|
gem.post_install_message = <<~MSG
|
@@ -31,15 +31,28 @@
|
|
31
31
|
line-height: $form-field-line-height;
|
32
32
|
transition: $transition-duration;
|
33
33
|
|
34
|
-
&:focus {
|
34
|
+
&:focus:not(.readonly) {
|
35
35
|
@include default-focus-style($box-shadow: 0 0 0 1px $focus-color);
|
36
36
|
}
|
37
37
|
|
38
|
-
&[disabled],
|
38
|
+
&[disabled],
|
39
|
+
&.disabled,
|
40
|
+
&[readonly],
|
41
|
+
&.readonly {
|
39
42
|
color: $form-field-disabled-text-color;
|
40
43
|
background-color: $form-field-disabled-bg-color;
|
44
|
+
cursor: default;
|
45
|
+
}
|
46
|
+
|
47
|
+
&[disabled],
|
48
|
+
&.disabled {
|
41
49
|
cursor: not-allowed;
|
42
50
|
}
|
51
|
+
|
52
|
+
&[readonly],
|
53
|
+
&.readonly {
|
54
|
+
pointer-events: none;
|
55
|
+
}
|
43
56
|
}
|
44
57
|
|
45
58
|
%gradiated-toolbar {
|
@@ -2,11 +2,26 @@
|
|
2
2
|
padding: 2 * $default-padding;
|
3
3
|
}
|
4
4
|
|
5
|
+
.applied-filter {
|
6
|
+
display: inline-block;
|
7
|
+
padding: 2px 6px;
|
8
|
+
border-radius: $default-border-radius;
|
9
|
+
border: 1px solid $default-border-color;
|
10
|
+
white-space: nowrap;
|
11
|
+
font-weight: normal;
|
12
|
+
|
13
|
+
.dismiss-filter {
|
14
|
+
position: relative;
|
15
|
+
top: -1px;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
5
19
|
.resources-table-wrapper {
|
6
20
|
padding-bottom: 60px;
|
7
21
|
|
8
22
|
&.with_tag_filter {
|
9
|
-
|
23
|
+
width: calc(100% - 235px);
|
24
|
+
overflow-x: auto;
|
10
25
|
}
|
11
26
|
}
|
12
27
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -21,8 +21,8 @@ module Alchemy
|
|
21
21
|
@attachments = @attachments.tagged_with(search_filter_params[:tagged_with])
|
22
22
|
end
|
23
23
|
|
24
|
-
if search_filter_params[:
|
25
|
-
@attachments = @attachments
|
24
|
+
if search_filter_params[:filter].present?
|
25
|
+
@attachments = apply_filters(@attachments)
|
26
26
|
end
|
27
27
|
|
28
28
|
@attachments = @attachments
|
@@ -77,8 +77,8 @@ module Alchemy
|
|
77
77
|
def search_filter_params
|
78
78
|
@_search_filter_params ||= params.except(*COMMON_SEARCH_FILTER_EXCLUDES + [:attachment]).permit(
|
79
79
|
*common_search_filter_includes + [
|
80
|
-
:file_type,
|
81
80
|
:form_field_id,
|
81
|
+
:content_id,
|
82
82
|
]
|
83
83
|
)
|
84
84
|
end
|
@@ -47,11 +47,7 @@ module Alchemy
|
|
47
47
|
end
|
48
48
|
|
49
49
|
if search_filter_params[:filter].present?
|
50
|
-
items = items
|
51
|
-
end
|
52
|
-
|
53
|
-
if search_filter_params[:page_layout].present?
|
54
|
-
items = items.where(page_layout: search_filter_params[:page_layout])
|
50
|
+
items = apply_filters(items)
|
55
51
|
end
|
56
52
|
|
57
53
|
items = items.page(params[:page] || 1).per(items_per_page)
|
@@ -244,10 +240,6 @@ module Alchemy
|
|
244
240
|
@_resource_handler ||= Alchemy::Resource.new(controller_path, alchemy_module, Alchemy::Page)
|
245
241
|
end
|
246
242
|
|
247
|
-
def common_search_filter_includes
|
248
|
-
super.push(:page_layout, :view)
|
249
|
-
end
|
250
|
-
|
251
243
|
def set_view
|
252
244
|
@view = params[:view] || session[:alchemy_pages_view] || "tree"
|
253
245
|
session[:alchemy_pages_view] = @view
|
@@ -21,12 +21,7 @@ module Alchemy
|
|
21
21
|
|
22
22
|
def index
|
23
23
|
@query = Picture.ransack(search_filter_params[:q])
|
24
|
-
@pictures =
|
25
|
-
search_filter_params,
|
26
|
-
@query,
|
27
|
-
items_per_page,
|
28
|
-
)
|
29
|
-
@pictures = @pictures.includes(:thumbs)
|
24
|
+
@pictures = filtered_pictures.includes(:thumbs)
|
30
25
|
|
31
26
|
if in_overlay?
|
32
27
|
archive_overlay
|
@@ -34,9 +29,11 @@ module Alchemy
|
|
34
29
|
end
|
35
30
|
|
36
31
|
def show
|
37
|
-
@
|
38
|
-
@
|
32
|
+
@query = Picture.ransack(params[:q])
|
33
|
+
@previous = filtered_pictures.where("name < ?", @picture.name).last
|
34
|
+
@next = filtered_pictures.where("name > ?", @picture.name).first
|
39
35
|
@assignments = @picture.essence_pictures.joins(content: { element: :page })
|
36
|
+
|
40
37
|
render action: "show"
|
41
38
|
end
|
42
39
|
|
@@ -130,6 +127,22 @@ module Alchemy
|
|
130
127
|
redirect_to_index
|
131
128
|
end
|
132
129
|
|
130
|
+
def filtered_pictures
|
131
|
+
pictures = @query.result
|
132
|
+
|
133
|
+
if params[:tagged_with].present?
|
134
|
+
pictures = pictures.tagged_with(params[:tagged_with])
|
135
|
+
end
|
136
|
+
|
137
|
+
if search_filter_params[:filter].present?
|
138
|
+
pictures = apply_filters(pictures)
|
139
|
+
end
|
140
|
+
|
141
|
+
pictures = pictures.page(params[:page] || 1).per(items_per_page)
|
142
|
+
|
143
|
+
pictures.order(:name)
|
144
|
+
end
|
145
|
+
|
133
146
|
def items_per_page
|
134
147
|
if in_overlay?
|
135
148
|
case @size
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "csv"
|
4
4
|
require "alchemy/resource"
|
5
5
|
require "alchemy/resources_helper"
|
6
|
+
require "alchemy/resource_filter"
|
6
7
|
|
7
8
|
module Alchemy
|
8
9
|
module Admin
|
@@ -13,7 +14,8 @@ module Alchemy
|
|
13
14
|
|
14
15
|
helper Alchemy::ResourcesHelper, TagsHelper
|
15
16
|
helper_method :resource_handler, :search_filter_params,
|
16
|
-
:items_per_page, :items_per_page_options
|
17
|
+
:items_per_page, :items_per_page_options, :resource_has_filters,
|
18
|
+
:resource_filters_for_select
|
17
19
|
|
18
20
|
before_action :load_resource,
|
19
21
|
only: [:show, :edit, :update, :destroy]
|
@@ -34,7 +36,7 @@ module Alchemy
|
|
34
36
|
end
|
35
37
|
|
36
38
|
if search_filter_params[:filter].present?
|
37
|
-
items = items
|
39
|
+
items = apply_filters(items)
|
38
40
|
end
|
39
41
|
|
40
42
|
respond_to do |format|
|
@@ -90,8 +92,79 @@ module Alchemy
|
|
90
92
|
@_resource_handler ||= Alchemy::Resource.new(controller_path, alchemy_module)
|
91
93
|
end
|
92
94
|
|
95
|
+
def resource_has_filters
|
96
|
+
resource_model.respond_to?(:alchemy_resource_filters)
|
97
|
+
end
|
98
|
+
|
99
|
+
def resource_has_deprecated_filters
|
100
|
+
resource_model.alchemy_resource_filters.any? { |f| !f.is_a?(Hash) }
|
101
|
+
end
|
102
|
+
|
103
|
+
def resource_filters
|
104
|
+
return unless resource_has_filters
|
105
|
+
|
106
|
+
@_resource_filters ||= deprecated_resource_filters || resource_model.alchemy_resource_filters
|
107
|
+
end
|
108
|
+
|
109
|
+
def resource_filters_for_select
|
110
|
+
resource_filters.map do |filter|
|
111
|
+
ResourceFilter.new(filter, resource_handler.resource_name)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
93
115
|
protected
|
94
116
|
|
117
|
+
def deprecated_resource_filters
|
118
|
+
if resource_has_deprecated_filters
|
119
|
+
Alchemy::Deprecation.warn(
|
120
|
+
"#{resource_model}.alchemy_resource_filters is using a legacy data structure. " \
|
121
|
+
"Please use an Array of Hashes instead. i.e. [{ name: 'foo', values: ['bar', 'baz'] }, ...] " \
|
122
|
+
"where values are scopes. With Alchemy 6.1 only the new structure will be supported."
|
123
|
+
)
|
124
|
+
|
125
|
+
@_resource_filters ||= [
|
126
|
+
{
|
127
|
+
name: :misc,
|
128
|
+
values: resource_model.alchemy_resource_filters,
|
129
|
+
},
|
130
|
+
]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def apply_filters(items)
|
135
|
+
sanitize_filter_params!
|
136
|
+
|
137
|
+
search_filter_params[:filter].each do |filter|
|
138
|
+
if argument_scope_filter?(filter)
|
139
|
+
items = items.public_send(filter[0], filter[1])
|
140
|
+
elsif simple_scope_filter?(filter)
|
141
|
+
items = items.public_send(filter[1])
|
142
|
+
else
|
143
|
+
raise "Can't apply filter #{filter[0]}. Either the name or the values must be defined as class methods / scopes on the model."
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
items
|
148
|
+
end
|
149
|
+
|
150
|
+
def simple_scope_filter?(filter)
|
151
|
+
resource_model.respond_to?(filter[1])
|
152
|
+
end
|
153
|
+
|
154
|
+
def argument_scope_filter?(filter)
|
155
|
+
resource_model.respond_to?(filter[0])
|
156
|
+
end
|
157
|
+
|
158
|
+
def sanitize_filter_params!
|
159
|
+
search_filter_params[:filter].reject! do |_, v|
|
160
|
+
eligible_resource_filter_values.exclude?(v)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def eligible_resource_filter_values
|
165
|
+
resource_filters.map(&:values).flatten
|
166
|
+
end
|
167
|
+
|
95
168
|
# Returns a translated +flash[:notice]+.
|
96
169
|
# The key should look like "Modelname successfully created|updated|destroyed."
|
97
170
|
def flash_notice_for_resource_action(action = params[:action])
|
@@ -136,27 +209,28 @@ module Alchemy
|
|
136
209
|
params.require(resource_handler.namespaced_resource_name).permit!
|
137
210
|
end
|
138
211
|
|
139
|
-
def sanitized_filter_params
|
140
|
-
resource_model.alchemy_resource_filters.detect do |filter|
|
141
|
-
filter == search_filter_params[:filter]
|
142
|
-
end || :all
|
143
|
-
end
|
144
|
-
|
145
212
|
def search_filter_params
|
146
213
|
@_search_filter_params ||= params.except(*COMMON_SEARCH_FILTER_EXCLUDES).permit(*common_search_filter_includes).to_h
|
147
214
|
end
|
148
215
|
|
149
216
|
def common_search_filter_includes
|
150
|
-
[
|
217
|
+
search_filters = [
|
151
218
|
{ q: [
|
152
219
|
resource_handler.search_field_name,
|
153
220
|
:s,
|
154
221
|
] },
|
155
222
|
:tagged_with,
|
156
|
-
:filter,
|
157
223
|
:page,
|
158
224
|
:per_page,
|
159
225
|
]
|
226
|
+
|
227
|
+
if resource_has_filters
|
228
|
+
search_filters << {
|
229
|
+
filter: resource_filters.map { |f| f[:name] },
|
230
|
+
}
|
231
|
+
end
|
232
|
+
|
233
|
+
search_filters
|
160
234
|
end
|
161
235
|
|
162
236
|
def items_per_page
|