Wave 2: form cleanups from the site comments, plus localization, project switcher and global search
Site comments (8/3) - BIM card: LOD removed, IFF # added next to the coordination status, and required once that status is "Signed off (IFF)" — an unnumbered sign-off isn't traceable. A LOD already stored on a package is preserved and shown as legacy, not blanked. - The blue "from SOP types" subtext under a field is now a SOP chip on the label with the detail in a tooltip. The chip stays visible rather than hover-only: field tablets have no hover, and "this came from the SOP" is the part that matters. The hint elements stay in the DOM (hidden) so the code writing to them keeps working; an observer mirrors their text into the tooltip. - Specification Section is no longer typed per package. Each WP type carries a spec section on the SOP; the field is read-only in the Creator and follows the type, with the SOP's spec folder linked underneath. This reads both spec comments as one intent — stop typing it, derive it. - Assignees and Distribution are multi-selects over the SOP project team, showing each person's job function, with the CM pre-added to Distribution (removable per package) and a free-text option for people with no account. The stored display strings are unchanged so print/export/dashboard keep working; account ids ride alongside for the notification work in wave 3. Localization + time - Per-user locale/timezone (Language & time in the user menu), an app-wide default in the admin console, then the browser. Timezones are validated against the server's zoneinfo and the picker is fed from it. Calendar dates are formatted from their parts so a due date never reads a day early in another zone. - Every displayed timestamp now goes through the shared helpers. Top-bar chrome - Project switcher beside the logo and a centered global search, injected into either generation of top bar; skipped in an iframe so the embedded Creator doesn't get a second one. Ctrl/Cmd-K focuses search. - GET /api/search covers work packages, projects and SOPs, scoped to the caller's projects, hiding archived packages, with LIKE wildcards escaped. Fixed along the way: showForm() cleared every card's inline display, which undid applyKind() — so the Package Type and BIM cards reappeared on an install-only project. Split out applyKindVisibility() and re-apply it there. Verified: 100 API checks on a fresh database (44 permissions + 22 password reset + 34 search/localization), 24 driven UI checks against the real Creator page in headless Chrome (SOP chips, both people pickers, spec auto-fill, critical tags, BIM suppression), and the chrome harness on both bar styles. Screenshots reviewed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -200,7 +200,7 @@ function fillProjectRoleOptions(){
|
||||
function renderUsers(list, meId){
|
||||
const wrap=document.getElementById('users-table');
|
||||
if(!list.length){ wrap.innerHTML='<div class="note">No users yet.</div>'; return; }
|
||||
const fmt = s => s ? new Date(s).toLocaleString() : '—';
|
||||
const fmt = s => s ? wpFormatDateTime(s) : '—';
|
||||
let rows = list.map(u=>{
|
||||
const me = u.id===meId;
|
||||
const active = u.is_active;
|
||||
@@ -394,7 +394,7 @@ function renderComments(){
|
||||
(!q || ((c.text||'')+' '+(c.author||'')).toLowerCase().indexOf(q)>=0));
|
||||
if(!rows.length){ box.innerHTML = '<div class="note">No comments'+((src||q)?' match the filter.':' yet.')+'</div>'; return; }
|
||||
rows = rows.slice().sort((a,b)=> String(b.created_at||'').localeCompare(String(a.created_at||'')));
|
||||
const fmt = s => s ? new Date(s).toLocaleString() : '—';
|
||||
const fmt = s => s ? wpFormatDateTime(s) : '—';
|
||||
const where = c => {
|
||||
const bits = [];
|
||||
if(c.page) bits.push(uesc(c.page));
|
||||
@@ -432,7 +432,7 @@ function renderAudit(){
|
||||
let rows = _audit.filter(e => (!type || e.entity_type===type) &&
|
||||
(!q || ((e.actor||'')+' '+(e.action||'')+' '+(e.summary||'')).toLowerCase().indexOf(q)>=0));
|
||||
if(!rows.length){ box.innerHTML = '<div class="note">No activity'+((type||q)?' matches the filter.':' yet.')+'</div>'; return; }
|
||||
const fmt = s => s ? new Date(s).toLocaleString() : '—';
|
||||
const fmt = s => s ? wpFormatDateTime(s) : '—';
|
||||
const det = e => {
|
||||
const d = e.detail || {};
|
||||
if(d.from!=null || d.to!=null) return uesc((d.from==null?'—':d.from)+' → '+(d.to==null?'—':d.to));
|
||||
@@ -471,7 +471,90 @@ function renderFeatures(){
|
||||
'<div class="note" style="margin-top:8px">When OFF, the SOP creator hides the BIM/VDC section entirely and '+
|
||||
'every project is install-only (IWP). Existing SOPs that already have BIM enabled keep their data — it just '+
|
||||
'stops being shown or offered, so no project can be put on the BIM path while it\'s off.</div>'+
|
||||
'<div id="features-msg" class="note" style="margin-top:6px"></div>';
|
||||
'<div id="features-msg" class="note" style="margin-top:6px"></div>'+
|
||||
|
||||
// Localization defaults. A user's own "Language & time" preference wins over
|
||||
// these; these decide what everyone else sees instead of the browser's guess.
|
||||
'<h2 style="margin-top:22px">Localization defaults</h2>'+
|
||||
'<div class="sub" style="margin-bottom:10px">How dates, times and numbers are written for users who haven\'t '+
|
||||
'set their own preference. Each user can override this from <strong>Language & time</strong> in the '+
|
||||
'top-right menu.</div>'+
|
||||
'<div class="urow">'+
|
||||
'<select id="set-locale" style="min-width:220px"></select>'+
|
||||
'<select id="set-tz" style="min-width:240px"></select>'+
|
||||
'<button class="primary" onclick="saveLocalization()">Save defaults</button>'+
|
||||
'<span id="l10n-msg" class="note" style="margin:0"></span>'+
|
||||
'</div>'+
|
||||
'<div class="note" id="l10n-preview" style="margin-top:8px"></div>';
|
||||
fillLocalization();
|
||||
}
|
||||
|
||||
// Locale shortlist mirrors wp-format.js so the admin default and the per-user
|
||||
// preference offer the same choices.
|
||||
const L10N_LOCALES = [['','Browser default'],['en-US','en-US — 8/3/2026, 2:07 PM'],
|
||||
['en-GB','en-GB — 03/08/2026, 14:07'],['en-CA','en-CA'],['es-MX','es-MX'],['es-US','es-US'],
|
||||
['fr-CA','fr-CA'],['de-DE','de-DE'],['ja-JP','ja-JP'],['ko-KR','ko-KR'],['zh-TW','zh-TW']];
|
||||
const L10N_ZONES = ['America/Chicago','America/New_York','America/Denver','America/Phoenix',
|
||||
'America/Los_Angeles','America/Boise','Asia/Tokyo','Asia/Taipei','Asia/Seoul','Asia/Singapore',
|
||||
'Europe/Dublin','Europe/London','UTC'];
|
||||
|
||||
function fillLocalization(){
|
||||
const s = _settings;
|
||||
const loc = document.getElementById('set-locale');
|
||||
const tz = document.getElementById('set-tz');
|
||||
if(!loc || !tz) return;
|
||||
const curL = s.default_locale || '', curZ = s.default_timezone || '';
|
||||
loc.innerHTML = L10N_LOCALES.map(p =>
|
||||
'<option value="'+uesc(p[0])+'"'+(p[0]===curL?' selected':'')+'>'+uesc(p[1])+'</option>').join('');
|
||||
if(curL && !L10N_LOCALES.some(p=>p[0]===curL)) loc.add(new Option(curL, curL, true, true));
|
||||
|
||||
let browserZone = '';
|
||||
try { browserZone = Intl.DateTimeFormat().resolvedOptions().timeZone || ''; } catch(e){}
|
||||
tz.innerHTML = '<option value=""'+(curZ?'':' selected')+'>Browser default'+
|
||||
(browserZone?' ('+uesc(browserZone)+')':'')+'</option>'+
|
||||
L10N_ZONES.map(z => '<option value="'+uesc(z)+'"'+(z===curZ?' selected':'')+'>'+uesc(z)+'</option>').join('')+
|
||||
(curZ && L10N_ZONES.indexOf(curZ)<0 ? '<option value="'+uesc(curZ)+'" selected>'+uesc(curZ)+'</option>' : '');
|
||||
|
||||
const preview = () => {
|
||||
const el = document.getElementById('l10n-preview'); if(!el) return;
|
||||
let out;
|
||||
try {
|
||||
out = new Intl.DateTimeFormat(loc.value||undefined, {year:'numeric',month:'short',day:'numeric',
|
||||
hour:'2-digit',minute:'2-digit',timeZone:tz.value||undefined}).format(new Date());
|
||||
} catch(e){ out = 'not supported by this browser'; }
|
||||
el.textContent = 'Preview — right now reads: ' + out;
|
||||
};
|
||||
loc.onchange = preview; tz.onchange = preview; preview();
|
||||
|
||||
// Offer the server's full zone list once it arrives (it validates against the
|
||||
// same list, so anything offered here will be accepted).
|
||||
api('GET','/api/timezones').then(({status,json}) => {
|
||||
if(status!==200 || !Array.isArray(json) || !json.length) return;
|
||||
const rest = json.filter(z => L10N_ZONES.indexOf(z) < 0);
|
||||
if(!rest.length) return;
|
||||
const g = document.createElement('optgroup'); g.label = 'All time zones';
|
||||
rest.forEach(z => g.appendChild(new Option(z, z, false, z === curZ)));
|
||||
tz.appendChild(g);
|
||||
if(curZ) tz.value = curZ;
|
||||
});
|
||||
}
|
||||
|
||||
async function saveLocalization(){
|
||||
const msg = document.getElementById('l10n-msg');
|
||||
const patch = {
|
||||
default_locale: document.getElementById('set-locale').value,
|
||||
default_timezone: document.getElementById('set-tz').value,
|
||||
};
|
||||
msg.textContent = 'Saving…'; msg.style.color = 'var(--muted)';
|
||||
const { status, json } = await api('PUT','/api/settings', patch);
|
||||
if(status===200){
|
||||
_settings = json; renderSettings();
|
||||
const m = document.getElementById('l10n-msg');
|
||||
if(m){ m.textContent = 'Saved.'; m.style.color = 'var(--green)'; }
|
||||
} else {
|
||||
msg.textContent = '❌ '+((json && json.detail) || ('HTTP '+status));
|
||||
msg.style.color = 'var(--red)';
|
||||
}
|
||||
}
|
||||
|
||||
async function saveFeatures(){
|
||||
@@ -544,7 +627,7 @@ async function loadNotifications(){
|
||||
const { status, json } = await api('GET','/api/notifications?all=1&limit=50');
|
||||
if(status!==200 || !Array.isArray(json)){ box.innerHTML = ''; return; }
|
||||
if(!json.length){ box.innerHTML = '<div class="note">No notifications yet.</div>'; return; }
|
||||
const fmt = s => s ? new Date(s).toLocaleString() : '—';
|
||||
const fmt = s => s ? wpFormatDateTime(s) : '—';
|
||||
const stColor = st => st==='sent'?'var(--green)':st==='failed'?'var(--red)':st==='skipped'?'var(--muted)':'var(--amber)';
|
||||
box.innerHTML = '<div class="sub" style="margin:4px 0 6px;color:var(--muted)">Recent notifications</div>'+
|
||||
'<table class="users"><thead><tr><th>When</th><th>To</th><th>Kind</th><th>Subject</th><th>Status</th></tr></thead><tbody>'+
|
||||
@@ -572,7 +655,7 @@ function loadUsage(){
|
||||
if(e.event==='step_view' && e.detail) byStep[e.detail.step] = (byStep[e.detail.step]||0)+1;
|
||||
if(e.ts < first) first = e.ts; if(e.ts > last) last = e.ts;
|
||||
});
|
||||
const fmt = s => s ? new Date(s).toLocaleString() : '—';
|
||||
const fmt = s => s ? wpFormatDateTime(s) : '—';
|
||||
let html = '<table class="kv">'+
|
||||
'<tr><th>Sessions</th><td>'+sessions.size+'</td></tr>'+
|
||||
'<tr><th>Events</th><td>'+evs.length+'</td></tr>'+
|
||||
|
||||
Reference in New Issue
Block a user