Explorar o código

Append template text instead of replacing the reply field

Lets a host combine hand-typed text with one or more templates in
the same message.
ZiB hai 3 meses
pai
achega
74182a11ec
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      room_cal/vue/calendar.html

+ 2 - 1
room_cal/vue/calendar.html

@@ -1557,7 +1557,7 @@ createApp({
       const checkout = sel?.checkout_date ? parseWithTime(sel.checkout_date, sel.checkout_time) : null;
       const fmtDate_ = (d, fmt) => d ? _strftime(fmt || dtFmt, d) : '';
       const resId = [serviceName(sel?.service), sel?.reservation_id].filter(Boolean).join(' ');
-      chatReply.value = raw.replace(/\{(\w+)(?::([^}]*))?\}/g, (_, key, fmt) => {
+      const rendered = raw.replace(/\{(\w+)(?::([^}]*))?\}/g, (_, key, fmt) => {
         if (key === 'guest_name')     return sel?.guest_name  ?? '';
         if (key === 'first_name')     return (sel?.guest_name ?? '').split(' ')[0] ?? '';
         if (key === 'wifi_key')       return sel?.wifi_key    ?? '';
@@ -1568,6 +1568,7 @@ createApp({
         if (key === 'reservation_id') return resId;
         return '';
       });
+      chatReply.value = chatReply.value.trim() ? `${chatReply.value}\n\n${rendered}` : rendered;
     }
 
     function fmtChatTime(ts) {