Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Diamantis Tziotzios 2023-12-21 09:46:12 +02:00
commit 17150126cb
26 changed files with 301 additions and 124 deletions

View File

@ -63,7 +63,7 @@ public class NotificationTemplateController {
public QueryResult<NotificationTemplate> query(@RequestBody NotificationTemplateLookup lookup) throws MyApplicationException, MyForbiddenException {
logger.debug("querying {}", NotificationTemplate.class.getSimpleName());
this.censorFactory.censor(NotificationTemplateCensor.class).censor(lookup.getProject());
//this.censorFactory.censor(NotificationTemplateCensor.class).censor(lookup.getProject()); TODO
NotificationTemplateQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrPermission);
List<NotificationTemplateEntity> data = query.collectAs(lookup.getProject());
@ -80,10 +80,10 @@ public class NotificationTemplateController {
public NotificationTemplate get(@PathVariable UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
logger.debug(new MapLogEntry("retrieving" + NotificationTemplate.class.getSimpleName()).And("id", id).And("fields", fieldSet));
this.censorFactory.censor(NotificationTemplateCensor.class).censor(fieldSet);
// this.censorFactory.censor(NotificationTemplateCensor.class).censor(fieldSet); TODO
NotificationTemplateQuery query = this.queryFactory.query(NotificationTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).ids(id);
NotificationTemplate model = this.builderFactory.builder(NotificationTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet));
NotificationTemplate model = this.builderFactory.builder(NotificationTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.first());
if (model == null)
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, NotificationTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));

View File

@ -142,7 +142,7 @@ permissions:
allowAnonymous: false
allowAuthenticated: false
# ViewPage Permissions
# Notification Template Permissions
BrowseNotificationTemplate:
roles:
- Admin

View File

@ -142,7 +142,7 @@ permissions:
allowAnonymous: false
allowAuthenticated: false
# ViewPage Permissions
# Notification Template Permissions
BrowseNotificationTemplate:
roles:
- Admin

View File

@ -60,7 +60,7 @@ public class NotificationTemplateBuilder extends BaseBuilder<NotificationTemplat
Map<UUID, Tenant> tenantMap = this.collectTenants(tenantFields, data);
FieldSet languageFields = fields.extractPrefixed(this.asPrefix(NotificationTemplate._language));
Map<UUID, Language> languageMap = this.collectLanguages(tenantFields, data);
Map<UUID, Language> languageMap = this.collectLanguages(languageFields, data);
List<NotificationTemplate> models = new ArrayList<>();
for(NotificationTemplateEntity d : data){

View File

@ -3,6 +3,9 @@ package gr.cite.notification.model.censorship;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.notification.authorization.Permission;
import gr.cite.notification.convention.ConventionService;
import gr.cite.notification.model.NotificationTemplate;
import gr.cite.notification.model.censorship.notificationtemplate.NotificationTemplateValueCensor;
import gr.cite.tools.data.censor.CensorFactory;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
@ -16,17 +19,21 @@ import org.springframework.stereotype.Component;
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class NotificationTemplateCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(NotificationTemplateCensor.class));
private final AuthorizationService authService;
protected final AuthorizationService authService;
protected final CensorFactory censorFactory;
@Autowired
public NotificationTemplateCensor(ConventionService conventionService, AuthorizationService authService) {
public NotificationTemplateCensor(ConventionService conventionService, AuthorizationService authService, CensorFactory censorFactory) {
super(conventionService);
this.authService = authService;
this.censorFactory = censorFactory;
}
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (this.isEmpty(fields)) return;
this.authService.authorizeForce(Permission.BrowseNotificationTemplate);
FieldSet valueFields = fields.extractPrefixed(this.asIndexerPrefix(NotificationTemplate._value));
this.censorFactory.censor(NotificationTemplateValueCensor.class).censor(valueFields);
}
}

View File

@ -1,6 +1,7 @@
package gr.cite.notification.model.persist.notificationtemplate;
import gr.cite.notification.common.enums.NotificationDataType;
import gr.cite.notification.common.validation.ValidEnum;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ -11,8 +12,7 @@ public class FieldInfoPersist {
@NotEmpty
private String key;
@NotNull
@NotEmpty
@ValidEnum
private NotificationDataType type;
@NotNull

View File

@ -8,7 +8,6 @@ import java.util.List;
public class FieldOptionsPersist {
@NotNull(message = "{validation.empty}")
@Valid
private List<String> mandatory;

View File

@ -176,6 +176,7 @@ public class NotificationTemplateQuery extends QueryBase<NotificationTemplateEnt
else if (item.match(NotificationTemplate._kind)) return NotificationTemplateEntity._kind;
else if (item.match(NotificationTemplate._notificationType)) return NotificationTemplateEntity._notificationType;
else if (item.prefix(NotificationTemplate._value)) return NotificationTemplateEntity._value;
else if (item.match(NotificationTemplate._language)) return NotificationTemplateEntity._language;
else if (item.prefix(NotificationTemplate._language)) return NotificationTemplateEntity._language;
else if (item.match(NotificationTemplate._createdAt)) return NotificationTemplateEntity._createdAt;
else if (item.match(NotificationTemplate._updatedAt)) return NotificationTemplateEntity._updatedAt;

View File

@ -83,7 +83,7 @@ public class NotificationServiceTemplateImpl implements NotificationTemplateServ
public NotificationTemplate persist(NotificationTemplatePersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException {
logger.debug(new MapLogEntry("persisting notification template").And("model", model).And("fields", fields));
this.authorizationService.authorizeForce(Permission.EditNotificationTemplate);
// this.authorizationService.authorizeForce(Permission.EditNotificationTemplate); TODO
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());

View File

@ -32,13 +32,13 @@ export interface NotificationTemplateValue {
export interface NotificationFieldOptions {
mandatory?: string[];
options?: NotificationFieldInfo[];
optional?: NotificationFieldInfo[];
formatting?: { [key: string]: string };
}
export interface NotificationFieldInfo {
key: string;
dataType: NotificationDataType,
type: NotificationDataType,
value: string;
}
@ -69,12 +69,12 @@ export interface NotificationTemplateValuePersist {
export interface NotificationFieldOptionsPersist {
mandatory?: string[];
options?: NotificationFieldInfoPersist[];
optional?: NotificationFieldInfoPersist[];
formatting?: { [key: string]: string };
}
export interface NotificationFieldInfoPersist {
key: string;
dataType: NotificationDataType,
type: NotificationDataType,
value: string;
}

View File

@ -108,6 +108,15 @@ export class ConfigurationService extends BaseComponent {
return this._userSettingsVersion;
}
private _notificationServiceAddress: string;
get notificationServiceAddress(): string {
return this._notificationServiceAddress || './';
}
private _notificationServiceEnabled: boolean;
get notificationServiceEnabled(): boolean {
return this._notificationServiceEnabled;
}
public loadConfiguration(): Promise<any> {
return new Promise((r, e) => {
@ -165,6 +174,10 @@ export class ConfigurationService extends BaseComponent {
}
this._maxFileSizeInMB = config.maxFileSizeInMB;
this._userSettingsVersion = config.userSettingsVersion;
if (config.notification_service) {
this._notificationServiceEnabled = config.notification_service.enabled;
this._notificationServiceAddress = config.notification_service.address;
}
}
}

View File

@ -7,15 +7,15 @@ import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { NotificationTemplate, NotificationTemplatePersist } from '@app/core/model/notification-template/notification-template';
import { BaseHttpV2Service } from '../http/base-http-v2.service';
import { ConfigurationService } from '../configuration/configuration.service';
@Injectable()
export class NotificationTemplateService {
constructor(private http: BaseHttpV2Service) {
constructor(private http: BaseHttpV2Service, private configurationService: ConfigurationService) {
}
//TODO ADD CONIFG URL
private get apiBase(): string { return `http://localhost:8081/api/notification-template`; }
private get apiBase(): string { return `${this.configurationService.notificationServiceAddress}notification-template`; }
query(q: NotificationTemplateLookup): Observable<QueryResult<NotificationTemplate>> {
const url = `${this.apiBase}/query`;

View File

@ -33,12 +33,12 @@
<div class="col-4">
<mat-form-field class="w-100">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.LANGUAGE' | translate}}</mat-label>
<mat-select (selectionChange)="selectedLangChanged($event.value)" name="language" [formControl]="formGroup.get('language')">
<mat-select [(value)]="languageCode" (selectionChange)="selectedLangChanged($event.value)" name="language" required>
<mat-option *ngFor="let languageCode of availableLanguageCodes" [value]="languageCode">
{{languageCode}}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('language').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('languageId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-4">
@ -71,18 +71,18 @@
<mat-form-field class="col-md-12">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.SUBJECT-TEXT' | translate}}</mat-label>
<input matInput [formControl]="formGroup.get('value').get('subjectText')">
<mat-error *ngIf="formGroup.get('value').get('subjectText').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('value').get('subjectText').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-4">
<mat-form-field class="col-md-12">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.SUBJECT-KEY' | translate}}</mat-label>
<input matInput [formControl]="formGroup.get('value').get('subjectKey')">
<mat-error *ngIf="formGroup.get('value').get('subjectKey').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('value').get('subjectKey').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
<h4 class="col-md-12">{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.SUBJECT-FIELD-OPTIONS' | translate}}
<mat-checkbox (change)="subjectFieldOptionsSelectionChanged($event)"></mat-checkbox>
<mat-checkbox [checked]="subjectFieldOptionsEnabled" (change)="subjectFieldOptionsSelectionChanged($event)"></mat-checkbox>
</h4>
<div *ngIf="subjectFieldOptionsEnabled == true">
<div class="col-6" >
@ -108,30 +108,30 @@
</div>
<h4 class="col-md-12">{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.OPTIONAL-TITLE' | translate}}</h4>
<div class="col-12">
<div class="row" *ngFor="let subjectOptions of formGroup.get('value').get('subjectFieldOptions').get('options')['controls']; let i = index">
<div class="row" *ngFor="let subjectOptions of formGroup.get('value').get('subjectFieldOptions').get('optional')['controls']; let i = index">
<div class="col-4">
<mat-form-field class="col-auto">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
<input matInput [formControl]="subjectOptions.get('key')">
<mat-error *ngIf="subjectOptions.get('key').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="subjectOptions.get('key').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-4">
<mat-form-field class="col-auto">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label>
<mat-select name="channel" [formControl]="subjectOptions.get('dataType')">
<mat-select name="channel" [formControl]="subjectOptions.get('type')">
<mat-option *ngFor="let type of notificationDataTypeEnum" [value]="type">
{{enumUtils.toNotificationTemplateDataTypeString(type)}}
</mat-option>
</mat-select>
<mat-error *ngIf="subjectOptions.get('dataType').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="subjectOptions.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-4">
<mat-form-field class="col">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput [formControl]="subjectOptions.get('value')">
<mat-error *ngIf="subjectOptions.get('value').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="subjectOptions.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-auto">
<button mat-icon-button (click)="removeOptionalItem(formGroup.get('value').get('subjectFieldOptions'),i)" [disabled]="formGroup.disabled">
@ -148,26 +148,68 @@
</div>
</div>
</div>
<h4 class="col-md-12">{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.FORMATTING' | translate}}</h4>
<div class="row" *ngFor="let item of formGroup.get('value').get('subjectFieldOptions').get('mandatory').value; let i = index">
<mat-form-field class="col-md-4">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
<input matInput [value]="insertFormattingItem(item, null)" [disabled] = "true">
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput>
</mat-form-field>
</div>
<div class="row" *ngFor="let item of formGroup.get('value').get('subjectFieldOptions').get('optional')['controls']; let i = index">
<div *ngIf="item.valid">
<mat-form-field class="col-md-4">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
<input matInput [value]="insertFormattingItem(item.value.key, null)" [disabled] = "true">
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput>
</mat-form-field>
</div>
</div>
</div>
<!-- Body -->
<div class="row">
<div>
<h3 class="col-md-12">{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.BODY-SECTION' | translate}}</h3>
<mat-form-field class="col-md-12">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.BODY-TEXT' | translate}}</mat-label>
<input matInput [formControl]="formGroup.get('value').get('bodyText')">
<mat-error *ngIf="formGroup.get('value').get('bodyText').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-4">
<mat-form-field class="col-md-12">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.BODY-KEY' | translate}}</mat-label>
<input matInput [formControl]="formGroup.get('value').get('bodyKey')">
<mat-error *ngIf="formGroup.get('value').get('bodyKey').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('value').get('bodyKey').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-12">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.BODY-TEXT' | translate}}</mat-label>
<editor class="w-100" [init]="{
base_url: '/tinymce',
suffix: '.min',
height: 800,
menubar: true,
plugins: [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks fullscreen fullpage',
'insertdatetime media table paste code help wordcount importcss ',
'codesample toc visualchars'
],
extended_valid_elements: '*[*]',
forced_root_block: '',
valid_children: '+body[script],ol[li|div|p|a|ol|table],h2[span],h3[span]',
save_enablewhendirty: false,
toolbar:
'undo redo | formatselect | bold italic backcolor | \
alignleft aligncenter alignright alignjustify | \
bullist numlist outdent indent | code codesample | searchreplace | preview | removeformat | help'
}" [formControl]="formGroup.get('value').get('bodyText')"></editor>
<mat-error *ngIf="formGroup.get('value').get('bodyText').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</div>
</div>
<h4 class="col-md-12">{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.BODY-FIELD-OPTIONS' | translate}}
<mat-checkbox (change)="bodyFieldOptionsSelectionChanged($event)"></mat-checkbox>
<mat-checkbox [checked]="bodyFieldOptionsEnabled" (change)="bodyFieldOptionsSelectionChanged($event)"></mat-checkbox>
</h4>
<div *ngIf="bodyFieldOptionsEnabled == true">
<div class="col-6" >
@ -193,30 +235,30 @@
</div>
<h4 class="col-md-12">{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.OPTIONAL-TITLE' | translate}}</h4>
<div class="col-12">
<div class="row" *ngFor="let bodyOptions of formGroup.get('value').get('bodyFieldOptions').get('options')['controls']; let i = index">
<div class="row" *ngFor="let bodyOptions of formGroup.get('value').get('bodyFieldOptions').get('optional')['controls']; let i = index">
<div class="col-4">
<mat-form-field class="col-auto">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
<input matInput [formControl]="bodyOptions.get('key')">
<mat-error *ngIf="bodyOptions.get('key').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="bodyOptions.get('key').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-4">
<mat-form-field class="col-auto">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label>
<mat-select name="channel" [formControl]="bodyOptions.get('dataType')">
<mat-select name="channel" [formControl]="bodyOptions.get('type')">
<mat-option *ngFor="let type of notificationDataTypeEnum" [value]="type">
{{enumUtils.toNotificationTemplateDataTypeString(type)}}
</mat-option>
</mat-select>
<mat-error *ngIf="bodyOptions.get('dataType').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="bodyOptions.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-4">
<mat-form-field class="col">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput [formControl]="bodyOptions.get('value')">
<mat-error *ngIf="bodyOptions.get('value').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="bodyOptions.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<div class="col-auto">
<button mat-icon-button (click)="removeOptionalItem(formGroup.get('value').get('bodyFieldOptions'),i)" [disabled]="formGroup.disabled">
@ -232,7 +274,30 @@
</button>
</div>
</div>
</div>
<h4 class="col-md-12">{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.FORMATTING' | translate}}</h4>
<div class="row" *ngFor="let item of formGroup.get('value').get('subjectFieldOptions').get('mandatory').value; let i = index">
<mat-form-field class="col-md-4">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
<input matInput [value]="insertFormattingItem(item, null)" [disabled] = "true">
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput>
</mat-form-field>
</div>
<div class="row" *ngFor="let item of formGroup.get('value').get('subjectFieldOptions').get('optional')['controls']; let i = index">
<div *ngIf="item.valid">
<mat-form-field class="col-md-4">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
<input matInput [value]="insertFormattingItem(item.value.key, null)" [disabled] = "true">
</mat-form-field>
<mat-form-field class="col-md-4">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
<input matInput>
</mat-form-field>
</div>
</div>
</div>
</div>
<!--Extra Options -->
<div class="row">
@ -246,7 +311,7 @@
<mat-form-field class="col-md-12">
<mat-label>{{'NOTIFICATION-SERVICE.NOTIFICATION-TEMPLATE-EDITOR.FIELDS.PRIORITY-KEY' | translate}}</mat-label>
<input matInput [formControl]="formGroup.get('value').get('priorityKey')">
<mat-error *ngIf="formGroup.get('value').get('priorityKey').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('value').get('priorityKey').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-4" >
@ -278,7 +343,7 @@
{{enumUtils.toEmailOverrideModeString(emailOverrideMode)}}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('value').get('ccMode').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('value').get('ccMode').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
</div>
@ -311,7 +376,7 @@
{{enumUtils.toEmailOverrideModeString(emailOverrideMode)}}
</mat-option>
</mat-select>
<mat-error *ngIf="formGroup.get('value').get('bccMode').hasError('required')">{{'COMMONS.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="formGroup.get('value').get('bccMode').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<!-- <div class="col-4" >

View File

@ -46,7 +46,6 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
isDeleted = false;
formGroup: UntypedFormGroup = null;
availableLanguageCodes: string[] = [];
selectedLangId: Guid = null;
subjectMandatoryFields: string[] = [];
bodyMandatoryFields: string[] = [];
subjectFieldOptionsEnabled: Boolean = false;
@ -54,6 +53,8 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
ccValues: string[] = [];
bccValues: string[] = [];
extraDataKeys: string[] = [];
languageCode: string;
formatting: { [key: string]: string } = {};
public notificationTemplateKindEnum = this.enumUtils.getEnumValues(NotificationTemplateKind);
public notificationTemplateChannelEnum = this.enumUtils.getEnumValues(NotificationTemplateChannel);
public notificationDataTypeEnum = this.enumUtils.getEnumValues(NotificationDataType);
@ -126,12 +127,21 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
if(data){
if(data.value && data.value.subjectFieldOptions){
this.subjectFieldOptionsEnabled = true;
this.subjectMandatoryFields = data.value.subjectFieldOptions.mandatory;
}
if(data.value && data.value.bodyFieldOptions){
this.bodyFieldOptionsEnabled = true;
this.bodyMandatoryFields = data.value.bodyFieldOptions.mandatory;
}
this.ccValues = this.editorModel.value.cc;
this.bccValues = this.editorModel.value.bcc;
this.extraDataKeys = this.editorModel.value.extraDataKeys;
this.languageCode = data.language.code;
}
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
this.buildForm();
} catch (error) {
this.logger.error('Could not parse Tenant item: ' + data + error);
this.logger.error('Could not parse Notification Template item: ' + data + error);
this.uiNotificationService.snackBarNotification(this.language.instant('COMMONS.ERRORS.DEFAULT'), SnackBarNotificationLevel.Error);
}
}
@ -213,8 +223,9 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
.pipe(takeUntil(this._destroyed))
.subscribe(
data => {
this.selectedLangId = data.id
console.log(this.formGroup);}
this.formGroup.get('languageId').patchValue(data.id);
console.log(this.formGroup);
}
);
}
@ -235,33 +246,6 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
}
}
// subject mandatory
addSubjectMandatory(event: MatChipInputEvent): void {
const value = (event.value || '').trim();
if (value) this.subjectMandatoryFields.push(value)
event.chipInput!.clear();
}
removeSubjectMandatory(field: string): void {
const index = this.subjectMandatoryFields.indexOf(field);
if (index >= 0) this.subjectMandatoryFields.splice(index, 1);
}
editSubjectMandatory(field: string, event: MatChipEditedEvent) {
const value = event.value.trim();
if (!value) {
this.removeSubjectMandatory(field);
return;
}
const index = this.subjectMandatoryFields.indexOf(field);
if (index >= 0) this.subjectMandatoryFields[index] = value
}
// chip lists
addChipListValues(type: string, event: MatChipInputEvent){
@ -340,11 +324,18 @@ export class NotificationTemplateEditorComponent extends BaseEditor<Notification
addOptionalItem(formGroup: UntypedFormGroup) {
const fieldInfo: NotificationFieldInfoEditorModel = new NotificationFieldInfoEditorModel();
(formGroup.get('options') as FormArray).push(fieldInfo.buildForm());
(formGroup.get('optional') as FormArray).push(fieldInfo.buildForm());
}
removeOptionalItem(formGroup: UntypedFormGroup, optionalIndex: number): void {
(formGroup.get('options') as FormArray).removeAt(optionalIndex);
(formGroup.get('optional') as FormArray).removeAt(optionalIndex);
}
insertFormattingItem(key: string, value: string){
this.formatting[key] = value;
// this.formGroup.get('value').get('subjectFieldOptions').get('formatting').patchValue(this.formatting); TODO
return key;
}
}

View File

@ -29,7 +29,7 @@ export class NotificationTemplateEditorModel extends BaseEditorModel implements
this.channel = item.channel;
this.notificationType = item.notificationType;
this.kind = item.kind;
if(item.language) //TODO this.language = item.language;
if(item.language && item.language.id) this.languageId = item.language.id;
if (item.value) { this.value = new NotificationTemplateValueEditorModel().fromModel(item.value); }
}
@ -44,7 +44,7 @@ export class NotificationTemplateEditorModel extends BaseEditorModel implements
channel: [{ value: this.channel, disabled: disabled }, context.getValidation('channel').validators],
notificationType: [{ value: this.notificationType, disabled: disabled }, context.getValidation('notificationType').validators],
kind: [{ value: this.kind, disabled: disabled }, context.getValidation('kind').validators],
language: [{ value: this.languageId, disabled: disabled }, context.getValidation('language').validators],
languageId: [{ value: this.languageId, disabled: disabled }, context.getValidation('languageId').validators],
value: this.value.buildForm({
rootPath: `value.`
}),
@ -59,7 +59,7 @@ export class NotificationTemplateEditorModel extends BaseEditorModel implements
baseValidationArray.push({ key: 'channel', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'channel')] });
baseValidationArray.push({ key: 'notificationType', validators: [BackendErrorValidator(this.validationErrorModel, 'notificationType')] });
baseValidationArray.push({ key: 'kind', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'kind')] });
baseValidationArray.push({ key: 'language', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'language')] });
baseValidationArray.push({ key: 'languageId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'languageId')] });
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'value')] });
baseValidationArray.push({ key: 'hash', validators: [] });
@ -149,16 +149,16 @@ export class NotificationTemplateValueEditorModel implements NotificationTemplat
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'subjectText', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}subjectText`)] });
baseValidationArray.push({ key: 'subjectKey', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}subjectKey`)] });
baseValidationArray.push({ key: 'bodyText', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}bodyText`)] });
baseValidationArray.push({ key: 'bodyKey', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}bodyKey`)] });
baseValidationArray.push({ key: 'priorityKey', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}priorityKey`)] });
baseValidationArray.push({ key: 'subjectText', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}subjectText`)] });
baseValidationArray.push({ key: 'subjectKey', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}subjectKey`)] });
baseValidationArray.push({ key: 'bodyText', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}bodyText`)] });
baseValidationArray.push({ key: 'bodyKey', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}bodyKey`)] });
baseValidationArray.push({ key: 'priorityKey', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}priorityKey`)] });
baseValidationArray.push({ key: 'allowAttachments', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}allowAttachments`)] });
baseValidationArray.push({ key: 'cc', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}cc`)] });
baseValidationArray.push({ key: 'ccMode', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}ccMode`)] });
baseValidationArray.push({ key: 'ccMode', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}ccMode`)] });
baseValidationArray.push({ key: 'bcc', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}bcc`)] });
baseValidationArray.push({ key: 'bccMode', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}bccMode`)] });
baseValidationArray.push({ key: 'bccMode', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}bccMode`)] });
baseValidationArray.push({ key: 'extraDataKeys', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}extraDataKeys`)] });
baseContext.validation = baseValidationArray;
@ -168,7 +168,7 @@ export class NotificationTemplateValueEditorModel implements NotificationTemplat
export class NotificationFieldOptionsEditorModel implements NotificationFieldOptionsPersist {
mandatory?: string[] = [];
options?: NotificationFieldInfoEditorModel[] = [];
optional?: NotificationFieldInfoEditorModel[] = [];
formatting?: { [key: string]: string };
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -180,7 +180,7 @@ export class NotificationFieldOptionsEditorModel implements NotificationFieldOpt
public fromModel(item: NotificationFieldOptions): NotificationFieldOptionsEditorModel {
if (item) {
this.mandatory = item.mandatory;
if(item.options) { item.options.map(x => this.options.push(new NotificationFieldInfoEditorModel().fromModel(x))); }
if(item.optional) { item.optional.map(x => this.optional.push(new NotificationFieldInfoEditorModel().fromModel(x))); }
this.formatting = item.formatting;
}
return this;
@ -202,13 +202,13 @@ export class NotificationFieldOptionsEditorModel implements NotificationFieldOpt
return this.formBuilder.group({
mandatory: [{ value: this.mandatory, disabled: disabled }, context.getValidation('mandatory').validators],
formatting: [{ value: this.formatting, disabled: disabled }, context.getValidation('formatting').validators],
options: this.formBuilder.array(
(this.options ?? []).map(
optional: this.formBuilder.array(
(this.optional ?? []).map(
(item, index) => new NotificationFieldInfoEditorModel(
this.validationErrorModel
).fromModel(item).buildForm({
rootPath: `options[${index}].`
}), context.getValidation('options')
rootPath: `optional[${index}].`
}), context.getValidation('optional')
)
),
});
@ -224,7 +224,7 @@ export class NotificationFieldOptionsEditorModel implements NotificationFieldOpt
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'mandatory', validators: [BackendErrorValidator(validationErrorModel,`${rootPath}mandatory`)] });
baseValidationArray.push({ key: 'options', validators: [BackendErrorValidator(validationErrorModel,`${rootPath}options`)] });
baseValidationArray.push({ key: 'optional', validators: [BackendErrorValidator(validationErrorModel,`${rootPath}optional`)] });
baseValidationArray.push({ key: 'formatting', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}formatting`)] });
baseContext.validation = baseValidationArray;
return baseContext;
@ -234,7 +234,7 @@ export class NotificationFieldOptionsEditorModel implements NotificationFieldOpt
export class NotificationFieldInfoEditorModel implements NotificationFieldInfoPersist {
key: string;
dataType: NotificationDataType;
type: NotificationDataType;
value: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -245,7 +245,7 @@ export class NotificationFieldInfoEditorModel implements NotificationFieldInfoPe
public fromModel(item: NotificationFieldInfo): NotificationFieldInfoEditorModel {
if (item) {
this.key = item.key;
this.dataType = item.dataType;
this.type = item.type;
this.value = item.value;
}
return this;
@ -265,7 +265,7 @@ export class NotificationFieldInfoEditorModel implements NotificationFieldInfoPe
}
return this.formBuilder.group({
key: [{ value: this.key, disabled: disabled }, context.getValidation('key').validators],
dataType: [{ value: this.dataType, disabled: disabled }, context.getValidation('dataType').validators],
type: [{ value: this.type, disabled: disabled }, context.getValidation('type').validators],
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
});
}
@ -280,7 +280,7 @@ export class NotificationFieldInfoEditorModel implements NotificationFieldInfoPe
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'key', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}key`)] });
baseValidationArray.push({ key: 'dataType', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}dataType`)] });
baseValidationArray.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
baseContext.validation = baseValidationArray;

View File

@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { NotificationTemplate } from '@app/core/model/notification-template/notification-template';
import { Language } from '@app/core/model/language/language';
import { NotificationFieldInfo, NotificationFieldOptions, NotificationTemplate, NotificationTemplateValue } from '@app/core/model/notification-template/notification-template';
import { NotificationTemplateService } from '@app/core/services/notification-template/notification-template.service';
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
import { BaseEditorResolver } from '@common/base/base-editor.resolver';
@ -22,7 +23,34 @@ export class NotificationTemplateEditorResolver extends BaseEditorResolver {
nameof<NotificationTemplate>(x => x.channel),
nameof<NotificationTemplate>(x => x.notificationType),
nameof<NotificationTemplate>(x => x.kind),
nameof<NotificationTemplate>(x => x.language),
[nameof<NotificationTemplate>(x => x.language),nameof<Language>(x => x.id)].join('.'),
[nameof<NotificationTemplate>(x => x.language),nameof<Language>(x => x.code)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.subjectText)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.subjectKey)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.subjectFieldOptions), nameof<NotificationFieldOptions>(x => x.mandatory)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.subjectFieldOptions), nameof<NotificationFieldOptions>(x => x.optional)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.subjectFieldOptions), nameof<NotificationFieldOptions>(x => x.optional), nameof<NotificationFieldInfo>(x => x.key)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.subjectFieldOptions), nameof<NotificationFieldOptions>(x => x.optional), nameof<NotificationFieldInfo>(x => x.type)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.subjectFieldOptions), nameof<NotificationFieldOptions>(x => x.optional), nameof<NotificationFieldInfo>(x => x.value)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.subjectFieldOptions), nameof<NotificationFieldOptions>(x => x.formatting)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bodyText)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bodyKey)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bodyFieldOptions), nameof<NotificationFieldOptions>(x => x.mandatory)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bodyFieldOptions), nameof<NotificationFieldOptions>(x => x.optional)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bodyFieldOptions), nameof<NotificationFieldOptions>(x => x.optional), nameof<NotificationFieldInfo>(x => x.key)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bodyFieldOptions), nameof<NotificationFieldOptions>(x => x.optional), nameof<NotificationFieldInfo>(x => x.type)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bodyFieldOptions), nameof<NotificationFieldOptions>(x => x.optional), nameof<NotificationFieldInfo>(x => x.value)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bodyFieldOptions), nameof<NotificationFieldOptions>(x => x.formatting)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.priorityKey)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.allowAttachments)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.cc)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.ccMode)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bcc)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.bccMode)].join('.'),
[nameof<NotificationTemplate>(x => x.value),nameof<NotificationTemplateValue>(x => x.extraDataKeys)].join('.'),
nameof<NotificationTemplate>(x => x.createdAt),
nameof<NotificationTemplate>(x => x.updatedAt),
nameof<NotificationTemplate>(x => x.hash),
@ -38,7 +66,7 @@ export class NotificationTemplateEditorResolver extends BaseEditorResolver {
const id = route.paramMap.get('id');
if (id != null) {
return this.notificationTemplateService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.language.code)), takeUntil(this._destroyed));
return this.notificationTemplateService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.notificationType.toString())), takeUntil(this._destroyed));
}
}
}

View File

@ -20,6 +20,22 @@
{{'NOTIFICATION-TEMPLATE-LISTING.FILTER.IS-ACTIVE' | translate}}
</mat-slide-toggle>
<div>
<mat-label>{{'NOTIFICATION-TEMPLATE-LISTING.FILTER.KIND' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.kinds">
<mat-option *ngFor="let kind of notificationTemplateKindEnumValues" [value]="kind">{{enumUtils.toNotificationTemplateKindString(kind)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div>
<mat-label>{{'NOTIFICATION-TEMPLATE-LISTING.FILTER.CHANNEL' | translate}}
<mat-select multiple [(ngModel)]="internalFilters.channels">
<mat-option *ngFor="let channel of notificationTemplateChannelEnumValues" [value]="channel">{{enumUtils.toNotificationTemplateChannelString(channel)}}</mat-option>
</mat-select>
</mat-label>
</div>
<div class="d-flex justify-content-end align-items-center mt-4 gap-1-rem">
<button mat-stroked-button color="primary" (click)="filterMenuTrigger?.closeMenu()">
{{'NOTIFICATION-TEMPLATE-LISTING.FILTER.CANCEL' | translate}}

View File

@ -1,5 +1,7 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { NotificationTemplateChannel } from '@app/core/common/enum/notification-template-channel';
import { NotificationTemplateKind } from '@app/core/common/enum/notification-template-kind';
import { NotificationTemplateFilter } from '@app/core/query/notification-template.lookup';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { BaseComponent } from '@common/base/base.component';
@ -14,9 +16,11 @@ export class NotificationTemplateListingFiltersComponent extends BaseComponent i
@Input() readonly filter: NotificationTemplateFilter;
@Output() filterChange = new EventEmitter<NotificationTemplateFilter>();
notificationTemplateKindEnumValues = this.enumUtils.getEnumValues<NotificationTemplateKind>(NotificationTemplateKind)
notificationTemplateChannelEnumValues = this.enumUtils.getEnumValues<NotificationTemplateChannel>(NotificationTemplateChannel);
// * State
internalFilters: TenantListingFilters = this._getEmptyFilters();
internalFilters: NotificationTemplateListingFilters = this._getEmptyFilters();
protected appliedFilterCount: number = 0;
constructor(
@ -45,35 +49,41 @@ export class NotificationTemplateListingFiltersComponent extends BaseComponent i
}
protected applyFilters(): void {
const { isActive } = this.internalFilters ?? {}
const { isActive, kinds, channels } = this.internalFilters ?? {}
this.filterChange.emit({
...this.filter,
// like,
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive]
isActive: isActive ? [IsActive.Active] : [IsActive.Inactive],
kinds,
channels
})
}
private _parseToInternalFilters(inputFilter: NotificationTemplateFilter): TenantListingFilters {
private _parseToInternalFilters(inputFilter: NotificationTemplateFilter): NotificationTemplateListingFilters {
if (!inputFilter) {
return this._getEmptyFilters();
}
let { excludedIds, ids, isActive } = inputFilter;
let { isActive, kinds, channels } = inputFilter;
return {
isActive: (isActive ?? [])?.includes(IsActive.Active) || !isActive?.length,
kinds: kinds,
channels: channels
}
}
private _getEmptyFilters(): TenantListingFilters {
private _getEmptyFilters(): NotificationTemplateListingFilters {
return {
isActive: true
isActive: true,
kinds: null,
channels: null
}
}
private _computeAppliedFilters(filters: TenantListingFilters): number {
private _computeAppliedFilters(filters: NotificationTemplateListingFilters): number {
let count = 0;
if (filters?.isActive) {
count++
@ -86,6 +96,8 @@ export class NotificationTemplateListingFiltersComponent extends BaseComponent i
}
}
interface TenantListingFilters {
interface NotificationTemplateListingFilters {
isActive: boolean;
kinds: NotificationTemplateKind[];
channels: NotificationTemplateChannel[];
}

View File

@ -22,6 +22,9 @@ import { IsActiveTypePipe } from '@common/formatting/pipes/is-active-type.pipe';
import { NotificationTemplate } from '@app/core/model/notification-template/notification-template';
import { NotificationTemplateLookup } from '@app/core/query/notification-template.lookup';
import { NotificationTemplateService } from '@app/core/services/notification-template/notification-template.service';
import { NotificationTemplateChannelPipe } from '@common/formatting/pipes/notification-template-channel.pipe';
import { NotificationTemplateKindPipe } from '@common/formatting/pipes/notification-template-kind.pipe';
import { Language } from '@app/core/model/language/language';
@Component({
templateUrl: './NOTIFICATION-TEMPLATE-LISTING.component.html',
@ -37,7 +40,7 @@ export class NotificationTemplateListingComponent extends BaseListingComponent<N
private readonly lookupFields: string[] = [
nameof<NotificationTemplate>(x => x.id),
nameof<NotificationTemplate>(x => x.language.code),
nameof<NotificationTemplate>(x => x.kind),
nameof<NotificationTemplate>(x => x.channel),
nameof<NotificationTemplate>(x => x.updatedAt),
nameof<NotificationTemplate>(x => x.createdAt),
@ -87,13 +90,16 @@ export class NotificationTemplateListingComponent extends BaseListingComponent<N
protected setupColumns() {
this.gridColumns.push(...[{
prop: nameof<NotificationTemplate>(x => x.language.code),
prop: nameof<NotificationTemplate>(x => x.kind),
sortable: true,
languageName: 'NOTIFICATION-TEMPLATE-LISTING.FIELDS.LANGUAGE'
}, {
languageName: 'NOTIFICATION-TEMPLATE-LISTING.FIELDS.KIND',
pipe: this.pipeService.getPipe<NotificationTemplateKindPipe>(NotificationTemplateKindPipe)
},
{
prop: nameof<NotificationTemplate>(x => x.channel),
sortable: true,
languageName: 'NOTIFICATION-TEMPLATE-LISTING.FIELDS.CHANNEL',
pipe: this.pipeService.getPipe<NotificationTemplateChannelPipe>(NotificationTemplateChannelPipe)
},
{
prop: nameof<NotificationTemplate>(x => x.createdAt),

View File

@ -16,6 +16,7 @@ import { NotificationTemplateRoutingModule } from './notification-template.routi
import { NotificationTemplateEditorComponent } from './editor/notification-template-editor.component';
import { NotificationTemplateListingFiltersComponent } from './listing/filters/notification-template-listing-filters.component';
import { MatIconModule } from '@angular/material/icon';
import { EditorModule } from '@tinymce/tinymce-angular';
@NgModule({
imports: [
@ -32,7 +33,8 @@ import { MatIconModule } from '@angular/material/icon';
UserSettingsModule,
CommonFormattingModule,
RichTextEditorModule,
MatIconModule
MatIconModule,
EditorModule
],
declarations: [
NotificationTemplateEditorComponent,

View File

@ -19,6 +19,10 @@
"clientSecret": null,
"grantType": "code"
},
"notification_service": {
"enabled": true,
"address": "http://localhost:8086/api/"
},
"zenodoConfiguration": {
"clientId": "",
"oauthUrl": "https://sandbox.zenodo.org/oauth/authorize",

View File

@ -1219,8 +1219,8 @@
"TITLE": "Notification Templates",
"CREATE": "Create Notification Template",
"FIELDS": {
"NAME": "Name",
"LANGUAGE":"Language",
"KIND":"Kind",
"CHANNEL":"Channel",
"UPDATED-AT": "Updated",
"CREATED-AT": "Created",
@ -1229,7 +1229,8 @@
"FILTER": {
"TITLE": "Filters",
"IS-ACTIVE": "Is Active",
"STATUS": "Status",
"KIND":"Kind",
"CHANNEL":"Channel",
"CANCEL": "Cancel",
"APPLY-FILTERS": "Apply filters"
},
@ -1321,7 +1322,8 @@
"CC-MODE": "CC Mode",
"BCC": "BCC",
"BCC-MODE": "BCC Mode",
"EXTRA-DATA-KEYS": "EXTRA-DATA-KEYS"
"EXTRA-DATA-KEYS": "EXTRA-DATA-KEYS",
"FORMATTING": "Formatting"
},
"ACTIONS": {
"SAVE": "Save",

View File

@ -7,6 +7,8 @@ import { LowercaseFirstLetterPipe } from '@common/formatting/pipes/lowercase-fir
import { IsActiveTypePipe } from './pipes/is-active-type.pipe';
import { ReferenceTypePipe } from './pipes/reference-type.pipe';
import { ReferenceSourceTypePipe } from './pipes/reference-source-type.pipe';
import { NotificationTemplateChannelPipe } from './pipes/notification-template-channel.pipe';
import { NotificationTemplateKindPipe } from './pipes/notification-template-kind.pipe';
//
//
@ -25,7 +27,9 @@ import { ReferenceSourceTypePipe } from './pipes/reference-source-type.pipe';
DataTableDateOnlyFormatPipe,
IsActiveTypePipe,
ReferenceTypePipe,
ReferenceSourceTypePipe
ReferenceSourceTypePipe,
NotificationTemplateChannelPipe,
NotificationTemplateKindPipe
],
exports: [
DateFormatPipe,
@ -38,7 +42,9 @@ import { ReferenceSourceTypePipe } from './pipes/reference-source-type.pipe';
DataTableDateOnlyFormatPipe,
IsActiveTypePipe,
ReferenceTypePipe,
ReferenceSourceTypePipe
ReferenceSourceTypePipe,
NotificationTemplateChannelPipe,
NotificationTemplateKindPipe
],
providers: [
DateFormatPipe,
@ -51,7 +57,9 @@ import { ReferenceSourceTypePipe } from './pipes/reference-source-type.pipe';
DataTableDateOnlyFormatPipe,
IsActiveTypePipe,
ReferenceTypePipe,
ReferenceSourceTypePipe
ReferenceSourceTypePipe,
NotificationTemplateChannelPipe,
NotificationTemplateKindPipe
]
})
export class CommonFormattingModule { }

View File

@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@Pipe({ name: 'NotificationTemplateChannelFormat' })
export class NotificationTemplateChannelPipe implements PipeTransform {
constructor(private enumUtils: EnumUtils) { }
public transform(value): any {
return this.enumUtils.toNotificationTemplateChannelString(value);
}
}

View File

@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@Pipe({ name: 'NotificationTemplateKindFormat' })
export class NotificationTemplateKindPipe implements PipeTransform {
constructor(private enumUtils: EnumUtils) { }
public transform(value): any {
return this.enumUtils.toNotificationTemplateKindString(value);
}
}

View File

@ -26,6 +26,7 @@ export abstract class BaseInterceptor implements HttpInterceptor {
}
return (req.params instanceof BaseHttpParams && req.params.interceptorContext && Array.isArray(req.params.interceptorContext.interceptAllRequests) && req.params.interceptorContext.interceptAllRequests.includes(this.type))
|| req.url.startsWith(this.configurationService.server);
|| req.url.startsWith(this.configurationService.server)
|| req.url.startsWith(this.configurationService.notificationServiceAddress);
}
}