Browse Source

updated cart widget

pull/41/head
Galip Tolga Erdem 5 years ago
parent
commit
74296d283b
  1. 4
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs
  2. 8
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Toolbar/Cart/Default.cshtml
  3. 2
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml
  4. 2
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml.cs
  5. 4
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.js
  6. 11
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/cart/cart-widget.js

4
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs

@ -9,8 +9,8 @@ namespace EShopOnAbp.PublicWeb.Components.Basket;
[Widget(
AutoInitialize = true,
RefreshUrl = "/Widgets/Basket",
StyleFiles = new[] { "/components/basket-widget.css" },
ScriptTypes = new[] { typeof(BasketWidgetScriptContributor) }
StyleFiles = new[] {"/components/basket-widget.css"},
ScriptTypes = new[] {typeof(BasketWidgetScriptContributor)}
)]
public class BasketWidgetViewComponent : AbpViewComponent
{

8
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Toolbar/Cart/Default.cshtml

@ -2,15 +2,15 @@
@using Microsoft.AspNetCore.Mvc.Localization
@inject IHtmlLocalizer<BasketServiceResource> L
@model EShopOnAbp.BasketService.BasketDto
<div class="nav-link">
<div id="shopping-cart" class="nav-link">
@if (Model == null)
{
<span class="cart-error" style="vertical-align: -webkit-baseline-middle;color: white">@L["Toolbar:BasketNotLoaded"] </span>
}
else
{
<abp-button button-type="Secondary">
@L["Toolbar:Cart"] <span abp-badge="Info" data-cart-count>@Model.Items.Count</span>
</abp-button>
<a class="btn" role="button" href="~/Basket">
<span abp-badge="Info" data-cart-count>@Model.Items.Count</span> @L["Toolbar:Cart"]
</a>
}
</div>

2
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml

@ -1,7 +1,7 @@
@page
@model EShopOnAbp.PublicWeb.Pages.IndexModel
@{
const int productsColumnSize = 3;
const int productsColumnSize = 4;
}
@section styles{

2
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml.cs

@ -26,4 +26,4 @@ namespace EShopOnAbp.PublicWeb.Pages
await HttpContext.ChallengeAsync("oidc");
}
}
}
}

4
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.js

@ -6,7 +6,7 @@
}
$(function () {
var basketWidget = new abp.WidgetManager('#BasketArea');
var cartWidget = new abp.WidgetManager('#shopping-cart');
$('.product-list-item').click(function () {
var $this = $(this);
@ -14,7 +14,7 @@
eShopOnAbp.basketService.basket.addProduct({
productId: productId
}).then(function () {
basketWidget.refresh();
cartWidget.refresh();
abp.notify.success("Added product to your basket.", "Successfully added");
});
});

11
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/cart/cart-widget.js

@ -1,15 +1,16 @@
(function (){
(function () {
alert("working")
var connection = new signalR.HubConnectionBuilder()
.withUrl("/signalr-hubs/cart")
.withUrl("/signalr-hubs/basket")
.build();
connection.on("BasketProductUpdated", function (data) {
var widgetManager = $wrapper.data('abp-widget-manager');
debugger;
var widgetManager = $wrapper.data('abp-widget-manager');
$('#data-cart-count-id').text(data);
widgetManager.refresh();
abp.notify.info('The product "' + data.productName + '" has been changed!', 'Your basket has been updated!');
// $('.basket-list')
// .closest('.abp-widget-wrapper')
// .each(function(){

Loading…
Cancel
Save