这是indexloc提供的服务,不要输入任何密码
Skip to content

Toggle Publish/Unpublish Button for Documents #380

@DennisAlund

Description

@DennisAlund

Description

Implement a button that toggles between "Publish" and "Unpublish" based on the published status of the document. When the document is unpublished, the button should display "Publish" and set the publishedAt attribute to the current server timestamp. When the document is published, the button should display "Unpublish" and set the publishedAt attribute to null.

Requirements

  1. Publish Button:

    • If the document is unpublished (publishedAt attribute is null), the button should display "Publish".
    • Clicking the "Publish" button should set the publishedAt attribute to the current server timestamp.
  2. Unpublish Button:

    • If the document is published (publishedAt attribute is not null), the button should display "Unpublish".
    • Clicking the "Unpublish" button should set the publishedAt attribute to null.

Steps to Accomplish

  1. Add Button to UI:

    • Add a button to the document editor page that displays "Publish" or "Unpublish" based on the publishedAt attribute of the document.
  2. Implement Publish Functionality:

    • When the "Publish" button is clicked, update the document's publishedAt attribute to the current server timestamp using Firestore's FieldValue.serverTimestamp().
  3. Implement Unpublish Functionality:

    • When the "Unpublish" button is clicked, update the document's publishedAt attribute to null.

Acceptance Criteria

  • The document editor page includes a button that toggles between "Publish" and "Unpublish" based on the document's publishedAt attribute.
  • Clicking the "Publish" button sets the document's publishedAt attribute to the current server timestamp.
  • Clicking the "Unpublish" button sets the document's publishedAt attribute to null.

Screenshots

image

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions