Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCST-1251: Add unregister notification #160

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ namespace VirtoCommerce.NotificationsModule.Core.Model
//The special type for handle cases when the system have stored the notification objects with unregistered types.
public class UnregisteredNotification : Notification
{
public UnregisteredNotification(string type) : base(type)
{

}

public UnregisteredNotification() : base(nameof(UnregisteredNotification))
{
Templates = new List<NotificationTemplate>();
}
public override string Kind => "undef";


public override void SetFromToMembers(string from, string to)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ public NotificationBuilder OverrideNotificationType<TOldNotificationType, TNewNo

return builder;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static Notification ToModel(NotificationEntity entity)
entity.ToModel(result);
}

return result ?? new UnregisteredNotification();
return result ?? new UnregisteredNotification(typeName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"dialogs": {
"unknown-kind": {
"title": "Error",
"message": "Unable to edit template of an unknown type: '{{kind}}'."
"message": "Unable to open '{{type}}' notification. Please contact your Site Administrator(s) for information."
},
"notification-details-save": {
"title": "Save changes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"dialogs": {
"unknown-kind": {
"title": "Ошибка",
"message": "Невозможно изменить шаблон неопределенного типа:: '{{kind}}'."
"message": "Невозможно открыть уведомление '{{type}}'. Обратитесь к администратору(ам) вашего сайта за информацией."
},
"notification-details-save": {
"title": "Сохранить изменения",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ angular.module('virtoCommerce.notificationsModule')
return _.toArray(templatesToDisplay);
}

function resolveType(kind) {
function resolveType(kind, type) {
var foundTemplate = notificationTemplatesResolverService.resolve(kind);
if (foundTemplate && foundTemplate.knownChildrenTypes && foundTemplate.knownChildrenTypes.length) {
return foundTemplate;
Expand All @@ -49,13 +49,14 @@ angular.module('virtoCommerce.notificationsModule')
id: "error",
title: "notifications.dialogs.unknown-kind.title",
message: "notifications.dialogs.unknown-kind.message",
messageValues: { kind: kind },
messageValues: { kind: kind, type: type },
});
return null;
}
}

blade.openTemplate = function (template) {
var foundTemplate = resolveType(blade.currentEntity.kind);
var foundTemplate = resolveType(blade.currentEntity.kind, blade.currentEntity.type);
if (foundTemplate) {
var newBlade = {
id: foundTemplate.detailBlade.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ angular.module('virtoCommerce.notificationsModule')
});
}

function resolveType(kind) {
function resolveType(kind, type) {
var foundNotification = notificationTypesResolverService.resolve(kind);
if (foundNotification && foundNotification.knownChildrenTypes && foundNotification.knownChildrenTypes.length) {
return foundNotification;
Expand All @@ -58,14 +58,15 @@ angular.module('virtoCommerce.notificationsModule')
id: "error",
title: "notifications.dialogs.unknown-kind.title",
message: "notifications.dialogs.unknown-kind.message",
messageValues: { kind: kind },
});
messageValues: { kind: kind, type: type },
});
return null;
}
}

if (authService.checkPermission('notifications:access')) {
blade.editNotification = function (item) {
var foundNotification = resolveType(item.kind);
var foundNotification = resolveType(item.kind, item.type);
var newBlade = {
id: 'editNotification',
title: 'notifications.blades.notification-details.title',
Expand Down
Loading