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

Commit

Permalink
[Back] ProductDeletePhoto | ProductPostMovePhoto | Remove Cover - [Fr…
Browse files Browse the repository at this point in the history
…ont] 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.
  • Loading branch information
Aloento authored Mar 2, 2024
1 parent d96e7d9 commit eeb956f
Show file tree
Hide file tree
Showing 47 changed files with 831 additions and 897 deletions.
18 changes: 14 additions & 4 deletions SoarCraft.AwaiShop/AdminHub/Product/Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@ internal partial class AdminHub {
* <remarks>
* @author Aloento
* @since 0.1.0
* @version 0.2.0
* @version 0.3.0
* </remarks>
*/
public async Task<bool> ProductDeletePhoto(uint photoId) {
var res = await this.Db.Photos
.Where(x => x.PhotoId == photoId)
var where = this.Db.Photos
.Where(x => x.PhotoId == photoId);

var objId = await where
.Select(x => x.ObjectId)
.SingleAsync();

await this.Db.Objects
.Where(x => x.Id == objId)
.ExecuteDeleteAsync();

return res > 0;
await where
.ExecuteDeleteAsync();

return true;
}

/**
Expand Down
10 changes: 7 additions & 3 deletions SoarCraft.AwaiShop/AdminHub/Product/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<uint> ProductPostCreate(string name) {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 1.0.0
* @version 1.1.0
* </remarks>
*/
public async Task<bool> ProductPostMovePhoto(uint photoId, bool up) {
Expand All @@ -57,14 +57,18 @@ public async Task<bool> ProductPostMovePhoto(uint photoId, bool up) {
if (current == 1)
throw new HubException("Photo already at top");

var prev = photos[index - 1].Order;

photos[index - 1].Order = current;
photos[index].Order = (byte)(current - 1);
photos[index].Order = prev;
} else {
if (current == photos.Last().Order)
throw new HubException("Photo already at bottom");

var next = photos[index + 1].Order;

photos[index + 1].Order = current;
photos[index].Order = (byte)(current + 1);
photos[index].Order = next;
}

await this.Db.SaveChangesAsync();
Expand Down
2 changes: 0 additions & 2 deletions SoarCraft.AwaiShop/Helpers/DataSeeder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static async Task SeedData(IApplicationBuilder host) {
Category = cate1,
Photos = [
new() {
Cover = true,
Caption = "Demo Caption",
Order = 1,
Object = new() { Data = p1 }
Expand All @@ -64,7 +63,6 @@ public static async Task SeedData(IApplicationBuilder host) {
Category = cate2,
Photos = [
new() {
Cover = true,
Caption = "Demo Caption",
Order = 1,
Object = new() { Data = p3 }
Expand Down
4 changes: 2 additions & 2 deletions SoarCraft.AwaiShop/Hub/Product/Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public Task<uint[]> ProductGetComboList(uint prodId) =>
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 0.2.0
* @version 0.2.1
* </remarks>
*/
public Task<uint[]> ProductGetPhotoList(uint prodId) =>
this.Db.Photos
.Where(x => x.ProductId == prodId)
.OrderBy(x => x.Order)
.Select(x => x.PhotoId)
.ToArrayAsync();

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ protected override void Up(MigrationBuilder migrationBuilder)
columns: table => new
{
PhotoId = table.Column<long>(type: "bigint", nullable: false),
Cover = table.Column<bool>(type: "boolean", nullable: true),
Caption = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
Order = table.Column<byte>(type: "smallint", nullable: false),
ObjectId = table.Column<Guid>(type: "uuid", nullable: false),
Expand Down
8 changes: 1 addition & 7 deletions SoarCraft.AwaiShop/Migrations/ShopContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Proxies:ChangeTracking", false)
.HasAnnotation("Proxies:CheckEquality", false)
.HasAnnotation("Proxies:LazyLoading", true)
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);

NpgsqlModelBuilderExtensions.UseHiLo(modelBuilder, "EntityFrameworkHiLoSequence");
Expand Down Expand Up @@ -215,9 +212,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<bool?>("Cover")
.HasColumnType("boolean");
b.Property<Guid>("ObjectId")
.HasColumnType("uuid");
Expand Down
4 changes: 1 addition & 3 deletions SoarCraft.AwaiShop/Models/Photo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ namespace SoarCraft.AwaiShop.Models;
* <remarks>
* @author Aloento
* @since 0.1.0
* @version 0.1.0
* @version 0.2.0
* </remarks>
*/
public class Photo : Concurrency {
public uint PhotoId { get; set; }

public bool? Cover { get; set; }

[StringLength(100)]
public string? Caption { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@azure/msal-browser": "^3.10.0",
"@azure/msal-common": "^14.7.1",
"@azure/msal-react": "^2.0.12",
"@fluentui/react-components": "^9.46.6",
"@fluentui/react-components": "^9.46.7",
"@fluentui/react-hooks": "^8.6.36",
"@fluentui/react-icons": "^2.0.230",
"@griffel/react": "^1.5.20",
Expand Down Expand Up @@ -53,7 +53,7 @@
},
"devDependencies": {
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.60",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"@vitejs/plugin-react-swc": "^3.6.0",
"typescript": "^5.3.3",
Expand Down
Loading

0 comments on commit eeb956f

Please sign in to comment.