Skip to content

Commit

Permalink
new TableRowSelector champ
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Oct 9, 2024
1 parent 0721ad6 commit cf3ff1e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/champ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Champ < ApplicationRecord
# pf champ
include DateEncodingConcern

delegate :accredited_user_list, :visa?, to: :type_de_champ
delegate :accredited_user_list, :visa?, :table_id, to: :type_de_champ

delegate :to_typed_id, :to_typed_id_for_query, to: :type_de_champ, prefix: true

Expand Down
21 changes: 21 additions & 0 deletions app/models/champs/table_row_selector_champ.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

class Champs::TableRowSelectorChamp < Champs::TextChamp
def fetch_external_data?
true
end

def fetch_external_data
# APIEducation::AnnuaireEducationAdapter.new(external_id).to_params
# TODO build api for TableRowSelector
end

def update_with_external_data!(data:)
if data&.is_a?(Hash)
update!(
data: data,
value: data['Mes-Démarches'] || data.first.value
)
end
end
end
8 changes: 7 additions & 1 deletion app/models/type_de_champ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TypeDeChamp < ApplicationRecord
commune_de_polynesie: 'commune_de_polynesie',
code_postal_de_polynesie: 'code_postal_de_polynesie',
numero_dn: 'numero_dn',
table_row_selector: 'table_row_selector',
te_fenua: 'te_fenua',
visa: 'visa'
}
Expand All @@ -39,6 +40,7 @@ class TypeDeChamp < ApplicationRecord
code_postal_de_polynesie: LOCALISATION,
numero_dn: REFERENTIEL_EXTERNE,
te_fenua: REFERENTIEL_EXTERNE,
table_row_selector: REFERENTIEL_EXTERNE,
visa: STRUCTURE
}

Expand Down Expand Up @@ -130,7 +132,7 @@ class TypeDeChamp < ApplicationRecord
expression_reguliere: 'expression_reguliere'
}.merge(INSTANCE_TYPE_CHAMPS)

INSTANCE_OPTIONS = [:parcelles, :batiments, :zones_manuelles, :min, :max, :level, :accredited_users]
INSTANCE_OPTIONS = [:parcelles, :batiments, :zones_manuelles, :min, :max, :level, :accredited_users, :table_id]
INSTANCE_CHAMPS_PARAMS = [:numero_dn, :date_de_naissance]

ROUTABLE_TYPES = [
Expand Down Expand Up @@ -461,6 +463,10 @@ def visa?
type_champ == TypeDeChamp.type_champs.fetch(:visa)
end

def table_row_selector?
type_champ == TypeDeChamp.type_champs.fetch(:table_row_selector)
end

def te_fenua?
type_champ == TypeDeChamp.type_champs.fetch(:te_fenua)
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/types_de_champ/table_row_selector_type_de_champ.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class TypesDeChamp::TableRowSelectorTypeDeChamp < TypesDeChamp::TypeDeChampBase
end

0 comments on commit cf3ff1e

Please sign in to comment.