Mattias Bodlund 1 year ago
parent
commit
dffb72504a
6 changed files with 23 additions and 18 deletions
  1. +7
    -7
      Gemfile.lock
  2. +1
    -0
      app/controllers/admin/nodes_controller.rb
  3. +8
    -1
      app/views/admin/attachments/_attachment.html.erb
  4. +4
    -8
      app/views/admin/attachments/new.turbo_stream.erb
  5. +1
    -1
      app/views/material/_trix_field.html.erb
  6. +2
    -1
      app/views/material/_trix_field_i18n.html.erb

+ 7
- 7
Gemfile.lock View File

@ -110,9 +110,9 @@ GEM
irb (~> 1.10) irb (~> 1.10)
reline (>= 0.3.8) reline (>= 0.3.8)
dkim (1.1.0) dkim (1.1.0)
dotenv (3.1.0)
dotenv-rails (3.1.0)
dotenv (= 3.1.0)
dotenv (3.1.1)
dotenv-rails (3.1.1)
dotenv (= 3.1.1)
railties (>= 6.1) railties (>= 6.1)
drb (2.2.1) drb (2.2.1)
erubi (1.12.0) erubi (1.12.0)
@ -130,8 +130,8 @@ GEM
activesupport (>= 6.0.0) activesupport (>= 6.0.0)
railties (>= 6.0.0) railties (>= 6.0.0)
io-console (0.7.2) io-console (0.7.2)
irb (1.12.0)
rdoc
irb (1.13.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2) reline (>= 0.4.2)
jbuilder (2.12.0) jbuilder (2.12.0)
actionview (>= 5.0.0) actionview (>= 5.0.0)
@ -256,9 +256,9 @@ GEM
redis-client (0.22.1) redis-client (0.22.1)
connection_pool connection_pool
regexp_parser (2.9.0) regexp_parser (2.9.0)
reline (0.5.4)
reline (0.5.5)
io-console (~> 0.5) io-console (~> 0.5)
request_store (1.6.0)
request_store (1.7.0)
rack (>= 1.4) rack (>= 1.4)
rexml (3.2.6) rexml (3.2.6)
ruby-vips (2.2.1) ruby-vips (2.2.1)


+ 1
- 0
app/controllers/admin/nodes_controller.rb View File

@ -50,6 +50,7 @@ class Admin::NodesController < Admin::AdminController
respond_to do |format| respond_to do |format|
if @node.save if @node.save
ensure_open_node_ids
session[:open_node_ids] << @node.id unless session[:open_node_ids].include?(@node.id) session[:open_node_ids] << @node.id unless session[:open_node_ids].include?(@node.id)
format.turbo_stream format.turbo_stream


+ 8
- 1
app/views/admin/attachments/_attachment.html.erb View File

@ -2,7 +2,14 @@
<div class="attachment__content"> <div class="attachment__content">
<%= render partial: 'admin/attachments/asset', collection: Array(f.object.asset) %> <%= render partial: 'admin/attachments/asset', collection: Array(f.object.asset) %>
<%= render partial: 'material/trix_field_i18n', locals: { f: f, attr: :body, label: t('activerecord.attributes.attachment.body', locale: I18n.default_locale) } %>
<%= render partial: 'material/trix_field_i18n',
locals: {
f: f,
attr: :body,
label: t('activerecord.attributes.attachment.body',
locale: I18n.default_locale),
tmp_id: local_assigns[:tmp_id]
} %>
<!--<div class="attachment__content-three"> <!--<div class="attachment__content-three">


+ 4
- 8
app/views/admin/attachments/new.turbo_stream.erb View File

@ -1,14 +1,10 @@
<turbo-stream action="append" targets="#attachments"> <turbo-stream action="append" targets="#attachments">
<template> <template>
<% @attachments.each_with_index do |attachment, i| %> <% @attachments.each_with_index do |attachment, i| %>
<%= fields_for "#{@attachable_for.class.name.underscore.singularize}[attachments_attributes][#{ Time.now.to_i + i }]", attachment do |builder| %>
<%= render partial: 'admin/attachments/attachment', locals: {f: builder}, formats: :html %>
<% tmp_id = Time.now.to_i + i %>
<%= fields_for "#{@attachable_for.class.name.underscore.singularize}[attachments_attributes][#{ tmp_id }]", attachment do |builder| %>
<%= render partial: 'admin/attachments/attachment', locals: {f: builder, tmp_id: tmp_id}, formats: :html %>
<% end %> <% end %>
<% end %>
<%# fields model: @node do |form| %>
<%# form.fields_for :attachments, @attachments do |builder| %>
<%# render partial: 'admin/attachments/attachment', locals: {f: builder} %>
<%# end%>
<%# end %>
<% end %>
</template> </template>
</turbo-stream> </turbo-stream>

+ 1
- 1
app/views/material/_trix_field.html.erb View File

@ -1,7 +1,7 @@
<%= content_tag :div, class: local_assigns[:class] do %> <%= content_tag :div, class: local_assigns[:class] do %>
<div class="trix__field"> <div class="trix__field">
<%- trix_id = f.object.new_record? ? (local_assigns[:child_index] ? "#{dom_id(f.object, attr)}_#{local_assigns[:child_index]}" :
<%- trix_id = f.object.new_record? ? (local_assigns[:tmp_id] ? "#{dom_id(f.object, attr)}_#{local_assigns[:tmp_id]}" :
"#{attr}_new_#{model_name_from_record_or_class(f.object).param_key.pluralize}" ) : "#{attr}_new_#{model_name_from_record_or_class(f.object).param_key.pluralize}" ) :
dom_id(f.object, attr) -%> dom_id(f.object, attr) -%>


+ 2
- 1
app/views/material/_trix_field_i18n.html.erb View File

@ -8,7 +8,8 @@
attr: i18n_attr, attr: i18n_attr,
class: "i18n__input i18n__input-#{locale}", class: "i18n__input i18n__input-#{locale}",
label_class: '', label_class: '',
label: local_assigns[:label]
label: local_assigns[:label],
tmp_id: local_assigns[:tmp_id]
} %> } %>
<%- end -%> <%- end -%>

Loading…
Cancel
Save