Skip to content

Commit 3318570

Browse files
eespiejbostoen
authored andcommitted
N°4756 - ✅ Ease extensibility for CRUD operations : Add unit tests
1 parent 5d1852f commit 3318570

File tree

5 files changed

+770
-8
lines changed

5 files changed

+770
-8
lines changed

core/dbobject.class.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -3345,10 +3345,12 @@ public function DBUpdate()
33453345
$this->m_bDirty = false;
33463346
$this->m_aTouchedAtt = array();
33473347
$this->m_aModifiedAtt = array();
3348-
3348+
$bModifiedByUpdateDone = false;
33493349
try {
33503350
$this->EventUpdateDone($aChanges);
33513351
$this->AfterUpdate();
3352+
// Save the status as it is reset just after...
3353+
$bModifiedByUpdateDone = $this->IsModified();
33523354

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

3391-
if ($this->IsModified()) {
3393+
if ($this->IsModified() || $bModifiedByUpdateDone) {
33923394
// Controlled reentrance
33933395
$this->DBUpdate();
33943396
}

datamodels/2.x/itop-portal-base/portal/public/js/portal_form_handler.js

+17-5
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,24 @@ $(function()
426426
}
427427
else
428428
{
429-
// Try to close the window
430-
window.close();
429+
430+
if(window.history.length == 1) {
431+
432+
// Not a modal, but there is no other history.
433+
// Try to close the window.
434+
window.close();
431435

432-
// 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.
433-
var sHomepageUrl = (this.options.base_url !== null) ? this.options.base_url : $('#sidebar .menu .brick_menu_item:first a').attr('href')
434-
window.location.href = sHomepageUrl;
436+
// 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.
437+
var sHomepageUrl = (this.options.base_url !== null) ? this.options.base_url : $('#sidebar .menu .brick_menu_item:first a').attr('href')
438+
window.location.href = sHomepageUrl;
439+
440+
}
441+
else {
442+
443+
window.history.back(-1);
444+
445+
}
446+
435447
}
436448
},
437449
submit: function(oEvent)

datamodels/2.x/itop-portal-base/portal/templates/bricks/object/mode_create.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
field_set: oFieldSet_{{ sFormIdSanitized }},
7777
submit_btn_selector: $('#{{ sFormId }}').parent().find('.form_btn_submit, .form_btn_transition'),
7878
cancel_btn_selector: $('#{{ sFormId }}').parent().find('.form_btn_cancel'),
79-
base_url: "{{ app['combodo.absolute_url'] }}",
79+
base_url: "{{ app['combodo.portal.base.absolute_url'] }}",
8080
{% if form.submit_rule is not null %}submit_rule: {{ form.submit_rule|json_encode|raw }}{% endif %},
8181
{% if form.cancel_rule is not null %}cancel_rule: {{ form.cancel_rule|json_encode|raw }}{% endif %},
8282
endpoint: "{{ form.renderer.GetEndpoint()|raw }}",

0 commit comments

Comments
 (0)