Skip to content

Conversation

@tlamDson
Copy link

@tlamDson tlamDson commented Dec 9, 2025

Purpose

The CropSelector component used in the Harvest form previously included a "+" button that allowed users to add new crop types. This behavior is inconsistent with the workflow, as a crop must exist and be planted before it can be harvested.

This PR removes that "+" button to prevent the creation of new crops during the harvest process.

Verification steps

Follow these steps manually to confirm that the fix behaves correctly:

  1. Open the Harvest form (FarmData2 -> Harvest).
  2. Locate the "Crop" dropdown selector.
  3. Verify that the green "+" button is NOT present on the right edge of the input.
  4. Navigate to the Seeding form ( or any other from using CropSelector component).
  5. Locate the "Crop" dropdown selector.
  6. Verify that the "+" button is visible and functional (assuming the user has permission).

Approach

  • Updated CropSelector Component: Added a new prop called allowCreate which defaults to true to maintain existing behavior in other forms.
  • Logic Change: Updated the component's creation logic to check both the user's existing permissions (canCreate) and this new allowCreate prop before setting the popupUrl.
  • UI Behavior: If allowCreate is false, popupUrl remains null, which signals the underlying SelectorBase to hide the "+" add button.
  • Implementation: For the Harvest form in the modules/farm_fd2/src/entrypoints/harvest/App.vue, passed v-bind:allowCreate="false" to the CropSelector to explicitly disable crop creation in this specific workflow.

Testing

We added a new Cypress component test named Check that allowCreate prop handles visibility of crop plus button. This test mounts the CropSelector component with the allowCreate prop set to false and verifies that the "+" button is correctly hidden.

Related issues

Closes #279

Additional information

Time spent: ~1 hour

Licensing Certification

FarmData2 is a Free Cultural Work and all accepted contributions are licensed as described in the LICENSE.md file. This requires that the contributor holds the rights to do so. By submitting this pull request I certify that I satisfy the terms of the Developer Certificate of Origin for its contents.

* Remove the plus button from cropselector in harvest form

* Add else handle statement

---------

Co-authored-by: aaronshin43 <aaronshin.exe@gmail.com>
Copilot AI review requested due to automatic review settings December 9, 2025 04:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the "+" button from the CropSelector component in the Harvest form to enforce that crops must be planted before they can be harvested, addressing a workflow inconsistency.

  • Added an allowCreate prop to CropSelector component with default value true
  • Updated the Harvest form to pass allowCreate="false" to CropSelector
  • Modified the component logic to check both user permissions and the new prop before showing the "+" button

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
modules/farm_fd2/src/entrypoints/harvest/App.vue Added allowCreate="false" prop to CropSelector to disable crop creation in harvest workflow
components/CropSelector/CropSelector.vue Added new allowCreate prop and updated logic to conditionally hide the "+" button based on this prop

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (this.canCreateCrop && this.allowCreate) {
this.popupUrl = '/admin/structure/taxonomy/manage/plant_type/add';
} else {
this.popUrl = null;
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Typo in variable name: popUrl should be popupUrl. This will cause the "+" button to remain visible even when allowCreate is set to false, as the correct variable (popupUrl) won't be set to null.

Suggested change
this.popUrl = null;
this.popupUrl = null;

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

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

This change should be made. Currently the solution is working only because this.popupURL is null by default, but not because of this line.

Copy link
Author

Choose a reason for hiding this comment

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

We delete the unecessary else statement for the popUrl.

Copy link

@braughtg braughtg left a comment

Choose a reason for hiding this comment

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

Overall this is looking pretty good. There are some changes that have been requested.

In addition, the E2E tests for the Harvest form should confirm that the "+" button is not visible when the CropSelector is used on the Harvest form. The component test requested checks that the new prop works, this test will check that that prop has actually been set by the Harvest form.

Please make the requested changes and push them to this PR. When you have made the changes change the PR back to "Ready for review".

if (this.canCreateCrop && this.allowCreate) {
this.popupUrl = '/admin/structure/taxonomy/manage/plant_type/add';
} else {
this.popUrl = null;

Choose a reason for hiding this comment

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

This change should be made. Currently the solution is working only because this.popupURL is null by default, but not because of this line.

@braughtg braughtg marked this pull request as draft December 10, 2025 13:55
aaronshin43 and others added 3 commits December 12, 2025 17:08
* Fix typo in variable name popupUrl

* Add JSDoc documentation for allowCreate prop

* Add test case to check the allowCreate prop works
* Remove the plus button from cropselector in harvest form

* Add else handle statement

* Delete unecessary else statement for the popUrl

---------

Signed-off-by: Aaron Shin <aaronshin.exe@gmail.com>
Co-authored-by: aaronshin43 <aaronshin.exe@gmail.com>
@tlamDson tlamDson marked this pull request as ready for review December 12, 2025 22:18
Copy link

@braughtg braughtg left a comment

Choose a reason for hiding this comment

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

Looks good! Very nicely done.

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.

Harvest form should not allow a new crop to be added.

3 participants