From 758b0b7cf24440128eed8eea421310d1d8e17a87 Mon Sep 17 00:00:00 2001 From: thangchung Date: Tue, 9 Feb 2021 20:08:56 +0700 Subject: [PATCH] update layout for pages --- coolstore.sln.DotSettings | 1 + .../Specification/GridSpecificationBase.cs | 42 ++ .../Specification}/PredicateBuilder.cs | 2 +- .../Specification/SpecificationBase.cs | 16 + .../N8T.Infrastructure.EfCore/Repository.cs | 1 - .../Queries/GetProductById.cs | 2 +- .../Specifications/ProductByIdQuerySpec.cs | 15 +- .../Specifications/ProductListQuerySpec.cs | 16 +- src/Web/assets/scss/main.scss | 11 + src/Web/layout/MainLayout.jsx | 31 +- src/Web/layout/foot/Footer.jsx | 48 -- src/Web/layout/foot/MyFooter.jsx | 18 + src/Web/layout/nav/NavBar.jsx | 59 +- src/Web/package-lock.json | 547 ++++++++++++++++++ src/Web/package.json | 5 +- src/Web/pages/_app.js | 1 + src/Web/pages/index.js | 1 - src/Web/pages/{product => products}/[id].js | 0 src/Web/pages/products/create.js | 110 ++++ .../pages/{products.js => products/index.js} | 138 +++-- 20 files changed, 887 insertions(+), 177 deletions(-) rename src/BuildingBlocks/{N8T.Infrastructure/LambdaExpression => N8T.Core/Specification}/PredicateBuilder.cs (99%) delete mode 100644 src/Web/layout/foot/Footer.jsx create mode 100644 src/Web/layout/foot/MyFooter.jsx rename src/Web/pages/{product => products}/[id].js (100%) create mode 100644 src/Web/pages/products/create.js rename src/Web/pages/{products.js => products/index.js} (67%) diff --git a/coolstore.sln.DotSettings b/coolstore.sln.DotSettings index 07b47f6..944e1eb 100644 --- a/coolstore.sln.DotSettings +++ b/coolstore.sln.DotSettings @@ -4,6 +4,7 @@ True True True + True True True True \ No newline at end of file diff --git a/src/BuildingBlocks/N8T.Core/Specification/GridSpecificationBase.cs b/src/BuildingBlocks/N8T.Core/Specification/GridSpecificationBase.cs index 61eba70..494c6c5 100644 --- a/src/BuildingBlocks/N8T.Core/Specification/GridSpecificationBase.cs +++ b/src/BuildingBlocks/N8T.Core/Specification/GridSpecificationBase.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq.Expressions; +using N8T.Core.Domain; namespace N8T.Core.Specification { @@ -17,16 +18,49 @@ public abstract class GridSpecificationBase : IGridSpecification public int Skip { get; private set; } public bool IsPagingEnabled { get; set; } + protected void ApplyIncludeList(IEnumerable>> includes) + { + foreach (var include in includes) + { + AddInclude(include); + } + } + protected void AddInclude(Expression> includeExpression) { Includes.Add(includeExpression); } + protected void ApplyIncludeList(IEnumerable includes) + { + foreach (var include in includes) + { + AddInclude(include); + } + } + protected void AddInclude(string includeString) { IncludeStrings.Add(includeString); } + protected IGridSpecification ApplyFilterList(IEnumerable filters) + { + foreach (var (fieldName, comparision, fieldValue) in filters) + { + ApplyFilter(PredicateBuilder.Build(fieldName, comparision, fieldValue)); + } + + return this; + } + + protected IGridSpecification ApplyFilter(Expression> expr) + { + Criterias.Add(expr); + + return this; + } + protected void ApplyPaging(int skip, int take) { Skip = skip; @@ -43,6 +77,14 @@ protected void ApplyOrderByDescending(Expression> orderByDescend protected void ApplyGroupBy(Expression> groupByExpression) => GroupBy = groupByExpression; + protected void ApplySortingList(IEnumerable sorts) + { + foreach (var sort in sorts) + { + ApplySorting(sort); + } + } + protected void ApplySorting(string sort) { this.ApplySorting(sort, nameof(ApplyOrderBy), nameof(ApplyOrderByDescending)); diff --git a/src/BuildingBlocks/N8T.Infrastructure/LambdaExpression/PredicateBuilder.cs b/src/BuildingBlocks/N8T.Core/Specification/PredicateBuilder.cs similarity index 99% rename from src/BuildingBlocks/N8T.Infrastructure/LambdaExpression/PredicateBuilder.cs rename to src/BuildingBlocks/N8T.Core/Specification/PredicateBuilder.cs index ac16d14..ea4d73b 100644 --- a/src/BuildingBlocks/N8T.Infrastructure/LambdaExpression/PredicateBuilder.cs +++ b/src/BuildingBlocks/N8T.Core/Specification/PredicateBuilder.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Linq.Expressions; -namespace N8T.Infrastructure.LambdaExpression +namespace N8T.Core.Specification { /// /// https://codereview.stackexchange.com/questions/166460/chaining-multiple-predicates diff --git a/src/BuildingBlocks/N8T.Core/Specification/SpecificationBase.cs b/src/BuildingBlocks/N8T.Core/Specification/SpecificationBase.cs index 1157faf..38ea75d 100644 --- a/src/BuildingBlocks/N8T.Core/Specification/SpecificationBase.cs +++ b/src/BuildingBlocks/N8T.Core/Specification/SpecificationBase.cs @@ -17,11 +17,27 @@ public abstract class SpecificationBase : ISpecification public int Skip { get; private set; } public bool IsPagingEnabled { get; private set; } + protected void ApplyIncludeList(IEnumerable>> includes) + { + foreach (var include in includes) + { + AddInclude(include); + } + } + protected void AddInclude(Expression> includeExpression) { Includes.Add(includeExpression); } + protected void ApplyIncludeList(IEnumerable includes) + { + foreach (var include in includes) + { + AddInclude(include); + } + } + protected void AddInclude(string includeString) { IncludeStrings.Add(includeString); diff --git a/src/BuildingBlocks/N8T.Infrastructure.EfCore/Repository.cs b/src/BuildingBlocks/N8T.Infrastructure.EfCore/Repository.cs index 548f2bf..21c635d 100644 --- a/src/BuildingBlocks/N8T.Infrastructure.EfCore/Repository.cs +++ b/src/BuildingBlocks/N8T.Infrastructure.EfCore/Repository.cs @@ -6,7 +6,6 @@ using N8T.Core.Domain; using N8T.Core.Repository; using N8T.Core.Specification; -using N8T.Infrastructure.LambdaExpression; namespace N8T.Infrastructure.EfCore { diff --git a/src/Product/ProductService.Application/Queries/GetProductById.cs b/src/Product/ProductService.Application/Queries/GetProductById.cs index 1cbc06b..b66a183 100644 --- a/src/Product/ProductService.Application/Queries/GetProductById.cs +++ b/src/Product/ProductService.Application/Queries/GetProductById.cs @@ -12,7 +12,7 @@ namespace ProductService.Application.Queries { - public class GetProductById + public static class GetProductById { public record Query : IItemQueryInput, IQuery { diff --git a/src/Product/ProductService.Core/Specifications/ProductByIdQuerySpec.cs b/src/Product/ProductService.Core/Specifications/ProductByIdQuerySpec.cs index a21e26e..321fdd4 100644 --- a/src/Product/ProductService.Core/Specifications/ProductByIdQuerySpec.cs +++ b/src/Product/ProductService.Core/Specifications/ProductByIdQuerySpec.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; using N8T.Core.Domain; using N8T.Core.Specification; @@ -8,17 +9,15 @@ namespace ProductService.Core.Specifications { public sealed class ProductByIdQuerySpec : SpecificationBase { - private readonly IItemQueryInput _queryInput; + private readonly Guid _id; - public ProductByIdQuerySpec(IItemQueryInput queryInput) + public ProductByIdQuerySpec([NotNull] IItemQueryInput queryInput) { - _queryInput = queryInput ?? throw new ArgumentNullException(nameof(queryInput)); - foreach (var include in queryInput.Includes) - { - AddInclude(include); - } + ApplyIncludeList(queryInput.Includes); + + _id = queryInput.Id; } - public override Expression> Criteria => p => p.Id == _queryInput.Id; + public override Expression> Criteria => p => p.Id == _id; } } diff --git a/src/Product/ProductService.Core/Specifications/ProductListQuerySpec.cs b/src/Product/ProductService.Core/Specifications/ProductListQuerySpec.cs index 5423508..a72278f 100644 --- a/src/Product/ProductService.Core/Specifications/ProductListQuerySpec.cs +++ b/src/Product/ProductService.Core/Specifications/ProductListQuerySpec.cs @@ -1,6 +1,5 @@ using N8T.Core.Domain; using N8T.Core.Specification; -using N8T.Infrastructure.LambdaExpression; using ProductService.Core.Entities; namespace ProductService.Core.Specifications @@ -9,20 +8,11 @@ public sealed class ProductListQuerySpec : GridSpecificationBase { public ProductListQuerySpec(IListQueryInput gridQueryInput) { - foreach (var include in gridQueryInput.Includes) - { - AddInclude(include); - } + ApplyIncludeList(gridQueryInput.Includes); - foreach (var (fieldName, comparision, fieldValue) in gridQueryInput.Filters) - { - Criterias.Add(PredicateBuilder.Build(fieldName, comparision, fieldValue)); - } + ApplyFilterList(gridQueryInput.Filters); - foreach (var sort in gridQueryInput.Sorts) - { - ApplySorting(sort); - } + ApplySortingList(gridQueryInput.Sorts); ApplyPaging(gridQueryInput.Page, gridQueryInput.PageSize); } diff --git a/src/Web/assets/scss/main.scss b/src/Web/assets/scss/main.scss index 60afe92..79e761b 100644 --- a/src/Web/assets/scss/main.scss +++ b/src/Web/assets/scss/main.scss @@ -2,3 +2,14 @@ // // Vendors variables override and path @import "vendors/vendor"; @import "base/base"; + +#components-layout-demo-fixed .logo { + float: left; + width: 120px; + height: 31px; + margin: 16px 24px 16px 0; + background: rgba(255, 255, 255, 0.2); +} +.site-layout .site-layout-background { + background: #fff; +} diff --git a/src/Web/layout/MainLayout.jsx b/src/Web/layout/MainLayout.jsx index b320ae6..2a9b33b 100644 --- a/src/Web/layout/MainLayout.jsx +++ b/src/Web/layout/MainLayout.jsx @@ -1,14 +1,11 @@ import React from "react"; -import { Container, Row, Col } from "reactstrap"; -import styled from "styled-components"; +import { Layout, Row, Col } from "antd"; /* Components */ import NavBar from "./nav/NavBar"; -import Footer from "./foot/Footer"; +import MyFooter from "./foot/MyFooter"; -const MyRow = styled(Row)` - margin-top: 30px; -` +const { Header, Content, Footer } = Layout; function MainLayout(mainProps) { const { children } = mainProps; @@ -17,13 +14,21 @@ function MainLayout(mainProps) { return ( <> - - - - {children} - - -