@cauca-911/material 21.0.1-beta.3 → 21.0.1-beta.5
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/.eslintrc.json +79 -0
- package/README_PACKAGE.md +5 -0
- package/karma.conf.js +50 -0
- package/ng-package.json +7 -0
- package/package.json +2 -17
- package/src/assets/i18n/cauca/en-material.json +104 -0
- package/src/assets/i18n/cauca/es-material.json +104 -0
- package/src/assets/i18n/cauca/fr-material.json +106 -0
- package/src/assets/images/loading.gif +0 -0
- package/src/lib/cauca-material.component.html +1 -0
- package/src/lib/cauca-material.component.spec.ts +29 -0
- package/src/lib/cauca-material.component.ts +12 -0
- package/src/lib/cauca-material.service.spec.ts +16 -0
- package/src/lib/cauca-material.service.ts +7 -0
- package/src/lib/components/button/button.component.html +52 -0
- package/src/lib/components/button/button.component.scss +6 -0
- package/src/lib/components/button/button.component.spec.ts +142 -0
- package/src/lib/components/button/button.component.ts +22 -0
- package/src/lib/components/buttons/base-button.ts +35 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.html +5 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.scss +12 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.spec.ts +106 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.ts +17 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.html +3 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.scss +12 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.spec.ts +82 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.ts +16 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.html +5 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.scss +12 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.spec.ts +106 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.ts +17 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.html +3 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.scss +23 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.spec.ts +38 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.ts +15 -0
- package/src/lib/components/buttons/link-button/link-button.component.html +1 -0
- package/src/lib/components/buttons/link-button/link-button.component.scss +3 -0
- package/src/lib/components/buttons/link-button/link-button.component.spec.ts +97 -0
- package/src/lib/components/buttons/link-button/link-button.component.ts +25 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.html +5 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.scss +6 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.spec.ts +66 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.ts +19 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.html +5 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.scss +12 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.spec.ts +108 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.ts +17 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.html +1 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.scss +0 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.spec.ts +81 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.ts +19 -0
- package/src/lib/components/buttons/round-button/round-button.component.html +3 -0
- package/src/lib/components/buttons/round-button/round-button.component.scss +34 -0
- package/src/lib/components/buttons/round-button/round-button.component.spec.ts +26 -0
- package/src/lib/components/buttons/round-button/round-button.component.ts +14 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.html +5 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.scss +23 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.spec.ts +114 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.ts +17 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.html +9 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.scss +7 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.spec.ts +68 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.ts +155 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.html +6 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.scss +25 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.spec.ts +23 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.ts +23 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.html +77 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.scss +124 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.spec.ts +96 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.ts +228 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.html +9 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.scss +15 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.spec.ts +105 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.ts +48 -0
- package/src/lib/components/cauca-date-time-picker/models/dialog-date-time-picker-data.ts +29 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.html +14 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.scss +3 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.ts +87 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.html +12 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.scss +3 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.spec.ts +35 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.ts +57 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.html +49 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.ts +56 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.html +11 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.scss +4 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.spec.ts +39 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.ts +20 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.html +7 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.scss +41 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.spec.ts +24 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.ts +67 -0
- package/src/lib/components/deprecated-components/shared/models/menu-item.ts +11 -0
- package/src/lib/components/deprecated-components/shared/models/simple-dialog-data.ts +5 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.html +10 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.scss +14 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.spec.ts +90 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.ts +41 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.html +11 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.scss +29 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.spec.ts +137 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.ts +47 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.html +17 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.scss +14 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.spec.ts +96 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.ts +40 -0
- package/src/lib/components/dialogs/delete-dialog/models/delete-dialog-data.spec.ts +7 -0
- package/src/lib/components/dialogs/delete-dialog/models/delete-dialog-data.ts +5 -0
- package/src/lib/components/dialogs/dialog-styles.css +9 -0
- package/src/lib/components/dialogs/dialog-styles.scss +9 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.html +10 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.scss +10 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.spec.ts +91 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.ts +32 -0
- package/src/lib/components/dialogs/services/dialog.service.spec.ts +82 -0
- package/src/lib/components/dialogs/services/dialog.service.ts +107 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.html +24 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.scss +22 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.spec.ts +126 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.ts +66 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.html +9 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.scss +0 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.spec.ts +29 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.ts +111 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.html +13 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.scss +0 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.spec.ts +80 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.ts +46 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.html +40 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.scss +39 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.spec.ts +135 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.ts +263 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.html +6 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.scss +27 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.spec.ts +90 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.ts +17 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.html +5 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.scss +8 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.spec.ts +98 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.ts +16 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.html +11 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.scss +12 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.spec.ts +141 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.ts +67 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.html +15 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.scss +32 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.spec.ts +138 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.ts +101 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.html +19 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.scss +0 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.spec.ts +215 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.ts +108 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.html +14 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.scss +48 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.spec.ts +48 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.ts +19 -0
- package/src/lib/components/layout/group-container/group-container.component.html +6 -0
- package/src/lib/components/layout/group-container/group-container.component.scss +22 -0
- package/src/lib/components/layout/group-container/group-container.component.spec.ts +34 -0
- package/src/lib/components/layout/group-container/group-container.component.ts +14 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.html +13 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.scss +27 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.spec.ts +144 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.ts +52 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.html +4 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.scss +10 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.spec.ts +80 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.ts +28 -0
- package/src/lib/components/layout/page-title/page-title.component.html +35 -0
- package/src/lib/components/layout/page-title/page-title.component.scss +40 -0
- package/src/lib/components/layout/page-title/page-title.component.spec.ts +162 -0
- package/src/lib/components/layout/page-title/page-title.component.ts +28 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.html +6 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.scss +27 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.spec.ts +42 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.ts +13 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.html +3 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.scss +18 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.spec.ts +35 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.ts +12 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.html +21 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.scss +44 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.spec.ts +74 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.ts +22 -0
- package/src/lib/components/list-paginator/list-paginator.component.html +16 -0
- package/src/lib/components/list-paginator/list-paginator.component.scss +46 -0
- package/src/lib/components/list-paginator/list-paginator.component.spec.ts +248 -0
- package/src/lib/components/list-paginator/list-paginator.component.ts +81 -0
- package/src/lib/components/misc/loading-error/loading-error.component.html +11 -0
- package/src/lib/components/misc/loading-error/loading-error.component.scss +0 -0
- package/src/lib/components/misc/loading-error/loading-error.component.spec.ts +75 -0
- package/src/lib/components/misc/loading-error/loading-error.component.ts +18 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.html +3 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.scss +0 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.spec.ts +43 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.ts +16 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.html +16 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.scss +84 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.spec.ts +136 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.ts +39 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.html +11 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.scss +0 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.spec.ts +67 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.ts +15 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.html +11 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.scss +0 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.spec.ts +77 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.ts +17 -0
- package/src/lib/components/presenters/badge/badge.component.html +6 -0
- package/src/lib/components/presenters/badge/badge.component.scss +10 -0
- package/src/lib/components/presenters/badge/badge.component.spec.ts +41 -0
- package/src/lib/components/presenters/badge/badge.component.ts +18 -0
- package/src/lib/components/presenters/icon/icon.component.scss +9 -0
- package/src/lib/components/presenters/icon/icon.component.spec.ts +38 -0
- package/src/lib/components/presenters/icon/icon.component.ts +37 -0
- package/src/lib/core/breadcrumb.service.spec.ts +35 -0
- package/src/lib/core/breadcrumb.service.ts +24 -0
- package/src/lib/core/directives/auto-trim-and-lower.directive.spec.ts +22 -0
- package/src/lib/core/directives/auto-trim-and-lower.directive.ts +19 -0
- package/src/lib/core/directives/form-error/form-error.module.ts +21 -0
- package/src/lib/core/directives/form-error/has-error-root.directive.ts +31 -0
- package/src/lib/core/directives/form-error/has-error.directive.ts +95 -0
- package/src/lib/core/loading-state.service.spec.ts +57 -0
- package/src/lib/core/loading-state.service.ts +44 -0
- package/src/lib/core/models/breadcrumb-location.ts +6 -0
- package/src/lib/core/models/password-validation.ts +20 -0
- package/src/lib/core/validators/password/password-validator.spec.ts +155 -0
- package/src/lib/core/validators/password/password-validator.ts +30 -0
- package/src/lib/provide-cauca-material.ts +10 -0
- package/src/public-api.ts +70 -0
- package/src/test.ts +17 -0
- package/tsconfig.lib.json +18 -0
- package/tsconfig.lib.prod.json +4 -0
- package/tsconfig.spec.json +17 -0
- package/fesm2022/cauca-911-material.mjs +0 -4321
- package/fesm2022/cauca-911-material.mjs.map +0 -1
- package/types/cauca-911-material.d.ts +0 -755
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { LoadingErrorComponent } from './loading-error.component';
|
|
4
|
+
import { signal } from '@angular/core';
|
|
5
|
+
import { MockComponent, ngMocks } from 'ng-mocks';
|
|
6
|
+
import { SnackBarComponent } from '../snack-bar/snack-bar.component';
|
|
7
|
+
import { By } from '@angular/platform-browser';
|
|
8
|
+
import { LoadingStateService } from '../../../core/loading-state.service';
|
|
9
|
+
|
|
10
|
+
describe('LoadingErrorComponent', () => {
|
|
11
|
+
let component: LoadingErrorComponent;
|
|
12
|
+
let fixture: ComponentFixture<LoadingErrorComponent>;
|
|
13
|
+
let loadingService: any;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
loadingService = { showError: signal(false) };
|
|
17
|
+
await TestBed.configureTestingModule({
|
|
18
|
+
declarations: [
|
|
19
|
+
MockComponent(SnackBarComponent),
|
|
20
|
+
],
|
|
21
|
+
imports: [
|
|
22
|
+
LoadingErrorComponent
|
|
23
|
+
],
|
|
24
|
+
providers: [
|
|
25
|
+
{ provide: LoadingStateService, useValue: loadingService },
|
|
26
|
+
]
|
|
27
|
+
})
|
|
28
|
+
.compileComponents();
|
|
29
|
+
|
|
30
|
+
fixture = TestBed.createComponent(LoadingErrorComponent);
|
|
31
|
+
component = fixture.componentInstance;
|
|
32
|
+
fixture.detectChanges();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should create', () => {
|
|
36
|
+
expect(component).toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should not show the error if there is not any', () => {
|
|
40
|
+
loadingService.showError.set(false);
|
|
41
|
+
fixture.detectChanges();
|
|
42
|
+
|
|
43
|
+
expect(fixture.debugElement.query(By.css('cauca-snackbar'))).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should show the error when it is one', () => {
|
|
47
|
+
loadingService.showError.set(true);
|
|
48
|
+
fixture.detectChanges();
|
|
49
|
+
|
|
50
|
+
expect(fixture.debugElement.query(By.css('cauca-snackbar'))).not.toBeNull();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should have the snackbar correctly configured', () => {
|
|
54
|
+
loadingService.showError.set(true);
|
|
55
|
+
fixture.detectChanges();
|
|
56
|
+
|
|
57
|
+
const snack = ngMocks.find<SnackBarComponent>('cauca-snackbar').componentInstance;
|
|
58
|
+
expect(snack.caption).toBe('generalError.loadingErrorAlertTitle');
|
|
59
|
+
expect(snack.type).toBe('error');
|
|
60
|
+
expect(snack.variant).toBe('standard');
|
|
61
|
+
expect(snack.showButton).toBeTrue();
|
|
62
|
+
expect(snack.buttonLabel).toBe('generalError.retryButtonLabel');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should emit a retry request event when clicking on the snackbar button', () => {
|
|
66
|
+
loadingService.showError.set(true);
|
|
67
|
+
fixture.detectChanges();
|
|
68
|
+
const snack = ngMocks.find<SnackBarComponent>('cauca-snackbar').componentInstance;
|
|
69
|
+
const spy = spyOn(component.retryRequest, 'emit');
|
|
70
|
+
|
|
71
|
+
snack.buttonClick.emit();
|
|
72
|
+
|
|
73
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component, EventEmitter, inject, Output } from '@angular/core';
|
|
2
|
+
import { SnackBarComponent } from '../snack-bar/snack-bar.component';
|
|
3
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
4
|
+
import { LoadingStateService } from '../../../core/loading-state.service';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'cauca-loading-error',
|
|
8
|
+
standalone: true,
|
|
9
|
+
imports: [SnackBarComponent, TranslateModule],
|
|
10
|
+
templateUrl: './loading-error.component.html',
|
|
11
|
+
styleUrl: './loading-error.component.scss'
|
|
12
|
+
})
|
|
13
|
+
export class LoadingErrorComponent {
|
|
14
|
+
@Output() public retryRequest: EventEmitter<void> = new EventEmitter<void>();
|
|
15
|
+
|
|
16
|
+
public readonly loadingState = inject(LoadingStateService);
|
|
17
|
+
public showError = this.loadingState.showError;
|
|
18
|
+
}
|
package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.scss
ADDED
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { LoadingSpinnerIndicatorComponent } from './loading-spinner-indicator.component';
|
|
4
|
+
import { signal } from '@angular/core';
|
|
5
|
+
import { MatProgressSpinner } from '@angular/material/progress-spinner';
|
|
6
|
+
import { ngMocks } from 'ng-mocks';
|
|
7
|
+
import { LoadingStateService } from '../../../core/loading-state.service';
|
|
8
|
+
|
|
9
|
+
describe('LoadingSpinnerIndicatorComponent', () => {
|
|
10
|
+
let component: LoadingSpinnerIndicatorComponent;
|
|
11
|
+
let fixture: ComponentFixture<LoadingSpinnerIndicatorComponent>;
|
|
12
|
+
let loadingStateService: any;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
loadingStateService = {
|
|
16
|
+
showLoadingIndicator: signal(true)
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
await TestBed.configureTestingModule({
|
|
20
|
+
imports: [LoadingSpinnerIndicatorComponent],
|
|
21
|
+
providers: [
|
|
22
|
+
{ provide: LoadingStateService, useValue: loadingStateService },
|
|
23
|
+
]
|
|
24
|
+
})
|
|
25
|
+
.compileComponents();
|
|
26
|
+
|
|
27
|
+
fixture = TestBed.createComponent(LoadingSpinnerIndicatorComponent);
|
|
28
|
+
component = fixture.componentInstance;
|
|
29
|
+
fixture.detectChanges();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should create', () => {
|
|
33
|
+
expect(component).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should set correct diameter to mat-progress-input', () => {
|
|
37
|
+
fixture.componentRef.setInput('diameter', 50);
|
|
38
|
+
|
|
39
|
+
fixture.detectChanges();
|
|
40
|
+
|
|
41
|
+
expect(ngMocks.find(MatProgressSpinner).componentInstance.diameter).toBe(50);
|
|
42
|
+
});
|
|
43
|
+
});
|
package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject, input, InputSignal } from '@angular/core';
|
|
2
|
+
import { MatProgressSpinner } from '@angular/material/progress-spinner';
|
|
3
|
+
import { LoadingStateService } from '../../../core/loading-state.service';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'cauca-loading-spinner-indicator',
|
|
7
|
+
standalone: true,
|
|
8
|
+
imports: [MatProgressSpinner],
|
|
9
|
+
templateUrl: './loading-spinner-indicator.component.html',
|
|
10
|
+
styleUrl: './loading-spinner-indicator.component.scss',
|
|
11
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
12
|
+
})
|
|
13
|
+
export class LoadingSpinnerIndicatorComponent {
|
|
14
|
+
public diameter: InputSignal<number> = input(100);
|
|
15
|
+
public loadingState = inject(LoadingStateService);
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div class="container" [class]="appearanceClasses()">
|
|
2
|
+
|
|
3
|
+
<div class="icon-container">
|
|
4
|
+
<mat-icon>{{icon()}}</mat-icon>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="text-container">
|
|
8
|
+
<div class="title alert-title">{{caption()|translate}}</div>
|
|
9
|
+
<div class="message body2"><ng-content></ng-content></div>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
@if (showButton()) {<cauca-stroked-button [color]="buttonColor()" [label]="buttonLabel()" (click)="buttonClick.emit()" onkeypress="buttonClick.emit()" [isInProgress]="inProgress()" [icon]="buttonIcon()" />}
|
|
13
|
+
|
|
14
|
+
@if (showCloseButton()) {<cauca-icon-button icon="close" (click)="closeClick.emit()" onkeypress="closeClick.emit()" />}
|
|
15
|
+
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.info {
|
|
2
|
+
--darkBackgroundColor: #0288D1;
|
|
3
|
+
--lightBackgroundColor: #E5F6FD;
|
|
4
|
+
--lightColor: white;
|
|
5
|
+
--darkColor: #014361;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.warning {
|
|
9
|
+
--darkBackgroundColor: #ED6C02;
|
|
10
|
+
--lightBackgroundColor: #FFF4E5;
|
|
11
|
+
--lightColor: white;
|
|
12
|
+
--darkColor: #663C00;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.success {
|
|
16
|
+
--darkBackgroundColor: #2E7D32;
|
|
17
|
+
--lightBackgroundColor: #EDF7ED;
|
|
18
|
+
--lightColor: white;
|
|
19
|
+
--darkColor: #1E4620;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.error {
|
|
23
|
+
--darkBackgroundColor: #D32F2F;
|
|
24
|
+
--lightBackgroundColor: #FDEDED;
|
|
25
|
+
--lightColor: white;
|
|
26
|
+
--darkColor: #5F2120;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.filled {
|
|
30
|
+
--textColor: var(--lightColor);
|
|
31
|
+
--iconColor: var(--lightColor);
|
|
32
|
+
background-color: var(--darkBackgroundColor);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.standard,.outlined {
|
|
36
|
+
--textColor: var(--darkColor);
|
|
37
|
+
--iconColor: var(--darkBackgroundColor);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.container {
|
|
41
|
+
display: flex;
|
|
42
|
+
padding: 6px 16px;
|
|
43
|
+
align-items: flex-start;
|
|
44
|
+
border-radius: 4px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.text-container {
|
|
48
|
+
display: flex;
|
|
49
|
+
padding: 8px 0px;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
align-items: flex-start;
|
|
52
|
+
gap: 4px;
|
|
53
|
+
flex: 1 0 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.icon-container {
|
|
57
|
+
display: flex;
|
|
58
|
+
padding: 7px 12px 7px 0px;
|
|
59
|
+
align-items: flex-start;
|
|
60
|
+
mat-icon {
|
|
61
|
+
color: var(--iconColor);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.message {
|
|
66
|
+
color: var(--textColor);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.title {
|
|
70
|
+
color: var(--textColor);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.standard {
|
|
74
|
+
background-color: var(--lightBackgroundColor);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.outlined {
|
|
78
|
+
background-color: transparent;
|
|
79
|
+
border: 1px solid var(--darkBackgroundColor);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.standard .outlined {
|
|
83
|
+
color: var(--darkColor);
|
|
84
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SnackBarComponent } from './snack-bar.component';
|
|
4
|
+
import { MockComponents, MockPipe, ngMocks } from 'ng-mocks';
|
|
5
|
+
import { By } from '@angular/platform-browser';
|
|
6
|
+
import { StrokedButtonComponent } from '../../buttons/stroked-button/stroked-button.component';
|
|
7
|
+
import { IconButtonComponent } from '../../buttons/icon-button/icon-button.component';
|
|
8
|
+
import { TranslatePipe } from '@ngx-translate/core';
|
|
9
|
+
|
|
10
|
+
describe('SnackBarComponent', () => {
|
|
11
|
+
let component: SnackBarComponent;
|
|
12
|
+
let fixture: ComponentFixture<SnackBarComponent>;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
await TestBed.configureTestingModule({
|
|
16
|
+
imports: [SnackBarComponent],
|
|
17
|
+
declarations: [
|
|
18
|
+
...MockComponents(
|
|
19
|
+
StrokedButtonComponent, IconButtonComponent
|
|
20
|
+
),
|
|
21
|
+
MockPipe(TranslatePipe, key => key),
|
|
22
|
+
]
|
|
23
|
+
})
|
|
24
|
+
.compileComponents();
|
|
25
|
+
|
|
26
|
+
fixture = TestBed.createComponent(SnackBarComponent);
|
|
27
|
+
component = fixture.componentInstance;
|
|
28
|
+
fixture.detectChanges();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should create', () => {
|
|
32
|
+
expect(component).toBeTruthy();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should generate appearance classes from type and variant', () => {
|
|
36
|
+
fixture.componentRef.setInput('variant', 'filled');
|
|
37
|
+
fixture.componentRef.setInput('type', 'error');
|
|
38
|
+
|
|
39
|
+
fixture.detectChanges();
|
|
40
|
+
const container = fixture.debugElement.query(By.css('.container'));
|
|
41
|
+
expect(container.nativeElement.classList.contains('error')).toBe(true);
|
|
42
|
+
expect(container.nativeElement.classList.contains('filled')).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should have white button when variant is filled', () => {
|
|
46
|
+
fixture.componentRef.setInput('variant', 'filled');
|
|
47
|
+
fixture.componentRef.setInput('type', 'error');
|
|
48
|
+
fixture.componentRef.setInput('showButton', true);
|
|
49
|
+
|
|
50
|
+
fixture.detectChanges();
|
|
51
|
+
|
|
52
|
+
expect(component.buttonColor()).toBe('white');
|
|
53
|
+
expect(ngMocks.find<StrokedButtonComponent>('cauca-stroked-button').componentInstance.color).toBe('white');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should have white button when variant is not filled', () => {
|
|
57
|
+
fixture.componentRef.setInput('variant', 'standard');
|
|
58
|
+
fixture.componentRef.setInput('type', 'error');
|
|
59
|
+
fixture.componentRef.setInput('showButton', true);
|
|
60
|
+
|
|
61
|
+
fixture.detectChanges();
|
|
62
|
+
|
|
63
|
+
expect(component.buttonColor()).toBeUndefined();
|
|
64
|
+
expect(ngMocks.find<StrokedButtonComponent>('cauca-stroked-button').componentInstance.color).toBeUndefined();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should display specified icon', async() => {
|
|
68
|
+
fixture.componentRef.setInput('icon', 'test');
|
|
69
|
+
|
|
70
|
+
fixture.detectChanges();
|
|
71
|
+
|
|
72
|
+
expect(fixture.nativeElement.querySelector('mat-icon').textContent).toBe('test');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should correctly display the title', () => {
|
|
76
|
+
fixture.componentRef.setInput('caption', 'test');
|
|
77
|
+
|
|
78
|
+
fixture.detectChanges();
|
|
79
|
+
|
|
80
|
+
expect(fixture.nativeElement.querySelector('.title.alert-title').textContent).toBe('test');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should not display the button if showButton is false', () => {
|
|
84
|
+
fixture.componentRef.setInput('showButton', false);
|
|
85
|
+
|
|
86
|
+
fixture.detectChanges();
|
|
87
|
+
|
|
88
|
+
expect(fixture.debugElement.query(By.css('cauca-stroked-button'))).toBeNull();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should display the button with the right label if showButton is true', () => {
|
|
92
|
+
fixture.componentRef.setInput('showButton', true);
|
|
93
|
+
fixture.componentRef.setInput('buttonLabel', 'test');
|
|
94
|
+
|
|
95
|
+
fixture.detectChanges();
|
|
96
|
+
|
|
97
|
+
const button = ngMocks.find<StrokedButtonComponent>('cauca-stroked-button').componentInstance;
|
|
98
|
+
expect(button.label).toBe('test');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should set button color to buttonSpecificColor if it is defined', () => {
|
|
102
|
+
fixture.componentRef.setInput('showButton', true);
|
|
103
|
+
fixture.componentRef.setInput('buttonSpecificColor', 'test');
|
|
104
|
+
|
|
105
|
+
fixture.detectChanges();
|
|
106
|
+
|
|
107
|
+
expect(component.buttonColor()).toBe('test');
|
|
108
|
+
expect(ngMocks.find<StrokedButtonComponent>('cauca-stroked-button').componentInstance.color).toBe('test');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should set button as in progress if inProgress is true', () => {
|
|
112
|
+
fixture.componentRef.setInput('showButton', true);
|
|
113
|
+
fixture.componentRef.setInput('inProgress', true);
|
|
114
|
+
|
|
115
|
+
fixture.detectChanges();
|
|
116
|
+
|
|
117
|
+
expect(ngMocks.find<StrokedButtonComponent>('cauca-stroked-button').componentInstance.isInProgress).toBeTrue();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should not display the close button if showCloseButton is false', () => {
|
|
121
|
+
fixture.componentRef.setInput('showCloseButton', false);
|
|
122
|
+
|
|
123
|
+
fixture.detectChanges();
|
|
124
|
+
|
|
125
|
+
expect(fixture.debugElement.query(By.css('cauca-icon-button'))).toBeNull();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should display the close button if showCloseButton is true', () => {
|
|
129
|
+
fixture.componentRef.setInput('showCloseButton', true);
|
|
130
|
+
|
|
131
|
+
fixture.detectChanges();
|
|
132
|
+
|
|
133
|
+
const button = ngMocks.find<IconButtonComponent>('cauca-icon-button').componentInstance;
|
|
134
|
+
expect(button).toBeDefined();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, EventEmitter, InputSignal, Output, Signal, computed, input } from '@angular/core';
|
|
2
|
+
import { MatIcon } from '@angular/material/icon';
|
|
3
|
+
import { StrokedButtonComponent } from '../../buttons/stroked-button/stroked-button.component';
|
|
4
|
+
import { IconButtonComponent } from '../../buttons/icon-button/icon-button.component';
|
|
5
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
6
|
+
|
|
7
|
+
@Component({
|
|
8
|
+
selector: 'cauca-snackbar',
|
|
9
|
+
imports: [MatIcon, StrokedButtonComponent, IconButtonComponent, TranslateModule],
|
|
10
|
+
templateUrl: './snack-bar.component.html',
|
|
11
|
+
styleUrl: './snack-bar.component.scss',
|
|
12
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
13
|
+
})
|
|
14
|
+
export class SnackBarComponent {
|
|
15
|
+
|
|
16
|
+
public icon: InputSignal<string> = input('info_outlined');
|
|
17
|
+
public caption: InputSignal<string> = input('');
|
|
18
|
+
public showCloseButton: InputSignal<boolean> = input(false);
|
|
19
|
+
public type: InputSignal<'info'|'success'|'warning'|'error'> = input('info');
|
|
20
|
+
public variant: InputSignal<'filled'|'outlined'|'standard'> = input('standard');
|
|
21
|
+
public appearanceClasses = computed(() => [this.type(), this.variant()]);
|
|
22
|
+
|
|
23
|
+
public buttonSpecificColor = input<string>(undefined);
|
|
24
|
+
public buttonIcon = input<string>(undefined);
|
|
25
|
+
public inProgress = input<boolean>(false);
|
|
26
|
+
public showButton: InputSignal<boolean> = input(false);
|
|
27
|
+
public buttonLabel: InputSignal<string> = input('');
|
|
28
|
+
|
|
29
|
+
public buttonColor: Signal<string> = computed(() => {
|
|
30
|
+
if (this.buttonSpecificColor()) {
|
|
31
|
+
return this.buttonSpecificColor();
|
|
32
|
+
} else {
|
|
33
|
+
return this.variant() === 'filled' ? 'white' : undefined;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
@Output() public closeClick: EventEmitter<void> = new EventEmitter<void>();
|
|
38
|
+
@Output() public buttonClick: EventEmitter<void> = new EventEmitter<void>();
|
|
39
|
+
}
|
package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.html
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@if (show()) {
|
|
2
|
+
<cauca-snackbar
|
|
3
|
+
caption="savingSuccessNotification.title"
|
|
4
|
+
type="success"
|
|
5
|
+
variant="standard"
|
|
6
|
+
[showButton]="false"
|
|
7
|
+
[showCloseButton]="true"
|
|
8
|
+
(closeClick)="show.set(false)">
|
|
9
|
+
{{'savingSuccessNotification.message' | translate}}
|
|
10
|
+
</cauca-snackbar>
|
|
11
|
+
}
|
package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.scss
ADDED
|
File without changes
|
package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.spec.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SavingConfirmedBoxComponent } from './saving-confirmed-box.component';
|
|
4
|
+
import { SnackBarComponent } from '../../misc/snack-bar/snack-bar.component';
|
|
5
|
+
import { MockComponent, ngMocks } from 'ng-mocks';
|
|
6
|
+
import { By } from '@angular/platform-browser';
|
|
7
|
+
|
|
8
|
+
describe('SavingConfirmedBoxComponent', () => {
|
|
9
|
+
let component: SavingConfirmedBoxComponent;
|
|
10
|
+
let fixture: ComponentFixture<SavingConfirmedBoxComponent>;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
await TestBed.configureTestingModule({
|
|
14
|
+
imports: [SavingConfirmedBoxComponent],
|
|
15
|
+
declarations: [MockComponent(SnackBarComponent)],
|
|
16
|
+
})
|
|
17
|
+
.compileComponents();
|
|
18
|
+
|
|
19
|
+
fixture = TestBed.createComponent(SavingConfirmedBoxComponent);
|
|
20
|
+
component = fixture.componentInstance;
|
|
21
|
+
fixture.detectChanges();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should create', () => {
|
|
25
|
+
expect(component).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should not show snackbar when show is false', () => {
|
|
29
|
+
component.show.set(false);
|
|
30
|
+
|
|
31
|
+
fixture.detectChanges();
|
|
32
|
+
|
|
33
|
+
expect(fixture.debugElement.query(By.css('cauca-snackbar'))).toBeNull();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should show snackbar when show is true', () => {
|
|
37
|
+
component.show.set(true);
|
|
38
|
+
|
|
39
|
+
fixture.detectChanges();
|
|
40
|
+
|
|
41
|
+
expect(fixture.debugElement.query(By.css('cauca-snackbar'))).toBeTruthy();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should have a correctly configured snackbar', () => {
|
|
45
|
+
component.show.set(true);
|
|
46
|
+
|
|
47
|
+
fixture.detectChanges();
|
|
48
|
+
|
|
49
|
+
const snackbar = ngMocks.find(SnackBarComponent).componentInstance;
|
|
50
|
+
expect(snackbar.caption).toBe('savingSuccessNotification.title');
|
|
51
|
+
expect(snackbar.type).toBe('success');
|
|
52
|
+
expect(snackbar.variant).toBe('standard');
|
|
53
|
+
expect(snackbar.showButton).toBeFalse();
|
|
54
|
+
expect(snackbar.showCloseButton).toBeTrue();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should hide the snackbar when clicking the close button', () => {
|
|
58
|
+
component.show.set(true);
|
|
59
|
+
fixture.detectChanges();
|
|
60
|
+
const snackbar = ngMocks.find(SnackBarComponent);
|
|
61
|
+
snackbar.componentInstance.closeClick.emit();
|
|
62
|
+
|
|
63
|
+
fixture.detectChanges();
|
|
64
|
+
|
|
65
|
+
expect(component.show()).toBeFalse();
|
|
66
|
+
});
|
|
67
|
+
});
|
package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, model } from '@angular/core';
|
|
2
|
+
import { SnackBarComponent } from '../../misc/snack-bar/snack-bar.component';
|
|
3
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'cauca-saving-confirmed-box',
|
|
7
|
+
standalone: true,
|
|
8
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
|
+
imports: [SnackBarComponent, TranslateModule],
|
|
10
|
+
templateUrl: './saving-confirmed-box.component.html',
|
|
11
|
+
styleUrl: './saving-confirmed-box.component.scss'
|
|
12
|
+
})
|
|
13
|
+
export class SavingConfirmedBoxComponent {
|
|
14
|
+
public show = model<boolean>(false);
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SavingErrorBoxComponent } from './saving-error-box.component';
|
|
4
|
+
import { MockComponent, ngMocks } from 'ng-mocks';
|
|
5
|
+
import { SnackBarComponent } from '../../misc/snack-bar/snack-bar.component';
|
|
6
|
+
import { By } from '@angular/platform-browser';
|
|
7
|
+
|
|
8
|
+
describe('SavingErrorBoxComponent', () => {
|
|
9
|
+
let component: SavingErrorBoxComponent;
|
|
10
|
+
let fixture: ComponentFixture<SavingErrorBoxComponent>;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
await TestBed.configureTestingModule({
|
|
14
|
+
imports: [SavingErrorBoxComponent],
|
|
15
|
+
declarations: [MockComponent(SnackBarComponent)],
|
|
16
|
+
})
|
|
17
|
+
.compileComponents();
|
|
18
|
+
|
|
19
|
+
fixture = TestBed.createComponent(SavingErrorBoxComponent);
|
|
20
|
+
component = fixture.componentInstance;
|
|
21
|
+
fixture.detectChanges();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should create', () => {
|
|
25
|
+
expect(component).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should have a default error message', () => {
|
|
29
|
+
expect(component.error()).toBe('generalError.savingErrorAlertMessage');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should use specific error message if provided', () => {
|
|
33
|
+
fixture.componentRef.setInput('specificError', 'specific error');
|
|
34
|
+
|
|
35
|
+
expect(component.error()).toBe('specific error');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should not show snackbar when show is false', () => {
|
|
39
|
+
component.show.set(false);
|
|
40
|
+
|
|
41
|
+
fixture.detectChanges();
|
|
42
|
+
|
|
43
|
+
expect(fixture.debugElement.query(By.css('cauca-snackbar'))).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should show snackbar when show is true', () => {
|
|
47
|
+
component.show.set(true);
|
|
48
|
+
|
|
49
|
+
fixture.detectChanges();
|
|
50
|
+
|
|
51
|
+
expect(fixture.debugElement.query(By.css('cauca-snackbar'))).toBeTruthy();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should have a correctly configured snackbar', () => {
|
|
55
|
+
component.show.set(true);
|
|
56
|
+
|
|
57
|
+
fixture.detectChanges();
|
|
58
|
+
|
|
59
|
+
const snackbar = ngMocks.find(SnackBarComponent).componentInstance;
|
|
60
|
+
expect(snackbar.caption).toBe('generalError.savingErrorAlertTitle');
|
|
61
|
+
expect(snackbar.type).toBe('error');
|
|
62
|
+
expect(snackbar.variant).toBe('standard');
|
|
63
|
+
expect(snackbar.showButton).toBeFalse();
|
|
64
|
+
expect(snackbar.showCloseButton).toBeTrue();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should hide the snackbar when clicking the close button', () => {
|
|
68
|
+
component.show.set(true);
|
|
69
|
+
fixture.detectChanges();
|
|
70
|
+
const snackbar = ngMocks.find(SnackBarComponent);
|
|
71
|
+
snackbar.componentInstance.closeClick.emit();
|
|
72
|
+
|
|
73
|
+
fixture.detectChanges();
|
|
74
|
+
|
|
75
|
+
expect(component.show()).toBeFalse();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, input, model } from '@angular/core';
|
|
2
|
+
import { SnackBarComponent } from '../../misc/snack-bar/snack-bar.component';
|
|
3
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'cauca-saving-error-box',
|
|
7
|
+
standalone: true,
|
|
8
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
|
+
imports: [SnackBarComponent, TranslateModule],
|
|
10
|
+
templateUrl: './saving-error-box.component.html',
|
|
11
|
+
styleUrl: './saving-error-box.component.scss'
|
|
12
|
+
})
|
|
13
|
+
export class SavingErrorBoxComponent {
|
|
14
|
+
public show = model<boolean>(false);
|
|
15
|
+
public specificError = input<string | null>(null);
|
|
16
|
+
public error = computed(() => this.specificError() ? this.specificError() : 'generalError.savingErrorAlertMessage');
|
|
17
|
+
}
|