Skip to content

Commit

Permalink
budgets: add component budget and accounts
Browse files Browse the repository at this point in the history
* 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
Garfield-fr committed Jan 24, 2020
1 parent f2b72d4 commit 97798f1
Show file tree
Hide file tree
Showing 26 changed files with 1,184 additions and 94 deletions.
156 changes: 78 additions & 78 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
"@biesbjerg/ngx-translate-extract": "^4.2.0",
"@biesbjerg/ngx-translate-extract-marker": "^1.0.0",
"@cospired/i18n-iso-languages": "^2.0.5",
"@ngx-formly/bootstrap": "^5.5.8",
"@ngx-formly/core": "^5.5.8",
"@ngx-formly/bootstrap": "^5.5.10",
"@ngx-formly/core": "^5.5.10",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"@rero/ng-core": "^0.0.25",
"@rero/ng-core": "^0.0.27",
"angular-datatables": "^8.0.0",
"bootstrap": "^4.3.1",
"crypto-js": "^3.1.9-1",
Expand All @@ -69,7 +69,7 @@
"jquery": "^3.4.1",
"lodash-es": "4.17.14",
"moment": "^2.24.0",
"ngx-bootstrap": "^5.2.0",
"ngx-bootstrap": "^5.3.2",
"ngx-toastr": "^10.2.0",
"ngx-toggle-switch": "^2.0.5",
"rxjs": "~6.4.0",
Expand Down
21 changes: 19 additions & 2 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ import { RemoteAutocompleteInputTypeComponent } from './record/editor/remote-aut
import { NoCacheHeaderInterceptor } from './interceptor/no-cache-header.interceptor';
import { InterfaceInfoComponent } from './interface-info/interface-info.component';
import { DocumentEditorComponent } from './record/custom-editor/document-editor/document-editor.component';
import { BudgetsBriefViewComponent } from './record/brief-view/budgets-brief-view.component';
import { BudgetDetailViewComponent } from './record/detail-view/budget-detail-view/budget-detail-view.component';
import { AcquisitionAccountsComponent } from './record/detail-view/budget-detail-view/acquisition-accounts/acquisition-accounts.component';
import { AcquisitionAccountComponent } from './record/detail-view/budget-detail-view/acquisition-account/acquisition-account.component';
import { OrganisationDetailViewComponent } from './record/detail-view/organisation-detail-view/organisation-detail-view.component';
import { BudgetSelectComponent } from './record/detail-view/organisation-detail-view/budget-select/budget-select.component';
import { BudgetSelectLineComponent } from './record/detail-view/organisation-detail-view/budget-select-line/budget-select-line.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -126,7 +133,14 @@ import { DocumentEditorComponent } from './record/custom-editor/document-editor/
PatronDetailViewComponent,
InterfaceInfoComponent,
RefComponent,
RemoteAutocompleteInputTypeComponent
RemoteAutocompleteInputTypeComponent,
BudgetsBriefViewComponent,
BudgetDetailViewComponent,
AcquisitionAccountsComponent,
AcquisitionAccountComponent,
OrganisationDetailViewComponent,
BudgetSelectComponent,
BudgetSelectLineComponent
],
imports: [
AppRoutingModule,
Expand Down Expand Up @@ -202,7 +216,10 @@ import { DocumentEditorComponent } from './record/custom-editor/document-editor/
ItemDetailViewComponent,
PatronDetailViewComponent,
RefComponent,
RemoteAutocompleteInputTypeComponent
RemoteAutocompleteInputTypeComponent,
BudgetsBriefViewComponent,
BudgetDetailViewComponent,
OrganisationDetailViewComponent
],
bootstrap: [AppComponent]
})
Expand Down
16 changes: 13 additions & 3 deletions projects/admin/src/app/menu/menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ export class MenuComponent implements OnInit {
routerLink: '/records/persons',
iconCssClass: 'fa fa-user'
}]
}, {
name: this.translateService.instant('Acquisitions'),
iconCssClass: 'fa fa-university',
entries: [{
name: this.translateService.instant('Budgets'),
routerLink: '/records/budgets',
}]
}, {
name: this.translateService.instant('Admin & Monitoring'),
iconCssClass: 'fa fa-cogs',
Expand All @@ -189,7 +196,11 @@ export class MenuComponent implements OnInit {
routerLink: '/records/patron_types',
iconCssClass: 'fa fa-users'
}, {
name: this.translateService.instant('My Library'),
name: this.translateService.instant('My organisation'),
routerLink: `/records/organisations/detail/${this.userService.getCurrentUser().library.organisation.pid}`,
iconCssClass: 'fa fa-university'
}, {
name: this.translateService.instant('My library'),
routerLink: this.myLibraryRouterLink(),
iconCssClass: 'fa fa-university'
}, {
Expand All @@ -202,11 +213,10 @@ export class MenuComponent implements OnInit {
};

this.localeStorageService.onSet$.subscribe(() => {
const link = this.linksMenu.entries[2].entries.find(
const link = this.linksMenu.entries[3].entries.find(
(element: any) => element.routerLink.indexOf('/libraries/detail') > -1
);
link.routerLink = this.myLibraryRouterLink();

});
}

Expand Down
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 };
}
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>
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);
}
}
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>
Loading

0 comments on commit 97798f1

Please sign in to comment.