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
implement form for time entry activities
Klaus Zandersf1bb16afb4ca
diff --git a/app/models/enumeration.rb b/app/models/enumeration.rbindex 4a0a3ed9845..34e99d76ad0 100644--- a/app/models/enumeration.rb+++ b/app/models/enumeration.rb@@ -51,9 +51,14 @@ class Enumeration < ApplicationRecord# let all child classes have Enumeration as its model name# used to not having to create another route for every subclass of Enumerationdef self.inherited(child)- child.instance_eval do- def model_name- Enumeration.model_name+ # in the long run we probably want to have seperate pages, time entry activities are first so we skipt it here+ enumerations_with_own_settings = %w(TimeEntryActivity)++ unless child.name.in?(enumerations_with_own_settings)+ child.instance_eval do+ def model_name+ Enumeration.model_name+ endendendsuperdiff --git a/modules/costs/app/components/admin/time_entry_activities/activity_form.rb b/modules/costs/app/components/admin/time_entry_activities/activity_form.rbnew file mode 100644index 00000000000..67d5cc36fcf--- /dev/null+++ b/modules/costs/app/components/admin/time_entry_activities/activity_form.rb@@ -0,0 +1,54 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module Admin+ module TimeEntryActivities+ class ActivityForm < ApplicationForm+ form do |form|+ form.text_field(+ name: :name,+ label: TimeEntryActivity.human_attribute_name(:name),+ required: true,+ input_width: :large+ )+ form.check_box(+ name: :active,+ label: TimeEntryActivity.human_attribute_name(:active)+ )++ form.submit(+ name: :submit,+ label: I18n.t(:button_save),+ scheme: :primary+ )+ end+ end+ end+enddiff --git a/modules/costs/app/components/time_entries/days_and_hours_form.rb b/modules/costs/app/components/time_entries/days_and_hours_form.rbindex 0e25d1fe2b0..babcf7ffda8 100644--- a/modules/costs/app/components/time_entries/days_and_hours_form.rb+++ b/modules/costs/app/components/time_entries/days_and_hours_form.rb@@ -50,6 +50,7 @@ module TimeEntriesrequired: start_and_end_time_required?,label: TimeEntry.human_attribute_name(:start_time),value: model.start_timestamp&.strftime("%H:%M"),+ placeholder: "--:--",show_clear_button: true,data: {"time-entry-target" => "startTimeInput",@@ -61,6 +62,7 @@ module TimeEntriesrequired: start_and_end_time_required?,label: TimeEntry.human_attribute_name(:end_time),value: model.end_timestamp&.strftime("%H:%M"),+ placeholder: "--:--",show_clear_button: true,caption: end_time_caption,data: {diff --git a/modules/costs/app/controllers/admin/time_entry_activities_controller.rb b/modules/costs/app/controllers/admin/time_entry_activities_controller.rbindex 080a39e95cd..e457a0fe5f2 100644--- a/modules/costs/app/controllers/admin/time_entry_activities_controller.rb+++ b/modules/costs/app/controllers/admin/time_entry_activities_controller.rb@@ -40,9 +40,13 @@ module Admin@time_entry_activities = TimeEntryActivity.allend- def new; end+ def new+ @time_entry_activity = TimeEntryActivity.new+ end- def edit; end+ def edit+ @time_entry_activity = TimeEntryActivity.find(params[:id])+ enddef create; enddiff --git a/modules/costs/app/views/admin/time_entry_activities/edit.html.erb b/modules/costs/app/views/admin/time_entry_activities/edit.html.erbindex e69de29bb2d..3bd21a8fae9 100644--- a/modules/costs/app/views/admin/time_entry_activities/edit.html.erb+++ b/modules/costs/app/views/admin/time_entry_activities/edit.html.erb@@ -0,0 +1,48 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) the OpenProject GmbH++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License version 3.++OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+Copyright (C) 2006-2013 Jean-Philippe Lang+Copyright (C) 2010-2013 the ChiliProject Team++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License+as published by the Free Software Foundation; either version 2+of the License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.v+See COPYRIGHT and LICENSE files for more details.++++#%>++<% html_title t(:label_administration), t(:enumeration_activities) %>++<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { @time_entry_activity.name }+ header.with_description { I18n.t(:label_time_entry_activity_form_description) }+ header.with_breadcrumbs(+ [+ { href: admin_index_path, text: t("label_administration") },+ { href: admin_costs_settings_path, text: t(:project_module_costs) },+ { href: admin_time_entry_activities_path, text: I18n.t(:enumeration_activities) },+ @time_entry_activity.name+ ]+ )+ end+%>++<%= primer_form_with(model: @time_entry_activity, url: admin_time_entry_activity_path(@time_entry_activity)) do |f| %>+ <%= render(Admin::TimeEntryActivities::ActivityForm.new(f)) %>+<% end %>diff --git a/modules/costs/app/views/admin/time_entry_activities/new.html.erb b/modules/costs/app/views/admin/time_entry_activities/new.html.erbindex e69de29bb2d..382f7d41ec4 100644--- a/modules/costs/app/views/admin/time_entry_activities/new.html.erb+++ b/modules/costs/app/views/admin/time_entry_activities/new.html.erb@@ -0,0 +1,48 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) the OpenProject GmbH++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License version 3.++OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+Copyright (C) 2006-2013 Jean-Philippe Lang+Copyright (C) 2010-2013 the ChiliProject Team++This program is free software; you can redistribute it and/or+modify it under the terms of the GNU General Public License+as published by the Free Software Foundation; either version 2+of the License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.v+See COPYRIGHT and LICENSE files for more details.++++#%>++<% html_title t(:label_administration), t(:enumeration_activities) %>++<%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { I18n.t(:label_new_time_entry_activity) }+ header.with_description { I18n.t(:label_time_entry_activity_form_description) }+ header.with_breadcrumbs(+ [+ { href: admin_index_path, text: t("label_administration") },+ { href: admin_costs_settings_path, text: t(:project_module_costs) },+ { href: admin_time_entry_activities_path, text: I18n.t(:enumeration_activities) },+ I18n.t(:label_new_time_entry_activity)+ ]+ )+ end+%>++<%= primer_form_with(model: @time_entry_activity, url: admin_time_entry_activities_path) do |f| %>+ <%= render(Admin::TimeEntryActivities::ActivityForm.new(f)) %>+<% end %>diff --git a/modules/costs/config/locales/en.yml b/modules/costs/config/locales/en.ymlindex bbbc33a3327..2e871d4ff66 100644--- a/modules/costs/config/locales/en.yml+++ b/modules/costs/config/locales/en.yml@@ -133,6 +133,8 @@ en:label_kind: "Type"label_less_or_equal: "<="label_log_costs: "Log unit costs"+ label_new_time_entry_activity: "New time entry activity"+ label_time_entry_activity_form_description: "Changes to this time entry activity will be reflected in all projects where it is enabled."label_no: "No"label_option_plural: "Options"label_overall_costs: "Overall costs"