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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add Feature Decision and setting for the costs module
Klaus Zanders3b0fb36dedac
diff --git a/modules/costs/app/models/time_entry.rb b/modules/costs/app/models/time_entry.rbindex 1388a237993..23489e88d08 100644--- a/modules/costs/app/models/time_entry.rb+++ b/modules/costs/app/models/time_entry.rb@@ -101,6 +101,11 @@ class TimeEntry < ApplicationRecord(user_id == usr.id && usr.allowed_in_project?(:view_own_hourly_rate, project))end+ def self.can_track_start_and_end_time?+ OpenProject::FeatureDecisions.track_start_and_end_times_for_time_entries_active? &&+ ActiveRecord::Type::Boolean.new.cast(Setting.plugin_costs["costs_currency"])+ end+privatedef cost_attributediff --git a/modules/costs/app/views/settings/_costs.html.erb b/modules/costs/app/views/settings/_costs.html.erbindex d1683e430c7..6e040565dcb 100644--- a/modules/costs/app/views/settings/_costs.html.erb+++ b/modules/costs/app/views/settings/_costs.html.erb@@ -41,3 +41,13 @@ See COPYRIGHT and LICENSE files for more details.<%= styled_text_field_tag 'settings[costs_currency_format]', @settings['costs_currency_format'], container_class: '-xslim' %></div></div>++<%- if OpenProject::FeatureDecisions.track_start_and_end_times_for_time_entries_active? %>+ <div class="form--field">+ <%= styled_label_tag :label_track_start_and_end_times, t(:label_track_start_and_end_times) %>+ <div class="form--field-container">+ <%= hidden_field_tag "settings[track_start_and_end_times]", 'false' %>+ <%= styled_check_box_tag "settings[track_start_and_end_times]", 'true', ActiveRecord::Type::Boolean.new.cast(@settings['track_start_and_end_times']) %>+ </div>+ </div>+<%- end %>diff --git a/modules/costs/config/locales/en.yml b/modules/costs/config/locales/en.ymlindex a143a293300..49938da5df8 100644--- a/modules/costs/config/locales/en.yml+++ b/modules/costs/config/locales/en.yml@@ -126,6 +126,7 @@ en:label_rate_plural: "Rates"label_status_finished: "Finished"label_show: "Show"+ label_track_start_and_end_times: "Time records with start and end time"label_units: "Cost units"label_user: "User"label_until: "until"@@ -135,7 +136,7 @@ en:notice_something_wrong: "Something went wrong. Please try again."notice_successful_restore: "Successful restore."notice_successful_lock: "Locked successfully."- notice_cost_logged_successfully: 'Unit cost logged successfully.'+ notice_cost_logged_successfully: "Unit cost logged successfully."permission_edit_cost_entries: "Edit booked unit costs"permission_edit_own_cost_entries: "Edit own booked unit costs"diff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rbindex f51fed3c2dc..bd17020ba23 100644--- a/modules/costs/lib/costs/engine.rb+++ b/modules/costs/lib/costs/engine.rb@@ -38,7 +38,11 @@ module Costsauthor_url: "https://www.openproject.org",bundled: true,settings: {- default: { "costs_currency" => "EUR", "costs_currency_format" => "%n %u" },+ default: {+ "costs_currency" => "EUR",+ "costs_currency_format" => "%n %u",+ "track_start_and_end_times" => "false"+ },partial: "settings/costs",page_title_key: :label_setting_plural,breadcrumb_elements: -> {@@ -132,6 +136,11 @@ module Costscaption: :label_cost_type_pluralend+ initializer "costs.feature_decisions" do+ OpenProject::FeatureDecisions.add :track_start_and_end_times_for_time_entries,+ description: "Allows admins to enable tracking start and end times for time entries"+ end+activity_provider :time_entries, class_name: "Activities::TimeEntryActivityProvider", default: falsepatches %i[Project User PermittedParams]