-
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
f2b72d4
commit 97798f1
Showing
26 changed files
with
1,184 additions
and
94 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
/* | ||
* 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 { | ||
|
||
/** | ||
* Record | ||
*/ | ||
@Input() | ||
record: any; | ||
|
||
/** | ||
* Type of record | ||
*/ | ||
@Input() | ||
type: string; | ||
|
||
/** | ||
* Detail Url | ||
*/ | ||
@Input() | ||
detailUrl: { link: string, external: boolean }; | ||
} |
41 changes: 41 additions & 0 deletions
41
...ord/detail-view/budget-detail-view/acquisition-account/acquisition-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)"> | ||
<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> |
91 changes: 91 additions & 0 deletions
91
...ecord/detail-view/budget-detail-view/acquisition-account/acquisition-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,91 @@ | ||
/* | ||
* 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, OnDestroy } from '@angular/core'; | ||
import { RecordUiService } from '@rero/ng-core'; | ||
import { RecordPermissionMessageService } from 'projects/admin/src/app/service/record-permission-message.service'; | ||
import { BudgetTotalService } from 'projects/admin/src/app/service/budget-total.service'; | ||
import { Subscription } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'admin-acquisition-account', | ||
templateUrl: './acquisition-account.component.html' | ||
}) | ||
export class AcquisitionAccountComponent implements OnDestroy { | ||
|
||
/** | ||
* Account record | ||
*/ | ||
@Input() account: any; | ||
|
||
/** | ||
* Currency code | ||
*/ | ||
@Input() currencyCode: string; | ||
|
||
/** | ||
* Event for delete acquisition account | ||
*/ | ||
@Output() deleteAcqAccount = new EventEmitter(); | ||
|
||
/** | ||
* Store some observables on Subcription | ||
*/ | ||
private _subcription = new Subscription(); | ||
|
||
/** | ||
* Constructor | ||
* @param _recordUiService - RecordUiService | ||
* @param _recordPermissionMessage - RecordPermissionMessageService | ||
* @param _budgetTotalService - BudgetTotalService | ||
*/ | ||
constructor( | ||
private _recordUiService: RecordUiService, | ||
private _recordPermissionMessage: RecordPermissionMessageService, | ||
private _budgetTotalService: BudgetTotalService | ||
) { } | ||
|
||
/** | ||
* On Destroy | ||
*/ | ||
ngOnDestroy() { | ||
this._subcription.unsubscribe(); | ||
} | ||
|
||
/** | ||
* Delete Acquisition account | ||
* @param acqAccountPid - Acquisition account pid | ||
*/ | ||
delete(acqAccount: any) { | ||
const acqAccountPid = acqAccount.metadata.pid; | ||
this._subcription.add(this._recordUiService.deleteRecord('acq_accounts', acqAccountPid) | ||
.subscribe((success: any) => { | ||
if (success) { | ||
this.deleteAcqAccount.emit(acqAccountPid); | ||
this._budgetTotalService.removeAmount(acqAccount.metadata.amount_allocated); | ||
} | ||
})); | ||
} | ||
|
||
/** | ||
* 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
...d/detail-view/budget-detail-view/acquisition-accounts/acquisition-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-acquisition-account | ||
[account]="account" | ||
[currencyCode]="currencyCode" | ||
(deleteAcqAccount)="delete($event)" | ||
></admin-acquisition-account> | ||
</li> | ||
</ul> | ||
</ng-container> |
Oops, something went wrong.