+
${Array.isArray(data.comments) ? getFilteredComments(data.comments).map(comment => `
-
-
Author: ${comment.author}
-
Comment:
-
${comment.content}
-
Posted: ${comment.created}
+
+
+ ${comment.author}
+ ${comment.created}
+
+
${comment.content}
`).join('') : ''}
` : '';
- const signature = `
-
Thank you,
-
Your Jira Automation
- `;
-
- return `${issueTemplate}${commentsTemplate}${signature}`;
-}
-
-// Function to generate minified HTML
-function generateHTML() {
- // Always use smart values for the minified output
- const data = templateData[currentProduct].smart;
-
- // Generate fields based on product type
- const generateFields = () => {
- let fields = '';
-
- // Common fields
- fields += `
-
-
Status
-
{{issue.status.name}}
-
-
-
Priority
-
{{issue.priority}}
-
-
-
Assignee
-
{{issue.assignee}}
-
-
-
Reporter
-
{{issue.reporter}}
-
-
-
Created
-
{{issue.created}}
-
-
-
Updated
-
{{issue.updated}}
-
- `;
-
- // Product specific fields
- if (currentProduct === 'software') {
- fields += `
-
-
Sprint
-
{{issue.sprint}}
-
-
-
Story Points
-
{{issue.storyPoints}}
-
- `;
- } else if (currentProduct === 'servicedesk') {
- fields += `
-
-
Request Type
-
{{issue.requestType}}
-
-
-
Impact
-
{{issue.impact}}
-
-
- `;
- } else if (currentProduct === 'core') {
- fields += `
-
-
Due Date
-
{{issue.dueDate}}
-
-
-
Category
-
{{issue.category}}
-
- `;
- }
-
- return fields;
- };
-
- // Function to generate the comments section for preview
- function generatePreviewComments() {
- if (!showComments) return '';
-
- const commentContent = Array.isArray(data.comments) ? getFilteredComments(data.comments).map(comment => `
-
-
- {{author.displayName}}
- {{created.format("yyyy-MM-dd HH:mm")}}
-
-
{{body.html}}
-
- `).join('') : (showSmartValues ? `
-
-
- {{author.displayName}}
- {{created.format("yyyy-MM-dd HH:mm")}}
-
-
{{body.html}}
-
- ` : '');
-
- return `
-
-
- Comments
-
-
- {{#issue.comments}}
- ${commentContent}
- {{/issue.comments}}
-
-
- `;
- }
-
- // Function to generate the comments section for minified output
- function generateMinifiedComments() {
- if (!showComments) return '';
-
- return `
-
-
- Comments
-
-
- {{#issue.comments}}
-
-
- {{author.displayName}}
- {{created.format("yyyy-MM-dd HH:mm")}}
-
-
{{body.html}}
-
- {{/issue.comments}}
-
-
- `;
- }
-
- const template = `
-
-
- {{issue.key}}
- {{issue.type}}
-
-
-
-
-
-
{{issue.description}}
-
-
-
- ${generateFields()}
-
-
- ${currentProduct === 'software' ? `
-
-
Components
-
- {{#issue.components}}
-
- {{.}}
-
- {{/issue.components}}
-
-
-
-
-
Labels
-
- {{#issue.labels}}
-
- {{.}}
-
- {{/issue.labels}}
-
-
- ` : ''}
-
-
- ${generatePreviewComments()}
-`;
-
- const minifiedTemplate = `
-
-
- {{issue.key}}
- {{issue.type}}
-
-
-
-
-
-
{{issue.description}}
-
-
-
- ${generateFields()}
-
-
- ${currentProduct === 'software' ? `
-
-
Components
-
- {{#issue.components}}
-
- {{.}}
-
- {{/issue.components}}
-
-
-
-
-
Labels
-
- {{#issue.labels}}
-
- {{.}}
-
- {{/issue.labels}}
-
-
- ` : ''}
+ const viewInJiraButton = `
+
-
- ${generateMinifiedComments()}
-`;
+ `;
- const fullHTML = `
-
+ return `
+
-
-
Jira Notification
-
-
- ${minifiedTemplate}
+
+ ${issueTemplate}
+ ${commentsTemplate}
+ ${viewInJiraButton}
`;
+}
- // Get the minified HTML
- const minifiedHTML = fullHTML
- .replace(/\s+/g, ' ') // Replace multiple whitespace with single space
- .replace(/>\s+<') // Remove whitespace between tags
- .replace(//g, '') // Remove comments
- .trim(); // Remove leading/trailing whitespace
-
+// Function to generate HTML for copying
+function generateHTML() {
+ // Always use smart values for the minified output
+ const previousSmartValue = showSmartValues;
+ showSmartValues = true;
+
+ // Generate the template with current settings
+ const template = generateEmailTemplate('full', templateData[currentProduct].smart, showComments);
+
+ // Reset smart values to previous state
+ showSmartValues = previousSmartValue;
+
+ // Minify the HTML by removing unnecessary whitespace and line breaks
+ const minifiedTemplate = template
+ .replace(/\s+/g, ' ') // Replace multiple spaces with a single space
+ .replace(/>\s+<') // Remove spaces between tags
+ .replace(/\n/g, '') // Remove line breaks
+ .trim(); // Remove leading/trailing whitespace
+
// Update the output
- document.getElementById("htmlOutput").textContent = minifiedHTML;
+ document.getElementById("htmlOutput").value = minifiedTemplate;
}
// Function to change template type