model: add estimated_fill_duration to type_de_champ
This commit is contained in:
parent
62d5778790
commit
3b57d98692
13 changed files with 54 additions and 0 deletions
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::AnnuaireEducationTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
class TypesDeChamp::AnnuaireEducationTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_MEDIUM
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,4 +11,8 @@ class TypesDeChamp::CarteTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
:znieff,
|
:znieff,
|
||||||
:cadastres
|
:cadastres
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_LONG
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::CnafTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
class TypesDeChamp::CnafTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_MEDIUM
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::DgfipTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
class TypesDeChamp::DgfipTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_MEDIUM
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::IbanTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
class TypesDeChamp::IbanTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_MEDIUM
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::MesriTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
class TypesDeChamp::MesriTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_MEDIUM
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::PieceJustificativeTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
class TypesDeChamp::PieceJustificativeTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_LONG
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::PoleEmploiTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
class TypesDeChamp::PoleEmploiTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_MEDIUM
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,15 @@ class TypesDeChamp::RepetitionTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
champ
|
champ
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
estimated_rows_in_repetition = 2.5
|
||||||
|
estimated_row_duration = @type_de_champ
|
||||||
|
.types_de_champ
|
||||||
|
.map { |child_tdc| child_tdc.estimated_fill_duration(revision) }
|
||||||
|
.sum
|
||||||
|
estimated_row_duration * estimated_rows_in_repetition
|
||||||
|
end
|
||||||
|
|
||||||
# We have to truncate the label here as spreadsheets have a (30 char) limit on length.
|
# We have to truncate the label here as spreadsheets have a (30 char) limit on length.
|
||||||
def libelle_for_export(index = 0)
|
def libelle_for_export(index = 0)
|
||||||
str = "(#{stable_id}) #{libelle}"
|
str = "(#{stable_id}) #{libelle}"
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::SiretTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
class TypesDeChamp::SiretTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_MEDIUM
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
class TypesDeChamp::TextareaTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
class TypesDeChamp::TextareaTypeDeChamp < TypesDeChamp::TextTypeDeChamp
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_MEDIUM
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
class TypesDeChamp::TitreIdentiteTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
class TypesDeChamp::TitreIdentiteTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
FRANCE_CONNECT = 'france_connect'
|
FRANCE_CONNECT = 'france_connect'
|
||||||
PIECE_JUSTIFICATIVE = 'piece_justificative'
|
PIECE_JUSTIFICATIVE = 'piece_justificative'
|
||||||
|
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_LONG
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,10 @@ class TypesDeChamp::TypeDeChampBase
|
||||||
|
|
||||||
delegate :description, :libelle, :stable_id, to: :@type_de_champ
|
delegate :description, :libelle, :stable_id, to: :@type_de_champ
|
||||||
|
|
||||||
|
FILL_DURATION_SHORT = 10.seconds.in_seconds
|
||||||
|
FILL_DURATION_MEDIUM = 1.minute.in_seconds
|
||||||
|
FILL_DURATION_LONG = 3.minutes.in_seconds
|
||||||
|
|
||||||
def initialize(type_de_champ)
|
def initialize(type_de_champ)
|
||||||
@type_de_champ = type_de_champ
|
@type_de_champ = type_de_champ
|
||||||
end
|
end
|
||||||
|
@ -25,6 +29,12 @@ class TypesDeChamp::TypeDeChampBase
|
||||||
libelle
|
libelle
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Default estimated duration to fill the champ in a form, in seconds.
|
||||||
|
# May be overridden by subclasses.
|
||||||
|
def estimated_fill_duration(revision)
|
||||||
|
FILL_DURATION_SHORT
|
||||||
|
end
|
||||||
|
|
||||||
def build_champ(params)
|
def build_champ(params)
|
||||||
@type_de_champ.champ.build(params)
|
@type_de_champ.champ.build(params)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue