diff --git a/docs/en/low-code/fluent-api.md b/docs/en/low-code/fluent-api.md index 8509cd8823..b4ded3407f 100644 --- a/docs/en/low-code/fluent-api.md +++ b/docs/en/low-code/fluent-api.md @@ -182,7 +182,7 @@ public string InternalNotes { get; set; } Controls whether clients can set this property value. Useful for computed or server-assigned fields: ````csharp -[DynamicPropertySetByClients(Allow = false)] +[DynamicPropertySetByClients(false)] public string RegistrationNumber { get; set; } ```` @@ -217,7 +217,7 @@ public class Organization } ```` -> The `Name` parameter must be one of: `"Create"`, `"Update"`, or `"Delete"`. Multiple interceptors can be added to the same class (`AllowMultiple = true`). +> The `Name` parameter must be one of: `"Create"`, `"Update"`, or `"Delete"`. The `InterceptorType` can be `Pre`, `Post`, or `Replace`. When `Replace` is used, the default DB operation is skipped entirely and only the JavaScript handler runs. Multiple interceptors can be added to the same class (`AllowMultiple = true`). See [Interceptors](interceptors.md) for the full JavaScript context API. @@ -292,7 +292,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) | `SetParent(entityName)` | Set parent entity for nesting | | `SetUI(action)` | Configure entity-level UI | | `ConfigureProperty(name, action)` | Configure a specific property | -| `AddInterceptor(name, type, js)` | Add a JavaScript interceptor | +| `AddInterceptor(name, type, js)` | Add a JavaScript interceptor. `name`: `"Create"`, `"Update"`, or `"Delete"`. `type`: `Pre`, `Post`, or `Replace` | ### Property Configuration Methods diff --git a/docs/en/low-code/index.md b/docs/en/low-code/index.md index 4687658eb7..9adf40614b 100644 --- a/docs/en/low-code/index.md +++ b/docs/en/low-code/index.md @@ -53,37 +53,7 @@ Run `dotnet ef migrations add Added_Product` and start your application. You get ## Getting Started -### 1. Install NuGet Packages - -| Package | Layer | -|---------|-------| -| `Volo.Abp.LowCode.Domain.Shared` | Domain.Shared | -| `Volo.Abp.LowCode.Domain` | Domain | -| `Volo.Abp.LowCode.Application.Contracts` | Application.Contracts | -| `Volo.Abp.LowCode.Application` | Application | -| `Volo.Abp.LowCode.HttpApi` | HttpApi | -| `Volo.Abp.LowCode.HttpApi.Client` | HttpApi.Client | -| `Volo.Abp.LowCode.EntityFrameworkCore` | EF Core | -| `Volo.Abp.LowCode.Blazor` | Blazor UI (SSR) | -| `Volo.Abp.LowCode.Blazor.Server` | Blazor Server | -| `Volo.Abp.LowCode.Blazor.WebAssembly` | Blazor WebAssembly | -| `Volo.Abp.LowCode.Installer` | Auto module discovery | - -### 2. Add Module Dependencies - -````csharp -[DependsOn( - typeof(AbpLowCodeApplicationModule), - typeof(AbpLowCodeEntityFrameworkCoreModule), - typeof(AbpLowCodeHttpApiModule), - typeof(AbpLowCodeBlazorModule) -)] -public class YourModule : AbpModule -{ -} -```` - -### 3. Register Your Assembly +### 1. Register Your Assembly In your Domain module, register the assembly that contains your `[DynamicEntity]` classes: @@ -96,7 +66,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) } ```` -### 4. Configure DbContext +### 2. Configure DbContext Call `ConfigureDynamicEntities()` in your `DbContext`: @@ -108,7 +78,7 @@ protected override void OnModelCreating(ModelBuilder builder) } ```` -### 5. Define Your First Entity +### 3. Define Your First Entity ````csharp [DynamicEntity] @@ -125,7 +95,7 @@ public class Customer } ```` -### 6. Add Migration and Run +### 4. Add Migration and Run ```bash dotnet ef migrations add Added_Customer diff --git a/docs/en/low-code/interceptors.md b/docs/en/low-code/interceptors.md index eec25ef019..ccadcb438d 100644 --- a/docs/en/low-code/interceptors.md +++ b/docs/en/low-code/interceptors.md @@ -7,7 +7,7 @@ # Interceptors -Interceptors allow you to run custom JavaScript code before or after Create, Update, and Delete operations on dynamic entities. +Interceptors allow you to run custom JavaScript code before, after, or instead of Create, Update, and Delete operations on dynamic entities. ## Interceptor Types @@ -15,10 +15,13 @@ Interceptors allow you to run custom JavaScript code before or after Create, Upd |---------|------|---------------| | `Create` | `Pre` | Before entity creation — validation, default values | | `Create` | `Post` | After entity creation — notifications, related data | +| `Create` | `Replace` | Instead of entity creation — the default DB insert is skipped, only JavaScript runs | | `Update` | `Pre` | Before entity update — validation, authorization | | `Update` | `Post` | After entity update — sync, notifications | +| `Update` | `Replace` | Instead of entity update — the default DB update is skipped, only JavaScript runs | | `Delete` | `Pre` | Before entity deletion — dependency checks | | `Delete` | `Post` | After entity deletion — cleanup | +| `Delete` | `Replace` | Instead of entity deletion — the default DB delete is skipped, only JavaScript runs | ## Defining Interceptors with Attributes @@ -42,7 +45,7 @@ public class Organization } ```` -The `Name` parameter must be one of: `"Create"`, `"Update"`, or `"Delete"`. This maps directly to the CRUD command being intercepted. Multiple interceptors can be added to the same class (`AllowMultiple = true`). +The `Name` parameter must be one of: `"Create"`, `"Update"`, or `"Delete"`. The `InterceptorType` can be `Pre`, `Post`, or `Replace`. When `Replace` is used, the default database operation is completely skipped and only your JavaScript handler executes. Multiple interceptors can be added to the same class (`AllowMultiple = true`). ## Defining Interceptors in model.json @@ -66,7 +69,7 @@ Add interceptors to the `interceptors` array of an entity: | Field | Type | Description | |-------|------|-------------| | `commandName` | string | `"Create"`, `"Update"`, or `"Delete"` | -| `type` | string | `"Pre"` or `"Post"` | +| `type` | string | `"Pre"`, `"Post"`, or `"Replace"` | | `javascript` | string | JavaScript code to execute | ## JavaScript Context @@ -166,7 +169,21 @@ globalError = 'Cannot delete this entity!'; } ``` -### Pre-Create: Self-Reference Check +### Replace-Create: Custom Insert Logic + +When you need to completely replace the default create operation with custom logic: + +```json +{ + "commandName": "Create", + "type": "Replace", + "javascript": "var data = context.commandArgs.data;\ndata['Code'] = 'PRD-' + Date.now();\nawait db.insert('LowCodeDemo.Products.Product', data);\ncontext.log('Product created with custom code: ' + data['Code']);" +} +``` + +> When `Replace` is used, the standard database operation does not run. You are responsible for performing any necessary persistence in your JavaScript handler. + +### Pre-Update: Self-Reference Check ```json { diff --git a/docs/en/low-code/scripting-api.md b/docs/en/low-code/scripting-api.md index 2fe714145b..286a918586 100644 --- a/docs/en/low-code/scripting-api.md +++ b/docs/en/low-code/scripting-api.md @@ -278,7 +278,6 @@ Direct CRUD methods on the `db` object: | Method | Description | Returns | |--------|-------------|---------| | `db.get(entityName, id)` | Get by ID | `Promise` | -| `db.getList(entityName, take?)` | Get list | `Promise` | | `db.getCount(entityName)` | Get count | `Promise` | | `db.insert(entityName, entity)` | Insert new | `Promise` | | `db.update(entityName, entity)` | Update existing | `Promise` |