@seniorsistemas/yms-integration 1.21.0 → 1.22.0

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.
@@ -1,4 +1,4 @@
1
- import { Subject, throwError, BehaviorSubject, empty, ReplaySubject, NEVER, of, forkJoin } from 'rxjs';
1
+ import { Subject, throwError, BehaviorSubject, empty, ReplaySubject, NEVER, forkJoin, of } from 'rxjs';
2
2
  import { takeUntil, catchError, finalize, map, filter, mergeMap, tap, concatMap, switchMap, debounceTime } from 'rxjs/operators';
3
3
  import { __extends, __decorate, __metadata, __assign, __spread, __values, __param } from 'tslib';
4
4
  import { CommonModule } from '@angular/common';
@@ -3069,13 +3069,15 @@ var DocumentService = /** @class */ (function (_super) {
3069
3069
  }(EntityService));
3070
3070
 
3071
3071
  var DocumentGridComponent = /** @class */ (function () {
3072
- function DocumentGridComponent(translate, documentService, messageService) {
3072
+ function DocumentGridComponent(translate, documentService, messageService, confirmationService) {
3073
3073
  this.translate = translate;
3074
3074
  this.documentService = documentService;
3075
3075
  this.messageService = messageService;
3076
+ this.confirmationService = confirmationService;
3076
3077
  this.viewDocument = new EventEmitter();
3077
3078
  this.gridData = [];
3078
3079
  this.ngUnsubscribe = new Subject();
3080
+ this.selection = [];
3079
3081
  }
3080
3082
  DocumentGridComponent.prototype.ngOnInit = function () {
3081
3083
  this.gridColumns = this.getGridColumns();
@@ -3091,6 +3093,7 @@ var DocumentGridComponent = /** @class */ (function () {
3091
3093
  {
3092
3094
  label: this.translate.instant("yms.int.wms_add_document_invoice_key"),
3093
3095
  command: function () {
3096
+ _this.selection = [];
3094
3097
  _this.visibleInvoiceKey = true;
3095
3098
  },
3096
3099
  icon: "fa fa-search"
@@ -3098,6 +3101,7 @@ var DocumentGridComponent = /** @class */ (function () {
3098
3101
  {
3099
3102
  label: this.translate.instant("yms.int.wms_add_document_register"),
3100
3103
  command: function () {
3104
+ _this.selection = [];
3101
3105
  _this.edit = true;
3102
3106
  _this.visibleDocumentRegister = true;
3103
3107
  },
@@ -3108,8 +3112,8 @@ var DocumentGridComponent = /** @class */ (function () {
3108
3112
  DocumentGridComponent.prototype.getProp = function (obj, path) {
3109
3113
  return path.split(".").reduce(function (result, prop) { return (result[prop] === undefined ? "" : result[prop]); }, obj);
3110
3114
  };
3111
- DocumentGridComponent.prototype.view = function (selection) {
3112
- this.viewDocument.emit(selection);
3115
+ DocumentGridComponent.prototype.view = function () {
3116
+ this.viewDocument.emit(this.selection[0]);
3113
3117
  this.visibleDocumentRegister = true;
3114
3118
  this.edit = false;
3115
3119
  };
@@ -3129,17 +3133,38 @@ var DocumentGridComponent = /** @class */ (function () {
3129
3133
  });
3130
3134
  }
3131
3135
  };
3132
- DocumentGridComponent.prototype.onDelete = function (selection) {
3136
+ DocumentGridComponent.prototype.onDelete = function () {
3133
3137
  var _this = this;
3134
- if (!selection.id) {
3135
- return;
3136
- }
3137
- this.documentService.delete(selection.id)
3138
- .pipe(takeUntil(this.ngUnsubscribe), finalize(function () {
3139
- _this.gridData = [];
3140
- _this.listDocuments();
3141
- })).
3142
- subscribe(function () { return _this.message("success", "deleted_message_title", "deleted_message_content"); });
3138
+ this.confirmationService.confirm({
3139
+ message: this.translate.instant("delete_confirmation_message"),
3140
+ header: this.translate.instant("delete_confirmation_title"),
3141
+ accept: function () {
3142
+ _this.removeDocumentIfIdUndfined();
3143
+ if (_this.selection.length < 1) {
3144
+ return empty();
3145
+ }
3146
+ return forkJoin(_this.selection.map(function (document) { return _this.documentService.delete(document.id); }))
3147
+ .pipe(takeUntil(_this.ngUnsubscribe))
3148
+ .subscribe(function () {
3149
+ _this.messageService.add({
3150
+ severity: "success",
3151
+ summary: _this.translate.instant("deleted_message_title"),
3152
+ detail: _this.translate.instant("deleted_message_content"),
3153
+ });
3154
+ _this.gridData = [];
3155
+ _this.listDocuments();
3156
+ });
3157
+ }
3158
+ });
3159
+ };
3160
+ DocumentGridComponent.prototype.removeDocumentIfIdUndfined = function () {
3161
+ var _this = this;
3162
+ this.selection.forEach(function (value, index) {
3163
+ if (!value.id) {
3164
+ _this.gridData.splice(index, 1);
3165
+ _this.selection.splice(index, 1);
3166
+ }
3167
+ });
3143
3168
  };
3144
3169
  DocumentGridComponent.prototype.listDocuments = function () {
3145
3170
  var _this = this;
@@ -3147,14 +3172,15 @@ var DocumentGridComponent = /** @class */ (function () {
3147
3172
  filterQuery: "schedulingId eq '" + this.agenda.id + "'"
3148
3173
  })
3149
3174
  .subscribe(function (contents) {
3175
+ _this.gridData = [];
3150
3176
  if (contents.totalElements > 0) {
3151
3177
  _this.gridData = contents.contents;
3152
3178
  _this.documentTotalRecords = contents.totalElements;
3153
3179
  }
3154
3180
  else {
3155
- _this.disabled = true;
3156
3181
  _this.documentTotalRecords = _this.gridData.length;
3157
3182
  }
3183
+ _this.disabled = true;
3158
3184
  _this.loading = false;
3159
3185
  });
3160
3186
  };
@@ -3220,12 +3246,13 @@ var DocumentGridComponent = /** @class */ (function () {
3220
3246
  DocumentGridComponent = __decorate([
3221
3247
  Component({
3222
3248
  selector: 'document-grid',
3223
- template: "<p-panel>\n <p-header>\n <div class=\"buttons\">\n <div>\n <s-button\n label=\"{{'yms.int.wms_add_document' | translate}}\"\n priority=\"primary\"\n [model]=\"getActions()\"\n [auxiliary]=\"false\">\n </s-button>\n <s-button\n label=\"{{'yms.wms_view_button' | translate}}\"\n priority=\"secondary\"\n [auxiliary]=\"false\"\n [disabled]=\"!selection || disabled\"\n (onClick)=\"view(selection)\">\n </s-button>\n <s-button\n label=\"{{'yms.wms_delete_button' | translate}}\"\n priority=\"secondary\"\n [auxiliary]=\"false\"\n [disabled]=\"!selection || disabled\"\n (click)=\"onDelete(selection)\">\n </s-button>\n </div>\n <s-button\n id=\"refresh-button\"\n priority=\"default\"\n iconClass=\"fa fa-refresh\"\n (onClick)=\"listDocuments()\"\n >\n </s-button>\n </div>\n </p-header>\n <div class=\"ui-g\">\n <div class=\"ui-g-12\" *ngIf=\"gridData && gridData.length; else emptyList\">\n <p-table #documentTable [value]=\"gridData\"\n [columns]=\"gridColumns\" dataKey=\"id\" [lazy]=\"true\" [scrollable]=\"true\" [resizableColumns]=\"true\"\n sortMode=\"single\" [paginator]=\"true\" [totalRecords]=\"documentTotalRecords\" rows=\"10\"\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\" [(selection)]=\"selection\"\n [loading]=\"loading\">\n <ng-template pTemplate=\"colgroup\" let-columns>\n <colgroup>\n <col *ngFor=\"let col of columns\" [style.width]=\"col.width\"/>\n </colgroup>\n </ng-template>\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th id=\"col\" *ngFor=\"let col of columns\" [pSortableColumn]=\"col.field\" pResizableColumn>\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ col.header }}</span>\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"body\" let-rowData let-columns let-expanded=\"expanded\">\n <tr [pSelectableRow]=\"rowData\">\n <td (click)=\"selection = rowData\">\n <span>{{ rowData[\"logistcUnitName\"] }}</span>\n </td>\n <td (click)=\"selection = rowData\">\n <span>{{ rowData[\"logistcUnitDocument\"] }}</span>\n </td>\n <td (click)=\"selection = rowData\">\n <span>{{ rowData[\"invoiceKey\"] }}</span>\n </td>\n <td (click)=\"selection = rowData\">\n <span>{{ rowData[\"invoiceNumber\"] }}</span>\n </td>\n <td (click)=\"selection = rowData\">\n <span>{{ rowData[\"invoiceSerialNumber\"] }}</span>\n </td>\n <td (click)=\"selection = rowData\">\n <span>{{ rowData[\"ownerName\"] }}</span>\n </td>\n <td (click)=\"selection = rowData\">\n <span>{{ rowData[\"ownerDocument\"] }}</span>\n </td>\n <td (click)=\"selection = rowData\">\n <span>{{ rowData[\"orderReceivingCode\"] }}</span>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"paginatorright\">\n <span [translate]=\"'total_records'\" [translateParams]=\"{ value: documentTotalRecords }\"></span>\n </ng-template>\n </p-table> \n </div>\n </div>\n <register-document\n [edit]=\"edit\"\n [viewDocument]=\"selection\"\n (document)=\"onChangeDocument($event)\"\n [(visible)]=\"visibleDocumentRegister\"\n [agenda]=\"agenda\">\n </register-document>\n <insert-key (document)=\"onChangeDocument($event)\" [(visible)]=\"visibleInvoiceKey\"></insert-key>\n</p-panel>\n<div class=\"button-save\">\n <s-button \n priority=\"primary\" [label]=\"'save' | translate\" [disabled]=\"!disabled || !this.gridData\" (click)=\"save()\">\n </s-button>\n</div>\n\n\n<ng-template #emptyList>\n <div class=\"center\">\n <s-empty-state\n iconClass=\"fa fa-exclamation-triangle\" [title]=\"'yms.dock.area_dock_empty_state_title' | translate\"\n [description]=\"'yms.dock.area_dock_empty_state_description' | translate\">\n </s-empty-state>\n </div>\n</ng-template>\n",
3224
- styles: [".buttons{display:flex;justify-content:space-between}.center{flex-direction:column;text-align:center}.ui-g{display:block}.button-save{margin:5px 0}#refresh-button{color:#fff}"]
3249
+ template: "<p-panel>\n <p-header>\n <div class=\"buttons\">\n <div>\n <s-button\n label=\"{{'yms.int.wms_add_document' | translate}}\"\n priority=\"primary\"\n [model]=\"getActions()\"\n [auxiliary]=\"false\">\n </s-button>\n <s-button\n label=\"{{'yms.wms_view_button' | translate}}\"\n priority=\"secondary\"\n [auxiliary]=\"false\"\n [disabled]=\"!selection || selection.length !== 1\"\n (onClick)=\"view()\">\n </s-button>\n <s-button\n label=\"{{'yms.wms_delete_button' | translate}}\"\n priority=\"secondary\"\n [disabled]=\"!selection || !selection.length\"\n (click)=\"onDelete()\">\n </s-button>\n </div>\n <s-button\n id=\"refresh-button\"\n priority=\"default\"\n iconClass=\"fa fa-refresh\"\n (onClick)=\"listDocuments()\"\n >\n </s-button>\n </div>\n </p-header>\n <div class=\"ui-g\">\n <div class=\"ui-g-12\" *ngIf=\"gridData && gridData.length; else emptyList\">\n <p-table #documentTable [value]=\"gridData\"\n [columns]=\"gridColumns\" dataKey=\"id\" [lazy]=\"true\" [scrollable]=\"true\" [resizableColumns]=\"true\"\n sortMode=\"multiple\" [paginator]=\"true\" [totalRecords]=\"documentTotalRecords\" rows=\"10\"\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\" [(selection)]=\"selection\"\n [loading]=\"loading\">\n <ng-template pTemplate=\"colgroup\" let-columns>\n <colgroup>\n <col *ngFor=\"let col of columns\" [style.width]=\"col.width\"/>\n </colgroup>\n </ng-template>\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th id=\"checkbox\" class=\"table-checkbox\">\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\n </th>\n <th id=\"col\" *ngFor=\"let col of columns\" [pSortableColumn]=\"col.field\" pResizableColumn>\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ col.header }}</span>\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"body\" let-rowData let-columns let-expanded=\"expanded\">\n <tr [pSelectableRow]=\"rowData\">\n <td class=\"table-checkbox\">\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\n </td>\n <td (click)=\"selection = [rowData]\">\n <span>{{ rowData[\"logistcUnitName\"] }}</span>\n </td>\n <td (click)=\"selection = [rowData]\">\n <span>{{ rowData[\"logistcUnitDocument\"] }}</span>\n </td>\n <td (click)=\"selection = [rowData]\">\n <span>{{ rowData[\"invoiceKey\"] }}</span>\n </td>\n <td (click)=\"selection = [rowData]\">\n <span>{{ rowData[\"invoiceNumber\"] }}</span>\n </td>\n <td (click)=\"selection = [rowData]\">\n <span>{{ rowData[\"invoiceSerialNumber\"] }}</span>\n </td>\n <td (click)=\"selection = [rowData]\">\n <span>{{ rowData[\"ownerName\"] }}</span>\n </td>\n <td (click)=\"selection = [rowData]\">\n <span>{{ rowData[\"ownerDocument\"] }}</span>\n </td>\n <td (click)=\"selection = [rowData]\">\n <span>{{ rowData[\"orderReceivingCode\"] }}</span>\n </td>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"paginatorright\">\n <span [translate]=\"'total_records'\" [translateParams]=\"{ value: documentTotalRecords }\"></span>\n </ng-template>\n </p-table> \n </div>\n </div>\n <register-document\n [edit]=\"edit\"\n [viewDocument]=\"selection\"\n (document)=\"onChangeDocument($event)\"\n [(visible)]=\"visibleDocumentRegister\"\n [agenda]=\"agenda\">\n </register-document>\n <insert-key (document)=\"onChangeDocument($event)\" [(visible)]=\"visibleInvoiceKey\"></insert-key>\n</p-panel>\n<div class=\"button-save\">\n <s-button \n priority=\"primary\" [label]=\"'save' | translate\" [disabled]=\"disabled || !this.gridData\" (click)=\"save()\">\n </s-button>\n</div>\n\n\n<ng-template #emptyList>\n <div class=\"center\">\n <s-empty-state\n iconClass=\"fa fa-exclamation-triangle\" [title]=\"'detail_empty_state_title' | translate\"\n [description]=\"'detail_empty_state_description' | translate\">\n </s-empty-state>\n </div>\n</ng-template>\n",
3250
+ styles: [".buttons{display:flex;justify-content:space-between}.center{flex-direction:column;text-align:center}.ui-g{display:block}.button-save{margin:5px 0}#refresh-button{color:#fff}.table-checkbox{width:50px}"]
3225
3251
  }),
3226
3252
  __metadata("design:paramtypes", [TranslateService,
3227
3253
  DocumentService,
3228
- MessageService])
3254
+ MessageService,
3255
+ ConfirmationService])
3229
3256
  ], DocumentGridComponent);
3230
3257
  return DocumentGridComponent;
3231
3258
  }());
@@ -3408,15 +3435,20 @@ var RegisterDocumentComponent = /** @class */ (function () {
3408
3435
  RegisterDocumentComponent.prototype.visibilityConfig = function () {
3409
3436
  if (!this.edit && this.visible) {
3410
3437
  this.formGroup.disable();
3411
- this.setValuesFormGroup(this.viewDocument);
3438
+ this.setValuesFormGroup(this.viewDocument[0]);
3412
3439
  this.setValueForPartner();
3413
3440
  this.hideSaveButton = true;
3414
3441
  return this.visible;
3415
3442
  }
3416
- return this.visible;
3443
+ if (this.formGroup !== undefined) {
3444
+ this.formGroup.enable();
3445
+ this.setValueForPartner();
3446
+ this.hideSaveButton = false;
3447
+ }
3417
3448
  };
3418
3449
  RegisterDocumentComponent.prototype.close = function () {
3419
3450
  this.visibleChange.emit(false);
3451
+ this.formGroup.reset();
3420
3452
  };
3421
3453
  RegisterDocumentComponent.prototype.setValuesFormGroup = function (document) {
3422
3454
  this.formGroup.get('invoiceKey').setValue(document.invoiceKey);
@@ -3466,13 +3498,13 @@ var RegisterDocumentComponent = /** @class */ (function () {
3466
3498
  RegisterDocumentComponent.prototype.successMessage = function () {
3467
3499
  this.messageService.add({
3468
3500
  severity: "success",
3469
- summary: this.translateService.instant("saved_message_title"),
3470
- detail: this.translateService.instant("saved_message_content"),
3501
+ summary: this.translateService.instant("yms.saved_message_title"),
3502
+ detail: this.translateService.instant("yms.int.wms_success_message_description"),
3471
3503
  });
3472
3504
  };
3473
3505
  __decorate([
3474
3506
  Input(),
3475
- __metadata("design:type", Document)
3507
+ __metadata("design:type", Array)
3476
3508
  ], RegisterDocumentComponent.prototype, "viewDocument", void 0);
3477
3509
  __decorate([
3478
3510
  Input(),
@@ -3569,7 +3601,7 @@ var InsertKeyComponent = /** @class */ (function () {
3569
3601
  return;
3570
3602
  }
3571
3603
  _this.document.emit(content.contents[0]);
3572
- _this.message("success", "yms.int.wms_insert_key_success_message_header", "yms.int.wms_insert_key_success_message_description");
3604
+ _this.message("success", "yms.int.wms_insert_key_success_message_header", "yms.int.wms_success_message_description");
3573
3605
  _this.formGroup.reset();
3574
3606
  });
3575
3607
  };
@@ -3598,7 +3630,7 @@ var InsertKeyComponent = /** @class */ (function () {
3598
3630
  InsertKeyComponent = __decorate([
3599
3631
  Component({
3600
3632
  selector: "insert-key",
3601
- template: "<form [formGroup]=\"formGroup\">\n <p-dialog [(visible)]=\"visible\" (visibleChange)=\"cancel()\">\n <p-header>{{'yms.insert_key_header' | translate}}</p-header>\n <div class=\"flex py-2 justify-content-center spacing-bottom\">\n <label for=\"key\">{{'yms.insert_key_label'}}</label>\n <input id=\"key\" class=\"size-input\" pInputText type=\"text\" formControlName=\"key\">\n </div>\n <div class=\"separator\"></div>\n <div class=\"spacing-top\">\n <s-button pButton label=\"{{'save' | translate}}\" (click)=\"add()\"></s-button>\n <s-button\n type=\"button\"\n class=\"ui-button-link\"\n pButton label=\"{{'cancel' | translate}}\"\n (click)=\"cancel()\">\n </s-button>\n </div>\n </p-dialog>\n</form>",
3633
+ template: "<form [formGroup]=\"formGroup\">\n <p-dialog [(visible)]=\"visible\" [modal]=\"true\" (visibleChange)=\"cancel()\">\n <p-header>{{'yms.int.wms_insert_key_header' | translate}}</p-header>\n <div class=\"flex py-2 justify-content-center spacing-bottom\">\n <label for=\"key\">{{'yms.int.wms_insert_key_label' | translate}}</label>\n <input id=\"key\" class=\"size-input\" pInputText type=\"text\" formControlName=\"key\">\n </div>\n <div class=\"separator\"></div>\n <div class=\"spacing-top\">\n <s-button pButton label=\"{{'save' | translate}}\" (click)=\"add()\"></s-button>\n <s-button\n type=\"button\"\n class=\"ui-button-link\"\n pButton label=\"{{'cancel' | translate}}\"\n (click)=\"cancel()\">\n </s-button>\n </div>\n </p-dialog>\n</form>",
3602
3634
  styles: [".spacing-top{margin-top:10px}.spacing-bottom{margin-bottom:10px}.separator{width:100%;margin:5px 0;height:1px;background-color:#ccc}.size-input{width:550px}"]
3603
3635
  }),
3604
3636
  __metadata("design:paramtypes", [FormBuilder,