This commit introduces new padding options for document sizes, allowing for customizable print padding and specific padding values (left, right, top, bottom). The document size schema has been updated to include these new fields, and corresponding route handlers have been modified to handle padding data during document size creation and editing. Additionally, the template manager has been updated to apply padding when rendering templates, ensuring that the layout respects the specified padding values. Tests have been added to verify the correct application of padding in both document sizes and templates, improving the overall document formatting capabilities.
110 lines
3.4 KiB
JavaScript
110 lines
3.4 KiB
JavaScript
import express from 'express';
|
|
import { isAuthenticated } from '../../keycloak.js';
|
|
import { checkPermissions } from '../../database/permissions.js';
|
|
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
|
|
|
const router = express.Router();
|
|
|
|
const listAllowedFilters = [
|
|
'name',
|
|
'width',
|
|
'height',
|
|
'printPadding',
|
|
'paddingLeft',
|
|
'paddingRight',
|
|
'paddingTop',
|
|
'paddingBottom',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference',
|
|
];
|
|
const listAllowedSorters = [
|
|
'name',
|
|
'width',
|
|
'height',
|
|
'infiniteHeight',
|
|
'printPadding',
|
|
'paddingLeft',
|
|
'paddingRight',
|
|
'paddingTop',
|
|
'paddingBottom',
|
|
'createdAt',
|
|
'updatedAt',
|
|
];
|
|
const propertiesAllowedFilters = [];
|
|
import {
|
|
listDocumentSizesRouteHandler,
|
|
getDocumentSizeRouteHandler,
|
|
editDocumentSizeRouteHandler,
|
|
newDocumentSizeRouteHandler,
|
|
deleteDocumentSizeRouteHandler,
|
|
listDocumentSizesByPropertiesRouteHandler,
|
|
getDocumentSizeStatsRouteHandler,
|
|
getDocumentSizeHistoryRouteHandler,
|
|
searchDocumentSizesRouteHandler,
|
|
getDocumentSizePropertyValuesRouteHandler,
|
|
|
|
getDocumentSizeNeighborsRouteHandler
|
|
} from '../../services/management/documentsizes.js';
|
|
|
|
// list of document sizes
|
|
router.get('/', isAuthenticated, async (req, res) => {
|
|
const { page, limit, property, search, sort, order } = req.query;
|
|
const filter = await getFilter(req.query, listAllowedFilters);
|
|
listDocumentSizesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
|
});
|
|
|
|
router.get('/properties', checkPermissions('documentSize', 'list'), isAuthenticated, async (req, res) => {
|
|
let properties = convertPropertiesString(req.query.properties);
|
|
const filter = await getFilter(req.query, propertiesAllowedFilters, false);
|
|
var masterFilter = {};
|
|
if (req.query.masterFilter) {
|
|
masterFilter = JSON.parse(req.query.masterFilter);
|
|
}
|
|
listDocumentSizesByPropertiesRouteHandler(req, res, properties, filter, masterFilter);
|
|
});
|
|
|
|
router.get('/values', checkPermissions('documentSize', 'list'), isAuthenticated, async (req, res) => {
|
|
const { property } = req.query;
|
|
getDocumentSizePropertyValuesRouteHandler(req, res, property);
|
|
});
|
|
|
|
router.get('/search', checkPermissions('documentSize', 'list'), isAuthenticated, async (req, res) => {
|
|
const { search } = req.query;
|
|
searchDocumentSizesRouteHandler(req, res, search);
|
|
});
|
|
|
|
router.post('/', isAuthenticated, checkPermissions('documentSize', 'new'), async (req, res) => {
|
|
newDocumentSizeRouteHandler(req, res);
|
|
});
|
|
|
|
// get document size stats
|
|
router.get('/stats', isAuthenticated, async (req, res) => {
|
|
getDocumentSizeStatsRouteHandler(req, res);
|
|
});
|
|
|
|
// get documentsizes history
|
|
router.get('/history', isAuthenticated, async (req, res) => {
|
|
getDocumentSizeHistoryRouteHandler(req, res);
|
|
});
|
|
|
|
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
|
const { property, search, sort, order, id } = req.query;
|
|
const filter = await getFilter(req.query, listAllowedFilters);
|
|
getDocumentSizeNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
|
});
|
|
|
|
router.get('/:id', isAuthenticated, async (req, res) => {
|
|
getDocumentSizeRouteHandler(req, res);
|
|
});
|
|
|
|
router.put('/:id', isAuthenticated, checkPermissions('documentSize', 'edit'), async (req, res) => {
|
|
editDocumentSizeRouteHandler(req, res);
|
|
});
|
|
|
|
router.delete('/:id', isAuthenticated, async (req, res) => {
|
|
deleteDocumentSizeRouteHandler(req, res);
|
|
});
|
|
|
|
export default router;
|