-
-
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.
Cambio inicial interno de ubicacion por ubicacionpre y uso de turbo e…
…n respectiva pestaña del formulario caso. Closes #725
- Loading branch information
Showing
19 changed files
with
288 additions
and
85 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
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/caso_ubicacionespre_controller' | ||
|
||
module Sivel2Gen | ||
class CasoUbicacionespreController < ApplicationController | ||
load_and_authorize_resource class: Sivel2Gen::CasoUbicacionpre | ||
include Sivel2Gen::Concerns::Controllers::CasoUbicacionespreController | ||
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/models/ubicacionpre' | ||
|
||
module Msip | ||
class Ubicacionpre < ActiveRecord::Base | ||
include Sivel2Gen::Concerns::Models::Ubicacionpre | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
require 'sivel2_gen/concerns/models/caso_ubicacionpre' | ||
|
||
module Sivel2Gen | ||
class CasoUbicacionpre < ActiveRecord::Base | ||
include Sivel2Gen::Concerns::Models::CasoUbicacionpre | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
app/views/sivel2_gen/caso_ubicacionespre/create.turbo_stream.erb
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,20 @@ | ||
<%= simple_form_for @caso do |form| %> | ||
<%= form.simple_fields_for :caso_ubicacionpre, | ||
child_index: params[:index] do |subf| %> | ||
<%= turbo_stream.replace "agregar-caso-ubicacionpre" do %> | ||
<%= form.submit "Agregar otra ubicacionpre", | ||
formaction: sivel2_gen.crear_caso_ubicacionpre_path( | ||
subf.index.to_i + 1 | ||
), | ||
formmethod: :post, | ||
formnovalidate: true, | ||
class: 'btn btn-sm btn-primary', | ||
id: "agregar-caso-ubicacionpre" %> | ||
<% end %> | ||
<%= turbo_stream.append "caso_ubicacionespre_marco" do %> | ||
<%= render "/sivel2_gen/casos/caso_ubicacionpre_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: @caso do |f| %> | ||
<%= f.simple_fields_for :caso_ubicacionpre, | ||
child_index: params[:index] do |subf| %> | ||
<%= turbo_frame_tag "caso_ubicacionpre_#{subf.index}" do %> | ||
<%= subf.hidden_field :id, value: params[:id] %> | ||
<%= subf.hidden_field :_destroy, value: true %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
53 changes: 53 additions & 0 deletions
53
app/views/sivel2_gen/casos/_caso_ubicacionpre_campos.html.erb
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,53 @@ | ||
<%= turbo_frame_tag "caso_ubicacionpre_#{f.index}" do %> | ||
<div class="control-group nested-fields seccionubicacionpre"> | ||
<div class="controls"> | ||
<%= f.input :id, as: :hidden %> | ||
<% if f.object.ubicacionpre.nil? %> | ||
<% f.object.ubicacionpre = Msip::Ubicacionpre.new %> | ||
<% end %> | ||
<%= f.input :ubicacionpre_id, as: :hidden %> | ||
<% htmlid = f.index %> | ||
<%= render partial: "msip/ubicacionespre/cuatro_filas", locals: { | ||
f: f, | ||
htmlid: "ubicacionpre-#{htmlid}", | ||
estilogen: "", | ||
campopais: :ubicacionpre_pais, | ||
campopais_etiqueta: "País", | ||
campodepartamento: :ubicacionpre_departamento, | ||
campodepartamento_etiqueta: "Departamento", | ||
campomunicipio: :ubicacionpre_municipio, | ||
campomunicipio_etiqueta: "Municipio", | ||
idresto: "restoubicacionpre", | ||
campocentropoblado: :ubicacionpre_centropoblado, | ||
campocentropoblado_etiqueta: "Centro poblado", | ||
campolugar: :ubicacionpre_lugar, | ||
campolugar_etiqueta: "Barrio o vereda", | ||
campoubicacionpre_id: :ubicacionpre_id, | ||
campositio: :ubicacionpre_sitio, | ||
campositio_etiqueta: "Dirección o finca", | ||
campotsitio: :ubicacionpre_tsitio, | ||
campotsitio_etiqueta: "Tipo de sitio", | ||
campolatitud: :ubicacionpre_latitud, | ||
campolatitud_etiqueta: "Latitud", | ||
campolongitud: :ubicacionpre_longitud, | ||
campolongitud_etiqueta: "Longitud" | ||
} %> | ||
|
||
<div class="links"> | ||
<%= f.submit "Eliminar", | ||
formaction: sivel2_gen.eliminar_caso_ubicacionpre_path( | ||
id: f.object.id, index: f.index), | ||
formmethod: :delete, | ||
formnovalidate: true, | ||
class: "btn btn-sm btn-danger", | ||
data: { | ||
disable_with: false, | ||
turbo_frame: "caso_ubicacionpre_#{f.index}", | ||
turbo_method: :delete | ||
} %> | ||
</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
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
<%= f.simple_fields_for :ubicacion do |ubicacion| %> | ||
<%= render 'ubicacion_fields', :f => ubicacion %> | ||
<% end %> | ||
<div class="links"> | ||
<%= link_to_add_association 'Añadir Ubicación', f, :ubicacion, { | ||
:class => 'btn btn-sm btn-primary', | ||
"data-ajax" => File.join( | ||
Rails.configuration.relative_url_root , | ||
"ubicaciones/nuevo" | ||
), | ||
"data-ajaxdata" => "caso_id" | ||
} %> | ||
<div id="caso_ubicacionespre_marco"> | ||
<%= f.simple_fields_for :caso_ubicacionpre, | ||
f.object.caso_ubicacionpre.order(:id), | ||
child_index: params[:index] do |cubi| %> | ||
<%= render 'sivel2_gen/casos/caso_ubicacionpre_campos', :f => cubi %> | ||
<% end %> | ||
</div> | ||
|
||
<%= f.submit "Agregar ubicacion", | ||
formaction: sivel2_gen.crear_caso_ubicacionpre_path( | ||
index: @caso.caso_ubicacionpre.size | ||
), | ||
formmethod: :post, | ||
formnovalidate: true, | ||
class: 'btn btn-sm btn-primary', | ||
name: "agregar-caso-ubicacionpre", | ||
id: "agregar-caso-ubicacionpre", | ||
data: { | ||
disable_with: false | ||
} | ||
%> |
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
32 changes: 32 additions & 0 deletions
32
lib/sivel2_gen/concerns/controllers/caso_ubicacionespre_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,32 @@ | ||
module Sivel2Gen | ||
module Concerns | ||
module Controllers | ||
module CasoUbicacionespreController | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
include ActionView::Helpers::AssetUrlHelper | ||
|
||
before_action :prepara_caso | ||
|
||
def destroy | ||
end | ||
|
||
def create | ||
end | ||
|
||
private | ||
|
||
def prepara_caso | ||
@caso = Sivel2Gen::Caso.new( | ||
caso_ubicacionpre: [Sivel2Gen::CasoUbicacionpre.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
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.