Merge branch 'dev'

This commit is contained in:
gregoirenovel 2017-11-23 09:48:04 +01:00
commit 838e110590
13 changed files with 76 additions and 29 deletions

View file

@ -24,3 +24,9 @@
// are ligned with those that have text
vertical-align: top;
}
.mixed-buttons-bar .label {
padding: $default-spacer $default-padding;
font-size: 14px;
line-height: 20px;
}

View file

@ -127,7 +127,7 @@
}
.dossier-motivation {
margin-top: 2 * $default-padding;
margin: $default-padding 0;
}
.attestation {

View file

@ -23,7 +23,7 @@
border: 1px solid $black;
}
&.closed {
&.success {
background-color: $green;
}

View file

@ -173,6 +173,17 @@ module NewGestionnaire
redirect_back(fallback_location: procedure_url(procedure))
end
def download_dossiers
export = procedure.generate_export
filename = "dossiers_#{procedure.procedure_path.path}_#{Time.now.strftime('%Y-%m-%d_%H-%M')}"
respond_to do |format|
format.csv { send_data(SpreadsheetArchitect.to_csv(data: export[:data], headers: export[:headers]), filename: "#{filename}.csv") }
format.xlsx { send_data(SpreadsheetArchitect.to_xlsx(data: export[:data], headers: export[:headers]), filename: "#{filename}.xlsx") }
format.ods { send_data(SpreadsheetArchitect.to_ods(data: export[:data], headers: export[:headers]), filename: "#{filename}.ods") }
end
end
private
def statut

View file

@ -31,7 +31,12 @@ class Users::CarteController < UsersController
end
def get_position
etablissement = current_user_dossier.etablissement
begin
etablissement = current_user_dossier.etablissement
rescue ActiveRecord::RecordNotFound
etablissement = nil
end
point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) unless etablissement.nil?
lon = '2.428462'

View file

@ -363,6 +363,16 @@ class Dossier < ActiveRecord::Base
end
end
def statut
if closed?
'accepté'
elsif without_continuation?
'classé sans suite'
elsif refused?
'refusé'
end
end
private
def build_attestation

View file

@ -60,24 +60,18 @@
= button_tag "Valider la décision", name: :process_action, value: "close", class: 'button primary', title: 'Accepter', data: { confirm: "Accepter ce dossier ?" }
- else
%span.button.dropdown{ class: dossier.closed? ? 'success' : nil }
- if dossier.closed?
accepté
- elsif dossier.without_continuation?
classé sans suite
- elsif dossier.refused?
refusé
.dropdown-content.fade-in-down.terminated
%h4
- if dossier.closed?
Dossier nº #{dossier.id} accepté
- elsif dossier.without_continuation?
Dossier nº #{dossier.id} classé sans suite
- elsif dossier.refused?
Dossier nº #{dossier.id} refusé
- if dossier.motivation.present? || dossier.attestation.present?
%span.button.dropdown{ class: dossier.closed? ? 'success' : nil }
= dossier.statut
.dropdown-content.fade-in-down.terminated
- if dossier.motivation.present?
%h4 Motivation
%p.dossier-motivation= dossier.motivation
%p.dossier-motivation= dossier.motivation.present? ? dossier.motivation : "aucune motivation n'a été fournie"
- if dossier.attestation.present?
%p.attestation L'acceptation du dossier a envoyé automatiquement une attestation au demandeur
= link_to "Voir l'attestation", attestation_dossier_path(dossier.procedure, dossier), target: '_blank', class: 'button'
- if dossier.attestation.present?
%h4 Attestation
%p.attestation L'acceptation du dossier a envoyé automatiquement une attestation au demandeur
= link_to "Voir l'attestation", attestation_dossier_path(dossier.procedure, dossier), target: '_blank', class: 'button'
- else
%span.label{ class: dossier.closed? ? 'success' : nil }
= dossier.statut

View file

@ -3,7 +3,7 @@
- elsif dossier.en_construction?
%span.label.construction en construction
- elsif dossier.closed?
%span.label.closed accepté
%span.label.success accepté
- elsif dossier.refused?
%span.label.refused refusé
- elsif dossier.without_continuation?

View file

@ -46,11 +46,11 @@
.dropdown-content.fade-in-down
%ul.dropdown-items
%li
= link_to "Au format .csv", backoffice_download_dossiers_tps_path(format: :csv, procedure_id: @procedure.id), target: "_blank"
= link_to "Au format .csv", download_dossiers_procedure_path(format: :csv, procedure_id: @procedure.id), target: "_blank"
%li
= link_to "Au format .xlsx", backoffice_download_dossiers_tps_path(format: :xlsx, procedure_id: @procedure.id), target: "_blank"
= link_to "Au format .xlsx", download_dossiers_procedure_path(format: :xlsx, procedure_id: @procedure.id), target: "_blank"
%li
= link_to "Au format .ods", backoffice_download_dossiers_tps_path(format: :ods, procedure_id: @procedure.id), target: "_blank"
= link_to "Au format .ods", download_dossiers_procedure_path(format: :ods, procedure_id: @procedure.id), target: "_blank"
.container
- if @dossiers.present? || @current_filters.count > 0

View file

@ -67,7 +67,7 @@
%span.label .label
%span.label.instruction .label.instruction
%span.label.construction .label.construction
%span.label.closed .label.closed
%span.label.success .label.success
%span.label.refused .label.refused
%span.label.without-continuation .label.without-continuation

View file

@ -1,2 +1,2 @@
%input{ type: 'hidden', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", value: '' }
%input{ type: 'checkbox', style: 'margin-left: 15px;', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on') }
%input{ type: 'checkbox', style: 'margin-left: 15px;', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.object.value == 'on') }

View file

@ -240,6 +240,7 @@ Rails.application.routes.draw do
get 'update_sort/:table/:column' => 'procedures#update_sort', as: 'update_sort'
post 'add_filter'
get 'remove_filter/:statut/:table/:column' => 'procedures#remove_filter', as: 'remove_filter'
get 'download_dossiers'
resources :dossiers, only: [:show], param: :dossier_id do
member do

View file

@ -0,0 +1,20 @@
require 'spec_helper'
describe 'users/description/champs/engagement.html.haml', type: :view do
let(:type_champ) { create(:type_de_champ_public, type_champ: :engagement) }
subject { render 'users/description/champs/engagement.html.haml', champ: champ }
context "when the value is on" do
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "on").decorate }
it { is_expected.to have_selector("input[type='checkbox'][checked]") }
end
context "when the value is nil" do
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil).decorate }
it { is_expected.to have_selector("input[type='checkbox']") }
it { is_expected.not_to have_selector("input[type='checkbox'][checked]") }
end
end