@cauca-911/material 20.2.12 → 20.2.13
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 +77 -0
- package/README.md +24 -5
- package/README_PACKAGE.md +5 -0
- package/karma.conf.js +50 -0
- package/ng-package.json +7 -0
- package/package.json +23 -38
- package/{assets → src/assets}/i18n/cauca/en-material.json +104 -104
- package/{assets → src/assets}/i18n/cauca/es-material.json +104 -104
- package/{assets → src/assets}/i18n/cauca/fr-material.json +106 -106
- 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 +134 -0
- package/src/lib/components/button/button.component.ts +21 -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 +53 -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 +93 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.ts +227 -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 +103 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.ts +47 -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 +11 -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 +8 -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-sidebar/cauca-menu-sidebar.component.html +19 -0
- package/src/lib/components/deprecated-components/cauca-menu-sidebar/cauca-menu-sidebar.component.scss +142 -0
- package/src/lib/components/deprecated-components/cauca-menu-sidebar/cauca-menu-sidebar.component.spec.ts +30 -0
- package/src/lib/components/deprecated-components/cauca-menu-sidebar/cauca-menu-sidebar.component.ts +112 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.html +26 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.scss +52 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.spec.ts +28 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.ts +53 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.html +7 -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 +100 -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 +213 -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 +12 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.scss +43 -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 +28 -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 +29 -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 +74 -0
- package/src/test.ts +17 -0
- package/tsconfig.lib.json +22 -0
- package/tsconfig.lib.prod.json +4 -0
- package/tsconfig.spec.json +17 -0
- package/LICENSE +0 -21
- package/fesm2022/cauca-911-material.mjs +0 -4640
- package/fesm2022/cauca-911-material.mjs.map +0 -1
- package/index.d.ts +0 -795
- /package/{assets → src/assets}/images/loading.gif +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<div mat-dialog-title>
|
|
2
|
+
<div class="h6">{{('errorDialog.titleError' | translate)}}</div>
|
|
3
|
+
<cauca-icon-button id="closeButton" (buttonClick)="closeClick()" icon="close"/>
|
|
4
|
+
</div>
|
|
5
|
+
<div mat-dialog-content>
|
|
6
|
+
<p>{{('errorDialog.messageError' | translate:{itemName})}}</p>
|
|
7
|
+
</div>
|
|
8
|
+
<mat-dialog-actions align="end">
|
|
9
|
+
<cauca-raised-button id="okButton" label="ok" color="warn" (buttonClick)="closeClick()"/>
|
|
10
|
+
</mat-dialog-actions>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ErrorDialogComponent } from './error-dialog.component';
|
|
4
|
+
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
5
|
+
import { TranslateModule, TranslatePipe } from '@ngx-translate/core';
|
|
6
|
+
import { MockComponents, MockModule, MockPipe, ngMocks } from 'ng-mocks';
|
|
7
|
+
import { BreakpointObserver, BreakpointState } from '@angular/cdk/layout';
|
|
8
|
+
import { of } from 'rxjs';
|
|
9
|
+
import { RaisedButtonComponent } from '../../buttons/raised-button/raised-button.component';
|
|
10
|
+
import { IconButtonComponent } from '../../buttons/icon-button/icon-button.component';
|
|
11
|
+
|
|
12
|
+
describe('ErrorDialogComponent', () => {
|
|
13
|
+
let component: ErrorDialogComponent;
|
|
14
|
+
let fixture: ComponentFixture<ErrorDialogComponent>;
|
|
15
|
+
let mockMatDialog: jasmine.SpyObj<MatDialogRef<any>>;
|
|
16
|
+
let breakpointObserverMock: jasmine.SpyObj<BreakpointObserver>;
|
|
17
|
+
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
breakpointObserverMock = jasmine.createSpyObj('BreakpointObserver', ['observe']);
|
|
20
|
+
breakpointObserverMock.observe.and.returnValue(of({ matches: true, breakpoints: {} }));
|
|
21
|
+
|
|
22
|
+
mockMatDialog = jasmine.createSpyObj('MatDialogRef', ['close', 'addPanelClass', 'updateSize']);
|
|
23
|
+
await TestBed.configureTestingModule({
|
|
24
|
+
declarations: [
|
|
25
|
+
...MockComponents(IconButtonComponent, RaisedButtonComponent),
|
|
26
|
+
MockPipe(TranslatePipe, value => value),
|
|
27
|
+
],
|
|
28
|
+
imports: [
|
|
29
|
+
ErrorDialogComponent,
|
|
30
|
+
MockModule(TranslateModule)
|
|
31
|
+
],
|
|
32
|
+
providers: [
|
|
33
|
+
{ provide: MatDialogRef, useValue: mockMatDialog },
|
|
34
|
+
{ provide: MAT_DIALOG_DATA, useValue: [] },
|
|
35
|
+
{ provide: BreakpointObserver, useValue: breakpointObserverMock },
|
|
36
|
+
]
|
|
37
|
+
})
|
|
38
|
+
.compileComponents();
|
|
39
|
+
|
|
40
|
+
fixture = TestBed.createComponent(ErrorDialogComponent);
|
|
41
|
+
component = fixture.componentInstance;
|
|
42
|
+
fixture.detectChanges();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should create', () => {
|
|
46
|
+
expect(component).toBeTruthy();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should initially add a global style class', () => {
|
|
50
|
+
expect(mockMatDialog.addPanelClass).toHaveBeenCalledWith('dialog-global-style');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should update dialog size when breakpoint matches', fakeAsync(() => {
|
|
54
|
+
mockMatDialog.updateSize.calls.reset();
|
|
55
|
+
const breakpointState: BreakpointState = { matches: true, breakpoints: {} };
|
|
56
|
+
breakpointObserverMock.observe.and.returnValue(of(breakpointState));
|
|
57
|
+
TestBed.createComponent(ErrorDialogComponent);
|
|
58
|
+
|
|
59
|
+
fixture.detectChanges();
|
|
60
|
+
|
|
61
|
+
expect(mockMatDialog.updateSize).toHaveBeenCalledWith('100vw');
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
it('should update dialog size when breakpoint does not match', fakeAsync(() => {
|
|
65
|
+
mockMatDialog.updateSize.calls.reset();
|
|
66
|
+
const breakpointState: BreakpointState = { matches: false, breakpoints: {} };
|
|
67
|
+
breakpointObserverMock.observe.and.returnValue(of(breakpointState));
|
|
68
|
+
TestBed.createComponent(ErrorDialogComponent);
|
|
69
|
+
|
|
70
|
+
fixture.detectChanges();
|
|
71
|
+
|
|
72
|
+
expect(mockMatDialog.updateSize).toHaveBeenCalledWith('auto');
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
it('should close dialog when pressing close', async () => {
|
|
76
|
+
const closeButton = ngMocks.find<IconButtonComponent>('#closeButton', null)?.componentInstance;
|
|
77
|
+
|
|
78
|
+
closeButton.buttonClick.emit();
|
|
79
|
+
|
|
80
|
+
expect(mockMatDialog.close).toHaveBeenCalled();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should close dialog when pressing ok', async () => {
|
|
84
|
+
const cancelButton = ngMocks.find<RaisedButtonComponent>('#okButton', null)?.componentInstance;
|
|
85
|
+
|
|
86
|
+
cancelButton.buttonClick.emit();
|
|
87
|
+
|
|
88
|
+
expect(mockMatDialog.close).toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Component, Inject } from '@angular/core';
|
|
2
|
+
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
|
3
|
+
import { DeleteDialogData } from '../delete-dialog/models/delete-dialog-data';
|
|
4
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
5
|
+
import { BreakpointObserver } from '@angular/cdk/layout';
|
|
6
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
+
import { RaisedButtonComponent } from '../../buttons/raised-button/raised-button.component';
|
|
8
|
+
import { IconButtonComponent } from '../../buttons/icon-button/icon-button.component';
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'cauca-error-dialog',
|
|
12
|
+
templateUrl: './error-dialog.component.html',
|
|
13
|
+
styleUrls: ['./error-dialog.component.scss'],
|
|
14
|
+
standalone: true,
|
|
15
|
+
imports: [MatDialogModule, TranslateModule, RaisedButtonComponent, IconButtonComponent]
|
|
16
|
+
})
|
|
17
|
+
export class ErrorDialogComponent {
|
|
18
|
+
public itemName: string = '';
|
|
19
|
+
|
|
20
|
+
public constructor(
|
|
21
|
+
public dialogRef: MatDialogRef<ErrorDialogComponent>,
|
|
22
|
+
@Inject(MAT_DIALOG_DATA) public data: DeleteDialogData,
|
|
23
|
+
breakdownObserver: BreakpointObserver) {
|
|
24
|
+
this.itemName = data.name ? data.name : '';
|
|
25
|
+
dialogRef.addPanelClass("dialog-global-style");
|
|
26
|
+
breakdownObserver.observe('(max-width: 500px)').pipe(takeUntilDestroyed()).subscribe(result => dialogRef.updateSize(result.matches ? '100vw' : 'auto'));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public closeClick(): void {
|
|
30
|
+
this.dialogRef.close();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ConfirmationResult, DialogService } from './dialog.service';
|
|
4
|
+
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
|
5
|
+
import { AlertDialogComponent } from '../alert-dialog/alert-dialog.component';
|
|
6
|
+
import { of } from 'rxjs';
|
|
7
|
+
import { TranslateService } from '@ngx-translate/core';
|
|
8
|
+
|
|
9
|
+
describe('DialogService', () => {
|
|
10
|
+
let service: DialogService;
|
|
11
|
+
let mockMatDialog: any;
|
|
12
|
+
let mockMatDialogRef: any;
|
|
13
|
+
let translateService: jasmine.SpyObj<any>;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
mockMatDialog = jasmine.createSpyObj('MatDialog', ['open']);
|
|
17
|
+
mockMatDialogRef = jasmine.createSpyObj('MatDialogRef', ['afterClosed']);
|
|
18
|
+
translateService = jasmine.createSpyObj('TranslateService', ['instant']);
|
|
19
|
+
translateService.instant.and.callFake((key: string) => key);
|
|
20
|
+
|
|
21
|
+
TestBed.configureTestingModule({
|
|
22
|
+
providers: [DialogService,
|
|
23
|
+
{ provide: MatDialog, useValue: mockMatDialog },
|
|
24
|
+
{ provide: TranslateService, useValue: translateService }
|
|
25
|
+
],
|
|
26
|
+
imports: [
|
|
27
|
+
MatDialogModule,
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
service = TestBed.inject(DialogService);
|
|
31
|
+
mockMatDialog.open.and.returnValue(mockMatDialogRef);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
mockMatDialog.open.calls.reset();
|
|
36
|
+
mockMatDialogRef.afterClosed.calls.reset();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should be created', () => {
|
|
40
|
+
expect(service).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should have config with data when showCustomDialog without options', async () => {
|
|
44
|
+
const myData = 'myData';
|
|
45
|
+
mockMatDialogRef.afterClosed.and.returnValue(of({}));
|
|
46
|
+
|
|
47
|
+
await service.showCustomDialog(AlertDialogComponent, myData );
|
|
48
|
+
|
|
49
|
+
expect(mockMatDialog.open).toHaveBeenCalledWith(
|
|
50
|
+
AlertDialogComponent,
|
|
51
|
+
jasmine.objectContaining({ data: myData })
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should have config with width and height when showCustomDialog ', async () => {
|
|
56
|
+
const myData = 'myData';
|
|
57
|
+
mockMatDialogRef.afterClosed.and.returnValue(of({}));
|
|
58
|
+
|
|
59
|
+
await service.showCustomDialog(AlertDialogComponent, myData, {width: 10, height:20} );
|
|
60
|
+
|
|
61
|
+
expect(mockMatDialog.open).toHaveBeenCalledWith(
|
|
62
|
+
AlertDialogComponent,
|
|
63
|
+
jasmine.objectContaining({ data: myData, width: 10 , height: 20})
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should should ask user for confirmation', async () => {
|
|
68
|
+
mockMatDialogRef.afterClosed.and.returnValue(of(ConfirmationResult.Yes));
|
|
69
|
+
|
|
70
|
+
await service.askForConfirmation('title', 'message');
|
|
71
|
+
|
|
72
|
+
expect(mockMatDialog.open).toHaveBeenCalledTimes(1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should returns user answer after confirmation', async () => {
|
|
76
|
+
mockMatDialogRef.afterClosed.and.returnValue(of(ConfirmationResult.Yes));
|
|
77
|
+
|
|
78
|
+
const result = await service.askForConfirmation('title', 'message');
|
|
79
|
+
|
|
80
|
+
expect(result).toBe(ConfirmationResult.Yes);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { inject, Injectable } from '@angular/core';
|
|
2
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
3
|
+
import { firstValueFrom } from 'rxjs';
|
|
4
|
+
import { AlertDialogComponent, AlertDialogData } from '../alert-dialog/alert-dialog.component';
|
|
5
|
+
import { ComponentType } from '@angular/cdk/portal';
|
|
6
|
+
import { ConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.component';
|
|
7
|
+
import { TextInputDialogComponent } from '../text-input-dialog/text-input-dialog.component';
|
|
8
|
+
import { ValidatorFn } from '@angular/forms';
|
|
9
|
+
import { TranslateService } from '@ngx-translate/core';
|
|
10
|
+
import { DeleteDialogComponent } from '../delete-dialog/delete-dialog.component';
|
|
11
|
+
import { DeleteDialogData } from '../delete-dialog/models/delete-dialog-data';
|
|
12
|
+
import { ErrorDialogComponent } from '../error-dialog/error-dialog.component';
|
|
13
|
+
|
|
14
|
+
@Injectable({
|
|
15
|
+
providedIn: 'root'
|
|
16
|
+
})
|
|
17
|
+
export class DialogService {
|
|
18
|
+
|
|
19
|
+
private readonly defaultConfirmationOptions: ConfirmationOptions = {
|
|
20
|
+
noText: 'no',
|
|
21
|
+
noColor: 'primary',
|
|
22
|
+
noType: 'stroked',
|
|
23
|
+
yesText: 'yes',
|
|
24
|
+
yesType: 'raised',
|
|
25
|
+
messageArgs: null,
|
|
26
|
+
titleArgs: null,
|
|
27
|
+
yesColor: 'primary'
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
private readonly translate = inject(TranslateService);
|
|
31
|
+
private readonly dialog = inject(MatDialog);
|
|
32
|
+
|
|
33
|
+
public async showDialog(title: string, message: string): Promise<any> {
|
|
34
|
+
const dialogRef = this.dialog.open(AlertDialogComponent, {
|
|
35
|
+
data: { title, message } as AlertDialogData,
|
|
36
|
+
autoFocus: false
|
|
37
|
+
});
|
|
38
|
+
return await firstValueFrom(dialogRef.afterClosed());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public async showCustomDialog(component: ComponentType<unknown>, args: any , options: any = { autoFocus: false }): Promise<any> {
|
|
42
|
+
const config = { ...options, ... { data: args} };
|
|
43
|
+
return await firstValueFrom(this.dialog.open(component, config)
|
|
44
|
+
.afterClosed());
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public async askForConfirmation(title: string, message: string, args: Partial<ConfirmationOptions> = null, options: any = { autoFocus: false}): Promise<ConfirmationResult> {
|
|
48
|
+
args = { ...this.defaultConfirmationOptions, ...(args || {}) };
|
|
49
|
+
const data = { options: args, title, message };
|
|
50
|
+
const config = { ...options, ... { data } };
|
|
51
|
+
const dialogRef = this.dialog.open(ConfirmDialogComponent, config);
|
|
52
|
+
return await firstValueFrom(dialogRef.afterClosed());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async askForDeleteConfirmation(name: string, type: string, translateType: boolean = false): Promise<any> {
|
|
56
|
+
if (translateType) {
|
|
57
|
+
type = this.translate.instant(type);
|
|
58
|
+
}
|
|
59
|
+
const dialogRef = this.dialog.open(DeleteDialogComponent, {
|
|
60
|
+
data: { name, type } as DeleteDialogData,
|
|
61
|
+
autoFocus: false
|
|
62
|
+
});
|
|
63
|
+
return await firstValueFrom(dialogRef.afterClosed());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public async showDeletionError(name: string): Promise<any> {
|
|
67
|
+
const dialogRef = this.dialog.open(ErrorDialogComponent, {
|
|
68
|
+
data: { name } as DeleteDialogData,
|
|
69
|
+
autoFocus: '#okButton'
|
|
70
|
+
});
|
|
71
|
+
return await firstValueFrom(dialogRef.afterClosed());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public async input(inputOptions: InputOptions, optionsDialog: any = { autoFocus: false }, value: string = '' , suffix = ''): Promise<{ result: ConfirmationResult, value: string }> {
|
|
75
|
+
const args = { ...inputOptions, value, suffix };
|
|
76
|
+
const config = { ...optionsDialog, ... { data: args } };
|
|
77
|
+
|
|
78
|
+
return await firstValueFrom(this.dialog.open(TextInputDialogComponent, config)
|
|
79
|
+
.afterClosed());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ConfirmationOptions {
|
|
84
|
+
noText: string;
|
|
85
|
+
noColor: string;
|
|
86
|
+
noType?: 'basic' | 'raised' | 'stroked' | 'flat' | 'icon';
|
|
87
|
+
yesText: string;
|
|
88
|
+
yesColor: string;
|
|
89
|
+
yesType?: 'basic' | 'raised' | 'stroked' | 'flat' | 'icon';
|
|
90
|
+
messageArgs: any;
|
|
91
|
+
titleArgs: any;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export enum ConfirmationResult {
|
|
95
|
+
Cancel,
|
|
96
|
+
Yes,
|
|
97
|
+
No
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface InputOptions {
|
|
101
|
+
titleLabel: string;
|
|
102
|
+
validateButtonLabel: string;
|
|
103
|
+
cancelButtonLabel: string;
|
|
104
|
+
inputLabel: string;
|
|
105
|
+
useTextArea?: boolean;
|
|
106
|
+
validators?: ValidatorFn | ValidatorFn[];
|
|
107
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<div mat-dialog-title>
|
|
2
|
+
<div class="h6">{{ titleLabel | translate }}</div>
|
|
3
|
+
<cauca-icon-button id="close-button" icon="close" (buttonClick)="cancelClick()" />
|
|
4
|
+
</div>
|
|
5
|
+
<div mat-dialog-content>
|
|
6
|
+
<form [formGroup]="form">
|
|
7
|
+
<mat-form-field>
|
|
8
|
+
<mat-label>{{ inputLabel | translate}}</mat-label>
|
|
9
|
+
@if (useTextArea()) {
|
|
10
|
+
<textarea cdkTextareaAutosize formControlName="input" matInput></textarea>
|
|
11
|
+
} @else {
|
|
12
|
+
<input formControlName="input" matInput />
|
|
13
|
+
}
|
|
14
|
+
@if (showSuffix()) { <span matTextSuffix>{{suffix()}}</span> }
|
|
15
|
+
@if (form.controls.input.hasError('required')) {<mat-error>{{'error.requiredField' | translate}}</mat-error>}
|
|
16
|
+
@if (form.controls.input.hasError('invalidName')) {<mat-error>{{'error.invalidName' | translate}}</mat-error>}
|
|
17
|
+
@if (form.controls.input.hasError('alreadyUsed')) {<mat-error>{{'error.alreadyUsed' | translate}}</mat-error>}
|
|
18
|
+
</mat-form-field>
|
|
19
|
+
</form>
|
|
20
|
+
</div>
|
|
21
|
+
<mat-dialog-actions align="end">
|
|
22
|
+
<cauca-stroked-button id="close-button" [label]="cancelButtonLabel" (buttonClick)="cancelClick()" color="primary" />
|
|
23
|
+
<cauca-raised-button class="yes-button" [isDisabled]="!form.valid" [label]="validateButtonLabel" color="primary" (buttonClick)="validateClick()" />
|
|
24
|
+
</mat-dialog-actions>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
:host>div:first-child {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
padding: 8px 24px 0px 24px;
|
|
5
|
+
|
|
6
|
+
div:first-child {
|
|
7
|
+
flex: 1;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
mat-form-field {
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.mat-mdc-dialog-actions.mat-mdc-dialog-actions-align-end,
|
|
16
|
+
.mat-mdc-dialog-actions[align=end] {
|
|
17
|
+
column-gap: 8px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.mat-mdc-dialog-content {
|
|
21
|
+
padding-top: 8px !important;
|
|
22
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { TextInputDialogComponent } from './text-input-dialog.component';
|
|
4
|
+
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
5
|
+
import { MockComponents, MockModule, MockPipe, ngMocks } from 'ng-mocks';
|
|
6
|
+
import { TranslateModule, TranslatePipe } from '@ngx-translate/core';
|
|
7
|
+
import { ConfirmationResult } from '../services/dialog.service';
|
|
8
|
+
import { HarnessLoader } from '@angular/cdk/testing';
|
|
9
|
+
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
|
10
|
+
import { MatFormFieldHarness } from '@angular/material/form-field/testing';
|
|
11
|
+
import { RaisedButtonComponent } from '../../buttons/raised-button/raised-button.component';
|
|
12
|
+
import { StrokedButtonComponent } from '../../buttons/stroked-button/stroked-button.component';
|
|
13
|
+
import { IconButtonComponent } from '../../buttons/icon-button/icon-button.component';
|
|
14
|
+
|
|
15
|
+
describe('TextInputDialogComponent', () => {
|
|
16
|
+
let component: TextInputDialogComponent;
|
|
17
|
+
let fixture: ComponentFixture<TextInputDialogComponent>;
|
|
18
|
+
let loader: HarnessLoader;
|
|
19
|
+
let mockMatDialog, defaultData: any;
|
|
20
|
+
|
|
21
|
+
beforeEach(async () => {
|
|
22
|
+
mockMatDialog = jasmine.createSpyObj('MatDialogRef', ['close']);
|
|
23
|
+
defaultData = {
|
|
24
|
+
titleLabel: 'Title',
|
|
25
|
+
validateButtonLabel: 'Validate',
|
|
26
|
+
cancelButtonLabel: 'Cancel',
|
|
27
|
+
inputLabel: 'Input',
|
|
28
|
+
suffix: '.xlxs'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
await TestBed.configureTestingModule({
|
|
32
|
+
imports: [TextInputDialogComponent,
|
|
33
|
+
MockModule(TranslateModule),
|
|
34
|
+
...MockComponents(IconButtonComponent, StrokedButtonComponent, RaisedButtonComponent)
|
|
35
|
+
],
|
|
36
|
+
declarations: [
|
|
37
|
+
MockPipe(TranslatePipe, value => value),
|
|
38
|
+
...MockComponents(StrokedButtonComponent, RaisedButtonComponent)
|
|
39
|
+
],
|
|
40
|
+
providers: [
|
|
41
|
+
{ provide: MatDialogRef, useValue: mockMatDialog },
|
|
42
|
+
{ provide: MAT_DIALOG_DATA, useValue: defaultData },
|
|
43
|
+
]
|
|
44
|
+
})
|
|
45
|
+
.compileComponents();
|
|
46
|
+
|
|
47
|
+
fixture = TestBed.createComponent(TextInputDialogComponent);
|
|
48
|
+
loader = TestbedHarnessEnvironment.loader(fixture);
|
|
49
|
+
component = fixture.componentInstance;
|
|
50
|
+
fixture.detectChanges();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should create', () => {
|
|
54
|
+
expect(component).toBeTruthy();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should set dialog labels', () => {
|
|
58
|
+
expect(component.titleLabel).toBe(defaultData.titleLabel);
|
|
59
|
+
expect(fixture.nativeElement.querySelector('.h6').textContent).toBe(defaultData.titleLabel);
|
|
60
|
+
|
|
61
|
+
expect(component.validateButtonLabel).toBe(defaultData.validateButtonLabel);
|
|
62
|
+
expect(ngMocks.findInstance(RaisedButtonComponent).label).toBe(defaultData.validateButtonLabel);
|
|
63
|
+
|
|
64
|
+
expect(component.cancelButtonLabel).toBe(defaultData.cancelButtonLabel);
|
|
65
|
+
expect(ngMocks.findInstance(StrokedButtonComponent).label).toBe(defaultData.cancelButtonLabel);
|
|
66
|
+
|
|
67
|
+
expect(component.inputLabel).toBe(defaultData.inputLabel);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should close dialog when clicking on cancel button in title', () => {
|
|
71
|
+
const closeButton = ngMocks.findInstance(IconButtonComponent);
|
|
72
|
+
|
|
73
|
+
closeButton.buttonClick.emit();
|
|
74
|
+
|
|
75
|
+
expect(mockMatDialog.close).toHaveBeenCalledWith({ result: ConfirmationResult.Cancel, value: null });
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should close dialog with cancel result on cancel button click', () => {
|
|
79
|
+
const closeButton = ngMocks.findInstance(StrokedButtonComponent);
|
|
80
|
+
|
|
81
|
+
closeButton.buttonClick.emit();
|
|
82
|
+
|
|
83
|
+
expect(mockMatDialog.close).toHaveBeenCalledWith({result: ConfirmationResult.Cancel, value: null});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should close dialog with yes result and input value on validate button click', () => {
|
|
87
|
+
const validateButton = ngMocks.findInstance(RaisedButtonComponent);
|
|
88
|
+
const value = 'test';
|
|
89
|
+
|
|
90
|
+
component.form.controls.input.setValue(value);
|
|
91
|
+
validateButton.buttonClick.emit();
|
|
92
|
+
|
|
93
|
+
expect(mockMatDialog.close).toHaveBeenCalledWith({result: ConfirmationResult.Yes, value});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should set suffix from received data', () => {
|
|
97
|
+
expect(component.suffix()).toBe(defaultData.suffix);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should show suffix when suffix is set', async () => {
|
|
101
|
+
const formField = await loader.getHarness(MatFormFieldHarness);
|
|
102
|
+
fixture.detectChanges();
|
|
103
|
+
|
|
104
|
+
expect(await formField.getSuffixText()).toBe('.xlxs');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should show suffix when showSuffix is not set', async () => {
|
|
108
|
+
const suffix = '';
|
|
109
|
+
component.suffix.set(suffix);
|
|
110
|
+
fixture.detectChanges();
|
|
111
|
+
|
|
112
|
+
const formField = await loader.getHarness(MatFormFieldHarness);
|
|
113
|
+
|
|
114
|
+
expect(await formField.getSuffixText()).toBe('');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should show textarea when useTextArea is set', async () => {
|
|
118
|
+
component.useTextArea.set(true);
|
|
119
|
+
fixture.detectChanges();
|
|
120
|
+
|
|
121
|
+
const textarea = fixture.nativeElement.querySelector('textarea');
|
|
122
|
+
|
|
123
|
+
expect(textarea).toBeTruthy();
|
|
124
|
+
expect( fixture.nativeElement.querySelector('input')).toBeFalsy();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Component, computed, Inject, signal } from '@angular/core';
|
|
2
|
+
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
|
3
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
4
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
5
|
+
import { MatInputModule } from '@angular/material/input';
|
|
6
|
+
import { FormGroup, ReactiveFormsModule, UntypedFormBuilder, ValidatorFn } from '@angular/forms';
|
|
7
|
+
import { ConfirmationResult } from '../services/dialog.service';
|
|
8
|
+
import { RaisedButtonComponent } from '../../buttons/raised-button/raised-button.component';
|
|
9
|
+
import { StrokedButtonComponent } from '../../buttons/stroked-button/stroked-button.component';
|
|
10
|
+
import { IconButtonComponent } from '../../buttons/icon-button/icon-button.component';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'cauca-text-input-dialog',
|
|
14
|
+
standalone: true,
|
|
15
|
+
imports: [TranslateModule, RaisedButtonComponent, MatDialogModule, StrokedButtonComponent, MatFormFieldModule, MatInputModule, ReactiveFormsModule, IconButtonComponent],
|
|
16
|
+
templateUrl: './text-input-dialog.component.html',
|
|
17
|
+
styleUrl: './text-input-dialog.component.scss'
|
|
18
|
+
})
|
|
19
|
+
export class TextInputDialogComponent {
|
|
20
|
+
public form: FormGroup;
|
|
21
|
+
|
|
22
|
+
public titleLabel: string = '';
|
|
23
|
+
public validateButtonLabel: string = '';
|
|
24
|
+
public cancelButtonLabel: string = '';
|
|
25
|
+
public inputLabel: string = '';
|
|
26
|
+
public suffix = signal<string>('');
|
|
27
|
+
public showSuffix = computed(() => !!this.suffix());
|
|
28
|
+
public useTextArea = signal<boolean>(false);
|
|
29
|
+
|
|
30
|
+
public constructor(
|
|
31
|
+
formBuilder: UntypedFormBuilder,
|
|
32
|
+
public dialogRef: MatDialogRef<TextInputDialogComponent>,
|
|
33
|
+
@Inject(MAT_DIALOG_DATA) public data: TextInputDialogData) {
|
|
34
|
+
this.suffix.set(data.suffix);
|
|
35
|
+
|
|
36
|
+
this.titleLabel = data.titleLabel;
|
|
37
|
+
this.validateButtonLabel = data.validateButtonLabel;
|
|
38
|
+
this.cancelButtonLabel = data.cancelButtonLabel;
|
|
39
|
+
this.inputLabel = data.inputLabel;
|
|
40
|
+
this.useTextArea.set(data.useTextArea ?? false);
|
|
41
|
+
|
|
42
|
+
this.form = formBuilder.group({
|
|
43
|
+
input: [data.value, data.validators]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public cancelClick(): void {
|
|
48
|
+
this.dialogRef.close({ result: ConfirmationResult.Cancel, value: null });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public validateClick(): void {
|
|
52
|
+
const trimmedValue = this.form.controls.input.value.trim();
|
|
53
|
+
this.dialogRef.close({ result: ConfirmationResult.Yes, value: trimmedValue });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface TextInputDialogData {
|
|
58
|
+
titleLabel: string;
|
|
59
|
+
validateButtonLabel: string;
|
|
60
|
+
cancelButtonLabel: string;
|
|
61
|
+
inputLabel: string;
|
|
62
|
+
suffix?: string;
|
|
63
|
+
useTextArea?: boolean;
|
|
64
|
+
validators?: ValidatorFn | ValidatorFn[];
|
|
65
|
+
value?: string;
|
|
66
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ColorPickerComponent } from './color-picker.component';
|
|
4
|
+
|
|
5
|
+
describe('ColorPickerComponent', () => {
|
|
6
|
+
let component: ColorPickerComponent;
|
|
7
|
+
let fixture: ComponentFixture<ColorPickerComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [ColorPickerComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(ColorPickerComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should set value when onChangeColor is called', () => {
|
|
25
|
+
const color = 'red';
|
|
26
|
+
component.onChangeColor(color);
|
|
27
|
+
expect(component.value).toEqual(color);
|
|
28
|
+
});
|
|
29
|
+
});
|