Files
Project-SDE-WP-Suite/feedback-config.js
n.siegfried d2dc6ff4f7 Remove discipline from WP types; prep for firewall hosting + feedback collection
WP type discipline removal:
- SOP WP Types step now has Enabled / Special Rules-Notes / WO Complete
  Approval columns (discipline column and DISCIPLINES/type-discipline maps gone)
- WP Creator: drop the derived Discipline field, the type-trade number code,
  and discipline from saved packages and output; number tokens are now generic
- Default WP number format no longer includes [Discipline]
- Harden buildConstraints against object-shaped constraint names

Firewall hosting:
- Remove external Google Fonts @import; fall back to system fonts (no
  outbound calls, runs fully behind a firewall)

Feedback collection:
- Add shared feedback-config.js with a single FEEDBACK_ENDPOINT hook +
  best-effort postFeedback() (backend or Power Automate/SharePoint)
- Add Export / Import to home and SOP feedback; wire central-post on all three
  surfaces (home, SOP step comments, WP review comments)
- Add DEPLOYMENT.md documenting hosting and both feedback paths

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 10:16:42 -07:00

43 lines
2.3 KiB
JavaScript

/* ──────────────────────────────────────────────────────────────────────────
CENTRAL FEEDBACK CONFIGURATION
----------------------------------------------------------------------------
By default the suite stores all feedback in each user's own browser
(localStorage) and reviewers share it via Export / Import. That needs no
server and works behind any firewall.
To ALSO collect feedback automatically into one central place, set
FEEDBACK_ENDPOINT below to a URL that accepts an HTTP POST of JSON. This
works with either:
• a small backend on your host (Node/PHP/Python/ASP.NET) that appends the
body to a feedback.json / .csv you can download, or
• a Microsoft Power Automate "When an HTTP request is received" trigger
that writes to a SharePoint list / Excel table.
Leave it as an empty string to stay fully local (export/import only).
See DEPLOYMENT.md for setup details and sample receivers.
────────────────────────────────────────────────────────────────────────── */
window.FEEDBACK_ENDPOINT = '';
/* Best-effort send to the central endpoint. Never throws and never blocks the
UI: feedback is always saved locally first by the caller, so a failed or
disabled POST simply means "not centrally collected." Returns a Promise that
resolves true on success, false otherwise. */
window.postFeedback = function (payload) {
if (!window.FEEDBACK_ENDPOINT) return Promise.resolve(false);
try {
return fetch(window.FEEDBACK_ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
app: 'Work Package Suite',
page: (typeof location !== 'undefined' && location.pathname) || '',
submittedAt: new Date().toISOString(),
...payload
}),
keepalive: true // allow the send to complete even if the page unloads
}).then(function (r) { return r.ok; }).catch(function () { return false; });
} catch (e) {
return Promise.resolve(false);
}
};