More document templates code.

This commit is contained in:
Tom Butcher 2025-08-18 00:56:14 +01:00
parent e904cc10b4
commit e4ab4ea9c7
6 changed files with 427 additions and 4 deletions

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" viewBox="0 0 64 64"><path d="M4.098 71.551c5.422 5.426 11.763 5.489 17.102.161 3.719-3.719 7.626-12.355 10.53-15.945l6.498 6.53c2.612 2.643 5.814 2.654 8.358.099l4.099-4.13c2.555-2.586 2.538-5.689-.1-8.326L25.74 25.058c-2.643-2.649-5.777-2.674-8.363-.088l-4.093 4.119c-2.561 2.56-2.581 5.708.074 8.357l6.519 6.499c-3.559 2.904-12.195 6.791-15.909 10.504-5.328 5.339-5.296 11.706.13 17.102m14.21-39.074 2.43-2.384c.706-.7 1.474-.731 2.18-.026L45.596 52.72c.68.706.68 1.479-.051 2.211l-2.353 2.378c-.712.763-1.525.788-2.242.026l-7.503-7.528c-1.274-1.28-2.965-1.155-4.413.255-2.437 2.401-6.679 12.615-11.665 17.564-2.859 2.884-6.31 2.879-9.283-.063-2.916-2.948-2.953-6.435-.068-9.294 4.985-4.943 15.194-9.191 17.6-11.634 1.379-1.468 1.53-3.159.25-4.413l-7.56-7.54c-.711-.705-.711-1.493 0-2.205m-5.655 34.304c2.052 0 3.709-1.682 3.709-3.729a3.703 3.703 0 0 0-3.709-3.703c-2.046 0-3.728 1.657-3.728 3.703a3.745 3.745 0 0 0 3.728 3.729m37.082-13.117 15.103-15.097c3.62-3.626 3.547-7.991-.168-11.711L40.105 2.254c-3.551-3.551-9.537-2.107-10.76 3.28-3.019 13.052-3.048 14.119-7.942 20.958l4.128 4.117c5.806-7.465 6.139-11.005 9.128-22.015.356-1.391 1.499-1.752 2.438-.839l23.204 23.178c1.297 1.297 1.291 2.783.099 3.98L45.695 49.624zm-5.027-18.24c1.65 1.656 10.781-3.407 13.932-7.375l-6.87-6.844c-.594 5.531-3.469 9.531-6.969 13.031-.406.406-.375.912-.093 1.188" style="fill-rule:nonzero" transform="translate(6.02 2.76)scale(.7697)"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 64 64" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(0.7697,0,0,0.7697,6.02054,2.76086)">
<path d="M4.098,71.551C9.52,76.977 15.861,77.04 21.2,71.712C24.919,67.993 28.826,59.357 31.73,55.767L38.228,62.297C40.84,64.94 44.042,64.951 46.586,62.396L50.685,58.266C53.24,55.68 53.223,52.577 50.585,49.94L25.74,25.058C23.097,22.409 19.963,22.384 17.377,24.97L13.284,29.089C10.723,31.649 10.703,34.797 13.358,37.446L19.877,43.945C16.318,46.849 7.682,50.736 3.968,54.449C-1.36,59.788 -1.328,66.155 4.098,71.551ZM18.308,32.477L20.738,30.093C21.444,29.393 22.212,29.362 22.918,30.067L45.596,52.72C46.276,53.426 46.276,54.199 45.545,54.931L43.192,57.309C42.48,58.072 41.667,58.097 40.95,57.335L33.447,49.807C32.173,48.527 30.482,48.652 29.034,50.062C26.597,52.463 22.355,62.677 17.369,67.626C14.51,70.51 11.059,70.505 8.086,67.563C5.17,64.615 5.133,61.128 8.018,58.269C13.003,53.326 23.212,49.078 25.618,46.635C26.997,45.167 27.148,43.476 25.868,42.222L18.308,34.682C17.597,33.977 17.597,33.189 18.308,32.477ZM12.653,66.781C14.705,66.781 16.362,65.099 16.362,63.052C16.362,61.006 14.705,59.349 12.653,59.349C10.607,59.349 8.925,61.006 8.925,63.052C8.925,65.099 10.607,66.781 12.653,66.781ZM49.735,53.664L64.838,38.567C68.458,34.941 68.385,30.576 64.67,26.856L40.105,2.254C36.554,-1.297 30.568,0.147 29.345,5.534C26.326,18.586 26.297,19.653 21.403,26.492L25.531,30.609C31.337,23.144 31.67,19.604 34.659,8.594C35.015,7.203 36.158,6.842 37.097,7.755L60.301,30.933C61.598,32.23 61.592,33.716 60.4,34.913L45.695,49.624L49.735,53.664ZM44.708,35.424C46.358,37.08 55.489,32.017 58.64,28.049L51.77,21.205C51.176,26.736 48.301,30.736 44.801,34.236C44.395,34.642 44.426,35.148 44.708,35.424Z" style="fill-rule:nonzero;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -18,6 +18,9 @@ import { AuditLog } from './models/AuditLog'
import { User } from './models/User' import { User } from './models/User'
import { NoteType } from './models/NoteType' import { NoteType } from './models/NoteType'
import { Note } from './models/Note' import { Note } from './models/Note'
import { DocumentSize } from './models/DocumentSize.js'
import { DocumentTemplate } from './models/DocumentTemplate.js'
import { DocumentPrinter } from './models/DocumentPrinter.js'
import QuestionCircleIcon from '../components/Icons/QuestionCircleIcon' import QuestionCircleIcon from '../components/Icons/QuestionCircleIcon'
export const objectModels = [ export const objectModels = [
@ -40,7 +43,10 @@ export const objectModels = [
AuditLog, AuditLog,
User, User,
NoteType, NoteType,
Note Note,
DocumentSize,
DocumentTemplate,
DocumentPrinter
] ]
// Re-export individual models for direct access // Re-export individual models for direct access
@ -64,12 +70,21 @@ export {
AuditLog, AuditLog,
User, User,
NoteType, NoteType,
Note Note,
DocumentSize,
DocumentTemplate,
DocumentPrinter
} }
export function getModelByName(name) { export function getModelByName(name, ignoreCase = false) {
function formatName(formattedName) {
if (ignoreCase == true) {
formattedName = formattedName.toUpperCase()
}
return formattedName
}
return ( return (
objectModels.find((meta) => meta.name === name) || { objectModels.find((meta) => formatName(meta.name) === formatName(name)) || {
name: 'unknown', name: 'unknown',
label: 'Unknown', label: 'Unknown',
prefix: 'UNK', prefix: 'UNK',

View File

@ -0,0 +1,125 @@
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import ReloadIcon from '../../components/Icons/ReloadIcon'
import EditIcon from '../../components/Icons/EditIcon'
import DocumentPrinterIcon from '../../components/Icons/DocumentPrinterIcon'
export const DocumentPrinter = {
name: 'documentPrinter',
label: 'Document Printer',
prefix: 'DPR',
icon: DocumentPrinterIcon,
actions: [
{
name: 'info',
label: 'Info',
default: true,
row: true,
icon: InfoCircleIcon,
url: (_id) =>
`/dashboard/management/documentprinters/info?documentPrinterId=${_id}`
},
{
name: 'reload',
label: 'Reload',
icon: ReloadIcon,
url: (_id) =>
`/dashboard/management/documentprinters/info?documentPrinterId=${_id}&action=reload`
},
{
name: 'edit',
label: 'Edit',
row: true,
icon: EditIcon,
url: (_id) =>
`/dashboard/management/documentprinters/info?documentPrinterId=${_id}&action=edit`
}
],
columns: [
'name',
'_id',
'documentSize',
'documentSize._id',
'createdAt',
'updatedAt'
],
filters: ['name', '_id'],
sorters: ['name', 'documentSize', 'createdAt', 'updatedAt'],
properties: [
{
name: '_id',
label: 'ID',
type: 'id',
objectType: 'documentPrinter',
showCopy: true
},
{
name: 'createdAt',
label: 'Created At',
type: 'dateTime',
readOnly: true
},
{
name: 'name',
label: 'Name',
required: true,
type: 'text',
columnWidth: 200,
columnFixed: 'left'
},
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true
},
{
name: 'documentSize',
label: 'Document Size',
required: true,
type: 'object',
objectType: 'documentSize'
},
{
name: 'documentSize._id',
label: 'Document Size ID',
type: 'id',
objectType: 'documentSize',
showCopy: true,
showHyperlink: true
},
{
name: 'active',
label: 'Active',
required: true,
type: 'bool'
},
{
name: 'tags',
label: 'Tags',
required: false,
type: 'tags'
},
{ name: 'global', label: 'Global', required: false, type: 'bool' },
{
name: 'parent',
label: 'Parent',
required: false,
type: 'object',
objectType: 'documentPrinter',
disabled: (documentPrinter) => {
if (documentPrinter.global == true) {
documentPrinter.parent = null
}
return documentPrinter.global
}
},
{
name: 'parent._id',
label: 'Parent ID',
required: false,
type: 'id',
objectType: 'documentPrinter'
}
]
}

View File

@ -0,0 +1,86 @@
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import ReloadIcon from '../../components/Icons/ReloadIcon'
import EditIcon from '../../components/Icons/EditIcon'
import DocumentSizeIcon from '../../components/Icons/DocumentSizeIcon'
export const DocumentSize = {
name: 'documentSize',
label: 'Document Size',
prefix: 'DSZ',
icon: DocumentSizeIcon,
actions: [
{
name: 'info',
label: 'Info',
default: true,
row: true,
icon: InfoCircleIcon,
url: (_id) =>
`/dashboard/management/documentsizes/info?documentSizeId=${_id}`
},
{
name: 'reload',
label: 'Reload',
icon: ReloadIcon,
url: (_id) =>
`/dashboard/management/documentsizes/info?documentSizeId=${_id}&action=reload`
},
{
name: 'edit',
label: 'Edit',
row: true,
icon: EditIcon,
url: (_id) =>
`/dashboard/management/documentsizes/info?documentSizeId=${_id}&action=edit`
}
],
columns: ['name', '_id', 'width', 'height', 'createdAt', 'updatedAt'],
filters: ['name', '_id', 'width', 'height'],
sorters: ['name', 'width', 'height', 'createdAt', 'updatedAt'],
properties: [
{
name: '_id',
label: 'ID',
type: 'id',
objectType: 'documentSize',
showCopy: true
},
{
name: 'createdAt',
label: 'Created At',
type: 'dateTime',
readOnly: true
},
{
name: 'name',
label: 'Name',
required: true,
type: 'text',
columnWidth: 200,
columnFixed: 'left'
},
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true
},
{
name: 'width',
label: 'Width',
required: true,
columnWidth: 150,
type: 'number',
suffix: 'mm'
},
{
name: 'height',
label: 'Height',
required: true,
columnWidth: 150,
type: 'number',
suffix: 'mm'
}
]
}

View File

@ -0,0 +1,189 @@
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import ReloadIcon from '../../components/Icons/ReloadIcon'
import EditIcon from '../../components/Icons/EditIcon'
import DesignIcon from '../../components/Icons/DesignIcon'
import DocumentTemplateIcon from '../../components/Icons/DocumentTemplateIcon'
export const DocumentTemplate = {
name: 'documentTemplate',
label: 'Document Template',
prefix: 'DTP',
icon: DocumentTemplateIcon,
actions: [
{
name: 'design',
label: 'Design',
row: true,
icon: DesignIcon,
url: (_id) =>
`/dashboard/management/documenttemplates/design?documentTemplateId=${_id}`
},
{
name: 'info',
label: 'Info',
default: true,
row: true,
icon: InfoCircleIcon,
url: (_id) =>
`/dashboard/management/documenttemplates/info?documentTemplateId=${_id}`
},
{
name: 'reload',
label: 'Reload',
icon: ReloadIcon,
url: (_id) =>
`/dashboard/management/documenttemplates/info?documentTemplateId=${_id}&action=reload`
},
{
name: 'edit',
label: 'Edit',
row: true,
icon: EditIcon,
url: (_id) =>
`/dashboard/management/documenttemplates/info?documentTemplateId=${_id}&action=edit`
}
],
columns: [
'name',
'_id',
'active',
'global',
'objectType',
'tags',
'parent',
'parent._id',
'documentSize',
'documentSize._id',
'createdAt',
'updatedAt'
],
filters: ['name', '_id', 'active', 'tags', 'objectType'],
group: ['documentSize', 'tags'],
sorters: [
'name',
'parent',
'documentSize',
'createdAt',
'updatedAt',
'active',
'global',
'objectType'
],
properties: [
{
name: '_id',
label: 'ID',
type: 'id',
objectType: 'documentTemplate',
showCopy: true
},
{
name: 'createdAt',
label: 'Created At',
type: 'dateTime',
readOnly: true
},
{
name: 'name',
label: 'Name',
required: true,
type: 'text',
columnWidth: 200,
columnFixed: 'left'
},
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true
},
{
name: 'objectType',
label: 'Object Type',
required: false,
type: 'objectType',
empty: (documentTemplate) => {
return documentTemplate.global
}
},
{
name: 'active',
label: 'Active',
required: true,
type: 'bool',
columnWidth: 150
},
{
name: 'tags',
label: 'Tags',
required: false,
type: 'tags'
},
{
name: 'global',
label: 'Global',
required: true,
type: 'bool',
columnWidth: 150
},
{
name: 'documentSize',
label: 'Document Size',
required: true,
type: 'object',
objectType: 'documentSize'
},
{
name: 'documentSize._id',
label: 'Document Size ID',
type: 'id',
objectType: 'documentSize',
showCopy: true,
showHyperlink: true
},
{
name: 'parent',
label: 'Parent',
required: false,
type: 'object',
masterFilter: { global: true, active: true },
objectType: 'documentTemplate',
empty: (documentTemplate) => {
return documentTemplate.global
}
},
{
name: 'parent._id',
label: 'Parent ID',
required: false,
type: 'id',
showHyperlink: true,
objectType: 'documentTemplate',
empty: (documentTemplate) => {
return documentTemplate.global
}
},
{
name: 'documentPrinters',
label: 'Document Printers',
required: false,
type: 'objectList',
objectType: 'documentPrinter'
},
{
name: 'content',
label: 'Content',
required: false,
type: 'codeBlock',
language: 'ejs'
},
{
name: 'testObject',
label: 'Test Object',
required: false,
type: 'codeBlock',
language: 'json'
}
]
}