Skip to content

Commit

Permalink
Merge pull request #108 from bcgov/ticdi-320
Browse files Browse the repository at this point in the history
Ticdi 320
  • Loading branch information
barrfalk authored Nov 1, 2023
2 parents c7fc043 + ac0ac12 commit a7f0143
Show file tree
Hide file tree
Showing 17 changed files with 670 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export class CreatePrintRequestLogDto extends PickType(PrintRequestLogDto, [
"document_template_id",
"print_request_detail_id",
"dtid",
"document_type",
"request_app_user",
"request_json",
"create_userid",
Expand Down
1 change: 1 addition & 0 deletions backend/src/print_request_log/dto/print_request_log.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export class PrintRequestLogDto {
document_template_id: number;
print_request_detail_id: number;
dtid: number;
document_type: string;
request_app_user: string;
request_json: string;
create_userid: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export class UpdatePrintRequestLogDto extends PickType(PrintRequestLogDto, [
"document_template_id",
"print_request_detail_id",
"dtid",
"document_type",
"request_app_user",
"request_json",
"update_userid",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class PrintRequestLog {
print_request_detail_id: number;
@Column({ nullable: true })
dtid: number;
@Column({nullable: true})
document_type: string;
@Column({ nullable: true })
request_app_user: string;
@Column({ nullable: true })
Expand All @@ -33,6 +35,7 @@ export class PrintRequestLog {
document_template_id?: number,
print_request_detail_id?: number,
dtid?: number,
document_type?: string,
request_app_user?: string,
request_json?: string,
create_userid?: string,
Expand All @@ -41,6 +44,7 @@ export class PrintRequestLog {
this.document_template_id = document_template_id || null;
this.print_request_detail_id = print_request_detail_id || null;
this.dtid = dtid || null;
this.document_type = document_type || "";
this.request_app_user = request_app_user || "";
this.request_json = request_json || "";
this.create_userid = create_userid || "";
Expand Down
6 changes: 3 additions & 3 deletions backend/src/print_request_log/print_request_log.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class PrintRequestLogController {
return this.printRequestLogService.findByDtid(+dtid);
}

@Get("version/:dtid")
findNextVersion(@Param("dtid") dtid: string): Promise<string> {
return this.printRequestLogService.findNextVersion(+dtid);
@Get("version/:dtid/:documentType")
findNextVersion(@Param("dtid") dtid: string, @Param("documentType") documentType: string): Promise<string> {
return this.printRequestLogService.findNextVersion(+dtid, documentType);
}
}
16 changes: 15 additions & 1 deletion backend/src/print_request_log/print_request_log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class PrintRequestLogService {
newItem.document_template_id = printRequestLog.document_template_id;
newItem.print_request_detail_id = printRequestLog.print_request_detail_id;
newItem.dtid = printRequestLog.dtid;
newItem.document_type = printRequestLog.document_type;
newItem.request_app_user = printRequestLog.request_app_user;
newItem.request_json = printRequestLog.request_json;
newItem.create_userid = printRequestLog.request_app_user; // same as request_app_user
Expand All @@ -37,10 +38,23 @@ export class PrintRequestLogService {
});
}

async findNextVersion(dtid: number): Promise<string> {
async findNextVersion(dtid: number, documentType: string): Promise<string> {
let fullDocumentType = "";
switch (documentType) {
case ("LUR"):
fullDocumentType = "LAND USE REPORT";
break;
case ("GL"):
fullDocumentType = "GRAZING LEASE";
break;
default:
fullDocumentType = "LAND USE REPORT";
break;
}
const requestLogs = await this.printRequestLogRepository.findAndCount({
where: {
dtid: dtid,
document_type: fullDocumentType
},
});
let version = (requestLogs[1] + 1).toString();
Expand Down
59 changes: 37 additions & 22 deletions frontend/public/js/manage-templates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var documentTable, groupMaxTable, provisionTable, editProvisionVariableTable;
var documentTable2, documentTable3, documentTable4, documentTable5;
var documentTable; // main template upload table
var groupMaxTable, provisionTable, editProvisionVariableTable;
var documentTable2, documentTable3, documentTable4, documentTable5; // nfr variants
var reportType = "";
var reportTitle = "";
var nfrDelayed = "NOTICE OF FINAL REVIEW (DELAYED)";
var nfrNoFees = "NOTICE OF FINAL REVIEW (NO FEES)";
var nfrSurveyReq = "NOTICE OF FINAL REVIEW (SURVEY REQUIRED)";
Expand All @@ -11,19 +13,23 @@ $(document).ready(function () {
if (reportIndex != 2) {
$(".nofr-section").hide();
}
reportType =
reportIndex == 1
? "LAND USE REPORT"
: reportIndex == 2
? "NOTICE OF FINAL REVIEW"
: "";
$("#reportTitle").text(
reportIndex == 1
? "Land Use Report"
: reportIndex == 2
? "Notice of Final Review"
: ""
);
switch (reportIndex) {
case 1:
reportType = "LAND USE REPORT";
reportTitle = "Land Use Report";
break;
case 2:
reportType = "NOTICE OF FINAL REVIEW";
reportTitle = "Notice of Final Review";
break;
case 3:
reportType = "GRAZING LEASE";
reportTitle = "Grazing Lease";
break;
default:
break;
}
$("#reportTitle").text(reportTitle);
// used for sorting the radio buttons
$.fn.dataTable.ext.order["dom-checkbox"] = function (settings, col) {
return this.api()
Expand Down Expand Up @@ -98,6 +104,7 @@ $(document).ready(function () {
},
order: [[0, "asc"]],
});
// nfr section
if (reportIndex == 2) {
documentTable2 = $("#documentTable2").DataTable({
ajax: {
Expand Down Expand Up @@ -577,12 +584,20 @@ function removeTemplate() {
const id = $("#document-template-id").val();
const urlParams = new URLSearchParams(window.location.search);
const reportIndex = parseInt(urlParams.get("report"));
const reportType =
reportIndex == 1
? "LAND USE REPORT"
: reportIndex == 2
? "NOTICE OF FINAL REVIEW"
: "";
let reportType = "";
switch (reportIndex) {
case 1:
reportType = "LAND USE REPORT";
break;
case 2:
reportType = "NOTICE OF FINAL REVIEW";
break;
case 3:
reportType = "GRAZING LEASE";
break;
default:
break;
}
fetch(`/admin/remove-template/${reportType}/${id}`, {
method: "GET",
})
Expand Down Expand Up @@ -921,7 +936,7 @@ function openEditModal() {
const provision_group = $(`#provision_group-${provisionId}`).val();
const max = $(`#max-${provisionId}`).val();
const provision_name = $(`#provision_name-${provisionId}`).val();
const free_text = $(`#free_text-${provisionId}`).data('fullval')
const free_text = $(`#free_text-${provisionId}`).data("fullval");
const help_text = $(`#help_text-${provisionId}`).val();
const category = $(`#category-${provisionId}`).val();
const variants = $(this).data("variants");
Expand Down
1 change: 1 addition & 0 deletions frontend/public/js/nfr.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ $(".legalDesc").each(function () {
});
if ($("#adminLink").text() == "-") {
$("#adminLink").hide();
$("#adminLink").text("");
}
groupMaxTable = $("#groupMaxTable").DataTable({
ajax: {
Expand Down
11 changes: 6 additions & 5 deletions frontend/public/js/util.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
async function generateReport() {
async function generateReport(documentType) {
const tenureFileNumber = $("#tfn").text();
const prdid = $("#prdid").text();
const dtid = $("#dtid").text();
$("#genReport").prop("disabled", true);
const reportName = await fetch(
`/report/get-report-name/${dtid}/${tenureFileNumber}`,
`/report/get-report-name/${dtid}/${tenureFileNumber}/${documentType}`,
{
method: "GET",
headers: {
Expand All @@ -20,12 +20,13 @@ async function generateReport() {
.catch(() => {
location.reload();
});
const document_type = $("#document_type_id option:selected").text();
console.log(reportName)
const data = {
prdid: prdid,
document_type: document_type,
dtid: dtid,
document_type: documentType,
};
fetch(`/report/generate-lur-report`, {
fetch(`/report/generate-report`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
Loading

0 comments on commit a7f0143

Please sign in to comment.