Changeset 11b3ba5 in Klonkt for src/views/pages/post-edit.ejs


Ignore:
Timestamp:
06/21/2026 03:54:13 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
1664f31
Parents:
5e61b17
Message:

fix(editor): schedule publication behind an on/off toggle (no accidental date)

The "Publish on" date field was always open → an accidentally chosen date silently
set the post to 'scheduled' (not live, no obvious reason). Now a "Schedule
publication" toggle, off by default = publish immediately; the date field appears
and counts only when the toggle is on (input disabled when off). Server honours
publish_at only with schedule_enabled (bulletproof, create + update). NL/EN/DE.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/post-edit.ejs

    r5e61b17 r11b3ba5  
    208208            <span>🔒 <%= t('pedit.fan_only_label') %></span>
    209209          </label>
    210           <div style="margin-top:8px">
    211             <label style="display:block;font-size:12.5px;opacity:.8;margin-bottom:4px">📅 <%= t('pedit.publish_at_label') %></label>
    212             <input type="datetime-local" name="publish_at" value="<%= post.publish_at ? String(post.publish_at).replace(' ','T').slice(0,16) : '' %>" style="padding:8px 10px;border-radius:8px;border:1px solid var(--rule,rgba(128,128,128,.4));background:transparent;color:inherit">
     210          <% var _scheduled = !!(post.publish_at && (post.status === 'scheduled' || Date.parse(String(post.publish_at).replace(' ', 'T')) > Date.now())); %>
     211          <label class="pe-checkbox" style="margin-top:8px">
     212            <input type="checkbox" name="schedule_enabled" value="1" id="pe-sched-toggle" <%= _scheduled ? 'checked' : '' %>>
     213            <span>📅 <%= t('pedit.schedule_label') %></span>
     214          </label>
     215          <div id="pe-sched-fields" style="margin-top:6px;<%= _scheduled ? '' : 'display:none' %>">
     216            <label style="display:block;font-size:12.5px;opacity:.8;margin-bottom:4px"><%= t('pedit.publish_at_label') %></label>
     217            <input type="datetime-local" name="publish_at" <%= _scheduled ? '' : 'disabled' %> value="<%= post.publish_at ? String(post.publish_at).replace(' ','T').slice(0,16) : '' %>" style="padding:8px 10px;border-radius:8px;border:1px solid var(--rule,rgba(128,128,128,.4));background:transparent;color:inherit">
    213218            <% if (post.status === 'scheduled' && post.publish_at) { %><div style="font-size:12px;opacity:.7;margin-top:4px">⏳ <%= t('pedit.scheduled_for', { d: post.publish_at }) %></div><% } %>
     219            <div style="font-size:11.5px;opacity:.65;margin-top:4px"><%= t('pedit.schedule_hint') %></div>
    214220          </div>
     221          <script>
     222            (function () {
     223              var cb = document.getElementById('pe-sched-toggle');
     224              var box = document.getElementById('pe-sched-fields');
     225              if (!cb || !box) return;
     226              var inp = box.querySelector('input[name="publish_at"]');
     227              function sync() { box.style.display = cb.checked ? '' : 'none'; if (inp) inp.disabled = !cb.checked; }
     228              cb.addEventListener('change', sync); sync();
     229            })();
     230          </script>
    215231        <% } %>
    216232      </div>
Note: See TracChangeset for help on using the changeset viewer.