Skip to content

Commit

Permalink
reload data record after canceled edit in modal window
Browse files Browse the repository at this point in the history
  • Loading branch information
blazej.kuhajda committed Dec 10, 2024
1 parent 27497b2 commit f8c3614
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ else
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">@Vm.SelectedRecord?.DataEntityId</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="() => { Vm.UnLocked(); }"></button>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="() => { Vm.UnLocked(); ReloadRecordAfterEditedWithoudModal(); }"></button>
</div>
<div class="modal-body">
@if (Vm.IsLockedByMeOrNull())
Expand Down Expand Up @@ -525,7 +525,7 @@ else
@* <button type="button" class="btn btn-primary @(!Vm.IsLockedByMeOrNull() ? "disabled" : null)" data-bs-dismiss="modal" @onclick="async () => { await Vm.Edit(); Vm.UnLocked(); }">@Localizer["Save"]</button> *@
<button type="button" class="btn btn-primary mx-1" data-bs-toggle="modal" data-bs-target="#AckEditUpdateModal-@ViewGuid">@Localizer["Update"]</button>

<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="() => { Vm.UnLocked(); }">@Localizer["Close"]</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="() => { Vm.UnLocked(); ReloadRecordAfterEditedWithoudModal(); }">@Localizer["Close"]</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -585,13 +585,13 @@ else
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">@Localizer["Update"] record : "@Vm.SelectedRecord?.DataEntityId"?</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="() => { Vm.UnLocked(); }"></button>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="() => { Vm.UnLocked();ReloadRecordAfterEditedWithoudModal(); }"></button>
</div>
<div class="modal-footer">

<button type="button" class="btn btn-primary @(!Vm.IsLockedByMeOrNull() ? "disabled" : null)" data-bs-dismiss="modal" @onclick="async () => { await Vm.Edit(); Vm.UnLocked(); }">@Localizer["Update"]</button>

<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="() => { Vm.UnLocked(); }">@Localizer["Close"]</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="() => { Vm.UnLocked(); ReloadRecordAfterEditedWithoudModal(); }">@Localizer["Close"]</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,28 @@
using AXOpen.Base.Data;
using AXOpen.Data.Interfaces;
using AXOpen.Data;

using AXOpen.Data.Interfaces;

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using System.IO;
using AXOpen.Core;
using AXOpen.Base.Dialogs;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using static AXOpen.Data.DataExchangeViewModel;

using AXOpen.Data;

using AXSharp.Connector;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging;

using Microsoft.AspNetCore.Components.Forms;
using AXOpen.Data.Interfaces;
using AXOpen.Core;
using AXOpen.Data;

using System.Data.Common;

namespace AXOpen.Data;
Expand Down Expand Up @@ -177,9 +183,27 @@ public async Task LoadCustomExportDataAsync()
StateHasChanged();
}

protected void ReloadRecordAfterEditWithoutModal()
{
if (this.ModalDataView) return; // make a sense when is not modal window

string identifier = Vm.SelectedRecord.DataEntityId;

Vm.FillObservableRecordsAsync().GetAwaiter();

var rec = Vm.Records.Where(e => e.DataEntityId == identifier).First();

if (rec != null)
{
Vm.SelectedRecord = rec;

this.StateHasChanged();
}
}

public void Dispose()
{
if(Vm.IsLockedByMeOrNull())
if (Vm.IsLockedByMeOrNull())
Vm.DataExchange.SetLockedBy(null);
}
}

0 comments on commit f8c3614

Please sign in to comment.