Skip to content

Implement Core Feedback Object Hierarchy #4366

@ozer550

Description

@ozer550

Overview

Implement the base feedback object hierarchy, consisting of BaseFeedback, BaseFeedbackEvent, BaseFeedbackInteractionEvent, BaseFlagFeedback, and FlagFeedbackEvent. These classes should form the foundation for creating feedback objects in the feedback mechanism.

Description and outcomes

  • Create a utility file called feedbackApiUtils.js in frontend/shared folder.
  • Define constants FLAG_FEEDBACK_EVENT_URL and FeedbackTypeOptions to ensure consistency.
    FeedbackTypeOptions should be:
      {
              imported: 'imported',
              rejected: 'rejected',
              previewed: 'previewed',
              showmore: 'showmore',
              ignored: 'ignored',
              flagged: 'flagged',
      }
  • BaseFeedBack Class:

    • Create a class named BaseFeedback with the constructor accepting parameters for context, contentnode_id, and content_id.
    • Include the properties: id, context, contentnode_id, and content_id.
    • Add class method getDataObject to construct a data object excluding functions from the current instance. This should be used to convert the feedback object into a format suitable for API requests.
    • The getDataObject method should return an object excluding the URL field of the class.
    • Add class method getUrl to retrieve the object's URL. Throw an error if URL is not defined.
  • BaseFeedbackEvent Class:

    • Extend BaseFeedback to create the class BaseFeedbackEvent.
    • Utilize the parameters from the BaseFeedback class by passing them to the super constructor.
    • Add fields for user and target_channel_id to the constructor.
  • BaseFeedbackInteractionEvent Class:

    • Extend BaseFeedback to create the class BaseFeedbackInteractionEvent.
    • Utilize the parameters from the BaseFeedbackInteractionEven class by passing them to the super constructor.
    • Add fields for feedback_type and feedback_reason to the constructor.
  • BaseFlagFeedback Class:

    • Extend BaseFeedbackInteractionEvent to create the class BaseFlagFeedback.
    • Add fields for target_topic_id to the constructor.
  • FlagFeedbackEvent Class:

    • Extend BaseFlagFeedback to create the class FlagFeedbackEvent.
    • Add the URL property and set it to FLAG_FEEDBACK_EVENT_URL.

Acceptance criteria

  • Inheritance should be maintained with each subsequent class extending the previous one.
  • Constants FLAG_FEEDBACK_EVENT_URL and FeedbackTypeOptions should be appropriately defined.
  • The BaseFeedback class should be correctly implemented with properties and methods as specified.
  • Unit tests

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions