Skip to content

Commit

Permalink
N°4756 - ✅ Ease extensibility for CRUD operations : Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eespie authored and jbostoen committed Jan 16, 2023
1 parent 5d1852f commit 3318570
Show file tree
Hide file tree
Showing 5 changed files with 770 additions and 8 deletions.
6 changes: 4 additions & 2 deletions core/dbobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3345,10 +3345,12 @@ public function DBUpdate()
$this->m_bDirty = false;
$this->m_aTouchedAtt = array();
$this->m_aModifiedAtt = array();

$bModifiedByUpdateDone = false;
try {
$this->EventUpdateDone($aChanges);
$this->AfterUpdate();
// Save the status as it is reset just after...
$bModifiedByUpdateDone = $this->IsModified();

// Reset original values although the object has not been reloaded
foreach ($this->m_aLoadedAtt as $sAttCode => $bLoaded) {
Expand Down Expand Up @@ -3388,7 +3390,7 @@ public function DBUpdate()
MetaModel::StopReentranceProtection(Metamodel::REENTRANCE_TYPE_UPDATE, $this);
}

if ($this->IsModified()) {
if ($this->IsModified() || $bModifiedByUpdateDone) {
// Controlled reentrance
$this->DBUpdate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,24 @@ $(function()
}
else
{
// Try to close the window
window.close();

if(window.history.length == 1) {

// Not a modal, but there is no other history.
// Try to close the window.
window.close();

// In some browser (eg. Firefox 70), window won't close if it has NOT been open by JS. In that case, we try to redirect to homepage as a fallback.
var sHomepageUrl = (this.options.base_url !== null) ? this.options.base_url : $('#sidebar .menu .brick_menu_item:first a').attr('href')
window.location.href = sHomepageUrl;
// In some browser (eg. Firefox 70), window won't close if it has NOT been open by JS. In that case, we try to redirect to homepage as a fallback.
var sHomepageUrl = (this.options.base_url !== null) ? this.options.base_url : $('#sidebar .menu .brick_menu_item:first a').attr('href')
window.location.href = sHomepageUrl;

}
else {

window.history.back(-1);

}

}
},
submit: function(oEvent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
field_set: oFieldSet_{{ sFormIdSanitized }},
submit_btn_selector: $('#{{ sFormId }}').parent().find('.form_btn_submit, .form_btn_transition'),
cancel_btn_selector: $('#{{ sFormId }}').parent().find('.form_btn_cancel'),
base_url: "{{ app['combodo.absolute_url'] }}",
base_url: "{{ app['combodo.portal.base.absolute_url'] }}",
{% if form.submit_rule is not null %}submit_rule: {{ form.submit_rule|json_encode|raw }}{% endif %},
{% if form.cancel_rule is not null %}cancel_rule: {{ form.cancel_rule|json_encode|raw }}{% endif %},
endpoint: "{{ form.renderer.GetEndpoint()|raw }}",
Expand Down
Loading

0 comments on commit 3318570

Please sign in to comment.