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
Removing Merge button from Add New Company View #13679
base: 5.x
Are you sure you want to change the base?
Conversation
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.
Thanks for fixing this! 👍🏻
@@ -209,7 +209,7 @@ public function newAction(Request $request, $entity = null) | |||
$leadFieldModel = $this->getModel('lead.field'); | |||
\assert($leadFieldModel instanceof FieldModel); | |||
$fields = $leadFieldModel->getPublishedFieldArrays('company'); | |||
$form = $model->createForm($entity, $this->formFactory, $action, ['fields' => $fields, 'update_select' => $updateSelect]); | |||
$form = $model->createForm($entity, $this->formFactory, $action, ['fields' => $fields, 'update_select' => $updateSelect, 'hide_extra_buttons' => true]); |
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.
- Let's call it what it really does.
- Let's avoid double negatives as those are hard to comprehend and break my brain (like hide = false)
$form = $model->createForm($entity, $this->formFactory, $action, ['fields' => $fields, 'update_select' => $updateSelect, 'hide_extra_buttons' => true]); | |
$form = $model->createForm($entity, $this->formFactory, $action, ['fields' => $fields, 'update_select' => $updateSelect, 'show_merge_button' => false]); |
Or, perhaps we could avoid this extra config option altogether if we'd base the condition if the company ID exists or not?
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.
Yes! I'll do the change
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 5.x #13679 +/- ##
============================================
- Coverage 61.39% 61.30% -0.09%
+ Complexity 34034 34006 -28
============================================
Files 2240 2238 -2
Lines 101714 101652 -62
============================================
- Hits 62443 62318 -125
- Misses 39271 39334 +63
|
01a42f4
to
acc043a
Compare
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.
@nishant-s7 Please add PHPUnit tests for this change.
Ref: https://contribute.mautic.org/contributing-to-mautic/developer/code/pull-requests#writing-tests
] | ||
), | ||
|
||
if (null === $options['data']->id) { |
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.
Are you sure this will work? On the line 117 I can see it's accessed as $options['data']->getId()
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.
It did work when I logged it, I also checked for the expected behavior and it worked fine. Should I change it to getId()
to be on the safer side?
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.
There is some Twig magic where it looks if the property exists, if not it tries if getId()
exists and if so it will use that. I'd prefer to use directly the entity method than the magic.
if (null === $options['data']->id) { | |
if (null === $options['data']->getId()) { |
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.
Works for me 👍
Description:
This PR removes the redundant Merge button when creating a new company, which makes sure the incorrect modal with "New" button (as mentioned in the issue) is not displayed.
Steps to test this PR:
Companies
and click onNew
.Merge
button is not displayed when creating a new company, but, it is visible once the company is saved, showing the correct modal on clicking it.