From 55699a144bacfa9cf9f338e44f3ec22d28eb77b0 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Tue, 28 Dec 2021 11:13:12 +0300 Subject: [PATCH] updated addressProvider and address selection --- .../Basket/UserAddressProvider.cs | 7 +++++-- .../Components/Payment/Default.cshtml | 4 ++-- .../EShopOnAbpPaymentConsts.cs | 6 ++++++ .../components/payment/payment-widget.css | 8 ++++--- .../components/payment/payment-widget.js | 21 ++++++++++++++++++- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs index dba1f13f..f106159d 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs @@ -11,13 +11,15 @@ public class UserAddressProvider : ITransientDependency { new() { - Name = "Home", + Id = 1, + Name = EShopOnAbpPaymentConsts.DemoAddressTypes.Work, Description = "Cecilia Chapman Senior 711-2880 Nulla St. Mankato Mississippi 96522/USA", IsDefault = true }, new() { - Name = "Work", + Id = 2, + Name = EShopOnAbpPaymentConsts.DemoAddressTypes.Work, Description = "Yeşilköy Serbest Bölge Mah. E-Blok Sokak E1 Blok No:2, Bakırköy/İstanbul" } }; @@ -26,6 +28,7 @@ public class UserAddressProvider : ITransientDependency public class AddressDto { + public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public bool IsDefault { get; set; } = false; diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml index 88ed30e7..6bc368b8 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/Default.cshtml @@ -19,11 +19,11 @@ @for (int j = 0; j < defaultColumnSize; j++) { - @if ((i * defaultColumnSize) + j < Model.Address.Count) + @if (i * defaultColumnSize + j < Model.Address.Count) { var address = Model.Address[(i * defaultColumnSize) + j]; string isSelected = address.IsDefault ? "is-selected" : string.Empty; -
+

@address.Name

@address.Description

diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPaymentConsts.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPaymentConsts.cs index 52d87fb4..c9a75f54 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPaymentConsts.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPaymentConsts.cs @@ -3,5 +3,11 @@ public static class EShopOnAbpPaymentConsts { public const string Currency = "USD"; + + public static class DemoAddressTypes + { + public const string Work = "Work"; + public const string Home = "Home"; + } } } diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css index 117d3043..1b38f784 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.css @@ -1,18 +1,20 @@ .card { /* Add shadows to create the "card" effect */ - box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); transition: 0.3s; } /* On mouse-over, add a deeper shadow */ .card:hover { - box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2); + box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2); + cursor: default; } /* Add some padding inside the card container */ .card-body { padding: 2px 16px; } -.is-selected{ + +.is-selected { border: solid #bfbfe3; } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.js b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.js index 95a5d939..1d3f09c0 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.js +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/payment/payment-widget.js @@ -1,3 +1,22 @@ (function () { - + abp.widgets.PaymentWidget = function ($wrapper) { + var widgetManager = $wrapper.data('abp-widget-manager'); + + var init = function (filters) { + $wrapper + .find('.address-list .card') + .click(function () { + var $this = $(this); + var addressId = $this.attr('data-address-id'); + abp.utils.setCookieValue("selected-address", addressId); + debugger; + $this.parents(".address-list").find('.card').removeClass("is-selected"); + $this.addClass("is-selected"); + }); + }; + + return { + init: init + }; + }; })(); \ No newline at end of file