Skip to content
This repository was archived by the owner on Mar 24, 2024. It is now read-only.

Commit eeb956f

Browse files
authored
[Back] ProductDeletePhoto | ProductPostMovePhoto | Remove Cover - [Front] DelegateDataGrid | GuidImage | AdminProductPhotoAction | AdminProductPhotoEditCaption | AdminProductPhotoEditDelete | AdminProductPhotoEditReplace | MakeCoverCol | ProductCarousel | usePhoto | useMovePhoto | useGet (#112)
* Update version numbers and disable buttons during loading * Update Photo model and related code * Update version numbers and fix code issues * Update TypeScript files for data grid and product components This commit includes updates to several TypeScript files related to a data grid component and product-related components in a web application. The changes include modifications to the way certain functions and components are exported and used, updates to the version numbers in the author comments, and changes to the way certain properties are accessed or passed to functions and components. The `manual: true` option has been removed from several `useRequest` calls, suggesting that these requests are now intended to run automatically when their dependencies change. Error handling has been improved with the addition of `onError` callbacks that log errors. Code has been refactored to use destructuring to access properties of objects, improving readability. Interfaces or type definitions have been updated for some functions and components, reflecting changes to the data structures they are expected to work with. Image handling has been updated, with changes to the `GuidImage` component and related functions. Changes have also been made to the way lists of photos are fetched and updated in the `AdminProductPhoto` component and related functions. The changes primarily revolve around the use of hooks and requests in the code, with significant updates to `Patch.ts`, `Post.ts`, `Data.ts`, and `Get.ts`. * Update dependencies in package.json * Updated photo handling and UI interactions in various files Updated and improved photo handling methods in `Delete.cs`, `Post.cs`, `GuidImage.tsx`, `Patch.ts`, and `ObjectStorage.ts`. This includes changes to deletion, moving, and uploading of photos. UI interactions have been enhanced in `Caption.tsx` and `index.tsx` to provide better user feedback during operations. The `ListUpdate` method in `Get.ts` has been marked as deprecated.
1 parent d96e7d9 commit eeb956f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+831
-897
lines changed

SoarCraft.AwaiShop/AdminHub/Product/Delete.cs

+14-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@ internal partial class AdminHub {
99
* <remarks>
1010
* @author Aloento
1111
* @since 0.1.0
12-
* @version 0.2.0
12+
* @version 0.3.0
1313
* </remarks>
1414
*/
1515
public async Task<bool> ProductDeletePhoto(uint photoId) {
16-
var res = await this.Db.Photos
17-
.Where(x => x.PhotoId == photoId)
16+
var where = this.Db.Photos
17+
.Where(x => x.PhotoId == photoId);
18+
19+
var objId = await where
20+
.Select(x => x.ObjectId)
21+
.SingleAsync();
22+
23+
await this.Db.Objects
24+
.Where(x => x.Id == objId)
1825
.ExecuteDeleteAsync();
1926

20-
return res > 0;
27+
await where
28+
.ExecuteDeleteAsync();
29+
30+
return true;
2131
}
2232

2333
/**

SoarCraft.AwaiShop/AdminHub/Product/Post.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task<uint> ProductPostCreate(string name) {
3838
* <remarks>
3939
* @author Aloento
4040
* @since 0.5.0
41-
* @version 1.0.0
41+
* @version 1.1.0
4242
* </remarks>
4343
*/
4444
public async Task<bool> ProductPostMovePhoto(uint photoId, bool up) {
@@ -57,14 +57,18 @@ public async Task<bool> ProductPostMovePhoto(uint photoId, bool up) {
5757
if (current == 1)
5858
throw new HubException("Photo already at top");
5959

60+
var prev = photos[index - 1].Order;
61+
6062
photos[index - 1].Order = current;
61-
photos[index].Order = (byte)(current - 1);
63+
photos[index].Order = prev;
6264
} else {
6365
if (current == photos.Last().Order)
6466
throw new HubException("Photo already at bottom");
6567

68+
var next = photos[index + 1].Order;
69+
6670
photos[index + 1].Order = current;
67-
photos[index].Order = (byte)(current + 1);
71+
photos[index].Order = next;
6872
}
6973

7074
await this.Db.SaveChangesAsync();

SoarCraft.AwaiShop/Helpers/DataSeeder.cs

-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public static async Task SeedData(IApplicationBuilder host) {
4646
Category = cate1,
4747
Photos = [
4848
new() {
49-
Cover = true,
5049
Caption = "Demo Caption",
5150
Order = 1,
5251
Object = new() { Data = p1 }
@@ -64,7 +63,6 @@ public static async Task SeedData(IApplicationBuilder host) {
6463
Category = cate2,
6564
Photos = [
6665
new() {
67-
Cover = true,
6866
Caption = "Demo Caption",
6967
Order = 1,
7068
Object = new() { Data = p3 }

SoarCraft.AwaiShop/Hub/Product/Get.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public Task<uint[]> ProductGetComboList(uint prodId) =>
3232
* <remarks>
3333
* @author Aloento
3434
* @since 0.5.0
35-
* @version 0.2.0
35+
* @version 0.2.1
3636
* </remarks>
3737
*/
3838
public Task<uint[]> ProductGetPhotoList(uint prodId) =>
3939
this.Db.Photos
4040
.Where(x => x.ProductId == prodId)
41+
.OrderBy(x => x.Order)
4142
.Select(x => x.PhotoId)
4243
.ToArrayAsync();
43-
4444
}

SoarCraft.AwaiShop/Migrations/20240103162914_Init.Designer.cs SoarCraft.AwaiShop/Migrations/20240301205204_Init.Designer.cs

+2-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SoarCraft.AwaiShop/Migrations/20240103162914_Init.cs SoarCraft.AwaiShop/Migrations/20240301205204_Init.cs

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ protected override void Up(MigrationBuilder migrationBuilder)
128128
columns: table => new
129129
{
130130
PhotoId = table.Column<long>(type: "bigint", nullable: false),
131-
Cover = table.Column<bool>(type: "boolean", nullable: true),
132131
Caption = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
133132
Order = table.Column<byte>(type: "smallint", nullable: false),
134133
ObjectId = table.Column<Guid>(type: "uuid", nullable: false),

SoarCraft.AwaiShop/Migrations/ShopContextModelSnapshot.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1717
{
1818
#pragma warning disable 612, 618
1919
modelBuilder
20-
.HasAnnotation("ProductVersion", "8.0.0")
21-
.HasAnnotation("Proxies:ChangeTracking", false)
22-
.HasAnnotation("Proxies:CheckEquality", false)
23-
.HasAnnotation("Proxies:LazyLoading", true)
20+
.HasAnnotation("ProductVersion", "8.0.2")
2421
.HasAnnotation("Relational:MaxIdentifierLength", 63);
2522

2623
NpgsqlModelBuilderExtensions.UseHiLo(modelBuilder, "EntityFrameworkHiLoSequence");
@@ -215,9 +212,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
215212
.HasMaxLength(100)
216213
.HasColumnType("character varying(100)");
217214

218-
b.Property<bool?>("Cover")
219-
.HasColumnType("boolean");
220-
221215
b.Property<Guid>("ObjectId")
222216
.HasColumnType("uuid");
223217

SoarCraft.AwaiShop/Models/Photo.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ namespace SoarCraft.AwaiShop.Models;
88
* <remarks>
99
* @author Aloento
1010
* @since 0.1.0
11-
* @version 0.1.0
11+
* @version 0.2.0
1212
* </remarks>
1313
*/
1414
public class Photo : Concurrency {
1515
public uint PhotoId { get; set; }
1616

17-
public bool? Cover { get; set; }
18-
1917
[StringLength(100)]
2018
public string? Caption { get; set; }
2119

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@azure/msal-browser": "^3.10.0",
1919
"@azure/msal-common": "^14.7.1",
2020
"@azure/msal-react": "^2.0.12",
21-
"@fluentui/react-components": "^9.46.6",
21+
"@fluentui/react-components": "^9.46.7",
2222
"@fluentui/react-hooks": "^8.6.36",
2323
"@fluentui/react-icons": "^2.0.230",
2424
"@griffel/react": "^1.5.20",
@@ -53,7 +53,7 @@
5353
},
5454
"devDependencies": {
5555
"@types/lodash-es": "^4.17.12",
56-
"@types/react": "^18.2.60",
56+
"@types/react": "^18.2.61",
5757
"@types/react-dom": "^18.2.19",
5858
"@vitejs/plugin-react-swc": "^3.6.0",
5959
"typescript": "^5.3.3",

0 commit comments

Comments
 (0)