-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rgl518 - Ya funciona Anexos con Turbo See merge request pasosdeJesus/sivel2_gen!467
- Loading branch information
Showing
19 changed files
with
1,582 additions
and
236 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
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 @@ | ||
require 'date' | ||
require 'sivel2_gen/concerns/controllers/anexos_controller' | ||
|
||
module Msip | ||
class AnexosController < Msip::ModelosController | ||
|
||
load_and_authorize_resource class: Msip::Anexo | ||
include Sivel2Gen::Concerns::Controllers::AnexosController | ||
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,8 @@ | ||
require 'sivel2_gen/concerns/controllers/anexo_casos_controller' | ||
|
||
module Sivel2Gen | ||
class AnexoCasosController < ApplicationController | ||
load_and_authorize_resource class: Sivel2Gen::AnexoCaso | ||
include Sivel2Gen::Concerns::Controllers::AnexoCasosController | ||
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
require 'sivel2_gen/concerns/models/anexo' | ||
|
||
module Msip | ||
|
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,17 @@ | ||
<%= simple_form_for @caso , multipart: true do |form| %> | ||
<%= form.simple_fields_for :anexo_caso, | ||
child_index: params[:index] do |ca_form| %> | ||
<%= turbo_stream.replace "agregar-anexo-caso" do %> | ||
<%= form.submit "Añadir Anexo", | ||
formaction: sivel2_gen.crear_anexo_caso_path(ca_form.index.to_i + 1), | ||
formmethod: :post, | ||
formnovalidate: true, | ||
class: 'btn btn-sm btn-primary agregar-ca', | ||
id: "agregar-anexo-caso" %> | ||
<% end %> | ||
<%= turbo_stream.append "anexo_casos_marco" do %> | ||
<%= render "/sivel2_gen/casos/anexo_caso_campos", f: ca_form %> | ||
<% 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,9 @@ | ||
<%= fields model: @caso do |form| %> | ||
<%= form.simple_fields_for :anexo_caso, | ||
child_index: params[:index] do |ca_form| %> | ||
<%= turbo_frame_tag "anexo_caso_#{ca_form.index}" do %> | ||
<%= ca_form.hidden_field :id, value: params[:id] %> | ||
<%= ca_form.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 |
---|---|---|
@@ -1,43 +1,54 @@ | ||
<div class='control-group nested-fields'> | ||
<div class="controls"> | ||
<% f.object.msip_anexo = Msip::Anexo.new if !f.object.msip_anexo %> | ||
<%= turbo_frame_tag "anexo_caso_#{f.index}" do %> | ||
<div class='control-group nested-fields'> | ||
<div class="controls"> | ||
<% if f.object.msip_anexo.nil? %> | ||
<% f.object.msip_anexo = Msip::Anexo.new %> | ||
<% end %> | ||
<%= f.simple_fields_for :msip_anexo, :html => {:multipart => true} do |a| %> | ||
<div class="row"> | ||
<div class="col-md-6"> | ||
<%= a.input :id, as: :hidden %> | ||
<%= f.input :fecha, | ||
:input_html => { type: "date" }, | ||
:as => :string, | ||
:label => "Fecha" %> | ||
</div> | ||
|
||
<%= f.simple_fields_for :msip_anexo do |a| %> | ||
|
||
<div class="row"> | ||
<div class="col-md-6"> | ||
<%= f.input :fecha_localizada, | ||
:input_html => { "data-behaviour" => "datepicker" }, | ||
:as => :string, :label => "Fecha" %> | ||
<div class="col-md-6"> | ||
<% if !a.object || !a.object.adjunto_file_name || !a.object.id %> | ||
<%= a.input :adjunto, as: :file, | ||
label: 'Archivo', | ||
data: { | ||
disable_with: false } %> | ||
<% else %> | ||
<div class="msip_anexo_adjunto"> | ||
<label for="msip_anexo_attributes_<%=a.object.id%>_adjunto"> | ||
Archivo | ||
</label> | ||
<a id="msip_anexo_attributes_<%=a.object.id%>_adjunto" | ||
href="<%= msip.descarga_anexo_path(a.object.id) %>" | ||
style="text-decoration:none" | ||
data-turbo='false'> | ||
<%= a.object.adjunto_file_name %> | ||
</a> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<div class="col-md-6"> | ||
<% if !a.object || !a.object.adjunto_file_name || !a.object.id %> | ||
<%= a.input :adjunto, as: :file, label: 'Archivo' %> | ||
<% else %> | ||
<div class="msip_anexo_adjunto"> | ||
<label for="msip_anexo_attributes_<%=a.object.id%>_adjunto"> | ||
Archivo | ||
</label> | ||
<a id="msip_anexo_attributes_<%=a.object.id%>_adjunto" | ||
href="<%= msip.descarga_anexo_path(a.object.id) %>" | ||
style="text-decoration:none" | ||
data-turbo='false'> | ||
<%= a.object.adjunto_file_name %> | ||
</a> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
</div> | ||
|
||
<%= a.input :descripcion %> | ||
<%= a.input :descripcion %> | ||
<%= a.input :id, as: :hidden %> | ||
<% end %> <!-- f.simple_fields_for :msip_anexo --> | ||
|
||
<%= a.input :id, as: :hidden %> | ||
<% end %> <!-- f.simple_fields_for :msip_anexo --> | ||
<%= link_to_remove_association "Eliminar Anexo", f, | ||
:class => 'btn btn-sm btn-danger', | ||
style: 'margin-bottom: 1em' | ||
%> | ||
<%= f.submit "Eliminar", | ||
formaction: eliminar_anexo_caso_path(id: f.object.id, index: f.index), | ||
formmethod: :delete, | ||
formnovalidate: true, | ||
class: 'btn btn-sm btn-danger', | ||
data: { | ||
turbo_frame: "anexo_caso_#{f.index}", | ||
disable_with: false | ||
} %> | ||
</div> | ||
</div> | ||
</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 |
---|---|---|
@@ -1,9 +1,17 @@ | ||
<%= f.simple_fields_for :anexo_caso do |anexo| %> | ||
<%= render 'sivel2_gen/casos/anexo_caso_campos', :f => anexo %> | ||
<% end %> | ||
<div id="anexo_casos_marco"> | ||
<%= f.simple_fields_for :anexo_caso, child_index: params[:index] do |anexo| %> | ||
<%= render 'sivel2_gen/casos/anexo_caso_campos', :f => anexo %> | ||
<% end %> | ||
</div> | ||
|
||
<div class="links"> | ||
<%= link_to_add_association 'Añadir Anexo', f, :anexo_caso, | ||
partial: 'sivel2_gen/casos/anexo_caso_campos', | ||
:class => 'btn btn-sm btn-primary' | ||
%> | ||
<%= f.submit "Añadir Anexo", | ||
formaction: sivel2_gen.crear_anexo_caso_path(index: @caso.anexo_caso.size), | ||
formmethod: :post, | ||
formnovalidate: true, | ||
class: 'btn btn-sm btn-primary agregar-ca', | ||
name: "agregar-anexo-caso", | ||
id: "agregar-anexo-caso", | ||
data: { | ||
disable_with: false } %> | ||
</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
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
50 changes: 50 additions & 0 deletions
50
lib/sivel2_gen/concerns/controllers/anexo_casos_controller.rb
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,50 @@ | ||
require 'date' | ||
|
||
module Sivel2Gen | ||
module Concerns | ||
module Controllers | ||
module AnexoCasosController | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
include ActionView::Helpers::AssetUrlHelper | ||
|
||
load_and_authorize_resource class: Sivel2Gen::AnexoCaso | ||
|
||
before_action :prepara_caso | ||
|
||
def clase | ||
"Sivel2Gen::AnexoCaso" | ||
end | ||
|
||
|
||
def nuevo | ||
end | ||
|
||
def destroy | ||
end | ||
|
||
def create | ||
end | ||
|
||
def update | ||
end | ||
|
||
def set_anexo_caso | ||
@anexocaso = Sivel2Gen::AnexoCaso.find(params[:id]) | ||
@registro = @anexocaso | ||
end | ||
|
||
private | ||
|
||
def prepara_caso | ||
@caso = Sivel2Gen::Caso.new( | ||
anexo_caso: [Sivel2Gen::AnexoCaso.new]) | ||
end | ||
end # included | ||
|
||
end | ||
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,30 @@ | ||
|
||
require 'msip/concerns/controllers/anexos_controller' | ||
require 'date' | ||
|
||
module Sivel2Gen | ||
module Concerns | ||
module Controllers | ||
module AnexosController | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
include Msip::Concerns::Controllers::AnexosController | ||
|
||
def remplazar_antes_salvar_v | ||
true | ||
end | ||
|
||
def remplazar_despues_salvar_v | ||
true | ||
end | ||
|
||
end # included | ||
|
||
|
||
class_methods do | ||
end # class_methods | ||
end | ||
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
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
Oops, something went wrong.