-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Permitir editar aportes desde formulario persona. Closes #228
- Loading branch information
Showing
10 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
class AportesController < ApplicationController | ||
|
||
load_and_authorize_resource class: ::Aporte | ||
|
||
before_action :prepara_persona | ||
|
||
# Para llamar vista con formato turbo stream | ||
def destroy | ||
end | ||
|
||
# Para llamar vista con formato turbo stream | ||
def create | ||
end | ||
|
||
private | ||
|
||
def prepara_persona | ||
@persona = Msip::Persona.new( | ||
aporte: [::Aporte.new] | ||
) | ||
end | ||
|
||
end # included |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<%= simple_fields_for @persona do |f| %> | ||
<%= f.simple_fields_for :aporte, | ||
child_index: params[:index] do |subf| %> | ||
<%= turbo_stream.append "aportes_marco" do %> | ||
<%= render "msip/personas/aporte_campos", f: subf %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%= fields model: @persona do |f| %> | ||
<%= f.simple_fields_for :aporte, | ||
child_index: params[:index] do |subf| %> | ||
<%= turbo_frame_tag "aporte_#{subf.index}" do %> | ||
<%= subf.hidden_field :id, value: params[:id] %> | ||
<%= subf.hidden_field :_destroy, value: true %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<%= turbo_frame_tag "aporte_#{f.index}", | ||
class: "div-tabla-fila nested-fields" do %> | ||
<% if f.object.nil? %> | ||
<% f.object = ::Aporte.new %> | ||
<% end %> | ||
<div class="div-tabla-celda"> | ||
<%= f.input :anio, | ||
collection: @anios, | ||
label: false | ||
%> | ||
</div> | ||
<div class="div-tabla-celda"> | ||
<%= f.input :mes, | ||
collection: @meses, | ||
label: false | ||
%> | ||
</div> | ||
<div class="div-tabla-celda"> | ||
<%= f.input :valor, | ||
label: false | ||
%> | ||
</div> | ||
<div class="div-tabla-celda"> | ||
<%= f.input :id, as: :hidden %> | ||
<%= f.submit "Eliminar", | ||
formaction: main_app.eliminar_aporte_path( | ||
id: f.object.id, index: f.index || 1), | ||
formmethod: :delete, | ||
formnovalidate: true, | ||
class: 'btn btn-sm btn-danger', | ||
data: { | ||
turbo_frame: "aporte_#{f.index}", | ||
disable_with: false | ||
} %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<div class="accordion" id="acordeonapo-<%= f.object.id %>"> | ||
<%= item_acordeon_bs( | ||
'acordeonapo', "colapsaapo-#{f.object.id}", | ||
'Aportes', false, { | ||
'estilo_accordion-header': 'text-align: center', | ||
'clase_accordion-body': 'table-responsive', | ||
'estilo_accordion-body': 'overflow-x:scroll' | ||
}) do %> | ||
<% if f.object.id.nil? %> | ||
Una vez guarde este registro y vuelva a editar podrá agregar aportes | ||
<% else %> | ||
<div id="aportes" class="panel-body table-responsive" > | ||
<div class="div-tabla"> | ||
<div id="aportes_marco" class="div-tabla-cuerpo"> | ||
<div class="div-tabla-fila"> | ||
<div class="div-tabla-celda">Año</div> | ||
<div class="div-tabla-celda">Mes</div> | ||
<div class="div-tabla-celda">Valor</div> | ||
<div class="div-tabla-celda">Acciones</div> | ||
</div> | ||
<%= f.simple_fields_for :aporte, | ||
f.object.aporte.order([:anio,:mes]), | ||
child_index: params[:index] do |apo| %> | ||
<%= render partial: "aporte_campos", | ||
locals: {f: apo} | ||
%> | ||
<% end %> | ||
</div> | ||
</div> | ||
<div class="enlace-agregar-aporte"> | ||
<%= f.submit "Agregar Aporte", | ||
formaction: main_app.crear_aporte_path( | ||
index: @persona.aporte.size | ||
), | ||
formmethod: :post, | ||
formnovalidate: true, | ||
class: 'btn btn-sm btn-primary', | ||
name: "agregar-aporte", | ||
id: "agregar-aporte", | ||
data: { | ||
disable_with: false | ||
} %> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters