feat: enable creator notification command
This commit was merged in pull request #10.
This commit is contained in:
@@ -198,6 +198,11 @@ button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px
|
||||
.action-result strong[data-state="FAILED"] { color: var(--bad); }
|
||||
.action-result strong[data-state="UNKNOWN_OUTCOME"] { color: var(--warn); }
|
||||
.action-result .secondary-button { min-width: 154px; margin: 0; padding: 0 14px; }
|
||||
.notification-command { grid-column: 1 / -1; padding: 14px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line-soft); }
|
||||
.notification-command div { min-width: 0; }
|
||||
.notification-command strong { display: block; margin-bottom: 5px; color: var(--ink); font: 600 10px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
|
||||
.notification-command span { display: block; color: var(--muted); font-size: 11px; line-height: 1.45; }
|
||||
.notification-command .secondary-button { flex: 0 0 auto; min-width: 190px; margin: 0; }
|
||||
.confirmation-dialog { width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: #111915; box-shadow: var(--shadow); }
|
||||
.confirmation-dialog::backdrop { background: rgba(3, 6, 5, .78); backdrop-filter: blur(5px); }
|
||||
.confirmation-dialog form { padding: 30px; }
|
||||
@@ -269,6 +274,8 @@ button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px
|
||||
.commit-zone-copy { grid-column: auto; grid-row: auto; margin-bottom: 6px; }
|
||||
.action-result { grid-template-columns: 1fr; align-items: stretch; }
|
||||
.action-result .secondary-button { width: 100%; }
|
||||
.notification-command { align-items: stretch; flex-direction: column; }
|
||||
.notification-command .secondary-button { width: 100%; }
|
||||
.confirmation-dialog form { padding: 24px 20px; }
|
||||
.confirmation-grid { grid-template-columns: 1fr; }
|
||||
.confirmation-grid .wide { grid-column: auto; }
|
||||
|
||||
@@ -11,6 +11,7 @@ let toastTimer;
|
||||
let currentTask = null;
|
||||
let currentProspective = null;
|
||||
let pendingCommand = null;
|
||||
let pendingNotification = null;
|
||||
let lastAuthorizedActionID = "";
|
||||
|
||||
function setText(id, value, fallback = "—") {
|
||||
@@ -93,6 +94,7 @@ function endSession(message = "Сессия завершена.") {
|
||||
currentTask = null;
|
||||
currentProspective = null;
|
||||
pendingCommand = null;
|
||||
pendingNotification = null;
|
||||
lastAuthorizedActionID = "";
|
||||
notify(message);
|
||||
}
|
||||
@@ -426,6 +428,7 @@ async function loadCapability(capabilityID) {
|
||||
|
||||
function updateActionReadiness() {
|
||||
const button = byId("prepare-satisfaction");
|
||||
const notificationButton = byId("prepare-notification");
|
||||
if (!button) return;
|
||||
const evidence = byId("satisfaction-evidence").value.trim();
|
||||
let message = "Доступно только для доставленного ожидания с проверенной Work-задачей.";
|
||||
@@ -441,6 +444,19 @@ function updateActionReadiness() {
|
||||
}
|
||||
button.disabled = !ready;
|
||||
setText("action-readiness", message);
|
||||
|
||||
let notificationReady = false;
|
||||
let notificationMessage = "Доступно для доставленного ожидания с проверенной Work-задачей.";
|
||||
if (!currentProspective) notificationMessage = "Сначала выберите и загрузите ожидание.";
|
||||
else if (currentProspective.State !== "DELIVERED") notificationMessage = `Состояние ${currentProspective.State || "UNKNOWN"}: уведомление доступно только для DELIVERED.`;
|
||||
else if (!currentTask) notificationMessage = "Загрузите проверенную Work-задачу как обоснование.";
|
||||
else if (currentTask.GoalID !== currentProspective.GoalID || currentTask.ScopeID !== currentProspective.ScopeID) notificationMessage = "Цель или область Work-задачи не совпадает с ожиданием.";
|
||||
else {
|
||||
notificationReady = true;
|
||||
notificationMessage = `Готово: receiver получит фиксированный шаблон для ${currentProspective.ID} · rev ${currentProspective.Revision}.`;
|
||||
}
|
||||
notificationButton.disabled = !notificationReady;
|
||||
setText("notification-readiness", notificationMessage);
|
||||
}
|
||||
|
||||
byId("satisfaction-evidence").addEventListener("input", updateActionReadiness);
|
||||
@@ -473,6 +489,53 @@ byId("cancel-satisfaction").addEventListener("click", () => {
|
||||
byId("satisfaction-dialog").close();
|
||||
});
|
||||
|
||||
byId("prepare-notification").addEventListener("click", () => {
|
||||
updateActionReadiness();
|
||||
if (byId("prepare-notification").disabled || !currentTask || !currentProspective) return;
|
||||
pendingNotification = {
|
||||
Target: {TaskID: currentTask.TaskID, GoalID: currentTask.GoalID, ScopeID: currentTask.ScopeID, Revision: currentTask.Revision},
|
||||
ProspectiveItemID: currentProspective.ID,
|
||||
ExpectedRevision: currentProspective.Revision,
|
||||
Confirm: true,
|
||||
};
|
||||
setText("notify-confirm-prospective", pendingNotification.ProspectiveItemID);
|
||||
setText("notify-confirm-prospective-revision", pendingNotification.ExpectedRevision);
|
||||
setText("notify-confirm-task", pendingNotification.Target.TaskID);
|
||||
setText("notify-confirm-task-revision", pendingNotification.Target.Revision);
|
||||
setText("notification-confirmation-error", "", "");
|
||||
byId("notification-dialog").showModal();
|
||||
});
|
||||
|
||||
byId("cancel-notification").addEventListener("click", () => {
|
||||
pendingNotification = null;
|
||||
byId("notification-dialog").close();
|
||||
});
|
||||
|
||||
byId("confirm-notification").addEventListener("click", async () => {
|
||||
if (!pendingNotification) return;
|
||||
const command = pendingNotification;
|
||||
const button = byId("confirm-notification");
|
||||
const prepare = byId("prepare-notification");
|
||||
button.disabled = true;
|
||||
prepare.disabled = true;
|
||||
button.textContent = "Отправляю…";
|
||||
setText("notification-confirmation-error", "", "");
|
||||
try {
|
||||
const result = await request("/api/actions/notify-delivered", {method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify(command)});
|
||||
pendingNotification = null;
|
||||
byId("notification-dialog").close();
|
||||
renderActionResult(result);
|
||||
await loadActionHistory();
|
||||
notify(result.State === "SUCCEEDED" ? "Receiver принял уведомление." : "Исход отправки требует сверки.");
|
||||
} catch (error) {
|
||||
setText("notification-confirmation-error", error.message);
|
||||
} finally {
|
||||
button.disabled = false;
|
||||
button.textContent = "Подтверждаю отправку";
|
||||
updateActionReadiness();
|
||||
}
|
||||
});
|
||||
|
||||
byId("confirm-satisfaction").addEventListener("click", async () => {
|
||||
if (!pendingCommand) return;
|
||||
const command = pendingCommand;
|
||||
|
||||
@@ -164,6 +164,10 @@
|
||||
<button id="prepare-satisfaction" class="commit-button" type="button" disabled>
|
||||
<span>Отметить исполненным</span><span aria-hidden="true">→</span>
|
||||
</button>
|
||||
<div class="notification-command">
|
||||
<div><strong>Windows-напоминание</strong><span id="notification-readiness">Доступно для доставленного ожидания с проверенной Work-задачей.</span></div>
|
||||
<button id="prepare-notification" class="secondary-button" type="button" disabled>Отправить уведомление</button>
|
||||
</div>
|
||||
<div id="action-result" class="action-result" hidden>
|
||||
<div><span>ИСХОД</span><strong id="action-state">—</strong></div>
|
||||
<div><span>ACTION</span><code id="action-id">—</code></div>
|
||||
@@ -209,6 +213,26 @@
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<dialog id="notification-dialog" class="confirmation-dialog" aria-labelledby="notification-confirmation-title">
|
||||
<form method="dialog">
|
||||
<p class="eyebrow">commit / внешнее действие</p>
|
||||
<h2 id="notification-confirmation-title">Отправить напоминание?</h2>
|
||||
<p class="confirmation-copy">Домовой создаст неизменяемое авторизованное действие и передаст типизированное уведомление в закреплённый receiver. Состояние Continuity не изменится; доставка не означает прочтение.</p>
|
||||
<dl class="confirmation-grid">
|
||||
<div><dt>Ожидание</dt><dd id="notify-confirm-prospective">—</dd></div>
|
||||
<div><dt>Ревизия</dt><dd id="notify-confirm-prospective-revision">—</dd></div>
|
||||
<div><dt>Work-задача</dt><dd id="notify-confirm-task">—</dd></div>
|
||||
<div><dt>Ревизия Work</dt><dd id="notify-confirm-task-revision">—</dd></div>
|
||||
<div class="wide"><dt>Канал</dt><dd>Локальное уведомление Windows · закреплённый receiver</dd></div>
|
||||
</dl>
|
||||
<p id="notification-confirmation-error" class="form-error" role="alert"></p>
|
||||
<div class="confirmation-actions">
|
||||
<button id="cancel-notification" class="text-button" type="button">Отмена</button>
|
||||
<button id="confirm-notification" class="commit-button" type="button">Подтверждаю отправку</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<div id="toast" class="toast" role="status" aria-live="polite" hidden></div>
|
||||
<script src="/assets/console.js" defer></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user