Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Admin panel - product attributes - improve better UX
KrzysztofPajake91d49d36e65
diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/EditAttributeValues.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/EditAttributeValues.cshtmldeleted file mode 100644index 5e4428f32..000000000--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/EditAttributeValues.cshtml+++ /dev/null@@ -1,150 +0,0 @@-@model ProductModel.ProductAttributeValueListModel--@{- //page title- ViewBag.Title = string.Format(Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.EditAttributeDetails"], Model.ProductAttributeName, Model.ProductName);-}-<form asp-area="@Constants.AreaAdmin" asp-controller="Product" asp-action="EditAttributeValues" id="productattribute-form"- asp-route-ProductId="@Context.Request.Query["ProductId"]"- asp-route-btnId="@Context.Request.Query["btnId"]"- asp-route-formId="@Context.Request.Query["formId"]">-- <div class="row">- <div class="col-md-12">- <div class="x_panel light form-fit">- <div class="x_title">- <div class="caption">- <i class="fa fa-cube"></i>- @string.Format(Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.EditAttributeDetails"], Model.ProductAttributeName, Model.ProductName)- <small>- <i class="fa fa-arrow-circle-left"></i>- @Html.ActionLink(Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.BackToProduct"], "Edit", "Product", new { Id = Model.ProductId }, null)</small>- </div>- <div class="actions">- <div class="btn-group btn-group-devided">- <input type="submit" id="btnAddNewValue" value="@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.AddNew"]" onclick="javascript:OpenWindow('@(Url.Action("ProductAttributeValueCreatePopup", "Product", new { productAttributeMappingId = Model.ProductAttributeMappingId, productId = Model.ProductId, btnId = "btnRefresh", formId = "productattribute-form", area = Constants.AreaAdmin }))', 800, 550, true); return false;" class="k-button" />- <input type="submit" id="btnRefresh" style="display: none" />- </div>- </div>- </div>- <div class="x_content form">- <div id="productattributevalues-grid"></div>- </div>- </div>- </div>- </div>-- <script>- $(document).ready(function () {- $("#productattributevalues-grid").kendoGrid({- dataSource: {- transport: {- read: {- url: "@Html.Raw(Url.Action("ProductAttributeValueList", "Product", new { productAttributeMappingId = Model.ProductAttributeMappingId, productId = Model.ProductId, area = Constants.AreaAdmin }))",- type: "POST",- dataType: "json",- data: addAntiForgeryToken- },- destroy: {- url: "@Html.Raw(Url.Action("ProductAttributeValueDelete", "Product", new { pam = Model.ProductAttributeMappingId, productId = Model.ProductId, area = Constants.AreaAdmin }))",- type: "POST",- dataType: "json",- data: addAntiForgeryToken- }- },- schema: {- data: "Data",- total: "Total",- errors: "Errors",- model: {- id: "Id",- fields: {- id: { editable: false, type: "string" },- }- }- },- error: function(e) {- display_kendoui_grid_error(e);- // Cancel the changes- this.cancelChanges();- },- serverPaging: true,- serverFiltering: true,- serverSorting: true- },- pageable: {- refresh: true,- numeric: false,- previousNext: false,- info: false- },- editable: {- confirmation: false,- mode: "inline"- },- scrollable: false,- columns: [- {- field: "AttributeValueTypeName",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AttributeValueType"]",- width: 150- }, {- field: "Name",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.Name"]",- width: 200- }, {- field: "AssociatedProductName",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct"]",- width: 200- }, {- field: "PriceAdjustmentStr",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.PriceAdjustment"]",- width: 150- }, {- field: "WeightAdjustmentStr",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.WeightAdjustment"]",- width: 150- }, {- field: "IsPreSelected",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.IsPreSelected"]",- width: 100,- headerAttributes: { style: "text-align:center" },- attributes: { style: "text-align:center" },- template: '# if(IsPreSelected) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'- }, {- field: "PictureThumbnailUrl",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.Picture"]",- template: '<img src="#=PictureThumbnailUrl#" />',- width: 200- },{- field: "DisplayOrder",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.DisplayOrder"]",- width: 100- },{- field: "Id",- title: "@Loc["Admin.Common.Edit"]",- width: 100,- template: "<input type='submit' value='@Loc["Admin.Common.Edit"]' onclick=\"javascript:OpenWindow('@Url.Action("ProductAttributeValueEditPopup", "Product", new { area = Constants.AreaAdmin })/#=Id#?productId=@(Model.ProductId)&productAttributeMappingId=@(Model.ProductAttributeMappingId)&btnId=btnRefresh&formId=productattribute-form', 800, 500, true); return false;\" class='k-button' />"- }, {- command: { name: "destroy", text: "@Loc["Admin.Common.Delete"]" },- title: "@Loc["Admin.Common.Delete"]",- width: 200- }- ]- });- });- </script>-- <script>- $(document).ready(function () {- $('#btnRefresh').click(function () {- //refresh grid- var grid = $("#productattributevalues-grid").data('kendoGrid');- grid.dataSource.read();-- //return false to don't reload a page- return false;- });- });- </script>-</form>\ No newline at end of filediff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdate.ProductAttributes.TabAttributes.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdate.ProductAttributes.TabAttributes.cshtmlindex c93c2b610..b8a51972f 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdate.ProductAttributes.TabAttributes.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdate.ProductAttributes.TabAttributes.cshtml@@ -78,6 +78,17 @@serverSorting: true},autoBind: false,+ //values grid+ detailInit: detailInit,+ dataBound: function () {+ var data = this.dataSource.data();+ $.each(data, function (i, row) {+ if (row.get("AttributeControlTypeId") == "4" || row.get("AttributeControlTypeId") == "10"+ || row.get("AttributeControlTypeId") == "30") {+ $('tr[data-uid="' + row.uid + '"] ').find(".k-hierarchy-cell a").remove();;+ }+ });+ },pageable: {refresh: true,numeric: false,@@ -113,12 +124,6 @@width: 140,template: "#:AttributeControlType# <br> # if(ValidationRulesAllowed) {# <a href='javascript:OpenWindow(\"@Url.Action("ProductAttributeValidationRulesPopup", "Product", new { area = Constants.AreaAdmin })/#=Id#?&productId=@(Model.Id)&btnId=btnRefreshProductAttributes&formId=product-form\", 800, 300, true);'>@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.ValidationRules.ViewLink"]</a><br />#=ValidationRulesString# #} #"},- {- field: "ShouldHaveValues",- title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values"]",- width: 60,- template: '# if(ShouldHaveValues) {# <a href="@Url.Action("EditAttributeValues", "Product", new { area = Constants.AreaAdmin })/?productAttributeMappingId=#=Id#&productId=@(Model.Id)">@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.ViewLink"]</a><br />@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.TotalValues"] #=TotalValues# #} #'- },{field: "ConditionAllowed",title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Condition"]",@@ -138,18 +143,101 @@});});+ //details grid+ function toolbar_click_newProductAttributeValue(id) {+ javascript: OpenWindow('@Url.Action("ProductAttributeValueCreatePopup", "Product", new { area = Constants.AreaAdmin })/' + '?productAttributeMappingId=' + id + '&[email protected]&formId=product-form&btnId=btnRefreshProductAttributesValues', 800, 550, true);+ return false;+ }+ function toolbar_click_editProductAttributeValue(id, pam) {+ javascript: OpenWindow('@Url.Action("ProductAttributeValueEditPopup", "Product", new { area = Constants.AreaAdmin })/' + id + '?productId=@(Model.Id)&productAttributeMappingId=' + pam + '&btnId=btnRefreshProductAttributesValues&formId=product-form', 800, 500, true);+ return false;+ }+ function detailInit(e) {+ $("<div data-name='productattributevalue' data-id='" + e.data.id+"' />").appendTo(e.detailCell).kendoGrid({+ dataSource: {+ transport: {+ read: {+ url: "@Html.Raw(Url.Action("ProductAttributeValueList", "Product", new { area = Constants.AreaAdmin }))?productAttributeMappingId=" + e.data.Id + "&[email protected]",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ },+ destroy: {+ url: "@Html.Raw(Url.Action("ProductAttributeValueDelete", "Product", new {area = Constants.AreaAdmin }))?pam=" + e.data.Id + "&[email protected]",+ type: "POST",+ dataType: "json",+ data: addAntiForgeryToken+ }+ },+ schema: {+ data: "Data",+ total: "Total",+ errors: "Errors",+ model: {+ id: "Id",+ }+ },+ error: function(e) {+ display_kendoui_grid_error(e);+ // Cancel the changes+ this.cancelChanges();+ },+ serverPaging: true,+ serverFiltering: true,+ serverSorting: true+ },+ toolbar: [+ {+ template: "<a class='k-button' href='\\#' onclick=\"return toolbar_click_newProductAttributeValue('"+e.data.Id+"')\">@Loc["Admin.Common.AddNew"]</a>"+ }+ ],+ scrollable: false,+ sortable: false,+ pageable: {+ refresh: true,+ numeric: false,+ previousNext: false,+ info: false+ },+ editable: {+ confirmation: true,+ mode: "inline"+ },+ columns: [+ {+ field: "Name",+ title: "@Loc["Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.Name"]",+ template: "<a class='k-link' href='\\#' onclick=\"toolbar_click_editProductAttributeValue('#=Id#', '" + e.data.Id + "')\">#=Name#</a>"+ }, {+ command: { name: "destroy", text: "@Loc["Admin.Common.Delete"]" },+ title: "@Loc["Admin.Common.Delete"]"+ }+ ]+ });+ }</script><input type="submit" id="btnRefreshProductAttributes" style="display: none" />+<input type="button" id="btnRefreshProductAttributesValues" style="display: none" /><script>- $(document).ready(function () {- $('#btnRefreshProductAttributes').click(function () {- //refresh grid- var grid = $("#productattributemappings-grid").data('kendoGrid');- grid.dataSource.read();+ $(document).ready(function () {+ $('#btnRefreshProductAttributes').click(function () {+ //refresh grid+ var grid = $("#productattributemappings-grid").data('kendoGrid');+ grid.dataSource.read();- //return false to don't reload a page- return false;- });+ //return false to don't reload a page+ return false;});+ $('#btnRefreshProductAttributesValues').click(function (e) {+ //refresh grid value+ var dataid = $(this).attr("data-id");+ var grid = $('[data-id="' + dataid + '"]').data('kendoGrid');+ grid.dataSource.read();++ //return false to don't reload a page+ return false;+ });+ });+</script>\ No newline at end of filediff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdateProductAttributeValue.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdateProductAttributeValue.cshtmlindex 943250d62..ae7b3ce0b 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdateProductAttributeValue.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdateProductAttributeValue.cshtml@@ -13,11 +13,15 @@@if (ViewBag.RefreshPage == true){- <script>- try {window.opener.document.forms['@(Context.Request.Query["formId"])'].@(Context.Request.Query["btnId"]).click();}+<script>+ try {+ window.opener.document.forms['@(Context.Request.Query["formId"])'].@(Context.Request.Query["btnId"]).setAttribute('data-id', '@Model.ProductAttributeMappingId');+ window.opener.document.forms['@(Context.Request.Query["formId"])'].@(Context.Request.Query["btnId"]).click();++ }catch (e){}window.close();- </script>+</script>}<script>$(document).ready(function () {