viecomponent logic
This commit is contained in:
parent
e9ac19406e
commit
479914dc8a
|
|
@ -10,7 +10,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Components
|
|||
{
|
||||
// Here you can fetch data for this grid if needed
|
||||
// For demo, just pass the model
|
||||
return View(model.ViewComponentName +".cshtml", model);
|
||||
return View(model.ViewComponentLocation, model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ using System.Text.Json;
|
|||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Components
|
||||
{
|
||||
[ViewComponent(Name = "TestChildGrid")]
|
||||
public class TestChildGridViewComponent : ViewComponent
|
||||
[ViewComponent(Name = "TestGridComponent")]
|
||||
public class TestGridComponent : ViewComponent
|
||||
{
|
||||
public IViewComponentResult Invoke(TestGridModel model)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
public async Task<IActionResult> OrderList(OrderSearchModel searchModel)
|
||||
{
|
||||
//prepare model
|
||||
//var orderListModel = await GetOrderListModelByFilter(searchModel);
|
||||
var orderListModel = new OrderListModel();
|
||||
var orderListModel = await GetOrderListModelByFilter(searchModel);
|
||||
//var orderListModel = new OrderListModel();
|
||||
|
||||
var valami = Json(orderListModel);
|
||||
Console.WriteLine(valami);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using DevExtreme.AspNet.Mvc.FileManagement;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure.Internal;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DevExtreme.NETCore.Demos.Controllers
|
||||
|
|
@ -20,12 +21,15 @@ namespace DevExtreme.NETCore.Demos.Controllers
|
|||
[Route("api/file-manager-file-system", Name = "FileManagementFileSystemApi")]
|
||||
public object FileSystem(FileSystemCommand command, string arguments, int orderId)
|
||||
{
|
||||
|
||||
string path = Request.Headers["TestHeader"];
|
||||
|
||||
var valami = new List<int>();
|
||||
|
||||
var config = new FileSystemConfiguration
|
||||
{
|
||||
Request = Request,
|
||||
FileSystemProvider = new PhysicalFileSystemProvider(_webHostEnvironment.ContentRootPath + $"/wwwroot/uploads/orders/{orderId}"),
|
||||
FileSystemProvider = new PhysicalFileSystemProvider(_webHostEnvironment.ContentRootPath + $"/wwwroot/uploads/orders/order{path}"),
|
||||
//uncomment the code below to enable file/folder management
|
||||
//AllowCopy = true,
|
||||
//AllowCreate = true,
|
||||
|
|
|
|||
|
|
@ -42,18 +42,30 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
var testGridModel2 = new TestGridModel();
|
||||
testGridModel2.GridName = "Orders";
|
||||
testGridModel2.ViewComponentName = "ShippingDocumentGridComponent";
|
||||
testGridModel2.ViewComponentLocation = "~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/ShippingDocumentGridComponent.cshtml";
|
||||
testGridModel2.Configuration = new GridConfiguration();
|
||||
testGridModel2.Configuration.ShowChildGridsAsTabs = true;
|
||||
testGridModel2.ChildGrids = new List<TestGridModel>();
|
||||
var childGrid1 = new TestGridModel
|
||||
{
|
||||
GridName = "TestGrid",
|
||||
ViewComponentName = "TestGridComponent",
|
||||
ViewComponentLocation = "~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/TestGridComponent.cshtml",
|
||||
ParentGridId = testGridModel2.Id,
|
||||
ChildGrids = new List<TestGridModel>()
|
||||
};
|
||||
testGridModel2.Configuration = new GridConfiguration();
|
||||
testGridModel2.Configuration.ShowChildGridsAsTabs = true;
|
||||
testGridModel2.ChildGrids.Add(childGrid1);
|
||||
|
||||
var childGrid2 = new TestGridModel
|
||||
{
|
||||
GridName = "Files",
|
||||
ViewComponentName = "FileUploadGridComponent",
|
||||
ViewComponentLocation = "~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/Order/FileUploadGridComponent.cshtml",
|
||||
ParentGridId = testGridModel2.Id,
|
||||
ChildGrids = new List<TestGridModel>()
|
||||
};
|
||||
testGridModel2.ChildGrids.Add(childGrid2);
|
||||
|
||||
|
||||
testPageModel.Grids.Add(testGridModel2);
|
||||
|
||||
|
|
@ -72,7 +84,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> LoadChildGrid([FromBody] LoadChildGridRequest request)
|
||||
public IActionResult LoadChildGrid([FromBody] LoadChildGridRequest request)
|
||||
{
|
||||
// request.contextId is the actual row ID (data.Id from DevExtreme)
|
||||
// request.childModel is the full TestGridModel object
|
||||
|
|
@ -84,9 +96,17 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
request.ChildModel.DataContext["contextId"] = request.ContextId;
|
||||
|
||||
// Invoke the view component with the full model
|
||||
return ViewComponent(request.ChildModel.ViewComponentLocation, new { model = request.ChildModel });
|
||||
return ViewComponent(request.ChildModel.ViewComponentName, request.ChildModel);
|
||||
}
|
||||
|
||||
// Request model for deserialization
|
||||
public class LoadChildGridRequest
|
||||
{
|
||||
public int ContextId { get; set; } // The actual row ID from data.Id
|
||||
public TestGridModel ChildModel { get; set; } // The full child grid model
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetShippings()
|
||||
{
|
||||
|
|
@ -165,16 +185,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Request model for deserialization
|
||||
public class LoadChildGridRequest
|
||||
{
|
||||
public int ContextId { get; set; } // The actual row ID from data.Id
|
||||
public TestGridModel ChildModel { get; set; } // The full child grid model
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[RequestSizeLimit(10485760)] // 10MB
|
||||
[RequestFormLimits(MultipartBodyLengthLimit = 10485760)]
|
||||
|
|
@ -256,7 +266,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
}
|
||||
|
||||
string analysisPrompt = "Extract the document identification number from this document, determine the type of the " +
|
||||
"document from the available list, and return them as JSON: documentNumber, documentType. " +
|
||||
"document IN ENGLISH from the available list, and return them as JSON: documentNumber, documentType. " +
|
||||
$"Available filetypes: {nameof(DocumentType.Invoice)}, {nameof(DocumentType.ShippingDocument)} , {nameof(DocumentType.OrderConfirmation)}, {nameof(DocumentType.Unknown)}" +
|
||||
"If you can't find information of any of these, return null value for that field.";
|
||||
|
||||
|
|
@ -266,10 +276,12 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
var extractedMetaData = ParseMetaDataAIResponse(metaAnalyzis);
|
||||
|
||||
if (extractedMetaData.DocumentNumber != null)
|
||||
|
||||
{
|
||||
dbFile.RawText = pdfText;
|
||||
dbFile.FileExtension = "pdf";
|
||||
dbFile.FileName = extractedMetaData.DocumentNumber;
|
||||
dbFile.FileExtension = "pdf";
|
||||
dbFile.FileName = extractedMetaData.DocumentNumber;
|
||||
}
|
||||
|
||||
|
||||
// - IF WE DON'T HAVE PARTNERID ALREADY: read partner information
|
||||
// (check if all 3 refers to the same partner)
|
||||
|
|
|
|||
|
|
@ -2,22 +2,30 @@
|
|||
@using DevExtreme.AspNet.Mvc
|
||||
|
||||
@{
|
||||
if (Model.DataContext["contextId"] != null)
|
||||
|
||||
|
||||
if (Model.DataContext.ContainsKey("contextId"))
|
||||
{
|
||||
var contextId = Model.DataContext["contextId"];
|
||||
|
||||
<text>
|
||||
<h4>contextId</h4>
|
||||
<h4>@Model.DataContext["contextId"]</h4>
|
||||
</text>
|
||||
})
|
||||
}
|
||||
// var gridId = $"dataGrid_{Guid.NewGuid():N}";
|
||||
}
|
||||
|
||||
@{
|
||||
var contextId = Model.DataContext["contextId"];
|
||||
var fileManagerId = $"fileManager_{contextId}";
|
||||
var beforeAjaxSendFunctionName = $"beforeAjaxSend_{contextId}";
|
||||
}
|
||||
|
||||
|
||||
<p> @Model.DataContext["contextId"], @Model.GridName, @Model.ViewComponentName </p>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
|
||||
@Model.DataContext["contextId"], @Model.GridName, @Model.ViewComponentName
|
||||
@* <form method="post" enctype="multipart/form-data" asp-controller="ManagementPage" asp-action="UploadFile">
|
||||
<form method="post" enctype="multipart/form-data" asp-controller="ManagementPage" asp-action="UploadFile">
|
||||
@(Html.DevExtreme().FileUploader()
|
||||
.ID("shippingDocumentUploader-" + contextId)
|
||||
.Name("files")
|
||||
|
|
@ -26,9 +34,9 @@
|
|||
.UploadMode(FileUploadMode.UseForm)
|
||||
)
|
||||
<input type="hidden" name="ShippingDocumentId" value="@contextId" />
|
||||
<% if (data.PartnerId) { %>
|
||||
|
||||
<input type="hidden" name="PartnerId" value="hello" />
|
||||
<% } %>
|
||||
|
||||
@(Html.DevExtreme().Button()
|
||||
.Text("Upload Files")
|
||||
.Type(ButtonType.Success)
|
||||
|
|
@ -39,16 +47,16 @@
|
|||
<div>
|
||||
<h4>Selected Files</h4>
|
||||
</div>
|
||||
</div> *@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
@* @(Html.DevExtreme().FileManager()
|
||||
.ID("fileManager_"+ contextId)
|
||||
@(Html.DevExtreme().FileManager()
|
||||
.ID(fileManagerId)
|
||||
.FileSystemProvider(provider => provider.Remote()
|
||||
.Url(Url.RouteUrl("FileManagementFileSystemApi"))
|
||||
.BeforeAjaxSend(@<text>
|
||||
function(e) {
|
||||
e.ajaxSettings.data.orderId = data.Id;
|
||||
function(arg) {
|
||||
arg.headers.TestHeader = @Model.DataContext["contextId"];
|
||||
}
|
||||
</text>))
|
||||
.Permissions(permissions => {
|
||||
|
|
@ -56,11 +64,9 @@
|
|||
permissions.Upload(true);
|
||||
})
|
||||
.AllowedFileExtensions(new[] { ".pdf", ".jpg", ".jpeg" })
|
||||
) *@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
)
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
function fileUploader_valueChanged(e) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
@model Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models.TestGridModel
|
||||
@using DevExtreme.AspNet.Mvc
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div>
|
||||
@(
|
||||
|
|
@ -131,6 +132,9 @@
|
|||
url: '@Url.Action("LoadChildGrid", "ManagementPage")',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
headers: {
|
||||
'RequestVerificationToken': $('input[name="__RequestVerificationToken"]').val()
|
||||
},
|
||||
data: JSON.stringify({
|
||||
contextId: contextId,
|
||||
childModel: childModel
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
<tr>
|
||||
<td><strong>@kvp.Key</strong></td>
|
||||
<td>@kvp.Value</td>
|
||||
<td><em>@kvp.Value?.GetType().Name</em></td>
|
||||
<td><em>@kvp.Value.GetType().Name</em></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -112,6 +112,11 @@ public class RouteProvider : IRouteProvider
|
|||
pattern: "Admin/ManagementPage/GetPartners",
|
||||
defaults: new { controller = "ManagementPage", action = "GetPartners", area = AreaNames.ADMIN });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(
|
||||
name: "Plugin.FruitBank.Admin.ManagementPage.LoadChildGrid",
|
||||
pattern: "Admin/ManagementPage/LoadChildGrid",
|
||||
defaults: new { controller = "ManagementPage", action = "LoadChildGrid", area = AreaNames.ADMIN });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(
|
||||
name: "Plugin.FruitBank.Admin.Products.List",
|
||||
pattern: "Admin/Product/List",
|
||||
|
|
|
|||
Loading…
Reference in New Issue