Simplify approval card workflow fields and format times in Eastern.
Remove moved-by and from-status, rename to-status to Status, and show Created/Updated in America/New_York with EDT/EST. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
225ca27c99
commit
781b238a5b
4 changed files with 55 additions and 11 deletions
|
|
@ -16,9 +16,7 @@
|
|||
"common": {
|
||||
"displayFields": [
|
||||
{ "path": "transition.transitionName", "label": "Approval step" },
|
||||
{ "path": "transition.from_status", "label": "From status" },
|
||||
{ "path": "transition.to_status", "label": "To status" },
|
||||
{ "path": "user.displayName", "label": "Moved by" },
|
||||
{ "path": "transition.to_status", "label": "Status" },
|
||||
{ "fieldId": "priority", "label": "Priority", "format": "option" },
|
||||
{ "fieldId": "assignee", "label": "Assignee", "format": "user" },
|
||||
{ "fieldId": "created", "label": "Created", "format": "datetime" },
|
||||
|
|
|
|||
|
|
@ -2,6 +2,46 @@ import fs from 'fs';
|
|||
import { formatJiraRichText } from './jiraRichText.js';
|
||||
|
||||
const SKIP_FIELD_IDS = new Set(['attachment']);
|
||||
const EASTERN_TIME_ZONE = 'America/New_York';
|
||||
|
||||
export function formatEasternDateTime(value) {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
const formatted = new Intl.DateTimeFormat('en-US', {
|
||||
timeZone: EASTERN_TIME_ZONE,
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: true,
|
||||
}).format(date);
|
||||
|
||||
const timeZoneName = new Intl.DateTimeFormat('en-US', {
|
||||
timeZone: EASTERN_TIME_ZONE,
|
||||
timeZoneName: 'short',
|
||||
}).formatToParts(date).find(part => part.type === 'timeZoneName')?.value || 'ET';
|
||||
|
||||
return `${formatted} ${timeZoneName}`;
|
||||
}
|
||||
|
||||
export function formatEasternDate(value) {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
return new Intl.DateTimeFormat('en-US', {
|
||||
timeZone: EASTERN_TIME_ZONE,
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
export function loadRequestTypeFields() {
|
||||
const path = './config/requestTypeFields.json';
|
||||
|
|
@ -68,8 +108,9 @@ export function formatFieldValue(value, format) {
|
|||
}
|
||||
return value.map(item => formatFieldValue(item, 'user')).filter(Boolean).join(', ');
|
||||
case 'datetime':
|
||||
return formatEasternDateTime(value);
|
||||
case 'date':
|
||||
return new Date(value).toLocaleString();
|
||||
return formatEasternDate(value);
|
||||
case 'cmdb':
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(item => item.label || item.name || item.objectKey || item.value).filter(Boolean).join(', ');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { buildDetailLinesForRequestType } from '../lib/requestTypeFields.js';
|
||||
import { buildDetailLinesForRequestType, formatEasternDateTime } from '../lib/requestTypeFields.js';
|
||||
|
||||
const PORTAL_BASE_URL = 'https://aeo.atlassian.net/servicedesk/customer/portal/135';
|
||||
|
||||
|
|
@ -152,13 +152,10 @@ function buildFallbackChangeDetailLines(jiraTicket) {
|
|||
lines.push({ label: 'Business justification', value: fields.customfield_10252 });
|
||||
}
|
||||
if (fields.customfield_10257) {
|
||||
const changeDate = new Date(fields.customfield_10257).toLocaleDateString();
|
||||
const changeTime = new Date(fields.customfield_10257).toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: true,
|
||||
lines.push({
|
||||
label: 'Implementation date',
|
||||
value: formatEasternDateTime(fields.customfield_10257),
|
||||
});
|
||||
lines.push({ label: 'Implementation date', value: `${changeDate} ${changeTime}` });
|
||||
}
|
||||
|
||||
return lines;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { describe, it } from 'node:test';
|
|||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
buildDetailLinesForRequestType,
|
||||
formatEasternDateTime,
|
||||
formatFieldValue,
|
||||
getDisplayFieldsForRequestType,
|
||||
} from '../lib/requestTypeFields.js';
|
||||
|
|
@ -72,6 +73,13 @@ describe('formatFieldValue', () => {
|
|||
'Store 123, Store 456'
|
||||
);
|
||||
});
|
||||
|
||||
it('formats datetimes in Eastern time', () => {
|
||||
const formatted = formatFieldValue('2026-07-28T20:33:16.000Z', 'datetime');
|
||||
assert.match(formatted, /EDT|EST/);
|
||||
assert.match(formatted, /7\/28\/2026/);
|
||||
assert.doesNotMatch(formatted, /20:33:16/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildDetailLinesForRequestType', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue