diff --git a/app/forms/work_packages/types/subject_configuration_form.rb b/app/forms/work_packages/types/subject_configuration_form.rb index f71032f1b94a..86dc58cdbdfc 100644 --- a/app/forms/work_packages/types/subject_configuration_form.rb +++ b/app/forms/work_packages/types/subject_configuration_form.rb @@ -59,12 +59,11 @@ def has_pattern?(type) subject_form.group(data: { "admin--subject-configuration-target": "patternInput" }) do |toggleable_group| toggleable_group.pattern_autocompleter( name: :subject_pattern, - pattern: subject_pattern, + value: subject_pattern, suggestions: ::Types::Patterns::TokenPropertyMapper.new.tokens_for_type(model), label: I18n.t("types.edit.subject_configuration.pattern.label"), caption: I18n.t("types.edit.subject_configuration.pattern.caption"), - required: true, - input_width: :large + required: true ) end diff --git a/lib/primer/open_project/forms/dsl/pattern_autocompleter_input.rb b/lib/primer/open_project/forms/dsl/pattern_autocompleter_input.rb index 7e1095954f2e..6f86f72bf507 100644 --- a/lib/primer/open_project/forms/dsl/pattern_autocompleter_input.rb +++ b/lib/primer/open_project/forms/dsl/pattern_autocompleter_input.rb @@ -5,19 +5,18 @@ module OpenProject module Forms module Dsl class PatternAutocompleterInput < Primer::Forms::Dsl::Input - attr_reader :name, :label, :pattern, :suggestions + attr_reader :name, :value, :suggestions - def initialize(name:, label:, pattern:, suggestions:, **system_arguments) + def initialize(name:, value:, suggestions:, **system_arguments) @name = name - @label = label - @pattern = pattern + @value = value @suggestions = suggestions super(**system_arguments) end def to_component - PatternAutocompleter.new(name:, label:, pattern:, suggestions:) + PatternAutocompleter.new(input: self, value:, suggestions:) end def type diff --git a/lib/primer/open_project/forms/pattern_autocompleter.html.erb b/lib/primer/open_project/forms/pattern_autocompleter.html.erb index 4db83abf7e3d..52097dc68c18 100644 --- a/lib/primer/open_project/forms/pattern_autocompleter.html.erb +++ b/lib/primer/open_project/forms/pattern_autocompleter.html.erb @@ -10,18 +10,16 @@ :div, class: "pattern-autocompleter", "data-controller": "pattern-autocompleter", - "data-pattern-autocompleter-pattern-initial-value": @pattern + "data-pattern-autocompleter-pattern-initial-value": @value ) do %> <%= - render( - Primer::Alpha::TextField.new( - label: @label, - name: @name, - hidden: true, # set to false for debugging - value: @pattern, - data: { "pattern-autocompleter-target": "formInput" } - ) + @input.builder.hidden_field( + name, + value: @value, + data: { + "pattern-autocompleter-target": "formInput" + } ) %> diff --git a/lib/primer/open_project/forms/pattern_autocompleter.rb b/lib/primer/open_project/forms/pattern_autocompleter.rb index 01db0e270a0c..cd73c0275e63 100644 --- a/lib/primer/open_project/forms/pattern_autocompleter.rb +++ b/lib/primer/open_project/forms/pattern_autocompleter.rb @@ -4,11 +4,12 @@ module Primer module OpenProject module Forms class PatternAutocompleter < Primer::Forms::BaseComponent - def initialize(name:, label:, pattern:, suggestions:) + delegate :name, to: :@input + + def initialize(input:, value:, suggestions:) super() - @name = name - @label = label - @pattern = pattern + @input = input + @value = value @suggestions = suggestions end