ListingEditor.svelte (28195B)
1 <script lang="ts"> 2 /* global document, setInterval, clearInterval */ 3 import { getContext, onMount, tick } from 'svelte'; 4 import ListingReview from './ListingReview.svelte'; 5 import ConflictNotice from './ConflictNotice.svelte'; 6 import ConfirmPanel from './ConfirmPanel.svelte'; 7 import InboxSetup from './InboxSetup.svelte'; 8 import { 9 PUBLIC_RUNTIME_CONTEXT, 10 publicRuntimeReady, 11 publicRuntimePolicy, 12 type PublicRuntimeContext, 13 type PublicRuntime 14 } from '../runtime/public-runtime.ts'; 15 import { 16 createRuntimeInboxSetupView, 17 inboxSetupViewOwnership, 18 inboxSetupViewSnapshot, 19 subscribeInboxSetupView, 20 closeInboxSetupView, 21 type InboxSetupView 22 } from '../messaging/inbox-setup-view.ts'; 23 import { 24 openEditorReview, 25 editorReviewSnapshot, 26 closeEditorReview, 27 publishEditorRevision, 28 stopEditorAction, 29 editorPublicationOperation, 30 type EditorReview, 31 type EditorFormError 32 } from '../publishing/editor-workflow.ts'; 33 import type { ListingOperationView } from '../publishing/listing-operation-view.ts'; 34 import CapabilityGate from './CapabilityGate.svelte'; 35 import Notice from './Notice.svelte'; 36 import OperationStatus from './OperationStatus.svelte'; 37 import { foodUnits } from '../contracts/food-availability-v1/values.ts'; 38 import type { PublicDraftForm } from '../contracts/local-records.ts'; 39 import { 40 IDENTITY_VIEW_CONTEXT, 41 identityViewSnapshot, 42 subscribeIdentityView, 43 connectIdentityView, 44 disconnectIdentityView, 45 type IdentityViewContext 46 } from '../runtime/view-context.ts'; 47 import { 48 openListingEditor, 49 listingEditorSnapshot, 50 editListingEditor, 51 saveAndCloseListingEditor, 52 closeListingEditor, 53 subscribeListingEditor, 54 listingEditorEditSource, 55 observeListingEditor, 56 type ListingEditor as Editor, 57 type ListingEditorRoute, 58 type ListingEditorSnapshot 59 } from '../publishing/listing-editor.ts'; 60 import { internalHref } from '../navigation-url.ts'; 61 import { operationCapabilities } from '../runtime/capabilities.ts'; 62 let { 63 route, 64 onfirstsave, 65 onsavedclose, 66 inboxController 67 }: { 68 route: ListingEditorRoute; 69 onfirstsave?: (draftId: string, current: () => boolean) => Promise<void>; 70 onsavedclose?: () => Promise<void>; 71 inboxController?: InboxSetupView; 72 } = $props(); 73 const context = getContext<IdentityViewContext>(IDENTITY_VIEW_CONTEXT); 74 const publicContext = getContext<PublicRuntimeContext>( 75 PUBLIC_RUNTIME_CONTEXT 76 ); 77 let runtime = $state.raw<PublicRuntime | undefined>(), 78 setup = $state.raw<InboxSetupView | undefined>(); 79 let setupState = $state(inboxSetupViewSnapshot(undefined)); 80 let review = $state.raw<EditorReview | undefined>(), 81 reviewBusy = $state(false); 82 let soldConfirm = $state(false), 83 withdrawalConfirm = $state(false), 84 publishBusy = $state(false); 85 let publicationOperation = $state.raw<ListingOperationView | undefined>(); 86 let errors = $state<readonly EditorFormError[]>([]), 87 reviewMessage = $state(''); 88 let identity = $state(identityViewSnapshot(context)), 89 mounted = $state(false), 90 editor = $state.raw<Editor | undefined>(), 91 snapshot = $state<ListingEditorSnapshot>(), 92 unavailable = $state(false); 93 let closeBusy = $state(false), 94 navigationFailed = $state(false); 95 let firstNavigation: Promise<void> | undefined; 96 let firstOwner: Editor | undefined; 97 type Form = { 98 -readonly [Key in keyof PublicDraftForm]: PublicDraftForm[Key]; 99 }; 100 const blankForm = (): Form => ({ 101 title: '', 102 description: '', 103 location: '', 104 amount: '', 105 currency: '', 106 unit: '', 107 quantity: '', 108 contactType: '', 109 contactValue: '' 110 }); 111 let form = $state<Form>(blankForm()); 112 const admittedAuthor = $derived( 113 identity.identity.state !== 'guest' && identity.identity.state !== 'pending' 114 ? identity.identity.publicKey 115 : undefined 116 ); 117 const active = $derived(mounted && identity.mounted); 118 const visible = $derived( 119 snapshot && 120 editor && 121 identity.mounted && 122 identity.identity.state !== 'guest' && 123 identity.identity.state !== 'pending' && 124 identity.identity.publicKey === snapshot.owner && 125 listingEditorSnapshot(editor) 126 ); 127 const editable = $derived( 128 !!(visible && visible.editable && !publicationOperation && !publishBusy) 129 ); 130 const availability = $derived( 131 operationCapabilities( 132 (runtime && publicRuntimePolicy(runtime)) ?? 133 inboxSetupViewOwnership(setup)?.policy 134 ) 135 ); 136 onMount(() => { 137 mounted = true; 138 const off = subscribeIdentityView(context, (next) => { 139 identity = next; 140 }); 141 if (publicContext) 142 void publicRuntimeReady(publicContext) 143 .then((value) => { 144 if (mounted) runtime = value; 145 }) 146 .catch(() => { 147 /* Draft saving does not depend on inbox setup. */ 148 }); 149 return () => { 150 mounted = false; 151 off(); 152 }; 153 }); 154 $effect(() => { 155 const author = admittedAuthor, 156 available = active, 157 source = runtime, 158 supplied = inboxController; 159 if (!available || !author) { 160 setup = undefined; 161 setupState = inboxSetupViewSnapshot(undefined); 162 return; 163 } 164 const owned = 165 supplied ?? (source && createRuntimeInboxSetupView(context, source)); 166 setup = owned; 167 const off = owned 168 ? subscribeInboxSetupView(owned, (next) => { 169 setupState = next; 170 }) 171 : () => {}; 172 return () => { 173 off(); 174 if (owned) closeInboxSetupView(owned); 175 }; 176 }); 177 const visibleReview = $derived.by(() => { 178 if ( 179 (!setupState.owner && route.mode !== 'edit') || 180 !snapshot || 181 !visible || 182 !review 183 ) 184 return; 185 return editorReviewSnapshot(review) ? review : undefined; 186 }); 187 $effect(() => { 188 const resource = route, 189 author = admittedAuthor, 190 editRuntime = route.mode === 'edit' ? runtime : undefined; 191 if (!active || !author) { 192 editor = undefined; 193 snapshot = undefined; 194 form = blankForm(); 195 unavailable = false; 196 return; 197 } 198 const cancellation = new AbortController(); 199 let alive = true, 200 owned: Editor | undefined, 201 off = () => {}; 202 const observer = 203 resource.mode === 'edit' 204 ? setInterval(() => { 205 if (owned) observeListingEditor(owned); 206 }, 250) 207 : undefined; 208 editor = undefined; 209 snapshot = undefined; 210 review = undefined; 211 publicationOperation = undefined; 212 soldConfirm = false; 213 withdrawalConfirm = false; 214 errors = []; 215 reviewMessage = ''; 216 form = blankForm(); 217 unavailable = false; 218 void openListingEditor( 219 context, 220 resource, 221 cancellation.signal, 222 editRuntime 223 ).then((result) => { 224 if (!alive) { 225 if (result.status === 'ready') closeListingEditor(result.editor); 226 return; 227 } 228 if (result.status !== 'ready') { 229 unavailable = true; 230 return; 231 } 232 owned = result.editor; 233 editor = owned; 234 const next = listingEditorSnapshot(owned); 235 if (!next) { 236 unavailable = true; 237 return; 238 } 239 snapshot = next; 240 form = { ...next.form }; 241 off = subscribeListingEditor(owned, () => { 242 snapshot = owned && listingEditorSnapshot(owned); 243 if ( 244 snapshot?.state === 'saved' && 245 snapshot.draftId && 246 resource.mode === 'new' && 247 owned && 248 firstOwner !== owned && 249 !closeBusy && 250 onfirstsave 251 ) { 252 firstOwner = owned; 253 firstNavigation = onfirstsave( 254 snapshot.draftId, 255 () => 256 alive && 257 mounted && 258 editor === owned && 259 !!owned && 260 !!listingEditorSnapshot(owned) 261 ).catch(() => { 262 if (alive) navigationFailed = true; 263 }); 264 } 265 if (!snapshot) { 266 unavailable = true; 267 form = blankForm(); 268 } 269 }); 270 }); 271 return () => { 272 alive = false; 273 if (observer !== undefined) clearInterval(observer); 274 cancellation.abort(); 275 off(); 276 if (owned) closeListingEditor(owned); 277 if (editor === owned && review) closeEditorReview(review); 278 form = blankForm(); 279 }; 280 }); 281 function changed() { 282 const original = editor; 283 if (!original || !listingEditorSnapshot(original)?.editable) return; 284 if (review) closeEditorReview(review); 285 review = undefined; 286 errors = []; 287 soldConfirm = false; 288 withdrawalConfirm = false; 289 void editListingEditor(original, { ...form }); 290 } 291 async function showReview( 292 status: 'active' | 'sold' | 'withdrawal' = 'active' 293 ) { 294 const original = editor, 295 resource = route, 296 author = admittedAuthor; 297 if ( 298 reviewBusy || 299 closeBusy || 300 publishBusy || 301 publicationOperation || 302 !availability.posting || 303 (route.mode !== 'edit' && !availability.newListing) || 304 !original || 305 !listingEditorSnapshot(original)?.editable 306 ) 307 return; 308 reviewBusy = true; 309 try { 310 const result = await openEditorReview( 311 original, 312 setup, 313 { ...form }, 314 status 315 ); 316 if ( 317 !mounted || 318 editor !== original || 319 route !== resource || 320 admittedAuthor !== author || 321 !listingEditorSnapshot(original) 322 ) { 323 if (result.status === 'review') closeEditorReview(result.review); 324 return; 325 } 326 if (result.status === 'blocked') { 327 errors = result.errors; 328 reviewMessage = result.message; 329 await tick(); 330 document.querySelector<HTMLElement>('#listing-review-errors')?.focus(); 331 return; 332 } 333 if (review) closeEditorReview(review); 334 review = result.review; 335 errors = []; 336 reviewMessage = ''; 337 await tick(); 338 if (mounted && editor === original && editorReviewSnapshot(result.review)) 339 document.querySelector<HTMLElement>('#listing-review-heading')?.focus(); 340 } finally { 341 reviewBusy = false; 342 } 343 } 344 async function editDetails() { 345 if (review) closeEditorReview(review); 346 review = undefined; 347 errors = []; 348 reviewMessage = ''; 349 await tick(); 350 if (mounted && editor && listingEditorSnapshot(editor)?.editable) 351 document.querySelector<HTMLInputElement>('#listing-title')?.focus(); 352 } 353 async function publishChanges() { 354 const original = review, 355 resource = route, 356 author = admittedAuthor; 357 if ( 358 !original || 359 publishBusy || 360 publicationOperation || 361 !availability.posting || 362 route.mode !== 'edit' 363 ) 364 return; 365 publishBusy = true; 366 try { 367 const result = await publishEditorRevision( 368 original, 369 editorReviewSnapshot(original)?.withdrawal 370 ? 'publish_reviewed_withdrawal' 371 : 'publish_reviewed_revision' 372 ); 373 if ( 374 !mounted || 375 review !== original || 376 route !== resource || 377 admittedAuthor !== author 378 ) 379 return; 380 publicationOperation = editorPublicationOperation(original); 381 if (result.status !== 'completed') 382 reviewMessage = 383 'The update did not complete. Your proposed draft remains here. Check any retained operation before another attempt.'; 384 } finally { 385 publishBusy = false; 386 } 387 } 388 function fieldError(field: keyof PublicDraftForm) { 389 return errors.find((value) => value.field === field); 390 } 391 function fieldId(field: keyof PublicDraftForm) { 392 return ( 393 'listing-' + 394 (field === 'contactType' 395 ? 'contact-type' 396 : field === 'contactValue' 397 ? 'contact-value' 398 : field) 399 ); 400 } 401 function connect() { 402 return connectIdentityView(context); 403 } 404 async function saveClose() { 405 const original = editor, 406 resource = route, 407 author = admittedAuthor; 408 if ( 409 closeBusy || 410 publishBusy || 411 publicationOperation || 412 !original || 413 !listingEditorSnapshot(original)?.editable 414 ) 415 return; 416 closeBusy = true; 417 try { 418 const saved = await saveAndCloseListingEditor(original); 419 await firstNavigation; 420 if ( 421 !saved || 422 !mounted || 423 editor !== original || 424 route !== resource || 425 !author || 426 admittedAuthor !== author 427 ) 428 return; 429 await onsavedclose?.(); 430 } catch { 431 if (mounted) navigationFailed = true; 432 } finally { 433 closeBusy = false; 434 } 435 } 436 function disconnect() { 437 disconnectIdentityView(context); 438 } 439 const title = $derived( 440 route.mode === 'new' 441 ? 'New listing' 442 : route.mode === 'draft' 443 ? 'Continue draft' 444 : 'Edit listing' 445 ); 446 </script> 447 448 <svelte:head 449 ><title>{title} ยท HarvestCircle</title><meta 450 name="robots" 451 content="noindex" 452 /></svelte:head 453 > 454 <div class="page page--reading stack"> 455 <a 456 href={internalHref( 457 route.mode === 'edit' ? `/products/${route.naddr}` : '/selling' 458 )}>{route.mode === 'edit' ? 'Back to listing' : 'Back to Selling'}</a 459 > 460 <h1>{title}</h1> 461 {#if !visible} 462 <CapabilityGate 463 identity={identity.identity} 464 required="connection" 465 focusTarget="protected" 466 onconnect={mounted ? connect : undefined} 467 ondisconnect={disconnect} 468 /> 469 {#if unavailable}<Notice 470 tone="warning" 471 text={route.mode === 'draft' 472 ? 'This draft is not available here.' 473 : route.mode === 'edit' 474 ? 'Supported local listing values are not available for editing. Keep this listing read-only.' 475 : 'Browser storage is unavailable. Your existing local data has not been reset.'} 476 />{:else if identity.identity.state !== 'guest' && identity.identity.state !== 'pending'}<p 477 role="status" 478 > 479 Loading local values. 480 </p>{/if} 481 {:else} 482 {#if !availability.posting}<Notice 483 tone="info" 484 text="Posting is unavailable here. Keep editing your local draft; retained operations still need separate review." 485 />{:else if route.mode !== 'edit' && !availability.newListing}<Notice 486 tone="info" 487 text="New listings require messaging availability as well as inbox readiness. Your local draft remains available." 488 />{/if} 489 {#if route.mode === 'edit' && editor && listingEditorEditSource(editor)} 490 <ConflictNotice 491 source={listingEditorEditSource(editor)!} 492 proposed={form} 493 /> 494 {#if editable}<Notice 495 tone="info" 496 text="Changes stay local until you review and publish them." 497 />{/if} 498 {/if} 499 {#if !editable}<Notice 500 tone="info" 501 text={route.mode === 'draft' 502 ? 'This draft has a retained listing operation. Keep its original outcome for reconciliation.' 503 : 'These retained local values are read-only until the current listing is checked.'} 504 />{:else}<p> 505 Changes are saved in this browser. Browser storage is not a backup. 506 </p>{/if} 507 {#if reviewMessage}<Notice tone="warning" text={reviewMessage} />{/if} 508 {#if soldConfirm && editable}<ConfirmPanel 509 title="Confirm sold update" 510 text="Marking this listing as sold is a public availability update, not a payment or stock reservation receipt. Review the exact update before publishing." 511 confirmLabel="Review sold update" 512 onconfirm={() => { 513 soldConfirm = false; 514 void showReview('sold'); 515 }} 516 oncancel={() => { 517 soldConfirm = false; 518 }} 519 />{/if} 520 {#if withdrawalConfirm && editable}<ConfirmPanel 521 title="Confirm removal request" 522 text="This public request asks clients to stop displaying the listing. It cannot erase all other copies. Review the exact target before publishing." 523 confirmLabel="Review removal request" 524 onconfirm={() => { 525 withdrawalConfirm = false; 526 void showReview('withdrawal'); 527 }} 528 oncancel={() => { 529 withdrawalConfirm = false; 530 }} 531 />{/if} 532 {#if visibleReview}<ListingReview 533 review={visibleReview} 534 onedit={editDetails} 535 onpublish={route.mode === 'edit' 536 ? () => { 537 void publishChanges(); 538 } 539 : undefined} 540 publishing={publishBusy} 541 captured={!!publicationOperation} 542 />{:else} 543 {#if errors.length}<div 544 id="listing-review-errors" 545 tabindex="-1" 546 role="alert" 547 > 548 <p>Check these listing fields. Your input remains here.</p> 549 <ul> 550 {#each errors as error (error.field)}<li> 551 <a href={internalHref('#' + fieldId(error.field))} 552 >{error.message}</a 553 > 554 </li>{/each} 555 </ul> 556 </div>{/if} 557 <form 558 class="stack" 559 onsubmit={(event) => event.preventDefault()} 560 novalidate 561 > 562 <div class="field"> 563 <label class="label" for="listing-title">Product name</label><input 564 id="listing-title" 565 aria-invalid={fieldError('title') ? 'true' : undefined} 566 aria-errormessage={fieldError('title') 567 ? 'listing-title-error' 568 : undefined} 569 type="text" 570 value={form.title} 571 oninput={(event) => { 572 form = { ...form, title: event.currentTarget.value }; 573 changed(); 574 }} 575 readonly={!editable} 576 /> 577 {#if fieldError('title')}<p id="listing-title-error"> 578 {fieldError('title')?.message} 579 </p>{/if} 580 </div> 581 <div class="field"> 582 <label class="label" for="listing-description">Description</label 583 ><textarea 584 id="listing-description" 585 aria-invalid={fieldError('description') ? 'true' : undefined} 586 aria-errormessage={fieldError('description') 587 ? 'listing-description-error' 588 : undefined} 589 rows="6" 590 value={form.description} 591 oninput={(event) => { 592 form = { ...form, description: event.currentTarget.value }; 593 changed(); 594 }} 595 readonly={!editable}></textarea> 596 {#if fieldError('description')}<p id="listing-description-error"> 597 {fieldError('description')?.message} 598 </p>{/if} 599 </div> 600 <div class="field"> 601 <label class="label" for="listing-location">Public area</label> 602 <p id="listing-location-hint" class="text-small"> 603 A town or collection area is enough. 604 </p> 605 <input 606 id="listing-location" 607 aria-invalid={fieldError('location') ? 'true' : undefined} 608 aria-errormessage={fieldError('location') 609 ? 'listing-location-error' 610 : undefined} 611 type="text" 612 aria-describedby="listing-location-hint" 613 value={form.location} 614 oninput={(event) => { 615 form = { ...form, location: event.currentTarget.value }; 616 changed(); 617 }} 618 readonly={!editable} 619 /> 620 {#if fieldError('location')}<p id="listing-location-error"> 621 {fieldError('location')?.message} 622 </p>{/if} 623 </div> 624 <div class="cluster"> 625 <div class="field"> 626 <label class="label" for="listing-amount">Price</label><input 627 id="listing-amount" 628 aria-invalid={fieldError('amount') ? 'true' : undefined} 629 aria-errormessage={fieldError('amount') 630 ? 'listing-amount-error' 631 : undefined} 632 type="text" 633 inputmode="decimal" 634 value={form.amount} 635 oninput={(event) => { 636 form = { ...form, amount: event.currentTarget.value }; 637 changed(); 638 }} 639 readonly={!editable} 640 /> 641 {#if fieldError('amount')}<p id="listing-amount-error"> 642 {fieldError('amount')?.message} 643 </p>{/if} 644 </div> 645 <div class="field"> 646 <label class="label" for="listing-currency">Currency</label><input 647 id="listing-currency" 648 aria-invalid={fieldError('currency') ? 'true' : undefined} 649 aria-errormessage={fieldError('currency') 650 ? 'listing-currency-error' 651 : undefined} 652 type="text" 653 maxlength="3" 654 value={form.currency} 655 oninput={(event) => { 656 form = { ...form, currency: event.currentTarget.value }; 657 changed(); 658 }} 659 readonly={!editable} 660 /> 661 {#if fieldError('currency')}<p id="listing-currency-error"> 662 {fieldError('currency')?.message} 663 </p>{/if} 664 </div> 665 <div class="field"> 666 <label class="label" for="listing-unit">Per</label><select 667 id="listing-unit" 668 aria-invalid={fieldError('unit') ? 'true' : undefined} 669 aria-errormessage={fieldError('unit') 670 ? 'listing-unit-error' 671 : undefined} 672 value={form.unit} 673 onchange={(event) => { 674 form = { ...form, unit: event.currentTarget.value }; 675 changed(); 676 }} 677 disabled={!editable} 678 ><option value="">Choose a unit</option 679 >{#each foodUnits as unit (unit)}<option value={unit} 680 >{unit}</option 681 >{/each}</select 682 > 683 {#if fieldError('unit')}<p id="listing-unit-error"> 684 {fieldError('unit')?.message} 685 </p>{/if} 686 </div> 687 </div> 688 <div class="field"> 689 <label class="label" for="listing-quantity" 690 >Advertised quantity (optional)</label 691 > 692 <p id="listing-quantity-unit"> 693 {form.unit || 'Uses the selected price unit'} 694 </p> 695 <input 696 id="listing-quantity" 697 aria-invalid={fieldError('quantity') ? 'true' : undefined} 698 aria-errormessage={fieldError('quantity') 699 ? 'listing-quantity-error' 700 : undefined} 701 type="text" 702 inputmode="decimal" 703 aria-describedby="listing-quantity-unit" 704 value={form.quantity} 705 oninput={(event) => { 706 form = { ...form, quantity: event.currentTarget.value }; 707 changed(); 708 }} 709 readonly={!editable} 710 /> 711 {#if fieldError('quantity')}<p id="listing-quantity-error"> 712 {fieldError('quantity')?.message} 713 </p>{/if} 714 </div> 715 <details> 716 <summary>Add public contact details (optional)</summary> 717 <div class="stack"> 718 <p>Only add contact details you want to include publicly.</p> 719 <div class="field"> 720 <label class="label" for="listing-contact-type" 721 >Public contact type</label 722 ><select 723 id="listing-contact-type" 724 aria-invalid={fieldError('contactType') ? 'true' : undefined} 725 aria-errormessage={fieldError('contactType') 726 ? 'listing-contact-type-error' 727 : undefined} 728 value={form.contactType} 729 onchange={(event) => { 730 const value = event.currentTarget.value; 731 if ( 732 value === '' || 733 value === 'email' || 734 value === 'phone' || 735 value === 'https' 736 ) { 737 form = { ...form, contactType: value }; 738 changed(); 739 } 740 }} 741 disabled={!editable} 742 ><option value="">No public contact</option><option 743 value="email">Email</option 744 ><option value="phone">Phone</option><option value="https" 745 >Website</option 746 ></select 747 > 748 {#if fieldError('contactType')}<p id="listing-contact-type-error"> 749 {fieldError('contactType')?.message} 750 </p>{/if} 751 </div> 752 <div class="field"> 753 <label class="label" for="listing-contact-value" 754 >Public contact details</label 755 ><input 756 id="listing-contact-value" 757 aria-invalid={fieldError('contactValue') ? 'true' : undefined} 758 aria-errormessage={fieldError('contactValue') 759 ? 'listing-contact-value-error' 760 : undefined} 761 type="text" 762 value={form.contactValue} 763 oninput={(event) => { 764 form = { ...form, contactValue: event.currentTarget.value }; 765 changed(); 766 }} 767 readonly={!editable} 768 /> 769 {#if fieldError('contactValue')}<p 770 id="listing-contact-value-error" 771 > 772 {fieldError('contactValue')?.message} 773 </p>{/if} 774 </div> 775 </div> 776 </details> 777 </form> 778 {#if editable}<button 779 type="button" 780 onclick={() => { 781 void showReview(); 782 }} 783 disabled={reviewBusy || 784 closeBusy || 785 !availability.posting || 786 (route.mode !== 'edit' && !availability.newListing)} 787 >{reviewBusy 788 ? 'Preparing review' 789 : route.mode === 'edit' 790 ? 'Review changes' 791 : 'Review listing'}</button 792 >{/if} 793 {/if} 794 {#if editable && route.mode === 'edit' && !visibleReview}<details> 795 <summary>Other listing actions</summary> 796 <button 797 type="button" 798 onclick={() => { 799 soldConfirm = true; 800 }} 801 disabled={reviewBusy || closeBusy || !availability.posting} 802 >Mark as sold</button 803 > 804 <button 805 type="button" 806 onclick={() => { 807 withdrawalConfirm = true; 808 }} 809 disabled={reviewBusy || closeBusy || !availability.posting} 810 >Request removal</button 811 > 812 </details>{/if} 813 {#if publishBusy && review && editorReviewSnapshot(review)?.withdrawal} 814 <p> 815 Stop stops further attempts; it cannot retract requests already sent or 816 whose outcome is unknown. 817 </p> 818 <button 819 type="button" 820 onclick={() => { 821 if (review) stopEditorAction(review); 822 }}>Stop current action</button 823 > 824 {/if} 825 {#if publicationOperation}<OperationStatus 826 publicOperation={publicationOperation} 827 />{/if} 828 {#if editable && route.mode !== 'edit' && setup}<InboxSetup 829 controller={setup} 830 inline 831 />{/if} 832 {#each visible.operations as operation (operation)}<OperationStatus 833 publicOperation={operation} 834 />{/each} 835 {#if editable}<button 836 type="button" 837 onclick={saveClose} 838 disabled={closeBusy || reviewBusy}>Save and close</button 839 >{/if} 840 {#if navigationFailed}<Notice 841 tone="warning" 842 text="Navigation did not complete. Your saved local data remains in this browser." 843 />{/if} 844 {#if editable}<p role="status"> 845 {visible.state === 'saved' 846 ? 'Saved in this browser.' 847 : visible.state === 'saving' 848 ? 'Saving in this browser.' 849 : visible.state === 'failed' 850 ? 'Not saved. Keep your current input here.' 851 : 'Not yet saved.'} 852 </p> 853 {#if visible.failure}<Notice 854 tone="warning" 855 text="Saving did not complete. Keep your current input. Existing local data has not been reset." 856 />{/if}{/if} 857 {/if} 858 </div>