Skip to content

Added Logistics Tab Search Kit#331

Merged
pokhiii merged 1 commit intodevelopfrom
feat/add-logistics-tab-search-kit
Oct 7, 2024
Merged

Added Logistics Tab Search Kit#331
pokhiii merged 1 commit intodevelopfrom
feat/add-logistics-tab-search-kit

Conversation

@belwalshubham
Copy link
Copy Markdown
Collaborator

@belwalshubham belwalshubham commented Oct 7, 2024

Description

Clicking on the Logistics tab will open a search kit and Once this Pr merged will update the aff.html file to add a Logistics button, which will load a form and pass the option.ccid parameter.

Summary by CodeRabbit

  • New Features

    • Enhanced logistics tab functionality for collection camps with updated configuration.
    • Improved state options retrieval for Indian states, filtering out inactive states.
  • Bug Fixes

    • Corrected method behavior to ensure proper handling of state options for the Eck_Collection_Camp entity.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes in this pull request primarily affect the CollectionCampService class located in wp-content/civi-extensions/goonjcustom/Civi/CollectionCampService.php. Updates were made to the collectionCampTabset method, specifically altering the configuration for the 'logistics' tab, including its module, directive, and template. Additionally, the setIndianStateOptions method was modified to filter and process only the options for the Eck_Collection_Camp entity, focusing on active Indian states. No new methods were added or existing methods removed.

Changes

File Path Change Summary
wp-content/civi-extensions/goonjcustom/Civi/CollectionCampService.php - Updated collectionCampTabset method: changed logistics tab configuration (module, directive, template).
- Modified setIndianStateOptions method to filter options for Indian states only.

Possibly related PRs

  • Refactor: Store entity ID in Eck_Collection_Camp1 in directive #307: This PR modifies the collectionCampTabset method in the CollectionCampService class, which is also a focus of the main PR, specifically regarding the configuration of tabs including the 'logistics' tab.
  • Fix/redirection for new individual signup for pu visit #311: Similar to the main PR, this PR also updates the collectionCampTabset method and the setIndianStateOptions method, refining how state options are processed and tab configurations are managed.
  • bug fixes and refactor #329: This PR introduces new methods in the CollectionCampService class, enhancing functionalities related to logistics emails and contributor tracking, which aligns with the overall focus on improving the CollectionCampService class in the main PR.

Suggested labels

in review

Suggested reviewers

  • pokhiii

Poem

In the fields where rabbits play,
Changes hop in bright array.
Logistics now with clearer sight,
State options dance in pure delight.
With every tweak, our joy will grow,
In the camp where good vibes flow! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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.

@belwalshubham belwalshubham self-assigned this Oct 7, 2024
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
wp-content/civi-extensions/goonjcustom/Civi/CollectionCampService.php (4)

86-88: LGTM! Consider adding a comment explaining the change.

The updates to the 'logistics' tab configuration align well with the PR objective of adding a Logistics Tab Search Kit. The new values for module, directive, and template are more specific and appropriate for the search functionality.

Consider adding a brief comment explaining the reason for this change, which could help future developers understand the context:

 'logistics' => [
   'title' => ts('Logistics'),
+  // Updated to use the new Logistics Tab Search Kit
   'module' => 'afsearchCollectionCampLogistics',
   'directive' => 'afsearch-collection-camp-logistics',
   'template' => 'CRM/Goonjcustom/Tabs/CollectionCamp.tpl',
 ],

Line range hint 1-24: Excellent improvements! Consider caching the custom field lookup.

The updates to setIndianStateOptions method are well-implemented:

  1. Filtering for the 'Eck_Collection_Camp' entity improves specificity.
  2. Including only active Indian states prevents selection of inactive options.

These changes align with best practices for data filtering and entity-specific operations.

Consider caching the result of the CustomField lookup to improve performance, especially if this method is called frequently:

+ private static $intentStateFieldId = null;

 public static function setIndianStateOptions(string $entity, string $field, array &$options, array $params) {
   if ($entity !== 'Eck_Collection_Camp') {
     return;
   }

+  if (self::$intentStateFieldId === null) {
     $intentStateFields = CustomField::get(FALSE)
       ->addWhere('custom_group_id:name', '=', 'Collection_Camp_Intent_Details')
       ->addWhere('name', '=', 'State')
       ->execute();

     $stateField = $intentStateFields->first();
-    $statefieldId = $stateField['id'];
+    self::$intentStateFieldId = $stateField['id'];
+  }

-  if ($field !== "custom_$statefieldId") {
+  if ($field !== "custom_" . self::$intentStateFieldId) {
     return;
   }

   // Rest of the method remains unchanged
 }

This change will cache the custom field ID, reducing database queries on subsequent calls to this method.


Line range hint 1-24: Great addition! Consider adding logging for better traceability.

The createActivityForCollectionCamp method is a valuable addition that aligns well with the PR objectives. It effectively creates activities for collection camps when they are authorized, handling both predefined and custom 'Others' activities.

To improve traceability and debugging, consider adding logging statements:

 public static function createActivityForCollectionCamp(string $op, string $objectName, $objectId, &$objectRef) {
   if ($objectName != 'Eck_Collection_Camp') {
     return;
   }

   $newStatus = $objectRef['Collection_Camp_Core_Details.Status'] ?? '';

   if (!$newStatus || !$objectId) {
     return;
   }

   // ... (existing code)

   foreach ($activities as $activityName) {
     // ... (existing code)

     $results = EckEntity::create('Collection_Camp_Activity', TRUE)
       ->addValue('title', $activityName)
       ->addValue('subtype', $optionValue['value'])
       ->addValue('Collection_Camp_Activity.Collection_Camp_Id', $campId)
       ->addValue('Collection_Camp_Activity.Start_Date', $startDate)
       ->addValue('Collection_Camp_Activity.End_Date', $endDate)
       ->addValue('Collection_Camp_Activity.Organizing_Person', $initiator)
       ->execute();

+    \Civi::log()->info("Created activity '$activityName' for Collection Camp ID: $campId");
   }
+  \Civi::log()->info("Finished creating activities for Collection Camp ID: $campId");
 }

These logging statements will help track the creation of activities and make it easier to debug any issues that may arise.


Line range hint 1-24: Overall excellent changes that enhance collection camp functionality.

The modifications to the CollectionCampService class significantly improve the handling of collection camps, particularly in relation to the Logistics tab. Key improvements include:

  1. Updated 'logistics' tab configuration in collectionCampTabset.
  2. Refined setIndianStateOptions method for better data filtering.
  3. New createActivityForCollectionCamp method for managing camp activities.

These changes align well with the PR objectives and follow good coding practices. The suggestions provided in the individual reviews (adding comments, caching, and logging) will further enhance the code's maintainability and performance.

As the CollectionCampService class grows, consider breaking it down into smaller, more focused classes in the future. This could improve maintainability and make it easier to test individual components. For example, you might create separate classes for handling logistics, activities, and state options.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 67ce170 and 1a42309.

📒 Files selected for processing (1)
  • wp-content/civi-extensions/goonjcustom/Civi/CollectionCampService.php (1 hunks)
🧰 Additional context used

@belwalshubham belwalshubham requested a review from pokhiii October 7, 2024 05:34
@belwalshubham belwalshubham changed the title Add Logistics Tab Search Kit Added Logistics Tab Search Kit Oct 7, 2024
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