katalyst-content 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +81 -7
  3. data/app/assets/builds/katalyst/content.esm.js +1004 -0
  4. data/app/assets/builds/katalyst/content.js +1004 -0
  5. data/app/assets/builds/katalyst/content.min.js +2 -0
  6. data/app/assets/builds/katalyst/content.min.js.map +1 -0
  7. data/app/assets/config/katalyst-content.js +1 -1
  8. data/app/assets/stylesheets/katalyst/content/editor/_index.scss +1 -1
  9. data/app/assets/stylesheets/katalyst/content/editor/_new-items.scss +36 -10
  10. data/app/assets/stylesheets/katalyst/content/editor/_status-bar.scss +3 -1
  11. data/app/{helpers/katalyst/content/editor/base.rb → components/katalyst/content/editor/base_component.rb} +15 -12
  12. data/app/components/katalyst/content/editor/errors_component.html.erb +12 -0
  13. data/app/components/katalyst/content/editor/errors_component.rb +15 -0
  14. data/app/components/katalyst/content/editor/item_component.html.erb +25 -0
  15. data/app/components/katalyst/content/editor/item_component.rb +28 -0
  16. data/app/components/katalyst/content/editor/new_item_component.html.erb +22 -0
  17. data/app/components/katalyst/content/editor/new_item_component.rb +52 -0
  18. data/app/{views/katalyst/content/editor/_new_items.html.erb → components/katalyst/content/editor/new_items_component.html.erb} +1 -1
  19. data/app/components/katalyst/content/editor/new_items_component.rb +20 -0
  20. data/app/{views/katalyst/content/editor/_list_item.html.erb → components/katalyst/content/editor/row_component.html.erb} +1 -1
  21. data/app/components/katalyst/content/editor/row_component.rb +13 -0
  22. data/app/{helpers/katalyst/content/editor/status_bar.rb → components/katalyst/content/editor/status_bar_component.rb} +17 -13
  23. data/app/components/katalyst/content/editor/table_component.html.erb +11 -0
  24. data/app/components/katalyst/content/editor/table_component.rb +36 -0
  25. data/app/components/katalyst/content/editor_component.html.erb +9 -0
  26. data/app/components/katalyst/content/editor_component.rb +49 -0
  27. data/app/controllers/katalyst/content/items_controller.rb +6 -3
  28. data/app/helpers/katalyst/content/editor_helper.rb +4 -48
  29. data/app/helpers/katalyst/content/frontend_helper.rb +3 -3
  30. data/app/javascript/content/application.js +35 -0
  31. data/app/{assets/javascripts/utils → javascript}/content/editor/container.js +1 -1
  32. data/app/{assets/javascripts/controllers → javascript}/content/editor/container_controller.js +3 -3
  33. data/app/{assets/javascripts/controllers → javascript}/content/editor/item_controller.js +1 -1
  34. data/app/{assets/javascripts/controllers → javascript}/content/editor/list_controller.js +12 -2
  35. data/app/models/katalyst/content/types/nodes_type.rb +2 -2
  36. data/app/views/active_storage/blobs/_blob.html.erb +1 -1
  37. data/app/views/katalyst/content/asides/_aside.html+form.erb +2 -2
  38. data/app/views/katalyst/content/columns/_column.html+form.erb +2 -2
  39. data/app/views/katalyst/content/contents/_content.html+form.erb +3 -3
  40. data/app/views/katalyst/content/figures/_figure.html+form.erb +2 -2
  41. data/app/views/katalyst/content/groups/_group.html+form.erb +2 -2
  42. data/app/views/katalyst/content/items/_item.html+form.erb +2 -2
  43. data/app/views/katalyst/content/items/update.turbo_stream.erb +2 -2
  44. data/app/views/katalyst/content/sections/_section.html+form.erb +2 -2
  45. data/config/importmap.rb +1 -6
  46. data/lib/katalyst/content.rb +0 -1
  47. metadata +61 -24
  48. data/app/helpers/katalyst/content/editor/container.rb +0 -43
  49. data/app/helpers/katalyst/content/editor/errors.rb +0 -24
  50. data/app/helpers/katalyst/content/editor/item.rb +0 -67
  51. data/app/helpers/katalyst/content/editor/list.rb +0 -41
  52. data/app/helpers/katalyst/content/editor/new_item.rb +0 -53
  53. data/app/views/katalyst/content/editor/_item.html.erb +0 -14
  54. data/app/views/katalyst/content/editor/_new_item.html.erb +0 -3
  55. data/lib/katalyst/content/version.rb +0 -7
  56. /data/app/{assets/javascripts/utils → javascript}/content/editor/item.js +0 -0
  57. /data/app/{assets/javascripts/controllers → javascript}/content/editor/new_item_controller.js +0 -0
  58. /data/app/{assets/javascripts/utils/content/editor/rules-engine.js → javascript/content/editor/rules_engine.js} +0 -0
  59. /data/app/{assets/javascripts/controllers → javascript}/content/editor/status_bar_controller.js +0 -0
  60. /data/app/{assets/javascripts/controllers → javascript}/content/editor/trix_controller.js +0 -0
@@ -0,0 +1,9 @@
1
+ <%= form_with(model: container, url:, scope:, **html_attributes) do %>
2
+ <%# Hidden input ensures that if the container is empty then the controller receives an empty array. %>
3
+ <input type="hidden" name="<%= attributes_scope %>[id]">
4
+ <%= render Katalyst::Content::Editor::ErrorsComponent.new(container:) %>
5
+
6
+ <%= render Katalyst::Content::Editor::TableComponent.new(container:) do |list| %>
7
+ <%= container.draft_items.each { |item| list.with_item(item) } %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Katalyst
4
+ module Content
5
+ class EditorComponent < Editor::BaseComponent
6
+ ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
7
+ submit->#{CONTAINER_CONTROLLER}#reindex
8
+ content:drop->#{CONTAINER_CONTROLLER}#drop
9
+ content:reindex->#{CONTAINER_CONTROLLER}#reindex
10
+ content:reset->#{CONTAINER_CONTROLLER}#reset
11
+ ACTIONS
12
+
13
+ attr_reader :url, :scope
14
+
15
+ def initialize(container:, url: [:admin, container], scope: :container, **)
16
+ super(container:, **)
17
+
18
+ @url = url
19
+ @scope = scope
20
+ end
21
+
22
+ def status_bar
23
+ Editor::StatusBarComponent.new(container:)
24
+ end
25
+
26
+ def new_items
27
+ Editor::NewItemsComponent.new(container:)
28
+ end
29
+
30
+ def item(item:)
31
+ Editor::ItemComponent.new(container:, item:)
32
+ end
33
+
34
+ def errors
35
+ Editor::ErrorsComponent.new(container:)
36
+ end
37
+
38
+ def default_html_attributes
39
+ {
40
+ id: container_form_id,
41
+ data: {
42
+ controller: CONTAINER_CONTROLLER,
43
+ action: ACTIONS,
44
+ },
45
+ }
46
+ end
47
+ end
48
+ end
49
+ end
@@ -20,9 +20,10 @@ module Katalyst
20
20
  def create
21
21
  @item = item = @container.items.build(item_params)
22
22
  if item.save
23
- render :update, locals: { item: item, previous: @container.items.build(type: item.type) }
23
+ editor = Katalyst::Content::EditorComponent.new(container: @item.container, item: @item)
24
+ render :update, locals: { editor:, item:, previous: @container.items.build(type: item.type) }
24
25
  else
25
- render :new, status: :unprocessable_entity, locals: { item: item }
26
+ render :new, status: :unprocessable_entity, locals: { item: }
26
27
  end
27
28
  end
28
29
 
@@ -32,7 +33,9 @@ module Katalyst
32
33
  if @item.valid?
33
34
  previous = @item
34
35
  @item = @item.dup.tap(&:save!)
35
- render locals: { item: @item, previous: previous }
36
+ editor = Katalyst::Content::EditorComponent.new(container: @item.container, item: @item)
37
+
38
+ render locals: { editor:, item: @item, previous: }
36
39
  else
37
40
  render :edit, status: :unprocessable_entity, locals: { item: @item }
38
41
  end
@@ -3,60 +3,16 @@
3
3
  module Katalyst
4
4
  module Content
5
5
  module EditorHelper
6
- def content_editor_new_items(container:)
7
- Katalyst::Content.config.items.map do |item_class|
8
- item_class = item_class.safe_constantize if item_class.is_a?(String)
9
- item_class.new(container: container)
10
- end
11
- end
12
-
13
- def content_editor_container(container:, **options, &block)
14
- Editor::Container.new(self, container).build(options, &block)
15
- end
16
-
17
- def content_editor_list(container:, items: container.draft_items, **options)
18
- Editor::List.new(self, container).build(options) do |list|
19
- list.items(*items) if items.present?
20
- end
21
- end
22
-
23
- # Generate items without their list wrapper, similar to form_with/fields
24
- def content_editor_items(item:, container: item.container)
25
- Editor::List.new(self, container).items(item)
26
- end
27
-
28
- # Generate a turbo stream fragment that will show structural errors to the user.
29
- def content_editor_errors(container:, **options)
30
- turbo_stream.replace(dom_id(container, :errors),
31
- Editor::Errors.new(self, container).build(**options))
32
- end
6
+ using Katalyst::HtmlAttributes::HasHtmlAttributes
33
7
 
34
- # Gene
35
- def content_editor_new_item(item:, container: item.container, **options, &block)
36
- Editor::NewItem.new(self, container).build(item, **options, &block)
37
- end
38
-
39
- def content_editor_item(item:, container: item.container, **options, &block)
40
- Editor::Item.new(self, container).build(item, **options, &block)
41
- end
42
-
43
- def content_editor_status_bar(container:, **options)
44
- Editor::StatusBar.new(self, container).build(**options)
45
- end
46
-
47
- def content_editor_rich_text_options(options = {})
48
- defaults = {
8
+ def content_editor_rich_text_attributes(attributes = {})
9
+ {
49
10
  data: {
50
11
  direct_upload_url: direct_uploads_url,
51
12
  controller: "content--editor--trix",
52
13
  action: "trix-initialize->content--editor--trix#trixInitialize",
53
14
  },
54
- }
55
- defaults.deep_merge(options)
56
- end
57
-
58
- def content_editor_image_field(...)
59
- Editor::ImageField.new(self, item.container).build(...)
15
+ }.merge_html(attributes)
60
16
  end
61
17
 
62
18
  # When rendering item forms do not include the controller namespace prefix (katalyst/content)
@@ -51,9 +51,9 @@ module Katalyst
51
51
  self.item = item
52
52
  end
53
53
 
54
- def render(**options, &block)
55
- content_tag tag, **default_options(**options) do
56
- content_tag :div, &block
54
+ def render(**, &)
55
+ content_tag tag, **default_options(**) do
56
+ content_tag(:div, &)
57
57
  end
58
58
  end
59
59
 
@@ -0,0 +1,35 @@
1
+ import ContainerController from "./editor/container_controller";
2
+ import ItemController from "./editor/item_controller";
3
+ import ListController from "./editor/list_controller";
4
+ import NewItemController from "./editor/new_item_controller";
5
+ import StatusBarController from "./editor/status_bar_controller";
6
+ import TrixController from "./editor/trix_controller";
7
+
8
+ const Definitions = [
9
+ {
10
+ identifier: "content--editor--container",
11
+ controllerConstructor: ContainerController,
12
+ },
13
+ {
14
+ identifier: "content--editor--item",
15
+ controllerConstructor: ItemController,
16
+ },
17
+ {
18
+ identifier: "content--editor--list",
19
+ controllerConstructor: ListController,
20
+ },
21
+ {
22
+ identifier: "content--editor--new-item",
23
+ controllerConstructor: NewItemController,
24
+ },
25
+ {
26
+ identifier: "content--editor--status-bar",
27
+ controllerConstructor: StatusBarController,
28
+ },
29
+ {
30
+ identifier: "content--editor--trix",
31
+ controllerConstructor: TrixController,
32
+ },
33
+ ];
34
+
35
+ export { Definitions as default };
@@ -1,4 +1,4 @@
1
- import Item from "utils/content/editor/item";
1
+ import Item from "./item";
2
2
 
3
3
  /**
4
4
  * @param nodes {NodeList}
@@ -1,8 +1,8 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
2
 
3
- import Item from "utils/content/editor/item";
4
- import Container from "utils/content/editor/container";
5
- import RulesEngine from "utils/content/editor/rules-engine";
3
+ import Item from "./item";
4
+ import Container from "./container";
5
+ import RulesEngine from "./rules_engine";
6
6
 
7
7
  export default class ContainerController extends Controller {
8
8
  static targets = ["container"];
@@ -1,5 +1,5 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
- import Item from "utils/content/editor/item";
2
+ import Item from "./item";
3
3
 
4
4
  export default class ItemController extends Controller {
5
5
  get item() {
@@ -82,7 +82,10 @@ export default class ListController extends Controller {
82
82
  }
83
83
 
84
84
  dropTarget(e) {
85
- return e && e.closest("[data-controller='content--editor--list'] > *");
85
+ return (
86
+ e.closest("[data-controller='content--editor--list'] > *") ||
87
+ e.closest("[data-controller='content--editor--list']")
88
+ );
86
89
  }
87
90
 
88
91
  reindex() {
@@ -95,7 +98,10 @@ export default class ListController extends Controller {
95
98
  }
96
99
 
97
100
  function swap(target, item) {
98
- if (target && target !== item) {
101
+ if (!target) return;
102
+ if (target === item) return;
103
+
104
+ if (target.nodeName === "LI") {
99
105
  const positionComparison = target.compareDocumentPosition(item);
100
106
  if (positionComparison & Node.DOCUMENT_POSITION_FOLLOWING) {
101
107
  target.insertAdjacentElement("beforebegin", item);
@@ -103,4 +109,8 @@ function swap(target, item) {
103
109
  target.insertAdjacentElement("afterend", item);
104
110
  }
105
111
  }
112
+
113
+ if (target.nodeName === "OL") {
114
+ target.appendChild(item);
115
+ }
106
116
  }
@@ -27,13 +27,13 @@ module Katalyst
27
27
  # Deserialize a params-style array, e.g. "0" => { ... }
28
28
  def deserialize_params(value)
29
29
  value.map do |index, attributes|
30
- Node.new(index: index, **attributes)
30
+ Node.new(index:, **attributes)
31
31
  end.select(&:id).sort_by(&:index)
32
32
  end
33
33
 
34
34
  def deserialize_array(value)
35
35
  value.map.with_index do |attributes, index|
36
- Node.new(index: index, **attributes)
36
+ Node.new(index:, **attributes)
37
37
  end.select(&:id).sort_by(&:index)
38
38
  end
39
39
  end
@@ -1,6 +1,6 @@
1
1
  <figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
2
2
  <% if blob.representable? %>
3
- <%= image_tag main_app.url_for(blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ])) %>
3
+ <%= image_tag main_app.url_for(blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [800, 600] : [1024, 768])) %>
4
4
  <% end %>
5
5
 
6
6
  <figcaption class="attachment__caption">
@@ -1,6 +1,6 @@
1
1
  <%= form_with model: aside, scope: :item, url: path do |form| %>
2
- <%= render "hidden_fields", form: form %>
3
- <%= render "form_errors", form: form %>
2
+ <%= render "hidden_fields", form: %>
3
+ <%= render "form_errors", form: %>
4
4
 
5
5
  <div class="field">
6
6
  <%= form.label :heading %>
@@ -1,6 +1,6 @@
1
1
  <%= form_with model: column, scope: :item, url: path do |form| %>
2
- <%= render "hidden_fields", form: form %>
3
- <%= render "form_errors", form: form %>
2
+ <%= render "hidden_fields", form: %>
3
+ <%= render "form_errors", form: %>
4
4
 
5
5
  <div class="field">
6
6
  <%= form.label :heading %>
@@ -1,6 +1,6 @@
1
1
  <%= form_with model: content, scope: :item, url: path do |form| %>
2
- <%= render "hidden_fields", form: form %>
3
- <%= render "form_errors", form: form %>
2
+ <%= render "hidden_fields", form: %>
3
+ <%= render "form_errors", form: %>
4
4
 
5
5
  <div class="field">
6
6
  <%= form.label :heading %>
@@ -24,7 +24,7 @@
24
24
 
25
25
  <div class="field">
26
26
  <%= form.label :content %>
27
- <%= form.rich_text_area :content, content_editor_rich_text_options %>
27
+ <%= form.rich_text_area :content, content_editor_rich_text_attributes %>
28
28
  </div>
29
29
 
30
30
  <%= form.submit "Done" %>
@@ -1,6 +1,6 @@
1
1
  <%= form_with model: figure, scope: :item, url: path do |form| %>
2
- <%= render "hidden_fields", form: form %>
3
- <%= render "form_errors", form: form %>
2
+ <%= render "hidden_fields", form: %>
3
+ <%= render "form_errors", form: %>
4
4
 
5
5
  <div class="field">
6
6
  <%= form.label :image %>
@@ -1,6 +1,6 @@
1
1
  <%= form_with model: group, scope: :item, url: path do |form| %>
2
- <%= render "hidden_fields", form: form %>
3
- <%= render "form_errors", form: form %>
2
+ <%= render "hidden_fields", form: %>
3
+ <%= render "form_errors", form: %>
4
4
 
5
5
  <div class="field">
6
6
  <%= form.label :heading %>
@@ -1,6 +1,6 @@
1
1
  <%= form_with model: item, scope: :item, url: path do |form| %>
2
- <%= render "hidden_fields", form: form %>
3
- <%= render "form_errors", form: form %>
2
+ <%= render "hidden_fields", form: %>
3
+ <%= render "form_errors", form: %>
4
4
 
5
5
  <div class="field">
6
6
  <%= form.label :heading %>
@@ -1,7 +1,7 @@
1
1
  <%= turbo_stream.replace "content--editor--item-frame" do %>
2
- <%= render "katalyst/content/editor/new_items", container: item.container %>
2
+ <%= render editor.new_items %>
3
3
  <% end %>
4
4
 
5
5
  <%= turbo_stream.replace dom_id(previous) do %>
6
- <%= render "katalyst/content/editor/item", item: item %>
6
+ <%= render editor.item(item:) %>
7
7
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <%= form_with model: section, scope: :item, url: path do |form| %>
2
- <%= render "hidden_fields", form: form %>
3
- <%= render "form_errors", form: form %>
2
+ <%= render "hidden_fields", form: %>
3
+ <%= render "form_errors", form: %>
4
4
 
5
5
  <div class="field">
6
6
  <%= form.label :heading %>
data/config/importmap.rb CHANGED
@@ -1,8 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- pin "trix"
4
- pin "@rails/actiontext", to: "actiontext.js"
5
-
6
- pin_all_from Katalyst::Content::Engine.root.join("app/assets/javascripts"),
7
- # preload in tests so that we don't start clicking before controllers load
8
- preload: Rails.env.test?
3
+ pin "@katalyst/content", to: "katalyst/content.js", preload: true
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "katalyst/content/config"
4
4
  require "katalyst/content/engine"
5
- require "katalyst/content/version"
6
5
 
7
6
  module Katalyst
8
7
  module Content
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-content
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-14 00:00:00.000000000 Z
11
+ date: 2023-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_storage_validations
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: katalyst-html-attributes
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: view_component
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description:
28
56
  email:
29
57
  - developers@katalyst.com.au
@@ -33,16 +61,11 @@ extra_rdoc_files: []
33
61
  files:
34
62
  - LICENSE.txt
35
63
  - README.md
64
+ - app/assets/builds/katalyst/content.esm.js
65
+ - app/assets/builds/katalyst/content.js
66
+ - app/assets/builds/katalyst/content.min.js
67
+ - app/assets/builds/katalyst/content.min.js.map
36
68
  - app/assets/config/katalyst-content.js
37
- - app/assets/javascripts/controllers/content/editor/container_controller.js
38
- - app/assets/javascripts/controllers/content/editor/item_controller.js
39
- - app/assets/javascripts/controllers/content/editor/list_controller.js
40
- - app/assets/javascripts/controllers/content/editor/new_item_controller.js
41
- - app/assets/javascripts/controllers/content/editor/status_bar_controller.js
42
- - app/assets/javascripts/controllers/content/editor/trix_controller.js
43
- - app/assets/javascripts/utils/content/editor/container.js
44
- - app/assets/javascripts/utils/content/editor/item.js
45
- - app/assets/javascripts/utils/content/editor/rules-engine.js
46
69
  - app/assets/stylesheets/katalyst/content/_index.scss
47
70
  - app/assets/stylesheets/katalyst/content/editor/_figure.scss
48
71
  - app/assets/stylesheets/katalyst/content/editor/_icon.scss
@@ -52,18 +75,37 @@ files:
52
75
  - app/assets/stylesheets/katalyst/content/editor/_new-items.scss
53
76
  - app/assets/stylesheets/katalyst/content/editor/_status-bar.scss
54
77
  - app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss
78
+ - app/components/katalyst/content/editor/base_component.rb
79
+ - app/components/katalyst/content/editor/errors_component.html.erb
80
+ - app/components/katalyst/content/editor/errors_component.rb
81
+ - app/components/katalyst/content/editor/item_component.html.erb
82
+ - app/components/katalyst/content/editor/item_component.rb
83
+ - app/components/katalyst/content/editor/new_item_component.html.erb
84
+ - app/components/katalyst/content/editor/new_item_component.rb
85
+ - app/components/katalyst/content/editor/new_items_component.html.erb
86
+ - app/components/katalyst/content/editor/new_items_component.rb
87
+ - app/components/katalyst/content/editor/row_component.html.erb
88
+ - app/components/katalyst/content/editor/row_component.rb
89
+ - app/components/katalyst/content/editor/status_bar_component.rb
90
+ - app/components/katalyst/content/editor/table_component.html.erb
91
+ - app/components/katalyst/content/editor/table_component.rb
92
+ - app/components/katalyst/content/editor_component.html.erb
93
+ - app/components/katalyst/content/editor_component.rb
55
94
  - app/controllers/katalyst/content/application_controller.rb
56
95
  - app/controllers/katalyst/content/direct_uploads_controller.rb
57
96
  - app/controllers/katalyst/content/items_controller.rb
58
- - app/helpers/katalyst/content/editor/base.rb
59
- - app/helpers/katalyst/content/editor/container.rb
60
- - app/helpers/katalyst/content/editor/errors.rb
61
- - app/helpers/katalyst/content/editor/item.rb
62
- - app/helpers/katalyst/content/editor/list.rb
63
- - app/helpers/katalyst/content/editor/new_item.rb
64
- - app/helpers/katalyst/content/editor/status_bar.rb
65
97
  - app/helpers/katalyst/content/editor_helper.rb
66
98
  - app/helpers/katalyst/content/frontend_helper.rb
99
+ - app/javascript/content/application.js
100
+ - app/javascript/content/editor/container.js
101
+ - app/javascript/content/editor/container_controller.js
102
+ - app/javascript/content/editor/item.js
103
+ - app/javascript/content/editor/item_controller.js
104
+ - app/javascript/content/editor/list_controller.js
105
+ - app/javascript/content/editor/new_item_controller.js
106
+ - app/javascript/content/editor/rules_engine.js
107
+ - app/javascript/content/editor/status_bar_controller.js
108
+ - app/javascript/content/editor/trix_controller.js
67
109
  - app/models/concerns/katalyst/content/container.rb
68
110
  - app/models/concerns/katalyst/content/garbage_collection.rb
69
111
  - app/models/concerns/katalyst/content/has_tree.rb
@@ -85,10 +127,6 @@ files:
85
127
  - app/views/katalyst/content/columns/_column.html.erb
86
128
  - app/views/katalyst/content/contents/_content.html+form.erb
87
129
  - app/views/katalyst/content/contents/_content.html.erb
88
- - app/views/katalyst/content/editor/_item.html.erb
89
- - app/views/katalyst/content/editor/_list_item.html.erb
90
- - app/views/katalyst/content/editor/_new_item.html.erb
91
- - app/views/katalyst/content/editor/_new_items.html.erb
92
130
  - app/views/katalyst/content/figures/_figure.html+form.erb
93
131
  - app/views/katalyst/content/figures/_figure.html.erb
94
132
  - app/views/katalyst/content/groups/_group.html+form.erb
@@ -112,7 +150,6 @@ files:
112
150
  - lib/katalyst/content.rb
113
151
  - lib/katalyst/content/config.rb
114
152
  - lib/katalyst/content/engine.rb
115
- - lib/katalyst/content/version.rb
116
153
  - spec/factories/katalyst/content/items.rb
117
154
  homepage: https://github.com/katalyst/content
118
155
  licenses:
@@ -127,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
164
  requirements:
128
165
  - - ">="
129
166
  - !ruby/object:Gem::Version
130
- version: '3.0'
167
+ version: '3.2'
131
168
  required_rubygems_version: !ruby/object:Gem::Requirement
132
169
  requirements:
133
170
  - - ">="
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Content
5
- module Editor
6
- class Container < Base
7
- ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
8
- submit->#{CONTAINER_CONTROLLER}#reindex
9
- content:drop->#{CONTAINER_CONTROLLER}#drop
10
- content:reindex->#{CONTAINER_CONTROLLER}#reindex
11
- content:reset->#{CONTAINER_CONTROLLER}#reset
12
- ACTIONS
13
-
14
- def build(options)
15
- form_with(model: container, **default_options(id: container_form_id, **options)) do |form|
16
- concat hidden_input
17
- concat errors
18
- concat(capture { yield form })
19
- end
20
- end
21
-
22
- private
23
-
24
- def errors
25
- Editor::Errors.new(self, container).build
26
- end
27
-
28
- # Hidden input ensures that if the container is empty then the controller
29
- # receives an empty array.
30
- def hidden_input
31
- tag.input(type: "hidden", name: "#{attributes_scope}[id]")
32
- end
33
-
34
- def default_options(options)
35
- add_option(options, :data, :controller, CONTAINER_CONTROLLER)
36
- add_option(options, :data, :action, ACTIONS)
37
-
38
- options
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Katalyst
4
- module Content
5
- module Editor
6
- class Errors < Base
7
- def build(**options)
8
- turbo_frame_tag dom_id(container, :errors) do
9
- next unless container.errors.any?
10
-
11
- tag.div(class: "content-errors", **options) do
12
- tag.h2("Errors in content") +
13
- tag.ul(class: "errors") do
14
- container.errors.each do |error|
15
- concat(tag.li(error.message))
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end