@dsivd/prestations-ng 14.5.13 → 14.5.14-beta4

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/CHANGELOG.md CHANGED
@@ -26,6 +26,16 @@ A change is considered **breaking** if you have to change your code or update yo
26
26
 
27
27
  ---
28
28
 
29
+ ## [14.5.14]
30
+
31
+ ### Added
32
+
33
+ - [foehn-table.module.ts](projects/prestations-ng/src/foehn-table/foehn-table.module.ts)
34
+ - [foehn-table.component.ts](projects/prestations-ng/src/foehn-table/foehn-table.component.ts)
35
+ - [foehn-table.component.html](projects/prestations-ng/src/foehn-table/foehn-table.component.html)
36
+ - added a paginated table
37
+ - for examples, see related page in the devtool (https://dsi-vd.github.io/prestations-ng/list#foehn_table)
38
+
29
39
  ## [14.5.13]
30
40
 
31
41
  ### Added
@@ -1911,7 +1911,10 @@
1911
1911
  'foehn-picture-upload.validate-selection-label': 'Valider la sélection',
1912
1912
  'foehn-picture-upload.cancel-selection-label': 'Annuler',
1913
1913
  'foehn-picture-upload.selection-not-validated-label': 'Merci de valider votre sélection',
1914
- 'foehn-picture-upload.delete-picture-label': 'Supprimer'
1914
+ 'foehn-picture-upload.delete-picture-label': 'Supprimer',
1915
+ 'foehn-table.totalElements': '{total} éléments trouvés',
1916
+ 'foehn-table.totalElements.1': '1 élément trouvé',
1917
+ 'foehn-table.totalElements.0': 'Aucun résultat'
1915
1918
  };
1916
1919
 
1917
1920
  var DICTIONARY_BASE_URL = 'api/dictionary';
@@ -9712,6 +9715,199 @@
9712
9715
  return PageChangeEvent;
9713
9716
  }());
9714
9717
 
9718
+ var hasInputChanged = function (change) { return !(!change ||
9719
+ !change.currentValue ||
9720
+ change.previousValue === change.currentValue); };
9721
+ var FoehnTableComponent = /** @class */ (function () {
9722
+ function FoehnTableComponent() {
9723
+ this.itemsPerPage = 10;
9724
+ this.id = 'foehn-table';
9725
+ this.previousLabel = 'Précédent';
9726
+ this.nextLabel = 'Suivant';
9727
+ this.pageChange = new i0.EventEmitter();
9728
+ this.sortChange = new i0.EventEmitter();
9729
+ this.currentPage = 1;
9730
+ this.filteredList = [];
9731
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9732
+ this.trackByFn = function (index, item) { return index; };
9733
+ }
9734
+ Object.defineProperty(FoehnTableComponent.prototype, "list", {
9735
+ set: function (list) {
9736
+ this._list = list;
9737
+ },
9738
+ enumerable: false,
9739
+ configurable: true
9740
+ });
9741
+ FoehnTableComponent.prototype.ngOnChanges = function (changes) {
9742
+ var itemsPerPageChange = changes.itemsPerPage;
9743
+ var listChange = changes.list;
9744
+ var fixedPageCountChange = changes.fixedPageCount;
9745
+ if (!hasInputChanged(itemsPerPageChange) &&
9746
+ !hasInputChanged(listChange) &&
9747
+ !hasInputChanged(fixedPageCountChange)) {
9748
+ return;
9749
+ }
9750
+ this.buildFilteredList();
9751
+ };
9752
+ FoehnTableComponent.prototype.previousPage = function () {
9753
+ this.currentPage = this.currentPage - 1;
9754
+ this.buildFilteredList();
9755
+ this.pageChange.next({
9756
+ previousPage: this.currentPage + 1,
9757
+ currentPage: this.currentPage,
9758
+ pageCount: this.pagesCount()
9759
+ });
9760
+ };
9761
+ FoehnTableComponent.prototype.hasPreviousPage = function () {
9762
+ return this.currentPage > 1;
9763
+ };
9764
+ FoehnTableComponent.prototype.nextPage = function () {
9765
+ this.currentPage = this.currentPage + 1;
9766
+ this.buildFilteredList();
9767
+ this.pageChange.next({
9768
+ previousPage: this.currentPage - 1,
9769
+ currentPage: this.currentPage,
9770
+ pageCount: this.pagesCount()
9771
+ });
9772
+ };
9773
+ FoehnTableComponent.prototype.hasNextPage = function () {
9774
+ return this.currentPage < this.pagesCount();
9775
+ };
9776
+ FoehnTableComponent.prototype.showPage = function (page, emitPageChangeEvent) {
9777
+ if (emitPageChangeEvent === void 0) { emitPageChangeEvent = false; }
9778
+ if (this.currentPage === page) {
9779
+ return;
9780
+ }
9781
+ var previousPage = this.currentPage;
9782
+ this.currentPage = page;
9783
+ this.buildFilteredList();
9784
+ if (emitPageChangeEvent) {
9785
+ this.pageChange.next({
9786
+ previousPage: previousPage,
9787
+ currentPage: this.currentPage,
9788
+ pageCount: this.pagesCount()
9789
+ });
9790
+ }
9791
+ };
9792
+ FoehnTableComponent.prototype.pagesCount = function () {
9793
+ if (!!this.fixedPageCount) {
9794
+ return this.fixedPageCount;
9795
+ }
9796
+ return this._list
9797
+ ? Math.ceil(this._list.length / this.itemsPerPage)
9798
+ : 0;
9799
+ };
9800
+ FoehnTableComponent.prototype.triggerSort = function (sortAttribute) {
9801
+ var sortDirection = 'DESC';
9802
+ if (this.sort.sortAttribute === sortAttribute) {
9803
+ sortDirection = this.sort.sortDirection === 'DESC' ? 'ASC' : 'DESC';
9804
+ }
9805
+ this.sortChange.next({
9806
+ sortDirection: sortDirection,
9807
+ sortAttribute: sortAttribute
9808
+ });
9809
+ };
9810
+ FoehnTableComponent.prototype.buildFilteredList = function () {
9811
+ if (!!this.fixedPageCount) {
9812
+ this.filteredList = this._list;
9813
+ return;
9814
+ }
9815
+ var currentPageExists = (this.currentPage - 1) * this.itemsPerPage <= this._list.length;
9816
+ if (!currentPageExists) {
9817
+ this.currentPage = 1;
9818
+ }
9819
+ var start = (this.currentPage - 1) * this.itemsPerPage;
9820
+ this.filteredList = this._list
9821
+ ? this._list.slice(start, start + this.itemsPerPage)
9822
+ : [];
9823
+ };
9824
+ return FoehnTableComponent;
9825
+ }());
9826
+ FoehnTableComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: FoehnTableComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
9827
+ FoehnTableComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.4", type: FoehnTableComponent, selector: "foehn-table", inputs: { itemsPerPage: "itemsPerPage", id: "id", previousLabel: "previousLabel", nextLabel: "nextLabel", totalElements: "totalElements", fixedPageCount: "fixedPageCount", columnsConfiguration: "columnsConfiguration", sort: "sort", trackByFn: "trackByFn", list: "list" }, outputs: { pageChange: "pageChange", sortChange: "sortChange" }, usesOnChanges: true, ngImport: i0__namespace, template: "<div class=\"row\" [id]=\"id\">\n <div class=\"col-12\">\n <h4 *ngIf=\"!!totalElements && totalElements === 1\">\n {{ 'foehn-table.totalElements.1' | fromDictionary }}\n </h4>\n <h4 *ngIf=\"!!totalElements && totalElements !== 1\">\n {{\n 'foehn-table.totalElements'\n | fromDictionary: { total: totalElements.toString() }\n }}\n </h4>\n </div>\n\n <div class=\"col-12 table-responsive\">\n <table class=\"table table-hover\">\n <thead class=\"vd-bg-pattern-bars-gray\">\n <tr>\n <th\n scope=\"col\"\n *ngFor=\"let col of columnsConfiguration\"\n [id]=\"col.id\"\n >\n <ng-container *ngIf=\"!col.sortAttribute\">\n <span\n [innerHTML]=\"\n col.columnLabelKey | fromDictionary\n \"\n ></span>\n </ng-container>\n\n <ng-container *ngIf=\"!!col.sortAttribute\">\n <a\n href=\"#\"\n class=\"vd-text-thin\"\n (click)=\"\n $event.preventDefault();\n triggerSort(col.sortAttribute)\n \"\n [title]=\"\n 'Trier par ' +\n (col.columnLabelKey | fromDictionary)\n \"\n >\n <span\n [innerHTML]=\"\n col.columnLabelKey | fromDictionary\n \"\n ></span>\n <ng-container\n *ngIf=\"\n sort.sortAttribute === col.sortAttribute\n \"\n >\n <span\n class=\"ml-3\"\n *ngIf=\"sort.sortDirection === 'ASC'\"\n >\n <foehn-icon-chevron-up></foehn-icon-chevron-up>\n </span>\n <span\n class=\"ml-3\"\n *ngIf=\"sort.sortDirection === 'DESC'\"\n >\n <foehn-icon-chevron-down></foehn-icon-chevron-down>\n </span>\n </ng-container>\n </a>\n </ng-container>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr\n *ngFor=\"\n let item of filteredList;\n let index = index;\n trackBy: trackByFn\n \"\n >\n <td\n *ngFor=\"let col of columnsConfiguration\"\n [id]=\"col.id + '-' + index\"\n >\n <ng-container *ngIf=\"!!col.isImportant\">\n <span\n *ngIf=\"col.isImportant(item)\"\n class=\"cell-vertical-align-middle\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"30\"\n height=\"30\"\n style=\"color: var(--red)\"\n fill=\"currentColor\"\n class=\"bi bi-exclamation\"\n viewBox=\"0 0 16 16\"\n >\n <path\n d=\"M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.553.553 0 0 1-1.1 0L7.1 4.995z\"\n />\n </svg>\n </span>\n </ng-container>\n\n <ng-container *ngIf=\"!col.routerLinkGetter\">\n <span\n [innerHTML]=\"col.valueGetter(item)\"\n class=\"cell-vertical-align-middle\"\n ></span>\n </ng-container>\n\n <ng-container *ngIf=\"!!col.routerLinkGetter\">\n <a\n [routerLink]=\"col.routerLinkGetter(item)\"\n queryParamsHandling=\"merge\"\n class=\"cell-vertical-align-middle\"\n >\n <span\n [innerHTML]=\"col.valueGetter(item)\"\n ></span>\n </a>\n </ng-container>\n </td>\n </tr>\n <tr *ngIf=\"!filteredList.length\">\n <td [colSpan]=\"columnsConfiguration.length\">\n <div class=\"w-100 text-center\">\n {{ 'foehn-table.totalElements.0' | fromDictionary }}\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n\n <div class=\"row d-flex justify-content-between p-1\">\n <div class=\"col-lg-3 col-md-3 col-sm-6 col-xs-6\">\n <nav\n class=\"vd-pagination\"\n aria-label=\"Pagination\"\n *ngIf=\"hasPreviousPage()\"\n >\n <ul class=\"vd-pagination__list\">\n <li\n class=\"vd-pagination__item vd-pagination__item--previous\"\n >\n <button\n class=\"btn-link vd-pagination__link btn-no-extra vd-pagination__link-reset\"\n (click)=\"previousPage()\"\n >\n <span class=\"vd-pagination__title\">\n <foehn-icon-chevron-left></foehn-icon-chevron-left>\n {{ previousLabel }}\n </span>\n <span class=\"sr-only\">:</span>\n <span class=\"vd-pagination__label\">\n {{ currentPage - 1 }} sur {{ pagesCount() }}\n </span>\n </button>\n </li>\n </ul>\n </nav>\n </div>\n\n <div class=\"col-lg-3 col-md-3 col-sm-6 col-xs-6\">\n <nav\n class=\"vd-pagination\"\n aria-label=\"Pagination\"\n *ngIf=\"hasNextPage()\"\n >\n <ul class=\"vd-pagination__list\">\n <li\n class=\"vd-pagination__item vd-pagination__item--next\"\n >\n <button\n class=\"btn-link vd-pagination__link btn-no-extra vd-pagination__link-reset\"\n (click)=\"nextPage()\"\n >\n <span class=\"vd-pagination__title\">\n {{ nextLabel }}\n <foehn-icon-chevron-right></foehn-icon-chevron-right>\n </span>\n <span class=\"sr-only\">:</span>\n <span class=\"vd-pagination__label\">\n {{ currentPage + 1 }} sur {{ pagesCount() }}\n </span>\n </button>\n </li>\n </ul>\n </nav>\n </div>\n </div>\n </div>\n</div>\n", styles: [".btn-no-extra{padding:0;border:none;font-weight:400;-webkit-text-decoration-line:none;text-decoration-line:none}.vd-pagination__link-reset{background:none;border:none;font-weight:inherit;-webkit-text-decoration-line:none;text-decoration-line:none;text-align:inherit;cursor:pointer}.vd-pagination__link-reset:focus{background-color:#ffbf47}.cell-vertical-align-middle{vertical-align:middle}\n"], components: [{ type: FoehnIconChevronUpComponent, selector: "foehn-icon-chevron-up" }, { type: FoehnIconChevronDownComponent, selector: "foehn-icon-chevron-down" }, { type: FoehnIconChevronLeftComponent, selector: "foehn-icon-chevron-left" }, { type: FoehnIconChevronRightComponent, selector: "foehn-icon-chevron-right" }], directives: [{ type: i3__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1__namespace$1.RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: ["routerLink", "target", "queryParams", "fragment", "queryParamsHandling", "preserveFragment", "skipLocationChange", "replaceUrl", "state", "relativeTo"] }], pipes: { "fromDictionary": SdkDictionaryPipe } });
9828
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: FoehnTableComponent, decorators: [{
9829
+ type: i0.Component,
9830
+ args: [{
9831
+ selector: 'foehn-table',
9832
+ templateUrl: './foehn-table.component.html',
9833
+ styleUrls: ['./foehn-table.component.css']
9834
+ }]
9835
+ }], propDecorators: { itemsPerPage: [{
9836
+ type: i0.Input
9837
+ }], id: [{
9838
+ type: i0.Input
9839
+ }], previousLabel: [{
9840
+ type: i0.Input
9841
+ }], nextLabel: [{
9842
+ type: i0.Input
9843
+ }], totalElements: [{
9844
+ type: i0.Input
9845
+ }], fixedPageCount: [{
9846
+ type: i0.Input
9847
+ }], columnsConfiguration: [{
9848
+ type: i0.Input
9849
+ }], pageChange: [{
9850
+ type: i0.Output
9851
+ }], sort: [{
9852
+ type: i0.Input
9853
+ }], sortChange: [{
9854
+ type: i0.Output
9855
+ }],
9856
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9857
+ trackByFn: [{
9858
+ type: i0.Input
9859
+ }], list: [{
9860
+ type: i0.Input
9861
+ }] } });
9862
+
9863
+ var FoehnTableModule = /** @class */ (function () {
9864
+ function FoehnTableModule() {
9865
+ }
9866
+ return FoehnTableModule;
9867
+ }());
9868
+ FoehnTableModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: FoehnTableModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
9869
+ FoehnTableModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: FoehnTableModule, declarations: [FoehnTableComponent], imports: [i3.CommonModule,
9870
+ FoehnIconsModule,
9871
+ SdkDictionaryModule,
9872
+ i1$1.RouterModule], exports: [FoehnTableComponent] });
9873
+ FoehnTableModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: FoehnTableModule, imports: [[
9874
+ i3.CommonModule,
9875
+ FoehnIconsModule,
9876
+ SdkDictionaryModule,
9877
+ i1$1.RouterModule
9878
+ ]] });
9879
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.4", ngImport: i0__namespace, type: FoehnTableModule, decorators: [{
9880
+ type: i0.NgModule,
9881
+ args: [{
9882
+ imports: [
9883
+ i3.CommonModule,
9884
+ FoehnIconsModule,
9885
+ SdkDictionaryModule,
9886
+ i1$1.RouterModule
9887
+ ],
9888
+ declarations: [FoehnTableComponent],
9889
+ exports: [FoehnTableComponent]
9890
+ }]
9891
+ }] });
9892
+
9893
+ var FoehnTableColumnConfiguration = /** @class */ (function () {
9894
+ function FoehnTableColumnConfiguration() {
9895
+ }
9896
+ return FoehnTableColumnConfiguration;
9897
+ }());
9898
+
9899
+ var FoehnTablePageChangeEvent = /** @class */ (function () {
9900
+ function FoehnTablePageChangeEvent() {
9901
+ }
9902
+ return FoehnTablePageChangeEvent;
9903
+ }());
9904
+
9905
+ var TableSort = /** @class */ (function () {
9906
+ function TableSort() {
9907
+ }
9908
+ return TableSort;
9909
+ }());
9910
+
9715
9911
  var RedirectComponent = /** @class */ (function () {
9716
9912
  function RedirectComponent(iamInterceptor) {
9717
9913
  var _this = this;
@@ -13115,6 +13311,10 @@
13115
13311
  exports.FoehnRemainingAlertsSummaryModule = FoehnRemainingAlertsSummaryModule;
13116
13312
  exports.FoehnSelectComponent = FoehnSelectComponent;
13117
13313
  exports.FoehnSkipLinkComponent = FoehnSkipLinkComponent;
13314
+ exports.FoehnTableColumnConfiguration = FoehnTableColumnConfiguration;
13315
+ exports.FoehnTableComponent = FoehnTableComponent;
13316
+ exports.FoehnTableModule = FoehnTableModule;
13317
+ exports.FoehnTablePageChangeEvent = FoehnTablePageChangeEvent;
13118
13318
  exports.FoehnTimeComponent = FoehnTimeComponent;
13119
13319
  exports.FoehnUserConnectedAsComponent = FoehnUserConnectedAsComponent;
13120
13320
  exports.FoehnUserConnectedAsModule = FoehnUserConnectedAsModule;
@@ -13179,6 +13379,7 @@
13179
13379
  exports.Street = Street;
13180
13380
  exports.StreetNumber = StreetNumber;
13181
13381
  exports.THOUSANDS_SEPARATOR = THOUSANDS_SEPARATOR;
13382
+ exports.TableSort = TableSort;
13182
13383
  exports.UploaderHelper = UploaderHelper;
13183
13384
  exports.ValidationHandlerService = ValidationHandlerService;
13184
13385