Files
pulse-signage/src/web/routes/signage/templates/duplicate.js
T
lzstealth 3960931ebe
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m53s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 34s
Add onboarding weather and template gradients
2026-08-28 20:05:23 +01:00

38 lines
1.1 KiB
JavaScript

// Template duplicate helpers.
function buildDuplicateTemplateName(name) {
const source = String(name || 'Template').trim() || 'Template';
return 'Copy of ' + source;
}
function cloneRegion(region) {
const cloned = JSON.parse(JSON.stringify(region || {}));
delete cloned.id;
delete cloned.template_id;
delete cloned.created_at;
delete cloned.modified_at;
delete cloned.created_by;
delete cloned.modified_by;
return cloned;
}
function buildDuplicateTemplate(template, duplicateName) {
const source = template || {};
return {
id: null,
name: String(duplicateName || buildDuplicateTemplateName(source.name)).trim(),
canvas_size_id: source.canvas_size_id || null,
canvas_size_width: source.canvas_size_width,
canvas_size_height: source.canvas_size_height,
background_color: source.background_color,
background_image_path: source.background_image_path,
background_gradient: source.background_gradient,
region_usage: [],
regions: Array.isArray(source.regions) ? source.regions.map(cloneRegion) : []
};
}
module.exports = {
buildDuplicateTemplateName,
buildDuplicateTemplate
};