Merge branch 'dev'
This commit is contained in:
commit
9456bfaa80
8 changed files with 105 additions and 8 deletions
|
@ -85,11 +85,35 @@ module NewUser
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@dossiers = current_user.dossiers.includes(:procedure).page([params[:page].to_i, 1].max)
|
@user_dossiers = current_user.dossiers.includes(:procedure).page(page)
|
||||||
|
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).page(page)
|
||||||
|
|
||||||
|
@current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count)
|
||||||
|
|
||||||
|
@dossiers = case @current_tab
|
||||||
|
when 'mes-dossiers'
|
||||||
|
@user_dossiers
|
||||||
|
when 'dossiers-invites'
|
||||||
|
@dossiers_invites
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def page
|
||||||
|
[params[:page].to_i, 1].max
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_tab(mes_dossiers_count, dossiers_invites_count)
|
||||||
|
if dossiers_invites_count == 0
|
||||||
|
'mes-dossiers'
|
||||||
|
elsif mes_dossiers_count == 0
|
||||||
|
'dossiers-invites'
|
||||||
|
else
|
||||||
|
params[:current_tab].presence || 'mes-dossiers'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# FIXME: require(:dossier) when all the champs are united
|
# FIXME: require(:dossier) when all the champs are united
|
||||||
def champs_params
|
def champs_params
|
||||||
params.permit(dossier: { champs_attributes: [:id, :value, :piece_justificative_file, value: []] })
|
params.permit(dossier: { champs_attributes: [:id, :value, :piece_justificative_file, value: []] })
|
||||||
|
|
|
@ -12,10 +12,6 @@ class RootController < ApplicationController
|
||||||
return redirect_to manager_root_path
|
return redirect_to manager_root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
if Date.today < Date.new(2018, 03, 31)
|
|
||||||
flash.now.notice = ["Téléprocédures Simplifiées change de nom et devient demarches-simplifiees.fr, <a href='https://demarches-simplifiees.gitbook.io/demarches-simplifiees/changement-de-nom' target='_blank' rel='noopener noreferrer'>en savoir plus</a>."]
|
|
||||||
end
|
|
||||||
|
|
||||||
render 'landing'
|
render 'landing'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
||||||
ATTRIBUTE_TYPES = {
|
ATTRIBUTE_TYPES = {
|
||||||
types_de_piece_justificative: TypesDePieceJustificativeCollectionField,
|
types_de_piece_justificative: TypesDePieceJustificativeCollectionField,
|
||||||
types_de_champ: TypesDeChampCollectionField,
|
types_de_champ: TypesDeChampCollectionField,
|
||||||
|
path: ProcedureLinkField,
|
||||||
dossiers: Field::HasMany,
|
dossiers: Field::HasMany,
|
||||||
procedure_path: Field::HasOne,
|
procedure_path: Field::HasOne,
|
||||||
administrateur: Field::BelongsTo,
|
administrateur: Field::BelongsTo,
|
||||||
|
@ -47,6 +48,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
||||||
# an array of attributes that will be displayed on the model's show page.
|
# an array of attributes that will be displayed on the model's show page.
|
||||||
SHOW_PAGE_ATTRIBUTES = [
|
SHOW_PAGE_ATTRIBUTES = [
|
||||||
:id,
|
:id,
|
||||||
|
:path,
|
||||||
:administrateur,
|
:administrateur,
|
||||||
:libelle,
|
:libelle,
|
||||||
:description,
|
:description,
|
||||||
|
|
7
app/fields/procedure_link_field.rb
Normal file
7
app/fields/procedure_link_field.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
require "administrate/field/base"
|
||||||
|
|
||||||
|
class ProcedureLinkField < Administrate::Field::Base
|
||||||
|
def name
|
||||||
|
"Lien procédure"
|
||||||
|
end
|
||||||
|
end
|
|
@ -14,6 +14,7 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
has_many :dossiers, dependent: :destroy
|
has_many :dossiers, dependent: :destroy
|
||||||
has_many :invites, dependent: :destroy
|
has_many :invites, dependent: :destroy
|
||||||
|
has_many :dossiers_invites, through: :invites, source: :dossier
|
||||||
has_many :piece_justificative, dependent: :destroy
|
has_many :piece_justificative, dependent: :destroy
|
||||||
has_many :cerfa, dependent: :destroy
|
has_many :cerfa, dependent: :destroy
|
||||||
has_one :france_connect_information, dependent: :destroy
|
has_one :france_connect_information, dependent: :destroy
|
||||||
|
|
4
app/views/fields/procedure_link_field/_show.html.haml
Normal file
4
app/views/fields/procedure_link_field/_show.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
- if field.data.present?
|
||||||
|
= link_to "/commencer/#{field.data}", commencer_url(procedure_path: field.data), target: '_blank'
|
||||||
|
- else
|
||||||
|
Plus en ligne
|
|
@ -1,10 +1,22 @@
|
||||||
|
.dossiers-headers.accompagnateur-header
|
||||||
.container
|
.container
|
||||||
%h1.page-title Mes dossiers
|
%h1.page-title Les dossiers
|
||||||
|
|
||||||
|
%ul.tabs
|
||||||
|
- if @user_dossiers.count > 0
|
||||||
|
%li{ class: (@current_tab == 'mes-dossiers') ? 'active' : nil }>
|
||||||
|
= link_to(dossiers_path(current_tab: 'mes-dossiers')) do
|
||||||
|
mes dossiers
|
||||||
|
- if @dossiers_invites.count > 0
|
||||||
|
%li{ class: (@current_tab == 'dossiers-invites') ? 'active' : nil }>
|
||||||
|
= link_to(dossiers_path(current_tab: 'dossiers-invites')) do
|
||||||
|
dossiers invités
|
||||||
|
|
||||||
|
.container
|
||||||
%table.table.dossiers-table.hoverable
|
%table.table.dossiers-table.hoverable
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th
|
%th.notification-col
|
||||||
%th.number-col Nº dossier
|
%th.number-col Nº dossier
|
||||||
%th Procédure
|
%th Procédure
|
||||||
%th.status-col Statut
|
%th.status-col Statut
|
||||||
|
|
|
@ -333,4 +333,55 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#index' do
|
||||||
|
before { sign_in(user) }
|
||||||
|
|
||||||
|
context 'when the user does not have any dossiers' do
|
||||||
|
before { get(:index) }
|
||||||
|
|
||||||
|
it { expect(assigns(:current_tab)).to eq('mes-dossiers') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the user only have its own dossiers' do
|
||||||
|
let!(:own_dossier) { create(:dossier, user: user) }
|
||||||
|
|
||||||
|
before { get(:index) }
|
||||||
|
|
||||||
|
it { expect(assigns(:current_tab)).to eq('mes-dossiers') }
|
||||||
|
it { expect(assigns(:dossiers)).to match([own_dossier]) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the user only have some dossiers invites' do
|
||||||
|
let!(:invite) { create(:invite, dossier: create(:dossier), user: user, type: 'InviteUser') }
|
||||||
|
|
||||||
|
before { get(:index) }
|
||||||
|
|
||||||
|
it { expect(assigns(:current_tab)).to eq('dossiers-invites') }
|
||||||
|
it { expect(assigns(:dossiers)).to match([invite.dossier]) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the user has both' do
|
||||||
|
let!(:own_dossier) { create(:dossier, user: user) }
|
||||||
|
let!(:invite) { create(:invite, dossier: create(:dossier), user: user, type: 'InviteUser') }
|
||||||
|
|
||||||
|
context 'and there is no current_tab param' do
|
||||||
|
before { get(:index) }
|
||||||
|
|
||||||
|
it { expect(assigns(:current_tab)).to eq('mes-dossiers') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'and there is "dossiers-invites" param' do
|
||||||
|
before { get(:index, params: { current_tab: 'dossiers-invites' }) }
|
||||||
|
|
||||||
|
it { expect(assigns(:current_tab)).to eq('dossiers-invites') }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'and there is "mes-dossiers" param' do
|
||||||
|
before { get(:index, params: { current_tab: 'mes-dossiers' }) }
|
||||||
|
|
||||||
|
it { expect(assigns(:current_tab)).to eq('mes-dossiers') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue