Manager: improve dossier view
This commit is contained in:
parent
afc2f2cd8e
commit
2f66625f18
5 changed files with 50 additions and 10 deletions
|
@ -16,7 +16,7 @@ class DossierDashboard < Administrate::BaseDashboard
|
||||||
created_at: Field::DateTime,
|
created_at: Field::DateTime,
|
||||||
updated_at: Field::DateTime,
|
updated_at: Field::DateTime,
|
||||||
hidden_at: Field::DateTime,
|
hidden_at: Field::DateTime,
|
||||||
types_de_champ: TypesDeChampCollectionField
|
champs: ChampCollectionField
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# COLLECTION_ATTRIBUTES
|
# COLLECTION_ATTRIBUTES
|
||||||
|
@ -38,7 +38,7 @@ class DossierDashboard < Administrate::BaseDashboard
|
||||||
:state,
|
:state,
|
||||||
:procedure,
|
:procedure,
|
||||||
:user,
|
:user,
|
||||||
:types_de_champ,
|
:champs,
|
||||||
:created_at,
|
:created_at,
|
||||||
:updated_at,
|
:updated_at,
|
||||||
:hidden_at
|
:hidden_at
|
||||||
|
|
7
app/fields/champ_collection_field.rb
Normal file
7
app/fields/champ_collection_field.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
require "administrate/field/base"
|
||||||
|
|
||||||
|
class ChampCollectionField < Administrate::Field::Base
|
||||||
|
def to_s
|
||||||
|
data
|
||||||
|
end
|
||||||
|
end
|
|
@ -23,15 +23,15 @@ class Champ < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def mandatory_and_blank?
|
def mandatory_and_blank?
|
||||||
if mandatory?
|
mandatory? && blank?
|
||||||
case type_de_champ.type_champ
|
end
|
||||||
when TypeDeChamp.type_champs.fetch(:carte)
|
|
||||||
value.blank? || value == '[]'
|
def blank?
|
||||||
else
|
case type_de_champ.type_champ
|
||||||
value.blank?
|
when TypeDeChamp.type_champs.fetch(:carte)
|
||||||
end
|
value.blank? || value == '[]'
|
||||||
else
|
else
|
||||||
false
|
value.blank?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
24
app/views/fields/champ_collection_field/_show.html.haml
Normal file
24
app/views/fields/champ_collection_field/_show.html.haml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
- if field.data.any?
|
||||||
|
%table.collection-data{ "aria-labelledby": "page-title" }
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%td.cell-label Libelle
|
||||||
|
%td.cell-label Type de champ
|
||||||
|
%td.cell-label Rempli
|
||||||
|
%tbody
|
||||||
|
- field.data.each do |f|
|
||||||
|
%tr
|
||||||
|
%td.cell-data
|
||||||
|
= f.libelle
|
||||||
|
- if f.mandatory?
|
||||||
|
%span.mandatory{ style: 'color: #A10005;' } *
|
||||||
|
%td.cell-data
|
||||||
|
= I18n.t("activerecord.attributes.type_de_champ.type_champs.#{f.type_champ}")
|
||||||
|
|
||||||
|
%td.cell-data
|
||||||
|
- if f.blank?
|
||||||
|
vide
|
||||||
|
- else
|
||||||
|
rempli
|
||||||
|
- else
|
||||||
|
Aucun
|
|
@ -4,12 +4,21 @@
|
||||||
%tr
|
%tr
|
||||||
%td.cell-label Libelle
|
%td.cell-label Libelle
|
||||||
%td.cell-label Type de champ
|
%td.cell-label Type de champ
|
||||||
|
%td.cell-label Rempli
|
||||||
%tbody
|
%tbody
|
||||||
- field.data.order(:order_place).each do |f|
|
- field.data.order(:order_place).each do |f|
|
||||||
%tr
|
%tr
|
||||||
%td.cell-data
|
%td.cell-data
|
||||||
= f.libelle
|
= f.libelle
|
||||||
|
- if f.mandatory?
|
||||||
|
%span.mandatory{ style: 'color: #A10005;' } *
|
||||||
%td.cell-data
|
%td.cell-data
|
||||||
= I18n.t("activerecord.attributes.type_de_champ.type_champs.#{f.type_champ}")
|
= I18n.t("activerecord.attributes.type_de_champ.type_champs.#{f.type_champ}")
|
||||||
|
|
||||||
|
%td.cell-data
|
||||||
|
- if f.blank?
|
||||||
|
vide
|
||||||
|
- else
|
||||||
|
rempli
|
||||||
- else
|
- else
|
||||||
Aucun
|
Aucun
|
||||||
|
|
Loading…
Reference in a new issue