-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cambia coffescript+jquery por turbo en proyectos financieros del form…
…ulario de actividad. Avanza https://gitlab.com/pasosdeJesus/si_jrscol/-/issues/1115
- Loading branch information
Showing
10 changed files
with
180 additions
and
65 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
app/controllers/cor1440_gen/actividad_proyectosfinancieros_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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require "cor1440_gen/concerns/controllers/actividad_proyectosfinancieros_controller" | ||
|
||
module Cor1440Gen | ||
class ActividadProyectosfinancierosController < ApplicationController | ||
load_and_authorize_resource class: ActividadProyectofinanciero | ||
|
||
include Cor1440Gen::Concerns::Controllers::ActividadProyectosfinancierosController | ||
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
25 changes: 25 additions & 0 deletions
25
app/views/cor1440_gen/actividad_proyectosfinancieros/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,25 @@ | ||
<%= simple_form_for @actividad do |f| %> | ||
<%= f.simple_fields_for :actividad_proyectofinanciero, | ||
child_index: params[:index] do |subf| %> | ||
<%= turbo_stream.replace "agregar-actividad-proyectofinanciero" do %> | ||
<%= f.submit "#{t('Agregar')} " + | ||
"#{@actividad.class.human_attribute_name(:proyectofinanciero)}", | ||
class: 'btn btn-sm btn-primary', | ||
data: { | ||
disable_with: false | ||
}, | ||
formaction: cor1440_gen.crear_actividad_proyectofinanciero_path( | ||
index: subf.index.to_i + 1 | ||
), | ||
formmethod: :post, | ||
formnovalidate: true, | ||
id: "agregar-actividad-proyectofinanciero" | ||
%> | ||
<% end %> | ||
|
||
<%= turbo_stream.append "actividad_proyectosfinancieros_marco" do %> | ||
<%= render "/cor1440_gen/actividades/actividad_proyectofinanciero_campos", | ||
f: subf, ac: f %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
9 changes: 9 additions & 0 deletions
9
app/views/cor1440_gen/actividad_proyectosfinancieros/destroy.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,9 @@ | ||
<%= fields model: @actividad do |f| %> | ||
<%= f.simple_fields_for :actividad_proyectofinanciero, | ||
child_index: params[:index] do |subf| %> | ||
<%= turbo_frame_tag "actividad_proyectofinanciero_#{subf.index}" do %> | ||
<%= subf.hidden_field :id, value: params[:id] %> | ||
<%= subf.hidden_field :_destroy, value: true %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
78 changes: 47 additions & 31 deletions
78
app/views/cor1440_gen/actividades/_actividad_proyectofinanciero_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 |
---|---|---|
@@ -1,52 +1,68 @@ | ||
<tr class='nested-fields'> | ||
<% if ac.object.fecha %> | ||
<% fr = ac.object.fecha %> | ||
<%= turbo_frame_tag "actividad_proyectofinanciero_#{f.index}", | ||
class: 'div-tabla-fila nested-fields' do %> | ||
<% if f.object.proyectofinanciero.nil? %> | ||
<% f.object.proyectofinanciero = Cor1440Gen::Proyectofinanciero.new %> | ||
<% end %> | ||
<% if params && params[:actividad] && params[:actividad][:fecha] %> | ||
<% fr = params[:actividad][:fecha] %> | ||
<% else %> | ||
<% fr = Time.now.strftime('%Y-%m-%d') %> | ||
<% end %> | ||
<% lp1 = Cor1440Gen::ProyectosfinancierosController::disponibles( | ||
{fecha: fr}, current_ability) %> | ||
<% ids1 = lp1.pluck(:id) %> | ||
<% ids2 = ac.object.proyectofinanciero.pluck(:id) %> | ||
<% ids2 = [] %> | ||
<% if params && params[:actividad] %> | ||
<% params[:actividad][:actividad_proyectofinanciero_attributes].each do |l, v| %> | ||
<% ids2 << v[:id] %> | ||
<% end %> | ||
<% else %> | ||
<% ids2 = ac.object.proyectofinanciero.pluck(:id) %> | ||
<% end %> | ||
<% # Si es uno nuevo excluimos los ya elegidos %> | ||
<% ids = ids1 | ids2 %> | ||
<% col = Cor1440Gen::Proyectofinanciero.where(id: ids). | ||
reorder('lower(nombre)') %> | ||
<td> | ||
<% # Inexcplicable que no opere coccoon:after-insert si se agrega: f.input :actividad_id, as: :hidden %> | ||
<div class="div-tabla-celda"> | ||
<%= f.input :id, as: :hidden %> | ||
<% vdis = false %> | ||
<% if f.object.proyectofinanciero_id %> | ||
<% vdis = true %> | ||
<% end %> | ||
<%= f.input :proyectofinanciero_id, | ||
collection: col, | ||
label: false, | ||
label_method: :nombre, | ||
disabled: vdis, | ||
value_method: :id, | ||
selected: f.object.proyectofinanciero_id, | ||
input_html: { | ||
title: t("Los proyectos presentados son los vigentes en la fecha "\ | ||
"de la actividad (cambie la fecha para actualizar estas opciones)"), | ||
title: t( | ||
"Los proyectos presentados son los vigentes en la fecha "\ | ||
"de la actividad (cambie la fecha para actualizar estas opciones)" | ||
), | ||
class: 'tom-select' | ||
} | ||
%> | ||
</td> | ||
<td> | ||
<%= render partial: 'campo_actividad_proyectofinanciero_actividadpf', | ||
}, | ||
label: false, | ||
label_method: :nombre, | ||
selected: f.object.proyectofinanciero_id, | ||
value_method: :id %> | ||
</div> | ||
<div class="div-tabla-celda"> | ||
<%= render partial: '/cor1440_gen/actividades/campo_actividad_proyectofinanciero_actividadpf', | ||
locals: {f: f} %> | ||
</td> | ||
<% if Cor1440Gen::Proyectofinanciero::en_toda_actividad_id && | ||
f.object.proyectofinanciero_id == | ||
Cor1440Gen::Proyectofinanciero::en_toda_actividad_id %> | ||
<% elestilo = "display: none" %> | ||
<% else%> | ||
<% elestilo = "display: block" %> | ||
<% end%> | ||
<td style="<%= elestilo %>"> | ||
<%= link_to_remove_association t("Eliminar"), f, | ||
:class => 'btn btn-sm btn-danger' | ||
%> | ||
</td> | ||
</tr> | ||
</div> | ||
<div class="div-tabla-celda"> | ||
<% if !Cor1440Gen::Proyectofinanciero::en_toda_actividad_id || | ||
f.object.proyectofinanciero_id != | ||
Cor1440Gen::Proyectofinanciero::en_toda_actividad_id %> | ||
<%= f.submit "Eliminar", | ||
class: 'btn btn-sm btn-danger', | ||
data: { | ||
turbo_frame: "actividad_proyectofinanciero_#{f.index}", | ||
disable_with: false | ||
}, | ||
formaction: cor1440_gen.eliminar_actividad_proyectofinanciero_path( | ||
id: f.object.id, index: f.index | ||
), | ||
formmethod: :delete, | ||
formnovalidate: true %> | ||
<% end%> | ||
</div> | ||
<% end %> |
66 changes: 34 additions & 32 deletions
66
app/views/cor1440_gen/actividades/_campo_proyectofinanciero.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 |
---|---|---|
@@ -1,35 +1,37 @@ | ||
<div class='div_actividad_proyectofinanciero'> | ||
<table class="tablapfac table-sm table-striped"> | ||
<thead> | ||
<tr> | ||
<th scope='col'> | ||
<%= @actividad.class.human_attribute_name(:proyectofinanciero) %> | ||
</th> | ||
<th scope='col' style='width-min: 30rem'> | ||
<%= f.input :id, type: :hidden %> | ||
<div class="div-tabla"> | ||
<div id="actividad_proyectosfinancieros_marco" class="div-tabla-cuerpo"> | ||
<div class="div-tabla-fila"> | ||
<div class="div-tabla-celda-encabezado"> | ||
<%= @actividad.class.human_attribute_name(:proyectofinanciero) %> | ||
</div> | ||
<div class="div-tabla-celda-encabezado"> | ||
<%= @actividad.class.human_attribute_name(:actividadespf) %> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody id="actividad_proyectofinanciero"> | ||
<%= f.simple_fields_for( | ||
:actividad_proyectofinanciero, | ||
f.object.actividad_proyectofinanciero.order(:id)) do |ap| %> | ||
<%= render partial: 'actividad_proyectofinanciero_campos', | ||
locals: {f: ap, ac: f} %> | ||
<% end %> | ||
<%= render partial: 'complemento_filas_proyectofinanciero', | ||
locals: {f: f} %> | ||
</tbody> | ||
</table> | ||
<div class="agregar-proyectofinanciero"> | ||
<%= link_to_add_association( | ||
"#{t('Añadir')} #{@actividad.class.human_attribute_name(:proyectofinanciero)}", | ||
f, :actividad_proyectofinanciero, | ||
render_options: {locals: { ac: f }}, | ||
"data-association-insertion-node": "tbody#actividad_proyectofinanciero", | ||
"data-association-insertion-method": "append", | ||
partial: "actividad_proyectofinanciero_campos", | ||
class: "btn btn-sm btn-primary" | ||
) %> | ||
</div> | ||
</div> | ||
<%= f.simple_fields_for( | ||
:actividad_proyectofinanciero, | ||
f.object.actividad_proyectofinanciero.order(:id)) do |ap| %> | ||
<%= render partial: | ||
'/cor1440_gen/actividades/actividad_proyectofinanciero_campos', | ||
locals: {f: ap, ac: f} %> | ||
<% end %> | ||
<%= render partial: '/cor1440_gen/actividades/complemento_filas_proyectofinanciero', | ||
locals: {f: f} %> | ||
</div> | ||
</div> | ||
<div class="enlace-agregar-proyectofinanciero"> | ||
<%= f.submit "#{t('Agregar')} " + | ||
"#{@actividad.class.human_attribute_name(:proyectofinanciero)}", | ||
class: 'btn btn-sm btn-primary', | ||
data: { | ||
disable_with: false | ||
}, | ||
formaction: cor1440_gen.crear_actividad_proyectofinanciero_path( | ||
index: @actividad.actividad_proyectofinanciero.size | ||
), | ||
formmethod: :post, | ||
formnovalidate: true, | ||
id: "agregar-actividad-proyectofinanciero" | ||
%> | ||
</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
35 changes: 35 additions & 0 deletions
35
lib/cor1440_gen/concerns/controllers/actividad_proyectosfinancieros_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,35 @@ | ||
module Cor1440Gen | ||
module Concerns | ||
module Controllers | ||
module ActividadProyectosfinancierosController | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_action :prepara_actividad | ||
|
||
def destroy | ||
end | ||
|
||
def create | ||
end | ||
|
||
private | ||
|
||
def prepara_actividad | ||
@actividad = Cor1440Gen::Actividad.where( | ||
id: params[:actividad][:id].to_i | ||
).take | ||
if @actividad.actividad_proyectofinanciero.length == 0 | ||
@actividad.actividad_proyectofinanciero = [ | ||
Cor1440Gen::ActividadProyectofinanciero.new | ||
] | ||
end | ||
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