Merge pull request #944 from sgmap/show_new_dossier_first
Show new dossier first
This commit is contained in:
commit
c5b678242a
6 changed files with 50 additions and 12 deletions
|
@ -33,17 +33,30 @@
|
|||
}
|
||||
|
||||
.icon.folder {
|
||||
margin-right: $default-spacer;
|
||||
position: relative;
|
||||
|
||||
.notifications {
|
||||
top: 0px;
|
||||
right: -10px;
|
||||
top: -3px;
|
||||
right: -6px;
|
||||
}
|
||||
}
|
||||
|
||||
.notification-col {
|
||||
width: 30px;
|
||||
text-align: center;
|
||||
|
||||
a {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.number-col {
|
||||
width: 110px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.folder-col {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.status-col {
|
||||
|
|
|
@ -240,7 +240,16 @@ module NewGestionnaire
|
|||
includes = ''
|
||||
where = ''
|
||||
|
||||
sorted_ids = nil
|
||||
|
||||
case table
|
||||
when 'notifications'
|
||||
dossiers_id_with_notification = current_gestionnaire.notifications_for_procedure(procedure)
|
||||
if order == 'desc'
|
||||
sorted_ids = dossiers_id_with_notification + (dossiers.order('dossiers.updated_at desc').ids - dossiers_id_with_notification)
|
||||
else
|
||||
sorted_ids = (dossiers.order('dossiers.updated_at asc').ids - dossiers_id_with_notification) + dossiers_id_with_notification
|
||||
end
|
||||
when 'self'
|
||||
order = "dossiers.#{column} #{order}"
|
||||
when'france_connect_information'
|
||||
|
@ -255,7 +264,11 @@ module NewGestionnaire
|
|||
order = "#{table.pluralize}.#{column} #{order}"
|
||||
end
|
||||
|
||||
dossiers.includes(includes).where(where).order(Dossier.sanitize_for_order(order)).pluck(:id)
|
||||
if sorted_ids.nil?
|
||||
sorted_ids = dossiers.includes(includes).where(where).order(Dossier.sanitize_for_order(order)).pluck(:id)
|
||||
end
|
||||
|
||||
sorted_ids
|
||||
end
|
||||
|
||||
def current_filters
|
||||
|
|
|
@ -74,6 +74,11 @@
|
|||
%table.table.dossiers-table.hoverable
|
||||
%thead
|
||||
%tr
|
||||
- if @statut == 'suivis' || @statut == 'tous'
|
||||
= render partial: "header_field", locals: { field: { "label" => "●", "table" => "notifications", "column" => "notifications" }, classname: "notification-col" }
|
||||
- else
|
||||
%th.notification-col
|
||||
|
||||
= render partial: "header_field", locals: { field: { "label" => "Nº dossier", "table" => "self", "column" => "id" }, classname: "number-col" }
|
||||
|
||||
- @displayed_fields.each do |field|
|
||||
|
@ -96,11 +101,13 @@
|
|||
%tbody
|
||||
- @dossiers.each do |dossier|
|
||||
%tr
|
||||
%td.folder-col
|
||||
.icon.folder
|
||||
- if current_gestionnaire.notifications_for_procedure(@procedure).include?(dossier.id)
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
|
||||
%td.number-col
|
||||
= link_to(dossier_path(@procedure, dossier), class: 'cell-link') do
|
||||
.icon.folder
|
||||
- if current_gestionnaire.notifications_for_procedure(@procedure).include?(dossier.id)
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
= dossier.id
|
||||
|
||||
- @displayed_fields.each do |field|
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class ChangeProcedurePresentationDefault < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
change_column_default :procedure_presentations, :sort, from: { "table" => "self", "column" => "id", "order" => "desc" }.to_json, to: { "table" => "notifications", "column" => "notifications", "order" => "desc" }.to_json
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20171024135653) do
|
||||
ActiveRecord::Schema.define(version: 20171117165748) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -394,9 +394,9 @@ ActiveRecord::Schema.define(version: 20171024135653) do
|
|||
|
||||
create_table "procedure_presentations", force: :cascade do |t|
|
||||
t.integer "assign_to_id"
|
||||
t.text "displayed_fields", default: ["{\"label\":\"Demandeur\",\"table\":\"user\",\"column\":\"email\"}"], null: false, array: true
|
||||
t.json "sort", default: "{\"table\":\"self\",\"column\":\"id\",\"order\":\"desc\"}", null: false
|
||||
t.json "filters", default: "{\"a-suivre\":[],\"suivis\":[],\"traites\":[],\"tous\":[],\"archives\":[]}", null: false
|
||||
t.text "displayed_fields", default: ["{\"label\":\"Demandeur\",\"table\":\"user\",\"column\":\"email\"}"], null: false, array: true
|
||||
t.json "sort", default: "{\"table\":\"notifications\",\"column\":\"notifications\",\"order\":\"desc\"}", null: false
|
||||
t.json "filters", default: "{\"a-suivre\":[],\"suivis\":[],\"traites\":[],\"tous\":[],\"archives\":[]}", null: false
|
||||
t.index ["assign_to_id"], name: "index_procedure_presentations_on_assign_to_id", unique: true, using: :btree
|
||||
end
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
let(:statut) { 'tous' }
|
||||
|
||||
it { expect(assigns(:statut)).to eq('tous') }
|
||||
it { expect(assigns(:dossiers)).to match([a_suivre__dossier, new_followed_dossier, termine_dossier].sort_by(&:updated_at)) }
|
||||
it { expect(assigns(:dossiers)).to match_array([a_suivre__dossier, new_followed_dossier, termine_dossier]) }
|
||||
end
|
||||
|
||||
context 'when statut is archives' do
|
||||
|
|
Loading…
Reference in a new issue