Skip to content

Commit

Permalink
Merge pull request #17268 from opf/implementation/59037-primerize-log…
Browse files Browse the repository at this point in the history
…-time-dialog

[#59037] Primerize "Log time" dialog
  • Loading branch information
klaustopher authored Jan 16, 2025
2 parents 0080542 + 7cd5622 commit 4472737
Show file tree
Hide file tree
Showing 63 changed files with 2,406 additions and 442 deletions.
4 changes: 4 additions & 0 deletions app/controllers/concerns/op_turbo/component_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def add_caption_to_input_element_via_turbo_stream(target, caption:, clean_other_
.render_in(view_context)
end

def close_dialog_via_turbo_stream(target)
turbo_streams << OpTurbo::StreamComponent.new(action: :closeDialog, target:).render_in(view_context)
end

def turbo_streams
@turbo_streams ||= []
end
Expand Down
2 changes: 2 additions & 0 deletions app/forms/custom_fields/custom_field_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#++

module CustomFields::CustomFieldRendering
include ActiveSupport::Concern

def render_custom_fields(form:)
custom_fields.each do |custom_field|
form.fields_for(:custom_field_values) do |builder|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
Expand Down
2 changes: 2 additions & 0 deletions app/forms/custom_fields/inputs/base/input.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
Expand Down
2 changes: 2 additions & 0 deletions app/forms/custom_fields/inputs/multi_select_list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
Expand Down
2 changes: 2 additions & 0 deletions app/forms/custom_fields/inputs/multi_user_select_list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
Expand Down
2 changes: 2 additions & 0 deletions app/forms/custom_fields/inputs/multi_version_select_list.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
Expand Down
67 changes: 10 additions & 57 deletions app/forms/projects/custom_fields/form.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
Expand Down Expand Up @@ -27,12 +29,10 @@
#++
module Projects::CustomFields
class Form < ApplicationForm
include CustomFields::CustomFieldRendering

form do |custom_fields_form|
custom_fields.each do |custom_field|
custom_fields_form.fields_for(:custom_field_values) do |builder|
custom_field_input(builder, custom_field)
end
end
render_custom_fields(form: custom_fields_form)
end

def initialize(project:, custom_field_section: nil, custom_field: nil, wrapper_id: nil)
Expand All @@ -48,6 +48,11 @@ def initialize(project:, custom_field_section: nil, custom_field: nil, wrapper_i
end
end

# override since we want to add the model with @project
def additional_custom_field_input_arguments
{ model: @project, wrapper_id: @wrapper_id }
end

private

def custom_fields
Expand All @@ -62,57 +67,5 @@ def custom_fields
@project.available_custom_fields
end
end

def custom_field_input(builder, custom_field)
if custom_field.multi_value?
multi_value_custom_field_input(builder, custom_field)
else
single_value_custom_field_input(builder, custom_field)
end
end

# TBD: transform inputs called below to primer form dsl instead of form classes?
# TODOS:
# - initial values for user inputs are not displayed
# - allow/disallow-non-open version setting is not yet respected in the version selector
# - rich text editor is not yet supported

def single_value_custom_field_input(builder, custom_field)
form_args = { custom_field:, object: @project, wrapper_id: @wrapper_id }

case custom_field.field_format
when "string", "link"
CustomFields::Inputs::String.new(builder, **form_args)
when "text"
CustomFields::Inputs::Text.new(builder, **form_args)
when "int"
CustomFields::Inputs::Int.new(builder, **form_args)
when "float"
CustomFields::Inputs::Float.new(builder, **form_args)
when "list"
CustomFields::Inputs::SingleSelectList.new(builder, **form_args)
when "date"
CustomFields::Inputs::Date.new(builder, **form_args)
when "bool"
CustomFields::Inputs::Bool.new(builder, **form_args)
when "user"
CustomFields::Inputs::SingleUserSelectList.new(builder, **form_args)
when "version"
CustomFields::Inputs::SingleVersionSelectList.new(builder, **form_args)
end
end

def multi_value_custom_field_input(builder, custom_field)
form_args = { custom_field:, object: @project, wrapper_id: @wrapper_id }

case custom_field.field_format
when "list"
CustomFields::Inputs::MultiSelectList.new(builder, **form_args)
when "user"
CustomFields::Inputs::MultiUserSelectList.new(builder, **form_args)
when "version"
CustomFields::Inputs::MultiVersionSelectList.new(builder, **form_args)
end
end
end
end
24 changes: 24 additions & 0 deletions frontend/src/app/core/path-helper/path-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,28 @@ export class PathHelperService {
public jobStatusModalPath(jobId:string) {
return `${this.staticBase}/job_statuses/${jobId}/dialog`;
}

public timeEntriesUserTimezoneCaption(userId:string) {
return `${this.staticBase}/time_entries/users/${userId}/tz_caption`;
}

public timeEntriesWorkPackageActivity(workPackageId:string) {
return `${this.staticBase}/time_entries/work_packages/${workPackageId}/time_entry_activities`;
}

public timeEntryDialog() {
return `${this.staticBase}/time_entries/dialog`;
}

public timeEntryEditDialog(timeEntryId:string) {
return `${this.staticBase}/time_entries/${timeEntryId}/dialog`;
}

public timeEntryWorkPackageDialog(workPackageId:string) {
return `${this.workPackagePath(workPackageId)}/time_entries/dialog`;
}

public timeEntryProjectDialog(projectId:string) {
return `${this.projectPath(projectId)}/time_entries/dialog`;
}
}
Loading

0 comments on commit 4472737

Please sign in to comment.