This commit is contained in:
Alexis Lahouze 2018-06-14 09:19:15 +02:00
parent 5f8cf9abbf
commit 65dcd7f453
6 changed files with 0 additions and 144 deletions

View File

@ -20,7 +20,6 @@ import { CategoryService } from './category.service';
import { OperationService } from './operation.service'; import { OperationService } from './operation.service';
import { OperationListComponent } from './operationList.component'; import { OperationListComponent } from './operationList.component';
import { OperationNewComponent } from './operationNew.component'; import { OperationNewComponent } from './operationNew.component';
import { OperationEditComponent } from './operationEdit.component';
import { OperationDeleteModalComponent } from './operationDeleteModal.component'; import { OperationDeleteModalComponent } from './operationDeleteModal.component';
import { OperationRoutes } from './operation.states'; import { OperationRoutes } from './operation.states';
@ -48,7 +47,6 @@ import { OperationRoutes } from './operation.states';
CategoryChartComponent, CategoryChartComponent,
OperationRowComponent, OperationRowComponent,
OperationListComponent, OperationListComponent,
OperationEditComponent,
OperationNewComponent, OperationNewComponent,
OperationDeleteModalComponent, OperationDeleteModalComponent,
], ],

View File

@ -4,7 +4,6 @@ import { Routes } from '@angular/router';
import { OperationListComponent } from './operationList.component'; import { OperationListComponent } from './operationList.component';
import { OperationNewComponent } from './operationNew.component'; import { OperationNewComponent } from './operationNew.component';
import { OperationEditComponent } from './operationEdit.component';
export const OperationRoutes: Routes = [{ export const OperationRoutes: Routes = [{
path: 'account/:accountId/operations', path: 'account/:accountId/operations',

View File

@ -1,20 +0,0 @@
// vim: set tw=80 ts=2 sw=2 sts=2 :
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'operation-edit',
template: `
<div>
<div class="row">
</div>
</div>
`
})
export class OperationEditComponent implements OnInit {
ngOnInit(): void {
}
}

View File

@ -1,63 +0,0 @@
// vim: set tw=80 ts=2 sw=2 sts=2:
import { Component, Input, ViewChild } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Operation } from './operation';
import { OperationFormComponent } from './operationForm.component';
@Component({
selector: 'operation-edit-modal',
template: `
<div class="modal-header">
<h3 class="modal-title" id="modal-title">{{ title() }}</h3>
</div>
<div class="modal-body" id="modal-body">
<operation-form [operation]="operation" (submit)="submit()" #operationForm="operationForm"></operation-form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" [disabled]="!operationForm.form.valid" (click)="submit()">
Save
</button>
<button class="btn btn-default" (click)="cancel()">
Cancel
</button>
</div>
`
})
export class OperationEditModalComponent {
@Input() operation: Operation;
@ViewChild('operationForm') operationForm: OperationFormComponent;
valid: boolean = false;
constructor(private activeModal: NgbActiveModal) {}
title(): string {
if(this.operation.id) {
return "Operation #" + this.operation.id;
} else {
return "New operation";
}
}
submit(): void {
let formModel = this.operationForm.form.value;
let operation = Object.assign({}, this.operation);
operation.id = this.operation.id;
operation.operation_date = formModel.operationDate;
operation.label = formModel.label;
operation.value = formModel.value;
operation.category = formModel.category;
this.activeModal.close(operation);
}
cancel(): void {
this.activeModal.dismiss("closed");
}
}

View File

@ -15,7 +15,6 @@ import { Account } from '../accounts/account';
import { AccountService } from '../accounts/account.service'; import { AccountService } from '../accounts/account.service';
import { Operation } from './operation'; import { Operation } from './operation';
import { OperationService } from './operation.service'; import { OperationService } from './operation.service';
import { OperationEditModalComponent } from './operationEditModal.component';
@Component({ @Component({
selector: 'operation-list', selector: 'operation-list',
@ -107,27 +106,6 @@ export class OperationListComponent implements OnInit {
//this.loadData(); //this.loadData();
} }
/*
* Add an empty operation.
*/
add() {
var operation = new Operation();
let accountId = this.route.snapshot.paramMap.get('accountId');
operation.account_id = +accountId;
// FIXME Alexis Lahouze 2017-06-15 i18n
const modal = this.ngbModal.open(OperationEditModalComponent, {
size: 'lg'
});
modal.componentInstance.operation = operation;
modal.result.then((operation: Operation) => {
this.save(operation);
}, (reason) => {
});
}
/* /*
* Load operations. * Load operations.
*/ */
@ -144,25 +122,4 @@ export class OperationListComponent implements OnInit {
this.operations = operations.reverse(); this.operations = operations.reverse();
}); });
} }
/*
* Save an operation and return a promise.
*/
save(operation) {
operation.confirmed = true;
return this.operationService.create(operation).subscribe(
(operation) => {
this.toastrService.success('Operation #' + operation.id + ' saved.');
//this.loadData();
this.logger.info('Reload route', this.router.url);
this.router.navigateByUrl(this.router.url);
}, (result) => {
this.toastrService.error(
'Error while saving operation: ' + result.message
);
}
);
}
} }

View File

@ -11,7 +11,6 @@ import { Account } from '../accounts/account';
import { Operation } from './operation'; import { Operation } from './operation';
import { OperationService } from './operation.service'; import { OperationService } from './operation.service';
import { OperationDeleteModalComponent } from './operationDeleteModal.component'; import { OperationDeleteModalComponent } from './operationDeleteModal.component';
import { OperationEditModalComponent } from './operationEditModal.component';
@Component({ @Component({
selector: 'tr[operation-row]', selector: 'tr[operation-row]',
@ -146,18 +145,4 @@ export class OperationRowComponent {
); );
}); });
}; };
modify(operation) {
// FIXME Alexis Lahouze 2017-06-15 i18n
const modal = this.ngbModal.open(OperationEditModalComponent, {
size: 'lg'
});
modal.componentInstance.operation = operation;
modal.result.then((operation: Operation) => {
this.save(operation);
}, (reason) => {
});
};
} }