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
[#43675] Migration splitting involved notification setting and date defaults
Dmitrii68d073c2cc34
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rbindex a1e8b515d21..c22de824486 100644--- a/app/models/notification_setting.rb+++ b/app/models/notification_setting.rb@@ -1,6 +1,7 @@class NotificationSetting < ApplicationRecordWATCHED = :watched- INVOLVED = :involved+ ASSIGNEE = :assignee+ RESPONSIBLE = :responsibleMENTIONED = :mentionedWORK_PACKAGE_CREATED = :work_package_createdWORK_PACKAGE_COMMENTED = :work_package_commented@@ -19,7 +20,8 @@ class NotificationSetting < ApplicationRecorddef self.all_settings[WATCHED,- INVOLVED,+ ASSIGNEE,+ RESPONSIBLE,MENTIONED,WORK_PACKAGE_CREATED,WORK_PACKAGE_COMMENTED,diff --git a/app/services/notifications/create_from_model_service.rb b/app/services/notifications/create_from_model_service.rbindex b471f7ecc78..12398b7f96a 100644--- a/app/services/notifications/create_from_model_service.rb+++ b/app/services/notifications/create_from_model_service.rb@@ -141,13 +141,13 @@ class Notifications::CreateFromModelServicedef settings_of_assignedproject_applicable_settings(User.where(id: group_or_user_ids(journal.data.assigned_to)),project,- NotificationSetting::INVOLVED)+ NotificationSetting::ASSIGNEE)enddef settings_of_responsibleproject_applicable_settings(User.where(id: group_or_user_ids(journal.data.responsible)),project,- NotificationSetting::INVOLVED)+ NotificationSetting::RESPONSIBLE)enddef settings_of_subscribeddiff --git a/app/services/user_preferences/update_service.rb b/app/services/user_preferences/update_service.rbindex 23f5701bded..65f4e3040c6 100644--- a/app/services/user_preferences/update_service.rb+++ b/app/services/user_preferences/update_service.rb@@ -90,7 +90,8 @@ module UserPreferencesconflict_target:,index_predicate:,columns: %i[watched- involved+ assignee+ responsiblementionedwork_package_commentedwork_package_createddiff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex e9c22773cec..024912adc44 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -632,6 +632,8 @@ en:involved:title: 'Assigned to me or accountable'description: 'Receive notifications for all activities on work packages for which I am assignee or accountable'+ assignee: 'Assignee'+ responsible: 'Accountable'watched: 'Updates on watched items'work_package_commented: 'All new comments'work_package_created: 'New work packages'diff --git a/db/migrate/20220922200908_add_assignee.rb b/db/migrate/20220922200908_add_assignee.rbnew file mode 100644index 00000000000..8e15229d088--- /dev/null+++ b/db/migrate/20220922200908_add_assignee.rb@@ -0,0 +1,20 @@+class AddAssignee < ActiveRecord::Migration[7.0]+ def change+ change_table :notification_settings, bulk: true do |t|+ t.column :assignee, :boolean, default: false, null: false+ t.column :responsible, :boolean, default: false, null: false+ end++ reversible do |change|+ change.up do+ NotificationSetting.where(involved: true).update_all(assignee: true, responsible: true)+ remove_column :notification_settings, :involved, :boolean+ end++ change.down do+ add_column :notification_settings, :involved, :boolean+ NotificationSetting.where(assignee: true).or(NotificationSetting.where(responsible: true)).update_all(involved: true)+ end+ end+ end+enddiff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.htmlindex cfd46505b67..e35be13487a 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html@@ -17,21 +17,31 @@slot="input"/><p slot="description">{{ text.mentioned.description }}</p>- </spot-selector-field>+ </op-checkbox-field>++ <op-checkbox-field+ [label]="text.assignee"+ [control]="form.get('assignee')"+ >+ <input+ slot="input"+ type="checkbox"+ formControlName="assignee"+ data-qa-global-notification-type="assignee"+ />+ </op-checkbox-field>- <spot-selector-field- class="op-notifications-settings--bold-label"- [label]="text.involved.title"- [control]="form.get('involved')"+ <op-checkbox-field+ [label]="text.responsible"+ [control]="form.get('responsible')"><inputslot="input"type="checkbox"- formControlName="involved"- data-qa-global-notification-type="involved"+ formControlName="responsible"+ data-qa-global-notification-type="responsible"/>- <p slot="description">{{ text.involved.description }}</p>- </spot-selector-field>+ </op-checkbox-field><h5>{{ text.alsoNotifyFor.title }}</h5><p>{{ text.alsoNotifyFor.description }}</p>diff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.tsindex 7e27710178f..480e581ae47 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts@@ -21,7 +21,8 @@ import { INotificationSetting } from 'core-app/features/user-preferences/state/nexport const myNotificationsPageComponentSelector = 'op-notifications-page';interface IToastSettingsValue {- involved:boolean;+ assignee:boolean;+ responsible:boolean;workPackageCreated:boolean;workPackageProcessed:boolean;workPackageScheduled:boolean;@@ -49,7 +50,8 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin impl@Input() userId:string;public form = new FormGroup({- involved: new FormControl(false),+ assignee: new FormControl(false),+ responsible: new FormControl(false),workPackageCreated: new FormControl(false),workPackageProcessed: new FormControl(false),workPackageScheduled: new FormControl(false),@@ -71,10 +73,6 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin impltitle: this.I18n.t('js.notifications.settings.reasons.mentioned.title'),description: this.I18n.t('js.notifications.settings.reasons.mentioned.description'),},- involved: {- title: this.I18n.t('js.notifications.settings.reasons.involved.title'),- description: this.I18n.t('js.notifications.settings.reasons.involved.description'),- },watched: this.I18n.t('js.notifications.settings.reasons.watched'),work_package_commented: this.I18n.t('js.notifications.settings.reasons.work_package_commented'),work_package_created: this.I18n.t('js.notifications.settings.reasons.work_package_created'),@@ -86,6 +84,8 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin impltitle: this.I18n.t('js.notifications.settings.project_specific.title'),description: this.I18n.t('js.notifications.settings.project_specific.description'),},+ assignee: this.I18n.t('js.notifications.settings.reasons.assignee'),+ responsible: this.I18n.t('js.notifications.settings.reasons.responsible'),};constructor(@@ -116,7 +116,8 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implreturn;}- this.form.get('involved')?.setValue(settings.involved);+ this.form.get('assignee')?.setValue(settings.assignee);+ this.form.get('responsible')?.setValue(settings.responsible);this.form.get('workPackageCreated')?.setValue(settings.workPackageCreated);this.form.get('workPackageProcessed')?.setValue(settings.workPackageProcessed);this.form.get('workPackageScheduled')?.setValue(settings.workPackageScheduled);@@ -139,7 +140,8 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin impl).forEach((setting) => projectSettings.push(new FormGroup({project: new FormControl(setting._links.project),- involved: new FormControl(setting.involved),+ assignee: new FormControl(setting.assignee),+ responsible: new FormControl(setting.responsible),workPackageCreated: new FormControl(setting.workPackageCreated),workPackageProcessed: new FormControl(setting.workPackageProcessed),workPackageScheduled: new FormControl(setting.workPackageScheduled),@@ -161,7 +163,8 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin impl_links: { project: { href: null } },watched: true,mentioned: true,- involved: notificationSettings.involved,+ assignee: notificationSettings.assignee,+ responsible: notificationSettings.responsible,workPackageCreated: notificationSettings.workPackageCreated,workPackageProcessed: notificationSettings.workPackageProcessed,workPackageScheduled: notificationSettings.workPackageScheduled,@@ -173,7 +176,8 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin impl_links: { project: { href: settings.project.href } },watched: true,mentioned: true,- involved: settings.involved,+ assignee: settings.assignee,+ responsible: settings.responsible,workPackageCreated: settings.workPackageCreated,workPackageProcessed: settings.workPackageProcessed,workPackageScheduled: settings.workPackageScheduled,diff --git a/frontend/src/app/features/user-preferences/state/notification-setting.model.ts b/frontend/src/app/features/user-preferences/state/notification-setting.model.tsindex d1504842505..05f521205ad 100644--- a/frontend/src/app/features/user-preferences/state/notification-setting.model.ts+++ b/frontend/src/app/features/user-preferences/state/notification-setting.model.ts@@ -3,7 +3,8 @@ import { HalSourceLink } from 'core-app/features/hal/resources/hal-resource';export interface INotificationSetting {_links:{ project:HalSourceLink };watched:boolean;- involved:boolean;+ assignee:boolean;+ responsible:boolean;mentioned:boolean;workPackageCommented:boolean;workPackageCreated:boolean;@@ -28,7 +29,8 @@ export function buildNotificationSetting(project:null|HalSourceLink, params:Parttitle: project?.title,},},- involved: true,+ assignee: true,+ responsible: true,mentioned: true,watched: true,workPackageCommented: true,diff --git a/spec/factories/notification_setting_factory.rb b/spec/factories/notification_setting_factory.rbindex f94a0c237e0..bbd022b49df 100644--- a/spec/factories/notification_setting_factory.rb+++ b/spec/factories/notification_setting_factory.rb@@ -1,6 +1,7 @@FactoryBot.define dofactory :notification_setting do- involved { true }+ assignee { true }+ responsible { true }mentioned { true }watched { true }work_package_commented { false }