[Fix #1098] Custom TypesDeChampCollectionField for Administrate
This commit is contained in:
parent
65f0859357
commit
51b94e2f53
5 changed files with 28 additions and 1 deletions
|
@ -9,7 +9,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
# on pages throughout the dashboard.
|
||||
ATTRIBUTE_TYPES = {
|
||||
types_de_piece_justificative: Field::HasMany,
|
||||
types_de_champ: Field::HasMany.with_options(class_name: "TypeDeChampPublic"),
|
||||
types_de_champ: TypesDeChampCollectionField,
|
||||
dossiers: Field::HasMany,
|
||||
procedure_path: Field::HasOne,
|
||||
administrateur: Field::BelongsTo,
|
||||
|
|
7
app/fields/types_de_champ_collection_field.rb
Normal file
7
app/fields/types_de_champ_collection_field.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require "administrate/field/base"
|
||||
|
||||
class TypesDeChampCollectionField < Administrate::Field::Base
|
||||
def to_s
|
||||
data
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
.field-unit__label
|
||||
= f.label field.attribute
|
||||
.field-unit__field
|
||||
= f.text_field field.attribute
|
|
@ -0,0 +1 @@
|
|||
= field.to_s
|
|
@ -0,0 +1,15 @@
|
|||
- if field.data.any?
|
||||
%table.collection-data{ "aria-labelledby": "page-title" }
|
||||
%thead
|
||||
%tr
|
||||
%td.cell-label Libelle
|
||||
%td.cell-label Type de champ
|
||||
%tbody
|
||||
- field.data.order(:order_place).each do |f|
|
||||
%tr
|
||||
%td.cell-data
|
||||
= f.libelle
|
||||
%td.cell-data
|
||||
= I18n.t("activerecord.attributes.type_de_champ.type_champs.#{f.type_champ}")
|
||||
- else
|
||||
Aucun
|
Loading…
Reference in a new issue