iron-cms 0.19.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -8
  3. data/app/assets/builds/iron.css +2125 -2101
  4. data/app/assets/tailwind/iron/application.css +2 -0
  5. data/app/assets/tailwind/iron/components/field-list.css +35 -0
  6. data/app/assets/tailwind/iron/components/translation-notice.css +39 -0
  7. data/app/assets/tailwind/iron/lexxy.css +154 -47
  8. data/app/controllers/iron/blocks_controller.rb +8 -1
  9. data/app/controllers/iron/entries/content_copies_controller.rb +36 -0
  10. data/app/controllers/iron/entries_controller.rb +2 -1
  11. data/app/controllers/iron/references_controller.rb +7 -0
  12. data/app/helpers/iron/entries_helper.rb +24 -0
  13. data/app/helpers/iron/fields_helper.rb +21 -0
  14. data/app/models/iron/entry/titlable.rb +29 -11
  15. data/app/models/iron/entry/translatable.rb +53 -0
  16. data/app/models/iron/entry.rb +1 -1
  17. data/app/models/iron/field.rb +14 -0
  18. data/app/models/iron/fields/block.rb +8 -0
  19. data/app/models/iron/fields/block_list.rb +14 -0
  20. data/app/models/iron/fields/boolean.rb +4 -0
  21. data/app/models/iron/fields/file.rb +4 -0
  22. data/app/models/iron/fields/reference_list.rb +8 -0
  23. data/app/models/iron/fields/rich_text_area.rb +10 -0
  24. data/app/views/iron/entries/_entry.html.erb +1 -1
  25. data/app/views/iron/entries/_entry_option.html.erb +4 -3
  26. data/app/views/iron/entries/_translation_notice.html.erb +32 -0
  27. data/app/views/iron/entries/edit.html.erb +14 -4
  28. data/app/views/iron/entries/entry.html.erb +8 -4
  29. data/app/views/iron/entries/fields/_block_list.html.erb +6 -22
  30. data/app/views/iron/entries/fields/_reference.html.erb +1 -1
  31. data/app/views/iron/entries/fields/_reference_item.html.erb +2 -2
  32. data/app/views/iron/entries/fields/_reference_list.html.erb +12 -3
  33. data/app/views/iron/entries/fields/block_list/_empty_state.html.erb +49 -0
  34. data/app/views/iron/entries/fields/block_list/_menu.html.erb +14 -0
  35. data/app/views/iron/entries/search.html.erb +3 -1
  36. data/app/views/iron/home/_recent_activity.html.erb +1 -1
  37. data/config/locales/en.yml +32 -0
  38. data/config/locales/it.yml +32 -0
  39. data/config/routes.rb +10 -0
  40. data/lib/iron/version.rb +1 -1
  41. metadata +18 -5
@@ -29,6 +29,17 @@ module Iron
29
29
  type.demodulize.underscore
30
30
  end
31
31
 
32
+ def content?
33
+ filled?
34
+ end
35
+
36
+ def copy_to(locale)
37
+ dup.tap do |copy|
38
+ copy.locale = locale
39
+ copy_content_into(copy)
40
+ end
41
+ end
42
+
32
43
  def searchable_text
33
44
  nil
34
45
  end
@@ -47,6 +58,9 @@ module Iron
47
58
 
48
59
  private
49
60
 
61
+ def copy_content_into(copy)
62
+ end
63
+
50
64
  def add_content_error(message)
51
65
  (@content_errors ||= []) << message
52
66
  end
@@ -45,6 +45,10 @@ module Iron
45
45
  end
46
46
  end
47
47
 
48
+ def content?
49
+ fields.any?(&:content?)
50
+ end
51
+
48
52
  def find_or_build_field(definition)
49
53
  fields.find { |f| f.definition == definition } || fields.build(type: definition.field_type, entry:, definition: definition, locale:)
50
54
  end
@@ -96,6 +100,10 @@ module Iron
96
100
 
97
101
  private
98
102
 
103
+ def copy_content_into(copy)
104
+ fields.each { |field| copy.fields << field.copy_to(copy.locale) }
105
+ end
106
+
99
107
  def export_nested_fields
100
108
  fields.to_h { |f| [ f.definition.handle, f.export_value ] }
101
109
  end
@@ -44,6 +44,16 @@ module Iron
44
44
  end
45
45
  end
46
46
 
47
+ def content?
48
+ blocks.any?
49
+ end
50
+
51
+ def counterpart_with_blocks
52
+ if parent.nil?
53
+ entry.fields.find { |field| field.definition_id == definition_id && field.definition_type == definition_type && field.locale_id != locale_id && field.parent_id.nil? && field.content? }
54
+ end
55
+ end
56
+
47
57
  def value
48
58
  blocks.map(&:value)
49
59
  end
@@ -58,6 +68,10 @@ module Iron
58
68
 
59
69
  private
60
70
 
71
+ def copy_content_into(copy)
72
+ blocks.each { |block| copy.blocks << block.copy_to(copy.locale) }
73
+ end
74
+
61
75
  def resolve_block_definition(block_data)
62
76
  unless block_data.is_a?(Hash)
63
77
  add_content_error("must contain block objects")
@@ -4,6 +4,10 @@ module Iron
4
4
  self.value_boolean = value
5
5
  end
6
6
 
7
+ def content?
8
+ value_boolean?
9
+ end
10
+
7
11
  def value
8
12
  value_boolean
9
13
  end
@@ -41,6 +41,10 @@ module Iron
41
41
 
42
42
  private
43
43
 
44
+ def copy_content_into(copy)
45
+ copy.file.attach(file.blob) if file.attached?
46
+ end
47
+
44
48
  def export_attachment_path
45
49
  "#{entry.id}/#{file.blob.key}_#{file.blob.filename}"
46
50
  end
@@ -22,6 +22,10 @@ module Iron
22
22
  end
23
23
  end
24
24
 
25
+ def content?
26
+ references.any?
27
+ end
28
+
25
29
  def value
26
30
  references.map do |reference|
27
31
  OpenStruct.new(
@@ -37,6 +41,10 @@ module Iron
37
41
 
38
42
  private
39
43
 
44
+ def copy_content_into(copy)
45
+ references.each { |reference| copy.references.build(entry: reference.entry, rank: reference.rank) }
46
+ end
47
+
40
48
  def supported_content_type?(referenced)
41
49
  return true if definition.supported_content_types.empty?
42
50
 
@@ -2,6 +2,8 @@ module Iron
2
2
  class Fields::RichTextArea < Field
3
3
  include ActionView::Helpers::TagHelper
4
4
 
5
+ NON_TEXT_CONTENT = "action-text-attachment, img, picture, video, audio, iframe, embed, object, hr"
6
+
5
7
  has_rich_text :rich_text
6
8
 
7
9
  def content_value=(value)
@@ -10,6 +12,10 @@ module Iron
10
12
 
11
13
  def filled? = rich_text&.body.present?
12
14
 
15
+ def content?
16
+ filled? && (rich_text.body.fragment.source.text.present? || rich_text.body.fragment.find_all(NON_TEXT_CONTENT).any?)
17
+ end
18
+
13
19
  def searchable_text
14
20
  rich_text&.to_plain_text
15
21
  end
@@ -38,6 +44,10 @@ module Iron
38
44
 
39
45
  private
40
46
 
47
+ def copy_content_into(copy)
48
+ copy.rich_text = rich_text.body if filled?
49
+ end
50
+
41
51
  def export_attachment_tag(attachment)
42
52
  case attachable = attachment.attachable
43
53
  when ActiveStorage::Blob
@@ -2,7 +2,7 @@
2
2
 
3
3
  <div id="<%= dom_id entry %>" class="card-item flex items-center justify-between gap-4">
4
4
  <div class="min-w-0">
5
- <%= link_to entry.title, edit_entry_path(entry), class: "card-link block text-sm font-medium text-stone-900 dark:text-white truncate" %>
5
+ <%= link_to entry.display_title, edit_entry_path(entry, locale: Iron::Current.locale.code), class: "card-link block text-sm font-medium text-stone-900 dark:text-white truncate" %>
6
6
  <span class="text-xs text-stone-400 dark:text-stone-500">
7
7
  <%= t("iron.shared.time_ago", time: time_ago_in_words(entry.updated_at)) %>
8
8
  </span>
@@ -1,17 +1,18 @@
1
- <%# locals: (entry:, reference_list_dom_id:, form_field_name:) -%>
1
+ <%# locals: (entry:, reference_list_dom_id:, form_field_name:, locale:) -%>
2
2
 
3
3
  <div id="<%= dom_id entry %>" class="relative">
4
4
  <%= link_to new_reference_path(
5
5
  reference_list_dom_id:,
6
6
  form_field_name:,
7
- entry_id: entry
7
+ entry_id: entry,
8
+ locale: locale.code
8
9
  ),
9
10
  data: { turbo_stream: true },
10
11
  class: "block px-2 py-2 hover:bg-stone-50 dark:hover:bg-stone-700/50 transition-colors rounded-lg" do %>
11
12
  <div class="flex items-start justify-between gap-4 pr-6">
12
13
  <div class="flex flex-col sm:flex-row sm:items-center sm:gap-8 min-w-0 flex-1">
13
14
  <div class="flex items-center gap-3 shrink-0">
14
- <h3 class="text-base font-semibold text-stone-900 dark:text-white truncate"><%= entry.title %></h3>
15
+ <h3 class="text-base font-semibold text-stone-900 dark:text-white truncate"><%= entry.display_title %></h3>
15
16
  </div>
16
17
  </div>
17
18
  </div>
@@ -0,0 +1,32 @@
1
+ <%# locals: (entry:, locale:) -%>
2
+
3
+ <% source = entry.written_locales.first %>
4
+
5
+ <section class="translation-notice" aria-labelledby="translation_notice_title">
6
+ <div class="translation-notice-icon">
7
+ <%= icon "languages", class: "size-5" %>
8
+ </div>
9
+
10
+ <div class="min-w-0 flex-1 basis-80">
11
+ <h2 id="translation_notice_title" class="translation-notice-title"><%= t(".title", target: locale.name) %></h2>
12
+ <p class="translation-notice-description"><%= t(".description", source: source.name, target: locale.name) %></p>
13
+
14
+ <div class="translation-notice-actions">
15
+ <% if Iron::Current.user.can_write? %>
16
+ <%= button_to entry_content_copy_path(entry), params: { from: source.code, to: locale.code }, class: "button-primary", form_class: "translation-notice-copy" do %>
17
+ <%= icon "copy", class: "size-4" %>
18
+ <%= t(".copy", source: source.name) %>
19
+ <% end %>
20
+ <% end %>
21
+
22
+ <%= link_to entry_editor_path(entry, locale: source), class: "button-secondary" do %>
23
+ <%= t(".switch", source: source.name) %>
24
+ <%= icon "arrow-right", class: "size-4" %>
25
+ <% end %>
26
+ </div>
27
+
28
+ <% if Iron::Current.user.can_write? %>
29
+ <p class="translation-notice-unsaved"><%= t(".unsaved_changes", source: source.name) %></p>
30
+ <% end %>
31
+ </div>
32
+ </section>
@@ -9,18 +9,20 @@
9
9
  <button type="button" class="inline-flex items-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-medium text-stone-700 shadow-xs inset-ring-1 inset-ring-stone-300 hover:bg-stone-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20">
10
10
  <%= icon "globe", class: "size-4 text-stone-500 dark:text-stone-400" %>
11
11
  <%= @locale.name %>
12
+ <%= untranslated_dot if @entry.needs_translation_into?(@locale) %>
12
13
  <%= icon "chevron-down", class: "size-4 text-stone-400 dark:text-stone-500" %>
13
14
  </button>
14
15
 
15
- <el-menu anchor="bottom end" popover class="w-40 origin-top-right rounded-md bg-white shadow-lg outline-1 outline-black/5 transition transition-discrete [--anchor-gap:--spacing(2)] data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in dark:bg-stone-800 dark:shadow-none dark:-outline-offset-1 dark:outline-white/10">
16
+ <el-menu anchor="bottom end" popover class="w-64 origin-top-right rounded-md bg-white shadow-lg outline-1 outline-black/5 transition transition-discrete [--anchor-gap:--spacing(2)] data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in dark:bg-stone-800 dark:shadow-none dark:-outline-offset-1 dark:outline-white/10">
16
17
  <div class="py-1">
17
18
  <% Iron::Locale.all.each do |locale| %>
18
19
  <%= link_to edit_entry_path(@entry, locale: locale.code),
19
- class: "group/item flex items-center px-4 py-2 text-sm #{locale.code == @locale.code ? 'text-sky-600 dark:text-sky-400 font-medium' : 'text-stone-700 dark:text-stone-300'} focus:bg-sky-100 focus:text-stone-900 focus:outline-hidden dark:focus:bg-sky-500/20 dark:focus:text-white" do %>
20
+ class: "group/item flex items-center gap-x-3 px-4 py-2 text-sm #{locale.code == @locale.code ? 'text-sky-600 dark:text-sky-400 font-medium' : 'text-stone-700 dark:text-stone-300'} focus:bg-sky-100 focus:text-stone-900 focus:outline-hidden dark:focus:bg-sky-500/20 dark:focus:text-white" do %>
20
21
  <% if locale.code == @locale.code %>
21
- <%= icon "check", class: "mr-2 size-4" %>
22
+ <%= icon "check", class: "-mr-1 size-4" %>
22
23
  <% end %>
23
24
  <%= locale.name %>
25
+ <%= locale_content_status(@entry, locale) %>
24
26
  <% end %>
25
27
  <% end %>
26
28
  </div>
@@ -49,7 +51,7 @@
49
51
  </div>
50
52
  </div>
51
53
 
52
- <h1 class="page-title-lg"><%= @entry.title %></h1>
54
+ <h1 class="page-title-lg"><%= @entry.display_title %></h1>
53
55
 
54
56
  <div class="mt-4 flex flex-wrap items-center gap-2">
55
57
  <% if @entry.creator %>
@@ -62,6 +64,12 @@
62
64
  <%= icon "clock", class: "size-3.5" %>
63
65
  <%= t("iron.shared.time_ago", time: time_ago_in_words(@entry.updated_at)) %>
64
66
  <% end %>
67
+ <% if title_source = @entry.title_borrowed_from %>
68
+ <%= badge do %>
69
+ <%= icon "languages", class: "size-3.5" %>
70
+ <%= t(".title_from", source: title_source.name) %>
71
+ <% end %>
72
+ <% end %>
65
73
  <% if @entry.content_type.web_publishing_enabled? && !@entry.route.nil? %>
66
74
  <%= link_to @entry.path, target: "_blank", rel: "noopener",
67
75
  class: "badge badge-sky" do %>
@@ -74,5 +82,7 @@
74
82
  <div class="absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-stone-200 to-transparent dark:via-stone-700"></div>
75
83
  </header>
76
84
 
85
+ <%= render "translation_notice", entry: @entry, locale: @locale if @entry.needs_translation_into?(@locale) %>
86
+
77
87
  <%= render "form", entry: @entry, locale: @locale %>
78
88
  </div>
@@ -10,18 +10,20 @@
10
10
  <button type="button" class="inline-flex items-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-medium text-stone-700 shadow-xs inset-ring-1 inset-ring-stone-300 hover:bg-stone-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20">
11
11
  <%= icon "globe", class: "size-4 text-stone-500 dark:text-stone-400" %>
12
12
  <%= @locale.name %>
13
+ <%= untranslated_dot if @entry.needs_translation_into?(@locale) %>
13
14
  <%= icon "chevron-down", class: "size-4 text-stone-400 dark:text-stone-500" %>
14
15
  </button>
15
16
 
16
- <el-menu anchor="bottom end" popover class="w-40 origin-top-right rounded-md bg-white shadow-lg outline-1 outline-black/5 transition transition-discrete [--anchor-gap:--spacing(2)] data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in dark:bg-stone-800 dark:shadow-none dark:-outline-offset-1 dark:outline-white/10">
17
+ <el-menu anchor="bottom end" popover class="w-64 origin-top-right rounded-md bg-white shadow-lg outline-1 outline-black/5 transition transition-discrete [--anchor-gap:--spacing(2)] data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in dark:bg-stone-800 dark:shadow-none dark:-outline-offset-1 dark:outline-white/10">
17
18
  <div class="py-1">
18
19
  <% Iron::Locale.all.each do |locale| %>
19
- <%= link_to content_type_entry_path(@content_type, locale: locale.code),
20
- class: "group/item flex items-center px-4 py-2 text-sm #{locale.code == @locale.code ? 'text-sky-600 dark:text-sky-400 font-medium' : 'text-stone-700 dark:text-stone-300'} focus:bg-sky-100 focus:text-stone-900 focus:outline-hidden dark:focus:bg-sky-500/20 dark:focus:text-white" do %>
20
+ <%= link_to entry_content_type_path(@content_type, locale: locale.code),
21
+ class: "group/item flex items-center gap-x-3 px-4 py-2 text-sm #{locale.code == @locale.code ? 'text-sky-600 dark:text-sky-400 font-medium' : 'text-stone-700 dark:text-stone-300'} focus:bg-sky-100 focus:text-stone-900 focus:outline-hidden dark:focus:bg-sky-500/20 dark:focus:text-white" do %>
21
22
  <% if locale.code == @locale.code %>
22
- <%= icon "check", class: "mr-2 size-4" %>
23
+ <%= icon "check", class: "-mr-1 size-4" %>
23
24
  <% end %>
24
25
  <%= locale.name %>
26
+ <%= locale_content_status(@entry, locale) %>
25
27
  <% end %>
26
28
  <% end %>
27
29
  </div>
@@ -48,5 +50,7 @@
48
50
  <div class="absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-stone-200 to-transparent dark:via-stone-700"></div>
49
51
  </header>
50
52
 
53
+ <%= render "translation_notice", entry: @entry, locale: @locale if @entry.needs_translation_into?(@locale) %>
54
+
51
55
  <%= render "form", entry: @entry, locale: @locale %>
52
56
  </div>
@@ -2,36 +2,18 @@
2
2
 
3
3
  <% block_list = field %>
4
4
 
5
- <section class="space-y-4">
5
+ <section class="field-list space-y-4">
6
6
  <div class="flex items-center justify-between">
7
7
  <h3 class="text-sm font-semibold text-stone-900 dark:text-white"><%= block_list.definition.name %></h3>
8
8
 
9
9
  <el-dropdown class="inline-block">
10
10
  <button type="button" class="inline-flex items-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-medium text-stone-700 shadow-xs inset-ring-1 inset-ring-stone-300 hover:bg-stone-50 dark:bg-white/10 dark:text-white dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20">
11
11
  <%= icon "plus", class: "size-4" %>
12
- Add Block
12
+ <%= t(".add_block") %>
13
13
  <%= icon "chevron-down", class: "size-4 text-stone-400 dark:text-stone-500" %>
14
14
  </button>
15
15
 
16
- <el-menu anchor="bottom end" popover class="w-56 origin-top-right rounded-md bg-white shadow-lg outline-1 outline-black/5 transition transition-discrete [--anchor-gap:--spacing(2)] data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in dark:bg-stone-800 dark:shadow-none dark:-outline-offset-1 dark:outline-white/10">
17
- <div class="py-1">
18
- <% block_list.definition.supported_block_definitions.each do |block_definition| %>
19
- <%= link_to new_block_path(
20
- block_list_field_definition_id: block_list.definition.id,
21
- block_definition_id: block_definition.id,
22
- locale_id: block_list.locale.id,
23
- form_field_name: builder.field_name(:blocks_attributes),
24
- ),
25
- data: {
26
- turbo_stream: true,
27
- },
28
- class: "group/item flex items-center px-4 py-2 text-sm text-stone-700 focus:bg-sky-100 focus:text-stone-900 focus:outline-hidden dark:text-stone-300 dark:focus:bg-sky-500/20 dark:focus:text-white" do %>
29
- <%= icon "plus", class: "mr-3 size-5 text-stone-400 group-focus/item:text-sky-600 dark:text-stone-500 dark:group-focus/item:text-sky-400" %>
30
- <%= block_definition.name %>
31
- <% end %>
32
- <% end %>
33
- </div>
34
- </el-menu>
16
+ <%= render "iron/entries/fields/block_list/menu", block_list:, builder:, block_definitions: block_list.definition.supported_block_definitions %>
35
17
  </el-dropdown>
36
18
  </div>
37
19
 
@@ -44,7 +26,7 @@
44
26
 
45
27
  <div
46
28
  id="<%= dom_id(block_list.definition) %>"
47
- class="space-y-3"
29
+ class="field-list-items space-y-3"
48
30
  data-controller="sortable-list"
49
31
  >
50
32
  <% block_list.blocks.each do |block| %>
@@ -53,4 +35,6 @@
53
35
  <% end %>
54
36
  <% end %>
55
37
  </div>
38
+
39
+ <%= render "iron/entries/fields/block_list/empty_state", block_list:, builder: %>
56
40
  </section>
@@ -8,6 +8,6 @@
8
8
 
9
9
  <%= render "iron/entries/fields/field_label", builder: builder, field: field, attribute: :referenced_entry_id %>
10
10
  <% entries = Iron::Entry.with_content_type(field.definition.supported_content_types.pluck(:id)) %>
11
- <%= builder.collection_select :referenced_entry_id, entries, :id, :title, { include_blank: "Select an entry" } %>
11
+ <%= builder.collection_select :referenced_entry_id, entries, :id, :display_title, { include_blank: "Select an entry" } %>
12
12
  <%= render "iron/entries/fields/field_errors", field: field %>
13
13
  </div>
@@ -4,7 +4,7 @@
4
4
  class="group reference-item"
5
5
  data-sortable-list-target="item"
6
6
  >
7
- <%= builder.check_box :_destroy, class: "destroy hidden", data: { destroy: "" } %>
7
+ <%= builder.check_box :_destroy, class: "destroy hidden", unstyled: true, data: { destroy: "" } %>
8
8
  <%= builder.hidden_field :rank, data: { sortable_list_target: "rank" } %>
9
9
  <%= builder.hidden_field :entry_id %>
10
10
 
@@ -23,7 +23,7 @@
23
23
 
24
24
  <div class="flex-1 min-w-0">
25
25
  <span class="reference-title">
26
- <%= reference.entry.title %>
26
+ <%= reference.entry.display_title %>
27
27
  </span>
28
28
  </div>
29
29
 
@@ -3,7 +3,7 @@
3
3
  <% reference_list = field %>
4
4
  <% reference_list_dom_id = dom_id(reference_list, unique_id) %>
5
5
 
6
- <section class="space-y-4">
6
+ <section class="field-list space-y-4">
7
7
  <div class="flex items-center justify-between">
8
8
  <h3 class="text-sm font-semibold text-stone-900 dark:text-white">
9
9
  <%= reference_list.definition.name %>
@@ -12,13 +12,14 @@
12
12
  <% picker_id = "picker_#{reference_list_dom_id}" %>
13
13
  <button type="button" class="button-secondary button-sm" popovertarget="<%= picker_id %>">
14
14
  <%= icon "plus", class: "size-4" %>
15
- Add
15
+ <%= t(".add") %>
16
16
  </button>
17
17
  <div id="<%= picker_id %>" popover class="rounded-lg overflow-hidden mt-2 bg-stone-800/90 backdrop-blur-xs shadow-sm w-sm [position-area:bottom_span-right]">
18
18
  <%= turbo_frame_tag "entries_picker", src: entries_search_path(
19
19
  reference_list_field_definition_id: reference_list.definition.id,
20
20
  reference_list_dom_id: reference_list_dom_id,
21
21
  form_field_name: builder.field_name(:references_attributes),
22
+ locale: reference_list.locale.code,
22
23
  ) do %>
23
24
  <% end %>
24
25
  </div>
@@ -33,7 +34,7 @@
33
34
 
34
35
  <div
35
36
  id="<%= reference_list_dom_id %>"
36
- class="space-y-2"
37
+ class="field-list-items space-y-2"
37
38
  data-controller="sortable-list"
38
39
  >
39
40
  <% reference_list.references.each do |reference| %>
@@ -42,4 +43,12 @@
42
43
  <% end %>
43
44
  <% end %>
44
45
  </div>
46
+
47
+ <div class="field-list-empty">
48
+ <div class="field-list-empty-icon">
49
+ <%= icon "link", class: "size-5" %>
50
+ </div>
51
+ <p class="field-list-empty-title"><%= t(".empty_title") %></p>
52
+ <p class="field-list-empty-description"><%= t(".empty_description") %></p>
53
+ </div>
45
54
  </section>
@@ -0,0 +1,49 @@
1
+ <%# locals: (block_list:, builder:) -%>
2
+
3
+ <% counterpart = block_list.counterpart_with_blocks %>
4
+
5
+ <div class="field-list-empty">
6
+ <div class="field-list-empty-icon">
7
+ <%= icon "rows-3", class: "size-5" %>
8
+ </div>
9
+
10
+ <% if counterpart %>
11
+ <p class="field-list-empty-title"><%= t(".untranslated_title", target: block_list.locale.name) %></p>
12
+ <p class="field-list-empty-description">
13
+ <%= t(".untranslated_description", count: counterpart.blocks.size, source: counterpart.locale.name, target: block_list.locale.name) %>
14
+ </p>
15
+
16
+ <div class="field-list-empty-actions">
17
+ <%= link_to entry_editor_path(block_list.entry, locale: counterpart.locale), class: "button-secondary button-sm" do %>
18
+ <%= t(".view_in", source: counterpart.locale.name) %>
19
+ <%= icon "arrow-right", class: "size-4" %>
20
+ <% end %>
21
+ </div>
22
+ <% else %>
23
+ <p class="field-list-empty-title"><%= t(".title") %></p>
24
+ <p class="field-list-empty-description"><%= t(".description") %></p>
25
+
26
+ <% quick_picks, more = block_quick_picks(block_list) %>
27
+ <div class="field-list-empty-actions">
28
+ <% quick_picks.each do |block_definition| %>
29
+ <%= link_to new_block_in_list_path(block_list, block_definition, builder),
30
+ data: { turbo_stream: true },
31
+ class: "button-secondary button-sm" do %>
32
+ <%= icon "plus", class: "size-4 text-stone-400" %>
33
+ <%= block_definition.name %>
34
+ <% end %>
35
+ <% end %>
36
+
37
+ <% if more.any? %>
38
+ <el-dropdown class="inline-block">
39
+ <button type="button" class="button-ghost button-sm">
40
+ <%= t(".more", count: more.size) %>
41
+ <%= icon "chevron-down", class: "size-4" %>
42
+ </button>
43
+
44
+ <%= render "iron/entries/fields/block_list/menu", block_list:, builder:, block_definitions: more, anchor: "bottom" %>
45
+ </el-dropdown>
46
+ <% end %>
47
+ </div>
48
+ <% end %>
49
+ </div>
@@ -0,0 +1,14 @@
1
+ <%# locals: (block_list:, builder:, block_definitions:, anchor: "bottom end") -%>
2
+
3
+ <el-menu anchor="<%= anchor %>" popover class="w-56 text-left origin-top-right rounded-md bg-white shadow-lg outline-1 outline-black/5 transition transition-discrete [--anchor-gap:--spacing(2)] data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in dark:bg-stone-800 dark:shadow-none dark:-outline-offset-1 dark:outline-white/10">
4
+ <div class="py-1">
5
+ <% block_definitions.each do |block_definition| %>
6
+ <%= link_to new_block_in_list_path(block_list, block_definition, builder),
7
+ data: { turbo_stream: true },
8
+ class: "group/item flex items-center px-4 py-2 text-sm text-stone-700 focus:bg-sky-100 focus:text-stone-900 focus:outline-hidden dark:text-stone-300 dark:focus:bg-sky-500/20 dark:focus:text-white" do %>
9
+ <%= icon "plus", class: "mr-3 size-5 text-stone-400 group-focus/item:text-sky-600 dark:text-stone-500 dark:group-focus/item:text-sky-400" %>
10
+ <%= block_definition.name %>
11
+ <% end %>
12
+ <% end %>
13
+ </div>
14
+ </el-menu>
@@ -14,6 +14,7 @@
14
14
  <%= form.hidden_field :reference_list_field_definition_id, value: @reference_list_field_definition_id %>
15
15
  <%= form.hidden_field :form_field_name, value: @form_field_name %>
16
16
  <%= form.hidden_field :reference_list_dom_id, value: @reference_list_dom_id %>
17
+ <%= form.hidden_field :locale, value: @locale.code %>
17
18
  <% end %>
18
19
  <%= turbo_frame_tag "entries_search_results" do %>
19
20
  <div
@@ -25,7 +26,8 @@
25
26
  as: :entry,
26
27
  locals: {
27
28
  reference_list_dom_id: @reference_list_dom_id,
28
- form_field_name: @form_field_name
29
+ form_field_name: @form_field_name,
30
+ locale: @locale
29
31
  } %>
30
32
  </div>
31
33
  <% end %>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="mt-4 card card-list">
7
7
  <% @recent_entries.each do |entry| %>
8
- <% entry_title = entry.content_type.single? ? entry.content_type.name : entry.title %>
8
+ <% entry_title = entry.content_type.single? ? entry.content_type.name : entry.display_title %>
9
9
  <% entry_path = entry.content_type.single? ? entry_content_type_path(entry.content_type) : edit_entry_path(entry) %>
10
10
  <div class="card-item flex items-center justify-between gap-4">
11
11
  <div class="min-w-0">
@@ -140,11 +140,17 @@ en:
140
140
  create_failed: "%{content_type} could not be created"
141
141
  update_failed: "%{content_type} could not be updated"
142
142
  validation_errors: "Could not save changes due to validation errors"
143
+ content_copies:
144
+ create:
145
+ copied: "Copied the %{source} content into %{target}. You can now translate it."
146
+ invalid: "Couldn’t copy from %{source}: %{field} %{error}. Fix it in %{source} and try again."
147
+ skipped: "Nothing was copied: %{target} already has content, or %{source} has none."
143
148
  edit:
144
149
  breadcrumb: "%{content_type} entries"
145
150
  delete_action: "Delete entry"
146
151
  delete_confirm: "Delete this entry? This can't be undone."
147
152
  more_actions: "More actions"
153
+ title_from: "Title from %{source}"
148
154
  empty_state:
149
155
  description: "Get started by creating your first entry."
150
156
  new_entry: "New entry"
@@ -154,15 +160,35 @@ en:
154
160
  edit_field_definition: "Edit field definition"
155
161
  missing_definition: "Missing block definition!"
156
162
  untitled: "Untitled"
163
+ block_list:
164
+ add_block: "Add Block"
165
+ empty_state:
166
+ description: "Pick a block to add the first one."
167
+ more:
168
+ one: "1 more"
169
+ other: "%{count} more"
170
+ title: "No blocks yet"
171
+ untranslated_description:
172
+ one: "The %{source} version has 1 block. Add one here to start the %{target} version."
173
+ other: "The %{source} version has %{count} blocks. Add one here to start the %{target} version."
174
+ untranslated_title: "No blocks in %{target} yet"
175
+ view_in: "View in %{source}"
157
176
  file:
158
177
  upload_hint: "PNG, JPG, GIF up to 10MB"
159
178
  upload_prompt: "Upload a file or drag and drop"
179
+ reference_list:
180
+ add: "Add"
181
+ empty_description: "Use Add to link existing entries."
182
+ empty_title: "No entries linked yet"
160
183
  index:
161
184
  count:
162
185
  one: "1 entry"
163
186
  other: "%{count} entries"
164
187
  new_entry: "New entry"
165
188
  title: "%{content_type} Entries"
189
+ locale_status:
190
+ untranslated: "Not translated"
191
+ written: "Has content"
166
192
  new:
167
193
  back: "%{content_type} entries"
168
194
  heading: "New entry"
@@ -173,6 +199,12 @@ en:
173
199
  updated: "%{content_type} was successfully updated."
174
200
  search:
175
201
  search_placeholder: "Search entries"
202
+ translation_notice:
203
+ copy: "Copy from %{source}"
204
+ description: "Its content is in %{source}. The fields below stay empty in %{target} until you fill them in, or start from a copy of the %{source} version and translate it."
205
+ switch: "Switch to %{source}"
206
+ title: "This entry hasn’t been translated into %{target} yet"
207
+ unsaved_changes: "Save or discard your changes to copy from %{source}."
176
208
  web_page_settings:
177
209
  index_home: "Make this the home page at /"
178
210
  index_with_base: "Make this the index page at /%{base_path}/"