@valtimo/components 4.15.3-next-main.14 → 4.15.3-next-main.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/valtimo-components.umd.js +4795 -4795
- package/esm2015/lib/alert/alert.component.js +141 -141
- package/esm2015/lib/alert/alert.module.js +27 -27
- package/esm2015/lib/alert/alert.service.js +80 -80
- package/esm2015/lib/bpmn-js-diagram/bpmn-js-diagram.component.js +159 -159
- package/esm2015/lib/bpmn-js-diagram/bpmn-js-diagram.module.js +29 -29
- package/esm2015/lib/breadcrumb-navigation/breadcrumb-navigation.component.js +92 -92
- package/esm2015/lib/breadcrumb-navigation/breadcrumb-navigation.module.js +33 -33
- package/esm2015/lib/camunda/form/camunda-form.components.js +36 -36
- package/esm2015/lib/camunda/form/camunda-form.module.js +37 -37
- package/esm2015/lib/camunda/form/custom/camunda-custom-form.component.js +41 -41
- package/esm2015/lib/camunda/form/custom/camunda-custom-form.module.js +33 -33
- package/esm2015/lib/camunda/form/generated/camunda-generated-form.component.js +68 -68
- package/esm2015/lib/camunda/form/generated/camunda-generated-form.module.js +62 -62
- package/esm2015/lib/camunda/form/generated/formfield/boolean/camunda-boolean-formfield.component.js +27 -27
- package/esm2015/lib/camunda/form/generated/formfield/camunda-formfield-generator.directive.js +63 -63
- package/esm2015/lib/camunda/form/generated/formfield/camunda-formfield.service.js +66 -66
- package/esm2015/lib/camunda/form/generated/formfield/choicefield/camunda-choicefield-formfield.component.js +37 -37
- package/esm2015/lib/camunda/form/generated/formfield/date/camunda-date-formfield.component.js +65 -65
- package/esm2015/lib/camunda/form/generated/formfield/enum/camunda-enum-formfield.component.js +30 -30
- package/esm2015/lib/camunda/form/generated/formfield/formfield.model.js +15 -15
- package/esm2015/lib/camunda/form/generated/formfield/long/camunda-long-formfield.component.js +27 -27
- package/esm2015/lib/camunda/form/generated/formfield/string/camunda-string-formfield.component.js +27 -27
- package/esm2015/lib/camunda/form/generated/formfield/textarea/camunda-textarea-formfield.component.js +27 -27
- package/esm2015/lib/camunda/form/generated/formfield/validation/camunda-formfield-validation.component.js +35 -35
- package/esm2015/lib/camunda/form/generated/formfield/validation/date.validators.js +59 -59
- package/esm2015/lib/card/card.component.js +36 -36
- package/esm2015/lib/card/card.module.js +29 -29
- package/esm2015/lib/components.module.js +21 -21
- package/esm2015/lib/data-list/data-list.component.js +33 -33
- package/esm2015/lib/data-list/data-list.module.js +29 -29
- package/esm2015/lib/dropzone/dropzone.component.js +142 -142
- package/esm2015/lib/dropzone/dropzone.module.js +31 -31
- package/esm2015/lib/field-auto-focus/field-auto-focus.directive.js +34 -34
- package/esm2015/lib/field-auto-focus/field-auto-focus.module.js +31 -31
- package/esm2015/lib/file-size/file-size.module.js +29 -29
- package/esm2015/lib/file-size/file-size.pipe.js +44 -44
- package/esm2015/lib/filter-sidebar/filter-sidebar.component.js +45 -45
- package/esm2015/lib/filter-sidebar/filter-sidebar.module.js +29 -29
- package/esm2015/lib/form-io/form-io-builder.component.js +38 -38
- package/esm2015/lib/form-io/form-io-uploader/form-io-uploader-edit-form.js +89 -89
- package/esm2015/lib/form-io/form-io-uploader/form-io-uploader.component.js +71 -71
- package/esm2015/lib/form-io/form-io-uploader/form-io-uploader.formio.js +25 -25
- package/esm2015/lib/form-io/form-io.component.js +157 -157
- package/esm2015/lib/form-io/form-io.module.js +55 -55
- package/esm2015/lib/form-io/formio-config.js +21 -21
- package/esm2015/lib/form-io/services/form-io-dom.service.js +22 -22
- package/esm2015/lib/form-io/services/form-io-state.service.js +23 -23
- package/esm2015/lib/left-sidebar/left-sidebar.component.js +113 -113
- package/esm2015/lib/left-sidebar/left-sidebar.module.js +33 -33
- package/esm2015/lib/list/ListFilterPipe.directive.js +34 -34
- package/esm2015/lib/list/list.component.js +176 -176
- package/esm2015/lib/list/list.module.js +32 -32
- package/esm2015/lib/menu/menu-item-text.component.js +27 -27
- package/esm2015/lib/menu/menu-routing.module.js +28 -28
- package/esm2015/lib/menu/menu.component.js +64 -64
- package/esm2015/lib/menu/menu.init.js +33 -33
- package/esm2015/lib/menu/menu.module.js +38 -38
- package/esm2015/lib/menu/menu.service.js +126 -126
- package/esm2015/lib/menu/submenu-item-text.component.js +27 -27
- package/esm2015/lib/modal/modal.component.js +47 -47
- package/esm2015/lib/modal/modal.module.js +27 -27
- package/esm2015/lib/page-header/page-header.component.js +28 -28
- package/esm2015/lib/page-header/page-header.module.js +33 -33
- package/esm2015/lib/page-title/page-title.component.js +75 -75
- package/esm2015/lib/page-title/page-title.module.js +31 -31
- package/esm2015/lib/progress-bar/progress-bar.component.js +25 -25
- package/esm2015/lib/progress-bar/progress-bar.module.js +29 -29
- package/esm2015/lib/right-sidebar/right-sidebar.component.js +130 -130
- package/esm2015/lib/right-sidebar/right-sidebar.module.js +48 -48
- package/esm2015/lib/searchable-dropdown/searchable-dropdown.component.js +184 -184
- package/esm2015/lib/searchable-dropdown/searchable-dropdown.module.js +28 -28
- package/esm2015/lib/searchable-dropdown-select/searchable-dropdown-select.component.js +51 -51
- package/esm2015/lib/searchable-dropdown-select/searchable-dropdown-select.module.js +29 -29
- package/esm2015/lib/spinner/spinner.component.js +44 -44
- package/esm2015/lib/spinner/spinner.module.js +35 -35
- package/esm2015/lib/timeline/timeline.component.js +28 -28
- package/esm2015/lib/timeline/timeline.module.js +31 -31
- package/esm2015/lib/topbar/topbar.component.js +28 -28
- package/esm2015/lib/topbar/topbar.module.js +31 -31
- package/esm2015/lib/uploader/uploader-drag-drop.directive.js +48 -48
- package/esm2015/lib/uploader/uploader.component.js +69 -69
- package/esm2015/lib/uploader/uploader.module.js +32 -32
- package/esm2015/lib/version/version.service.js +37 -37
- package/esm2015/lib/view-content/type-converters/booleanTypeConverter.js +28 -28
- package/esm2015/lib/view-content/type-converters/dateTypeConverter.js +29 -29
- package/esm2015/lib/view-content/type-converters/enumTypeConverter.js +23 -23
- package/esm2015/lib/view-content/type-converters/relatedFilesTypeConverter.js +23 -23
- package/esm2015/lib/view-content/type-converters/stringReplaceUnderscoreTypeConverter.js +26 -26
- package/esm2015/lib/view-content/type-converters/stringTypeConverter.js +23 -23
- package/esm2015/lib/view-content/type-converters/type-converters.model.js +36 -36
- package/esm2015/lib/view-content/view-content.service.js +50 -50
- package/esm2015/lib/webcam/webcam.component.js +102 -102
- package/esm2015/lib/webcam/webcam.module.js +31 -31
- package/esm2015/lib/widget/widget.component.js +79 -79
- package/esm2015/lib/widget/widget.module.js +29 -29
- package/esm2015/public_api.js +83 -83
- package/esm2015/valtimo-components.js +26 -26
- package/fesm2015/valtimo-components.js +4303 -4303
- package/lib/alert/alert.component.d.ts +21 -21
- package/lib/alert/alert.module.d.ts +2 -2
- package/lib/alert/alert.service.d.ts +21 -21
- package/lib/bpmn-js-diagram/bpmn-js-diagram.component.d.ts +27 -27
- package/lib/bpmn-js-diagram/bpmn-js-diagram.module.d.ts +2 -2
- package/lib/breadcrumb-navigation/breadcrumb-navigation.component.d.ts +14 -14
- package/lib/breadcrumb-navigation/breadcrumb-navigation.module.d.ts +2 -2
- package/lib/camunda/form/camunda-form.components.d.ts +9 -9
- package/lib/camunda/form/camunda-form.module.d.ts +2 -2
- package/lib/camunda/form/custom/camunda-custom-form.component.d.ts +8 -8
- package/lib/camunda/form/custom/camunda-custom-form.module.d.ts +2 -2
- package/lib/camunda/form/generated/camunda-generated-form.component.d.ts +19 -19
- package/lib/camunda/form/generated/camunda-generated-form.module.d.ts +2 -2
- package/lib/camunda/form/generated/formfield/boolean/camunda-boolean-formfield.component.d.ts +7 -7
- package/lib/camunda/form/generated/formfield/camunda-formfield-generator.directive.d.ts +13 -13
- package/lib/camunda/form/generated/formfield/camunda-formfield.service.d.ts +7 -7
- package/lib/camunda/form/generated/formfield/choicefield/camunda-choicefield-formfield.component.d.ts +12 -12
- package/lib/camunda/form/generated/formfield/date/camunda-date-formfield.component.d.ts +14 -14
- package/lib/camunda/form/generated/formfield/enum/camunda-enum-formfield.component.d.ts +10 -10
- package/lib/camunda/form/generated/formfield/formfield.model.d.ts +20 -20
- package/lib/camunda/form/generated/formfield/long/camunda-long-formfield.component.d.ts +7 -7
- package/lib/camunda/form/generated/formfield/string/camunda-string-formfield.component.d.ts +7 -7
- package/lib/camunda/form/generated/formfield/textarea/camunda-textarea-formfield.component.d.ts +7 -7
- package/lib/camunda/form/generated/formfield/validation/camunda-formfield-validation.component.d.ts +10 -10
- package/lib/camunda/form/generated/formfield/validation/date.validators.d.ts +3 -3
- package/lib/card/card.component.d.ts +16 -16
- package/lib/card/card.module.d.ts +2 -2
- package/lib/components.module.d.ts +2 -2
- package/lib/data-list/data-list.component.d.ts +7 -7
- package/lib/data-list/data-list.module.d.ts +2 -2
- package/lib/dropzone/dropzone.component.d.ts +38 -38
- package/lib/dropzone/dropzone.module.d.ts +2 -2
- package/lib/field-auto-focus/field-auto-focus.directive.d.ts +6 -6
- package/lib/field-auto-focus/field-auto-focus.module.d.ts +2 -2
- package/lib/file-size/file-size.module.d.ts +2 -2
- package/lib/file-size/file-size.pipe.d.ts +5 -5
- package/lib/filter-sidebar/filter-sidebar.component.d.ts +8 -8
- package/lib/filter-sidebar/filter-sidebar.module.d.ts +2 -2
- package/lib/form-io/form-io-builder.component.d.ts +8 -8
- package/lib/form-io/form-io-uploader/form-io-uploader-edit-form.d.ts +61 -61
- package/lib/form-io/form-io-uploader/form-io-uploader.component.d.ts +29 -29
- package/lib/form-io/form-io-uploader/form-io-uploader.formio.d.ts +3 -3
- package/lib/form-io/form-io.component.d.ts +44 -44
- package/lib/form-io/form-io.module.d.ts +2 -2
- package/lib/form-io/formio-config.d.ts +6 -6
- package/lib/form-io/services/form-io-dom.service.d.ts +6 -6
- package/lib/form-io/services/form-io-state.service.d.ts +10 -10
- package/lib/left-sidebar/left-sidebar.component.d.ts +34 -34
- package/lib/left-sidebar/left-sidebar.module.d.ts +2 -2
- package/lib/list/ListFilterPipe.directive.d.ts +4 -4
- package/lib/list/list.component.d.ts +43 -43
- package/lib/list/list.module.d.ts +2 -2
- package/lib/menu/menu-item-text.component.d.ts +4 -4
- package/lib/menu/menu-routing.module.d.ts +2 -2
- package/lib/menu/menu.component.d.ts +18 -18
- package/lib/menu/menu.init.d.ts +3 -3
- package/lib/menu/menu.module.d.ts +2 -2
- package/lib/menu/menu.service.d.ts +23 -23
- package/lib/menu/submenu-item-text.component.d.ts +4 -4
- package/lib/modal/modal.component.d.ts +12 -12
- package/lib/modal/modal.module.d.ts +2 -2
- package/lib/page-header/page-header.component.d.ts +5 -5
- package/lib/page-header/page-header.module.d.ts +2 -2
- package/lib/page-title/page-title.component.d.ts +19 -19
- package/lib/page-title/page-title.module.d.ts +2 -2
- package/lib/progress-bar/progress-bar.component.d.ts +2 -2
- package/lib/progress-bar/progress-bar.module.d.ts +2 -2
- package/lib/right-sidebar/right-sidebar.component.d.ts +34 -34
- package/lib/right-sidebar/right-sidebar.module.d.ts +2 -2
- package/lib/searchable-dropdown/searchable-dropdown.component.d.ts +39 -39
- package/lib/searchable-dropdown/searchable-dropdown.module.d.ts +2 -2
- package/lib/searchable-dropdown-select/searchable-dropdown-select.component.d.ts +19 -19
- package/lib/searchable-dropdown-select/searchable-dropdown-select.module.d.ts +2 -2
- package/lib/spinner/spinner.component.d.ts +10 -10
- package/lib/spinner/spinner.module.d.ts +2 -2
- package/lib/timeline/timeline.component.d.ts +4 -4
- package/lib/timeline/timeline.module.d.ts +2 -2
- package/lib/topbar/topbar.component.d.ts +3 -3
- package/lib/topbar/topbar.module.d.ts +2 -2
- package/lib/uploader/uploader-drag-drop.directive.d.ts +7 -7
- package/lib/uploader/uploader.component.d.ts +15 -15
- package/lib/uploader/uploader.module.d.ts +2 -2
- package/lib/version/version.service.d.ts +8 -8
- package/lib/view-content/type-converters/booleanTypeConverter.d.ts +5 -5
- package/lib/view-content/type-converters/dateTypeConverter.d.ts +5 -5
- package/lib/view-content/type-converters/enumTypeConverter.d.ts +5 -5
- package/lib/view-content/type-converters/relatedFilesTypeConverter.d.ts +5 -5
- package/lib/view-content/type-converters/stringReplaceUnderscoreTypeConverter.d.ts +6 -6
- package/lib/view-content/type-converters/stringTypeConverter.d.ts +5 -5
- package/lib/view-content/type-converters/type-converters.model.d.ts +5 -5
- package/lib/view-content/view-content.service.d.ts +8 -8
- package/lib/webcam/webcam.component.d.ts +20 -20
- package/lib/webcam/webcam.module.d.ts +2 -2
- package/lib/widget/widget.component.d.ts +28 -28
- package/lib/widget/widget.module.d.ts +2 -2
- package/package.json +1 -1
- package/public_api.d.ts +65 -65
- package/valtimo-components.d.ts +26 -26
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { Component } from '@angular/core';
|
|
17
|
-
import { AlertType } from '@valtimo/contract';
|
|
18
|
-
import { AlertService } from './alert.service';
|
|
19
|
-
export class AlertComponent {
|
|
20
|
-
constructor(alertService) {
|
|
21
|
-
this.alertService = alertService;
|
|
22
|
-
this.alerts = [];
|
|
23
|
-
this.autoCloseInMS = 5000;
|
|
24
|
-
}
|
|
25
|
-
ngOnInit() {
|
|
26
|
-
}
|
|
27
|
-
ngAfterContentInit() {
|
|
28
|
-
this.subscription = this.alertService.onAlert()
|
|
29
|
-
.subscribe(alert => {
|
|
30
|
-
if (!alert.message) {
|
|
31
|
-
// clear alerts when an empty alert is received
|
|
32
|
-
this.alerts = [];
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
// set empty array when an empty alert confirmations is received
|
|
36
|
-
if (!alert.confirmations) {
|
|
37
|
-
alert.confirmations = [];
|
|
38
|
-
}
|
|
39
|
-
// add alert to array if not exist
|
|
40
|
-
const alertExist = this.alerts.filter(x => x.message === alert.message);
|
|
41
|
-
if (alertExist.length === 0) {
|
|
42
|
-
this.alerts.push(alert);
|
|
43
|
-
}
|
|
44
|
-
if (this.inModal(alert)) {
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
this.openModal();
|
|
47
|
-
}, 300);
|
|
48
|
-
}
|
|
49
|
-
// auto close except alert confirmations not empty
|
|
50
|
-
if (this.autoCloseInMS > 0 && alert.confirmations.length === 0) {
|
|
51
|
-
setTimeout(() => {
|
|
52
|
-
this.removeAlert(alert);
|
|
53
|
-
}, this.autoCloseInMS);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
closeModal() {
|
|
58
|
-
$('#modalNotification').modal('hide');
|
|
59
|
-
}
|
|
60
|
-
openModal() {
|
|
61
|
-
$('#modalNotification').modal('show');
|
|
62
|
-
}
|
|
63
|
-
alertConfirm(alert, confirm) {
|
|
64
|
-
alert.confirm = confirm;
|
|
65
|
-
this.alertService.emitAlertConfirmEvent(alert);
|
|
66
|
-
this.removeAlert(alert);
|
|
67
|
-
}
|
|
68
|
-
ngOnDestroy() {
|
|
69
|
-
// unsubscribe to avoid memory leaks
|
|
70
|
-
this.subscription.unsubscribe();
|
|
71
|
-
}
|
|
72
|
-
removeAlert(alert) {
|
|
73
|
-
if (this.inModal(alert)) {
|
|
74
|
-
this.closeModal();
|
|
75
|
-
}
|
|
76
|
-
// remove specified alert from array
|
|
77
|
-
this.alerts = this.alerts.filter(x => x.message !== alert.message);
|
|
78
|
-
}
|
|
79
|
-
inModal(alert) {
|
|
80
|
-
if (!alert) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
// return true based on AlertType.ModalNotification
|
|
84
|
-
switch (alert.type) {
|
|
85
|
-
case AlertType.ModalNotification:
|
|
86
|
-
return true;
|
|
87
|
-
default:
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
cssClass(alert) {
|
|
92
|
-
if (!alert) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
// return css class based on alert type
|
|
96
|
-
switch (alert.type) {
|
|
97
|
-
case AlertType.Success:
|
|
98
|
-
return 'alert alert-success';
|
|
99
|
-
case AlertType.Error:
|
|
100
|
-
return 'alert alert-danger';
|
|
101
|
-
case AlertType.Info:
|
|
102
|
-
return 'alert alert-info';
|
|
103
|
-
case AlertType.Warning:
|
|
104
|
-
return 'alert alert-warning';
|
|
105
|
-
case AlertType.Notification:
|
|
106
|
-
return 'alert alert-light';
|
|
107
|
-
case AlertType.ModalNotification:
|
|
108
|
-
return 'alert alert-light';
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
cssIconClass(alert) {
|
|
112
|
-
if (!alert) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
// return css class based on alert type
|
|
116
|
-
switch (alert.type) {
|
|
117
|
-
case AlertType.Success:
|
|
118
|
-
return 'mdi mdi-check';
|
|
119
|
-
case AlertType.Error:
|
|
120
|
-
return 'mdi mdi-close-circle-o';
|
|
121
|
-
case AlertType.Info:
|
|
122
|
-
return 'mdi mdi-info-outline';
|
|
123
|
-
case AlertType.Warning:
|
|
124
|
-
return 'mdi mdi-alert-triangle';
|
|
125
|
-
case AlertType.Notification:
|
|
126
|
-
return 'mdi mdi-notifications';
|
|
127
|
-
case AlertType.ModalNotification:
|
|
128
|
-
return 'mdi mdi-notifications';
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
AlertComponent.decorators = [
|
|
133
|
-
{ type: Component, args: [{
|
|
134
|
-
selector: 'valtimo-alert',
|
|
135
|
-
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div *ngFor=\"let alert of alerts\" class=\"{{cssClass(alert)}} rounded-0 m-0 alert-dismissable\">\n\n <div *ngIf=\"inModal(alert)\">\n <!-- Modal -->\n <div class=\"modal fade\" id=\"modalNotification\" tabindex=\"-1\" role=\"dialog\">\n <div class=\"modal-dialog\" role=\"document\">\n <div class=\"modal-content\">\n <div class=\"modal-body p-0\">\n <button class=\"close\" type=\"button\" (click)=\"removeAlert(alert)\"><span class=\"mdi mdi-close\" aria-hidden=\"true\"></span></button>\n <div class=\"icon\"><span class=\"{{ alert.iconClass || cssIconClass(alert) }}\"></span></div>\n <div class=\"message\">\n <div [innerHTML]=\"alert.message\"></div>\n </div>\n </div>\n <div class=\"modal-footer pt-0\" *ngIf=\"alert.confirmations?.length\">\n <button class=\"{{ confirmation.class }} mr-2\"\n *ngFor=\"let confirmation of alert.confirmations\"\n (click)=\"alertConfirm(alert, confirmation.value)\">{{ confirmation.label }}</button>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <div *ngIf=\"!inModal(alert)\" class=\"alert-block\">\n <div class=\"icon\"><span class=\"{{ alert.iconClass || cssIconClass(alert) }}\"></span></div>\n <div class=\"message\">\n <div [innerHTML]=\"alert.message\"></div>\n <div class=\"mt-3\" *ngIf=\"alert.confirmations?.length\">\n <button class=\"{{ confirmation.class }} mr-2\"\n *ngFor=\"let confirmation of alert.confirmations\"\n (click)=\"alertConfirm(alert, confirmation.value)\">{{ confirmation.label }}</button>\n </div>\n </div>\n <button class=\"close\" type=\"button\" (click)=\"removeAlert(alert)\"><span class=\"mdi mdi-close\" aria-hidden=\"true\"></span></button>\n </div>\n</div>\n",
|
|
136
|
-
styles: [".alert-block{display:flex;flex-direction:row;justify-content:space-between}.alert-block .message{width:100%}.alert-block .icon{align-items:center;display:flex}.alert .message{font-size:1.1rem!important;line-height:1.5rem!important;padding:2rem 5rem 2rem 2rem!important}.alert .close{color:#fff!important;opacity:1!important;padding:2rem 2rem 0 0!important;right:0!important}.alert .icon{padding-left:2rem!important}.alert-warning{color:#404040!important}.alert-light .close,.alert-warning .close{color:#404040!important;opacity:1!important}"]
|
|
137
|
-
},] }
|
|
138
|
-
];
|
|
139
|
-
AlertComponent.ctorParameters = () => [
|
|
140
|
-
{ type: AlertService }
|
|
141
|
-
];
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Component } from '@angular/core';
|
|
17
|
+
import { AlertType } from '@valtimo/contract';
|
|
18
|
+
import { AlertService } from './alert.service';
|
|
19
|
+
export class AlertComponent {
|
|
20
|
+
constructor(alertService) {
|
|
21
|
+
this.alertService = alertService;
|
|
22
|
+
this.alerts = [];
|
|
23
|
+
this.autoCloseInMS = 5000;
|
|
24
|
+
}
|
|
25
|
+
ngOnInit() {
|
|
26
|
+
}
|
|
27
|
+
ngAfterContentInit() {
|
|
28
|
+
this.subscription = this.alertService.onAlert()
|
|
29
|
+
.subscribe(alert => {
|
|
30
|
+
if (!alert.message) {
|
|
31
|
+
// clear alerts when an empty alert is received
|
|
32
|
+
this.alerts = [];
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// set empty array when an empty alert confirmations is received
|
|
36
|
+
if (!alert.confirmations) {
|
|
37
|
+
alert.confirmations = [];
|
|
38
|
+
}
|
|
39
|
+
// add alert to array if not exist
|
|
40
|
+
const alertExist = this.alerts.filter(x => x.message === alert.message);
|
|
41
|
+
if (alertExist.length === 0) {
|
|
42
|
+
this.alerts.push(alert);
|
|
43
|
+
}
|
|
44
|
+
if (this.inModal(alert)) {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
this.openModal();
|
|
47
|
+
}, 300);
|
|
48
|
+
}
|
|
49
|
+
// auto close except alert confirmations not empty
|
|
50
|
+
if (this.autoCloseInMS > 0 && alert.confirmations.length === 0) {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
this.removeAlert(alert);
|
|
53
|
+
}, this.autoCloseInMS);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
closeModal() {
|
|
58
|
+
$('#modalNotification').modal('hide');
|
|
59
|
+
}
|
|
60
|
+
openModal() {
|
|
61
|
+
$('#modalNotification').modal('show');
|
|
62
|
+
}
|
|
63
|
+
alertConfirm(alert, confirm) {
|
|
64
|
+
alert.confirm = confirm;
|
|
65
|
+
this.alertService.emitAlertConfirmEvent(alert);
|
|
66
|
+
this.removeAlert(alert);
|
|
67
|
+
}
|
|
68
|
+
ngOnDestroy() {
|
|
69
|
+
// unsubscribe to avoid memory leaks
|
|
70
|
+
this.subscription.unsubscribe();
|
|
71
|
+
}
|
|
72
|
+
removeAlert(alert) {
|
|
73
|
+
if (this.inModal(alert)) {
|
|
74
|
+
this.closeModal();
|
|
75
|
+
}
|
|
76
|
+
// remove specified alert from array
|
|
77
|
+
this.alerts = this.alerts.filter(x => x.message !== alert.message);
|
|
78
|
+
}
|
|
79
|
+
inModal(alert) {
|
|
80
|
+
if (!alert) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// return true based on AlertType.ModalNotification
|
|
84
|
+
switch (alert.type) {
|
|
85
|
+
case AlertType.ModalNotification:
|
|
86
|
+
return true;
|
|
87
|
+
default:
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
cssClass(alert) {
|
|
92
|
+
if (!alert) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// return css class based on alert type
|
|
96
|
+
switch (alert.type) {
|
|
97
|
+
case AlertType.Success:
|
|
98
|
+
return 'alert alert-success';
|
|
99
|
+
case AlertType.Error:
|
|
100
|
+
return 'alert alert-danger';
|
|
101
|
+
case AlertType.Info:
|
|
102
|
+
return 'alert alert-info';
|
|
103
|
+
case AlertType.Warning:
|
|
104
|
+
return 'alert alert-warning';
|
|
105
|
+
case AlertType.Notification:
|
|
106
|
+
return 'alert alert-light';
|
|
107
|
+
case AlertType.ModalNotification:
|
|
108
|
+
return 'alert alert-light';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
cssIconClass(alert) {
|
|
112
|
+
if (!alert) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// return css class based on alert type
|
|
116
|
+
switch (alert.type) {
|
|
117
|
+
case AlertType.Success:
|
|
118
|
+
return 'mdi mdi-check';
|
|
119
|
+
case AlertType.Error:
|
|
120
|
+
return 'mdi mdi-close-circle-o';
|
|
121
|
+
case AlertType.Info:
|
|
122
|
+
return 'mdi mdi-info-outline';
|
|
123
|
+
case AlertType.Warning:
|
|
124
|
+
return 'mdi mdi-alert-triangle';
|
|
125
|
+
case AlertType.Notification:
|
|
126
|
+
return 'mdi mdi-notifications';
|
|
127
|
+
case AlertType.ModalNotification:
|
|
128
|
+
return 'mdi mdi-notifications';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
AlertComponent.decorators = [
|
|
133
|
+
{ type: Component, args: [{
|
|
134
|
+
selector: 'valtimo-alert',
|
|
135
|
+
template: "<!--\n ~ Copyright 2015-2020 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div *ngFor=\"let alert of alerts\" class=\"{{cssClass(alert)}} rounded-0 m-0 alert-dismissable\">\n\n <div *ngIf=\"inModal(alert)\">\n <!-- Modal -->\n <div class=\"modal fade\" id=\"modalNotification\" tabindex=\"-1\" role=\"dialog\">\n <div class=\"modal-dialog\" role=\"document\">\n <div class=\"modal-content\">\n <div class=\"modal-body p-0\">\n <button class=\"close\" type=\"button\" (click)=\"removeAlert(alert)\"><span class=\"mdi mdi-close\" aria-hidden=\"true\"></span></button>\n <div class=\"icon\"><span class=\"{{ alert.iconClass || cssIconClass(alert) }}\"></span></div>\n <div class=\"message\">\n <div [innerHTML]=\"alert.message\"></div>\n </div>\n </div>\n <div class=\"modal-footer pt-0\" *ngIf=\"alert.confirmations?.length\">\n <button class=\"{{ confirmation.class }} mr-2\"\n *ngFor=\"let confirmation of alert.confirmations\"\n (click)=\"alertConfirm(alert, confirmation.value)\">{{ confirmation.label }}</button>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <div *ngIf=\"!inModal(alert)\" class=\"alert-block\">\n <div class=\"icon\"><span class=\"{{ alert.iconClass || cssIconClass(alert) }}\"></span></div>\n <div class=\"message\">\n <div [innerHTML]=\"alert.message\"></div>\n <div class=\"mt-3\" *ngIf=\"alert.confirmations?.length\">\n <button class=\"{{ confirmation.class }} mr-2\"\n *ngFor=\"let confirmation of alert.confirmations\"\n (click)=\"alertConfirm(alert, confirmation.value)\">{{ confirmation.label }}</button>\n </div>\n </div>\n <button class=\"close\" type=\"button\" (click)=\"removeAlert(alert)\"><span class=\"mdi mdi-close\" aria-hidden=\"true\"></span></button>\n </div>\n</div>\n",
|
|
136
|
+
styles: [".alert-block{display:flex;flex-direction:row;justify-content:space-between}.alert-block .message{width:100%}.alert-block .icon{align-items:center;display:flex}.alert .message{font-size:1.1rem!important;line-height:1.5rem!important;padding:2rem 5rem 2rem 2rem!important}.alert .close{color:#fff!important;opacity:1!important;padding:2rem 2rem 0 0!important;right:0!important}.alert .icon{padding-left:2rem!important}.alert-warning{color:#404040!important}.alert-light .close,.alert-warning .close{color:#404040!important;opacity:1!important}"]
|
|
137
|
+
},] }
|
|
138
|
+
];
|
|
139
|
+
AlertComponent.ctorParameters = () => [
|
|
140
|
+
{ type: AlertService }
|
|
141
|
+
];
|
|
142
142
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWxlcnQuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvdmFsdGltby9jb21wb25lbnRzL3NyYy9saWIvYWxlcnQvYWxlcnQuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7Ozs7OztHQWNHO0FBRUgsT0FBTyxFQUFtQixTQUFTLEVBQW9CLE1BQU0sZUFBZSxDQUFDO0FBRTdFLE9BQU8sRUFBUSxTQUFTLEVBQUMsTUFBTSxtQkFBbUIsQ0FBQztBQUNuRCxPQUFPLEVBQUMsWUFBWSxFQUFDLE1BQU0saUJBQWlCLENBQUM7QUFTN0MsTUFBTSxPQUFPLGNBQWM7SUFLdkIsWUFDWSxZQUEwQjtRQUExQixpQkFBWSxHQ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RvQ2xvc2VJbk1TOiBudW1iZXI7XG5cbiAgICBjb25zdHJ1Y3RvcihcbiAgICAgICAgcHJpdmF0ZSBhbGVydFNlcnZpY2U6IEFsZXJ0U2VydmljZVxuICAgICkge1xuICAgICAgICB0aGlzLmF1dG9DbG9zZUluTVMgPSA1MDAwO1xuICAgIH1cblxuICAgIG5nT25Jbml0KCkge1xuICAgIH1cblxuICAgIG5nQWZ0ZXJDb250ZW50SW5pdCgpIHtcbiAgICAgICAgdGhpcy5zdWJzY3JpcHRpb24gPSB0aGlzLmFsZXJ0U2VydmljZS5vbkFsZXJ0KClcbiAgICAgICAgICAgIC5zdWJzY3JpYmUoYWxlcnQgPT4ge1xuXG4gICAgICAgICAgICAgICAgaWYgKCFhbGVydC5tZXNzYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGNsZWFyIGFsZXJ0cyB3aGVuIGFuIGVtcHR5IGFsZXJ0IGlzIHJlY2VpdmVkXG4gICAgICAgICAgICAgICAgICAgIHRoaXMuYWxlcnRzID0gW107XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBzZXQgZW1wdHkgYXJyYXkgd2hlbiBhbiBlbXB0eSBhbGVydCBjb25maXJtYXRpb25zIGlzIHJlY2VpdmVkXG4gICAgICAgICAgICAgICAgaWYgKCFhbGVydC5jb25maXJtYXRpb25zKSB7XG4gICAgICAgICAgICAgICAgICAgIGFsZXJ0LmNvbmZpcm1hdGlvbnMgPSBbXTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBhZGQgYWxlcnQgdG8gYXJyYXkgaWYgbm90IGV4aXN0XG4gICAgICAgICAgICAgICAgY29uc3QgYWxlcnRFeGlzdCA9IHRoaXMuYWxlcnRzLmZpbHRlcih4ID0+IHgubWVzc2FnZSA9PT0gYWxlcnQubWVzc2FnZSk7XG4gICAgICAgICAgICAgICAgaWYgKGFsZXJ0RXhpc3QubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuYWxlcnRzLnB1c2goYWxlcnQpO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICh0aGlzLmluTW9kYWwoYWxlcnQpKSB7XG4gICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVuTW9kYWwoKTtcbiAgICAgICAgICAgICAgICAgICAgfSwgMzAwKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAvLyBhdXRvIGNsb3NlIGV4Y2VwdCBhbGVydCBjb25maXJtYXRpb25zIG5vdCBlbXB0eVxuICAgICAgICAgICAgICAgIGlmICh0aGlzLmF1dG9DbG9zZUluTVMgPiAwICYmIGFsZXJ0LmNvbmZpcm1hdGlvbnMubGVuZ3RoID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmVBbGVydChhbGVydCk7XG4gICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuYXV0b0Nsb3NlSW5NUyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgfVxuXG4gICAgY2xvc2VNb2RhbCgpIHtcbiAgICAgICAgJCgnI21vZGFsTm90aWZpY2F0aW9uJykubW9kYWwoJ2hpZGUnKTtcbiAgICB9XG5cbiAgICBvcGVuTW9kYWwoKSB7XG4gICAgICAgICQoJyNtb2RhbE5vdGlmaWNhdGlvbicpLm1vZGFsKCdzaG93Jyk7XG4gICAgfVxuXG4gICAgYWxlcnRDb25maXJtKGFsZXJ0OiBBbGVydCwgY29uZmlybTogYW55KSB7XG4gICAgICAgIGFsZXJ0LmNvbmZpcm0gPSBjb25maXJtO1xuICAgICAgICB0aGlzLmFsZXJ0U2VydmljZS5l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gICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgLy8gcmV0dXJuIGNzcyBjbGFzcyBiYXNlZCBvbiBhbGVydCB0eXBlXG4gICAgICAgIHN3aXRjaCAoYWxlcnQudHlwZSkge1xuICAgICAgICAgICAgY2FzZSBBbGVydFR5cGUuU3VjY2VzczpcbiAgICAgICAgICAgICAgICByZXR1cm4gJ2FsZXJ0IGFsZXJ0LXN1Y2Nlc3MnO1xuICAgICAgICAgICAgY2FzZSBBbGVydFR5cGUuRXJyb3I6XG4gICAgICAgICAgICAgICAgcmV0dXJuICdhbGVydCBhbGVydC1kYW5nZXInO1xuICAgICAgICAgICAgY2FzZSBBbGVydFR5cGUuSW5mbzpcbiAgICAgICAgICAgICAgICByZXR1cm4gJ2FsZXJ0IGFsZXJ0LWluZm8nO1xuICAgICAgICAgICAgY2FzZSBBbGVydFR5cGUuV2FybmluZzpcbiAgICAgICAgICAgICAgICByZXR1cm4gJ2FsZXJ0IGFsZXJ0LXdhcm5pbmcnO1xuICAgICAgICAgICAgY2FzZSBBbGVydFR5cGUuTm90aWZpY2F0aW9uOlxuICAgICAgICAgICAgICAgIHJldHVybiAnYWxlcnQgYWxlcnQtbGlnaHQnO1xuICAgICAgICAgICAgY2FzZSBBbGVydFR5cGUuTW9kYWxOb3RpZmljYXRpb246XG4gICAgICAgICAgICAgICAgcmV0dXJuICdhbGVydCBhbGVydC1saWdodCc7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBjc3NJY29uQ2xhc3MoYWxlcnQ6IEFsZXJ0KSB7XG4gICAgICAgIGlmICghYWxlcnQpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIHJldHVybiBjc3MgY2xhc3MgYmFzZWQgb24gYWxlcnQgdHlwZVxuICAgICAgICBzd2l0Y2ggKGFsZXJ0LnR5cGUpIHtcbiAgICAgICAgICAgIGNhc2UgQWxlcnRUeXBlLlN1Y2Nlc3M6XG4gICAgICAgICAgICAgICAgcmV0dXJuICdtZGkgbWRpLWNoZWNrJztcbiAgICAgICAgICAgIGNhc2UgQWxlcnRUeXBlLkVycm9yOlxuICAgICAgICAgICAgICAgIHJldHVybiAnbWRpIG1kaS1jbG9zZS1jaXJjbGUtbyc7XG4gICAgICAgICAgICBjYXNlIEFsZXJ0VHlwZS5JbmZvOlxuICAgICAgICAgICAgICAgIHJldHVybiAnbWRpIG1kaS1pbmZvLW91dGxpbmUnO1xuICAgICAgICAgICAgY2FzZSBBbGVydFR5cGUuV2FybmluZzpcbiAgICAgICAgICAgICAgICByZXR1cm4gJ21kaSBtZGktYWxlcnQtdHJpYW5nbGUnO1xuICAgICAgICAgICAgY2FzZSBBbGVydFR5cGUuTm90aWZpY2F0aW9uOlxuICAgICAgICAgICAgICAgIHJldHVybiAnbWRpIG1kaS1ub3RpZmljYXRpb25zJztcbiAgICAgICAgICAgIGNhc2UgQWxlcnRUeXBlLk1vZGFsTm90aWZpY2F0aW9uOlxuICAgICAgICAgICAgICAgIHJldHVybiAnbWRpIG1kaS1ub3RpZmljYXRpb25zJztcbiAgICAgICAgfVxuICAgIH1cblxufVxuIl19
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { NgModule } from '@angular/core';
|
|
17
|
-
import { CommonModule } from '@angular/common';
|
|
18
|
-
import { AlertComponent } from './alert.component';
|
|
19
|
-
export class AlertModule {
|
|
20
|
-
}
|
|
21
|
-
AlertModule.decorators = [
|
|
22
|
-
{ type: NgModule, args: [{
|
|
23
|
-
imports: [CommonModule],
|
|
24
|
-
declarations: [AlertComponent],
|
|
25
|
-
exports: [AlertComponent]
|
|
26
|
-
},] }
|
|
27
|
-
];
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { NgModule } from '@angular/core';
|
|
17
|
+
import { CommonModule } from '@angular/common';
|
|
18
|
+
import { AlertComponent } from './alert.component';
|
|
19
|
+
export class AlertModule {
|
|
20
|
+
}
|
|
21
|
+
AlertModule.decorators = [
|
|
22
|
+
{ type: NgModule, args: [{
|
|
23
|
+
imports: [CommonModule],
|
|
24
|
+
declarations: [AlertComponent],
|
|
25
|
+
exports: [AlertComponent]
|
|
26
|
+
},] }
|
|
27
|
+
];
|
|
28
28
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWxlcnQubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvdmFsdGltby9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HJpYnV0ZWQgb24gYW4gXCJBUyBJU1wiIGJhc2lzLFxuICogV0lUSE9VVCBXQVJSQU5USUVTIE9SIENPTkRJVElPTlMgT0YgQU5ZIEtJTkQsIGVpdGhlciBleHByZXNzIG9yIGltcGxpZWQuXG4gKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kXG4gKiBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS5cbiAqL1xuXG5pbXBvcnQge05nTW9kdWxlfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7Q29tbW9uTW9kdWxlfSBmcm9tICdAYW5ndWxhci9jb21tb24nO1xuaW1wb3J0IHtBbGVydENvbXBvbmVudH0gZnJvbSAnLi9hbGVydC5jb21wb25lbnQnO1xuXG5ATmdNb2R1bGUoe1xuICBpbXBvcnRzOiBbQ29tbW9uTW9kdWxlXSxcbiAgZGVjbGFyYXRpb25zOiBbQWxlcnRDb21wb25lbnRdLFxuICBleHBvcnRzOiBbQWxlcnRDb21wb25lbnRdXG59KVxuZXhwb3J0IGNsYXNzIEFsZXJ0TW9kdWxlIHtcbn1cbiJdfQ==
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under EUPL, Version 1.2 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" basis,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { EventEmitter, Injectable } from '@angular/core';
|
|
17
|
-
import { NavigationStart, Router } from '@angular/router';
|
|
18
|
-
import { Subject } from 'rxjs';
|
|
19
|
-
import { Alert, AlertType } from '@valtimo/contract';
|
|
20
|
-
import * as i0 from "@angular/core";
|
|
21
|
-
import * as i1 from "@angular/router";
|
|
22
|
-
export class AlertService {
|
|
23
|
-
constructor(router) {
|
|
24
|
-
this.router = router;
|
|
25
|
-
this.confirmed = new EventEmitter();
|
|
26
|
-
this.subject = new Subject();
|
|
27
|
-
// clear alert messages on route change unless 'keepAfterRouteChange' flag is true
|
|
28
|
-
this.router.events.subscribe(event => {
|
|
29
|
-
if (event instanceof NavigationStart) {
|
|
30
|
-
// clear alert messages
|
|
31
|
-
this.clear();
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// enable subscribing to alerts observable
|
|
36
|
-
onAlert() {
|
|
37
|
-
return this.subject.asObservable();
|
|
38
|
-
}
|
|
39
|
-
// convenience methods
|
|
40
|
-
success(message, confirmations, iconClass) {
|
|
41
|
-
this.alert(new Alert({ message, type: AlertType.Success, confirmations, iconClass }));
|
|
42
|
-
}
|
|
43
|
-
error(message, confirmations, iconClass) {
|
|
44
|
-
this.alert(new Alert({ message, type: AlertType.Error, confirmations, iconClass }));
|
|
45
|
-
}
|
|
46
|
-
info(message, confirmations, iconClass) {
|
|
47
|
-
this.alert(new Alert({ message, type: AlertType.Info, confirmations, iconClass }));
|
|
48
|
-
}
|
|
49
|
-
warning(message, confirmations, iconClass) {
|
|
50
|
-
this.alert(new Alert({ message, type: AlertType.Warning, confirmations, iconClass }));
|
|
51
|
-
}
|
|
52
|
-
notification(message, confirmations, iconClass) {
|
|
53
|
-
this.alert(new Alert({ message, type: AlertType.Notification, confirmations, iconClass }));
|
|
54
|
-
}
|
|
55
|
-
modalNotification(message, confirmations, iconClass) {
|
|
56
|
-
this.alert(new Alert({ message, type: AlertType.ModalNotification, confirmations, iconClass }));
|
|
57
|
-
}
|
|
58
|
-
// main alert method
|
|
59
|
-
alert(alert) {
|
|
60
|
-
this.subject.next(alert);
|
|
61
|
-
}
|
|
62
|
-
// clear alerts
|
|
63
|
-
clear() {
|
|
64
|
-
this.subject.next(new Alert({}));
|
|
65
|
-
}
|
|
66
|
-
// emit confirm
|
|
67
|
-
emitAlertConfirmEvent(alert) {
|
|
68
|
-
this.confirmed.emit(alert);
|
|
69
|
-
}
|
|
70
|
-
getAlertConfirmChangeEmitter() {
|
|
71
|
-
return this.confirmed;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
AlertService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AlertService_Factory() { return new AlertService(i0.ɵɵinject(i1.Router)); }, token: AlertService, providedIn: "root" });
|
|
75
|
-
AlertService.decorators = [
|
|
76
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
77
|
-
];
|
|
78
|
-
AlertService.ctorParameters = () => [
|
|
79
|
-
{ type: Router }
|
|
80
|
-
];
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2015-2020 Ritense BV, the Netherlands.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { EventEmitter, Injectable } from '@angular/core';
|
|
17
|
+
import { NavigationStart, Router } from '@angular/router';
|
|
18
|
+
import { Subject } from 'rxjs';
|
|
19
|
+
import { Alert, AlertType } from '@valtimo/contract';
|
|
20
|
+
import * as i0 from "@angular/core";
|
|
21
|
+
import * as i1 from "@angular/router";
|
|
22
|
+
export class AlertService {
|
|
23
|
+
constructor(router) {
|
|
24
|
+
this.router = router;
|
|
25
|
+
this.confirmed = new EventEmitter();
|
|
26
|
+
this.subject = new Subject();
|
|
27
|
+
// clear alert messages on route change unless 'keepAfterRouteChange' flag is true
|
|
28
|
+
this.router.events.subscribe(event => {
|
|
29
|
+
if (event instanceof NavigationStart) {
|
|
30
|
+
// clear alert messages
|
|
31
|
+
this.clear();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// enable subscribing to alerts observable
|
|
36
|
+
onAlert() {
|
|
37
|
+
return this.subject.asObservable();
|
|
38
|
+
}
|
|
39
|
+
// convenience methods
|
|
40
|
+
success(message, confirmations, iconClass) {
|
|
41
|
+
this.alert(new Alert({ message, type: AlertType.Success, confirmations, iconClass }));
|
|
42
|
+
}
|
|
43
|
+
error(message, confirmations, iconClass) {
|
|
44
|
+
this.alert(new Alert({ message, type: AlertType.Error, confirmations, iconClass }));
|
|
45
|
+
}
|
|
46
|
+
info(message, confirmations, iconClass) {
|
|
47
|
+
this.alert(new Alert({ message, type: AlertType.Info, confirmations, iconClass }));
|
|
48
|
+
}
|
|
49
|
+
warning(message, confirmations, iconClass) {
|
|
50
|
+
this.alert(new Alert({ message, type: AlertType.Warning, confirmations, iconClass }));
|
|
51
|
+
}
|
|
52
|
+
notification(message, confirmations, iconClass) {
|
|
53
|
+
this.alert(new Alert({ message, type: AlertType.Notification, confirmations, iconClass }));
|
|
54
|
+
}
|
|
55
|
+
modalNotification(message, confirmations, iconClass) {
|
|
56
|
+
this.alert(new Alert({ message, type: AlertType.ModalNotification, confirmations, iconClass }));
|
|
57
|
+
}
|
|
58
|
+
// main alert method
|
|
59
|
+
alert(alert) {
|
|
60
|
+
this.subject.next(alert);
|
|
61
|
+
}
|
|
62
|
+
// clear alerts
|
|
63
|
+
clear() {
|
|
64
|
+
this.subject.next(new Alert({}));
|
|
65
|
+
}
|
|
66
|
+
// emit confirm
|
|
67
|
+
emitAlertConfirmEvent(alert) {
|
|
68
|
+
this.confirmed.emit(alert);
|
|
69
|
+
}
|
|
70
|
+
getAlertConfirmChangeEmitter() {
|
|
71
|
+
return this.confirmed;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
AlertService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AlertService_Factory() { return new AlertService(i0.ɵɵinject(i1.Router)); }, token: AlertService, providedIn: "root" });
|
|
75
|
+
AlertService.decorators = [
|
|
76
|
+
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
77
|
+
];
|
|
78
|
+
AlertService.ctorParameters = () => [
|
|
79
|
+
{ type: Router }
|
|
80
|
+
];
|
|
81
81
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWxlcnQuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL3ZhbHRpbW8vY29tcG9uZW50cy9zcmMvbGliL2FsZXJ0L2FsZXJ0LnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFFSCxPQUFPLEVBQUMsWUFBWSxFQUFFLFVBQVUsRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUN2RCxPQUFPLEVBQUMsZUFBZSxFQUFFLE1BQU0sRUFBQyxNQUFNLGlCQUFpQixDQUFDO0FBQ3hELE9BQU8sRUFBYSxPQUFPLEVBQUMsTUFBTSxNQUFNLENBQUM7QUFDekMsT0FBTyxFQUFDLEtBQUssRUFBRSxTQUFTLEVBQUMsTUFBTSxtQkFBbUIsQ0FBQzs7O0FBR25ELE1BQU0sT0FBTyxZQUFZO0lBSXZCLFlBQW9C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