Repository navigation
Person attributes - #3161
Person attributes#3161DamianoSilverhand wants to merge 5 commits into
Conversation
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
We'll rebase / review again after next changes for item import of @objecttothis are integrated. |
objecttothis
left a comment
There was a problem hiding this comment.
I didn't do a full review. Just the one change that I noted.
| $failCodes[] = $i; | ||
| $failed_row = $i+1; | ||
| $failCodes[] = $failed_row; | ||
| log_message("ERROR","CSV Item import failed on line ". $failed_row .". This customer was not imported."); |
There was a problem hiding this comment.
This line needs to change. I think it probably needs to read something like log_message("ERROR","CSV Customer import failed on line ". $failed_row .". This customer was not imported.");
There was a problem hiding this comment.
Also, if you aren't using string interpolation you need to use ' not ". " calls the parser unnecessarily when there are no variables to parse. That said, this line would be better written with string interpolation:
log_message("ERROR","CSV Customer import failed on line $failed_row. This customer was not imported.");
There was a problem hiding this comment.
@DamianoSilverhand still motivated to drive this one home?
There was a problem hiding this comment.
@jekkos if you can get the Person Attributes to show in the table view he might get interested in it again. LOL
There was a problem hiding this comment.
I have cloned and rebased the branch and pushed it to the organisation's repo now.. let's see what changes are in there.
There was a problem hiding this comment.
you're right, we need to fix that first so this change can be implemented correctly
There was a problem hiding this comment.
@jekkos I downloaded this version but Now I am unable to update an employee. The Dev server does the same. Unable to update Employee. I can create a new Employee. The Demo server also does not allow the Employee to be updated and I am getting no errors with errors set to 1 . I narrowed it down to the following commit. Check username before employee creation (#3239)
There was a problem hiding this comment.
Ok thanks for testing, I'll have look later, I probably missed something there. It might have been better to implement the check as a jQuery validation instead.
fddedb8 to
6d106d6
Compare
32cd824 to
cce2c1c
Compare
2772920 to
0f3175b
Compare
|
@DamianoSilverhand now that CI4 has been merged into the master can you rebase your changes so we can proceed? |
|
@jekkos this PR seems to have gone stale. It is a change I will eventually get to, but other changes are taking priority at the moment. Do you have any thoughts for what we should do with this PR? I never heard back from @DamianoSilverhand. |
PR #3161 Rework Plan - Person Attributes (Unified Architecture)This is a plan to modernize and properly implement person attributes using the unified attribute system. Current StatusI'm working on a reimplementation based on the latest CI4 master branch with the following approach: Architectural ApproachUsing Unified Attribute System (instead of separate person_attribute tables):
Implementation Progress✅ Completed:
🔄 In Progress:
📋 Remaining:
Benefits of Unified Approach
WorktreeWorking in: I'll update this PR as progress continues. Feedback welcome on the architectural approach. |
Excellent choice to re-use the existing architecture to add person attributes. We need to consider indices on the attribute_links table and rework them so they are optimized for the queries we are doing. Right now there are potentially too many indices, which will slow down write operations. With attribute_definitions we likely need to maintain two different views in the UI. One for Person Attributes and the other for Item attributes. In the attribute_definitions table we should add a person_attribute column to store the boolean value so that the business logic in each model can properly return only item attributes or only person attributes. |
We also need to make sure person attributes are not allowed to be added to items and vis a versa. If we are keeping one Model and Controller for Attributes rather than breaking it into two, that's fine but we need to think through the best way to structure CRUD methods then so that we are not writing a lot of redundant code. Potentially one way to do this would be to add a parameter to indicate the attribute type. This could be a Something to consider regarding visibility is that it should not just affect the manage.php view in terms of which columns show up in the table. visibility should also prevent that type of attribute from being added to that type of person. Currently in item attributes I believe visibility just affects whether it appears in the table. We need a way of restricting person attributes from being added to specific types of people. For example a DROPDOWN attribute called "Role" may be good to show up for Employees but we don't want it appearing in Customer views. Visibility is how we should do that restricting, but I don't think we should change the current behavior for item attributes. |
Progress UpdateThe person attributes implementation is progressing well. Here's the current status: ✅ Completed
🔄 Remaining
Constants (bit flags)SHOW_IN_ITEMS = 1
SHOW_IN_SALES = 2
SHOW_IN_RECEIVINGS = 4
SHOW_IN_SEARCH = 8
SHOW_IN_CUSTOMERS = 16
SHOW_IN_EMPLOYEES = 32
SHOW_IN_SUPPLIERS = 64Working in worktree: |
Implementation Complete ✓The person attributes implementation is now complete. Here's the summary: Files ChangedNew Files:
Modified Files:
Constants (Bit Flags)SHOW_IN_ITEMS = 1
SHOW_IN_SALES = 2
SHOW_IN_RECEIVINGS = 4
SHOW_IN_SEARCH = 8
SHOW_IN_CUSTOMERS = 16
SHOW_IN_EMPLOYEES = 32
SHOW_IN_SUPPLIERS = 64Architecture
Next Steps
Worktree: |
Rebase Complete ✓The branch has been rebased on top of the latest master (commit 165c335). Conflict Resolved
Files ChangedThe branch is now ready for testing. The person attributes feature has been properly integrated with the latest changes from master. |
| $this->load->view("customers/form", $data); | ||
| } | ||
|
|
||
| /* |
There was a problem hiding this comment.
PHPdocs that don't add information of value should be removed completely.
| Adds Person_attributes to customer controller | ||
| */ | ||
|
|
||
| public function person_attributes($customer_id = -1) |
There was a problem hiding this comment.
All new code should have PSR compliant function and variable names.
| Adds Person_attributes to customer controller | ||
| */ | ||
|
|
||
| public function person_attributes($customer_id = -1) |
There was a problem hiding this comment.
-1 should be replaced with a constant. I think we use NEW_ENTRY for this
|
|
||
|
|
||
| foreach($data['definition_values'] as $definition_id => $definition_value) | ||
| { |
There was a problem hiding this comment.
All new code must be PSR compliant. All of this new code needs to be refactored with curly braces in the correct places.
| Adds Person_attributes to customer controller | ||
| */ | ||
|
|
||
| public function person_attributes($customer_id = -1) |
There was a problem hiding this comment.
This function name does not describe what the function does. It should be renamed to correctly describe what the function does. If this is the corollary to getAttributes() in the Items controller then it should be renamed to getPersonAttributes()
| foreach($data['definition_values'] as $definition_id => $definition_value) | ||
| { | ||
| $person_attribute_value = $this->Person_attribute->get_person_attribute_value($customer_id, $definition_id); | ||
|
|
There was a problem hiding this comment.
Delete one extra line here
|
|
||
|
|
||
| $data['definition_names'] = $this->Person_attribute->get_definition_names(); | ||
|
|
There was a problem hiding this comment.
the extra empty lines in this function. Generally variable definitions would have no blank lines between them and code blocks would have one blank line before/after.
| $this->load->view('person_attributes/person', $data); | ||
| } | ||
|
|
||
| /* |
There was a problem hiding this comment.
This code is all old CI3 code, so all the conflicts need to be resolved in this branch before I review more.
Addressing Review FeedbackThank you @objecttothis for the detailed architectural feedback. Let me address each point: 1. Database Indices on
|
Addressing Review Feedback - Changes AppliedBased on @objecttothis feedback, I have made the following updates: 1. Added
|
You need to resolve the branch conflicts before proceeding further. |
Using a tinyint as a bitmask will handle up to 8 flags and it only requires one column per row, but that's about it for the advantages. It's difficult to maintain the code and is not easily human readable. I recommend that we create a parent PR here to first migrate our current infrastructure for flags to a mapping table. A clean model for this can be created in code which will not only unclutter the attribute model, but will create better SRP adherence. A migration would need to be made to migrate existing flags, but that wouldn't take too much work to do. |
- Add person_id column to attribute_links table for person attributes - Add person_attribute column to attribute_definitions to distinguish item vs person attributes - Add visibility flags: SHOW_IN_CUSTOMERS, SHOW_IN_EMPLOYEES, SHOW_IN_SUPPLIERS - Add person attribute methods to Attribute model (getAttributesByPerson, savePersonAttributeLink, etc.) - Refactor Persons controller with shared attribute handling (getPersonAttributes, savePersonAttributes) - Update Customers, Employees, Suppliers controllers with PSR-12 naming and attribute integration - Create attributes/person.php view for rendering person attributes - Add person attributes container to customer/employee/supplier forms Relates to #3161
|
This PR has been superseded by PR #4521 which contains a complete rework of the person attributes feature based on the latest master branch with the unified attribute system approach. |
This PR adds person attributes on Customers, Suppliers and Employees. Also includes person attributes in customer import using csv.