-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
budgets: add component budget and accounts
* Adds brief and detail views for budget. * Adds list of acquisition accounts for current library on budget detail view. * Adds detail view for organisation. * Adds default budget option on organisation detail view. Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
- Loading branch information
1 parent
83895cb
commit 666c71b
Showing
22 changed files
with
770 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
projects/admin/src/app/record/brief-view/budgets-brief-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2019 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { Component, Input } from '@angular/core'; | ||
import { ResultItem } from '@rero/ng-core'; | ||
|
||
@Component({ | ||
selector: 'admin-budgets-brief-view', | ||
template: ` | ||
<h5 class="card-title mb-0 rero-ils-person"> | ||
<a [routerLink]="[detailUrl.link]" class="pr-1">{{ record.metadata.name }}</a> | ||
</h5> | ||
`, | ||
styles: [] | ||
}) | ||
export class BudgetsBriefViewComponent implements ResultItem { | ||
|
||
@Input() | ||
record: any; | ||
|
||
@Input() | ||
type: string; | ||
|
||
@Input() | ||
detailUrl: { link: string, external: boolean }; | ||
} |
41 changes: 41 additions & 0 deletions
41
...dmin/src/app/record/detail-view/budget-detail-view/acq-account/acq-account.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- | ||
RERO ILS UI | ||
Copyright (C) 2019 RERO | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<div class="row"> | ||
<div class="col-sm-7"> | ||
<h5 class="mb-0">{{ account.metadata.name }}</h5> | ||
{{ account.metadata.description }} | ||
</div> | ||
<div class="col-sm-2 text-right"> | ||
{{ account.metadata.amount_allocated | currency:currencyCode:'symbol' }} | ||
</div> | ||
<div class="col-sm-3 text-right"> | ||
<button *ngIf="!account.permissions.cannot_update" type="button" class="btn btn-primary btn-sm" | ||
[routerLink]="['/records', 'acq_accounts', 'edit', account.metadata.pid]"> | ||
<i class="fa fa-pencil"></i> {{ 'Edit' | translate }} | ||
</button> | ||
|
||
<button *ngIf="!account.permissions.cannot_delete; else notDelete" type="button" class="btn btn-primary btn-sm ml-1" | ||
(click)="delete(account.metadata.pid)"> | ||
<i class="fa fa-trash"></i> {{ 'Delete' | translate }} | ||
</button> | ||
<ng-template #notDelete> | ||
<button type="button" class="btn btn-dark btn-sm ml-1" (click)="showDeleteMessage(account)"> | ||
<i class="fa fa-trash"></i> {{ 'Delete' | translate }} | ||
</button> | ||
</ng-template> | ||
</div> | ||
</div> |
59 changes: 59 additions & 0 deletions
59
.../admin/src/app/record/detail-view/budget-detail-view/acq-account/acq-account.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2019 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { Component, Input, Output, EventEmitter } from '@angular/core'; | ||
import { RecordUiService } from '@rero/ng-core'; | ||
import { RecordPermissionMessageService } from 'projects/admin/src/app/service/record-permission-message.service'; | ||
|
||
@Component({ | ||
selector: 'admin-acq-account', | ||
templateUrl: './acq-account.component.html' | ||
}) | ||
export class AcqAccountComponent { | ||
|
||
@Input() account: any; | ||
|
||
@Input() currencyCode: string; | ||
|
||
@Output() deleteAcqAccount = new EventEmitter(); | ||
|
||
constructor( | ||
private recordUiService: RecordUiService, | ||
private recordPermissionMessage: RecordPermissionMessageService | ||
) { } | ||
|
||
/** | ||
* Delete Acquisition account | ||
* @param acqAccountPid - Acquisition account pid | ||
*/ | ||
delete(acqAccountPid: string) { | ||
this.recordUiService.deleteRecord('acq_accounts', acqAccountPid) | ||
.subscribe((success: any) => { | ||
if (success) { | ||
this.deleteAcqAccount.emit(acqAccountPid); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Display message if the record cannot be deleted | ||
* @param acqAccount - Acquisition Account record | ||
*/ | ||
public showDeleteMessage(acqAccount: object) { | ||
const message = this.recordPermissionMessage.generateMessage(acqAccount); | ||
this.recordUiService.showDeleteMessage(message); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...in/src/app/record/detail-view/budget-detail-view/acq-accounts/acq-accounts.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!-- | ||
RERO ILS UI | ||
Copyright (C) 2019 RERO | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<h4 class="mt-4" translate>Acquisition accounts</h4> | ||
<a | ||
class="btn btn-sm btn-primary" | ||
[routerLink]="['/', 'records', 'acq_accounts', 'new']" | ||
[queryParams]="{ budget: budgetPid }" | ||
> | ||
<i class="fa fa-plus-square-o"></i> {{ 'Add' | translate }} | ||
</a> | ||
<ng-container *ngIf="accounts"> | ||
<ul class="list-group list-group-flush mt-3"> | ||
<li class="list-group-item" *ngFor="let account of accounts"> | ||
<admin-acq-account | ||
[account]="account" | ||
[currencyCode]="currencyCode" | ||
(deleteAcqAccount)="delete($event)" | ||
></admin-acq-account> | ||
</li> | ||
</ul> | ||
</ng-container> |
68 changes: 68 additions & 0 deletions
68
...dmin/src/app/record/detail-view/budget-detail-view/acq-accounts/acq-accounts.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2019 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
import { UserService } from 'projects/admin/src/app/service/user.service'; | ||
import { RecordService } from '@rero/ng-core'; | ||
import { map, mergeMap } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'admin-acq-accounts', | ||
templateUrl: './acq-accounts.component.html' | ||
}) | ||
export class AcqAccountsComponent implements OnInit { | ||
|
||
@Input() budgetPid: string; | ||
|
||
accounts: Array<any>; | ||
|
||
currencyCode: string; | ||
|
||
constructor( | ||
private userService: UserService, | ||
private recordService: RecordService | ||
) { } | ||
|
||
ngOnInit() { | ||
this.loadAcqAccounts(); | ||
} | ||
|
||
delete(acqAccountPid: string) { | ||
this.accounts = this.accounts.filter( | ||
acqAccount => acqAccountPid !== acqAccount.metadata.pid | ||
); | ||
} | ||
|
||
private loadAcqAccounts() { | ||
const currentLibrary = this.userService.getCurrentUser().getCurrentLibrary(); | ||
this.recordService.getRecord('libraries', currentLibrary, 1).pipe( | ||
map(library => { | ||
return library.metadata.organisation.pid; | ||
}), | ||
mergeMap(orgPid => this.recordService.getRecord('organisations', orgPid)) | ||
).subscribe(organisation => { | ||
this.currencyCode = organisation.metadata.default_currency; | ||
const query = `budget.pid:${this.budgetPid} AND library.pid:${currentLibrary}`; | ||
this.recordService.getRecords( | ||
'acq_accounts', query, 1, RecordService.MAX_REST_RESULTS_SIZE | ||
).subscribe(result => { | ||
if (result.hits.total > 0) { | ||
this.accounts = result.hits.hits; | ||
} | ||
}); | ||
}); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...cts/admin/src/app/record/detail-view/budget-detail-view/budget-detail-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- | ||
RERO ILS UI | ||
Copyright (C) 2019 RERO | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, version 3 of the License. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
<ng-container *ngIf="record$ | async as record"> | ||
<header class="row"> | ||
<h1 class="mb-1">{{ record.metadata.name }}</h1> | ||
</header> | ||
<section> | ||
<admin-acq-accounts | ||
[budgetPid]="record.metadata.pid" | ||
></admin-acq-accounts> | ||
</section> | ||
</ng-container> |
30 changes: 30 additions & 0 deletions
30
projects/admin/src/app/record/detail-view/budget-detail-view/budget-detail-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* RERO ILS UI | ||
* Copyright (C) 2019 RERO | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import { Component } from '@angular/core'; | ||
import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'admin-budget-detail-view', | ||
templateUrl: './budget-detail-view.component.html' | ||
}) | ||
export class BudgetDetailViewComponent implements DetailRecord { | ||
|
||
record$: Observable<any>; | ||
|
||
type: string; | ||
} |
Oops, something went wrong.