alchemy_cms 6.0.0.pre.rc6 → 6.0.0.pre.rc7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +8 -8
  3. data/.github/workflows/stale.yml +21 -7
  4. data/.gitignore +0 -1
  5. data/.rspec +1 -0
  6. data/CHANGELOG.md +69 -0
  7. data/Gemfile +7 -6
  8. data/Rakefile +5 -1
  9. data/alchemy_cms.gemspec +2 -2
  10. data/app/assets/javascripts/alchemy/admin.js +0 -1
  11. data/app/assets/javascripts/alchemy/page_select.js +13 -8
  12. data/app/assets/javascripts/alchemy/templates/index.js +1 -0
  13. data/app/assets/javascripts/alchemy/templates/page.hbs +17 -7
  14. data/app/assets/javascripts/alchemy/templates/page_folder.hbs +3 -0
  15. data/app/assets/stylesheets/alchemy/archive.scss +4 -0
  16. data/app/assets/stylesheets/alchemy/page-select.scss +29 -4
  17. data/app/assets/stylesheets/alchemy/sitemap.scss +2 -6
  18. data/app/controllers/alchemy/admin/pages_controller.rb +9 -12
  19. data/app/controllers/alchemy/api/pages_controller.rb +14 -4
  20. data/app/models/alchemy/ingredient.rb +6 -1
  21. data/app/serializers/alchemy/page_serializer.rb +7 -1
  22. data/app/serializers/alchemy/page_tree_serializer.rb +3 -3
  23. data/app/views/alchemy/admin/pages/_form.html.erb +19 -0
  24. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +16 -5
  25. data/app/views/alchemy/admin/pages/_page.html.erb +111 -133
  26. data/app/views/alchemy/admin/pages/_sitemap.html.erb +2 -8
  27. data/app/views/alchemy/admin/pages/_toolbar.html.erb +0 -12
  28. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  29. data/app/views/alchemy/admin/pages/update.js.erb +7 -0
  30. data/app/views/alchemy/admin/partials/_routes.html.erb +8 -1
  31. data/app/views/alchemy/essences/_essence_page_editor.html.erb +1 -1
  32. data/config/locales/alchemy.en.yml +0 -3
  33. data/config/routes.rb +4 -2
  34. data/lib/alchemy/permissions.rb +0 -1
  35. data/lib/alchemy/test_support/shared_ingredient_examples.rb +4 -2
  36. data/lib/alchemy/version.rb +1 -1
  37. data/lib/generators/alchemy/install/install_generator.rb +6 -1
  38. data/package/src/image_loader.js +4 -2
  39. data/package/src/node_tree.js +13 -6
  40. data/package/src/page_publication_fields.js +15 -14
  41. data/package/src/page_sorter.js +62 -0
  42. data/package/src/picture_editors.js +4 -4
  43. data/package/src/sitemap.js +51 -36
  44. data/package/src/utils/__tests__/ajax.spec.js +52 -16
  45. data/package/src/utils/ajax.js +12 -0
  46. data/package.json +1 -1
  47. metadata +21 -22
  48. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +0 -24
  49. data/app/views/alchemy/admin/pages/fold.js.erb +0 -2
  50. data/app/views/alchemy/admin/pages/sort.html.erb +0 -19
  51. data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +0 -434
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2c4b9cbf469cb88a351047757a38e9ab434cd67006b0390170e22dd5b64d0a8
4
- data.tar.gz: 48d6dec7c669c2f854ac0414e16801236cace3a6cef2eef5fb07fa4e509ef996
3
+ metadata.gz: d81ddf40cd98c283ac6b58332e03e6ed4094de86671f0dc80692a0de5c8292ea
4
+ data.tar.gz: 1115141343d2e2310001c8ee1e58f9d8070a4c34c770226f9647a6fa09f05d7d
5
5
  SHA512:
6
- metadata.gz: 9b290944338b8ca490e0472fa886c8f4b09d47bd957a7d45c014ab328c81a9545cc74196a69eda2969dcf2e5fb0af3bad4bfc9d5079e45c645a51d41582b4137
7
- data.tar.gz: 67c3a355c1df19256609680c562d0ae0c2bd76811daee6ea930b1425e85e3ff2087313e3a2d5d203523320f0da20d643d79b11badd1700912930e3209dfb2ddd
6
+ metadata.gz: f80e8e421037e50315254799456626f6b82ee4f30922d30920b2cec73ee7783a85fccf74b1a66a9a310fc2ca668844ad4d0daaa0b03ecca77cb4f4a1bb28c1e4
7
+ data.tar.gz: 2898baf39517e918cfdf0b99f6d79ad61836e74083922e2c496dcebb539c057ea558b03040578eba16040313bff647d0dbdb6a27221cbdfd8b1c7e8a7e69e395
@@ -9,12 +9,12 @@ jobs:
9
9
  fail-fast: false
10
10
  matrix:
11
11
  rails:
12
- - '6.0'
13
- - '6.1'
12
+ - "6.0"
13
+ - "6.1"
14
14
  ruby:
15
- - '2.6.8'
16
- - '2.7.4'
17
- - '3.0.2'
15
+ - "2.6"
16
+ - "2.7"
17
+ - "3.0"
18
18
  database:
19
19
  - mysql
20
20
  - postgresql
@@ -22,7 +22,7 @@ jobs:
22
22
  DB: ${{ matrix.database }}
23
23
  DB_USER: alchemy_user
24
24
  DB_PASSWORD: password
25
- DB_HOST: '127.0.0.1'
25
+ DB_HOST: "127.0.0.1"
26
26
  RAILS_ENV: test
27
27
  RAILS_VERSION: ${{ matrix.rails }}
28
28
  services:
@@ -32,11 +32,11 @@ jobs:
32
32
  POSTGRES_USER: alchemy_user
33
33
  POSTGRES_PASSWORD: password
34
34
  POSTGRES_DB: alchemy_cms_dummy_test
35
- ports: ['5432:5432']
35
+ ports: ["5432:5432"]
36
36
  options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
37
37
  mysql:
38
38
  image: mysql:latest
39
- ports: ['3306:3306']
39
+ ports: ["3306:3306"]
40
40
  env:
41
41
  MYSQL_USER: alchemy_user
42
42
  MYSQL_PASSWORD: password
@@ -2,16 +2,30 @@ name: Mark stale issues and pull requests
2
2
 
3
3
  on:
4
4
  schedule:
5
- - cron: "0 0 * * *"
5
+ - cron: "0 0 * * *"
6
6
 
7
7
  jobs:
8
8
  stale:
9
-
10
9
  runs-on: ubuntu-latest
11
10
 
12
11
  steps:
13
- - uses: actions/stale@v1
14
- with:
15
- repo-token: ${{ secrets.GITHUB_TOKEN }}
16
- stale-issue-message: 'This issue has not seen any activity in a long time. If the issue described still exists in recent versions of Alchemy, please open a new issue or preferably open a PR with a fix. Thanks for reporting.'
17
- stale-pr-message: 'This pull request has not seen any activiy in a long time. Probably because of missing tests or a necessary rebase. Please open a new PR to latest main if you want to continue working on this. Thanks for the contribution.'
12
+ - uses: actions/stale@v5
13
+ with:
14
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
15
+ stale-issue-message: |
16
+ This issue has not seen any activity in a long time.
17
+ Please create a pull request with a fix or ask someone of the community if they can help.
18
+ This issue will be closed in 7 days if no further activity happens.
19
+ close-issue-message: |
20
+ This issue has not seen any activity in a long time.
21
+ If the issue described still exists in recent versions of Alchemy,
22
+ please open a new issue with. Thanks for reporting.
23
+ stale-pr-message: |
24
+ This pull request has not seen any activiy in a long time.
25
+ Probably because of missing tests or a necessary rebase.
26
+ This PR will be closed in 7 days if no further activity happens.
27
+ close-pr-message: |
28
+ This pull request has not seen any activiy in a long time.
29
+ Probably because of missing tests or a necessary rebase.
30
+ Please open a new PR to latest main if you want to continue working on this.
31
+ Thanks for the contribution.
data/.gitignore CHANGED
@@ -33,7 +33,6 @@ spec/dummy/uploads/
33
33
  .ruby-gemset
34
34
  .ruby-version
35
35
  .env
36
- .rspec
37
36
  node_modules
38
37
  yarn-error.log
39
38
  yarn-debug.log*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## 6.0.0-rc7 (2022-03-28)
2
+
3
+ - fix(Sitemap): Use response data [#2272](https://github.com/AlchemyCMS/alchemy_cms/pull/2272) ([tvdeyen](https://github.com/tvdeyen))
4
+ - Revert "Ajax: Send method override" [#2271](https://github.com/AlchemyCMS/alchemy_cms/pull/2271) ([tvdeyen](https://github.com/tvdeyen))
5
+ - ImageLoader: Add error handling [#2270](https://github.com/AlchemyCMS/alchemy_cms/pull/2270) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Check presence of page_public checkbox [#2269](https://github.com/AlchemyCMS/alchemy_cms/pull/2269) ([afdev82](https://github.com/afdev82))
7
+ - Use lodash-es instead of lodash [#2268](https://github.com/AlchemyCMS/alchemy_cms/pull/2268) ([afdev82](https://github.com/afdev82))
8
+ - CI: Update stale workflow [#2267](https://github.com/AlchemyCMS/alchemy_cms/pull/2267) ([tvdeyen](https://github.com/tvdeyen))
9
+ - Allow to skip db:create during install task [#2266](https://github.com/AlchemyCMS/alchemy_cms/pull/2266) ([tvdeyen](https://github.com/tvdeyen))
10
+ - CI: Fix mysql builds [#2263](https://github.com/AlchemyCMS/alchemy_cms/pull/2263) ([tvdeyen](https://github.com/tvdeyen))
11
+ - Fix new Sitemap [#2262](https://github.com/AlchemyCMS/alchemy_cms/pull/2262) ([tvdeyen](https://github.com/tvdeyen))
12
+ - [ruby - main] Allow ransack version 2.6.0 [#2259](https://github.com/AlchemyCMS/alchemy_cms/pull/2259) ([depfu](https://github.com/apps/depfu))
13
+ - Allow all pages in API again [#2258](https://github.com/AlchemyCMS/alchemy_cms/pull/2258) ([tvdeyen](https://github.com/tvdeyen))
14
+ - Fix setting default value of ingredients [#2257](https://github.com/AlchemyCMS/alchemy_cms/pull/2257) ([tvdeyen](https://github.com/tvdeyen))
15
+ - Eager load in PageTree serializer [#2256](https://github.com/AlchemyCMS/alchemy_cms/pull/2256) ([tvdeyen](https://github.com/tvdeyen))
16
+ - Revert "Merge pull request #2203 from tvdeyen/switch-to-cuprite" [#2255](https://github.com/AlchemyCMS/alchemy_cms/pull/2255) ([tvdeyen](https://github.com/tvdeyen))
17
+ - [js] New version of flatpickr (4.6.10) broke the build [#2254](https://github.com/AlchemyCMS/alchemy_cms/pull/2254) ([depfu](https://github.com/apps/depfu))
18
+ - New sortable page tree [#2252](https://github.com/AlchemyCMS/alchemy_cms/pull/2252) ([tvdeyen](https://github.com/tvdeyen))
19
+ - Use minor versions for ruby version matrix [#2251](https://github.com/AlchemyCMS/alchemy_cms/pull/2251) ([tvdeyen](https://github.com/tvdeyen))
20
+ - Precompile packs during test setup [#2250](https://github.com/AlchemyCMS/alchemy_cms/pull/2250) ([tvdeyen](https://github.com/tvdeyen))
21
+ - Allow parent page change [#2246](https://github.com/AlchemyCMS/alchemy_cms/pull/2246) ([tvdeyen](https://github.com/tvdeyen))
22
+ - Send language_id to Api::PagesController#index so Pages can be restricted to the language of the page [#2245](https://github.com/AlchemyCMS/alchemy_cms/pull/2245) ([dbwinger](https://github.com/dbwinger))
23
+
1
24
  ## 6.0.0-rc6 (2022-03-05)
2
25
 
3
26
  - Rework sitemap JS [#2249](https://github.com/AlchemyCMS/alchemy_cms/pull/2249) ([tvdeyen](https://github.com/tvdeyen))
@@ -189,6 +212,52 @@
189
212
  - Fix delete element confirm dialog [#2023](https://github.com/AlchemyCMS/alchemy_cms/pull/2023) ([tvdeyen](https://github.com/tvdeyen))
190
213
  - Build for Ruby 3 [#1990](https://github.com/AlchemyCMS/alchemy_cms/pull/1990) ([tvdeyen](https://github.com/tvdeyen))
191
214
 
215
+ ## 5.2.7 (2022-03-01)
216
+
217
+ - Fix copying page with descendants to a different language ([dbwinger](https://github.com/dbwinger))
218
+ - Handle copying/pasting global pages ([dbwinger](https://github.com/dbwinger))
219
+
220
+ ## 5.2.6 (2022-02-28)
221
+
222
+ - Add crop_resize Dragonfly processor ([tvdeyen](https://github.com/tvdeyen))
223
+
224
+ ## 5.2.5 (2021-11-24)
225
+
226
+ - Adjust tinymce skin assets urls again ([tvdeyen](https://github.com/tvdeyen))
227
+
228
+ ## 5.2.4 (2021-11-17)
229
+
230
+ - Set stampable user_class_name without root identifier ([tvdeyen](https://github.com/tvdeyen))
231
+ - Use relative path for tinymce font-face ([tvdeyen](https://github.com/tvdeyen))
232
+
233
+ ## 5.2.3 (2021-10-26)
234
+
235
+ - Make sure to install correct npm package ([tvdeyen](https://github.com/tvdeyen))
236
+
237
+ ## 5.2.2 (2021-09-15)
238
+
239
+ - Return only pages from current site in api [#2169](https://github.com/AlchemyCMS/alchemy_cms/pull/2169) ([afdev82](https://github.com/afdev82))
240
+ - Improve cache key defaults for menus #2138 [#2160](https://github.com/AlchemyCMS/alchemy_cms/pull/2160) ([oneiros](https://github.com/oneiros))
241
+ - generate picture thumbnails only for pictures with convertible format [#2130](https://github.com/AlchemyCMS/alchemy_cms/pull/2130) ([afdev82](https://github.com/afdev82))
242
+ - Backport #2114 to v5.2 [#2116](https://github.com/AlchemyCMS/alchemy_cms/pull/2116) ([afdev82](https://github.com/afdev82))
243
+ - Add webpacker tasks to Alchemy upgrader [#2115](https://github.com/AlchemyCMS/alchemy_cms/pull/2115) ([dbwinger](https://github.com/dbwinger))
244
+
245
+ ## 5.2.1 (2021-05-13)
246
+
247
+ - Fix alchemy:generate:thumbnails task [#2092](https://github.com/AlchemyCMS/alchemy_cms/pull/2092) ([afdev82](https://github.com/afdev82))
248
+ - Do not attempt to generate thumbs for svg files. [#2090](https://github.com/AlchemyCMS/alchemy_cms/pull/2090) ([oneiros](https://github.com/oneiros))
249
+
250
+ ## 5.2.0 (2021-05-06)
251
+
252
+ - Backport #2049 to 5.2 [#2086](https://github.com/AlchemyCMS/alchemy_cms/pull/2086) ([rickythefox](https://github.com/rickythefox))
253
+ - hotfix and deprecate page_active? helper [#2073](https://github.com/AlchemyCMS/alchemy_cms/pull/2073) ([robinboening](https://github.com/robinboening))
254
+
255
+ ## 5.2.0.rc1 (2021-02-17)
256
+
257
+ ### Changes
258
+
259
+ - Change Factory loading mechanism to FactoryBots supported mechanism [#2030](https://github.com/AlchemyCMS/alchemy_cms/pull/2030) ([mamhoff](https://github.com/mamhoff))
260
+
192
261
  ## 5.2.0.b1 (2021-02-11)
193
262
 
194
263
  ### Features
data/Gemfile CHANGED
@@ -4,7 +4,13 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  rails_version = ENV.fetch("RAILS_VERSION", 6.1).to_f
7
- gem "rails", "~> #{rails_version}.0"
7
+ # Necessary until a new 6.1.5 version has been released
8
+ # https://github.com/rails/rails/pull/44691
9
+ if rails_version.to_s.match?(/6.1/)
10
+ gem "rails", git: "https://github.com/rails/rails", branch: "6-1-stable"
11
+ else
12
+ gem "rails", "~> #{rails_version}.0"
13
+ end
8
14
 
9
15
  if ENV["DB"].nil? || ENV["DB"] == "sqlite"
10
16
  gem "sqlite3", "~> 1.4.1"
@@ -40,8 +46,3 @@ group :development, :test do
40
46
  gem "brakeman", require: false
41
47
  end
42
48
  end
43
-
44
- # Necessary for system tests in Rails 6.0
45
- if ENV["RAILS_VERSION"] == "6.0"
46
- gem "selenium-webdriver"
47
- end
data/Rakefile CHANGED
@@ -41,12 +41,16 @@ namespace :alchemy do
41
41
  task :prepare do
42
42
  system(
43
43
  <<~BASH
44
+ yarn install && \
45
+ yarn link && \
44
46
  cd spec/dummy && \
45
47
  export RAILS_ENV=test && \
46
48
  bin/rake db:create && \
47
49
  bin/rake db:environment:set && \
48
50
  bin/rake db:migrate:reset && \
49
- bin/rails g alchemy:install --skip --skip-demo-files --auto-accept && \
51
+ bin/rails g alchemy:install --skip --skip-demo-files --auto-accept --skip-db-create && \
52
+ yarn link @alchemy_cms/admin && \
53
+ RAILS_ENV=test bin/webpack && \
50
54
  cd -
51
55
  BASH
52
56
  ) || fail
data/alchemy_cms.gemspec CHANGED
@@ -46,7 +46,7 @@ Gem::Specification.new do |gem|
46
46
  gem.add_runtime_dependency "kaminari", ["~> 1.1"]
47
47
  gem.add_runtime_dependency "originator", ["~> 3.1"]
48
48
  gem.add_runtime_dependency "non-stupid-digest-assets", ["~> 1.0.8"]
49
- gem.add_runtime_dependency "ransack", [">= 1.8", "<= 2.5.0"] # 2.4.2 dropped Ruby 2.5 support in a patch level release
49
+ gem.add_runtime_dependency "ransack", [">= 1.8", "<= 2.6.0"] # 2.4.2 dropped Ruby 2.5 support in a patch level release
50
50
  gem.add_runtime_dependency "request_store", ["~> 1.2"]
51
51
  gem.add_runtime_dependency "responders", [">= 2.0", "< 4.0"]
52
52
  gem.add_runtime_dependency "sassc-rails", ["~> 2.1"]
@@ -57,13 +57,13 @@ Gem::Specification.new do |gem|
57
57
 
58
58
  gem.add_development_dependency "capybara", ["~> 3.0"]
59
59
  gem.add_development_dependency "capybara-screenshot", ["~> 1.0"]
60
- gem.add_development_dependency "cuprite", ["~> 0.13"]
61
60
  gem.add_development_dependency "factory_bot_rails", ["~> 6.0"]
62
61
  gem.add_development_dependency "puma", ["~> 5.0"]
63
62
  gem.add_development_dependency "rails-controller-testing", ["~> 1.0"]
64
63
  gem.add_development_dependency "rspec-activemodel-mocks", ["~> 1.0"]
65
64
  gem.add_development_dependency "rspec-rails", [">= 4.0.0.beta2"]
66
65
  gem.add_development_dependency "simplecov", ["~> 0.20"]
66
+ gem.add_development_dependency "webdrivers", ["~> 5.0"]
67
67
  gem.add_development_dependency "webmock", ["~> 3.3"]
68
68
  gem.add_development_dependency "shoulda-matchers", ["~> 5.0"]
69
69
  gem.add_development_dependency "timecop", ["~> 0.9"]
@@ -35,7 +35,6 @@
35
35
  //= require alchemy/alchemy.link_dialog
36
36
  //= require alchemy/alchemy.list_filter
37
37
  //= require alchemy/alchemy.initializer
38
- //= require alchemy/alchemy.page_sorter
39
38
  //= require alchemy/alchemy.uploader
40
39
  //= require alchemy/alchemy.preview_window
41
40
  //= require alchemy/alchemy.spinner
@@ -1,9 +1,11 @@
1
- $.fn.alchemyPageSelect = function(options) {
1
+ $.fn.alchemyPageSelect = function (options) {
2
2
  var pageTemplate = HandlebarsTemplates.page
3
3
 
4
4
  return this.select2({
5
5
  placeholder: options.placeholder,
6
- allowClear: true,
6
+ allowClear: options.hasOwnProperty("allowClear")
7
+ ? options.allowClear
8
+ : true,
7
9
  minimumInputLength: 3,
8
10
  initSelection: function (_$el, callback) {
9
11
  if (options.initialSelection) {
@@ -12,13 +14,16 @@ $.fn.alchemyPageSelect = function(options) {
12
14
  },
13
15
  ajax: {
14
16
  url: options.url,
15
- datatype: 'json',
17
+ datatype: "json",
16
18
  quietMillis: 300,
17
19
  data: function (term, page) {
18
20
  return {
19
- q: $.extend({
20
- name_cont: term
21
- }, options.query_params),
21
+ q: $.extend(
22
+ {
23
+ name_cont: term
24
+ },
25
+ options.query_params
26
+ ),
22
27
  page: page
23
28
  }
24
29
  },
@@ -34,8 +39,8 @@ $.fn.alchemyPageSelect = function(options) {
34
39
  formatSelection: function (page) {
35
40
  return page.text || page.name
36
41
  },
37
- formatResult: function(page) {
38
- return pageTemplate({page: page})
42
+ formatResult: function (page) {
43
+ return pageTemplate({ page: page })
39
44
  }
40
45
  })
41
46
  }
@@ -2,3 +2,4 @@
2
2
  //= require alchemy/templates/page
3
3
  //= require alchemy/templates/node_folder
4
4
  //= require alchemy/templates/node
5
+ //= require alchemy/templates/page_folder
@@ -1,9 +1,19 @@
1
1
  <div class="page-select--page">
2
- <i class="icon far fa-file fa-lg"></i>
3
- <span class="page-select--page-name">
4
- {{ page.name }}
5
- </span>
6
- <span class="page-select--page-urlname">
7
- {{ page.url_path }}
8
- </span>
2
+ <div class="page-select--top">
3
+ <i class="icon far fa-file fa-lg"></i>
4
+ <span class="page-select--page-name">
5
+ {{ page.name }}
6
+ </span>
7
+ <span class="page-select--page-urlname">
8
+ {{ page.url_path }}
9
+ </span>
10
+ </div>
11
+ <div class="page-select--bottom">
12
+ <span class="page-select--site-name">
13
+ {{ page.site.name }}
14
+ </span>
15
+ <span class="page-select--language-code">
16
+ {{ page.language.name }}
17
+ </span>
18
+ </div>
9
19
  </div>
@@ -0,0 +1,3 @@
1
+ <a class="page_folder" data-page-id="{{ page.id }}">
2
+ <i class="far fa-{{#if page.folded }}plus{{else}}minus{{/if}}-square fa-fw"></i>
3
+ </a>
@@ -48,6 +48,10 @@ div#image_assign_filter_and_image_sizing {
48
48
  background-color: $thumbnail-background-color;
49
49
  width: 100%;
50
50
  height: 120px;
51
+
52
+ &:hover {
53
+ text-decoration: none;
54
+ }
51
55
  }
52
56
 
53
57
  .picture_thumbnail {
@@ -8,24 +8,49 @@
8
8
 
9
9
  .page-select--page {
10
10
  display: flex;
11
- align-items: center;
11
+ flex-direction: column;
12
12
 
13
13
  .icon {
14
14
  margin: 0 8px 0 4px;
15
15
 
16
16
  .select2-highlighted & {
17
- color: $white
17
+ color: $white;
18
18
  }
19
19
  }
20
20
  }
21
21
 
22
+ .page-select--top,
23
+ .page-select--bottom {
24
+ display: flex;
25
+ flex-direction: row;
26
+ align-items: center;
27
+ }
28
+
29
+ .page-select--bottom {
30
+ font-size: $small-font-size;
31
+ padding-left: 6 * $default-padding;
32
+ }
33
+
34
+ .page-select--language-code {
35
+ display: inline-block;
36
+ background-color: $medium-gray;
37
+ margin-left: auto;
38
+ border-radius: $default-border-radius;
39
+ padding: $default-padding / 2 $default-padding;
40
+
41
+ .select2-highlighted & {
42
+ color: $select-hover-bg-color;
43
+ background-color: white;
44
+ }
45
+ }
46
+
22
47
  .page-select--page-urlname {
23
48
  margin-left: auto;
24
- padding: $default-padding 2*$default-padding;
49
+ padding: $default-padding 2 * $default-padding;
25
50
  color: $dark-gray;
26
51
  font-size: $small-font-size;
27
52
 
28
53
  .select2-highlighted & {
29
- color: $white
54
+ color: $white;
30
55
  }
31
56
  }
@@ -142,12 +142,8 @@ $sitemap-url-xlarge-width: 350px;
142
142
  #sitemap {
143
143
  padding: 0 0 104px 0;
144
144
 
145
- &.sorting {
146
- padding-top: 100px;
147
-
148
- .page_icon {
149
- cursor: move;
150
- }
145
+ .handle {
146
+ cursor: move;
151
147
  }
152
148
 
153
149
  .page_folder {
@@ -7,7 +7,7 @@ module Alchemy
7
7
 
8
8
  helper "alchemy/pages"
9
9
 
10
- before_action :load_resource, except: [:index, :flush, :new, :order, :create, :copy_language_tree, :link, :sort]
10
+ before_action :load_resource, except: [:index, :flush, :new, :order, :create, :copy_language_tree, :link]
11
11
 
12
12
  authorize_resource class: Alchemy::Page, except: [:index, :tree]
13
13
 
@@ -21,7 +21,7 @@ module Alchemy
21
21
  except: [:show]
22
22
 
23
23
  before_action :set_root_page,
24
- only: [:index, :show, :sort, :order]
24
+ only: [:index, :show, :order]
25
25
 
26
26
  before_action :run_on_page_layout_callbacks,
27
27
  if: :run_on_page_layout_callbacks?,
@@ -123,6 +123,7 @@ module Alchemy
123
123
  # * fetches page via before filter
124
124
  #
125
125
  def update
126
+ @old_parent_id = @page.parent_id
126
127
  if @page.update(page_params)
127
128
  @notice = Alchemy.t("Page saved", name: @page.name)
128
129
  @while_page_edit = request.referer.include?("edit")
@@ -167,9 +168,7 @@ module Alchemy
167
168
  def fold
168
169
  # @page is fetched via before filter
169
170
  @page.fold!(current_alchemy_user.id, !@page.folded?(current_alchemy_user.id))
170
- respond_to do |format|
171
- format.js
172
- end
171
+ render json: serialized_page_tree
173
172
  end
174
173
 
175
174
  # Leaves the page editing mode and unlocks the page for other users
@@ -202,10 +201,6 @@ module Alchemy
202
201
  redirect_to admin_pages_path
203
202
  end
204
203
 
205
- def sort
206
- @sorting = true
207
- end
208
-
209
204
  # Receives a JSON object representing a language tree to be ordered
210
205
  # and updates all pages in that language structure to their correct indexes
211
206
  def order
@@ -387,9 +382,11 @@ module Alchemy
387
382
  end
388
383
 
389
384
  def serialized_page_tree
390
- PageTreeSerializer.new(@page, ability: current_ability,
391
- user: current_alchemy_user,
392
- full: params[:full] == "true")
385
+ PageTreeSerializer.new(
386
+ @page,
387
+ ability: current_ability,
388
+ user: current_alchemy_user,
389
+ )
393
390
  end
394
391
 
395
392
  def load_languages_and_layouts
@@ -2,17 +2,19 @@
2
2
 
3
3
  module Alchemy
4
4
  class Api::PagesController < Api::BaseController
5
+ serialization_scope :current_ability
5
6
  before_action :load_page, only: [:show]
6
7
 
7
8
  # Returns all pages as json object
8
9
  #
9
10
  def index
10
11
  # Fix for cancancan not able to merge multiple AR scopes for logged in users
11
- if cannot? :edit_content, Alchemy::Page
12
- @pages = Alchemy::Page.accessible_by(current_ability, :index)
13
- @pages = @pages.where(language: Language.current)
12
+ if can? :edit_content, Alchemy::Page
13
+ @pages = Alchemy::Page.all
14
14
  else
15
- @pages = Language.current&.pages.presence || Alchemy::Page.none
15
+ language = Alchemy::Language.find_by(id: params[:language_id]) || Alchemy::Language.current
16
+ @pages = Alchemy::Page.accessible_by(current_ability, :index)
17
+ @pages = @pages.where(language: language)
16
18
  end
17
19
  @pages = @pages.includes(*page_includes)
18
20
  @pages = @pages.ransack(params[:q]).result
@@ -49,6 +51,14 @@ module Alchemy
49
51
  respond_with @page
50
52
  end
51
53
 
54
+ def move
55
+ @page = Page.find(params[:id])
56
+ authorize! :update, @page
57
+ target_parent_page = Page.find(params[:target_parent_id])
58
+ @page.move_to_child_with_index(target_parent_page, params[:new_position])
59
+ render json: @page, serializer: PageSerializer
60
+ end
61
+
52
62
  private
53
63
 
54
64
  def load_page
@@ -11,7 +11,8 @@ module Alchemy
11
11
  belongs_to :element, touch: true, class_name: "Alchemy::Element", inverse_of: :ingredients
12
12
  belongs_to :related_object, polymorphic: true, optional: true
13
13
 
14
- before_validation(on: :create) { self.value ||= default_value }
14
+ after_initialize :set_default_value,
15
+ if: -> { definition.key?(:default) && value.nil? }
15
16
 
16
17
  validates :type, presence: true
17
18
  validates :role, presence: true
@@ -161,6 +162,10 @@ module Alchemy
161
162
  role
162
163
  end
163
164
 
165
+ def set_default_value
166
+ self.value = default_value
167
+ end
168
+
164
169
  # Returns the default value from ingredient definition
165
170
  #
166
171
  # If the value is a symbol it gets passed through i18n
@@ -14,8 +14,14 @@ module Alchemy
14
14
  :created_at,
15
15
  :updated_at,
16
16
  :status,
17
- :url_path
17
+ :url_path,
18
+ :parent_id
18
19
 
19
20
  has_many :elements
21
+
22
+ with_options if: -> { scope.can?(:edit_content, object) } do
23
+ belongs_to :site
24
+ belongs_to :language
25
+ end
20
26
  end
21
27
  end
@@ -3,13 +3,13 @@
3
3
  module Alchemy
4
4
  class PageTreeSerializer < BaseSerializer
5
5
  def attributes
6
- {"pages" => nil}
6
+ { "pages" => nil }
7
7
  end
8
8
 
9
9
  def pages
10
10
  tree = []
11
- path = [{id: object.parent_id, children: tree}]
12
- page_list = object.self_and_descendants
11
+ path = [{ id: object.parent_id, children: tree }]
12
+ page_list = object.self_and_descendants.includes(:public_version, { language: :site })
13
13
  base_level = object.level - 1
14
14
  # Load folded pages in advance
15
15
  folded_user_pages = FoldedPage.folded_for_user(opts[:user]).pluck(:page_id)
@@ -1,4 +1,8 @@
1
1
  <%= alchemy_form_for [:admin, @page], class: 'edit_page' do |f| %>
2
+ <% unless @page.language_root? || @page.layoutpage %>
3
+ <%= f.input :parent_id, required: true, input_html: { class: 'alchemy_selectbox' } %>
4
+ <% end %>
5
+
2
6
  <div class="input check_boxes">
3
7
  <label class="control-label"><%= Alchemy.t(:page_status) %></label>
4
8
  <div class="control_group">
@@ -37,3 +41,18 @@
37
41
 
38
42
  <%= f.submit Alchemy.t(:save) %>
39
43
  <% end %>
44
+
45
+ <script>
46
+ $('#page_parent_id').alchemyPageSelect({
47
+ placeholder: "<%= Alchemy.t(:search_page) %>",
48
+ url: "<%= alchemy.api_pages_path %>",
49
+ allowClear: false,
50
+ <% if @page.parent %>
51
+ initialSelection: {
52
+ id: <%= @page.parent.id %>,
53
+ text: "<%= @page.parent.name %>",
54
+ url_path: "<%= @page.parent.url_path %>"
55
+ }
56
+ <% end %>
57
+ })
58
+ </script>
@@ -3,11 +3,7 @@
3
3
  <%= f.hidden_field(:parent_id) %>
4
4
  <% else %>
5
5
  <% @page.parent = @current_language.root_page %>
6
- <%= f.input :parent_id,
7
- collection: @current_language.pages.contentpages,
8
- label_method: :name,
9
- value_method: :id,
10
- input_html: { class: "alchemy_selectbox" } %>
6
+ <%= f.input :parent_id, as: :string, input_html: { class: 'alchemy_selectbox' } %>
11
7
  <% end %>
12
8
  <%= f.hidden_field(:language_id) %>
13
9
  <%= f.hidden_field(:layoutpage) %>
@@ -21,3 +17,18 @@
21
17
  <%= f.input :name %>
22
18
  <%= f.submit Alchemy.t(:create) %>
23
19
  <% end %>
20
+
21
+ <script>
22
+ $('input[type="text"]#page_parent_id').alchemyPageSelect({
23
+ placeholder: "<%= Alchemy.t(:search_page) %>",
24
+ url: "<%= alchemy.api_pages_path %>",
25
+ allowClear: false,
26
+ <% if @page.parent %>
27
+ initialSelection: {
28
+ id: <%= @page.parent.id %>,
29
+ text: "<%= @page.parent.name %>",
30
+ url_path: "<%= @page.parent.url_path %>"
31
+ }
32
+ <% end %>
33
+ })
34
+ </script>