@cauca-911/material 21.0.1-beta.4 → 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 -4323
- package/fesm2022/cauca-911-material.mjs.map +0 -1
- package/types/cauca-911-material.d.ts +0 -755
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, InputSignal, input } from '@angular/core';
|
|
2
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'cauca-main-section',
|
|
6
|
+
imports: [TranslateModule],
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
templateUrl: './main-section.component.html',
|
|
9
|
+
styleUrl: './main-section.component.scss'
|
|
10
|
+
})
|
|
11
|
+
export class MainSectionComponent {
|
|
12
|
+
public title: InputSignal<string> = input('');
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
flex: 1 0 0;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: stretch;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.section-columns {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
align-items: flex-start;
|
|
12
|
+
gap: 8px;
|
|
13
|
+
flex: 1 0 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.big-gap {
|
|
17
|
+
gap: 16px;
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SectionColumnComponent } from './section-column.component';
|
|
4
|
+
|
|
5
|
+
describe('SectionColumnComponent', () => {
|
|
6
|
+
let component: SectionColumnComponent;
|
|
7
|
+
let fixture: ComponentFixture<SectionColumnComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [SectionColumnComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(SectionColumnComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should not add big-gap class if not specified', () => {
|
|
25
|
+
expect(fixture.nativeElement.querySelector('.section-columns')).not.toHaveClass('big-gap');
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should not add big-gap class if specified', () => {
|
|
29
|
+
fixture.componentRef.setInput('showBigGap', true);
|
|
30
|
+
|
|
31
|
+
fixture.detectChanges();
|
|
32
|
+
|
|
33
|
+
expect(fixture.nativeElement.querySelector('.section-columns')).toHaveClass('big-gap');
|
|
34
|
+
})
|
|
35
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
selector: 'cauca-section-column',
|
|
5
|
+
standalone: true,
|
|
6
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
7
|
+
templateUrl: './section-column.component.html',
|
|
8
|
+
styleUrl: './section-column.component.scss'
|
|
9
|
+
})
|
|
10
|
+
export class SectionColumnComponent {
|
|
11
|
+
public showBigGap = input<boolean>(false);
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<div class="section-fields-line" [class.multi-line]="useMultipleValues()">
|
|
2
|
+
<div class="option-label body1" [class.link]="showLink()">
|
|
3
|
+
@if(autoTranslateLabel()) {
|
|
4
|
+
{{label()|translate}}
|
|
5
|
+
} @else {
|
|
6
|
+
{{label()}}
|
|
7
|
+
}
|
|
8
|
+
@if (showLink()) {
|
|
9
|
+
<mat-icon class="icon-link" (click)="linkClick.emit()" onkeypress="linkClick.emit()">link</mat-icon>
|
|
10
|
+
}:
|
|
11
|
+
</div>
|
|
12
|
+
<div class="option-value body2" [class.no-flex]="!splitEqually()">
|
|
13
|
+
@if (useMultipleValues()) {
|
|
14
|
+
@for(item of values(); track item) {
|
|
15
|
+
<span>{{fieldName() ? item[fieldName()] : item }}</span>
|
|
16
|
+
}
|
|
17
|
+
} @else {
|
|
18
|
+
{{value()}}
|
|
19
|
+
}
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
flex: 1 0 0;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: stretch;
|
|
6
|
+
width: 100%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.section-fields-line {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: 8px;
|
|
13
|
+
align-self: stretch;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
& > * {
|
|
16
|
+
flex: 1 0 0;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.option-value {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
align-items: flex-start;
|
|
24
|
+
gap: 8px;
|
|
25
|
+
flex: 1 0 0;
|
|
26
|
+
white-space: wrap;
|
|
27
|
+
word-break: break-all;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.option-value.no-flex {
|
|
31
|
+
flex: unset;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.multi-line {
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.icon-link {
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.link {
|
|
43
|
+
display: flex;
|
|
44
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { SectionFieldComponent } from './section-field.component';
|
|
4
|
+
import { By } from '@angular/platform-browser';
|
|
5
|
+
import { MockModule, MockPipe } from 'ng-mocks';
|
|
6
|
+
import { TranslateModule, TranslatePipe } from '@ngx-translate/core';
|
|
7
|
+
|
|
8
|
+
describe('SectionFieldComponent', () => {
|
|
9
|
+
let component: SectionFieldComponent;
|
|
10
|
+
let fixture: ComponentFixture<SectionFieldComponent>;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
await TestBed.configureTestingModule({
|
|
14
|
+
declarations: [MockPipe(TranslatePipe, () => 'translated')],
|
|
15
|
+
imports: [SectionFieldComponent, MockModule(TranslateModule)]
|
|
16
|
+
})
|
|
17
|
+
.compileComponents();
|
|
18
|
+
|
|
19
|
+
fixture = TestBed.createComponent(SectionFieldComponent);
|
|
20
|
+
component = fixture.componentInstance;
|
|
21
|
+
fixture.detectChanges();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should create', () => {
|
|
25
|
+
expect(component).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should display the specified label', () => {
|
|
29
|
+
fixture.componentRef.setInput('label', 'value');
|
|
30
|
+
fixture.detectChanges();
|
|
31
|
+
|
|
32
|
+
expect(fixture.nativeElement.querySelector('.option-label').textContent).toContain('translated');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should not translate the label if translation is set to off', () => {
|
|
36
|
+
fixture.componentRef.setInput('label', 'someValue');
|
|
37
|
+
fixture.componentRef.setInput('autoTranslateLabel', false);
|
|
38
|
+
fixture.detectChanges();
|
|
39
|
+
|
|
40
|
+
expect(fixture.nativeElement.querySelector('.option-label').textContent).toContain('someValue');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should display the specified value', () => {
|
|
44
|
+
const someValue = 'someValue';
|
|
45
|
+
|
|
46
|
+
fixture.componentRef.setInput('value', someValue);
|
|
47
|
+
fixture.detectChanges();
|
|
48
|
+
|
|
49
|
+
expect(component.useMultipleValues()).toBeFalse();
|
|
50
|
+
expect(fixture.nativeElement.querySelector('.option-value').textContent).toContain(someValue);
|
|
51
|
+
expect(fixture.nativeElement.querySelector('.section-fields-line')).not.toHaveClass('multi-line');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should display a list of value when values is specified', () => {
|
|
55
|
+
const someValues = ['value1', 'value2'];
|
|
56
|
+
|
|
57
|
+
fixture.componentRef.setInput('values', someValues);
|
|
58
|
+
fixture.detectChanges();
|
|
59
|
+
|
|
60
|
+
expect(component.useMultipleValues()).toBeTrue();
|
|
61
|
+
fixture.debugElement.query(By.css('.option-value')).children.forEach((node, index) => {
|
|
62
|
+
expect(node.nativeElement.textContent).toBe(someValues[index]);
|
|
63
|
+
});
|
|
64
|
+
expect(fixture.nativeElement.querySelector('.section-fields-line')).toHaveClass('multi-line');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should display link when showLink is true', () => {
|
|
68
|
+
fixture.componentRef.setInput('showLink', true);
|
|
69
|
+
fixture.detectChanges();
|
|
70
|
+
|
|
71
|
+
expect(fixture.debugElement.query(By.css('.icon-link'))).toBeDefined();
|
|
72
|
+
expect(fixture.nativeElement.querySelector('.option-label')).toHaveClass('link');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
|
|
2
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
3
|
+
import { MatIcon } from '@angular/material/icon';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'cauca-section-field',
|
|
7
|
+
imports: [TranslateModule, MatIcon],
|
|
8
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
|
+
templateUrl: './section-field.component.html',
|
|
10
|
+
styleUrl: './section-field.component.scss'
|
|
11
|
+
})
|
|
12
|
+
export class SectionFieldComponent {
|
|
13
|
+
public autoTranslateLabel = input<boolean>(true);
|
|
14
|
+
public label = input<string>('');
|
|
15
|
+
public value = input<unknown>('');
|
|
16
|
+
public values = input<unknown[]>([]);
|
|
17
|
+
public fieldName = input<string>('');
|
|
18
|
+
public useMultipleValues = computed(() => this.values()?.length > 0);
|
|
19
|
+
public showLink = input<boolean>(false);
|
|
20
|
+
public linkClick = output<void>();
|
|
21
|
+
public splitEqually = input<boolean>(true);
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div class="pages">
|
|
2
|
+
<cauca-icon-button class="page first" [isDisabled]="previousDisabled()" (buttonClick)="tryMoveToFirst()" icon="first_page" />
|
|
3
|
+
<cauca-icon-button class="page previous" [isDisabled]="previousDisabled()" (buttonClick)="tryMoveToPrevious()" icon="chevron_left" />
|
|
4
|
+
|
|
5
|
+
@for(page of pagesToShow(); track page) {
|
|
6
|
+
@if (page === pageSplitterValue) {
|
|
7
|
+
<div class="page">{{pageSplitter}}
|
|
8
|
+
</div>
|
|
9
|
+
} @else {
|
|
10
|
+
<cauca-round-button class="page specific" [class.selected]="page === currentPage()" (buttonClick)="changePage(page)" [translateLabel]="false" [label]="page.toString()" />
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
<cauca-icon-button class="page next" [isDisabled]="nextDisabled()" (buttonClick)="tryMoveToNext()" icon="chevron_right" />
|
|
15
|
+
<cauca-icon-button class="page last" [isDisabled]="nextDisabled()" (buttonClick)="tryMoveToLast()" icon="last_page" />
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.pages {
|
|
8
|
+
display: flex;
|
|
9
|
+
padding: 0px 6px;
|
|
10
|
+
align-items: flex-start;
|
|
11
|
+
gap: 6px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.page {
|
|
15
|
+
display: flex;
|
|
16
|
+
width: 40px;
|
|
17
|
+
height: 40px;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
align-items: center;
|
|
20
|
+
color: #121014;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.page:hover:not(.disabled) {
|
|
25
|
+
background: rgba(18, 16, 20, 0.02);
|
|
26
|
+
border-radius: 100px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.page:active:not(.disabled) {
|
|
30
|
+
background: rgba(18, 16, 20, 0.06);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.selected {
|
|
34
|
+
border-radius: 100px;
|
|
35
|
+
background: rgba(18, 16, 20, 0.08);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.disabled {
|
|
39
|
+
color: #12101448;
|
|
40
|
+
|
|
41
|
+
mat-icon {
|
|
42
|
+
color: #12101448;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
cursor: default;
|
|
46
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ListPaginatorComponent } from './list-paginator.component';
|
|
4
|
+
import { By } from '@angular/platform-browser';
|
|
5
|
+
import { MockComponents, ngMocks } from 'ng-mocks';
|
|
6
|
+
import { IconButtonComponent } from '../buttons/icon-button/icon-button.component';
|
|
7
|
+
import { RoundButtonComponent } from '../buttons/round-button/round-button.component';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
describe('ListPaginatorComponent', () => {
|
|
11
|
+
let component: ListPaginatorComponent;
|
|
12
|
+
let fixture: ComponentFixture<ListPaginatorComponent>;
|
|
13
|
+
|
|
14
|
+
beforeEach(async () => {
|
|
15
|
+
await TestBed.configureTestingModule({
|
|
16
|
+
imports: [ListPaginatorComponent,
|
|
17
|
+
...MockComponents(IconButtonComponent, RoundButtonComponent)
|
|
18
|
+
]
|
|
19
|
+
})
|
|
20
|
+
.compileComponents();
|
|
21
|
+
|
|
22
|
+
fixture = TestBed.createComponent(ListPaginatorComponent);
|
|
23
|
+
component = fixture.componentInstance;
|
|
24
|
+
fixture.detectChanges();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should create', () => {
|
|
28
|
+
expect(component).toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should have one page when itemsCount is less than page size', () => {
|
|
32
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
33
|
+
fixture.componentRef.setInput('itemsCount', 3);
|
|
34
|
+
|
|
35
|
+
fixture.detectChanges();
|
|
36
|
+
|
|
37
|
+
expect(component.pageCount()).toBe(1);
|
|
38
|
+
expect(fixture.debugElement.queryAll(By.css('.specific')).length).toBe(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should have one page when itemsCount is exactly the page size ', () => {
|
|
42
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
43
|
+
fixture.componentRef.setInput('itemsCount', 6);
|
|
44
|
+
|
|
45
|
+
fixture.detectChanges();
|
|
46
|
+
|
|
47
|
+
expect(component.pageCount()).toBe(1);
|
|
48
|
+
expect(fixture.debugElement.queryAll(By.css('.specific')).length).toBe(1);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should have two pages when the itemsCount is slightly bigger than page size', () => {
|
|
52
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
53
|
+
fixture.componentRef.setInput('itemsCount', 7);
|
|
54
|
+
|
|
55
|
+
fixture.detectChanges();
|
|
56
|
+
|
|
57
|
+
expect(component.pageCount()).toBe(2);
|
|
58
|
+
expect(fixture.debugElement.queryAll(By.css('.specific')).length).toBe(2);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should disabled previous and first when current page is the first one', () => {
|
|
62
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
63
|
+
fixture.componentRef.setInput('itemsCount', 7);
|
|
64
|
+
|
|
65
|
+
component.currentPage.set(1);
|
|
66
|
+
|
|
67
|
+
expect(component.previousDisabled()).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should disabled next and last when current page is the last one', () => {
|
|
71
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
72
|
+
fixture.componentRef.setInput('itemsCount', 7);
|
|
73
|
+
|
|
74
|
+
component.currentPage.set(2);
|
|
75
|
+
|
|
76
|
+
expect(component.nextDisabled()).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should go to specified page when clicking on page button', () => {
|
|
80
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
81
|
+
fixture.componentRef.setInput('itemsCount', 7);
|
|
82
|
+
fixture.detectChanges();
|
|
83
|
+
const spy = spyOn(component.pageChange, 'emit');
|
|
84
|
+
|
|
85
|
+
const button = ngMocks.findInstances('.specific', RoundButtonComponent)[1];
|
|
86
|
+
button.buttonClick.emit();
|
|
87
|
+
fixture.detectChanges();
|
|
88
|
+
|
|
89
|
+
expect(component.currentPage()).toBe(2);
|
|
90
|
+
expect(spy).toHaveBeenCalledOnceWith(2);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should go to first page when clicking on first button', () => {
|
|
94
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
95
|
+
fixture.componentRef.setInput('itemsCount', 30);
|
|
96
|
+
component.currentPage.set(2);
|
|
97
|
+
const spy = spyOn(component.pageChange, 'emit');
|
|
98
|
+
fixture.detectChanges();
|
|
99
|
+
|
|
100
|
+
const button = ngMocks.findInstance('.first', IconButtonComponent);
|
|
101
|
+
button.buttonClick.emit();
|
|
102
|
+
fixture.detectChanges();
|
|
103
|
+
|
|
104
|
+
expect(component.currentPage()).toBe(1);
|
|
105
|
+
expect(spy).toHaveBeenCalledOnceWith(1);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should go to previous page when clicking on previous button', () => {
|
|
109
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
110
|
+
fixture.componentRef.setInput('itemsCount', 30);
|
|
111
|
+
component.currentPage.set(3);
|
|
112
|
+
fixture.detectChanges();
|
|
113
|
+
const spy = spyOn(component.pageChange, 'emit');
|
|
114
|
+
|
|
115
|
+
const button = ngMocks.findInstance('.previous', IconButtonComponent);
|
|
116
|
+
button.buttonClick.emit();
|
|
117
|
+
fixture.detectChanges();
|
|
118
|
+
|
|
119
|
+
expect(component.currentPage()).toBe(2);
|
|
120
|
+
expect(spy).toHaveBeenCalledOnceWith(2);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should go to last page when clicking on last button', () => {
|
|
124
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
125
|
+
fixture.componentRef.setInput('itemsCount', 30);
|
|
126
|
+
component.currentPage.set(1);
|
|
127
|
+
fixture.detectChanges();
|
|
128
|
+
const spy = spyOn(component.pageChange, 'emit');
|
|
129
|
+
|
|
130
|
+
const button = ngMocks.findInstance('.last', IconButtonComponent);
|
|
131
|
+
button.buttonClick.emit();
|
|
132
|
+
fixture.detectChanges();
|
|
133
|
+
|
|
134
|
+
expect(component.currentPage()).toBe(5);
|
|
135
|
+
expect(spy).toHaveBeenCalledOnceWith(5);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should go to next page when clicking on next button', () => {
|
|
139
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
140
|
+
fixture.componentRef.setInput('itemsCount', 30);
|
|
141
|
+
component.currentPage.set(1);
|
|
142
|
+
fixture.detectChanges();
|
|
143
|
+
const spy = spyOn(component.pageChange, 'emit');
|
|
144
|
+
|
|
145
|
+
const button = ngMocks.findInstance('.next', IconButtonComponent);
|
|
146
|
+
button.buttonClick.emit();
|
|
147
|
+
fixture.detectChanges();
|
|
148
|
+
|
|
149
|
+
expect(component.currentPage()).toBe(2);
|
|
150
|
+
expect(spy).toHaveBeenCalledOnceWith(2);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should be able to move to first page without emitting', () => {
|
|
154
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
155
|
+
fixture.componentRef.setInput('itemsCount', 30);
|
|
156
|
+
component.currentPage.set(2);
|
|
157
|
+
const spy = spyOn(component.pageChange, 'emit');
|
|
158
|
+
|
|
159
|
+
component.moveToFirst();
|
|
160
|
+
|
|
161
|
+
expect(component.currentPage()).toBe(1);
|
|
162
|
+
expect(spy).not.toHaveBeenCalled();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should always show first page button', () => {
|
|
166
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
167
|
+
fixture.componentRef.setInput('itemsCount', 300);
|
|
168
|
+
component.currentPage.set(30);
|
|
169
|
+
fixture.detectChanges();
|
|
170
|
+
const spy = spyOn(component.pageChange, 'emit');
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
const button = ngMocks.findInstances('.specific', RoundButtonComponent)[0];
|
|
174
|
+
button.buttonClick.emit();
|
|
175
|
+
fixture.detectChanges();
|
|
176
|
+
|
|
177
|
+
expect(component.currentPage()).toBe(1);
|
|
178
|
+
expect(spy).toHaveBeenCalledOnceWith(1);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('should always show last page button', () => {
|
|
182
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
183
|
+
fixture.componentRef.setInput('itemsCount', 300);
|
|
184
|
+
component.currentPage.set(1);
|
|
185
|
+
fixture.detectChanges();
|
|
186
|
+
const spy = spyOn(component.pageChange, 'emit');
|
|
187
|
+
|
|
188
|
+
const buttons = ngMocks.findInstances('.specific', RoundButtonComponent);
|
|
189
|
+
const button = buttons[buttons.length - 1];
|
|
190
|
+
button.buttonClick.emit();
|
|
191
|
+
fixture.detectChanges();
|
|
192
|
+
|
|
193
|
+
expect(component.currentPage()).toBe(50);
|
|
194
|
+
expect(spy).toHaveBeenCalledOnceWith(50);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('should not show more page than showTotalPage value excluding first page and last page', () => {
|
|
198
|
+
const pageCountWithFirstAndLastPagesIncluded = 6;
|
|
199
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
200
|
+
fixture.componentRef.setInput('itemsCount', 300);
|
|
201
|
+
fixture.componentRef.setInput('showTotalPage', pageCountWithFirstAndLastPagesIncluded - 2);
|
|
202
|
+
component.currentPage.set(20);
|
|
203
|
+
fixture.detectChanges();
|
|
204
|
+
|
|
205
|
+
const buttons = fixture.nativeElement.querySelectorAll('.specific');
|
|
206
|
+
|
|
207
|
+
expect(buttons.length).toBe(pageCountWithFirstAndLastPagesIncluded);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('should show pages between the currentPage', () => {
|
|
211
|
+
const pageCountWithFirstAndLastPagesIncluded = 7;
|
|
212
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
213
|
+
fixture.componentRef.setInput('itemsCount', 300);
|
|
214
|
+
fixture.componentRef.setInput('showTotalPage', pageCountWithFirstAndLastPagesIncluded - 2);
|
|
215
|
+
component.currentPage.set(20);
|
|
216
|
+
fixture.detectChanges();
|
|
217
|
+
|
|
218
|
+
const pages = component.pagesToShow();
|
|
219
|
+
|
|
220
|
+
expect(pages).toEqual([1, -1, 18, 19, 20, 21, 22, -1, 50]);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it('should not show pages before the first', () => {
|
|
224
|
+
const pageCountWithFirstAndLastPagesIncluded = 6;
|
|
225
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
226
|
+
fixture.componentRef.setInput('itemsCount', 300);
|
|
227
|
+
fixture.componentRef.setInput('showTotalPage', pageCountWithFirstAndLastPagesIncluded - 2);
|
|
228
|
+
component.currentPage.set(1);
|
|
229
|
+
fixture.detectChanges();
|
|
230
|
+
|
|
231
|
+
const pages = component.pagesToShow();
|
|
232
|
+
|
|
233
|
+
expect(pages).toEqual([1,2,3,4,-1,50]);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('should not show pages after the last', () => {
|
|
237
|
+
const pageCountWithFirstAndLastPagesIncluded = 6;
|
|
238
|
+
fixture.componentRef.setInput('pageSize', 6);
|
|
239
|
+
fixture.componentRef.setInput('itemsCount', 300);
|
|
240
|
+
fixture.componentRef.setInput('showTotalPage', pageCountWithFirstAndLastPagesIncluded - 2);
|
|
241
|
+
component.currentPage.set(49);
|
|
242
|
+
fixture.detectChanges();
|
|
243
|
+
|
|
244
|
+
const pages = component.pagesToShow();
|
|
245
|
+
|
|
246
|
+
expect(pages).toEqual([1, -1, 47, 48, 49, 50]);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, EventEmitter, InputSignal, Output, Signal, WritableSignal, computed, input, signal } from '@angular/core';
|
|
2
|
+
import { RoundButtonComponent } from '../buttons/round-button/round-button.component';
|
|
3
|
+
import { IconButtonComponent } from '../buttons/icon-button/icon-button.component';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'cauca-list-paginator',
|
|
7
|
+
imports: [IconButtonComponent, RoundButtonComponent],
|
|
8
|
+
templateUrl: './list-paginator.component.html',
|
|
9
|
+
styleUrl: './list-paginator.component.scss',
|
|
10
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
11
|
+
})
|
|
12
|
+
export class ListPaginatorComponent {
|
|
13
|
+
public itemsCount: InputSignal<number> = input(0);
|
|
14
|
+
public showTotalPage: InputSignal<number> = input(9);
|
|
15
|
+
public pageSize: InputSignal<number> = input(50);
|
|
16
|
+
public pageCount: Signal<number> = computed(() => this.itemsCount() > 0 ? Math.ceil(this.itemsCount() / this.pageSize()) : 1);
|
|
17
|
+
public pages: Signal<number[]> = computed(() => [...Array(this.pageCount()).keys()]);
|
|
18
|
+
public currentPage: WritableSignal<number> = signal(1);
|
|
19
|
+
public previousDisabled: Signal<boolean> = computed(() => this.currentPage() === 1);
|
|
20
|
+
public nextDisabled: Signal<boolean> = computed(() => this.currentPage() === this.pageCount());
|
|
21
|
+
|
|
22
|
+
public pagesToShow: Signal<number[]> = computed(() => {
|
|
23
|
+
const pagesToShow: number[] = [];
|
|
24
|
+
|
|
25
|
+
const rangeStart = Math.max(this.currentPage() - Math.floor(this.showTotalPage() / 2), 1);
|
|
26
|
+
const rangeEnd = Math.min(rangeStart + this.showTotalPage() - 1, this.pageCount());
|
|
27
|
+
|
|
28
|
+
for (let index = rangeStart; index <= rangeEnd; index++) {
|
|
29
|
+
pagesToShow.push(index);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!pagesToShow.includes(1)) {
|
|
33
|
+
pagesToShow.unshift(1, -1);
|
|
34
|
+
}
|
|
35
|
+
if (!pagesToShow.includes(this.pageCount())) {
|
|
36
|
+
pagesToShow.push(-1, this.pageCount());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return pagesToShow;
|
|
40
|
+
});
|
|
41
|
+
@Output() public pageChange: EventEmitter<number> = new EventEmitter<number>();
|
|
42
|
+
|
|
43
|
+
public get pageSplitter(): string {
|
|
44
|
+
return '...';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public get pageSplitterValue(): number {
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public changePage(page: number): void {
|
|
52
|
+
if (page != this.currentPage()) {
|
|
53
|
+
this.currentPage.set(page);
|
|
54
|
+
this.pageChange.emit(this.currentPage());
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public moveToFirst(): void {
|
|
59
|
+
this.currentPage.set(1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public tryMoveToFirst(): void {
|
|
63
|
+
if (this.previousDisabled()) return;
|
|
64
|
+
this.changePage(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public tryMoveToLast(): void {
|
|
68
|
+
if (this.nextDisabled()) return;
|
|
69
|
+
this.changePage(this.pageCount());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public tryMoveToPrevious(): void {
|
|
73
|
+
if (this.previousDisabled()) return;
|
|
74
|
+
this.changePage(this.currentPage() - 1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public tryMoveToNext(): void {
|
|
78
|
+
if (this.nextDisabled()) return;
|
|
79
|
+
this.changePage(this.currentPage() + 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@if (showError()) {
|
|
2
|
+
<cauca-snackbar
|
|
3
|
+
caption="generalError.loadingErrorAlertTitle"
|
|
4
|
+
type="error"
|
|
5
|
+
variant="standard"
|
|
6
|
+
[showButton]="true"
|
|
7
|
+
buttonLabel="generalError.retryButtonLabel"
|
|
8
|
+
(buttonClick)="retryRequest.emit()">
|
|
9
|
+
{{'generalError.loadingErrorAlertMessage' | translate}}
|
|
10
|
+
</cauca-snackbar>
|
|
11
|
+
}
|
|
File without changes
|