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,
|
||||
updated_at: Field::DateTime,
|
||||
hidden_at: Field::DateTime,
|
||||
types_de_champ: TypesDeChampCollectionField
|
||||
champs: ChampCollectionField
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
|
@ -38,7 +38,7 @@ class DossierDashboard < Administrate::BaseDashboard
|
|||
:state,
|
||||
:procedure,
|
||||
:user,
|
||||
:types_de_champ,
|
||||
:champs,
|
||||
:created_at,
|
||||
:updated_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
|
||||
|
||||
def mandatory_and_blank?
|
||||
if mandatory?
|
||||
case type_de_champ.type_champ
|
||||
when TypeDeChamp.type_champs.fetch(:carte)
|
||||
value.blank? || value == '[]'
|
||||
else
|
||||
value.blank?
|
||||
end
|
||||
mandatory? && blank?
|
||||
end
|
||||
|
||||
def blank?
|
||||
case type_de_champ.type_champ
|
||||
when TypeDeChamp.type_champs.fetch(:carte)
|
||||
value.blank? || value == '[]'
|
||||
else
|
||||
false
|
||||
value.blank?
|
||||
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
|
||||
%td.cell-label Libelle
|
||||
%td.cell-label Type de champ
|
||||
%td.cell-label Rempli
|
||||
%tbody
|
||||
- field.data.order(:order_place).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
|
||||
|
|
Loading…
Reference in a new issue