From 9dd2633e0c1ae35d0aa765fe99bdcb77217926fa Mon Sep 17 00:00:00 2001 From: Snowknight26 Date: Mon, 2 Mar 2026 05:52:02 -0600 Subject: [PATCH] chore(web): deduplicate storage template examples (#26462) --- .../SupportedDatetimePanel.svelte | 87 +++++-------------- 1 file changed, 20 insertions(+), 67 deletions(-) diff --git a/web/src/lib/components/admin-settings/SupportedDatetimePanel.svelte b/web/src/lib/components/admin-settings/SupportedDatetimePanel.svelte index de455380a9..c22d3cb792 100644 --- a/web/src/lib/components/admin-settings/SupportedDatetimePanel.svelte +++ b/web/src/lib/components/admin-settings/SupportedDatetimePanel.svelte @@ -11,85 +11,38 @@ let { options }: Props = $props(); - const getLuxonExample = (format: string) => { - return DateTime.fromISO('2022-02-15T20:03:05.250Z', { locale: $locale }).toFormat(format); - }; + const getExampleDate = () => DateTime.fromISO('2022-02-15T20:03:05.250Z', { locale: $locale }); +{#snippet example(title: string, options: Array)} +
+ {title} +
    + {#each options as format, index (index)} +
  • {`{{${format}}} - ${getExampleDate().toFormat(format)}`}
  • + {/each} +
+
+{/snippet} + {$t('date_and_time')} - {$t('admin.storage_template_date_time_description')} {$t('admin.storage_template_date_time_sample', { values: { date: '2022-02-15T20:03:05.250+00:00' } })}{$t('admin.storage_template_date_time_sample', { values: { date: getExampleDate().toISO() } })}
-
- {$t('year')} -
    - {#each options.yearOptions as yearFormat, index (index)} -
  • {'{{'}{yearFormat}{'}}'} - {getLuxonExample(yearFormat)}
  • - {/each} -
-
- -
- {$t('month')} -
    - {#each options.monthOptions as monthFormat, index (index)} -
  • {'{{'}{monthFormat}{'}}'} - {getLuxonExample(monthFormat)}
  • - {/each} -
-
- -
- {$t('week')} -
    - {#each options.weekOptions as weekFormat, index (index)} -
  • {'{{'}{weekFormat}{'}}'} - {getLuxonExample(weekFormat)}
  • - {/each} -
-
- -
- {$t('day')} -
    - {#each options.dayOptions as dayFormat, index (index)} -
  • {'{{'}{dayFormat}{'}}'} - {getLuxonExample(dayFormat)}
  • - {/each} -
-
- -
- {$t('hour')} -
    - {#each options.hourOptions as dayFormat, index (index)} -
  • {'{{'}{dayFormat}{'}}'} - {getLuxonExample(dayFormat)}
  • - {/each} -
-
- -
- {$t('minute')} -
    - {#each options.minuteOptions as dayFormat, index (index)} -
  • {'{{'}{dayFormat}{'}}'} - {getLuxonExample(dayFormat)}
  • - {/each} -
-
- -
- {$t('second')} -
    - {#each options.secondOptions as dayFormat, index (index)} -
  • {'{{'}{dayFormat}{'}}'} - {getLuxonExample(dayFormat)}
  • - {/each} -
-
+ {@render example($t('year'), options.yearOptions)} + {@render example($t('month'), options.monthOptions)} + {@render example($t('week'), options.weekOptions)} + {@render example($t('day'), options.dayOptions)} + {@render example($t('hour'), options.hourOptions)} + {@render example($t('minute'), options.minuteOptions)} + {@render example($t('second'), options.secondOptions)}