diff --git a/src/app/clients/clients-view/clients-view.component.html b/src/app/clients/clients-view/clients-view.component.html index c353caed9..8f43e2507 100644 --- a/src/app/clients/clients-view/clients-view.component.html +++ b/src/app/clients/clients-view/clients-view.component.html @@ -108,7 +108,7 @@ - diff --git a/src/app/core/shell/toolbar/toolbar.component.html b/src/app/core/shell/toolbar/toolbar.component.html index 18b4231b3..6b7c39835 100644 --- a/src/app/core/shell/toolbar/toolbar.component.html +++ b/src/app/core/shell/toolbar/toolbar.component.html @@ -69,7 +69,7 @@ - + @@ -89,11 +89,11 @@ - + - + diff --git a/src/app/core/shell/toolbar/toolbar.component.ts b/src/app/core/shell/toolbar/toolbar.component.ts index 80c83bc6c..acd873a40 100644 --- a/src/app/core/shell/toolbar/toolbar.component.ts +++ b/src/app/core/shell/toolbar/toolbar.component.ts @@ -1,5 +1,5 @@ /** Angular Imports */ -import { Component, OnInit, Input, EventEmitter, Output, ViewChild, AfterViewInit, ElementRef, TemplateRef } from '@angular/core'; +import { Component, OnInit, Input, EventEmitter, Output, ViewChild, AfterViewInit, ElementRef, TemplateRef, AfterContentChecked, ChangeDetectorRef } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { MatSidenav } from '@angular/material/sidenav'; import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; @@ -25,7 +25,7 @@ import { ConfigurationWizardComponent } from '../../../configuration-wizard/conf templateUrl: './toolbar.component.html', styleUrls: ['./toolbar.component.scss'] }) -export class ToolbarComponent implements OnInit, AfterViewInit { +export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChecked { /* Reference of institution */ @ViewChild('institution') institution: ElementRef; @@ -64,7 +64,8 @@ export class ToolbarComponent implements OnInit, AfterViewInit { private authenticationService: AuthenticationService, private popoverService: PopoverService, private configurationWizardService: ConfigurationWizardService, - private dialog: MatDialog) { } + private dialog: MatDialog, + private changeDetector: ChangeDetectorRef) { } /** * Subscribes to breakpoint for handset. @@ -77,6 +78,10 @@ export class ToolbarComponent implements OnInit, AfterViewInit { }); } + ngAfterContentChecked(): void { + this.changeDetector.detectChanges(); + } + /** * Toggles the current state of sidenav. */ @@ -187,4 +192,10 @@ export class ToolbarComponent implements OnInit, AfterViewInit { }); } } + + navigateMenu(routePath: string): void { + console.log(routePath); + this.router.navigate([routePath]); + } + } diff --git a/src/app/products/loan-products/create-loan-product/create-loan-product.component.html b/src/app/products/loan-products/create-loan-product/create-loan-product.component.html index a6d8fe235..27ba07d38 100644 --- a/src/app/products/loan-products/create-loan-product/create-loan-product.component.html +++ b/src/app/products/loan-products/create-loan-product/create-loan-product.component.html @@ -63,9 +63,10 @@ PAYMENT ALLOCATION - diff --git a/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts b/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts index 3cb67d8e6..b07474f88 100644 --- a/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts +++ b/src/app/products/loan-products/create-loan-product/create-loan-product.component.ts @@ -13,7 +13,7 @@ import { LoanProductAccountingStepComponent } from '../loan-product-stepper/loan /** Custom Services */ import { ProductsService } from 'app/products/products.service'; import { LoanProducts } from '../loan-products'; -import { PaymentAllocation } from '../loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component'; +import { PaymentAllocation, PaymentAllocationTransactionType, PaymentAllocationTransactionTypes, PaymentAllocationTypes } from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model'; @Component({ selector: 'mifosx-create-loan-product', @@ -35,6 +35,9 @@ export class CreateLoanProductComponent implements OnInit { isAdvancedPaymentStrategy = false; paymentAllocation: PaymentAllocation[] = []; + transactionTypes: PaymentAllocationTransactionType[] = [ + PaymentAllocationTransactionTypes.DEFAULT_TRANSACTION + ]; /** * @param {ActivatedRoute} route Activated Route. diff --git a/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.html b/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.html index 9951034bc..c25f01d3d 100644 --- a/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.html +++ b/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.html @@ -63,10 +63,11 @@ PAYMENT ALLOCATION - diff --git a/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts b/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts index d34b3eed4..987007b8a 100644 --- a/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts +++ b/src/app/products/loan-products/edit-loan-product/edit-loan-product.component.ts @@ -14,7 +14,7 @@ import { LoanProductAccountingStepComponent } from '../loan-product-stepper/loan import { ProductsService } from 'app/products/products.service'; import { GlobalConfiguration } from 'app/system/configurations/global-configurations-tab/configuration.model'; import { LoanProducts } from '../loan-products'; -import { PaymentAllocation } from '../loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component'; +import { PaymentAllocation, PaymentAllocationTransactionType, PaymentAllocationTransactionTypes } from '../loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model'; @Component({ selector: 'mifosx-edit-loan-product', @@ -37,6 +37,9 @@ export class EditLoanProductComponent implements OnInit { isAdvancedPaymentStrategy = false; wasPaymentAllocationChanged = false; paymentAllocation: PaymentAllocation[] = []; + transactionTypes: PaymentAllocationTransactionType[] = [ + PaymentAllocationTransactionTypes.DEFAULT_TRANSACTION + ]; /** * @param {ActivatedRoute} route Activated Route. diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html index dfc2c98ec..21b3b7382 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.html @@ -1,32 +1,55 @@
+
- - Future Installment Allocation Rule - - - {{ installmentAllocation.name | translate }} - - - + + Transaction Type + + + {{ transactionTypeOption.name | translate }} + + + -
+
- +
- - - - + + + + - - - - + + + + - - -
Order {{ (rowIndex + 1) }} Order {{ (rowIndex + 1) }} Transaction Type {{ transactionType.name }} Payment Allocation {{ paymentAllocation.name }}
+ + + +
+ + + Future Installment Allocation Rule + + + {{ installmentAllocation.name | translate }} + + +
+
+ + +
diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts index e808de3fd..a86d7cf57 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/loan-product-payment-strategy-step.component.ts @@ -3,23 +3,7 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angu import { UntypedFormControl, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { MatTable } from '@angular/material/table'; -import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; - -interface PaymentCode { - name: string; - code: string; -} - -interface PaymentAllocationOrder { - paymentAllocationRule: string; - order: number; -} - -export interface PaymentAllocation { - transactionType: string; - paymentAllocationOrder: PaymentAllocationOrder[]; - futureInstallmentAllocationRule: string; -} +import { FutureInstallmentAllocationRules, PaymentAllocation, PaymentAllocationOrder, PaymentAllocationTransactionType, PaymentAllocationTransactionTypes, PaymentAllocationTypes, PaymentCode } from './payment-allocation-model'; @Component({ selector: 'mifosx-loan-product-payment-strategy-step', @@ -29,112 +13,64 @@ export interface PaymentAllocation { export class LoanProductPaymentStrategyStepComponent implements OnInit { @Input() loanProductsTemplate: any; + @Input() transactionType: PaymentAllocationTransactionType; @Output() paymentAllocation = new EventEmitter(); @Output() paymentAllocationChange = new EventEmitter(); - transactionTypesData: PaymentCode[] = []; - transactionTypeOptions: PaymentCode[] = []; + paymentAllocationsData: PaymentCode[] = []; installmentAllocationOptions: PaymentCode[] = []; + transactionTypeOptions: PaymentCode[] = []; - transactionType = new UntypedFormControl(''); + transactionTypeCtrl = new UntypedFormControl(''); futureInstallmentAllocationRule = new UntypedFormControl('', Validators.required); @ViewChild('table') table: MatTable; /** Columns to be displayed in the table. */ - displayedColumns: string[] = ['order', 'transactionName']; + displayedColumns: string[] = ['order', 'paymentAllocation']; - constructor(private dialog: MatDialog) { } + constructor() { } ngOnInit(): void { - this.transactionTypesData = []; + this.paymentAllocationsData = []; this.setOptions(); this.sendPaymentAllocation(); } setOptions(): void { - this.transactionTypeOptions = [ - { name: 'Past due penalty', code: 'PAST_DUE_PENALTY' }, - { name: 'Past due fee', code: 'PAST_DUE_FEE' }, - { name: 'Past due principal', code: 'PAST_DUE_PRINCIPAL' }, - { name: 'Past due interest', code: 'PAST_DUE_INTEREST' }, - { name: 'Due penalty', code: 'DUE_PENALTY' }, - { name: 'Due fee', code: 'DUE_FEE' }, - { name: 'Due principal', code: 'DUE_PRINCIPAL' }, - { name: 'Due interest', code: 'DUE_INTEREST' }, - { name: 'In advance penalty', code: 'IN_ADVANCE_PENALTY' }, - { name: 'In advance fee', code: 'IN_ADVANCE_FEE' }, - { name: 'In advance principal', code: 'IN_ADVANCE_PRINCIPAL' }, - { name: 'In advance interest', code: 'IN_ADVANCE_INTEREST' } - ]; - this.transactionTypesData = this.transactionTypeOptions; - - this.installmentAllocationOptions = [ - { name: 'Next Installment', code: 'NEXT_INSTALLMENT' }, - { name: 'Last Installment', code: 'LAST_INSTALLMENT' }, - { name: 'Reamortization', code: 'REAMORTIZATION' } - ]; - - this.futureInstallmentAllocationRule.patchValue('NEXT_INSTALLMENT'); - } - - addTransactionType(): void { - this.transactionTypeOptions.forEach((txType: PaymentCode) => { - if (txType.code === this.transactionType.value) { - this.transactionTypesData = [ - ...this.transactionTypesData, - txType - ]; - this.sendPaymentAllocation(); - this.removePaymentCode(txType); - this.resetTransactionType(); - } - }); - } - - removePaymentCode(txType: PaymentCode): void { - this.transactionTypeOptions = this.transactionTypeOptions.filter(({ code }) => code !== txType.code); - } - - resetTransactionType(): void { - this.transactionType.patchValue(''); - this.transactionType.markAsUntouched(); - } - - removeTransactionType(index: number) { - const transactionTypeName = this.transactionTypesData[index].name; - const dialogRef = this.dialog.open(DeleteDialogComponent, { - data: { deleteContext: transactionTypeName } - }); - dialogRef.afterClosed().subscribe((response: any) => { - if (response.delete) { - this.transactionTypesData.splice(index, 1); - this.transactionTypesData = this.transactionTypesData.concat([]); - this.transactionTypesData = [...this.transactionTypesData]; - this.sendPaymentAllocation(); - } - }); + this.paymentAllocationsData = PaymentAllocationTypes.options; + this.transactionTypeOptions = PaymentAllocationTransactionTypes.options; + this.transactionTypeCtrl.patchValue(this.transactionTypeOptions[0].code); + if (this.transactionType) { + this.transactionTypeCtrl.patchValue(this.transactionType.code); + } + this.installmentAllocationOptions = FutureInstallmentAllocationRules.options; + this.futureInstallmentAllocationRule.patchValue(this.installmentAllocationOptions[0].code); } dropTable(event: CdkDragDrop) { - const prevIndex = this.transactionTypesData.findIndex((d: any) => d === event.item.data); - moveItemInArray(this.transactionTypesData, prevIndex, event.currentIndex); - this.transactionTypesData = [...this.transactionTypesData]; + const prevIndex = this.paymentAllocationsData.findIndex((d: any) => d === event.item.data); + moveItemInArray(this.paymentAllocationsData, prevIndex, event.currentIndex); + this.paymentAllocationsData = [...this.paymentAllocationsData]; this.table.renderRows(); this.sendPaymentAllocation(); this.paymentAllocationChange.emit(true); } sendPaymentAllocation(): void { + let transactionTypeVal = PaymentAllocationTransactionTypes.DEFAULT_TRANSACTION.code; + if (this.transactionType) { + transactionTypeVal = this.transactionType.code; + } const paymentAllocationOrder: PaymentAllocationOrder[] = []; - this.transactionTypesData.forEach((txType: PaymentCode, index: number) => { + this.paymentAllocationsData.forEach((txType: PaymentCode, index: number) => { paymentAllocationOrder.push({ 'paymentAllocationRule': txType.code, order: (index + 1) }); }); const paymentAllocation: PaymentAllocation[] = []; paymentAllocation.push({ 'futureInstallmentAllocationRule': this.futureInstallmentAllocationRule.value, - 'transactionType': 'DEFAULT', + 'transactionType': transactionTypeVal, 'paymentAllocationOrder': paymentAllocationOrder }); diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model.ts b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model.ts new file mode 100644 index 000000000..adbcdc650 --- /dev/null +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-payment-strategy-step/payment-allocation-model.ts @@ -0,0 +1,53 @@ +export interface PaymentCode { + name: string; + code: string; +} + +export interface PaymentAllocationOrder { + paymentAllocationRule: string; + order: number; +} + +export interface PaymentAllocation { + transactionType: string; + paymentAllocationOrder: PaymentAllocationOrder[]; + futureInstallmentAllocationRule: string; +} + +export interface PaymentAllocationTransactionType { + name: string; + code: string; +} + +export class PaymentAllocationTransactionTypes { + public static DEFAULT_TRANSACTION: PaymentAllocationTransactionType = { name: 'Default', code: 'DEFAULT' }; + + public static options: PaymentCode[] = [ + this.DEFAULT_TRANSACTION + ]; +} + +export class PaymentAllocationTypes { + public static options: PaymentCode[] = [ + { name: 'Past due penalty', code: 'PAST_DUE_PENALTY' }, + { name: 'Past due fee', code: 'PAST_DUE_FEE' }, + { name: 'Past due principal', code: 'PAST_DUE_PRINCIPAL' }, + { name: 'Past due interest', code: 'PAST_DUE_INTEREST' }, + { name: 'Due penalty', code: 'DUE_PENALTY' }, + { name: 'Due fee', code: 'DUE_FEE' }, + { name: 'Due principal', code: 'DUE_PRINCIPAL' }, + { name: 'Due interest', code: 'DUE_INTEREST' }, + { name: 'In advance penalty', code: 'IN_ADVANCE_PENALTY' }, + { name: 'In advance fee', code: 'IN_ADVANCE_FEE' }, + { name: 'In advance principal', code: 'IN_ADVANCE_PRINCIPAL' }, + { name: 'In advance interest', code: 'IN_ADVANCE_INTEREST' } + ]; +} + +export class FutureInstallmentAllocationRules { + public static options: PaymentCode[] = [ + { name: 'Next Installment', code: 'NEXT_INSTALLMENT' }, + { name: 'Last Installment', code: 'LAST_INSTALLMENT' }, + { name: 'Reamortization', code: 'REAMORTIZATION' } + ]; +} diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.html b/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.html index f641f8402..1a2f5a25b 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.html +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.html @@ -37,7 +37,7 @@ - {{datatableColumn}} + {{ getInputName(datatableColumn) }} {{ formatValue(data, datatableColumn) }} diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.ts b/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.ts index a4789a714..068d74f1c 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.ts +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.ts @@ -256,4 +256,8 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges return ''; } + getInputName(attr: string): string { + return this.datatables.getName(attr); + } + } diff --git a/src/app/users/users-routing.module.ts b/src/app/users/users-routing.module.ts index 11b903692..2e3f66560 100644 --- a/src/app/users/users-routing.module.ts +++ b/src/app/users/users-routing.module.ts @@ -23,7 +23,7 @@ import { UserResolver } from './user.resolver'; const routes: Routes = [ Route.withShell([ { - path: 'users', + path: 'appusers', data: { title: extract('Users'), breadcrumb: 'Users' }, children: [ { diff --git a/src/app/users/users.service.ts b/src/app/users/users.service.ts index 6aed811f8..1eaf6b6f7 100644 --- a/src/app/users/users.service.ts +++ b/src/app/users/users.service.ts @@ -22,7 +22,7 @@ export class UsersService { * @returns {Observable} Users data */ getUsers(): Observable { - return this.http.get('/users'); + return this.http.get(`/users`); } /** diff --git a/src/assets/styles/_colours.scss b/src/assets/styles/_colours.scss index 6ed6d7f9c..085f09e0b 100644 --- a/src/assets/styles/_colours.scss +++ b/src/assets/styles/_colours.scss @@ -88,3 +88,7 @@ $error-log: #ffa726; color: $status-inactive; text-align: center; } + +.cdk-drag-placeholder { + background: $peter-river; +}