-
Notifications
You must be signed in to change notification settings - Fork 110
Section functionality #2824
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
Draft
shynkaruck
wants to merge
5
commits into
nextcloud:main
Choose a base branch
from
shynkaruck:form_section
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Section functionality #2824
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # Add Section functionality to Nextcloud Forms | ||
|
|
||
| ## Description | ||
|
|
||
| This PR adds a new "Section" element type to Nextcloud Forms that acts as a visual separator to group fields logically, without affecting data storage, validation, or submission logic. | ||
|
|
||
| ## Functional Requirements | ||
|
|
||
| ### 1. Section Creation | ||
| - New "Section" element type in the form editor | ||
| - Only parameter: section name (title) visible to users | ||
|
|
||
| ### 2. Editor Display | ||
| - Sections appear as non-input elements | ||
| - Draggable for reordering | ||
| - Title displayed in bold/visually distinct style | ||
| - No description field for sections | ||
| - Bottom separator line for visual distinction | ||
|
|
||
| ### 3. Form Filling Display | ||
| - Sections display as headings/subheadings at their position | ||
| - No influence on validation, mandatory fields, or submission flow | ||
|
|
||
| ### 4. Export/View Responses Behavior | ||
| - Sections do not affect CSV export or response viewing | ||
| - Not stored in user responses | ||
|
|
||
| ## Technical Implementation | ||
|
|
||
| ### Backend Changes | ||
|
|
||
| #### Constants and Types | ||
| - **`lib/Constants.php`**: Added `ANSWER_TYPE_SECTION = 'section'` constant | ||
| - **`lib/ResponseDefinitions.php`**: Updated `FormsQuestionType` to include `"section"` | ||
|
|
||
| #### API Controller (`lib/Controller/ApiController.php`) | ||
| - **Section Validation**: Sections cannot be required, have options, or file uploads | ||
| - **Answer Storage**: Sections are filtered out from answer storage | ||
| - **Export Filtering**: Sections are excluded from submissions export | ||
| - **Form Cloning**: Sections maintain `isRequired = false` when cloning forms | ||
|
|
||
| #### Submission Service (`lib/Service/SubmissionService.php`) | ||
| - **Export Data**: Sections are filtered out from CSV/Excel export data | ||
| - **Validation**: Sections are ignored during submission validation | ||
|
|
||
| ### Frontend Changes | ||
|
|
||
| #### Components | ||
| - **`src/components/Questions/QuestionSection.vue`**: New component for section rendering | ||
| - **`src/components/Questions/Question.vue`**: Updated to support section display and editing | ||
| - **`src/models/AnswerTypes.js`**: Added section type with appropriate icon and labels | ||
| - **`src/models/Constants.ts`**: Added `ANSWER_TYPE_SECTION` constant | ||
|
|
||
| #### Views | ||
| - **`src/views/Create.vue`**: Updated to pass question type to components | ||
| - **`src/views/Submit.vue`**: Updated to filter sections from validation and storage | ||
| - **`src/components/Results/ResultsSummary.vue`**: Updated to handle sections in results display | ||
| - **`src/components/Results/Submission.vue`**: Updated to filter sections from submission data | ||
|
|
||
| ## Testing | ||
|
|
||
| ### Backend Tests | ||
|
|
||
| #### ApiControllerTest.php | ||
| - `testUpdateQuestion_sectionCannotBeRequired()`: Verifies sections cannot be made required | ||
| - `testNewOption_sectionCannotHaveOptions()`: Verifies sections cannot have options | ||
| - `testUploadFiles_sectionCannotHaveFileUploads()`: Verifies sections cannot have file uploads | ||
| - `testGetSubmissions_sectionsAreFilteredOut()`: Verifies sections are filtered from export | ||
| - `testNewSubmission_sectionsAreNotStored()`: Verifies sections are not stored in answers | ||
|
|
||
| #### SubmissionServiceTest.php | ||
| - `testGetSubmissionsData_sectionsAreFilteredOut()`: Verifies sections are filtered from export data | ||
| - `testValidateSubmission_sectionsAreIgnored()`: Verifies sections are ignored in validation | ||
| - `testValidateSubmission_sectionsCannotBeRequired()`: Verifies sections cannot be required in validation | ||
|
|
||
| ## Files Changed | ||
|
|
||
| ### Backend Files | ||
| - `lib/Constants.php` - Added section constant | ||
| - `lib/ResponseDefinitions.php` - Updated type definitions | ||
| - `lib/Controller/ApiController.php` - Added section validation and filtering | ||
| - `lib/Service/SubmissionService.php` - Added export filtering | ||
|
|
||
| ### Frontend Files | ||
| - `src/components/Questions/QuestionSection.vue` - New section component | ||
| - `src/components/Questions/Question.vue` - Updated for section support | ||
| - `src/models/AnswerTypes.js` - Added section type | ||
| - `src/models/Constants.ts` - Added section constant | ||
| - `src/views/Create.vue` - Updated component props | ||
| - `src/views/Submit.vue` - Updated validation and storage logic | ||
| - `src/components/Results/ResultsSummary.vue` - Updated results display | ||
| - `src/components/Results/Submission.vue` - Updated submission handling | ||
|
|
||
| ### Test Files | ||
| - `tests/Unit/Controller/ApiControllerTest.php` - Added section tests | ||
| - `tests/Unit/Service/SubmissionServiceTest.php` - Added section tests | ||
|
|
||
| ## Screenshots | ||
|
|
||
| ### Before | ||
| - No section functionality available | ||
|
|
||
| ### After | ||
| - Section element available in form editor | ||
| - Sections display as visual separators with titles | ||
| - Sections can be reordered like other form elements | ||
| - Sections do not appear in form submissions or exports | ||
|
|
||
| ## Breaking Changes | ||
| None. This is a purely additive feature that does not affect existing functionality. | ||
|
|
||
| ## Notes to Reviewers | ||
|
|
||
| - All hardcoded string literals have been replaced with constants (`Constants::ANSWER_TYPE_SECTION` on backend, `ANSWER_TYPE_SECTION` on frontend) | ||
| - Sections are completely filtered out from data storage and export to ensure they don't affect existing functionality | ||
| - Comprehensive test coverage has been added for all section-related functionality | ||
| - The implementation follows Nextcloud Forms coding standards and patterns | ||
|
|
||
| ## Related Issues | ||
| This PR implements the section functionality as requested in the technical specification. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please remove this file from the PR