Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Disable pattern input instead of hiding it for enterprise

Jan Sandbrinkcd17640f13f1
diff --git a/app/components/work_package_types/pattern_input.html.erb b/app/components/work_package_types/pattern_input.html.erb
index 818b578ac1b..48a1e010c2f 100644
--- a/app/components/work_package_types/pattern_input.html.erb
+++ b/app/components/work_package_types/pattern_input.html.erb
@@ -93,9 +93,10 @@ See COPYRIGHT and LICENSE files for more details.
render(
Primer::BaseComponent.new(
tag: :div,
- contenteditable: true,
+ contenteditable: !disabled,
+ disabled:,
border: true, border_radius: 2, p: 1,
- classes: "op-pattern-input--text-field",
+ classes: "op-pattern-input--text-field FormControl-input",
data: {
action: "keydown->pattern-input#input_keydown
input->pattern-input#input_change
diff --git a/app/components/work_package_types/pattern_input.rb b/app/components/work_package_types/pattern_input.rb
index ecc2de7e45b..d7d2bf71d8e 100644
--- a/app/components/work_package_types/pattern_input.rb
+++ b/app/components/work_package_types/pattern_input.rb
@@ -32,15 +32,16 @@ module WorkPackageTypes
class PatternInput < Primer::Forms::BaseComponent
prepend Primer::OpenProject::Forms::WrappedInput
- attr_reader :input
+ attr_reader :input, :disabled
delegate :name, to: :input
- def initialize(input:, value:, suggestions:)
+ def initialize(input:, value:, suggestions:, disabled:)
super()
@input = input
@value = value
@suggestions = suggestions
+ @disabled = disabled
end
def suggestions_for_stimulus
diff --git a/app/forms/work_package_types/subject_configuration_form.rb b/app/forms/work_package_types/subject_configuration_form.rb
index 3a52424443e..5fb4bfc4234 100644
--- a/app/forms/work_package_types/subject_configuration_form.rb
+++ b/app/forms/work_package_types/subject_configuration_form.rb
@@ -55,7 +55,7 @@ module WorkPackageTypes
toggleable_group.pattern_input(
name: :pattern,
value: model.pattern,
- hidden: !enterprise?,
+ disabled: !enterprise?,
suggestions: model.suggestions,
label: I18n.t("types.edit.subject_configuration.pattern.label"),
caption: pattern_input_caption,
diff --git a/lib/primer/open_project/forms/dsl/pattern_input.rb b/lib/primer/open_project/forms/dsl/pattern_input.rb
index 62037b627b5..5d0ada7f198 100644
--- a/lib/primer/open_project/forms/dsl/pattern_input.rb
+++ b/lib/primer/open_project/forms/dsl/pattern_input.rb
@@ -33,19 +33,20 @@ module Primer
module Forms
module Dsl
class PatternInput < Primer::Forms::Dsl::Input
- attr_reader :name, :label, :value, :suggestions
+ attr_reader :name, :label, :value, :suggestions, :disabled
- def initialize(name:, label:, value:, suggestions:, **system_arguments)
+ def initialize(name:, label:, value:, suggestions:, disabled: false, **system_arguments)
@name = name
@label = label
@value = value
@suggestions = suggestions
+ @disabled = disabled
super(**system_arguments)
end
def to_component
- WorkPackageTypes::PatternInput.new(input: self, value:, suggestions:)
+ WorkPackageTypes::PatternInput.new(input: self, value:, suggestions:, disabled:)
end
def type