mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: mark specific template as default
This commit is contained in:
@@ -21,7 +21,6 @@ export class PdfTemplatesController extends BaseController {
|
||||
this.validationResult,
|
||||
this.deletePdfTemplate.bind(this)
|
||||
);
|
||||
|
||||
router.put(
|
||||
'/:template_id',
|
||||
[
|
||||
@@ -54,6 +53,12 @@ export class PdfTemplatesController extends BaseController {
|
||||
this.validationResult,
|
||||
this.createPdfInvoiceTemplate.bind(this)
|
||||
);
|
||||
router.post(
|
||||
'/:template_id/assign_default',
|
||||
[param('template_id').exists().isInt().toInt()],
|
||||
this.validationResult,
|
||||
this.assginPdfTemplateAsDefault.bind(this)
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
@@ -139,4 +144,29 @@ export class PdfTemplatesController extends BaseController {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
async assginPdfTemplateAsDefault(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
const { tenantId } = req;
|
||||
const { template_id: templateId } = req.params;
|
||||
|
||||
try {
|
||||
await this.pdfTemplateApplication.assignPdfTemplateAsDefault(
|
||||
tenantId,
|
||||
Number(templateId)
|
||||
);
|
||||
return res
|
||||
.status(204)
|
||||
.send({
|
||||
id: templateId,
|
||||
message:
|
||||
'The given pdf template has been assigned as default template',
|
||||
});
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user