Skip to content

Commit

Permalink
chore: in progress
Browse files Browse the repository at this point in the history
* Adapts for the new ng-core (primeng).
* Removes ngx-toasts.
* Adds primeng toast.
* Removes ngx-bootstrap modal and service.
* Adds dialog from primeng.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Sep 24, 2024
1 parent 5b9fc2e commit eb2bbe3
Show file tree
Hide file tree
Showing 88 changed files with 1,422 additions and 1,838 deletions.
25 changes: 18 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"moment": "^2.30.1",
"ngx-bootstrap": "^12.0.0",
"ngx-spinner": "^16.0.0",
"ngx-toastr": "^18.0.0",
"primeflex": "^3.3.1",
"primeicons": "^6.0.1",
"primeng": "^17.14.1",
Expand Down Expand Up @@ -133,6 +132,7 @@
"karma-jasmine-html-reporter": "~2.1.0",
"karma-spec-reporter": "0.0.36",
"ng-packagr": "^17.1.1",
"primelocale": "^1.0.3",
"typescript": "~5.3.3"
},
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { UserService } from '@rero/shared';
import { ToastrService } from 'ngx-toastr';
import { Component, EventEmitter, inject, Input, OnInit, Output } from '@angular/core';
import { RecordPermissions } from '@app/admin/classes/permissions';
import { OrganisationService } from '@app/admin/service/organisation.service';
import { RecordPermissionService } from '@app/admin/service/record-permission.service';
import { IAcqAccount } from '../../../classes/account';
import { TranslateService } from '@ngx-translate/core';
import { UserService } from '@rero/shared';
import { MessageService } from 'primeng/api';
import { AcqAccountApiService } from '../../../api/acq-account-api.service';
import { IAcqAccount } from '../../../classes/account';

@Component({
selector: 'admin-account-brief-view',
Expand All @@ -33,6 +33,8 @@ import { AcqAccountApiService } from '../../../api/acq-account-api.service';
})
export class AccountBriefViewComponent implements OnInit {

private messageService = inject(MessageService);

// COMPONENT ATTRIBUTES ========================================================
/** the account to display */
@Input() account: IAcqAccount = null;
Expand Down Expand Up @@ -72,15 +74,13 @@ export class AccountBriefViewComponent implements OnInit {
* @param recordPermissionService - RecordPermissionService
* @param organisationService - OrganisationService
* @param accountApiService - AcqAccountApiService
* @param toastrService - ToastrService
* @param translateService - TranslateService
* @param userService - UserService
*/
constructor(
private recordPermissionService: RecordPermissionService,
private organisationService: OrganisationService,
private accountApiService: AcqAccountApiService,
private toastrService: ToastrService,
private translateService: TranslateService,
private userService: UserService
) { }
Expand Down Expand Up @@ -108,7 +108,11 @@ export class AccountBriefViewComponent implements OnInit {
this.accountApiService
.delete(this.account.pid)
.subscribe(() => {
this.toastrService.success(this.translateService.instant('Account deleted'));
this.messageService.add({
severity: 'success',
summary: this.translateService.instant('Account'),
detail: this.translateService.instant('Account deleted')
});
this.deleteAccount.emit(this.account);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ <h1 translate>Acquisition accounts</h1>
<!-- EXPORT BUTTON -->
<ng-core-export-button
[exportOptions]="exportOptions"
[cssClass]="'btn btn-sm btn-outline-primary mr-2 ml-2'">
</ng-core-export-button>
/>
<!-- END EXPORT BUTTON -->
<!-- TRANSFER BUTTON -->
<a [routerLink]="['/', 'acquisition', 'accounts', 'transfer']"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*/

import { getCurrencySymbol } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { Component, inject, OnInit } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { OrganisationService } from '@app/admin/service/organisation.service';
import { TranslateService } from '@ngx-translate/core';
import { UserService } from '@rero/shared';
import { ToastrService } from 'ngx-toastr';
import { MessageService } from 'primeng/api';
import { AcqAccountApiService } from '../../../api/acq-account-api.service';
import { IAcqAccount } from '../../../classes/account';
import { orderAccountsAsTree } from '../../../utils/account';
Expand All @@ -35,6 +35,8 @@ import { orderAccountsAsTree } from '../../../utils/account';
})
export class AccountTransferComponent implements OnInit {

private messageService = inject(MessageService);

// COMPONENT ATTRIBUTES =======================================================
/** the accounts available for transfer */
accountsToDisplay: IAcqAccount[] = [];
Expand Down Expand Up @@ -65,7 +67,6 @@ export class AccountTransferComponent implements OnInit {
* @param acqAccountApiService - AcqAccountApiService
* @param organisationService - OrganisationService
* @param formBuilder - FormBuilder,
* @param toastrService - ToastrService,
* @param translateService - TranslateService
* @param router - Router
* @param userService - UserService
Expand All @@ -74,7 +75,6 @@ export class AccountTransferComponent implements OnInit {
private acqAccountApiService: AcqAccountApiService,
private organisationService: OrganisationService,
private formBuilder: UntypedFormBuilder,
private toastrService: ToastrService,
private translateService: TranslateService,
private router: Router,
private userService: UserService
Expand Down Expand Up @@ -123,13 +123,21 @@ export class AccountTransferComponent implements OnInit {
submit(): void {
this.acqAccountApiService
.transferFunds(this.form.value.source.pid, this.form.value.target.pid, this.form.value.amount)
.subscribe(
() => {
this.toastrService.success(this.translateService.instant('Fund transfer successful!'));
.subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: this.translateService.instant('Account'),
detail: this.translateService.instant('Fund transfer successful!')
});
this.router.navigate(['/', 'acquisition', 'accounts']);
},
(err) => { this.toastrService.error(this.translateService.instant(err.error.message)); }
);
error: (err) => this.messageService.add({
severity: 'error',
summary: this.translateService.instant('Account'),
detail:this.translateService.instant(err.error.message)
}),
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ViewportScroller } from '@angular/common';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Component, inject, OnDestroy, OnInit } from '@angular/core';
import { AcqOrderApiService } from '@app/admin/acquisition/api/acq-order-api.service';
import { RecordPermissions } from '@app/admin/classes/permissions';
import { RecordPermissionService } from '@app/admin/service/record-permission.service';
import { CurrentLibraryPermissionValidator } from '@app/admin/utils/permissions';
import { extractIdOnRef } from '@rero/ng-core';
import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record';
import { BsModalService } from 'ngx-bootstrap/modal';
import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
import { Observable, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import { AcqOrderHistoryVersion, AcqOrderHistoryVersionResponseInterface, AcqOrderStatus, IAcqOrder } from '../../../classes/order';
import { OrderEmailFormComponent } from '../order-email-form/order-email-form.component';
import { extractIdOnRef } from '@rero/ng-core';

@Component({
selector: 'admin-acquisition-order-detail-view',
Expand All @@ -36,6 +36,12 @@ import { extractIdOnRef } from '@rero/ng-core';
})
export class OrderDetailViewComponent implements DetailRecord, OnInit, OnDestroy {

private dialogService = inject(DialogService);
private scroller = inject(ViewportScroller);
private recordPermissionService = inject(RecordPermissionService);
private acqOrderService = inject(AcqOrderApiService);
private permissionValidator = inject(CurrentLibraryPermissionValidator);

// COMPONENT ATTRIBUTES =====================================================
/** Observable resolving record data */
record$: Observable<any>;
Expand All @@ -57,6 +63,8 @@ export class OrderDetailViewComponent implements DetailRecord, OnInit, OnDestroy
/** all component subscription */
private subscriptions = new Subscription();

modalRef: DynamicDialogRef | undefined;

// GETTER & SETTER ==========================================================
/** Determine if the order could be "placed/ordered" */
get canPlaceOrder(): boolean {
Expand All @@ -68,22 +76,6 @@ export class OrderDetailViewComponent implements DetailRecord, OnInit, OnDestroy
return this.order.status !== AcqOrderStatus.PENDING;
}

// CONSTRUCTOR & HOOKS ======================================================
/** Constructor
* @param scroller - ViewportScroller
* @param modalService - BsModalService
* @param recordPermissionService - RecordPermissionService
* @param permissionValidator - CurrentLibraryPermissionValidator
* @param acqOrderService - AcqOrderApiService
*/
constructor(
private scroller: ViewportScroller,
private modalService: BsModalService,
private recordPermissionService: RecordPermissionService,
private acqOrderService: AcqOrderApiService,
private permissionValidator: CurrentLibraryPermissionValidator
) { }

/** OnInit hook */
ngOnInit() {
this.subscriptions.add(this.record$.subscribe(
Expand Down Expand Up @@ -131,18 +123,14 @@ export class OrderDetailViewComponent implements DetailRecord, OnInit, OnDestroy
* If the user submit the form (and submitting is success), then update the order to get the updated data.
*/
placeOrderDialog() {
const modalRef = this.modalService.show(OrderEmailFormComponent, {
ignoreBackdropClick: true,
keyboard: true,
class: 'modal-xl',
initialState: {
this.modalRef = this.dialogService.open(OrderEmailFormComponent, {
dismissableMask: true,
data: {
order: this.order
}
});
// Event to allow the closing of the dialog
modalRef.content.closeDialog.subscribe((close: boolean) => modalRef.hide());
modalRef.content.recordChange.subscribe((order: IAcqOrder) => {
if (this.order.pid === order.pid) {
this.modalRef.onClose.subscribe((order?: IAcqOrder) => {
if (order && this.order.pid === order.pid) {
if (order.vendor.$ref) {
order.vendor.pid = extractIdOnRef(order.vendor.$ref);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
[preview]="response.preview"
[previewPosition]="'bottom'"
[prePopulateRecipients]="suggestions.recipients"
(closeDialog)="closeEmailDialog()"
(closeDialog)="closeDialog()"
(data)="confirmOrder($event)"
>
<ng-container title>{{ 'Place order' | translate }}</ng-container>
Expand Down
Loading

0 comments on commit eb2bbe3

Please sign in to comment.