@extends($layout) @section('content') @php $hiddenRelatesLabels = $relatesLabels ?? []; // Metric preview — from the SAVED values; re-renders on save. $mType = $canvasItem['metricType'] ?: 'number'; // new goals default to # (no math) $mStart = (float) ($canvasItem['startValue'] ?? 0); $mCur = (float) ($canvasItem['currentValue'] ?? 0); $mGoal = (float) ($canvasItem['endValue'] ?? 0); $mPct = ($mGoal - $mStart) != 0 ? max(0, min(100, (($mCur - $mStart) / ($mGoal - $mStart)) * 100)) : 0; $fmtM = function ($v) use ($mType) { $v = (float) $v; if ($mType === 'percent') return rtrim(rtrim(number_format($v, 2), '0'), '.') . '%'; if ($mType === 'currency') return '$' . number_format($v, $v == floor($v) ? 0 : 2); return rtrim(rtrim(number_format($v, 2), '0'), '.'); }; @endphp
{{-- Section headers use the SYSTEM modal recipe (h4.widgettitle .title-light — same as Subtasks/Discussion/Schedule on the task modal), not a dialog-private eyebrow style. --}}

{{ $canvasTypes[$canvasItem['box']]['title'] }}

{{-- ── Tabs on top — the nav frames the whole workspace (review 2026-08-03). The old Goal tab dissolved: name lives below the tabs (shared by both), status/dates/relates in the Details rail. New goals have only Progress, so no bar at all. ── --}} @if ($id !== '')
@endif {{-- Name — one label only (the placeholder); the modal's GOAL header already names the object, so no third repetition. --}}
{{-- ── Tab: Edit — the goal's DEFINITION (metric, type, start, target). One-time setup, separated from the recurring monitoring job (review 2026-08-03). --}}
{{-- ── Tab: Progress — MONITORING. The RA pattern: the readout's number IS the input (click in, type, blur = saved via HTMX). All the bars live here — the goal metric plus each linked milestone's own read-only bar. The Milestones tab MANAGES the links; this tab watches them. --}}
@include('goalcanvas::partials.progressReadout') {{-- Milestone bars — read-only context, one quiet row per linked milestone. Goal progress stays metric-defined (Marcel): these never aggregate into the bar above. --}} @if (count($goalMilestones ?? []) > 0)
@foreach ($goalMilestones as $ms)
{{-- Status dot — the monitoring signal, moved here from the management list; it also carries the status color when the bar sits at 0%. --}} {{ $ms['headline'] }}
{{ (int) $ms['percentDone'] }}%
@endforeach
@endif
{{-- ── Tab: Milestones ── --}} @if ($id !== '')
{{-- Summary + chips live in a partial so the chip-remove hx-post re-renders the whole section (counts + arrow stay correct — deleting only the chip left them stale). --}} @include('goalcanvas::partials.milestonesSection') @if ($login::userIsAtLeast($roles::$editor)) @endif
@endif {{-- ── Actions (main column; Delete lives in the Details rail) ── --}} @if ($login::userIsAtLeast($roles::$editor))
{{ __('buttons.save_and_close') }}
@endif
{{-- /gv-main --}} {{-- ── Details rail — the essentials (Docs-article pattern). ── --}}
{{-- /gv-cols --}}
{{-- Discussion — the comments submodule brings its OWN
; it must stay a SIBLING of the goal form: nested, the HTML parser drops the inner form tag and its close tag closes the OUTER form, orphaning every field and button after it (Save did nothing). --}} @if ($id !== '')

{{ __('subtitles.discussion') }}

@include('comments::submodules.generalComment', ['formUrl' => '/goalcanvas/editCanvasItem/' . $id])
@endif
@endsection