-
Notifications
You must be signed in to change notification settings - Fork 0
Copy paste #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop-v2
Are you sure you want to change the base?
Copy paste #7
Conversation
- 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.
|
bugbot run |
- 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.
|
bugbot run |
There was a problem hiding this 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
survey-engine/src/survey/components/survey-item-component.ts
Lines 142 to 143 in 6c7a8e0
| export class DisplayComponent extends ItemComponent { | |
| declare componentType: DisplayComponentTypes; |
src/survey-editor/survey-item-editors.ts#L244-L245
survey-engine/src/survey-editor/survey-item-editors.ts
Lines 244 to 245 in 6c7a8e0
| abstract class ScgMcgEditor extends QuestionEditor { | |
| declare protected _currentItem: SingleChoiceQuestionItem | MultipleChoiceQuestionItem; |
src/survey/items/survey-item.ts#L513-L514
survey-engine/src/survey/items/survey-item.ts
Lines 513 to 514 in 6c7a8e0
| itemType: SurveyItemType.SingleChoiceQuestion = SurveyItemType.SingleChoiceQuestion; | |
| declare responseConfig: ScgMcgChoiceResponseConfig; |
src/survey/items/survey-item.ts#L529-L530
survey-engine/src/survey/items/survey-item.ts
Lines 529 to 530 in 6c7a8e0
| itemType: SurveyItemType.MultipleChoiceQuestion = SurveyItemType.MultipleChoiceQuestion; | |
| declare responseConfig: ScgMcgChoiceResponseConfig; |
src/survey/components/survey-item-component.ts#L238-L239
survey-engine/src/survey/components/survey-item-component.ts
Lines 238 to 239 in 6c7a8e0
| items: Array<ScgMcgOptionBase>; | |
| declare shuffleItems?: boolean; |
src/survey/components/survey-item-component.ts#L289-L290
survey-engine/src/survey/components/survey-item-component.ts
Lines 289 to 290 in 6c7a8e0
| export abstract class ScgMcgOptionBase extends ItemComponent { | |
| declare componentType: ScgMcgOptionTypes; |
src/expressions/expression.ts#L112-L119
survey-engine/src/expressions/expression.ts
Lines 112 to 119 in 6c7a8e0
| 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; |
Was this report helpful? Give feedback by reacting with 👍 or 👎
…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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
- 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.
No description provided.