Documents and Notes for Clients, Loans and Clients (#1632)
Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
28d5d7595f
commit
cafe8fa73d
@@ -0,0 +1,35 @@
|
||||
<div class="tab-container mat-typography">
|
||||
|
||||
<h3>Notes</h3>
|
||||
|
||||
<div>
|
||||
<form #formRef="ngForm" [formGroup]="noteForm" fxLayout="row" fxLayoutAlign="start baseline" fxLayoutGap="20px"
|
||||
(ngSubmit)="addNote()">
|
||||
<mat-form-field fxFlex="calc(90%-20px)">
|
||||
<textarea required formControlName="note" matInput placeholder="Write a note ...." cdkTextareaAutosize cdkAutosizeMinRows="2"></textarea>
|
||||
</mat-form-field>
|
||||
<button mat-raised-button fxFlex color="primary" [disabled]="!noteForm.valid">
|
||||
<fa-icon icon="plus" class="m-r-10"></fa-icon>Add
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<mat-list>
|
||||
<mat-list-item *ngFor="let entityNote of entityNotes; let i=index;">
|
||||
<fa-icon icon="sticky-note" matListIcon></fa-icon>
|
||||
<h3 matLine>{{ entityNote.note }} </h3>
|
||||
<p matLine>
|
||||
<span>Created by: {{entityNote.createdByUsername}}</span><br />
|
||||
<span>Date: {{entityNote.createdOn | dateFormat}}</span>
|
||||
</p>
|
||||
<div fxLayout="row" fxLayoutAlign="flex-start">
|
||||
<button mat-button color="primary" (click)="editNote(entityNote.id, entityNote.note, i)">
|
||||
<fa-icon icon="edit"></fa-icon>
|
||||
</button>
|
||||
<button mat-button color="warn" (click)="deleteNote(entityNote.id, i)">
|
||||
<fa-icon icon="trash"></fa-icon>
|
||||
</button>
|
||||
</div>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
</div>
|
||||
@@ -0,0 +1,4 @@
|
||||
.tab-container {
|
||||
padding: 1%;
|
||||
margin: 1%;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EntityNotesTabComponent } from './entity-notes-tab.component';
|
||||
|
||||
describe('EntityNotesTabComponent', () => {
|
||||
let component: EntityNotesTabComponent;
|
||||
let fixture: ComponentFixture<EntityNotesTabComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ EntityNotesTabComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EntityNotesTabComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ClientsService } from 'app/clients/clients.service';
|
||||
import { LoansService } from 'app/loans/loans.service';
|
||||
import { SavingsService } from 'app/savings/savings.service';
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-entity-notes-tab',
|
||||
templateUrl: './entity-notes-tab.component.html',
|
||||
styleUrls: ['./entity-notes-tab.component.scss']
|
||||
})
|
||||
export class EntityNotesTabComponent implements OnInit {
|
||||
|
||||
@ViewChild('formRef', { static: true }) formRef: any;
|
||||
|
||||
@Input() entityId: string;
|
||||
@Input() entityNotes: any;
|
||||
|
||||
@Input() callbackAdd: (note: any) => void;
|
||||
@Input() callbackEdit: (noteId: string, note: string, index: number) => void;
|
||||
@Input() callbackDelete: (noteId: string, index: number) => void;
|
||||
|
||||
noteForm: FormGroup;
|
||||
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private savingsService: SavingsService,
|
||||
private loansService: LoansService,
|
||||
private clientsService: ClientsService,
|
||||
private dialog: MatDialog) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.createNoteForm();
|
||||
}
|
||||
|
||||
createNoteForm() {
|
||||
this.noteForm = this.formBuilder.group({
|
||||
'note': ['', Validators.required]
|
||||
});
|
||||
}
|
||||
|
||||
addNote() {
|
||||
this.callbackAdd(this.noteForm.value);
|
||||
this.formRef.resetForm();
|
||||
}
|
||||
|
||||
editNote(noteId: string, noteContent: string, index: number) {
|
||||
const editNoteDialogRef = this.dialog.open(FormDialogComponent, {
|
||||
data: { formfields: [{
|
||||
controlName: 'note',
|
||||
required: true,
|
||||
value: noteContent,
|
||||
controlType: 'input',
|
||||
label: 'Note'
|
||||
}],
|
||||
layout: {
|
||||
columns: 1,
|
||||
addButtonText: 'Confirm'
|
||||
},
|
||||
title: 'Edit Note'
|
||||
}
|
||||
});
|
||||
editNoteDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data && response.data.value.note !== noteContent) {
|
||||
this.callbackEdit(noteId, response.data.value, index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteNote(noteId: string, index: number) {
|
||||
const deleteNoteDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: `Note: ${this.entityNotes[index].note}` }
|
||||
});
|
||||
deleteNoteDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.callbackDelete(noteId, index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user