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
Disable ignoreNonWorkingDays when not writable
Oliver Günther77ac1561090e
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.htmlindex b18fd8eaea6..900654493fb 100644--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html@@ -17,6 +17,7 @@></op-datepicker-scheduling-toggle><op-datepicker-working-days-togglename="ignoreNonWorkingDays"+ [disabled]="!ignoreNonWorkingDaysWritable"[(ngModel)]="ignoreNonWorkingDays"(ngModelChange)="changeNonWorkingDays()"></op-datepicker-working-days-toggle>diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.tsindex 64d317c28f6..21f1577213f 100644--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts@@ -222,6 +222,8 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterViprivate changeset:ResourceChangeset;+ ignoreNonWorkingDaysWritable = true;+private datePickerInstance:DatePicker;private formUpdates$ = new Subject<FieldUpdates>();@@ -259,6 +261,16 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVithis.scheduleManually = !!this.changeset.value('scheduleManually');this.ignoreNonWorkingDays = !!this.changeset.value('ignoreNonWorkingDays');+ // Ensure we get the writable values from the loaded form+ void this+ .changeset+ .getForm()+ .then((form) => {+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access+ this.ignoreNonWorkingDaysWritable = !!form.schema.ignoreNonWorkingDays.writable;+ this.cdRef.detectChanges();+ });+this.setDurationDaysFromUpstream(this.changeset.value('duration'));this.dates.start = this.changeset.value('startDate');diff --git a/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.html b/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.htmlindex 57c429cf6a5..f99917db7ac 100644--- a/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.html+++ b/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.html@@ -4,6 +4,7 @@</label><div class="form--field-container"><spot-toggle+ [disabled]="disabled"[options]="ignoreNonWorkingDaysOptions"[value]="ignoreNonWorkingDays"[name]="'include-non-working-days'"diff --git a/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.ts b/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.tsindex cea4209070a..e0c33b0311f 100644--- a/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.ts+++ b/frontend/src/app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component.ts@@ -24,6 +24,8 @@ import {export class DatepickerWorkingDaysToggleComponent implements ControlValueAccessor {@Input() ignoreNonWorkingDays:boolean;+ @Input() disabled = false;+text = {ignoreNonWorkingDays: {title: this.I18n.t('js.work_packages.datepicker_modal.ignore_non_working_days.title'),diff --git a/spec/features/work_packages/datepicker/datepicker_parent_spec.rb b/spec/features/work_packages/datepicker/datepicker_parent_spec.rbnew file mode 100644index 00000000000..f7d3cf35e80--- /dev/null+++ b/spec/features/work_packages/datepicker/datepicker_parent_spec.rb@@ -0,0 +1,82 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2022 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.+#++++require 'spec_helper'+require 'support/edit_fields/edit_field'++describe 'Datepicker logic on parents',+ with_settings: { date_format: '%Y-%m-%d' },+ js: true do+ shared_let(:user) { create :admin }++ # assume sat+sun are non working days+ shared_let(:week_days) { week_with_saturday_and_sunday_as_weekend }++ shared_let(:type) { create :type_bug }+ shared_let(:project) { create :project, types: [type] }+ shared_let(:parent) { create :work_package, type:, project: }+ shared_let(:child) { create :work_package, type:, project:, parent: }++ let(:work_packages_page) { Pages::FullWorkPackage.new(parent) }+ let(:date_field) { work_packages_page.edit_field(:combinedDate) }+ let(:datepicker) { date_field.datepicker }++ let(:parent_attributes) { {} }+ let(:child_attributes) { {} }++ before do+ parent.update!(parent_attributes)+ child.update!(child_attributes)++ login_as(user)++ work_packages_page.visit!+ work_packages_page.ensure_page_loaded++ date_field.activate!+ date_field.expect_active!+ # Wait for the datepicker to be initialized+ datepicker.expect_visible+ end++ context 'with the child having set dates' do+ let(:child_attributes) do+ {+ start_date: '2021-02-01',+ due_date: '2021-02-02',+ ignore_non_working_days: true+ }+ end++ it 'disables the non working days options' do+ expect(page)+ .to have_selector('[data-qa-selector="spot-toggle--option"][data-qa-disabled]',+ count: 2)+ end+ end+end