Changeset View
Changeset View
Standalone View
Standalone View
assets/src/bundles/save/index.js
Show First 20 Lines • Show All 339 Lines • ▼ Show 20 Lines | export function formatValuePerType(type, value) { | ||||
// Given some typed value, format and return accordingly formatted value | // Given some typed value, format and return accordingly formatted value | ||||
const mapFormatPerTypeFn = { | const mapFormatPerTypeFn = { | ||||
'json': (v) => JSON.stringify(v, null, 2), | 'json': (v) => JSON.stringify(v, null, 2), | ||||
'date': (v) => new Date(v).toLocaleString(), | 'date': (v) => new Date(v).toLocaleString(), | ||||
'raw': (v) => v, | 'raw': (v) => v, | ||||
'duration': (v) => v + ' seconds' | 'duration': (v) => v + ' seconds' | ||||
}; | }; | ||||
return mapFormatPerTypeFn[type](value); | return value === null ? null : mapFormatPerTypeFn[type](value); | ||||
ardumont: may be simpler to read (plus it avoids one negation we so love for some reason) | |||||
} | } | ||||
export function displaySaveRequestInfo(event, saveRequestId) { | export function displaySaveRequestInfo(event, saveRequestId) { | ||||
event.stopPropagation(); | event.stopPropagation(); | ||||
const saveRequestTaskInfoUrl = Urls.origin_save_task_info(saveRequestId); | const saveRequestTaskInfoUrl = Urls.origin_save_task_info(saveRequestId); | ||||
// close popover when clicking again on the info icon | // close popover when clicking again on the info icon | ||||
if ($(event.target).data('bs.popover')) { | if ($(event.target).data('bs.popover')) { | ||||
$(event.target).popover('dispose'); | $(event.target).popover('dispose'); | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |
may be simpler to read (plus it avoids one negation we so love for some reason)