Merge remote-tracking branch 'origin/dev' into implementation/43695-add-modal-to-display-first-level-of-file-content

pull/11315/head
Andreas Pfohl 2 years ago
commit 0aca0f880d
No known key found for this signature in database
GPG Key ID: FF58F3B771328EB4
  1. 4
      Gemfile.lock
  2. 3
      app/models/notification.rb
  3. 7
      app/models/user_preference.rb
  4. 2
      frontend/src/app/features/user-preferences/state/user-preferences.store.ts
  5. 11
      frontend/src/app/shared/components/op-date-picker/datepicker.ts
  6. 6
      frontend/src/global_styles/content/_datepicker.sass
  7. 11
      spec/features/notifications/settings/workdays_settings_spec.rb
  8. 37
      spec/models/user_preference_spec.rb

@ -291,8 +291,8 @@ GEM
awesome_nested_set (3.5.0)
activerecord (>= 4.0.0, < 7.1)
aws-eventstream (1.2.0)
aws-partitions (1.647.0)
aws-sdk-core (3.161.0)
aws-partitions (1.648.0)
aws-sdk-core (3.162.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)

@ -10,7 +10,8 @@ class Notification < ApplicationRecord
prioritized: 7,
scheduled: 8,
responsible: 9,
date_alert: 10
date_alert_start_date: 10,
date_alert_due_date: 11
}.freeze
enum reason: REASONS,

@ -33,6 +33,9 @@ class UserPreference < ApplicationRecord
validates :user,
presence: true
WORKDAYS_FROM_MONDAY_TO_FRIDAY = [1, 2, 3, 4, 5].freeze
##
# Retrieve keys from settings, and allow accessing
# as boolean with ? suffix
@ -124,6 +127,10 @@ class UserPreference < ApplicationRecord
super.presence || { enabled: true, times: ["08:00:00+00:00"] }.with_indifferent_access
end
def workdays
super || WORKDAYS_FROM_MONDAY_TO_FRIDAY
end
def immediate_reminders
super.presence || { mentioned: false }.with_indifferent_access
end

@ -44,7 +44,7 @@ function createInitialState():IUserPreference {
enabled: true,
times: ['08:00'],
},
workdays: [],
workdays: [1, 2, 3, 4, 5],
immediateReminders: {
mentioned: false,
},

@ -27,10 +27,7 @@
//++
import * as moment from 'moment';
import flatpickr from 'flatpickr';
import {
DayElement,
Instance,
} from 'flatpickr/dist/types/instance';
import { Instance } from 'flatpickr/dist/types/instance';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { rangeSeparator } from 'core-app/shared/components/op-date-picker/op-range-date-picker/op-range-date-picker.component';
@ -173,12 +170,6 @@ export class DatePicker {
getWeek(dateObj:Date) {
return moment(dateObj).format('W');
},
onDayCreate: async (dObj:Date[], dStr:string, fp:flatpickr.Instance, dayElem:DayElement) => {
await this.weekdaysPromise;
if (this.weekdaysService.isNonWorkingDay(dayElem.dateObj)) {
dayElem.classList.add('flatpickr-non-working-selectable-day');
}
},
dateFormat: this.datepickerFormat,
defaultDate: this.date,
locale: {

@ -43,10 +43,6 @@ $datepicker--border-radius: 5px
border-radius: 0
pointer-events: none
@mixin non-working-selectable-day
background: $spot-color-basic-gray-6
border-radius: 0
.flatpickr-current-month
display: flex !important
@ -60,8 +56,6 @@ $datepicker--border-radius: 5px
@include disabled-day
&.flatpickr-non-working-day
@include non-working-day
&.flatpickr-non-working-selectable-day
@include non-working-selectable-day
.flatpickr-calendar.inline
box-shadow: none !important

@ -14,7 +14,8 @@ describe "Workday notification settings", type: :feature, js: true do
# Configure the reminders
settings_page.visit!
settings_page.expect_non_workdays %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
settings_page.expect_workdays %w[Monday Tuesday Wednesday Thursday Friday]
settings_page.expect_non_workdays %w[Saturday Sunday]
settings_page.set_workdays Monday: true,
Tuesday: true,
@ -36,11 +37,12 @@ describe "Workday notification settings", type: :feature, js: true do
expect(pref.reload.workdays).to eq [1, 2, 5, 6, 7]
end
it 'updates properly working days' do
it 'can unselect all working days' do
# Configure the reminders
settings_page.visit!
settings_page.expect_non_workdays %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]
settings_page.expect_workdays %w[Monday Tuesday Wednesday Thursday Friday]
settings_page.expect_non_workdays %w[Saturday Sunday]
settings_page.set_workdays Monday: false,
Tuesday: false,
@ -72,7 +74,8 @@ describe "Workday notification settings", type: :feature, js: true do
settings_page.visit!
# Expect Mo-Fr to be checked
settings_page.expect_non_workdays %w[Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag]
settings_page.expect_workdays %w[Montag Dienstag Mittwoch Donnerstag Freitag]
settings_page.expect_non_workdays %w[Samstag Sonntag]
settings_page.set_workdays Montag: true,
Dienstag: true,

@ -179,13 +179,48 @@ describe UserPreference do
}
end
it 'uses the defaults' do
it 'returns the stored value' do
expect(subject.daily_reminders)
.to eql(settings["daily_reminders"])
end
end
end
describe '#workdays' do
context 'without work days being stored' do
it 'uses the defaults' do
expect(subject.workdays)
.to eq([1, 2, 3, 4, 5])
end
end
context 'with work days being stored' do
let(:settings) do
{
"workdays" => [1, 2, 4, 5]
}
end
it 'returns the stored value' do
expect(subject.workdays)
.to eql([1, 2, 4, 5])
end
end
context 'with work days being stored and empty' do
let(:settings) do
{
"workdays" => []
}
end
it 'return empty array' do
expect(subject.workdays)
.to eql([])
end
end
end
describe '[]=' do
let(:user) { create(:user) }

Loading…
Cancel
Save