Skip to content

Conversation

@phev8
Copy link
Contributor

@phev8 phev8 commented Jul 17, 2025

No description provided.

- Introduced the `CopyPaste` class to handle copying and pasting of survey items and components, including support for nested structures and translations.
- Implemented methods for copying items, pasting items with unique key generation, and handling component-specific copy-paste operations.
- Enhanced the `SurveyEditor` class to integrate copy-paste methods, allowing users to copy and paste items and components directly within the editor.
- Added comprehensive tests to ensure the correctness of copy-paste operations, including validation of clipboard data formats and error handling for non-existent items.
- Improved overall functionality and user experience in the survey editor by enabling efficient item management through copy-paste capabilities.
@phev8 phev8 changed the base branch from master to develop-v2 July 17, 2025 14:21
@phev8
Copy link
Contributor Author

phev8 commented Jul 17, 2025

bugbot run

cursor[bot]

This comment was marked as outdated.

phev8 added 4 commits July 17, 2025 17:00
- Removed prefill rules from the `Survey` and `JsonSurvey` types, streamlining the data structure.
- Updated the `CopyPaste` class to eliminate prefills from clipboard data, simplifying the copy-paste functionality.
- Adjusted related tests to reflect the removal of prefill handling, ensuring consistency across the codebase.
- Replaced the `CopyPaste` class with `ItemCopyPaste` to streamline item copy-paste operations.
- Updated tests to reflect changes in the copy-paste implementation, ensuring compatibility with the new class structure.
- Removed unused component copy functionality and adjusted related methods in `SurveyEditor` for improved clarity and maintainability.
- Introduced a new `survey-item-component-json.ts` file to separate JSON schema definitions for item components, enhancing code organization.
- Updated TypeScript target from ES6 to ES2023 in `tsconfig.json` for improved language features.
- Removed the `yarn.lock` file to streamline dependency management.
- Refactored expression classes to use `declare` for type properties, enhancing clarity and consistency in `expression.ts`, `survey-item.ts`, and `survey-item-editors.ts`.
- Added error handling in `SurveyEditor` for duplicate item keys in groups, improving robustness in item management.
- Introduced a new `GroupItemEditor` class to manage group items, including methods for item ordering, swapping, and adding/removing child items, enhancing the survey editor's functionality.
@phev8
Copy link
Contributor Author

phev8 commented Jul 18, 2025

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: TypeScript `declare` Misuse Causes Runtime Errors

The commit incorrectly replaced definite assignment assertions (!) with the declare keyword for several class properties. The declare keyword tells TypeScript a property exists but is initialized elsewhere, generating no JavaScript code for it. This change causes runtime errors for properties that are not initialized in their constructors (e.g., responseConfig in SingleChoiceQuestionItem and MultipleChoiceQuestionItem). When these objects are instantiated directly, such properties remain undefined, leading to crashes upon access. For properties that are assigned in their constructors (e.g., type, _currentItem, componentType), using declare is semantically incorrect and misleading.

src/survey/components/survey-item-component.ts#L142-L143

export class DisplayComponent extends ItemComponent {
declare componentType: DisplayComponentTypes;

src/survey-editor/survey-item-editors.ts#L244-L245

abstract class ScgMcgEditor extends QuestionEditor {
declare protected _currentItem: SingleChoiceQuestionItem | MultipleChoiceQuestionItem;

src/survey/items/survey-item.ts#L513-L514

itemType: SurveyItemType.SingleChoiceQuestion = SurveyItemType.SingleChoiceQuestion;
declare responseConfig: ScgMcgChoiceResponseConfig;

src/survey/items/survey-item.ts#L529-L530

itemType: SurveyItemType.MultipleChoiceQuestion = SurveyItemType.MultipleChoiceQuestion;
declare responseConfig: ScgMcgChoiceResponseConfig;

src/survey/components/survey-item-component.ts#L238-L239

items: Array<ScgMcgOptionBase>;
declare shuffleItems?: boolean;

src/survey/components/survey-item-component.ts#L289-L290

export abstract class ScgMcgOptionBase extends ItemComponent {
declare componentType: ScgMcgOptionTypes;

src/expressions/expression.ts#L112-L119

export class ConstExpression extends Expression {
declare type: ExpressionType.Const;
value?: ValueType;
constructor(value?: ValueType, editorConfig?: ExpressionEditorConfig) {
super(ExpressionType.Const, editorConfig);
this.value = value;
this.type = ExpressionType.Const;

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

phev8 added 4 commits July 18, 2025 15:12
…gMcgChoiceResponseConfig` and `SingleChoiceQuestionItem` classes to streamline code and improve clarity.
…and group management

- Introduced the `ItemInitHelper` class to facilitate the creation and management of survey items, including unique key generation for groups.
- Implemented methods for adding groups with customizable shuffle options and ensuring unique keys among siblings.
- Added comprehensive tests in `item-init-helper.test.ts` to validate key generation logic, group creation, and error handling scenarios.
- Enhanced the `SurveyEditor` class to support new item management functionalities, improving overall survey editing capabilities.
- Expanded the `ItemInitHelper` class to include methods for creating survey end items, page breaks, and display items, enhancing the survey item management capabilities.
- Implemented unique key generation for each new item, ensuring no conflicts within the survey structure.
- Updated the `surveyEnd` and `pageBreak` methods to support optional positioning for item insertion.
- Added comprehensive tests in `item-init-helper.test.ts` to validate the new functionalities and ensure robust error handling for non-existent parents.
- Enhanced the `survey-editor` module to export the `ItemInitHelper`, making it accessible for broader use in the survey editing process.
…n handling

- Added tests for creating and adding display items, single choice questions, and multiple choice questions in `item-init-helper.test.ts`, ensuring comprehensive coverage for new item types.
- Updated the `SurveyEditor` class to conditionally set item translations only if content is provided, improving robustness in translation management.
- Enhanced existing tests to verify the correct positioning of items within parent groups and ensure proper error handling for non-existent parents.
@coderabbitai
Copy link

coderabbitai bot commented Aug 8, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copy-paste

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

- Removed unused imports and commented-out methods in `item-copy-paste.ts` to streamline the code and improve clarity.
- Updated `item-init-helper.test.ts` to remove the import of `SingleChoiceQuestionItem`, reflecting changes in item management.
- Enhanced overall maintainability by eliminating redundant code and focusing on essential functionalities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants