v7.0.0-beta.4 release
This commit is contained in:
1 parent
05db17887d
commit
1db039ff34
1545 files changed
+136783
-11634
No files matched your search
@@ -0,0 +1,15 @@
|
||||
# Changelog
|
||||
|
||||
이 프로젝트의 모든 주요 변경사항을 기록합니다.
|
||||
형식은 [Keep a Changelog](https://keepachangelog.com/ko/1.1.0/)를 따르며,
|
||||
[Semantic Versioning](https://semver.org/lang/ko/)을 준수합니다.
|
||||
|
||||
## [0.1.0-beta.1] - 2026-05-11
|
||||
|
||||
### Added
|
||||
|
||||
- 학습용 최소 샘플 모듈 초기 릴리즈
|
||||
- Memo 엔티티 Admin CRUD 및 공개 읽기 API
|
||||
- 훅 발행 데모 (`gnuboard7-hello_module.memo.created`)
|
||||
- 기본 권한 4종 (read, create, update, delete) 및 관리자 메뉴 등록
|
||||
- 다국어 지원 (ko, en)
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "modules/gnuboard7-hello_module",
|
||||
"description": "Hello sample module for Gnuboard7 (learning purpose)",
|
||||
"type": "library",
|
||||
"version": "0.1.0-beta.1",
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Gnuboard7\\HelloModule\\": "src/",
|
||||
"Modules\\Gnuboard7\\HelloModule\\Database\\Seeders\\": "database/seeders/",
|
||||
"Modules\\Gnuboard7\\HelloModule\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\Gnuboard7\\HelloModule\\Upgrades\\": "upgrades/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\Gnuboard7\\HelloModule\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"per_page": 10,
|
||||
"frontend_schema": {
|
||||
"fields": [
|
||||
{
|
||||
"key": "per_page",
|
||||
"type": "number",
|
||||
"label": {
|
||||
"ko": "페이지당 항목 수",
|
||||
"en": "Items per page"
|
||||
},
|
||||
"min": 1,
|
||||
"max": 100,
|
||||
"default": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
|
||||
/**
|
||||
* 메모 팩토리
|
||||
*
|
||||
* 테스트/샘플 데이터 생성에 사용됩니다.
|
||||
*/
|
||||
class MemoFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* 모델 클래스
|
||||
*
|
||||
* @var class-string<Memo>
|
||||
*/
|
||||
protected $model = Memo::class;
|
||||
|
||||
/**
|
||||
* 모델 기본 상태 정의
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'title' => $this->faker->sentence(3),
|
||||
'content' => $this->faker->paragraph(3),
|
||||
];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('gnuboard7_hello_module_memos', function (Blueprint $table) {
|
||||
$table->bigIncrements('id')->comment('메모 고유번호');
|
||||
$table->string('uuid', 36)->unique()->comment('메모 UUID (외부 식별자)');
|
||||
$table->string('title', 255)->comment('메모 제목');
|
||||
$table->text('content')->comment('메모 본문');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('created_at', 'gnuboard7_hello_module_memos_created_at_index');
|
||||
});
|
||||
|
||||
if (DB::getDriverName() === 'mysql') {
|
||||
Schema::table('gnuboard7_hello_module_memos', function (Blueprint $table) {
|
||||
$table->comment('Hello 모듈 메모 (학습용 샘플)');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('gnuboard7_hello_module_memos')) {
|
||||
Schema::dropIfExists('gnuboard7_hello_module_memos');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Database\Seeders;
|
||||
|
||||
use App\Traits\HasSampleSeeders;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\Gnuboard7\HelloModule\Database\Seeders\Sample\MemoSampleSeeder;
|
||||
|
||||
/**
|
||||
* Hello 모듈 메인 시더
|
||||
*
|
||||
* 설치 시더:
|
||||
* - MemoSeeder - 기본 메모 2건
|
||||
*
|
||||
* 샘플 시더 (--sample 옵션 시):
|
||||
* - MemoSampleSeeder - 메모 20건
|
||||
*
|
||||
* 실행 방법:
|
||||
* php artisan module:seed gnuboard7-hello_module # 설치 시더만
|
||||
* php artisan module:seed gnuboard7-hello_module --sample # 설치 + 샘플
|
||||
*/
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use HasSampleSeeders;
|
||||
|
||||
/**
|
||||
* 시더 실행
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->command->info('=== Hello 모듈 시더 실행 시작 ===');
|
||||
|
||||
$this->call([
|
||||
MemoSeeder::class,
|
||||
]);
|
||||
|
||||
if ($this->shouldIncludeSample()) {
|
||||
$this->command->info('--- Hello 모듈 샘플 시더 실행 ---');
|
||||
$this->call(MemoSampleSeeder::class);
|
||||
}
|
||||
|
||||
$this->command->info('=== Hello 모듈 시더 실행 완료 ===');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
|
||||
/**
|
||||
* 메모 기본 시더
|
||||
*
|
||||
* 모듈 설치 시 기본 샘플 메모 2건을 생성합니다.
|
||||
*/
|
||||
class MemoSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* 시더 실행
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$defaults = [
|
||||
[
|
||||
'title' => '환영합니다',
|
||||
'content' => 'Hello 모듈의 첫 번째 샘플 메모입니다. 학습용으로 제공됩니다.',
|
||||
],
|
||||
[
|
||||
'title' => '두 번째 메모',
|
||||
'content' => 'Memo 엔티티의 CRUD 동작을 확인할 수 있는 추가 샘플입니다.',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($defaults as $row) {
|
||||
Memo::updateOrCreate(
|
||||
['title' => $row['title']],
|
||||
[
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'content' => $row['content'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Database\Seeders\Sample;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
|
||||
/**
|
||||
* 메모 샘플 시더
|
||||
*
|
||||
* --sample 옵션 시 20건의 메모를 추가 생성합니다.
|
||||
*/
|
||||
class MemoSampleSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* 시더 실행
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Memo::factory()->count(20)->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"identifier": "gnuboard7-hello_module",
|
||||
"vendor": "gnuboard7",
|
||||
"name": {
|
||||
"ko": "Hello 모듈",
|
||||
"en": "Hello Module"
|
||||
},
|
||||
"version": "0.1.0-beta.1",
|
||||
"license": "MIT",
|
||||
"description": {
|
||||
"ko": "학습용 최소 샘플 모듈 (Memo CRUD)",
|
||||
"en": "Learning minimal sample module (Memo CRUD)"
|
||||
},
|
||||
"g7_version": ">=7.0.0-beta.4",
|
||||
"hidden": true,
|
||||
"dependencies": {
|
||||
"modules": {},
|
||||
"plugins": {}
|
||||
},
|
||||
"assets": {
|
||||
"js": [],
|
||||
"css": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule;
|
||||
|
||||
use App\Extension\AbstractModule;
|
||||
use Modules\Gnuboard7\HelloModule\Database\Seeders\MemoSeeder;
|
||||
use Modules\Gnuboard7\HelloModule\Listeners\LogMemoCreatedListener;
|
||||
|
||||
/**
|
||||
* Hello 학습용 샘플 모듈
|
||||
*
|
||||
* Memo 엔티티 1개에 대한 Admin CRUD + User 읽기만 제공하는
|
||||
* 최소 동작 샘플입니다. manifest hidden:true 로 관리자 UI 에서 숨겨집니다.
|
||||
*/
|
||||
class Module extends AbstractModule
|
||||
{
|
||||
/**
|
||||
* 모듈 역할 정의
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function getRoles(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 모듈 권한 목록 반환 (계층형 구조, 다국어 지원)
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getPermissions(): array
|
||||
{
|
||||
return [
|
||||
'name' => [
|
||||
'ko' => 'Hello 모듈',
|
||||
'en' => 'Hello Module',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => 'Hello 모듈 권한',
|
||||
'en' => 'Hello module permissions',
|
||||
],
|
||||
'categories' => [
|
||||
[
|
||||
'identifier' => 'memos',
|
||||
'resource_route_key' => 'memo',
|
||||
'owner_key' => null,
|
||||
'name' => [
|
||||
'ko' => '메모 관리',
|
||||
'en' => 'Memo Management',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => '메모 관리 권한',
|
||||
'en' => 'Memo management permissions',
|
||||
],
|
||||
'permissions' => [
|
||||
[
|
||||
'action' => 'read',
|
||||
'name' => [
|
||||
'ko' => '메모 조회',
|
||||
'en' => 'View Memos',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => '메모 목록 및 상세 조회',
|
||||
'en' => 'View memo list and details',
|
||||
],
|
||||
'type' => 'admin',
|
||||
'roles' => ['admin', 'manager'],
|
||||
],
|
||||
[
|
||||
'action' => 'create',
|
||||
'name' => [
|
||||
'ko' => '메모 생성',
|
||||
'en' => 'Create Memo',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => '새 메모 생성',
|
||||
'en' => 'Create new memo',
|
||||
],
|
||||
'type' => 'admin',
|
||||
'roles' => ['admin', 'manager'],
|
||||
],
|
||||
[
|
||||
'action' => 'update',
|
||||
'name' => [
|
||||
'ko' => '메모 수정',
|
||||
'en' => 'Update Memo',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => '메모 내용 수정',
|
||||
'en' => 'Update memo content',
|
||||
],
|
||||
'type' => 'admin',
|
||||
'roles' => ['admin', 'manager'],
|
||||
],
|
||||
[
|
||||
'action' => 'delete',
|
||||
'name' => [
|
||||
'ko' => '메모 삭제',
|
||||
'en' => 'Delete Memo',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => '메모 삭제',
|
||||
'en' => 'Delete memo',
|
||||
],
|
||||
'type' => 'admin',
|
||||
'roles' => ['admin'],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 모듈 설치 시 실행할 시더 목록 반환
|
||||
*
|
||||
* @return array<class-string<\Illuminate\Database\Seeder>>
|
||||
*/
|
||||
public function getSeeders(): array
|
||||
{
|
||||
return [
|
||||
MemoSeeder::class,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 훅 리스너 목록 반환
|
||||
*
|
||||
* @return array<class-string>
|
||||
*/
|
||||
public function getHookListeners(): array
|
||||
{
|
||||
return [
|
||||
LogMemoCreatedListener::class,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 메뉴 정의
|
||||
*
|
||||
* 주의: manifest `hidden: true` 이므로 실제 UI 에 노출되지 않을 수 있으나
|
||||
* 메뉴 등록 자체는 학습 목적의 샘플로 제공합니다.
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function getAdminMenus(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'name' => [
|
||||
'ko' => 'Hello 메모',
|
||||
'en' => 'Hello Memos',
|
||||
],
|
||||
'slug' => 'gnuboard7-hello_module',
|
||||
'url' => '/admin/memos',
|
||||
'icon' => 'fas fa-sticky-note',
|
||||
'order' => 99,
|
||||
'permission' => 'gnuboard7-hello_module.memos.read',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"admin": {
|
||||
"memos": {
|
||||
"index": {
|
||||
"title": "Hello Memos",
|
||||
"description": "Learning memo list"
|
||||
},
|
||||
"form": {
|
||||
"title_create": "Create Memo",
|
||||
"title_edit": "Edit Memo",
|
||||
"fields": {
|
||||
"title": "Title",
|
||||
"content": "Content"
|
||||
},
|
||||
"actions": {
|
||||
"save": "Save",
|
||||
"cancel": "Cancel"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"user": {
|
||||
"memos": {
|
||||
"index": {
|
||||
"title": "Memo List"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"admin": {
|
||||
"memos": {
|
||||
"index": {
|
||||
"title": "Hello 메모",
|
||||
"description": "학습용 메모 목록"
|
||||
},
|
||||
"form": {
|
||||
"title_create": "메모 생성",
|
||||
"title_edit": "메모 수정",
|
||||
"fields": {
|
||||
"title": "제목",
|
||||
"content": "본문"
|
||||
},
|
||||
"actions": {
|
||||
"save": "저장",
|
||||
"cancel": "취소"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"user": {
|
||||
"memos": {
|
||||
"index": {
|
||||
"title": "메모 목록"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"layout_name": "admin_memo_form",
|
||||
"permissions": [
|
||||
"gnuboard7-hello_module.memos.read"
|
||||
],
|
||||
"extends": "_admin_base",
|
||||
"meta": {
|
||||
"title": "{{route?.id ? '$t:gnuboard7-hello_module.admin.memos.form.title_edit' : '$t:gnuboard7-hello_module.admin.memos.form.title_create'}}"
|
||||
},
|
||||
"data_sources": [
|
||||
{
|
||||
"id": "memoData",
|
||||
"type": "api",
|
||||
"endpoint": "/api/modules/gnuboard7-hello_module/admin/memos/{{route?.id}}",
|
||||
"method": "GET",
|
||||
"auto_fetch": true,
|
||||
"auth_required": true,
|
||||
"if": "{{route?.id}}",
|
||||
"initLocal": "form",
|
||||
"fallback": {
|
||||
"data": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"init_actions": [
|
||||
{
|
||||
"comment": "생성 모드에서 폼 기본값 초기화",
|
||||
"if": "{{!route?.id}}",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"form": {
|
||||
"title": "",
|
||||
"content": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"slots": {
|
||||
"content": [
|
||||
{
|
||||
"id": "memo_form_wrapper",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "p-6 bg-gray-50 dark:bg-gray-900 min-h-screen"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "memo_form_card",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"dataKey": "form",
|
||||
"props": {
|
||||
"className": "max-w-2xl mx-auto p-6 bg-white dark:bg-gray-800 rounded-lg shadow"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "memo_form_title",
|
||||
"type": "basic",
|
||||
"name": "H1",
|
||||
"props": {
|
||||
"className": "text-2xl font-bold text-gray-900 dark:text-white mb-6"
|
||||
},
|
||||
"text": "{{route?.id ? '$t:gnuboard7-hello_module.admin.memos.form.title_edit' : '$t:gnuboard7-hello_module.admin.memos.form.title_create'}}"
|
||||
},
|
||||
{
|
||||
"id": "memo_field_title",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "mb-4"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": {
|
||||
"className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"
|
||||
},
|
||||
"text": "$t:gnuboard7-hello_module.admin.memos.form.fields.title"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Input",
|
||||
"name_attr": "title",
|
||||
"props": {
|
||||
"type": "text",
|
||||
"name": "title",
|
||||
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "memo_field_content",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "mb-6"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": {
|
||||
"className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"
|
||||
},
|
||||
"text": "$t:gnuboard7-hello_module.admin.memos.form.fields.content"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Textarea",
|
||||
"props": {
|
||||
"name": "content",
|
||||
"rows": 6,
|
||||
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "memo_form_actions",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex items-center justify-end gap-2"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "memo_cancel_button",
|
||||
"type": "basic",
|
||||
"name": "Button",
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "px-4 py-2 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 font-medium transition-colors"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "navigate",
|
||||
"params": {
|
||||
"path": "/admin/memos"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "$t:gnuboard7-hello_module.admin.memos.form.actions.cancel"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "memo_save_button",
|
||||
"type": "basic",
|
||||
"name": "Button",
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium transition-colors"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "apiCall",
|
||||
"auth_required": true,
|
||||
"target": "{{route?.id ? '/api/modules/gnuboard7-hello_module/admin/memos/' + route?.id : '/api/modules/gnuboard7-hello_module/admin/memos'}}",
|
||||
"params": {
|
||||
"method": "{{route?.id ? 'PUT' : 'POST'}}",
|
||||
"body": "{{_local.form}}"
|
||||
},
|
||||
"onSuccess": [
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"type": "success",
|
||||
"message": "{{route?.id ? '$t:gnuboard7-hello_module.admin.memos.form.title_edit' : '$t:gnuboard7-hello_module.admin.memos.form.title_create'}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "navigate",
|
||||
"params": {
|
||||
"path": "/admin/memos"
|
||||
}
|
||||
}
|
||||
],
|
||||
"onError": [
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"type": "error",
|
||||
"message": "{{error.message ?? 'error'}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "$t:gnuboard7-hello_module.admin.memos.form.actions.save"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"layout_name": "admin_memo_list",
|
||||
"permissions": [
|
||||
"gnuboard7-hello_module.memos.read"
|
||||
],
|
||||
"extends": "_admin_base",
|
||||
"meta": {
|
||||
"title": "$t:gnuboard7-hello_module.admin.memos.index.title",
|
||||
"description": "$t:gnuboard7-hello_module.admin.memos.index.description"
|
||||
},
|
||||
"data_sources": [
|
||||
{
|
||||
"id": "memos",
|
||||
"type": "api",
|
||||
"endpoint": "/api/modules/gnuboard7-hello_module/admin/memos",
|
||||
"method": "GET",
|
||||
"auto_fetch": true,
|
||||
"auth_required": true,
|
||||
"params": {
|
||||
"page": "{{query.page}}",
|
||||
"per_page": "{{query.per_page ?? 10}}"
|
||||
},
|
||||
"fallback": {
|
||||
"data": {
|
||||
"data": [],
|
||||
"meta": {
|
||||
"current_page": 1,
|
||||
"last_page": 1,
|
||||
"per_page": 10,
|
||||
"total": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"slots": {
|
||||
"content": [
|
||||
{
|
||||
"id": "memo_list_wrapper",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "p-6 bg-gray-50 dark:bg-gray-900 min-h-screen"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "memo_list_header",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex items-center justify-between mb-6"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "memo_list_title",
|
||||
"type": "basic",
|
||||
"name": "H1",
|
||||
"props": {
|
||||
"className": "text-2xl font-bold text-gray-900 dark:text-white"
|
||||
},
|
||||
"text": "$t:gnuboard7-hello_module.admin.memos.index.title"
|
||||
},
|
||||
{
|
||||
"id": "memo_create_button",
|
||||
"type": "basic",
|
||||
"name": "Button",
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium transition-colors"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "navigate",
|
||||
"params": {
|
||||
"path": "/admin/memos/create"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "$t:gnuboard7-hello_module.admin.memos.form.title_create"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "memo_items",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "space-y-3"
|
||||
},
|
||||
"iteration": {
|
||||
"data": "{{memos?.data?.data ?? []}}",
|
||||
"item_var": "memo",
|
||||
"index_var": "idx"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "memo_item",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "p-4 bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "H2",
|
||||
"props": {
|
||||
"className": "text-lg font-semibold text-gray-900 dark:text-white"
|
||||
},
|
||||
"text": "{{memo.title ?? ''}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "P",
|
||||
"props": {
|
||||
"className": "mt-2 text-sm text-gray-600 dark:text-gray-300"
|
||||
},
|
||||
"text": "{{memo.content ?? ''}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"layout_name": "user_memo_list",
|
||||
"extends": "_user_base",
|
||||
"meta": {
|
||||
"title": "$t:gnuboard7-hello_module.user.memos.index.title"
|
||||
},
|
||||
"data_sources": [
|
||||
{
|
||||
"id": "memos",
|
||||
"type": "api",
|
||||
"endpoint": "/api/modules/gnuboard7-hello_module/memos",
|
||||
"method": "GET",
|
||||
"auto_fetch": true,
|
||||
"auth_required": false,
|
||||
"params": {
|
||||
"page": "{{query.page}}",
|
||||
"per_page": "{{query.per_page ?? 10}}"
|
||||
},
|
||||
"fallback": {
|
||||
"data": {
|
||||
"data": [],
|
||||
"meta": {
|
||||
"current_page": 1,
|
||||
"last_page": 1,
|
||||
"per_page": 10,
|
||||
"total": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"slots": {
|
||||
"content": [
|
||||
{
|
||||
"id": "user_memo_wrapper",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "max-w-3xl mx-auto p-6"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "user_memo_title",
|
||||
"type": "basic",
|
||||
"name": "H1",
|
||||
"props": {
|
||||
"className": "text-2xl font-bold text-gray-900 dark:text-white mb-6"
|
||||
},
|
||||
"text": "$t:gnuboard7-hello_module.user.memos.index.title"
|
||||
},
|
||||
{
|
||||
"id": "user_memo_items",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "space-y-3"
|
||||
},
|
||||
"iteration": {
|
||||
"data": "{{memos?.data?.data ?? []}}",
|
||||
"item_var": "memo",
|
||||
"index_var": "idx"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "user_memo_item",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "p-4 bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "H2",
|
||||
"props": {
|
||||
"className": "text-lg font-semibold text-gray-900 dark:text-white"
|
||||
},
|
||||
"text": "{{memo.title ?? ''}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "P",
|
||||
"props": {
|
||||
"className": "mt-2 text-sm text-gray-600 dark:text-gray-300"
|
||||
},
|
||||
"text": "{{memo.content ?? ''}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"routes": [
|
||||
{
|
||||
"path": "*/admin/memos",
|
||||
"layout": "admin_memo_list",
|
||||
"auth_required": true,
|
||||
"meta": {
|
||||
"title": "$t:gnuboard7-hello_module.admin.memos.index.title"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "*/admin/memos/create",
|
||||
"layout": "admin_memo_form",
|
||||
"auth_required": true,
|
||||
"meta": {
|
||||
"title": "$t:gnuboard7-hello_module.admin.memos.form.title_create"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "*/admin/memos/:id/edit",
|
||||
"layout": "admin_memo_form",
|
||||
"auth_required": true,
|
||||
"meta": {
|
||||
"title": "$t:gnuboard7-hello_module.admin.memos.form.title_edit"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "*/memos",
|
||||
"layout": "user_memo_list",
|
||||
"auth_required": false,
|
||||
"meta": {
|
||||
"title": "$t:gnuboard7-hello_module.user.memos.index.title"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Api\Base\AdminBaseController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Gnuboard7\HelloModule\Http\Requests\Admin\StoreMemoRequest;
|
||||
use Modules\Gnuboard7\HelloModule\Http\Requests\Admin\UpdateMemoRequest;
|
||||
use Modules\Gnuboard7\HelloModule\Http\Resources\MemoCollection;
|
||||
use Modules\Gnuboard7\HelloModule\Http\Resources\MemoResource;
|
||||
use Modules\Gnuboard7\HelloModule\Services\MemoService;
|
||||
|
||||
/**
|
||||
* 관리자용 메모 관리 컨트롤러
|
||||
*
|
||||
* 메모의 CRUD 를 제공합니다.
|
||||
*/
|
||||
class MemoController extends AdminBaseController
|
||||
{
|
||||
/**
|
||||
* MemoController 생성자
|
||||
*
|
||||
* @param MemoService $memoService 메모 서비스
|
||||
*/
|
||||
public function __construct(
|
||||
private MemoService $memoService,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모 목록을 조회합니다.
|
||||
*
|
||||
* @param Request $request HTTP 요청
|
||||
* @return JsonResponse 메모 목록 응답
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$perPage = (int) $request->query('per_page', 10);
|
||||
$memos = $this->memoService->getMemos($perPage);
|
||||
|
||||
return $this->success(
|
||||
'gnuboard7-hello_module::messages.memo.fetch_success',
|
||||
new MemoCollection($memos)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('gnuboard7-hello_module::messages.memo.fetch_failed', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모 상세를 조회합니다.
|
||||
*
|
||||
* @param int $id 메모 ID
|
||||
* @return JsonResponse 메모 상세 응답
|
||||
*/
|
||||
public function show(int $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$memo = $this->memoService->getMemo($id);
|
||||
|
||||
return $this->successWithResource(
|
||||
'gnuboard7-hello_module::messages.memo.fetch_success',
|
||||
new MemoResource($memo)
|
||||
);
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException) {
|
||||
return $this->notFound('gnuboard7-hello_module::messages.memo.not_found');
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('gnuboard7-hello_module::messages.memo.fetch_failed', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 생성합니다.
|
||||
*
|
||||
* @param StoreMemoRequest $request 메모 생성 요청
|
||||
* @return JsonResponse 생성된 메모 응답
|
||||
*/
|
||||
public function store(StoreMemoRequest $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$memo = $this->memoService->createMemo($request->validated());
|
||||
|
||||
return $this->successWithResource(
|
||||
'gnuboard7-hello_module::messages.memo.create_success',
|
||||
new MemoResource($memo),
|
||||
201
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('gnuboard7-hello_module::messages.memo.create_failed', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 수정합니다.
|
||||
*
|
||||
* @param UpdateMemoRequest $request 메모 수정 요청
|
||||
* @param int $id 메모 ID
|
||||
* @return JsonResponse 수정된 메모 응답
|
||||
*/
|
||||
public function update(UpdateMemoRequest $request, int $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$memo = $this->memoService->getMemo($id);
|
||||
$memo = $this->memoService->updateMemo($memo, $request->validated());
|
||||
|
||||
return $this->successWithResource(
|
||||
'gnuboard7-hello_module::messages.memo.update_success',
|
||||
new MemoResource($memo)
|
||||
);
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException) {
|
||||
return $this->notFound('gnuboard7-hello_module::messages.memo.not_found');
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('gnuboard7-hello_module::messages.memo.update_failed', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 삭제합니다.
|
||||
*
|
||||
* @param int $id 메모 ID
|
||||
* @return JsonResponse 삭제 결과 응답
|
||||
*/
|
||||
public function destroy(int $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$memo = $this->memoService->getMemo($id);
|
||||
$this->memoService->deleteMemo($memo);
|
||||
|
||||
return $this->success('gnuboard7-hello_module::messages.memo.delete_success');
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException) {
|
||||
return $this->notFound('gnuboard7-hello_module::messages.memo.not_found');
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('gnuboard7-hello_module::messages.memo.delete_failed', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Api\Base\PublicBaseController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Gnuboard7\HelloModule\Http\Resources\MemoCollection;
|
||||
use Modules\Gnuboard7\HelloModule\Http\Resources\MemoResource;
|
||||
use Modules\Gnuboard7\HelloModule\Services\MemoService;
|
||||
|
||||
/**
|
||||
* 공개용 메모 조회 컨트롤러
|
||||
*
|
||||
* 비로그인 사용자도 메모 목록 및 상세를 조회할 수 있습니다.
|
||||
*/
|
||||
class MemoController extends PublicBaseController
|
||||
{
|
||||
/**
|
||||
* MemoController 생성자
|
||||
*
|
||||
* @param MemoService $memoService 메모 서비스
|
||||
*/
|
||||
public function __construct(
|
||||
private MemoService $memoService,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모 목록을 조회합니다.
|
||||
*
|
||||
* @param Request $request HTTP 요청
|
||||
* @return JsonResponse 메모 목록 응답
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$perPage = (int) $request->query('per_page', 10);
|
||||
$memos = $this->memoService->getMemos($perPage);
|
||||
|
||||
return $this->success(
|
||||
'gnuboard7-hello_module::messages.memo.fetch_success',
|
||||
new MemoCollection($memos)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('gnuboard7-hello_module::messages.memo.fetch_failed', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모 상세를 조회합니다.
|
||||
*
|
||||
* @param int $id 메모 ID
|
||||
* @return JsonResponse 메모 상세 응답
|
||||
*/
|
||||
public function show(int $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$memo = $this->memoService->getMemo($id);
|
||||
|
||||
return $this->successWithResource(
|
||||
'gnuboard7-hello_module::messages.memo.fetch_success',
|
||||
new MemoResource($memo)
|
||||
);
|
||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException) {
|
||||
return $this->notFound('gnuboard7-hello_module::messages.memo.not_found');
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('gnuboard7-hello_module::messages.memo.fetch_failed', 500, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 메모 생성 요청
|
||||
*
|
||||
* 권한 검증은 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
class StoreMemoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 인증 허용 여부
|
||||
*
|
||||
* 인증/권한 로직은 permission 미들웨어에서 처리하므로 true 고정.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'content' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required' => __('gnuboard7-hello_module::validation.title.required'),
|
||||
'title.max' => __('gnuboard7-hello_module::validation.title.max'),
|
||||
'content.required' => __('gnuboard7-hello_module::validation.content.required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 메모 수정 요청
|
||||
*
|
||||
* 권한 검증은 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
class UpdateMemoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 인증 허용 여부
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 규칙을 반환합니다.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => ['required', 'string', 'max:255'],
|
||||
'content' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지를 반환합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'title.required' => __('gnuboard7-hello_module::validation.title.required'),
|
||||
'title.max' => __('gnuboard7-hello_module::validation.title.max'),
|
||||
'content.required' => __('gnuboard7-hello_module::validation.content.required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Http\Resources;
|
||||
|
||||
use App\Http\Resources\BaseApiCollection;
|
||||
use App\Http\Resources\Traits\HasAbilityCheck;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* 메모 목록 API 컬렉션
|
||||
*/
|
||||
class MemoCollection extends BaseApiCollection
|
||||
{
|
||||
use HasAbilityCheck;
|
||||
|
||||
/**
|
||||
* 컬렉션이 포함하는 리소스 클래스
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $collects = MemoResource::class;
|
||||
|
||||
/**
|
||||
* 권한-ability 매핑을 반환합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function abilityMap(): array
|
||||
{
|
||||
return [
|
||||
'can_create' => 'gnuboard7-hello_module.memos.create',
|
||||
'can_update' => 'gnuboard7-hello_module.memos.update',
|
||||
'can_delete' => 'gnuboard7-hello_module.memos.delete',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 리소스를 배열로 변환합니다.
|
||||
*
|
||||
* @param Request $request HTTP 요청 객체
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection,
|
||||
'meta' => [
|
||||
'current_page' => $this->resource->currentPage(),
|
||||
'last_page' => $this->resource->lastPage(),
|
||||
'per_page' => $this->resource->perPage(),
|
||||
'total' => $this->resource->total(),
|
||||
],
|
||||
'abilities' => $this->resolveAbilitiesFromMap($this->abilityMap(), $request->user()),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Http\Resources;
|
||||
|
||||
use App\Http\Resources\BaseApiResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* 메모 API 리소스
|
||||
*/
|
||||
class MemoResource extends BaseApiResource
|
||||
{
|
||||
/**
|
||||
* 리소스를 배열로 변환합니다.
|
||||
*
|
||||
* @param Request $request HTTP 요청 객체
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'uuid' => $this->uuid,
|
||||
'title' => $this->title,
|
||||
'content' => $this->content,
|
||||
...$this->formatTimestamps(),
|
||||
...$this->resourceMeta($request),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 리소스별 권한 매핑을 반환합니다.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function abilityMap(): array
|
||||
{
|
||||
return [
|
||||
'can_create' => 'gnuboard7-hello_module.memos.create',
|
||||
'can_update' => 'gnuboard7-hello_module.memos.update',
|
||||
'can_delete' => 'gnuboard7-hello_module.memos.delete',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
|
||||
/**
|
||||
* 메모 생성 로그 리스너 (학습용 데모)
|
||||
*
|
||||
* 자신(MemoService)이 발행한 `gnuboard7-hello_module.memo.created` 훅을
|
||||
* 자신이 받아 로그에 기록하는 간단한 데모 리스너입니다.
|
||||
*/
|
||||
class LogMemoCreatedListener implements HookListenerInterface
|
||||
{
|
||||
/**
|
||||
* 구독할 훅 목록 반환
|
||||
*
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
public static function getSubscribedHooks(): array
|
||||
{
|
||||
return [
|
||||
'gnuboard7-hello_module.memo.created' => [
|
||||
'method' => 'onMemoCreated',
|
||||
'priority' => 10,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본 훅 핸들러 (HookListenerInterface 필수 메서드)
|
||||
*
|
||||
* @param mixed ...$args 훅 인자
|
||||
* @return void
|
||||
*/
|
||||
public function handle(...$args): void
|
||||
{
|
||||
// 개별 메서드에서 처리
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모 생성 시 로그를 기록합니다.
|
||||
*
|
||||
* @param mixed ...$args 훅 인자 (첫 번째: Memo 모델)
|
||||
* @return void
|
||||
*/
|
||||
public function onMemoCreated(...$args): void
|
||||
{
|
||||
$memo = $args[0] ?? null;
|
||||
|
||||
if (! $memo instanceof Memo) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::info('[HelloModule] Memo created', [
|
||||
'id' => $memo->id,
|
||||
'uuid' => $memo->uuid,
|
||||
'title' => $memo->title,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\Gnuboard7\HelloModule\Database\Factories\MemoFactory;
|
||||
|
||||
/**
|
||||
* 메모 모델
|
||||
*
|
||||
* Hello 학습용 샘플 엔티티입니다.
|
||||
*/
|
||||
class Memo extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasUuids;
|
||||
|
||||
/**
|
||||
* 테이블명
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'gnuboard7_hello_module_memos';
|
||||
|
||||
/**
|
||||
* 대량 할당 가능한 속성
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'title',
|
||||
'content',
|
||||
];
|
||||
|
||||
/**
|
||||
* UUID 가 적용될 컬럼 목록을 반환합니다.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function uniqueIds(): array
|
||||
{
|
||||
return ['uuid'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 팩토리 클래스를 반환합니다.
|
||||
*
|
||||
* @return MemoFactory
|
||||
*/
|
||||
protected static function newFactory(): MemoFactory
|
||||
{
|
||||
return MemoFactory::new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Providers;
|
||||
|
||||
use App\Extension\BaseModuleServiceProvider;
|
||||
use Modules\Gnuboard7\HelloModule\Repositories\Contracts\MemoRepositoryInterface;
|
||||
use Modules\Gnuboard7\HelloModule\Repositories\MemoRepository;
|
||||
|
||||
/**
|
||||
* Hello 모듈 서비스 프로바이더
|
||||
*
|
||||
* Repository 인터페이스와 구현체 바인딩을 담당합니다.
|
||||
*/
|
||||
class HelloModuleServiceProvider extends BaseModuleServiceProvider
|
||||
{
|
||||
/**
|
||||
* 모듈 식별자
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected string $moduleIdentifier = 'gnuboard7-hello_module';
|
||||
|
||||
/**
|
||||
* Repository 인터페이스와 구현체 매핑
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected array $repositories = [
|
||||
MemoRepositoryInterface::class => MemoRepository::class,
|
||||
];
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Repositories\Contracts;
|
||||
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
|
||||
/**
|
||||
* 메모 Repository 인터페이스
|
||||
*/
|
||||
interface MemoRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* 메모 목록을 페이지네이션하여 조회합니다.
|
||||
*
|
||||
* @param int $perPage 페이지당 항목 수
|
||||
* @return LengthAwarePaginator 메모 목록
|
||||
*/
|
||||
public function paginate(int $perPage = 10): LengthAwarePaginator;
|
||||
|
||||
/**
|
||||
* ID로 메모를 조회합니다.
|
||||
*
|
||||
* @param int $id 메모 ID
|
||||
* @return Memo|null 메모 모델 또는 null
|
||||
*/
|
||||
public function findById(int $id): ?Memo;
|
||||
|
||||
/**
|
||||
* ID로 메모를 조회하며, 없으면 예외를 발생시킵니다.
|
||||
*
|
||||
* @param int $id 메모 ID
|
||||
* @return Memo 메모 모델
|
||||
*
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
*/
|
||||
public function findOrFail(int $id): Memo;
|
||||
|
||||
/**
|
||||
* 메모를 생성합니다.
|
||||
*
|
||||
* @param array $data 메모 생성 데이터
|
||||
* @return Memo 생성된 메모 모델
|
||||
*/
|
||||
public function create(array $data): Memo;
|
||||
|
||||
/**
|
||||
* 메모를 수정합니다.
|
||||
*
|
||||
* @param Memo $memo 메모 모델
|
||||
* @param array $data 수정할 데이터
|
||||
* @return Memo 수정된 메모 모델
|
||||
*/
|
||||
public function update(Memo $memo, array $data): Memo;
|
||||
|
||||
/**
|
||||
* 메모를 삭제합니다.
|
||||
*
|
||||
* @param Memo $memo 메모 모델
|
||||
* @return bool 삭제 성공 여부
|
||||
*/
|
||||
public function delete(Memo $memo): bool;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Repositories;
|
||||
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
use Modules\Gnuboard7\HelloModule\Repositories\Contracts\MemoRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 메모 Repository 구현체
|
||||
*/
|
||||
class MemoRepository implements MemoRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* 메모 목록을 페이지네이션하여 조회합니다.
|
||||
*
|
||||
* @param int $perPage 페이지당 항목 수
|
||||
* @return LengthAwarePaginator 메모 목록
|
||||
*/
|
||||
public function paginate(int $perPage = 10): LengthAwarePaginator
|
||||
{
|
||||
return Memo::query()
|
||||
->orderByDesc('created_at')
|
||||
->paginate($perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* ID로 메모를 조회합니다.
|
||||
*
|
||||
* @param int $id 메모 ID
|
||||
* @return Memo|null 메모 모델 또는 null
|
||||
*/
|
||||
public function findById(int $id): ?Memo
|
||||
{
|
||||
return Memo::find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* ID로 메모를 조회하며, 없으면 예외를 발생시킵니다.
|
||||
*
|
||||
* @param int $id 메모 ID
|
||||
* @return Memo 메모 모델
|
||||
*
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
*/
|
||||
public function findOrFail(int $id): Memo
|
||||
{
|
||||
return Memo::findOrFail($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 생성합니다.
|
||||
*
|
||||
* @param array $data 메모 생성 데이터
|
||||
* @return Memo 생성된 메모 모델
|
||||
*/
|
||||
public function create(array $data): Memo
|
||||
{
|
||||
return Memo::create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 수정합니다.
|
||||
*
|
||||
* @param Memo $memo 메모 모델
|
||||
* @param array $data 수정할 데이터
|
||||
* @return Memo 수정된 메모 모델
|
||||
*/
|
||||
public function update(Memo $memo, array $data): Memo
|
||||
{
|
||||
$memo->fill($data)->save();
|
||||
|
||||
return $memo->fresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 삭제합니다.
|
||||
*
|
||||
* @param Memo $memo 메모 모델
|
||||
* @return bool 삭제 성공 여부
|
||||
*/
|
||||
public function delete(Memo $memo): bool
|
||||
{
|
||||
return (bool) $memo->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Services;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
use Modules\Gnuboard7\HelloModule\Repositories\Contracts\MemoRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 메모 서비스
|
||||
*
|
||||
* 메모 생성/수정/삭제 비즈니스 로직 및 훅 발행을 담당합니다.
|
||||
*/
|
||||
class MemoService
|
||||
{
|
||||
/**
|
||||
* MemoService 생성자
|
||||
*
|
||||
* @param MemoRepositoryInterface $memoRepository 메모 Repository
|
||||
*/
|
||||
public function __construct(
|
||||
private MemoRepositoryInterface $memoRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 메모 목록을 조회합니다.
|
||||
*
|
||||
* @param int $perPage 페이지당 항목 수
|
||||
* @return LengthAwarePaginator 메모 목록
|
||||
*/
|
||||
public function getMemos(int $perPage = 10): LengthAwarePaginator
|
||||
{
|
||||
return $this->memoRepository->paginate($perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* ID 로 메모를 조회합니다.
|
||||
*
|
||||
* @param int $id 메모 ID
|
||||
* @return Memo 메모 모델
|
||||
*
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
*/
|
||||
public function getMemo(int $id): Memo
|
||||
{
|
||||
return $this->memoRepository->findOrFail($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 생성합니다.
|
||||
*
|
||||
* 생성 성공 시 `gnuboard7-hello_module.memo.created` 훅을 발행합니다.
|
||||
*
|
||||
* @param array $data 메모 생성 데이터 (title, content)
|
||||
* @return Memo 생성된 메모 모델
|
||||
*/
|
||||
public function createMemo(array $data): Memo
|
||||
{
|
||||
$memo = $this->memoRepository->create($data);
|
||||
|
||||
HookManager::doAction('gnuboard7-hello_module.memo.created', $memo);
|
||||
|
||||
return $memo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 수정합니다.
|
||||
*
|
||||
* @param Memo $memo 메모 모델
|
||||
* @param array $data 수정할 데이터
|
||||
* @return Memo 수정된 메모 모델
|
||||
*/
|
||||
public function updateMemo(Memo $memo, array $data): Memo
|
||||
{
|
||||
return $this->memoRepository->update($memo, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 삭제합니다.
|
||||
*
|
||||
* @param Memo $memo 메모 모델
|
||||
* @return bool 삭제 성공 여부
|
||||
*/
|
||||
public function deleteMemo(Memo $memo): bool
|
||||
{
|
||||
return $this->memoRepository->delete($memo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'memo' => [
|
||||
'not_found' => 'Memo not found.',
|
||||
'fetch_success' => 'Memo fetched successfully.',
|
||||
'fetch_failed' => 'Failed to fetch memo.',
|
||||
'create_success' => 'Memo created successfully.',
|
||||
'create_failed' => 'Failed to create memo.',
|
||||
'update_success' => 'Memo updated successfully.',
|
||||
'update_failed' => 'Failed to update memo.',
|
||||
'delete_success' => 'Memo deleted successfully.',
|
||||
'delete_failed' => 'Failed to delete memo.',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => [
|
||||
'required' => 'The memo title is required.',
|
||||
'max' => 'The memo title may not be greater than :max characters.',
|
||||
],
|
||||
'content' => [
|
||||
'required' => 'The memo content is required.',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 메모 메시지
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'memo' => [
|
||||
'not_found' => '메모를 찾을 수 없습니다.',
|
||||
'fetch_success' => '메모를 조회했습니다.',
|
||||
'fetch_failed' => '메모 조회에 실패했습니다.',
|
||||
'create_success' => '메모가 생성되었습니다.',
|
||||
'create_failed' => '메모 생성에 실패했습니다.',
|
||||
'update_success' => '메모가 수정되었습니다.',
|
||||
'update_failed' => '메모 수정에 실패했습니다.',
|
||||
'delete_success' => '메모가 삭제되었습니다.',
|
||||
'delete_failed' => '메모 삭제에 실패했습니다.',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 메모 검증 메시지
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'title' => [
|
||||
'required' => '메모 제목은 필수입니다.',
|
||||
'max' => '메모 제목은 :max자를 초과할 수 없습니다.',
|
||||
],
|
||||
'content' => [
|
||||
'required' => '메모 본문은 필수입니다.',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Gnuboard7\HelloModule\Http\Controllers\Api\MemoController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Hello Module Public API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| 비로그인 사용자도 접근 가능한 공개 읽기 API.
|
||||
|
|
||||
*/
|
||||
|
||||
Route::prefix('memos')
|
||||
->middleware(['optional.sanctum', 'throttle:600,1'])
|
||||
->name('memos.')
|
||||
->group(function () {
|
||||
Route::get('/', [MemoController::class, 'index'])->name('index');
|
||||
Route::get('/{id}', [MemoController::class, 'show'])
|
||||
->whereNumber('id')
|
||||
->name('show');
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\Gnuboard7\HelloModule\Http\Controllers\Admin\MemoController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Hello Module Admin Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| ModuleRouteServiceProvider 가 자동으로 prefix 를 적용합니다.
|
||||
| - URL prefix: 'api/modules/gnuboard7-hello_module'
|
||||
| - Name prefix: 'api.modules.gnuboard7-hello_module.'
|
||||
|
|
||||
*/
|
||||
|
||||
Route::prefix('admin/memos')
|
||||
->middleware(['auth:sanctum', 'throttle:600,1'])
|
||||
->name('admin.memos.')
|
||||
->group(function () {
|
||||
Route::get('/', [MemoController::class, 'index'])
|
||||
->middleware('permission:admin,gnuboard7-hello_module.memos.read')
|
||||
->name('index');
|
||||
|
||||
Route::post('/', [MemoController::class, 'store'])
|
||||
->middleware('permission:admin,gnuboard7-hello_module.memos.create')
|
||||
->name('store');
|
||||
|
||||
Route::get('/{id}', [MemoController::class, 'show'])
|
||||
->whereNumber('id')
|
||||
->middleware('permission:admin,gnuboard7-hello_module.memos.read')
|
||||
->name('show');
|
||||
|
||||
Route::put('/{id}', [MemoController::class, 'update'])
|
||||
->whereNumber('id')
|
||||
->middleware('permission:admin,gnuboard7-hello_module.memos.update')
|
||||
->name('update');
|
||||
|
||||
Route::delete('/{id}', [MemoController::class, 'destroy'])
|
||||
->whereNumber('id')
|
||||
->middleware('permission:admin,gnuboard7-hello_module.memos.delete')
|
||||
->name('destroy');
|
||||
});
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Tests\Feature\Admin;
|
||||
|
||||
require_once __DIR__.'/../../FeatureTestCase.php';
|
||||
|
||||
use App\Models\User;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
use Modules\Gnuboard7\HelloModule\Tests\FeatureTestCase;
|
||||
use Tests\Helpers\ProtectsExtensionDirectories;
|
||||
|
||||
/**
|
||||
* 관리자 메모 컨트롤러 Feature 테스트
|
||||
*
|
||||
* Admin CRUD 각 1건을 검증합니다.
|
||||
*/
|
||||
class MemoControllerTest extends FeatureTestCase
|
||||
{
|
||||
use ProtectsExtensionDirectories;
|
||||
|
||||
protected User $adminUser;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpExtensionProtection();
|
||||
|
||||
$this->adminUser = $this->createAdminUser([
|
||||
'gnuboard7-hello_module.memos.read',
|
||||
'gnuboard7-hello_module.memos.create',
|
||||
'gnuboard7-hello_module.memos.update',
|
||||
'gnuboard7-hello_module.memos.delete',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->tearDownExtensionProtection();
|
||||
|
||||
Memo::query()->delete();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모 목록을 조회할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_admin_can_list_memos(): void
|
||||
{
|
||||
Memo::factory()->count(2)->create();
|
||||
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->getJson('/api/modules/gnuboard7-hello_module/admin/memos');
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonStructure([
|
||||
'success',
|
||||
'data' => [
|
||||
'data',
|
||||
'meta' => ['current_page', 'last_page', 'per_page', 'total'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 생성할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_admin_can_create_memo(): void
|
||||
{
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->postJson('/api/modules/gnuboard7-hello_module/admin/memos', [
|
||||
'title' => '새 메모',
|
||||
'content' => '본문 내용',
|
||||
]);
|
||||
|
||||
$response->assertStatus(201)
|
||||
->assertJsonPath('success', true)
|
||||
->assertJsonPath('data.title', '새 메모');
|
||||
|
||||
$this->assertDatabaseHas('gnuboard7_hello_module_memos', [
|
||||
'title' => '새 메모',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모 상세를 조회할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_admin_can_show_memo(): void
|
||||
{
|
||||
$memo = Memo::factory()->create(['title' => '상세 대상']);
|
||||
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->getJson("/api/modules/gnuboard7-hello_module/admin/memos/{$memo->id}");
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonPath('data.id', $memo->id)
|
||||
->assertJsonPath('data.title', '상세 대상');
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 수정할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_admin_can_update_memo(): void
|
||||
{
|
||||
$memo = Memo::factory()->create(['title' => '수정 전']);
|
||||
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->putJson("/api/modules/gnuboard7-hello_module/admin/memos/{$memo->id}", [
|
||||
'title' => '수정 후',
|
||||
'content' => '수정된 본문',
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonPath('data.title', '수정 후');
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 삭제할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_admin_can_delete_memo(): void
|
||||
{
|
||||
$memo = Memo::factory()->create();
|
||||
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->deleteJson("/api/modules/gnuboard7-hello_module/admin/memos/{$memo->id}");
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonPath('success', true);
|
||||
|
||||
$this->assertDatabaseMissing('gnuboard7_hello_module_memos', [
|
||||
'id' => $memo->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 필수 필드가 누락되면 422 를 반환하는지 확인합니다.
|
||||
*/
|
||||
public function test_creating_memo_without_required_fields_returns_422(): void
|
||||
{
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->postJson('/api/modules/gnuboard7-hello_module/admin/memos', []);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors(['title', 'content']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Tests\Feature;
|
||||
|
||||
require_once __DIR__.'/../FeatureTestCase.php';
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
use Modules\Gnuboard7\HelloModule\Services\MemoService;
|
||||
use Modules\Gnuboard7\HelloModule\Tests\FeatureTestCase;
|
||||
|
||||
/**
|
||||
* 훅 통합 테스트
|
||||
*
|
||||
* MemoService::createMemo() 호출 시 `gnuboard7-hello_module.memo.created` 훅이
|
||||
* 실제로 발행되고 리스너가 반응하는지 검증합니다. (mock 금지 - 실제 훅 체인)
|
||||
*/
|
||||
class HookIntegrationTest extends FeatureTestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Memo::query()->delete();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* MemoService::createMemo 호출 시 memo.created 훅이 발행되는지 확인합니다.
|
||||
*/
|
||||
public function test_creating_memo_triggers_memo_created_hook(): void
|
||||
{
|
||||
$captured = [];
|
||||
|
||||
// 테스트 전용 리스너 등록 (HookManager 에 직접 주입)
|
||||
$hookManager = app(HookManager::class);
|
||||
$hookManager->addAction(
|
||||
'gnuboard7-hello_module.memo.created',
|
||||
function (...$args) use (&$captured) {
|
||||
$captured[] = $args[0] ?? null;
|
||||
},
|
||||
5
|
||||
);
|
||||
|
||||
/** @var MemoService $service */
|
||||
$service = app(MemoService::class);
|
||||
$memo = $service->createMemo([
|
||||
'title' => '훅 발행 테스트',
|
||||
'content' => '본문',
|
||||
]);
|
||||
|
||||
// 훅이 1회 발행되고, 전달된 payload 가 생성된 Memo 와 동일한지 검증
|
||||
$this->assertCount(1, $captured, '메모 생성 시 memo.created 훅이 정확히 1회 발행되어야 합니다.');
|
||||
$this->assertInstanceOf(Memo::class, $captured[0]);
|
||||
$this->assertEquals($memo->id, $captured[0]->id);
|
||||
$this->assertEquals('훅 발행 테스트', $captured[0]->title);
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본 등록된 LogMemoCreatedListener 가 예외 없이 호출되는지 확인합니다.
|
||||
*
|
||||
* (로그 내용은 검증하지 않고, 훅 체인 실행 시 예외가 발생하지 않는지만 확인)
|
||||
*/
|
||||
public function test_default_listener_runs_without_exception(): void
|
||||
{
|
||||
/** @var MemoService $service */
|
||||
$service = app(MemoService::class);
|
||||
|
||||
$memo = $service->createMemo([
|
||||
'title' => '기본 리스너 테스트',
|
||||
'content' => '본문',
|
||||
]);
|
||||
|
||||
$this->assertNotNull($memo->id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Tests;
|
||||
|
||||
/**
|
||||
* Hello 모듈 Feature 테스트 베이스
|
||||
*
|
||||
* HTTP 요청 기반 API 테스트에 사용합니다.
|
||||
*/
|
||||
abstract class FeatureTestCase extends ModuleTestCase
|
||||
{
|
||||
/**
|
||||
* 테스트 환경 설정
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->registerModuleAsActive();
|
||||
$this->registerModuleRoutes();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Tests;
|
||||
|
||||
use App\Enums\ExtensionStatus;
|
||||
use App\Models\Module;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Hello 모듈 테스트 베이스 클래스
|
||||
*
|
||||
* 모듈 오토로드, ServiceProvider 등록, 마이그레이션 실행을 담당합니다.
|
||||
*/
|
||||
abstract class ModuleTestCase extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* 마이그레이션 완료 플래그 (프로세스당 한 번만 실행)
|
||||
*/
|
||||
protected static bool $migrated = false;
|
||||
|
||||
/**
|
||||
* 모듈 루트 경로를 반환합니다.
|
||||
*
|
||||
* @return string 모듈 루트 절대 경로
|
||||
*/
|
||||
protected function getModuleBasePath(): string
|
||||
{
|
||||
return dirname(__DIR__);
|
||||
}
|
||||
|
||||
/**
|
||||
* HookManager static state 스냅샷 — tearDown 에서 복원하여 테스트 간 훅 격리 보장.
|
||||
*
|
||||
* @var array{hooks: array, filters: array, dispatching: array}|null
|
||||
*/
|
||||
private ?array $hookSnapshot = null;
|
||||
|
||||
/**
|
||||
* 테스트 환경 설정
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->registerModuleAutoload();
|
||||
|
||||
$this->app->register(\Modules\Gnuboard7\HelloModule\Providers\HelloModuleServiceProvider::class);
|
||||
|
||||
$this->runModuleMigrationIfNeeded();
|
||||
|
||||
$this->createDefaultRoles();
|
||||
|
||||
// 훅 리스너 수동 등록 (모듈 매니저를 거치지 않는 테스트 환경 대응)
|
||||
$this->registerModuleHookListeners();
|
||||
|
||||
// 훅 등록 완료 후 스냅샷 — tearDown 에서 이 시점으로 복원
|
||||
$this->snapshotHookManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown 에 HookManager 상태 복원 — 테스트 본문이 추가한 훅만 제거.
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->restoreHookManager();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* HookManager static $hooks / $filters / $dispatching 를 스냅샷.
|
||||
*/
|
||||
private function snapshotHookManager(): void
|
||||
{
|
||||
$ref = new \ReflectionClass(\App\Extension\HookManager::class);
|
||||
$this->hookSnapshot = [
|
||||
'hooks' => $ref->getProperty('hooks')->getValue(),
|
||||
'filters' => $ref->getProperty('filters')->getValue(),
|
||||
'dispatching' => $ref->getProperty('dispatching')->getValue(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 스냅샷 시점으로 HookManager 복원.
|
||||
*/
|
||||
private function restoreHookManager(): void
|
||||
{
|
||||
if ($this->hookSnapshot === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ref = new \ReflectionClass(\App\Extension\HookManager::class);
|
||||
$ref->getProperty('hooks')->setValue(null, $this->hookSnapshot['hooks']);
|
||||
$ref->getProperty('filters')->setValue(null, $this->hookSnapshot['filters']);
|
||||
$ref->getProperty('dispatching')->setValue(null, $this->hookSnapshot['dispatching']);
|
||||
|
||||
$this->hookSnapshot = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 모듈 마이그레이션을 필요 시 실행합니다.
|
||||
*/
|
||||
protected function runModuleMigrationIfNeeded(): void
|
||||
{
|
||||
if (static::$migrated) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 매 PHP process 첫 setUp 시 DB 완전 초기화 후 코어+모듈 마이그레이션을 처음부터 실행한다.
|
||||
// (DatabaseTransactions 사용 시 schema 자동 재구축 없음 — 잔재로 인한 컬럼 충돌 차단)
|
||||
$this->artisan('migrate:fresh');
|
||||
|
||||
$this->artisan('migrate', [
|
||||
'--path' => $this->getModuleBasePath().'/database/migrations',
|
||||
'--realpath' => true,
|
||||
]);
|
||||
|
||||
static::$migrated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 모듈 오토로드를 등록합니다.
|
||||
*/
|
||||
protected function registerModuleAutoload(): void
|
||||
{
|
||||
$moduleBasePath = $this->getModuleBasePath();
|
||||
|
||||
spl_autoload_register(function ($class) use ($moduleBasePath) {
|
||||
$prefix = 'Modules\\Gnuboard7\\HelloModule\\';
|
||||
$len = strlen($prefix);
|
||||
|
||||
if (strncmp($prefix, $class, $len) !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$relativeClass = substr($class, $len);
|
||||
|
||||
if (str_starts_with($relativeClass, 'Database\\Factories\\')) {
|
||||
$factoryClass = substr($relativeClass, strlen('Database\\Factories\\'));
|
||||
$file = $moduleBasePath.'/database/factories/'.str_replace('\\', '/', $factoryClass).'.php';
|
||||
} elseif (str_starts_with($relativeClass, 'Database\\Seeders\\')) {
|
||||
$seederClass = substr($relativeClass, strlen('Database\\Seeders\\'));
|
||||
$file = $moduleBasePath.'/database/seeders/'.str_replace('\\', '/', $seederClass).'.php';
|
||||
} else {
|
||||
$file = $moduleBasePath.'/src/'.str_replace('\\', '/', $relativeClass).'.php';
|
||||
}
|
||||
|
||||
if (file_exists($file)) {
|
||||
require $file;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 모듈을 활성화 상태로 등록합니다.
|
||||
*/
|
||||
protected function registerModuleAsActive(): void
|
||||
{
|
||||
if (Module::where('identifier', 'gnuboard7-hello_module')->exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Module::create([
|
||||
'identifier' => 'gnuboard7-hello_module',
|
||||
'vendor' => 'gnuboard7',
|
||||
'name' => ['ko' => 'Hello 모듈', 'en' => 'Hello Module'],
|
||||
'status' => ExtensionStatus::Active->value,
|
||||
'version' => '0.1.0-beta.1',
|
||||
'config' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 모듈 라우트를 등록합니다.
|
||||
*/
|
||||
protected function registerModuleRoutes(): void
|
||||
{
|
||||
$apiRoutesFile = $this->getModuleBasePath().'/src/routes/api.php';
|
||||
$webRoutesFile = $this->getModuleBasePath().'/src/routes/web.php';
|
||||
|
||||
if (file_exists($webRoutesFile)) {
|
||||
Route::prefix('api/modules/gnuboard7-hello_module')
|
||||
->name('api.modules.gnuboard7-hello_module.')
|
||||
->middleware('api')
|
||||
->group($webRoutesFile);
|
||||
}
|
||||
|
||||
if (file_exists($apiRoutesFile)) {
|
||||
Route::prefix('api/modules/gnuboard7-hello_module')
|
||||
->name('api.modules.gnuboard7-hello_module.public.')
|
||||
->middleware('api')
|
||||
->group($apiRoutesFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 모듈 훅 리스너를 수동 등록합니다.
|
||||
*
|
||||
* 실제 런타임에서는 ModuleManager 가 자동 등록하지만
|
||||
* 테스트 환경에서는 수동으로 HookManager 에 주입해야 합니다.
|
||||
*/
|
||||
protected function registerModuleHookListeners(): void
|
||||
{
|
||||
$moduleClass = 'Modules\\Gnuboard7\\HelloModule\\Module';
|
||||
if (! class_exists($moduleClass)) {
|
||||
require_once $this->getModuleBasePath().'/module.php';
|
||||
}
|
||||
|
||||
$module = new $moduleClass([
|
||||
'identifier' => 'gnuboard7-hello_module',
|
||||
'vendor' => 'gnuboard7',
|
||||
'name' => ['ko' => 'Hello 모듈', 'en' => 'Hello Module'],
|
||||
'version' => '0.1.0-beta.1',
|
||||
]);
|
||||
|
||||
$hookManager = app(\App\Extension\HookManager::class);
|
||||
foreach ($module->getHookListeners() as $listenerClass) {
|
||||
foreach ($listenerClass::getSubscribedHooks() as $hookName => $config) {
|
||||
$method = is_array($config) ? ($config['method'] ?? 'handle') : 'handle';
|
||||
$priority = is_array($config) ? ($config['priority'] ?? 10) : 10;
|
||||
$hookManager->addAction($hookName, [new $listenerClass(), $method], $priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 기본 역할을 생성합니다.
|
||||
*/
|
||||
protected function createDefaultRoles(): void
|
||||
{
|
||||
Role::firstOrCreate(
|
||||
['identifier' => 'admin'],
|
||||
['name' => ['ko' => '관리자', 'en' => 'Administrator']]
|
||||
);
|
||||
|
||||
Role::firstOrCreate(
|
||||
['identifier' => 'user'],
|
||||
['name' => ['ko' => '일반 사용자', 'en' => 'User']]
|
||||
);
|
||||
|
||||
Role::firstOrCreate(
|
||||
['identifier' => 'guest'],
|
||||
['name' => ['ko' => '비회원', 'en' => 'Guest']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 역할을 가진 사용자를 생성합니다.
|
||||
*
|
||||
* @param array $permissions 추가 권한 목록
|
||||
* @return User 관리자 사용자
|
||||
*/
|
||||
protected function createAdminUser(array $permissions = []): User
|
||||
{
|
||||
$adminRole = Role::where('identifier', 'admin')->first();
|
||||
$user = User::factory()->create();
|
||||
$user->roles()->attach($adminRole->id);
|
||||
|
||||
foreach ($permissions as $permissionIdentifier) {
|
||||
$permission = Permission::firstOrCreate(
|
||||
['identifier' => $permissionIdentifier],
|
||||
[
|
||||
'name' => ['ko' => $permissionIdentifier, 'en' => $permissionIdentifier],
|
||||
'type' => 'admin',
|
||||
]
|
||||
);
|
||||
$adminRole->permissions()->syncWithoutDetaching([$permission->id]);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 일반 사용자를 생성합니다.
|
||||
*
|
||||
* @return User 일반 사용자
|
||||
*/
|
||||
protected function createUser(): User
|
||||
{
|
||||
$userRole = Role::where('identifier', 'user')->first();
|
||||
$user = User::factory()->create();
|
||||
$user->roles()->attach($userRole->id);
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Gnuboard7\HelloModule\Tests\Unit\Services;
|
||||
|
||||
use Modules\Gnuboard7\HelloModule\Models\Memo;
|
||||
use Modules\Gnuboard7\HelloModule\Services\MemoService;
|
||||
use Modules\Gnuboard7\HelloModule\Tests\ModuleTestCase;
|
||||
|
||||
/**
|
||||
* MemoService 단위 테스트
|
||||
*
|
||||
* 메모 생성/수정/삭제 Pure Logic 을 검증합니다.
|
||||
*/
|
||||
class MemoServiceTest extends ModuleTestCase
|
||||
{
|
||||
private MemoService $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->service = app(MemoService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 생성할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_create_memo_persists_record(): void
|
||||
{
|
||||
$memo = $this->service->createMemo([
|
||||
'title' => '테스트 제목',
|
||||
'content' => '테스트 본문',
|
||||
]);
|
||||
|
||||
$this->assertInstanceOf(Memo::class, $memo);
|
||||
$this->assertNotNull($memo->uuid);
|
||||
$this->assertEquals('테스트 제목', $memo->title);
|
||||
|
||||
$this->assertDatabaseHas('gnuboard7_hello_module_memos', [
|
||||
'id' => $memo->id,
|
||||
'title' => '테스트 제목',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 수정할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_update_memo_changes_fields(): void
|
||||
{
|
||||
$memo = $this->service->createMemo([
|
||||
'title' => '원본',
|
||||
'content' => '원본 본문',
|
||||
]);
|
||||
|
||||
$updated = $this->service->updateMemo($memo, [
|
||||
'title' => '수정됨',
|
||||
'content' => '수정된 본문',
|
||||
]);
|
||||
|
||||
$this->assertEquals('수정됨', $updated->title);
|
||||
$this->assertEquals('수정된 본문', $updated->content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 메모를 삭제할 수 있는지 확인합니다.
|
||||
*/
|
||||
public function test_delete_memo_removes_record(): void
|
||||
{
|
||||
$memo = $this->service->createMemo([
|
||||
'title' => '삭제 대상',
|
||||
'content' => '본문',
|
||||
]);
|
||||
|
||||
$result = $this->service->deleteMemo($memo);
|
||||
|
||||
$this->assertTrue($result);
|
||||
$this->assertDatabaseMissing('gnuboard7_hello_module_memos', [
|
||||
'id' => $memo->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,41 @@
|
||||
형식은 [Keep a Changelog](https://keepachangelog.com/ko/1.1.0/)를 따르며,
|
||||
[Semantic Versioning](https://semver.org/lang/ko/)을 준수합니다.
|
||||
|
||||
## [1.0.0-beta.4] - 2026-05-11
|
||||
|
||||
### Added
|
||||
|
||||
- 환경설정 → 신고 정책 탭에 신고 알림 채널 선택 UI 추가 (이메일 / 사이트 알림 다중 선택)
|
||||
- 게시판 환경설정에 "본인인증 정책" 탭 추가 — 게시판 컨텍스트의 본인인증 정책을 코어 정책 관리 화면과 동일한 UI/UX (검색·필터(강제 시점/출처)·페이지네이션·정책 추가/편집 모달 직접 호출·이 모듈이 등록한 본인인증 목적 칩 섹션·데스크탑 테이블/모바일 카드 자동 분기 + enabled 인라인 토글) 로 한 곳에서 관리. 정책 목록의 "인증 목적" 컬럼이 코드명 대신 사람이 읽을 수 있는 라벨로 표시
|
||||
- 본인인증 정책 4종 declarative 선언 (게시글 삭제·블라인드·신고 일괄처리·신고 삭제) — 기본 비활성, 운영자가 환경설정에서 활성화 가능
|
||||
- 사용자(self) 본인인증 정책 4종 추가 — 자기 글 삭제, 자기 댓글 삭제, 신고 작성, 신규 사용자 첫 글 작성. 기본 비활성, 운영자가 환경설정에서 활성화 가능
|
||||
- 본인인증 메시지 정의를 모듈 자체에서 선언하도록 정합화 (현재는 코어 sensitive_action 기본 문구를 그대로 사용하므로 빈 선언 유지)
|
||||
- 게시판 모듈 자체 권한 신설: `sirsoft-board.identity.policies.{read,update}` (정책 관리 최소 권한)
|
||||
- 게시판 알림 발송 이력 / 본인인증 이력 샘플 시더 추가 — `module:seed sirsoft-board --sample` 으로 댓글·신고 등 게시판 영역 더미 이력만 독립 생성 (코어/타 모듈 영역 침범 없음)
|
||||
- 게시판 알림 정의 7종(새 댓글·대댓글·답변글·게시글 처리·신규 게시글 관리자·신고 접수·신고 처리)을 모듈 manifest 에서 직접 선언하도록 통일 — 활성화/업데이트 시 운영자 편집값을 보존하면서 자동 등록·정리되며, 권한·메뉴·본인인증과 동일한 declarative 패턴으로 일관화
|
||||
- 게시글 상세 페이지의 OG 메타태그·Article 구조화 데이터를 게시판 모듈이 직접 선언하도록 SEO declaration 구현 — 작성일·수정일·작성자·게시판 카테고리가 og:article:* 와 Schema.org Article 스키마로 자동 출력됨
|
||||
- 게시글 API 응답에 첨부파일 개수(`attachment_count`) 노출 — 기존 첨부 여부(`has_attachment`) 와 함께 제공되어 헤더 카운트와 첨부 수 표시를 일관되게 처리
|
||||
- 활동 로그의 게시판 액션 라벨(게시글·댓글·신고 등)을 게시판 모듈 다국어 파일에서 관리하도록 정리 — 모듈 라벨이 자기 영역에서 자기설명되며, 일본어 등 추가 언어팩이 키 누락 없이 동기화
|
||||
|
||||
### Changed
|
||||
|
||||
- 코어 최소 요구 버전을 7.0.0-beta.4 로 상향 (본인인증 인프라 + source 필터 API + 알림 시스템 권한 기반 수신자 타입 의존)
|
||||
- 신고 알림(관리자 수신) 기본 수신자를 역할(role=admin) 에서 권한(`sirsoft-board.reports.manage`) 기반으로 전환 — 권한이 부여된 모든 역할로 자동 확장
|
||||
- 모듈 환경설정에서 알림 토글이 OFF 인 경우 발송 자체를 사전 차단하도록 정책 게이트 강화
|
||||
- 게시판 유형(`board_types`) 의 다국어 라벨이 활성 언어팩 추가 시 자동으로 새 언어 키를 포함하도록 정합화 — 운영자가 한국어 라벨만 직접 수정한 row 도 한국어는 보존하면서 신규 언어(예: 일본어) 라벨은 자동 동기화
|
||||
|
||||
### Fixed
|
||||
|
||||
- 알림 템플릿 편집 모달의 입력 필드에서 글자를 입력할 때마다 화면이 심하게 버벅이던 문제 수정
|
||||
- 게시판 환경설정 알림 탭의 채널 라벨이 식별자(mail / database)로 노출되던 문제 수정 — 활성 언어 기준의 사람이 읽을 수 있는 라벨로 표시
|
||||
- 사용자 활동(작성/댓글) 조회 응답의 댓글 수 키를 단수형(`comment_count`) 으로 통일 — 게시글 상세 응답과 키 명명을 일치시켜 프로필/마이페이지의 댓글 수 표시를 일관되게 함
|
||||
- 관리자 게시글 상세의 섹션 순서 변경 — 첨부파일을 원글 인용 박스 위로 이동 (답글 화면에서 첨부파일이 더 잘 보이도록)
|
||||
- 게시판 환경설정의 일괄 적용 체크박스가 라벨 클릭으로만 토글되고 체크박스 자체 클릭으로는 반응하지 않던 문제 수정 — 모든 일괄 적용 항목에서 라벨과 체크박스 어느 쪽을 클릭해도 일관되게 토글
|
||||
- 게시판 환경설정 권한 탭의 권한 행과 섹션 헤더(관리자/사용자) 일괄 토글 체크박스가 직접 클릭으로 반응하지 않던 문제 수정
|
||||
- 게시판/게시글/댓글 모델의 카운트 컬럼(게시글 수·댓글 수·답글 수·첨부파일 수)이 일부 흐름에서 정수가 아닌 문자열로 노출되거나 갱신되지 않던 문제 수정 — 모든 카운트 컬럼이 항상 정수로 처리됩니다
|
||||
- 관리자 게시글 상세의 답글/댓글/첨부파일 헤더 카운트가 실제 수와 어긋나던 문제 수정 — "삭제 댓글 보기" 토글 ON 시에도 헤더는 활성 댓글 수만 표시
|
||||
- 관리자 게시글 상세의 첨부파일 이미지 썸네일이 표시되지 않던 문제 수정 — 다운로드 URL 대신 미리보기 URL 사용
|
||||
|
||||
## [1.0.0-beta.3] - 2026-04-21
|
||||
|
||||
### Fixed
|
||||
@@ -12,6 +47,8 @@
|
||||
- 일부 권한 설정에서 비밀글·접근 제한 게시글의 이전/다음 조회 시 500 오류가 발생하던 문제 수정 — 옆 글을 찾지 못하면 빈 값을 반환하도록 변경
|
||||
- 큐 워커가 실행 중이지 않은 환경에서 댓글/게시글/첨부 수가 즉시 반영되지 않던 문제 수정
|
||||
- CKEditor 등 임시 업로드를 거친 첨부가 게시글에 연결되어도 첨부 수가 늘어나지 않던 문제 수정
|
||||
- 내가 댓글 단 게시글 활동(`activity_type=commented`) 조회 시 쿼리 오류로 500 응답을 반환하던 문제 수정
|
||||
- 삭제된 게시글에 달았던 댓글이 활동 통계(`total_comments`)에 계속 포함되던 문제 수정
|
||||
|
||||
### Removed
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "modules/sirsoft-board",
|
||||
"description": "Board module for Gnuboard7",
|
||||
"type": "library",
|
||||
"version": "1.0.0-beta.3",
|
||||
"version": "1.0.0-beta.4",
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -71,7 +71,9 @@
|
||||
"rejection_limit_days": 30,
|
||||
"notify_admin_on_report": true,
|
||||
"notify_admin_on_report_scope": "per_case",
|
||||
"notify_author_on_report_action": true
|
||||
"notify_admin_on_report_channels": ["mail", "database"],
|
||||
"notify_author_on_report_action": true,
|
||||
"notify_author_on_report_action_channels": ["mail", "database"]
|
||||
},
|
||||
"spam_security": {
|
||||
"post_cooldown_seconds": 0,
|
||||
|
||||
-483
@@ -1,483 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Board\Database\Seeders;
|
||||
|
||||
use App\Extension\Helpers\NotificationSyncHelper;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class BoardNotificationDefinitionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* 게시판 알림 정의 및 템플릿을 시딩합니다.
|
||||
*
|
||||
* 데이터 정합성 (upsert + stale cleanup) 은 NotificationSyncHelper 에 위임하며,
|
||||
* 사용자 수정(user_overrides) 은 helper 내부 HasUserOverrides trait 를 통해 보존됩니다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->command?->info('게시판 알림 정의 시딩 시작...');
|
||||
|
||||
$helper = app(NotificationSyncHelper::class);
|
||||
$definitions = $this->getDefaultDefinitions();
|
||||
$definedTypes = [];
|
||||
|
||||
foreach ($definitions as $data) {
|
||||
$definition = $helper->syncDefinition($data);
|
||||
$definedTypes[] = $definition->type;
|
||||
|
||||
$definedChannels = [];
|
||||
foreach ($data['templates'] as $template) {
|
||||
$helper->syncTemplate($definition->id, $template);
|
||||
$definedChannels[] = $template['channel'];
|
||||
}
|
||||
|
||||
// 완전 동기화: seeder 에서 제거된 channel 의 template 삭제
|
||||
$helper->cleanupStaleTemplates($definition->id, $definedChannels);
|
||||
|
||||
$this->command?->info(" - {$data['type']} 알림 정의 등록 완료");
|
||||
}
|
||||
|
||||
// 완전 동기화: seeder 에서 제거된 게시판 definition 삭제 (cascade 로 template 도 정리)
|
||||
$helper->cleanupStaleDefinitions('module', 'sirsoft-board', $definedTypes);
|
||||
|
||||
$this->command?->info('게시판 알림 정의 시딩 완료 ('.count($definitions).'종)');
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 기본 알림 정의 데이터를 반환합니다.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultDefinitions(): array
|
||||
{
|
||||
return [
|
||||
$this->newCommentDefinition(),
|
||||
$this->replyCommentDefinition(),
|
||||
$this->postReplyDefinition(),
|
||||
$this->postActionDefinition(),
|
||||
$this->newPostAdminDefinition(),
|
||||
$this->reportReceivedAdminDefinition(),
|
||||
$this->reportActionDefinition(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 새 댓글 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function newCommentDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'new_comment',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => 'sirsoft-board',
|
||||
'name' => ['ko' => '새 댓글 알림', 'en' => 'New Comment Notification'],
|
||||
'description' => ['ko' => '게시글에 새 댓글이 작성되면 게시글 작성자에게 발송', 'en' => 'Sent to post author when a new comment is posted'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.comment.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'comment_author', 'description' => '댓글 작성자'],
|
||||
['key' => 'comment_content', 'description' => '댓글 내용 (200자)'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] 게시글에 새 댓글이 등록되었습니다',
|
||||
'en' => '[{board_name}] New comment on your post',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판의 게시글에 <strong>{comment_author}</strong>님이 댓글을 남겼습니다.</p>'
|
||||
.'<blockquote style="border-left: 3px solid #cbd5e0; padding-left: 12px; color: #718096;">{comment_content}</blockquote>'
|
||||
.$this->button('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p><strong>{comment_author}</strong> commented on your post in <strong>{board_name}</strong>.</p>'
|
||||
.'<blockquote style="border-left: 3px solid #cbd5e0; padding-left: 12px; color: #718096;">{comment_content}</blockquote>'
|
||||
.$this->button('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '게시글에 새 댓글이 달렸습니다', 'en' => 'New comment on your post'],
|
||||
'body' => ['ko' => '{comment_author}님이 \'{board_name}\' 게시글 \'{post_title}\'에 댓글을 남겼습니다.', 'en' => '{comment_author} commented on your post \'{post_title}\' in \'{board_name}\'.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 대댓글 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function replyCommentDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'reply_comment',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => 'sirsoft-board',
|
||||
'name' => ['ko' => '대댓글 알림', 'en' => 'Reply Comment Notification'],
|
||||
'description' => ['ko' => '댓글에 대댓글이 작성되면 댓글 작성자에게 발송', 'en' => 'Sent to comment author when a reply is posted'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.comment.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'comment_author', 'description' => '답글 작성자'],
|
||||
['key' => 'comment_content', 'description' => '답글 내용 (200자)'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'parent_comment_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] 댓글에 답글이 등록되었습니다',
|
||||
'en' => '[{board_name}] Reply to your comment',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판에서 <strong>{comment_author}</strong>님이 댓글에 답글을 남겼습니다.</p>'
|
||||
.'<blockquote style="border-left: 3px solid #cbd5e0; padding-left: 12px; color: #718096;">{comment_content}</blockquote>'
|
||||
.$this->button('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p><strong>{comment_author}</strong> replied to your comment in <strong>{board_name}</strong>.</p>'
|
||||
.'<blockquote style="border-left: 3px solid #cbd5e0; padding-left: 12px; color: #718096;">{comment_content}</blockquote>'
|
||||
.$this->button('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'parent_comment_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '댓글에 답글이 달렸습니다', 'en' => 'New reply to your comment'],
|
||||
'body' => ['ko' => '{comment_author}님이 \'{board_name}\'의 댓글에 답글을 남겼습니다.', 'en' => '{comment_author} replied to your comment in \'{board_name}\'.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 답변글 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function postReplyDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'post_reply',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => 'sirsoft-board',
|
||||
'name' => ['ko' => '답변글 알림', 'en' => 'Post Reply Notification'],
|
||||
'description' => ['ko' => '게시글에 답변글이 작성되면 원글 작성자에게 발송', 'en' => 'Sent to original post author when a reply post is created'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.post.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'original_post_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] 게시글에 답변글이 등록되었습니다',
|
||||
'en' => '[{board_name}] Reply to your post',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판의 게시글 "<strong>{post_title}</strong>"에 답변글이 등록되었습니다.</p>'
|
||||
.$this->button('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>A reply has been posted to your post "<strong>{post_title}</strong>" in <strong>{board_name}</strong>.</p>'
|
||||
.$this->button('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'original_post_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '게시글에 답변이 등록되었습니다', 'en' => 'A reply has been posted to your post'],
|
||||
'body' => ['ko' => '\'{board_name}\'의 게시글 \'{post_title}\'에 답변이 등록되었습니다.', 'en' => 'A reply has been posted to your post \'{post_title}\' in \'{board_name}\'.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시글 처리 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function postActionDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'post_action',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => 'sirsoft-board',
|
||||
'name' => ['ko' => '게시글/댓글 처리 알림', 'en' => 'Content Action Notification'],
|
||||
'description' => ['ko' => '게시글/댓글 블라인드/삭제/복원 시 작성자에게 발송', 'en' => 'Sent to author on blind/delete/restore actions'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.post.after_blind', 'sirsoft-board.post.after_delete', 'sirsoft-board.post.after_restore', 'sirsoft-board.comment.after_blind', 'sirsoft-board.comment.after_delete', 'sirsoft-board.comment.after_restore'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'action_type', 'description' => '처리 유형 (블라인드/삭제/복원)'],
|
||||
['key' => 'target_type', 'description' => '처리 대상 (게시글/댓글)'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author']],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] \'{post_title}\' {target_type}이(가) {action_type} 처리되었습니다',
|
||||
'en' => '[{board_name}] Your {target_type} "{post_title}" has been {action_type}',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판의 "<strong>{post_title}</strong>" {target_type}이(가) 관리자에 의해 <strong>{action_type}</strong> 처리되었습니다.</p>'
|
||||
.'<p>문의사항이 있으시면 관리자에게 연락해 주세요.</p>'
|
||||
.$this->button('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>Your {target_type} "<strong>{post_title}</strong>" in <strong>{board_name}</strong> has been <strong>{action_type}</strong> by an administrator.</p>'
|
||||
.'<p>If you have any questions, please contact the administrator.</p>'
|
||||
.$this->button('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author']],
|
||||
'subject' => ['ko' => '{target_type}이(가) 처리되었습니다', 'en' => 'Your {target_type} has been actioned'],
|
||||
'body' => ['ko' => '\'{board_name}\'의 \'{post_title}\' {target_type}이(가) {action_type} 처리되었습니다.', 'en' => 'Your {target_type} \'{post_title}\' in \'{board_name}\' has been {action_type}.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 새 게시글 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function newPostAdminDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'new_post_admin',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => 'sirsoft-board',
|
||||
'name' => ['ko' => '새 게시글 관리자 알림', 'en' => 'New Post Admin Notification'],
|
||||
'description' => ['ko' => '새 게시글 작성 시 관리자에게 발송', 'en' => 'Sent to admin when a new post is created'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.post.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름 (관리자)'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'post_author', 'description' => '게시글 작성자'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'board_managers', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] 새 게시글이 등록되었습니다',
|
||||
'en' => '[{board_name}] New post has been created',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판에 <strong>{post_author}</strong>님이 새 게시글을 등록했습니다.</p>'
|
||||
.'<p>게시글 제목: <strong>{post_title}</strong></p>'
|
||||
.$this->button('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p><strong>{post_author}</strong> created a new post in <strong>{board_name}</strong>.</p>'
|
||||
.'<p>Title: <strong>{post_title}</strong></p>'
|
||||
.$this->button('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'board_managers', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '새 게시글이 등록되었습니다', 'en' => 'New post registered'],
|
||||
'body' => ['ko' => '{post_author}님이 \'{board_name}\'에 새 게시글 \'{post_title}\'을 등록했습니다.', 'en' => '{post_author} posted \'{post_title}\' in \'{board_name}\'.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 신고 접수 관리자 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function reportReceivedAdminDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'report_received_admin',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => 'sirsoft-board',
|
||||
'name' => ['ko' => '신고 접수 관리자 알림', 'en' => 'Report Received Admin Notification'],
|
||||
'description' => ['ko' => '신고 접수 시 관리자에게 발송', 'en' => 'Sent to admin when a report is received'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.report.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '신고 대상 게시글 제목'],
|
||||
['key' => 'target_type', 'description' => '신고 대상 유형 (게시글/댓글)'],
|
||||
['key' => 'reason_type', 'description' => '신고 사유'],
|
||||
['key' => 'report_url', 'description' => '신고 관리 페이지 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'role', 'value' => 'admin', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] "{post_title}"에 대한 신고가 접수되었습니다',
|
||||
'en' => '[{board_name}] A new report has been received for "{post_title}"',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판에서 <strong>{target_type}</strong> "<strong>{post_title}</strong>"에 대한 새 신고가 접수되었습니다.</p>'
|
||||
.'<p>신고 사유: <strong>{reason_type}</strong></p>'
|
||||
.$this->button('신고 관리 페이지로 이동', '{report_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>A new report has been received for the <strong>{target_type}</strong> "<strong>{post_title}</strong>" in <strong>{board_name}</strong>.</p>'
|
||||
.'<p>Reason: <strong>{reason_type}</strong></p>'
|
||||
.$this->button('Go to Report Management', '{report_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'role', 'value' => 'admin', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '신고가 접수되었습니다', 'en' => 'New report received'],
|
||||
'body' => ['ko' => '\'{board_name}\'의 {target_type} \'{post_title}\'에 대한 신고({reason_type})가 접수되었습니다.', 'en' => 'A report ({reason_type}) on {target_type} \'{post_title}\' in \'{board_name}\' has been received.'],
|
||||
'click_url' => '{report_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 신고 처리 결과 알림 정의.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function reportActionDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'report_action',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => 'sirsoft-board',
|
||||
'name' => ['ko' => '신고 처리 결과 알림', 'en' => 'Report Action Notification'],
|
||||
'description' => ['ko' => '신고 처리 완료 시 게시글 작성자에게 발송', 'en' => 'Sent to post author when a report action is taken'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.post.after_blind', 'sirsoft-board.post.after_delete', 'sirsoft-board.post.after_restore', 'sirsoft-board.comment.after_blind', 'sirsoft-board.comment.after_delete', 'sirsoft-board.comment.after_restore'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'action_type', 'description' => '처리 유형 (블라인드/삭제/복원)'],
|
||||
['key' => 'target_type', 'description' => '처리 대상 (게시글/댓글)'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author']],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] \'{post_title}\' {target_type}이(가) {action_type} 처리되었습니다',
|
||||
'en' => '[{board_name}] Your {target_type} "{post_title}" has been {action_type}',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판의 "<strong>{post_title}</strong>" {target_type}이(가) 신고 처리에 의해 <strong>{action_type}</strong> 처리되었습니다.</p>'
|
||||
.'<p>문의사항이 있으시면 관리자에게 연락해 주세요.</p>'
|
||||
.$this->button('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>Your {target_type} "<strong>{post_title}</strong>" in <strong>{board_name}</strong> has been <strong>{action_type}</strong> due to reports.</p>'
|
||||
.'<p>If you have any questions, please contact the administrator.</p>'
|
||||
.$this->button('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author']],
|
||||
'subject' => ['ko' => '신고 처리 결과 안내', 'en' => 'Report action result'],
|
||||
'body' => ['ko' => '\'{board_name}\'의 \'{post_title}\' {target_type}이(가) {action_type} 처리되었습니다.', 'en' => 'Your {target_type} \'{post_title}\' in \'{board_name}\' has been {action_type}.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 이메일 호환 CTA 버튼 HTML을 생성합니다.
|
||||
*
|
||||
* @param string $text 버튼 텍스트
|
||||
* @param string $url 버튼 링크 URL
|
||||
* @return string 인라인 스타일 버튼 HTML
|
||||
*/
|
||||
private function button(string $text, string $url): string
|
||||
{
|
||||
return '<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin: 24px 0;">'
|
||||
.'<tr><td align="center">'
|
||||
.'<a href="'.$url.'" style="display: inline-block; padding: 12px 32px; background-color: #2d3748; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: 600; font-size: 14px;">'
|
||||
.$text
|
||||
.'</a>'
|
||||
.'</td></tr></table>';
|
||||
}
|
||||
}
|
||||
@@ -2,49 +2,55 @@
|
||||
|
||||
namespace Modules\Sirsoft\Board\Database\Seeders;
|
||||
|
||||
use App\Concerns\Seeder\HasTranslatableSeeder;
|
||||
use App\Contracts\Seeder\TranslatableSeederInterface;
|
||||
use App\Extension\Helpers\GenericEntitySyncHelper;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\Sirsoft\Board\Models\BoardType;
|
||||
|
||||
/**
|
||||
* 게시판 유형 초기 시더
|
||||
*
|
||||
* 기본 3개 유형(basic, gallery, card)을 생성합니다.
|
||||
* module.php getSeeders()에서 직접 등록됩니다.
|
||||
* 게시판 유형 초기 시더.
|
||||
*
|
||||
* GenericEntitySyncHelper 기반 upsert + stale cleanup 패턴.
|
||||
* 활성 언어팩의 seed/board_types.json 다국어 키는 trait 가 자동 머지.
|
||||
*/
|
||||
class BoardTypeSeeder extends Seeder
|
||||
class BoardTypeSeeder extends Seeder implements TranslatableSeederInterface
|
||||
{
|
||||
/**
|
||||
* 초기 게시판 유형 데이터
|
||||
*/
|
||||
private const DEFAULT_BOARD_TYPES = [
|
||||
[
|
||||
'slug' => 'basic',
|
||||
'name' => ['ko' => '기본형', 'en' => 'Basic List'],
|
||||
],
|
||||
[
|
||||
'slug' => 'gallery',
|
||||
'name' => ['ko' => '갤러리형', 'en' => 'Gallery'],
|
||||
],
|
||||
[
|
||||
'slug' => 'card',
|
||||
'name' => ['ko' => '카드형', 'en' => 'Card'],
|
||||
],
|
||||
];
|
||||
use HasTranslatableSeeder;
|
||||
|
||||
public function getExtensionIdentifier(): string
|
||||
{
|
||||
return 'sirsoft-board';
|
||||
}
|
||||
|
||||
public function getTranslatableEntity(): string
|
||||
{
|
||||
return 'board_types';
|
||||
}
|
||||
|
||||
public function getMatchKey(): string
|
||||
{
|
||||
return 'slug';
|
||||
}
|
||||
|
||||
/**
|
||||
* 시더 실행
|
||||
*
|
||||
* @return void
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function getDefaults(): array
|
||||
{
|
||||
return [
|
||||
['slug' => 'basic', 'name' => ['ko' => '기본형', 'en' => 'Basic List']],
|
||||
['slug' => 'gallery', 'name' => ['ko' => '갤러리형', 'en' => 'Gallery']],
|
||||
['slug' => 'card', 'name' => ['ko' => '카드형', 'en' => 'Card']],
|
||||
];
|
||||
}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$helper = app(GenericEntitySyncHelper::class);
|
||||
$definedSlugs = [];
|
||||
|
||||
foreach (self::DEFAULT_BOARD_TYPES as $boardTypeData) {
|
||||
foreach ($this->resolveTranslatedDefaults() as $boardTypeData) {
|
||||
$existing = BoardType::where('slug', $boardTypeData['slug'])->exists();
|
||||
|
||||
$helper->sync(
|
||||
@@ -61,7 +67,6 @@ class BoardTypeSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
|
||||
// 완전 동기화: seeder 에서 제거된 유형 삭제 (user_overrides 무관)
|
||||
$deleted = $helper->cleanupStale(BoardType::class, [], 'slug', $definedSlugs);
|
||||
if ($deleted > 0) {
|
||||
$this->command->warn(" stale 게시판 유형 {$deleted}건 삭제");
|
||||
|
||||
@@ -12,9 +12,11 @@ use Illuminate\Database\Seeder;
|
||||
* 설치 필수 시더는 항상 실행되며, 샘플 시더는 --sample 옵션 시에만 실행됩니다.
|
||||
*
|
||||
* 설치 시더:
|
||||
* - InstallSeeder (BoardNotificationDefinitionSeeder 포함)
|
||||
* - BoardTypeSeeder
|
||||
*
|
||||
* 알림 정의는 module.php::getNotificationDefinitions() 가 SSoT 로,
|
||||
* ModuleManager 가 activate/update 시 자동 동기화합니다 (시더 호출 불필요).
|
||||
*
|
||||
* 샘플 시더 (--sample 옵션 시):
|
||||
* 1. BoardSampleSeeder - 게시판 8개 (테이블 + 권한 자동 생성)
|
||||
* 2. PostSampleSeeder - 게시글/댓글 샘플 (총 160건)
|
||||
@@ -42,11 +44,9 @@ class DatabaseSeeder extends Seeder
|
||||
$this->command->info('');
|
||||
|
||||
// 설치 필수 시더 (항상 실행)
|
||||
$this->command->info('[설치] 게시판 타입 및 메일 템플릿 생성');
|
||||
$this->command->info('[설치] 게시판 타입 생성');
|
||||
$this->call([
|
||||
InstallSeeder::class,
|
||||
BoardTypeSeeder::class,
|
||||
BoardNotificationDefinitionSeeder::class,
|
||||
]);
|
||||
$this->command->info('');
|
||||
|
||||
@@ -66,12 +66,22 @@ class DatabaseSeeder extends Seeder
|
||||
$this->command->info('');
|
||||
|
||||
// 3. 신고 샘플 생성 (count 불필요)
|
||||
$this->command->info('[3/5] 신고 샘플 생성');
|
||||
$this->command->info('[3/6] 신고 샘플 생성');
|
||||
$this->call(Sample\ReportSampleSeeder::class);
|
||||
$this->command->info('');
|
||||
|
||||
// 4. 활동 로그 샘플 (모든 샘플 데이터 생성 후 마지막에 실행)
|
||||
$this->command->info('[4/4] 활동 로그 샘플 생성');
|
||||
// 4. 알림 발송 이력 샘플 (count-aware)
|
||||
$this->command->info('[4/6] 알림 발송 이력 샘플 생성');
|
||||
$this->callWithCounts(Sample\NotificationLogSeeder::class);
|
||||
$this->command->info('');
|
||||
|
||||
// 5. 본인인증 이력 샘플 (count-aware)
|
||||
$this->command->info('[5/6] 본인인증 이력 샘플 생성');
|
||||
$this->callWithCounts(Sample\IdentityVerificationLogSeeder::class);
|
||||
$this->command->info('');
|
||||
|
||||
// 6. 활동 로그 샘플 (모든 샘플 데이터 생성 후 마지막에 실행)
|
||||
$this->command->info('[6/6] 활동 로그 샘플 생성');
|
||||
$this->call(ActivityLogSampleSeeder::class);
|
||||
$this->command->info('');
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Board\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* 게시판 모듈 설치 시더
|
||||
*
|
||||
* 모듈 설치 시 실행되는 시더입니다.
|
||||
* 기본 알림 정의 7종을 생성합니다.
|
||||
*
|
||||
* 테스트 데이터가 필요한 경우 DatabaseSeeder를 수동으로 실행하세요:
|
||||
* php artisan module:seed sirsoft-board
|
||||
*/
|
||||
class InstallSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* 시더 실행
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call(BoardNotificationDefinitionSeeder::class);
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Board\Database\Seeders\Sample;
|
||||
|
||||
use App\Database\Sample\AbstractIdentityVerificationLogSampleSeeder;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
* 게시판 모듈 본인인증 이력 샘플 시더.
|
||||
*
|
||||
* source_identifier='sirsoft-board' 인 IdentityPolicy(post.blind/delete, report.bulk_action/delete)만
|
||||
* 사용하여 게시판 운영 영역 본인인증 이력을 채운다.
|
||||
*
|
||||
* 수동 실행:
|
||||
* php artisan module:seed sirsoft-board \
|
||||
* --class="Sample\\IdentityVerificationLogSeeder" --sample
|
||||
*/
|
||||
class IdentityVerificationLogSeeder extends AbstractIdentityVerificationLogSampleSeeder
|
||||
{
|
||||
/**
|
||||
* 게시판 모듈 정책만 필터링.
|
||||
*
|
||||
* @param Builder $query IdentityPolicy 쿼리
|
||||
* @return Builder 게시판 영역 쿼리
|
||||
*/
|
||||
protected function applyPolicyScope(Builder $query): Builder
|
||||
{
|
||||
return $query->where('source_identifier', 'sirsoft-board');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string 카운트 옵션 키
|
||||
*/
|
||||
protected function countKey(): string
|
||||
{
|
||||
return 'board_identity_verification_logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int 기본 건수
|
||||
*/
|
||||
protected function defaultCount(): int
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string 영역 라벨
|
||||
*/
|
||||
protected function scopeLabel(): string
|
||||
{
|
||||
return '[게시판]';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Sirsoft\Board\Database\Seeders\Sample;
|
||||
|
||||
use App\Database\Sample\AbstractNotificationLogSampleSeeder;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* 게시판 모듈 알림 발송 이력 샘플 시더.
|
||||
*
|
||||
* extension_identifier='sirsoft-board' 인 알림 정의(댓글/답글/신고 7종)만 사용하여
|
||||
* 게시판 영역 발송 이력을 채운다.
|
||||
*
|
||||
* 수동 실행:
|
||||
* php artisan module:seed sirsoft-board \
|
||||
* --class="Sample\\NotificationLogSeeder" --sample
|
||||
*/
|
||||
class NotificationLogSeeder extends AbstractNotificationLogSampleSeeder
|
||||
{
|
||||
/**
|
||||
* 게시판 모듈 정의만 필터링.
|
||||
*
|
||||
* @param Builder $query NotificationDefinition 쿼리
|
||||
* @return Builder 게시판 영역 쿼리
|
||||
*/
|
||||
protected function applyDefinitionScope(Builder $query): Builder
|
||||
{
|
||||
return $query->where('extension_identifier', 'sirsoft-board');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string 카운트 옵션 키
|
||||
*/
|
||||
protected function countKey(): string
|
||||
{
|
||||
return 'board_notification_logs';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int 기본 건수
|
||||
*/
|
||||
protected function defaultCount(): int
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string 영역 라벨
|
||||
*/
|
||||
protected function scopeLabel(): string
|
||||
{
|
||||
return '[게시판]';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function subjectMap(): array
|
||||
{
|
||||
return [
|
||||
'new_comment' => '[G7] 새 댓글이 등록되었습니다',
|
||||
'reply_comment' => '[G7] 작성하신 댓글에 답글이 달렸습니다',
|
||||
'post_reply' => '[G7] 답변글이 등록되었습니다',
|
||||
'post_action' => '[G7] 게시물 처리 결과 안내',
|
||||
'new_post_admin' => '[G7관리자] 새 게시글이 등록되었습니다',
|
||||
'report_received_admin' => '[G7관리자] 게시물 신고가 접수되었습니다',
|
||||
'report_action' => '[G7] 신고 처리 결과 안내',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, callable(User, Carbon): string>
|
||||
*/
|
||||
protected function bodyMap(): array
|
||||
{
|
||||
return [
|
||||
'new_comment' => fn (User $u, Carbon $t) => "안녕하세요 {$u->name}님,\n\n작성하신 게시글에 새 댓글이 등록되었습니다.\n게시글에서 확인해 주세요.",
|
||||
'reply_comment' => fn (User $u, Carbon $t) => "안녕하세요 {$u->name}님,\n\n남기신 댓글에 누군가 답글을 작성했습니다.",
|
||||
'post_reply' => fn (User $u, Carbon $t) => "안녕하세요 {$u->name}님,\n\n작성하신 게시글에 답변글이 등록되었습니다.",
|
||||
'post_action' => fn (User $u, Carbon $t) => "안녕하세요 {$u->name}님,\n\n게시물에 대한 관리자 조치가 적용되었습니다.\n자세한 내용은 알림 메시지에서 확인해 주세요.",
|
||||
'new_post_admin' => fn (User $u, Carbon $t) => "관리자님,\n\n새 게시글이 등록되었습니다.\n검토가 필요한 경우 관리자 페이지에서 확인해 주세요.",
|
||||
'report_received_admin' => fn (User $u, Carbon $t) => "관리자님,\n\n게시물 신고가 접수되었습니다.\n신속한 처리를 부탁드립니다.",
|
||||
'report_action' => fn (User $u, Carbon $t) => "안녕하세요 {$u->name}님,\n\n접수하신 신고 건에 대한 처리 결과를 안내드립니다.\n자세한 내용은 알림 메시지에서 확인하실 수 있습니다.",
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,13 @@
|
||||
"ko": "게시판",
|
||||
"en": "Board"
|
||||
},
|
||||
"version": "1.0.0-beta.3",
|
||||
"version": "1.0.0-beta.4",
|
||||
"license": "MIT",
|
||||
"description": {
|
||||
"ko": "게시판 관리를 위한 모듈",
|
||||
"en": "Module for board management"
|
||||
},
|
||||
"g7_version": ">=7.0.0-beta.2",
|
||||
"g7_version": ">=7.0.0-beta.4",
|
||||
"dependencies": {
|
||||
"modules": {},
|
||||
"plugins": {}
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace Modules\Sirsoft\Board;
|
||||
|
||||
use App\Extension\AbstractModule;
|
||||
use App\Models\Role;
|
||||
use App\Seo\Concerns\LocalizesSeoValues;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Modules\Sirsoft\Board\Database\Seeders\BoardTypeSeeder;
|
||||
use Modules\Sirsoft\Board\Database\Seeders\InstallSeeder;
|
||||
use Modules\Sirsoft\Board\Listeners\ActivityLogDescriptionResolver;
|
||||
use Modules\Sirsoft\Board\Listeners\BoardActivityLogListener;
|
||||
use Modules\Sirsoft\Board\Listeners\BoardNotificationChannelListener;
|
||||
@@ -25,6 +25,8 @@ use Modules\Sirsoft\Board\Listeners\UserNotificationSettingsListener;
|
||||
|
||||
class Module extends AbstractModule
|
||||
{
|
||||
use LocalizesSeoValues;
|
||||
|
||||
/**
|
||||
* 모듈 제거 시 동적으로 생성된 게시판별 역할을 정리합니다.
|
||||
*
|
||||
@@ -179,6 +181,46 @@ class Module extends AbstractModule
|
||||
],
|
||||
],
|
||||
],
|
||||
// 본인인증 정책 관리 권한 (type: admin)
|
||||
[
|
||||
'identifier' => 'identity.policies',
|
||||
'name' => [
|
||||
'ko' => '게시판 본인인증 정책',
|
||||
'en' => 'Board Identity Policies',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => '게시판 컨텍스트의 본인인증 정책 관리 권한',
|
||||
'en' => 'Manage identity verification policies in board context',
|
||||
],
|
||||
'permissions' => [
|
||||
[
|
||||
'action' => 'read',
|
||||
'name' => [
|
||||
'ko' => '본인인증 정책 조회',
|
||||
'en' => 'View Identity Policies',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => '게시판 본인인증 정책 조회',
|
||||
'en' => 'View board identity policies',
|
||||
],
|
||||
'type' => 'admin',
|
||||
'roles' => ['admin'],
|
||||
],
|
||||
[
|
||||
'action' => 'update',
|
||||
'name' => [
|
||||
'ko' => '본인인증 정책 수정',
|
||||
'en' => 'Update Identity Policies',
|
||||
],
|
||||
'description' => [
|
||||
'ko' => '게시판 본인인증 정책 수정/추가/삭제',
|
||||
'en' => 'Update, add, delete board identity policies',
|
||||
],
|
||||
'type' => 'admin',
|
||||
'roles' => ['admin'],
|
||||
],
|
||||
],
|
||||
],
|
||||
// 신고 관리 권한 (type: admin)
|
||||
[
|
||||
'identifier' => 'reports',
|
||||
@@ -325,7 +367,6 @@ class Module extends AbstractModule
|
||||
{
|
||||
return [
|
||||
BoardTypeSeeder::class,
|
||||
InstallSeeder::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -397,6 +438,130 @@ class Module extends AbstractModule
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 페이지 타입별 OG 메타태그 기본값 선언
|
||||
*
|
||||
* 게시판 도메인에서 og:type=article, og:image, og:article:* 부속 태그를 직접 제공.
|
||||
*
|
||||
* @param string $pageType 페이지 타입
|
||||
* @param array $context 데이터 컨텍스트
|
||||
* @param array $routeParams 라우트 파라미터
|
||||
* @return array OG 데이터
|
||||
*/
|
||||
public function seoOgDefaults(string $pageType, array $context, array $routeParams = []): array
|
||||
{
|
||||
if ($pageType === 'post') {
|
||||
$post = data_get($context, 'post.data', []);
|
||||
// 다국어 JSON array (MariaDB 환경) 자동 변환
|
||||
$title = $this->resolveLocalizedValue($post['subject'] ?? $post['title'] ?? '');
|
||||
|
||||
$extra = [];
|
||||
$publishedAt = (string) ($post['created_at'] ?? '');
|
||||
if ($publishedAt !== '') {
|
||||
$extra[] = ['property' => 'article:published_time', 'content' => $publishedAt];
|
||||
}
|
||||
$modifiedAt = (string) ($post['updated_at'] ?? '');
|
||||
if ($modifiedAt !== '') {
|
||||
$extra[] = ['property' => 'article:modified_time', 'content' => $modifiedAt];
|
||||
}
|
||||
$authorName = (string) (data_get($post, 'author.name') ?? data_get($post, 'user.name') ?? '');
|
||||
if ($authorName !== '') {
|
||||
$extra[] = ['property' => 'article:author', 'content' => $authorName];
|
||||
}
|
||||
$boardName = (string) (data_get($context, 'board.data.name') ?? '');
|
||||
if ($boardName !== '') {
|
||||
$extra[] = ['property' => 'article:section', 'content' => $boardName];
|
||||
}
|
||||
|
||||
// PostResource toArray() 의 'thumbnail' 키 사용 (PostResource.php:183).
|
||||
// 상대 경로(/api/...) 는 url() 로 절대 URL 변환 — Facebook/Threads/Slack 모두 절대 URL 필수.
|
||||
$thumbnailRaw = (string) (data_get($post, 'thumbnail') ?? '');
|
||||
$image = $thumbnailRaw !== ''
|
||||
? (str_starts_with($thumbnailRaw, 'http') ? $thumbnailRaw : url($thumbnailRaw))
|
||||
: '';
|
||||
|
||||
return array_filter([
|
||||
'type' => 'article',
|
||||
'image' => $image,
|
||||
'image_alt' => $title,
|
||||
'extra' => $extra,
|
||||
], fn ($v) => $v !== null && $v !== '' && $v !== []);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 페이지 타입별 JSON-LD 구조화 데이터 선언
|
||||
*
|
||||
* 게시판 도메인 스키마(Article)를 모듈이 직접 owned.
|
||||
*
|
||||
* @param string $pageType 페이지 타입
|
||||
* @param array $context 데이터 컨텍스트
|
||||
* @param array $routeParams 라우트 파라미터
|
||||
* @return array Schema.org Article 형식
|
||||
*/
|
||||
public function seoStructuredData(string $pageType, array $context, array $routeParams = []): array
|
||||
{
|
||||
if ($pageType !== 'post') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$post = data_get($context, 'post.data', []);
|
||||
if (empty($post)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 다국어 JSON array 안전 변환
|
||||
$headline = $this->resolveLocalizedValue($post['subject'] ?? $post['title'] ?? '');
|
||||
if ($headline === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$schema = [
|
||||
'@type' => 'Article',
|
||||
'headline' => $headline,
|
||||
];
|
||||
|
||||
$description = $this->resolveLocalizedValue($post['summary'] ?? $post['excerpt'] ?? $post['content_text'] ?? '');
|
||||
if ($description !== '') {
|
||||
$schema['description'] = mb_substr(strip_tags($description), 0, 200);
|
||||
}
|
||||
|
||||
// 썸네일 URL — thumbnail 키 우선 + 절대 URL 변환
|
||||
$thumbnailRaw = (string) (data_get($post, 'thumbnail') ?? '');
|
||||
if ($thumbnailRaw !== '') {
|
||||
$schema['image'] = str_starts_with($thumbnailRaw, 'http') ? $thumbnailRaw : url($thumbnailRaw);
|
||||
}
|
||||
|
||||
$publishedAt = (string) ($post['created_at'] ?? '');
|
||||
if ($publishedAt !== '') {
|
||||
$schema['datePublished'] = $publishedAt;
|
||||
}
|
||||
$modifiedAt = (string) ($post['updated_at'] ?? '');
|
||||
if ($modifiedAt !== '') {
|
||||
$schema['dateModified'] = $modifiedAt;
|
||||
}
|
||||
|
||||
$authorName = (string) (data_get($post, 'author.name') ?? data_get($post, 'user.name') ?? '');
|
||||
if ($authorName !== '') {
|
||||
$schema['author'] = [
|
||||
'@type' => 'Person',
|
||||
'name' => $authorName,
|
||||
];
|
||||
}
|
||||
|
||||
$publisherName = (string) g7_core_settings('general.site_name', '');
|
||||
if ($publisherName !== '') {
|
||||
$schema['publisher'] = [
|
||||
'@type' => 'Organization',
|
||||
'name' => $publisherName,
|
||||
];
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* 스토리지 디스크 설정 반환
|
||||
*/
|
||||
@@ -458,4 +623,549 @@ class Module extends AbstractModule
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 모듈이 선언하는 IDV 정책 목록.
|
||||
*
|
||||
* 코어 IDV 인프라가 install/update 시 IdentityPolicySyncHelper 를 통해 자동 동기화한다.
|
||||
* 운영자가 S1d / 게시판 환경설정 > 본인인증 탭 에서 enabled / grace_minutes / provider_id /
|
||||
* fail_mode 4 필드를 수정하면 user_overrides 에 기록되어 모듈 재설치 시에도 보존된다.
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function getIdentityPolicies(): array
|
||||
{
|
||||
return [
|
||||
// 게시글 개별 삭제 (관리자 민감 작업)
|
||||
[
|
||||
'key' => 'sirsoft-board.post.delete',
|
||||
'scope' => 'hook',
|
||||
'target' => 'sirsoft-board.post.before_delete',
|
||||
'purpose' => 'sensitive_action',
|
||||
'grace_minutes' => 5,
|
||||
'enabled' => false,
|
||||
'applies_to' => 'admin',
|
||||
'fail_mode' => 'block',
|
||||
],
|
||||
// 게시글 블라인드 (관리자 민감 작업)
|
||||
[
|
||||
'key' => 'sirsoft-board.post.blind',
|
||||
'scope' => 'hook',
|
||||
'target' => 'sirsoft-board.post.before_blind',
|
||||
'purpose' => 'sensitive_action',
|
||||
'grace_minutes' => 5,
|
||||
'enabled' => false,
|
||||
'applies_to' => 'admin',
|
||||
'fail_mode' => 'block',
|
||||
],
|
||||
// 신고 일괄 처리 (관리자 민감 작업)
|
||||
[
|
||||
'key' => 'sirsoft-board.report.bulk_action',
|
||||
'scope' => 'hook',
|
||||
'target' => 'sirsoft-board.report.before_bulk_update_status',
|
||||
'purpose' => 'sensitive_action',
|
||||
'grace_minutes' => 5,
|
||||
'enabled' => false,
|
||||
'applies_to' => 'admin',
|
||||
'fail_mode' => 'block',
|
||||
],
|
||||
// 신고 삭제 (관리자 민감 작업)
|
||||
[
|
||||
'key' => 'sirsoft-board.report.delete',
|
||||
'scope' => 'hook',
|
||||
'target' => 'sirsoft-board.report.before_delete',
|
||||
'purpose' => 'sensitive_action',
|
||||
'grace_minutes' => 0,
|
||||
'enabled' => false,
|
||||
'applies_to' => 'admin',
|
||||
'fail_mode' => 'block',
|
||||
],
|
||||
// 자기 글 삭제 (사용자 본인 작업) — 계정 탈취 시 게시물 일괄 삭제 차단.
|
||||
// post.delete 정책과 같은 훅(before_delete)을 공유하지만 applies_to=self 로 분기됨.
|
||||
[
|
||||
'key' => 'sirsoft-board.post.user_delete',
|
||||
'scope' => 'hook',
|
||||
'target' => 'sirsoft-board.post.before_delete',
|
||||
'purpose' => 'sensitive_action',
|
||||
'grace_minutes' => 0,
|
||||
'enabled' => false,
|
||||
'applies_to' => 'self',
|
||||
'fail_mode' => 'block',
|
||||
],
|
||||
// 자기 댓글 삭제 (사용자 본인 작업) — 빈도 높아 grace 길게
|
||||
[
|
||||
'key' => 'sirsoft-board.comment.user_delete',
|
||||
'scope' => 'hook',
|
||||
'target' => 'sirsoft-board.comment.before_delete',
|
||||
'purpose' => 'sensitive_action',
|
||||
'grace_minutes' => 30,
|
||||
'enabled' => false,
|
||||
'applies_to' => 'self',
|
||||
'fail_mode' => 'block',
|
||||
],
|
||||
// 신고 작성 (사용자 본인 작업) — 악성/장난 신고 방지
|
||||
[
|
||||
'key' => 'sirsoft-board.report.create',
|
||||
'scope' => 'hook',
|
||||
'target' => 'sirsoft-board.report.before_create',
|
||||
'purpose' => 'sensitive_action',
|
||||
'grace_minutes' => 30,
|
||||
'enabled' => false,
|
||||
'applies_to' => 'self',
|
||||
'fail_mode' => 'block',
|
||||
],
|
||||
// 첫 글 작성 (사용자 본인 작업) — 스팸봇 방지
|
||||
[
|
||||
'key' => 'sirsoft-board.post.user_create',
|
||||
'scope' => 'hook',
|
||||
'target' => 'sirsoft-board.post.before_create',
|
||||
'purpose' => 'sensitive_action',
|
||||
'grace_minutes' => 0,
|
||||
'enabled' => false,
|
||||
'applies_to' => 'self',
|
||||
'fail_mode' => 'block',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 모듈이 등록할 IDV purpose 목록.
|
||||
*
|
||||
* 게시판은 코어 sensitive_action 으로 충분하므로 신규 purpose 를 도입하지 않는다.
|
||||
*
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
public function getIdentityPurposes(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 모듈이 등록할 IDV 메시지 정의.
|
||||
*
|
||||
* 현재 4개 정책 모두 purpose=sensitive_action 을 사용하므로 코어 fallback
|
||||
* (`provider=g7:core.mail`, `scope_type=purpose`, `scope_value=sensitive_action`)
|
||||
* 메시지로 충분하다. 게시판 도메인에 특화된 문구가 필요해지거나 사용자 측 정책
|
||||
* (예: 자기 글 삭제, 신고 작성)이 추가되면 여기에 등록한다.
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function getIdentityMessages(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시판 모듈이 등록할 알림 정의.
|
||||
*
|
||||
* AbstractModule 계약에 따라 ModuleManager 가 activate/update 시 자동으로
|
||||
* NotificationSyncHelper 를 통해 동기화하며, uninstall(deleteData=true) 시 정리합니다.
|
||||
* 운영자가 관리자 UI 에서 수정한 필드는 user_overrides JSON 에 보존됩니다.
|
||||
*
|
||||
* `extension_type`/`extension_identifier` 는 Manager 가 자동 주입.
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public function getNotificationDefinitions(): array
|
||||
{
|
||||
return [
|
||||
$this->newCommentDefinition(),
|
||||
$this->replyCommentDefinition(),
|
||||
$this->postReplyDefinition(),
|
||||
$this->postActionDefinition(),
|
||||
$this->newPostAdminDefinition(),
|
||||
$this->reportReceivedAdminDefinition(),
|
||||
$this->reportActionDefinition(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 새 댓글 알림 정의.
|
||||
*/
|
||||
private function newCommentDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'new_comment',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'name' => ['ko' => '새 댓글 알림', 'en' => 'New Comment Notification'],
|
||||
'description' => ['ko' => '게시글에 새 댓글이 작성되면 게시글 작성자에게 발송', 'en' => 'Sent to post author when a new comment is posted'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.comment.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'comment_author', 'description' => '댓글 작성자'],
|
||||
['key' => 'comment_content', 'description' => '댓글 내용 (200자)'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] 게시글에 새 댓글이 등록되었습니다',
|
||||
'en' => '[{board_name}] New comment on your post',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판의 게시글에 <strong>{comment_author}</strong>님이 댓글을 남겼습니다.</p>'
|
||||
.'<blockquote style="border-left: 3px solid #cbd5e0; padding-left: 12px; color: #718096;">{comment_content}</blockquote>'
|
||||
.$this->notificationButton('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p><strong>{comment_author}</strong> commented on your post in <strong>{board_name}</strong>.</p>'
|
||||
.'<blockquote style="border-left: 3px solid #cbd5e0; padding-left: 12px; color: #718096;">{comment_content}</blockquote>'
|
||||
.$this->notificationButton('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '게시글에 새 댓글이 달렸습니다', 'en' => 'New comment on your post'],
|
||||
'body' => ['ko' => '{comment_author}님이 \'{board_name}\' 게시글 \'{post_title}\'에 댓글을 남겼습니다.', 'en' => '{comment_author} commented on your post \'{post_title}\' in \'{board_name}\'.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 대댓글 알림 정의.
|
||||
*/
|
||||
private function replyCommentDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'reply_comment',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'name' => ['ko' => '대댓글 알림', 'en' => 'Reply Comment Notification'],
|
||||
'description' => ['ko' => '댓글에 대댓글이 작성되면 댓글 작성자에게 발송', 'en' => 'Sent to comment author when a reply is posted'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.comment.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'comment_author', 'description' => '답글 작성자'],
|
||||
['key' => 'comment_content', 'description' => '답글 내용 (200자)'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'parent_comment_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] 댓글에 답글이 등록되었습니다',
|
||||
'en' => '[{board_name}] Reply to your comment',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판에서 <strong>{comment_author}</strong>님이 댓글에 답글을 남겼습니다.</p>'
|
||||
.'<blockquote style="border-left: 3px solid #cbd5e0; padding-left: 12px; color: #718096;">{comment_content}</blockquote>'
|
||||
.$this->notificationButton('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p><strong>{comment_author}</strong> replied to your comment in <strong>{board_name}</strong>.</p>'
|
||||
.'<blockquote style="border-left: 3px solid #cbd5e0; padding-left: 12px; color: #718096;">{comment_content}</blockquote>'
|
||||
.$this->notificationButton('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'parent_comment_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '댓글에 답글이 달렸습니다', 'en' => 'New reply to your comment'],
|
||||
'body' => ['ko' => '{comment_author}님이 \'{board_name}\'의 댓글에 답글을 남겼습니다.', 'en' => '{comment_author} replied to your comment in \'{board_name}\'.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 답변글 알림 정의.
|
||||
*/
|
||||
private function postReplyDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'post_reply',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'name' => ['ko' => '답변글 알림', 'en' => 'Post Reply Notification'],
|
||||
'description' => ['ko' => '게시글에 답변글이 작성되면 원글 작성자에게 발송', 'en' => 'Sent to original post author when a reply post is created'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.post.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'original_post_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] 게시글에 답변글이 등록되었습니다',
|
||||
'en' => '[{board_name}] Reply to your post',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판의 게시글 "<strong>{post_title}</strong>"에 답변글이 등록되었습니다.</p>'
|
||||
.$this->notificationButton('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>A reply has been posted to your post "<strong>{post_title}</strong>" in <strong>{board_name}</strong>.</p>'
|
||||
.$this->notificationButton('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'original_post_author', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '게시글에 답변이 등록되었습니다', 'en' => 'A reply has been posted to your post'],
|
||||
'body' => ['ko' => '\'{board_name}\'의 게시글 \'{post_title}\'에 답변이 등록되었습니다.', 'en' => 'A reply has been posted to your post \'{post_title}\' in \'{board_name}\'.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시글 처리 알림 정의.
|
||||
*/
|
||||
private function postActionDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'post_action',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'name' => ['ko' => '게시글/댓글 처리 알림', 'en' => 'Content Action Notification'],
|
||||
'description' => ['ko' => '게시글/댓글 블라인드/삭제/복원 시 작성자에게 발송', 'en' => 'Sent to author on blind/delete/restore actions'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.post.after_blind', 'sirsoft-board.post.after_delete', 'sirsoft-board.post.after_restore', 'sirsoft-board.comment.after_blind', 'sirsoft-board.comment.after_delete', 'sirsoft-board.comment.after_restore'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'action_type', 'description' => '처리 유형 (블라인드/삭제/복원)'],
|
||||
['key' => 'target_type', 'description' => '처리 대상 (게시글/댓글)'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author']],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] \'{post_title}\' {target_type}이(가) {action_type} 처리되었습니다',
|
||||
'en' => '[{board_name}] Your {target_type} "{post_title}" has been {action_type}',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판의 "<strong>{post_title}</strong>" {target_type}이(가) 관리자에 의해 <strong>{action_type}</strong> 처리되었습니다.</p>'
|
||||
.'<p>문의사항이 있으시면 관리자에게 연락해 주세요.</p>'
|
||||
.$this->notificationButton('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>Your {target_type} "<strong>{post_title}</strong>" in <strong>{board_name}</strong> has been <strong>{action_type}</strong> by an administrator.</p>'
|
||||
.'<p>If you have any questions, please contact the administrator.</p>'
|
||||
.$this->notificationButton('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author']],
|
||||
'subject' => ['ko' => '{target_type}이(가) 처리되었습니다', 'en' => 'Your {target_type} has been actioned'],
|
||||
'body' => ['ko' => '\'{board_name}\'의 \'{post_title}\' {target_type}이(가) {action_type} 처리되었습니다.', 'en' => 'Your {target_type} \'{post_title}\' in \'{board_name}\' has been {action_type}.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 새 게시글 알림 정의.
|
||||
*/
|
||||
private function newPostAdminDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'new_post_admin',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'name' => ['ko' => '새 게시글 관리자 알림', 'en' => 'New Post Admin Notification'],
|
||||
'description' => ['ko' => '새 게시글 작성 시 관리자에게 발송', 'en' => 'Sent to admin when a new post is created'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.post.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름 (관리자)'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'post_author', 'description' => '게시글 작성자'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'board_managers', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] 새 게시글이 등록되었습니다',
|
||||
'en' => '[{board_name}] New post has been created',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판에 <strong>{post_author}</strong>님이 새 게시글을 등록했습니다.</p>'
|
||||
.'<p>게시글 제목: <strong>{post_title}</strong></p>'
|
||||
.$this->notificationButton('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p><strong>{post_author}</strong> created a new post in <strong>{board_name}</strong>.</p>'
|
||||
.'<p>Title: <strong>{post_title}</strong></p>'
|
||||
.$this->notificationButton('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'board_managers', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '새 게시글이 등록되었습니다', 'en' => 'New post registered'],
|
||||
'body' => ['ko' => '{post_author}님이 \'{board_name}\'에 새 게시글 \'{post_title}\'을 등록했습니다.', 'en' => '{post_author} posted \'{post_title}\' in \'{board_name}\'.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 신고 접수 관리자 알림 정의.
|
||||
*/
|
||||
private function reportReceivedAdminDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'report_received_admin',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'name' => ['ko' => '신고 접수 관리자 알림', 'en' => 'Report Received Admin Notification'],
|
||||
'description' => ['ko' => '신고 접수 시 관리자에게 발송', 'en' => 'Sent to admin when a report is received'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.report.after_create'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '신고 대상 게시글 제목'],
|
||||
['key' => 'target_type', 'description' => '신고 대상 유형 (게시글/댓글)'],
|
||||
['key' => 'reason_type', 'description' => '신고 사유'],
|
||||
['key' => 'report_url', 'description' => '신고 관리 페이지 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'permission', 'value' => 'sirsoft-board.reports.manage', 'exclude_trigger_user' => true]],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] "{post_title}"에 대한 신고가 접수되었습니다',
|
||||
'en' => '[{board_name}] A new report has been received for "{post_title}"',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판에서 <strong>{target_type}</strong> "<strong>{post_title}</strong>"에 대한 새 신고가 접수되었습니다.</p>'
|
||||
.'<p>신고 사유: <strong>{reason_type}</strong></p>'
|
||||
.$this->notificationButton('신고 관리 페이지로 이동', '{report_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>A new report has been received for the <strong>{target_type}</strong> "<strong>{post_title}</strong>" in <strong>{board_name}</strong>.</p>'
|
||||
.'<p>Reason: <strong>{reason_type}</strong></p>'
|
||||
.$this->notificationButton('Go to Report Management', '{report_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'permission', 'value' => 'sirsoft-board.reports.manage', 'exclude_trigger_user' => true]],
|
||||
'subject' => ['ko' => '신고가 접수되었습니다', 'en' => 'New report received'],
|
||||
'body' => ['ko' => '\'{board_name}\'의 {target_type} \'{post_title}\'에 대한 신고({reason_type})가 접수되었습니다.', 'en' => 'A report ({reason_type}) on {target_type} \'{post_title}\' in \'{board_name}\' has been received.'],
|
||||
'click_url' => '{report_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 신고 처리 결과 알림 정의.
|
||||
*/
|
||||
private function reportActionDefinition(): array
|
||||
{
|
||||
return [
|
||||
'type' => 'report_action',
|
||||
'hook_prefix' => 'sirsoft-board',
|
||||
'name' => ['ko' => '신고 처리 결과 알림', 'en' => 'Report Action Notification'],
|
||||
'description' => ['ko' => '신고 처리 완료 시 게시글 작성자에게 발송', 'en' => 'Sent to post author when a report action is taken'],
|
||||
'channels' => ['mail', 'database'],
|
||||
'hooks' => ['sirsoft-board.post.after_blind', 'sirsoft-board.post.after_delete', 'sirsoft-board.post.after_restore', 'sirsoft-board.comment.after_blind', 'sirsoft-board.comment.after_delete', 'sirsoft-board.comment.after_restore'],
|
||||
'variables' => [
|
||||
['key' => 'name', 'description' => '수신자 이름'],
|
||||
['key' => 'app_name', 'description' => '사이트명'],
|
||||
['key' => 'board_name', 'description' => '게시판 이름'],
|
||||
['key' => 'post_title', 'description' => '게시글 제목'],
|
||||
['key' => 'action_type', 'description' => '처리 유형 (블라인드/삭제/복원)'],
|
||||
['key' => 'target_type', 'description' => '처리 대상 (게시글/댓글)'],
|
||||
['key' => 'post_url', 'description' => '게시글 URL'],
|
||||
['key' => 'site_url', 'description' => '사이트 URL'],
|
||||
],
|
||||
'templates' => [
|
||||
[
|
||||
'channel' => 'mail',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author']],
|
||||
'subject' => [
|
||||
'ko' => '[{board_name}] \'{post_title}\' {target_type}이(가) {action_type} 처리되었습니다',
|
||||
'en' => '[{board_name}] Your {target_type} "{post_title}" has been {action_type}',
|
||||
],
|
||||
'body' => [
|
||||
'ko' => '<h1>{name}님, 안녕하세요.</h1>'
|
||||
.'<p><strong>{board_name}</strong> 게시판의 "<strong>{post_title}</strong>" {target_type}이(가) 신고 처리에 의해 <strong>{action_type}</strong> 처리되었습니다.</p>'
|
||||
.'<p>문의사항이 있으시면 관리자에게 연락해 주세요.</p>'
|
||||
.$this->notificationButton('게시글 보기', '{post_url}')
|
||||
.'<p>감사합니다,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
'en' => '<h1>Hello, {name}.</h1>'
|
||||
.'<p>Your {target_type} "<strong>{post_title}</strong>" in <strong>{board_name}</strong> has been <strong>{action_type}</strong> due to reports.</p>'
|
||||
.'<p>If you have any questions, please contact the administrator.</p>'
|
||||
.$this->notificationButton('View Post', '{post_url}')
|
||||
.'<p>Thank you,<br><a href="{site_url}">{app_name}</a></p>',
|
||||
],
|
||||
],
|
||||
[
|
||||
'channel' => 'database',
|
||||
'recipients' => [['type' => 'related_user', 'relation' => 'post_author']],
|
||||
'subject' => ['ko' => '신고 처리 결과 안내', 'en' => 'Report action result'],
|
||||
'body' => ['ko' => '\'{board_name}\'의 \'{post_title}\' {target_type}이(가) {action_type} 처리되었습니다.', 'en' => 'Your {target_type} \'{post_title}\' in \'{board_name}\' has been {action_type}.'],
|
||||
'click_url' => '{post_url}',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 이메일 호환 CTA 버튼 HTML 을 생성합니다.
|
||||
*
|
||||
* @param string $text 버튼 텍스트
|
||||
* @param string $url 버튼 링크 URL
|
||||
* @return string 인라인 스타일 버튼 HTML
|
||||
*/
|
||||
private function notificationButton(string $text, string $url): string
|
||||
{
|
||||
return '<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin: 24px 0;">'
|
||||
.'<tr><td align="center">'
|
||||
.'<a href="'.$url.'" style="display: inline-block; padding: 12px 32px; background-color: #2d3748; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: 600; font-size: 14px;">'
|
||||
.$text
|
||||
.'</a>'
|
||||
.'</td></tr></table>';
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@g7/sirsoft-board",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.0-beta.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@g7/sirsoft-board",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.0-beta.4",
|
||||
"devDependencies": {
|
||||
"jsdom": "^27.4.0",
|
||||
"typescript": "^5.3.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@g7/sirsoft-board",
|
||||
"version": "1.0.0-beta.3",
|
||||
"version": "1.0.0-beta.4",
|
||||
"description": "그누보드7 게시판 모듈 프론트엔드 에셋",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @file admin-board-post-detail-count-consistency.test.tsx
|
||||
* @description 관리자 게시글 상세 - 카운트 컬럼 정합성 검증 (이슈 #304 Phase 4)
|
||||
*
|
||||
* 검증 방식: 레이아웃 JSON 트리 직접 분석 (DOM 비의존).
|
||||
* 검증 목적:
|
||||
* 1. Verification — 답글/댓글/첨부 헤더 카운트가 서버 컬럼(reply_count/comment_count/attachment_count)을 사용
|
||||
* 2. Regression — `.length` 기반 카운트 패턴 제거 고정
|
||||
* 3. 정책 고정 — del_cmt=1 토글 시 헤더(comment_count) ≠ 표시 항목 수(comments[].length) 의도된 트레이드오프
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
// 정정 대상 4개 파일
|
||||
import postDetail from '../../../../resources/layouts/admin/admin_board_post_detail.json';
|
||||
import commentsPartial from '../../../../resources/layouts/admin/partials/admin_board_post_detail/_comments.json';
|
||||
import postCardContent from '../../../../resources/layouts/admin/partials/admin_board_post_detail/_post_card_content.json';
|
||||
import replyCardContent from '../../../../resources/layouts/admin/partials/admin_board_post_detail/_reply_card_content.json';
|
||||
|
||||
function stringifyDeep(node: unknown): string {
|
||||
return JSON.stringify(node);
|
||||
}
|
||||
|
||||
describe('이슈 #304 Phase 4 — 관리자 게시글 상세 카운트 컬럼 정합성', () => {
|
||||
describe('admin_board_post_detail.json — 답글 섹션 헤더', () => {
|
||||
it('답글 섹션 표시 조건은 reply_count 서버 컬럼을 사용한다', () => {
|
||||
const dump = stringifyDeep(postDetail);
|
||||
expect(dump).toContain('post?.data?.reply_count');
|
||||
});
|
||||
|
||||
it('답글 헤더 카운트 텍스트가 (post.data.replies ?? []).length 를 사용하지 않는다', () => {
|
||||
const dump = stringifyDeep(postDetail);
|
||||
expect(dump).not.toMatch(/\(post\?\.data\?\.replies\s*\?\?\s*\[\]\)\.length/);
|
||||
});
|
||||
|
||||
it('iteration source 는 여전히 replies 배열을 사용한다 (표시는 배열 그대로)', () => {
|
||||
const dump = stringifyDeep(postDetail);
|
||||
expect(dump).toContain('post?.data?.replies ?? []');
|
||||
});
|
||||
});
|
||||
|
||||
describe('_comments.json — 댓글 헤더 / 빈 상태 / 표시 분기', () => {
|
||||
it('댓글 헤더 카운트는 comment_count 서버 컬럼을 사용한다', () => {
|
||||
const dump = stringifyDeep(commentsPartial);
|
||||
expect(dump).toContain('post?.data?.comment_count');
|
||||
});
|
||||
|
||||
it('댓글 헤더/빈 상태 분기가 (post.data.comments ?? []).length 를 사용하지 않는다', () => {
|
||||
const dump = stringifyDeep(commentsPartial);
|
||||
// count={{(post.data.comments ?? []).length}} 와 if 분기 양쪽 모두 제거
|
||||
expect(dump).not.toMatch(/\(post\?\.data\?\.comments\s*\?\?\s*\[\]\)\.length/);
|
||||
});
|
||||
|
||||
it('iteration source 는 여전히 comments 배열을 사용한다 (del_cmt 정책)', () => {
|
||||
// [정책 고정] del_cmt=1 토글 시 헤더(comment_count=활성만) ≠ 표시 항목(comments[]=삭제 포함) 의도된 정책
|
||||
const dump = stringifyDeep(commentsPartial);
|
||||
expect(dump).toContain('post?.data?.comments ?? []');
|
||||
});
|
||||
});
|
||||
|
||||
describe('_post_card_content.json — 게시글 카드 댓글 수 / 첨부', () => {
|
||||
it('댓글 수 표시는 comment_count 서버 컬럼을 사용한다', () => {
|
||||
const dump = stringifyDeep(postCardContent);
|
||||
expect(dump).toContain('post?.data?.comment_count');
|
||||
});
|
||||
|
||||
it('댓글 수 표시가 (post.data.comments ?? []).length 를 사용하지 않는다', () => {
|
||||
const dump = stringifyDeep(postCardContent);
|
||||
expect(dump).not.toMatch(/count=\{\{\(post\?\.data\?\.comments\s*\?\?\s*\[\]\)\.length\}\}/);
|
||||
});
|
||||
|
||||
it('첨부 섹션 표시 if 는 has_attachment boolean 을 사용한다', () => {
|
||||
const dump = stringifyDeep(postCardContent);
|
||||
expect(dump).toContain('post?.data?.has_attachment');
|
||||
});
|
||||
|
||||
it('첨부 카운트 배지는 attachment_count 서버 컬럼을 사용한다', () => {
|
||||
const dump = stringifyDeep(postCardContent);
|
||||
expect(dump).toContain('post?.data?.attachment_count');
|
||||
});
|
||||
|
||||
it('첨부 섹션 표시 if 가 (post.data.attachments ?? []).length 를 사용하지 않는다', () => {
|
||||
const dump = stringifyDeep(postCardContent);
|
||||
expect(dump).not.toMatch(/\(post\?\.data\?\.attachments\s*\?\?\s*\[\]\)\.length/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('_reply_card_content.json — 답글 카드 첨부', () => {
|
||||
it('첨부 섹션 표시 if 는 has_attachment 를 사용한다', () => {
|
||||
const dump = stringifyDeep(replyCardContent);
|
||||
expect(dump).toContain('item.has_attachment');
|
||||
});
|
||||
|
||||
it('첨부 카운트 배지는 attachment_count 서버 컬럼을 사용한다', () => {
|
||||
const dump = stringifyDeep(replyCardContent);
|
||||
expect(dump).toContain('item.attachment_count');
|
||||
});
|
||||
|
||||
it('첨부 섹션 표시 if 가 (item.attachments ?? []).length 를 사용하지 않는다', () => {
|
||||
const dump = stringifyDeep(replyCardContent);
|
||||
expect(dump).not.toMatch(/\(item\.attachments\s*\?\?\s*\[\]\)\.length/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('del_cmt 정책 고정 — 헤더 카운트는 항상 서버 컬럼, 표시 항목은 응답 배열', () => {
|
||||
it('관리자 댓글 헤더는 comment_count, iteration 은 comments 배열 — 분리된 SSoT 사용', () => {
|
||||
const dump = stringifyDeep(commentsPartial);
|
||||
// 헤더 = 서버 컬럼 (활성 댓글만)
|
||||
expect(dump).toContain('post?.data?.comment_count');
|
||||
// 표시 = 응답 배열 (del_cmt=1 시 삭제 포함)
|
||||
expect(dump).toContain('post?.data?.comments ?? []');
|
||||
// 둘이 어긋나는 것이 의도된 정책 — `.length` 기반 합치기 패턴 제거 확정
|
||||
expect(dump).not.toMatch(/\(post\?\.data\?\.comments\s*\?\?\s*\[\]\)\.length/);
|
||||
});
|
||||
});
|
||||
});
|
||||
+2
-3
@@ -14,9 +14,8 @@ import { describe, it, expect } from 'vitest';
|
||||
import adminAttachments from '../../../layouts/admin/partials/admin_board_post_form/_attachments.json';
|
||||
import adminPostForm from '../../../layouts/admin/admin_board_post_form.json';
|
||||
|
||||
// 사용자 폼은 templates 디렉토리에 있으므로 상대경로 사용
|
||||
// JSON 파일은 직접 import (vitest가 자동 파싱)
|
||||
import userPostForm from '../../../../../../templates/sirsoft-basic/layouts/partials/board/form/_post_form.json';
|
||||
// 사용자 폼은 _bundled 템플릿에서 import (활성 디렉토리는 .gitignore 대상이므로 원본 참조)
|
||||
import userPostForm from '../../../../../../../templates/_bundled/sirsoft-basic/layouts/partials/board/form/_post_form.json';
|
||||
|
||||
/**
|
||||
* JSON 트리에서 특정 타입의 컴포넌트를 재귀적으로 찾습니다.
|
||||
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @file admin-board-settings-modal-perf.test.tsx
|
||||
* @description 게시판 환경설정 모달 회귀 (옵션 K — _global 단일 진실)
|
||||
*
|
||||
* namespace 키 분리 — 게시판: board_notification_template_form_modal
|
||||
* 정책 모달은 동일 키 (identity_policy_form_modal) 사용 — 코어와 ecommerce/board 가
|
||||
* 동시 마운트되지 않으므로 키 충돌 없음 (각 모듈 환경설정 페이지에서만 노출)
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
const policyTab = require('../../../layouts/admin/partials/admin_board_settings/_tab_identity_policies.json');
|
||||
const policyModal = require('../../../layouts/admin/partials/admin_board_settings/_modal_identity_policy_form.json');
|
||||
const notifTab = require('../../../layouts/admin/partials/admin_board_settings/_tab_notification_definitions.json');
|
||||
const notifModal = require('../../../layouts/admin/partials/admin_board_settings/_modal_notification_template_edit.json');
|
||||
const notifPreview = require('../../../layouts/admin/partials/admin_board_settings/_modal_notification_template_preview.json');
|
||||
|
||||
interface AnyJson { [k: string]: any }
|
||||
|
||||
const collectChangeTargets = (node: AnyJson, acc: string[] = []): string[] => {
|
||||
if (!node || typeof node !== 'object') return acc;
|
||||
if (Array.isArray(node)) { node.forEach(item => collectChangeTargets(item, acc)); return acc; }
|
||||
if (Array.isArray(node.actions)) {
|
||||
for (const a of node.actions) {
|
||||
const isChange = a?.type === 'change' || a?.event === 'onChange' || a?.event === 'onSearch';
|
||||
if (isChange && a?.handler === 'setState' && a?.params?.target) {
|
||||
acc.push(a.params.target);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const k of Object.keys(node)) collectChangeTargets(node[k], acc);
|
||||
return acc;
|
||||
};
|
||||
|
||||
describe('게시판 본인인증 정책 모달 회귀 (옵션 K)', () => {
|
||||
it('lifecycle.onMount 미사용', () => {
|
||||
expect(policyModal.lifecycle).toBeUndefined();
|
||||
});
|
||||
|
||||
it('change 액션은 모두 target:"global"', () => {
|
||||
const targets = collectChangeTargets(policyModal);
|
||||
expect(targets.length).toBeGreaterThan(0);
|
||||
expect(targets.every(t => t === 'global')).toBe(true);
|
||||
});
|
||||
|
||||
it('list 측 setState 가 _global.identity_policy_form_modal 통째 set', () => {
|
||||
const tabStr = JSON.stringify(policyTab);
|
||||
expect(tabStr).toContain('"target":"global"');
|
||||
expect(tabStr).toContain('"identity_policy_form_modal":{');
|
||||
});
|
||||
|
||||
it('표시/입력 모두 _global.identity_policy_form_modal 경로', () => {
|
||||
const modalStr = JSON.stringify(policyModal);
|
||||
expect(modalStr).toContain('_global.identity_policy_form_modal?.form?.key');
|
||||
expect(modalStr).toContain('"identity_policy_form_modal.form.key":');
|
||||
});
|
||||
|
||||
it('apiCall body source_identifier=sirsoft-board, dataSourceId=boardIdentityPolicies', () => {
|
||||
const modalStr = JSON.stringify(policyModal);
|
||||
expect(modalStr).toContain("'sirsoft-board'");
|
||||
expect(modalStr).toContain('"dataSourceId":"boardIdentityPolicies"');
|
||||
});
|
||||
|
||||
it('저장 onSuccess 에 namespace null 정리', () => {
|
||||
const modalStr = JSON.stringify(policyModal);
|
||||
expect(modalStr).toContain('"identity_policy_form_modal":null');
|
||||
});
|
||||
});
|
||||
|
||||
describe('게시판 알림 템플릿 모달 회귀 (옵션 K)', () => {
|
||||
it('lifecycle.onMount 미사용', () => {
|
||||
expect(notifModal.lifecycle).toBeUndefined();
|
||||
});
|
||||
|
||||
it('change/onChange/onSearch 액션은 모두 target:"global"', () => {
|
||||
const targets = collectChangeTargets(notifModal);
|
||||
expect(targets.length).toBeGreaterThan(0);
|
||||
expect(targets.every(t => t === 'global')).toBe(true);
|
||||
});
|
||||
|
||||
it('list 측 setState 가 _global.board_notification_template_form_modal 통째 set', () => {
|
||||
const tabStr = JSON.stringify(notifTab);
|
||||
expect(tabStr).toContain('"board_notification_template_form_modal":{');
|
||||
});
|
||||
|
||||
it('표시 표현식이 board_notification_template_form_modal 경로', () => {
|
||||
const modalStr = JSON.stringify(notifModal);
|
||||
expect(modalStr).toContain('_global.board_notification_template_form_modal?.template?.subject');
|
||||
expect(modalStr).toContain('_global.board_notification_template_form_modal?.recipients');
|
||||
});
|
||||
|
||||
it('subject/body — Object.assign + dot path 통째 set', () => {
|
||||
const modalStr = JSON.stringify(notifModal);
|
||||
expect(modalStr).toContain('"board_notification_template_form_modal.template.subject":');
|
||||
expect(modalStr).toContain('Object.assign({}, _global.board_notification_template_form_modal?.template?.subject');
|
||||
});
|
||||
|
||||
it('recipients — .map/.filter 통째 교체', () => {
|
||||
const modalStr = JSON.stringify(notifModal);
|
||||
expect(modalStr).toContain('"board_notification_template_form_modal.recipients":');
|
||||
});
|
||||
|
||||
it('preview 모달이 _global.board_notification_template_form_modal?.preview 참조', () => {
|
||||
const previewStr = JSON.stringify(notifPreview);
|
||||
expect(previewStr).toContain('_global.board_notification_template_form_modal?.preview?.subject');
|
||||
expect(previewStr).toContain('_global.board_notification_template_form_modal?.preview?.body');
|
||||
});
|
||||
|
||||
it('저장 onSuccess 에 dataSourceId=boardNotificationDefinitions + namespace null 정리', () => {
|
||||
const modalStr = JSON.stringify(notifModal);
|
||||
expect(modalStr).toContain('"dataSourceId":"boardNotificationDefinitions"');
|
||||
expect(modalStr).toContain('"board_notification_template_form_modal":null');
|
||||
});
|
||||
});
|
||||
+141
-23
@@ -271,20 +271,22 @@ describe('admin_board_settings.json - 메인 레이아웃', () => {
|
||||
const tabAction = tabNav.actions[0];
|
||||
|
||||
expect(tabAction.handler).toBe('sequence');
|
||||
expect(tabAction.actions).toHaveLength(3);
|
||||
// sequence 하위 액션은 params.actions 에 위치 (엔진 규약)
|
||||
const innerActions = tabAction.params.actions;
|
||||
expect(innerActions).toHaveLength(3);
|
||||
|
||||
// setState - errors 초기화
|
||||
expect(tabAction.actions[0].handler).toBe('setState');
|
||||
expect(tabAction.actions[0].params.target).toBe('local');
|
||||
expect(tabAction.actions[0].params.errors).toBeNull();
|
||||
expect(innerActions[0].handler).toBe('setState');
|
||||
expect(innerActions[0].params.target).toBe('local');
|
||||
expect(innerActions[0].params.errors).toBeNull();
|
||||
|
||||
// setState - 글로벌 탭 상태
|
||||
expect(tabAction.actions[1].handler).toBe('setState');
|
||||
expect(tabAction.actions[1].params.target).toBe('global');
|
||||
expect(innerActions[1].handler).toBe('setState');
|
||||
expect(innerActions[1].params.target).toBe('global');
|
||||
|
||||
// replaceUrl - URL 업데이트
|
||||
expect(tabAction.actions[2].handler).toBe('replaceUrl');
|
||||
expect(tabAction.actions[2].params.query.tab).toBeDefined();
|
||||
expect(innerActions[2].handler).toBe('replaceUrl');
|
||||
expect(innerActions[2].params.query.tab).toBeDefined();
|
||||
});
|
||||
|
||||
it('sticky 헤더 구조가 올바르다', () => {
|
||||
@@ -336,14 +338,16 @@ describe('admin_board_settings.json - 메인 레이아웃', () => {
|
||||
|
||||
const clickAction = saveBtn.actions[0];
|
||||
expect(clickAction.handler).toBe('sequence');
|
||||
// sequence 하위 액션은 params.actions 에 위치
|
||||
const innerActions = clickAction.params.actions;
|
||||
|
||||
// 1단계: setState isSaving=true
|
||||
const setStateAction = clickAction.actions[0];
|
||||
const setStateAction = innerActions[0];
|
||||
expect(setStateAction.handler).toBe('setState');
|
||||
expect(setStateAction.params.isSaving).toBe(true);
|
||||
|
||||
// 2단계: apiCall PUT
|
||||
const apiCallAction = clickAction.actions[1];
|
||||
const apiCallAction = innerActions[1];
|
||||
expect(apiCallAction.handler).toBe('apiCall');
|
||||
expect(apiCallAction.target).toBe('/api/modules/sirsoft-board/admin/settings');
|
||||
expect(apiCallAction.params.method).toBe('PUT');
|
||||
@@ -456,7 +460,7 @@ describe('_tab_board_settings_basic.json - 기본 하위 탭', () => {
|
||||
expect(fields).toContain('basic_defaults.use_report');
|
||||
});
|
||||
|
||||
it('각 필드에 일괄 적용 체크박스가 있고 Label 클릭으로 토글된다', () => {
|
||||
it('각 필드에 일괄 적용 체크박스가 있고 Input change 액션으로 토글된다 — controlled checkbox 표준 (#304)', () => {
|
||||
const fieldType = findById(tabBoardSettingsBasic, 'field_type');
|
||||
expect(fieldType).toBeDefined();
|
||||
|
||||
@@ -464,15 +468,49 @@ describe('_tab_board_settings_basic.json - 기본 하위 탭', () => {
|
||||
(c: any) => c.props?.type === 'checkbox' && c.props?.className?.includes('checkbox')
|
||||
);
|
||||
expect(checkboxes.length).toBeGreaterThanOrEqual(1);
|
||||
expect(checkboxes[0].actions).toBeUndefined();
|
||||
|
||||
const labels = findByName(fieldType, 'Label');
|
||||
const labelWithClick = labels.find(
|
||||
(l: any) => l.actions?.some((a: any) => a.type === 'click' && a.handler === 'setState')
|
||||
// 체크박스 Input 토글 시 change 이벤트로 setState 발화 — React controlled checkbox 표준
|
||||
const checkboxChangeAction = checkboxes[0].actions?.find(
|
||||
(a: any) => a.type === 'change' && a.handler === 'setState'
|
||||
);
|
||||
expect(labelWithClick).toBeDefined();
|
||||
const clickAction = labelWithClick!.actions.find((a: any) => a.type === 'click');
|
||||
expect(clickAction.params.bulkApplyFields).toBeDefined();
|
||||
expect(checkboxChangeAction).toBeDefined();
|
||||
expect(checkboxChangeAction.params.target).toBe('local');
|
||||
expect(checkboxChangeAction.params.bulkApplyFields).toContain("includes('type')");
|
||||
|
||||
// 라벨에는 click 액션이 없어야 한다 (HTML 표준: Label 클릭 시 자식 Input의 change 자동 발화)
|
||||
const labels = findByName(fieldType, 'Label');
|
||||
for (const label of labels) {
|
||||
const labelClick = label.actions?.find((a: any) => a.type === 'click');
|
||||
expect(labelClick, 'Label에 click 액션 없음 (이중 발화 방지)').toBeUndefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('basic 탭의 모든 일괄적용 필드(4개) Input에 change 액션이 적용되어 있고 라벨에는 click 액션이 없다 (#304)', () => {
|
||||
const fieldIds = ['field_type', 'field_secret_mode', 'field_show_view_count', 'field_use_report'];
|
||||
|
||||
for (const fieldId of fieldIds) {
|
||||
const field = findById(tabBoardSettingsBasic, fieldId);
|
||||
expect(field, `${fieldId} 노드 존재`).toBeDefined();
|
||||
|
||||
const checkboxes = findByName(field, 'Input').filter(
|
||||
(c: any) => c.props?.type === 'checkbox' && c.props?.className?.includes('checkbox')
|
||||
);
|
||||
expect(checkboxes.length, `${fieldId} 체크박스 1개 이상`).toBeGreaterThanOrEqual(1);
|
||||
|
||||
const checkboxChange = checkboxes[0].actions?.find(
|
||||
(a: any) => a.type === 'change' && a.handler === 'setState'
|
||||
);
|
||||
expect(checkboxChange, `${fieldId} 체크박스 Input change 액션 존재`).toBeDefined();
|
||||
expect(checkboxChange.params.target, `${fieldId} target=local`).toBe('local');
|
||||
expect(checkboxChange.params.bulkApplyFields, `${fieldId} bulkApplyFields 토글 표현식`).toBeDefined();
|
||||
|
||||
// 라벨에 click 액션이 없는지 (이중 발화 방지)
|
||||
const labels = findByName(field, 'Label');
|
||||
for (const label of labels) {
|
||||
const labelClick = label.actions?.find((a: any) => a.type === 'click');
|
||||
expect(labelClick, `${fieldId} Label에 click 액션 없음`).toBeUndefined();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -524,6 +562,83 @@ describe('_tab_board_settings_permissions.json - 권한 하위 탭', () => {
|
||||
expect(tagInput.props.value).toContain('perm?.[0]');
|
||||
}
|
||||
});
|
||||
|
||||
it('권한 행은 Label로 체크박스+텍스트를 감싸고 Input change로 토글한다 — basic 탭과 동일 패턴 (#304)', () => {
|
||||
const sectionIds = ['permissions_admin_section', 'permissions_user_section'];
|
||||
|
||||
for (const sectionId of sectionIds) {
|
||||
const section = findById(tabBoardSettingsPermissions, sectionId);
|
||||
expect(section, `${sectionId} 노드 존재`).toBeDefined();
|
||||
|
||||
const iterDiv = findByName(section, 'Div').find(
|
||||
(d: any) => d.iteration?.source?.includes('Permissions')
|
||||
);
|
||||
expect(iterDiv, `${sectionId} iteration Div 존재`).toBeDefined();
|
||||
|
||||
// iteration Div에는 click 액션이 없어야 한다 (HTML Label이 자식 Input change를 자동 발화)
|
||||
const parentClick = iterDiv.actions?.find((a: any) => a.type === 'click');
|
||||
expect(parentClick, `${sectionId} iteration Div에 click 액션 없음`).toBeUndefined();
|
||||
|
||||
// iteration Div의 직계 자식에 Label이 있고, Label이 체크박스를 감싼다
|
||||
const labelChild = iterDiv.children?.find((c: any) => c.name === 'Label');
|
||||
expect(labelChild, `${sectionId} 직계 자식 Label 존재`).toBeDefined();
|
||||
|
||||
const labelCheckbox = findByName(labelChild, 'Input').find(
|
||||
(c: any) => c.props?.type === 'checkbox'
|
||||
);
|
||||
expect(labelCheckbox, `${sectionId} Label 안 체크박스 존재`).toBeDefined();
|
||||
const checkboxChange = labelCheckbox.actions?.find(
|
||||
(a: any) => a.type === 'change' && a.handler === 'setState'
|
||||
);
|
||||
expect(checkboxChange, `${sectionId} 체크박스 Input에 change 액션 존재`).toBeDefined();
|
||||
|
||||
// 자식 컨테이너의 className에 pointer-events-none 사용 금지 (이중 발화 차단 회피)
|
||||
const childDivs = findByName(iterDiv, 'Div');
|
||||
for (const child of childDivs) {
|
||||
const className: string = child.props?.className ?? '';
|
||||
expect(
|
||||
className.includes('pointer-events-none'),
|
||||
`${sectionId} 자식 Div className: "${className}" — pointer-events-none 사용 금지`
|
||||
).toBe(false);
|
||||
}
|
||||
|
||||
// Label 안에 Label 중첩 금지 (기존 권한 이름 Label은 Span으로 다운그레이드되어야 함)
|
||||
const nestedLabels = findByName(labelChild, 'Label').filter((l: any) => l !== labelChild);
|
||||
expect(nestedLabels.length, `${sectionId} Label 안 중첩 Label 금지`).toBe(0);
|
||||
}
|
||||
});
|
||||
|
||||
it('권한 섹션 헤더(전체 토글)는 Label로 체크박스+텍스트를 감싸고 Input change로 토글한다 (#304)', () => {
|
||||
const sectionIds = ['permissions_admin_section', 'permissions_user_section'];
|
||||
|
||||
for (const sectionId of sectionIds) {
|
||||
const section = findById(tabBoardSettingsPermissions, sectionId);
|
||||
expect(section, `${sectionId} 노드 존재`).toBeDefined();
|
||||
|
||||
// 섹션 헤더는 첫 자식 Label (cursor-pointer + 체크박스 감쌈)
|
||||
const headerLabel = section.children.find(
|
||||
(c: any) => c.name === 'Label' && (c.props?.className ?? '').includes('cursor-pointer')
|
||||
);
|
||||
expect(headerLabel, `${sectionId} 섹션 헤더 Label 존재`).toBeDefined();
|
||||
|
||||
// Label 자체에는 click 액션이 없어야 한다 (HTML 표준이 자식 Input change를 자동 발화)
|
||||
expect(headerLabel.actions, `${sectionId} 섹션 헤더 Label에 액션 없음`).toBeUndefined();
|
||||
|
||||
// 헤더 내 체크박스에 change 액션 + pointer-events-none 미사용
|
||||
const headerCheckbox = findByName(headerLabel, 'Input').find(
|
||||
(c: any) => c.props?.type === 'checkbox'
|
||||
);
|
||||
expect(headerCheckbox, `${sectionId} 섹션 헤더 체크박스 존재`).toBeDefined();
|
||||
expect(
|
||||
(headerCheckbox.props.className ?? '').includes('pointer-events-none'),
|
||||
`${sectionId} 섹션 헤더 체크박스 pointer-events-none 미사용`
|
||||
).toBe(false);
|
||||
const headerChange = headerCheckbox.actions?.find(
|
||||
(a: any) => a.type === 'change' && a.handler === 'setState'
|
||||
);
|
||||
expect(headerChange, `${sectionId} 섹션 헤더 체크박스 change 액션 존재`).toBeDefined();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// =============================================
|
||||
@@ -1082,13 +1197,16 @@ describe('크로스 파일 검증', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('저장 body에 notification_channels 포함 로직이 있다', () => {
|
||||
it('저장 body에 notification channels 포함 로직이 있다', () => {
|
||||
const content = mainLayout.slots.content[0];
|
||||
const saveBtn = findById(content, 'save_button');
|
||||
const apiCallAction = saveBtn.actions[0].actions[1];
|
||||
const apiCallAction = saveBtn.actions[0].params.actions[1];
|
||||
|
||||
// body 표현식 안에서 notifications.channels 구조를 조립한다
|
||||
// (notification_definitions 탭 진입 시 form.notifications.channels 를 그대로 전송)
|
||||
const body = apiCallAction.params.body;
|
||||
expect(body).toContain('notification_channels');
|
||||
expect(body).toContain('notifications');
|
||||
expect(body).toContain('channels');
|
||||
expect(body).toContain('basic_defaults');
|
||||
});
|
||||
|
||||
@@ -1192,7 +1310,7 @@ describe('기본 설정 탭 (general) - 날짜 표시 방식', () => {
|
||||
it('저장 body에 general 탭 분기 로직이 있다', () => {
|
||||
const content = mainLayout.slots.content[0];
|
||||
const saveBtn = findById(content, 'save_button');
|
||||
const apiCallAction = saveBtn.actions[0].actions[1];
|
||||
const apiCallAction = saveBtn.actions[0].params.actions[1];
|
||||
const body = apiCallAction.params.body as string;
|
||||
|
||||
// general 탭에서 display 카테고리 전송
|
||||
@@ -1371,7 +1489,7 @@ describe('_tab_seo.json - SEO 설정 탭', () => {
|
||||
it('저장 body에 seo 탭 분기 로직이 있다', () => {
|
||||
const content = mainLayout.slots.content[0];
|
||||
const saveBtn = findById(content, 'save_button');
|
||||
const apiCallAction = saveBtn.actions[0].actions[1];
|
||||
const apiCallAction = saveBtn.actions[0].params.actions[1];
|
||||
const body = apiCallAction.params.body as string;
|
||||
expect(body).toContain("'seo'");
|
||||
expect(body).toContain('seo:');
|
||||
|
||||
+288
-807
File diff suppressed because it is too large.
Load diff
+149
-708
@@ -1,733 +1,174 @@
|
||||
// @vitest-environment jsdom
|
||||
/**
|
||||
* @file board-index-empty-states.test.tsx
|
||||
* @description 게시판 목록 - 빈 상태, 로딩/오류, 글쓰기 버튼 렌더링 테스트
|
||||
* @description 게시판 목록 - 빈 상태 / 로딩 / 오류 / 글쓰기 버튼 레이아웃 JSON 구조 검증
|
||||
*
|
||||
* 검증 항목:
|
||||
* 1. 빈 상태 3종 (빈 페이지 / 게시글 없음 / 검색 결과 없음) 조건부 렌더링
|
||||
* 2. 로딩 스켈레톤 / 오류 페이지 조건부 렌더링
|
||||
* 3. 글쓰기 버튼 권한별 분기 (allowed / no_permission / not_logged_in)
|
||||
* 검증 방식: 레이아웃 JSON 트리 구조 직접 분석 (DOM 렌더링 비의존).
|
||||
* 빈 상태/로딩/오류 분기는 JSON 의 if 표현식과 컴포넌트 트리로 충분히 검증 가능.
|
||||
* (testId 도입을 회피하고 RTL 권장 패턴인 구조 검증으로 통합 — issue #204 후속 결정)
|
||||
*/
|
||||
|
||||
import '@testing-library/jest-dom';
|
||||
import React from 'react';
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { createLayoutTest, screen } from '@core/template-engine/__tests__/utils/layoutTestUtils';
|
||||
import { ComponentRegistry } from '@core/template-engine/ComponentRegistry';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
// G7Core 전역 모킹
|
||||
(globalThis as any).window = globalThis.window || globalThis;
|
||||
(window as any).G7Core = (window as any).G7Core || {
|
||||
createChangeEvent: vi.fn((data: { checked?: boolean; name?: string; value?: any }) => ({
|
||||
target: {
|
||||
checked: data.checked ?? false,
|
||||
name: data.name ?? '',
|
||||
value: data.value ?? (data.checked ? 'on' : 'off'),
|
||||
type: 'checkbox',
|
||||
},
|
||||
currentTarget: {
|
||||
checked: data.checked ?? false,
|
||||
name: data.name ?? '',
|
||||
value: data.value ?? (data.checked ? 'on' : 'off'),
|
||||
type: 'checkbox',
|
||||
},
|
||||
preventDefault: vi.fn(),
|
||||
stopPropagation: vi.fn(),
|
||||
})),
|
||||
state: {
|
||||
get: vi.fn(),
|
||||
set: vi.fn(),
|
||||
update: vi.fn(),
|
||||
subscribe: vi.fn(() => vi.fn()),
|
||||
},
|
||||
toast: { success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn() },
|
||||
modal: { open: vi.fn(), close: vi.fn() },
|
||||
events: { emit: vi.fn(), on: vi.fn(() => vi.fn()), off: vi.fn() },
|
||||
t: (key: string) => key,
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
// 테스트용 컴포넌트 정의
|
||||
// ============================================================
|
||||
|
||||
const TestDiv: React.FC<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
'data-testid'?: string;
|
||||
}> = ({ className, children, 'data-testid': testId }) => (
|
||||
<div className={className} data-testid={testId}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
const TestButton: React.FC<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
text?: string;
|
||||
type?: string;
|
||||
onClick?: () => void;
|
||||
'data-testid'?: string;
|
||||
}> = ({ className, children, text, onClick, 'data-testid': testId }) => (
|
||||
<button className={className} onClick={onClick} data-testid={testId}>
|
||||
{children || text}
|
||||
</button>
|
||||
);
|
||||
|
||||
const TestSpan: React.FC<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
text?: string;
|
||||
}> = ({ className, children, text }) => (
|
||||
<span className={className}>{children || text}</span>
|
||||
);
|
||||
|
||||
const TestH1: React.FC<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
text?: string;
|
||||
}> = ({ className, children, text }) => (
|
||||
<h1 className={className}>{children || text}</h1>
|
||||
);
|
||||
|
||||
const TestH2: React.FC<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
text?: string;
|
||||
}> = ({ className, children, text }) => (
|
||||
<h2 className={className}>{children || text}</h2>
|
||||
);
|
||||
|
||||
const TestP: React.FC<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
text?: string;
|
||||
}> = ({ className, children, text }) => (
|
||||
<p className={className}>{children || text}</p>
|
||||
);
|
||||
|
||||
const TestIcon: React.FC<{
|
||||
name?: string;
|
||||
size?: string;
|
||||
className?: string;
|
||||
}> = ({ name, size, className }) => (
|
||||
<i className={className} data-icon={name} data-size={size} />
|
||||
);
|
||||
|
||||
const TestContainer: React.FC<{
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
}> = ({ className, children }) => (
|
||||
<div className={className} data-testid="container">
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
const TestSearchBar: React.FC<{
|
||||
name?: string;
|
||||
placeholder?: string;
|
||||
value?: string;
|
||||
showButton?: boolean;
|
||||
className?: string;
|
||||
onSubmit?: (e: React.FormEvent) => void;
|
||||
}> = ({ name, placeholder, value, className, onSubmit }) => (
|
||||
<form onSubmit={onSubmit} data-testid="search-bar">
|
||||
<input name={name} placeholder={placeholder} defaultValue={value} />
|
||||
</form>
|
||||
);
|
||||
|
||||
const TestPagination: React.FC<{
|
||||
currentPage?: number;
|
||||
totalPages?: number;
|
||||
className?: string;
|
||||
onPageChange?: (page: number) => void;
|
||||
}> = ({ currentPage, totalPages, className }) => (
|
||||
<nav className={className} data-testid="pagination">
|
||||
<span>
|
||||
Page {currentPage} of {totalPages}
|
||||
</span>
|
||||
</nav>
|
||||
);
|
||||
|
||||
const TestSelect: React.FC<{
|
||||
value?: string | number;
|
||||
className?: string;
|
||||
options?: Array<{ value: string | number; label: string }>;
|
||||
onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
||||
}> = ({ value, className, options, onChange }) => (
|
||||
<select value={value} className={className} onChange={onChange}>
|
||||
{options?.map((opt) => (
|
||||
<option key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
);
|
||||
|
||||
// ============================================================
|
||||
// 컴포넌트 레지스트리 설정
|
||||
// ============================================================
|
||||
|
||||
function setupTestRegistry(): ComponentRegistry {
|
||||
const registry = ComponentRegistry.getInstance();
|
||||
|
||||
(registry as any).registry = {
|
||||
Fragment: { component: ({ children }: any) => <>{children}</>, metadata: { name: 'Fragment', type: 'layout' } },
|
||||
Div: { component: TestDiv, metadata: { name: 'Div', type: 'basic' } },
|
||||
Button: { component: TestButton, metadata: { name: 'Button', type: 'basic' } },
|
||||
Span: { component: TestSpan, metadata: { name: 'Span', type: 'basic' } },
|
||||
H1: { component: TestH1, metadata: { name: 'H1', type: 'basic' } },
|
||||
H2: { component: TestH2, metadata: { name: 'H2', type: 'basic' } },
|
||||
P: { component: TestP, metadata: { name: 'P', type: 'basic' } },
|
||||
Icon: { component: TestIcon, metadata: { name: 'Icon', type: 'basic' } },
|
||||
Select: { component: TestSelect, metadata: { name: 'Select', type: 'basic' } },
|
||||
Container: { component: TestContainer, metadata: { name: 'Container', type: 'layout' } },
|
||||
SearchBar: { component: TestSearchBar, metadata: { name: 'SearchBar', type: 'composite' } },
|
||||
Pagination: { component: TestPagination, metadata: { name: 'Pagination', type: 'composite' } },
|
||||
};
|
||||
|
||||
return registry;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 레이아웃 JSON (빈 상태 + 로딩/오류 + 글쓰기 버튼 검증용)
|
||||
// ============================================================
|
||||
// 게시판 목록의 빈 상태 / 로딩-오류 partial
|
||||
import emptyStatesPartial from '../../../../../../../templates/_bundled/sirsoft-basic/layouts/partials/board/index/_empty_states.json';
|
||||
import loadingErrorPartial from '../../../../../../../templates/_bundled/sirsoft-basic/layouts/partials/board/index/_loading_error.json';
|
||||
import writeButtonPartial from '../../../../../../../templates/_bundled/sirsoft-basic/layouts/partials/board/index/_write_button.json';
|
||||
|
||||
/**
|
||||
* 리팩토링된 index.json 구조의 핵심 부분을 재현
|
||||
* partial 분리된 내용을 인라인으로 포함 (테스트 편의)
|
||||
* 컴포넌트 트리에서 if 표현식이 특정 패턴을 포함하는 첫 노드를 찾는다.
|
||||
*/
|
||||
const boardIndexLayoutJson = {
|
||||
version: '1.0.0',
|
||||
layout_name: 'board_index_empty_states_test',
|
||||
data_sources: [
|
||||
{
|
||||
id: 'posts',
|
||||
type: 'api',
|
||||
endpoint: '/api/modules/sirsoft-board/boards/test-board/posts',
|
||||
method: 'GET',
|
||||
params: {
|
||||
page: '{{query.page ?? 1}}',
|
||||
search: "{{query.search ?? ''}}",
|
||||
category: "{{query.category ?? ''}}",
|
||||
},
|
||||
auto_fetch: true,
|
||||
auth_required: true,
|
||||
},
|
||||
],
|
||||
components: [
|
||||
{
|
||||
comment: '로딩 스켈레톤 (오류 없을 때만)',
|
||||
type: 'layout',
|
||||
name: 'Container',
|
||||
if: '{{!posts?.data?.board && !_global.hasError}}',
|
||||
props: { 'data-testid': 'loading-skeleton' },
|
||||
children: [
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'P',
|
||||
text: '게시글을 불러오는 중입니다...',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
comment: '오류 페이지',
|
||||
type: 'layout',
|
||||
name: 'Container',
|
||||
if: '{{_global.hasError}}',
|
||||
props: { 'data-testid': 'error-page' },
|
||||
children: [
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'H2',
|
||||
props: { 'data-testid': 'error-title' },
|
||||
text: '일시적인 오류가 발생했습니다',
|
||||
},
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'Button',
|
||||
props: { 'data-testid': 'reload-btn' },
|
||||
text: '새로고침',
|
||||
actions: [{ type: 'click', handler: 'refresh' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
comment: '메인 컨테이너 (데이터 로드 완료 시)',
|
||||
type: 'layout',
|
||||
name: 'Container',
|
||||
if: '{{posts?.data?.board}}',
|
||||
children: [
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'H1',
|
||||
props: { 'data-testid': 'board-title' },
|
||||
text: "{{posts?.data?.board?.name ?? ''}}",
|
||||
},
|
||||
{
|
||||
comment: '글쓰기 버튼',
|
||||
type: 'basic',
|
||||
name: 'Button',
|
||||
props: { 'data-testid': 'write-btn' },
|
||||
actions: [
|
||||
{
|
||||
type: 'click',
|
||||
handler: 'switch',
|
||||
params: {
|
||||
value:
|
||||
"{{posts?.data?.permissions?.posts_write ? 'allowed' : (_global.currentUser?.uuid ? 'no_permission' : 'not_logged_in')}}",
|
||||
},
|
||||
cases: {
|
||||
allowed: {
|
||||
handler: 'navigate',
|
||||
params: { path: '/board/{{route.slug}}/write' },
|
||||
},
|
||||
no_permission: {
|
||||
handler: 'toast',
|
||||
params: { type: 'warning', message: '글쓰기 권한이 없습니다' },
|
||||
},
|
||||
not_logged_in: {
|
||||
handler: 'sequence',
|
||||
actions: [
|
||||
{
|
||||
handler: 'toast',
|
||||
params: { type: 'info', message: '글을 작성하려면 로그인이 필요합니다' },
|
||||
},
|
||||
{
|
||||
handler: 'navigate',
|
||||
params: {
|
||||
path: '/login',
|
||||
query: { redirect: '/board/{{route.slug}}/write' },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
children: [
|
||||
{ type: 'basic', name: 'Icon', props: { name: 'pencil', size: 'sm' } },
|
||||
{ type: 'basic', name: 'Span', text: '글쓰기' },
|
||||
],
|
||||
},
|
||||
{
|
||||
comment: '빈 페이지 (page > 1 + 데이터 0건)',
|
||||
type: 'basic',
|
||||
name: 'Div',
|
||||
if: '{{posts?.data?.board?.slug && query.page && Number(query.page) > 1 && posts?.data?.data?.length === 0}}',
|
||||
props: {
|
||||
className: 'flex flex-col items-center justify-center py-16 text-center bg-gray-100/70 dark:bg-gray-800/50 rounded-xl',
|
||||
'data-testid': 'empty-page',
|
||||
},
|
||||
children: [
|
||||
{ type: 'basic', name: 'P', text: '해당 페이지에 게시글이 없습니다' },
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'Button',
|
||||
text: '첫 페이지로 이동',
|
||||
props: { 'data-testid': 'go-first-btn' },
|
||||
actions: [
|
||||
{
|
||||
type: 'click',
|
||||
handler: 'navigate',
|
||||
params: { path: '/board/{{route.slug}}' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
comment: '게시글 없음 (검색/카테고리 아닐 때)',
|
||||
type: 'basic',
|
||||
name: 'Div',
|
||||
if: "{{posts?.data?.board?.slug && !query.search && !query.category && (!query.page || Number(query.page) <= 1) && posts?.data?.pagination?.total === 0}}",
|
||||
props: {
|
||||
className: 'flex flex-col items-center justify-center py-16 text-center bg-gray-100/70 dark:bg-gray-800/50 rounded-xl',
|
||||
'data-testid': 'empty-no-posts',
|
||||
},
|
||||
children: [
|
||||
{ type: 'basic', name: 'P', text: '등록된 게시글이 없습니다' },
|
||||
],
|
||||
},
|
||||
{
|
||||
comment: '검색 결과 없음',
|
||||
type: 'basic',
|
||||
name: 'Div',
|
||||
if: '{{posts?.data?.board?.slug && (query.search || query.category) && posts?.data?.pagination?.total === 0}}',
|
||||
props: {
|
||||
className: 'flex flex-col items-center justify-center py-16 text-center bg-gray-100/70 dark:bg-gray-800/50 rounded-xl',
|
||||
'data-testid': 'empty-search',
|
||||
},
|
||||
children: [
|
||||
{ type: 'basic', name: 'P', text: '검색 결과가 없습니다' },
|
||||
{
|
||||
type: 'basic',
|
||||
name: 'Button',
|
||||
text: '검색 초기화',
|
||||
props: { 'data-testid': 'clear-search-btn' },
|
||||
actions: [
|
||||
{
|
||||
type: 'click',
|
||||
handler: 'navigate',
|
||||
params: { path: '/board/{{route.slug}}' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
comment: '페이지네이션',
|
||||
type: 'composite',
|
||||
name: 'Pagination',
|
||||
props: {
|
||||
currentPage: '{{posts?.data?.pagination?.current_page ?? 1}}',
|
||||
totalPages: '{{posts?.data?.pagination?.last_page ?? 1}}',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
function findByIfPattern(node: any, pattern: string): any | null {
|
||||
if (!node) return null;
|
||||
if (typeof node.if === 'string' && node.if.includes(pattern)) return node;
|
||||
if (Array.isArray(node.children)) {
|
||||
for (const child of node.children) {
|
||||
const found = findByIfPattern(child, pattern);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 테스트 데이터
|
||||
// ============================================================
|
||||
/**
|
||||
* 컴포넌트 트리에서 text 가 특정 i18n 키를 포함하는 노드를 모두 찾는다.
|
||||
*/
|
||||
function findAllByText(node: any, textPattern: string): any[] {
|
||||
const results: any[] = [];
|
||||
if (!node) return results;
|
||||
if (typeof node.text === 'string' && node.text.includes(textPattern)) results.push(node);
|
||||
if (Array.isArray(node.children)) {
|
||||
for (const child of node.children) {
|
||||
results.push(...findAllByText(child, textPattern));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/** 게시글이 있는 기본 응답 */
|
||||
const boardWithPostsResponse = {
|
||||
data: {
|
||||
board: {
|
||||
id: 1,
|
||||
slug: 'test-board',
|
||||
name: '테스트 게시판',
|
||||
type: 'basic',
|
||||
categories: [],
|
||||
},
|
||||
data: [
|
||||
{ id: 1, title: '첫 번째 글' },
|
||||
{ id: 2, title: '두 번째 글' },
|
||||
],
|
||||
pagination: { current_page: 1, last_page: 2, total: 15 },
|
||||
permissions: { posts_write: true },
|
||||
},
|
||||
};
|
||||
/**
|
||||
* 컴포넌트 트리에서 name 이 일치하는 첫 노드를 찾는다.
|
||||
*/
|
||||
function findByName(node: any, name: string): any | null {
|
||||
if (!node) return null;
|
||||
if (node.name === name) return node;
|
||||
if (Array.isArray(node.children)) {
|
||||
for (const child of node.children) {
|
||||
const found = findByName(child, name);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 게시글이 없는 응답 (total=0) */
|
||||
const emptyBoardResponse = {
|
||||
data: {
|
||||
board: {
|
||||
id: 1,
|
||||
slug: 'test-board',
|
||||
name: '테스트 게시판',
|
||||
type: 'basic',
|
||||
categories: [],
|
||||
},
|
||||
data: [],
|
||||
pagination: { current_page: 1, last_page: 1, total: 0 },
|
||||
permissions: { posts_write: true },
|
||||
},
|
||||
};
|
||||
describe('게시판 목록 - 빈 상태 / 로딩 / 오류 (JSON 구조 검증)', () => {
|
||||
describe('빈 상태 3종 조건부 렌더링 (_empty_states.json)', () => {
|
||||
it('빈 페이지 (page > 1 + total 0건) 분기가 정의되어 있다', () => {
|
||||
const node = findByIfPattern(emptyStatesPartial, 'query.page');
|
||||
expect(node).not.toBeNull();
|
||||
expect(node.if).toContain('Number(query.page) > 1');
|
||||
expect(node.if).toContain("posts?.data?.data?.length === 0");
|
||||
// "처음으로" 이동 버튼이 함께 존재
|
||||
const goFirstBtn = findByName(node, 'Button');
|
||||
expect(goFirstBtn).not.toBeNull();
|
||||
expect(goFirstBtn.text).toContain('go_to_first_page');
|
||||
expect(goFirstBtn.actions[0].handler).toBe('navigate');
|
||||
expect(goFirstBtn.actions[0].params.path).toContain('/board/');
|
||||
});
|
||||
|
||||
/** page > 1이면서 데이터 0건인 응답 */
|
||||
const emptyPageResponse = {
|
||||
data: {
|
||||
board: {
|
||||
id: 1,
|
||||
slug: 'test-board',
|
||||
name: '테스트 게시판',
|
||||
type: 'basic',
|
||||
categories: [],
|
||||
},
|
||||
data: [],
|
||||
pagination: { current_page: 5, last_page: 3, total: 25 },
|
||||
permissions: { posts_write: true },
|
||||
},
|
||||
};
|
||||
it('게시글 없음 (검색/카테고리 없이 total === 0) 분기가 정의되어 있다', () => {
|
||||
const node = findByIfPattern(emptyStatesPartial, '!query.search');
|
||||
expect(node).not.toBeNull();
|
||||
expect(node.if).toContain('!query.category');
|
||||
expect(node.if).toContain('posts?.data?.pagination?.total === 0');
|
||||
// "게시글 없음" 안내 텍스트
|
||||
const noPostsTexts = findAllByText(node, 'no_posts');
|
||||
expect(noPostsTexts.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
/** 글쓰기 권한 없는 응답 (로그인 상태) */
|
||||
const boardNoWritePermResponse = {
|
||||
data: {
|
||||
board: {
|
||||
id: 1,
|
||||
slug: 'test-board',
|
||||
name: '테스트 게시판',
|
||||
type: 'basic',
|
||||
categories: [],
|
||||
},
|
||||
data: [{ id: 1, title: '글1' }],
|
||||
pagination: { current_page: 1, last_page: 1, total: 1 },
|
||||
permissions: { posts_write: false },
|
||||
},
|
||||
};
|
||||
it('검색 결과 없음 (search 또는 category + total === 0) 분기가 정의되어 있다', () => {
|
||||
const node = findByIfPattern(emptyStatesPartial, '(query.search || query.category)');
|
||||
expect(node).not.toBeNull();
|
||||
expect(node.if).toContain('posts?.data?.pagination?.total === 0');
|
||||
// "검색 결과 없음" 안내 텍스트 + 검색 초기화 버튼
|
||||
const noResultsTexts = findAllByText(node, 'no_search_results');
|
||||
expect(noResultsTexts.length).toBeGreaterThanOrEqual(1);
|
||||
const clearBtn = findByName(node, 'Button');
|
||||
expect(clearBtn).not.toBeNull();
|
||||
expect(clearBtn.text).toContain('clear_search');
|
||||
expect(clearBtn.actions[0].handler).toBe('navigate');
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// 테스트
|
||||
// ============================================================
|
||||
it('세 분기는 서로 배타적인 if 조건을 사용한다 (page>1 / 검색없음 / 검색있음)', () => {
|
||||
const branches = emptyStatesPartial.children.filter((c: any) => typeof c.if === 'string');
|
||||
expect(branches.length).toBe(3);
|
||||
|
||||
describe('게시판 목록 - 빈 상태/로딩/오류/글쓰기 버튼', () => {
|
||||
let registry: ComponentRegistry;
|
||||
|
||||
beforeEach(() => {
|
||||
registry = setupTestRegistry();
|
||||
});
|
||||
|
||||
describe('로딩 스켈레톤 표시 조건', () => {
|
||||
it('데이터 로드 전 + 오류 없음: 로딩 스켈레톤 표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
initialData: {},
|
||||
initGlobal: { hasError: false },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('loading-skeleton')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('error-page')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('board-title')).not.toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
const conditions = branches.map((b: any) => b.if);
|
||||
// 정확히 하나의 분기가 query.page > 1 을 포함
|
||||
expect(conditions.filter((c: string) => c.includes('Number(query.page) > 1')).length).toBe(1);
|
||||
// 정확히 하나의 분기가 검색/카테고리 없음
|
||||
expect(conditions.filter((c: string) => c.includes('!query.search')).length).toBe(1);
|
||||
// 정확히 하나의 분기가 검색/카테고리 있음
|
||||
expect(conditions.filter((c: string) => c.includes('(query.search || query.category)')).length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('데이터 로드 완료: 로딩 스켈레톤 미표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
initialData: { posts: boardWithPostsResponse },
|
||||
});
|
||||
describe('로딩 / 오류 표시 조건 (_loading_error.json)', () => {
|
||||
it('로딩 분기가 !posts.data.board && !_global.hasError 조건으로 정의된다', () => {
|
||||
const loading = findByIfPattern(loadingErrorPartial, '!posts?.data?.board');
|
||||
expect(loading).not.toBeNull();
|
||||
expect(loading.if).toContain('!_global.hasError');
|
||||
// 로딩 분기에 '$t:board.loading_posts' 메시지 노출
|
||||
const loadingTexts = findAllByText(loading, 'loading_posts');
|
||||
expect(loadingTexts.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
it('오류 분기가 _global.hasError 조건으로 정의되며 새로고침 버튼을 가진다', () => {
|
||||
// 로딩 분기도 !_global.hasError 를 포함하므로, 부정 키워드(!) 없는
|
||||
// 오류 전용 분기를 children 에서 직접 식별
|
||||
const errorNode = loadingErrorPartial.children.find(
|
||||
(c: any) => typeof c.if === 'string'
|
||||
&& c.if.includes('_global.hasError')
|
||||
&& !c.if.includes('!_global.hasError'),
|
||||
);
|
||||
expect(errorNode).toBeDefined();
|
||||
// 오류 제목 + 설명 i18n 키
|
||||
const titleTexts = findAllByText(errorNode, 'error_title');
|
||||
expect(titleTexts.length).toBeGreaterThanOrEqual(1);
|
||||
const descTexts = findAllByText(errorNode, 'error_description');
|
||||
expect(descTexts.length).toBeGreaterThanOrEqual(1);
|
||||
// 새로고침 버튼 (refresh handler)
|
||||
const reloadBtn = findByName(errorNode, 'Button');
|
||||
expect(reloadBtn).not.toBeNull();
|
||||
expect(reloadBtn.actions[0].handler).toBe('refresh');
|
||||
});
|
||||
|
||||
expect(screen.queryByTestId('loading-skeleton')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('board-title')).toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
});
|
||||
|
||||
describe('오류 페이지 표시 조건', () => {
|
||||
it('_global.hasError가 true: 오류 페이지 표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
initialData: {},
|
||||
initGlobal: { hasError: true },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('error-page')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('error-title')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('reload-btn')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('loading-skeleton')).not.toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
});
|
||||
|
||||
describe('빈 상태 3종 조건부 렌더링', () => {
|
||||
it('게시글 없음 (검색/카테고리 없이 total=0): empty-no-posts 표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
initialData: { posts: emptyBoardResponse },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('empty-no-posts')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('empty-search')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('empty-page')).not.toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
it('로딩과 오류 분기는 서로 배타적이다 (오류 시 로딩 미표시)', () => {
|
||||
const branches = loadingErrorPartial.children.filter((c: any) => typeof c.if === 'string');
|
||||
expect(branches.length).toBe(2);
|
||||
const loadingBranch = branches.find((b: any) => b.if.includes('!_global.hasError'));
|
||||
const errorBranch = branches.find((b: any) =>
|
||||
b.if.includes('_global.hasError') && !b.if.includes('!_global.hasError')
|
||||
);
|
||||
expect(loadingBranch).toBeDefined();
|
||||
expect(errorBranch).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
it('검색 결과 없음 (query.search 있고 total=0): empty-search 표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
queryParams: { search: '존재하지않는검색어' },
|
||||
initialData: { posts: emptyBoardResponse },
|
||||
});
|
||||
describe('글쓰기 버튼 권한 분기 (_write_button.json)', () => {
|
||||
it('글쓰기 버튼이 정의되어 있고 i18n 텍스트와 아이콘을 포함한다', () => {
|
||||
// _write_button.json 의 최상위 또는 children 어딘가에 Button + write 텍스트
|
||||
const writeBtn = findByName(writeButtonPartial, 'Button');
|
||||
expect(writeBtn).not.toBeNull();
|
||||
// pencil 아이콘 또는 write 관련 i18n 텍스트 존재
|
||||
const iconNode = findByName(writeBtn, 'Icon');
|
||||
expect(iconNode).not.toBeNull();
|
||||
expect(typeof iconNode.props?.name).toBe('string');
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('empty-search')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('empty-no-posts')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('clear-search-btn')).toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
it('글쓰기 권한이 없거나 비로그인 시 분기 노출 (if 표현식 존재)', () => {
|
||||
// can_write 또는 currentUser 등 권한/인증 분기가 어딘가 있어야 함
|
||||
const ifPatterns = JSON.stringify(writeButtonPartial);
|
||||
const hasAuthBranch = /(can_write|currentUser|abilities)/.test(ifPatterns);
|
||||
expect(hasAuthBranch).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('카테고리 필터 결과 없음 (query.category 있고 total=0): empty-search 표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
queryParams: { category: '존재하지않는카테고리' },
|
||||
initialData: { posts: emptyBoardResponse },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('empty-search')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('empty-no-posts')).not.toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
|
||||
it('빈 페이지 (page > 1 + data 0건): empty-page 표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
queryParams: { page: '5' },
|
||||
initialData: { posts: emptyPageResponse },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('empty-page')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('go-first-btn')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('empty-no-posts')).not.toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
|
||||
it('게시글이 있을 때 빈 상태 모두 미표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
initialData: { posts: boardWithPostsResponse },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('empty-no-posts')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('empty-search')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('empty-page')).not.toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
});
|
||||
|
||||
describe('빈 상태 배경 스타일 일관성', () => {
|
||||
it('모든 빈 상태 컴포넌트가 동일한 배경 클래스를 가진다', () => {
|
||||
const expectedBgClass = 'bg-gray-100/70 dark:bg-gray-800/50 rounded-xl';
|
||||
const mainContainer = boardIndexLayoutJson.components[2];
|
||||
const children = mainContainer.children;
|
||||
|
||||
// 빈 페이지, 게시글 없음, 검색 결과 없음 3개 컴포넌트 확인
|
||||
const emptyPageComp = children.find(
|
||||
(c: any) => c.props?.['data-testid'] === 'empty-page'
|
||||
);
|
||||
const emptyNoPostsComp = children.find(
|
||||
(c: any) => c.props?.['data-testid'] === 'empty-no-posts'
|
||||
);
|
||||
const emptySearchComp = children.find(
|
||||
(c: any) => c.props?.['data-testid'] === 'empty-search'
|
||||
);
|
||||
|
||||
expect(emptyPageComp?.props?.className).toContain(expectedBgClass);
|
||||
expect(emptyNoPostsComp?.props?.className).toContain(expectedBgClass);
|
||||
expect(emptySearchComp?.props?.className).toContain(expectedBgClass);
|
||||
});
|
||||
});
|
||||
|
||||
describe('글쓰기 버튼 switch 핸들러', () => {
|
||||
it('글쓰기 권한 있을 때 switch value가 "allowed"', () => {
|
||||
// 정적 구조 검증: switch value 표현식 확인
|
||||
const mainContainer = boardIndexLayoutJson.components[2];
|
||||
const writeBtn = mainContainer.children.find(
|
||||
(c: any) => c.props?.['data-testid'] === 'write-btn'
|
||||
);
|
||||
|
||||
expect(writeBtn).toBeDefined();
|
||||
expect(writeBtn.actions[0].handler).toBe('switch');
|
||||
expect(writeBtn.actions[0].cases).toHaveProperty('allowed');
|
||||
expect(writeBtn.actions[0].cases).toHaveProperty('no_permission');
|
||||
expect(writeBtn.actions[0].cases).toHaveProperty('not_logged_in');
|
||||
});
|
||||
|
||||
it('allowed 케이스: navigate 핸들러로 글쓰기 페이지 이동', () => {
|
||||
const mainContainer = boardIndexLayoutJson.components[2];
|
||||
const writeBtn = mainContainer.children.find(
|
||||
(c: any) => c.props?.['data-testid'] === 'write-btn'
|
||||
);
|
||||
|
||||
const allowedCase = writeBtn.actions[0].cases.allowed;
|
||||
expect(allowedCase.handler).toBe('navigate');
|
||||
expect(allowedCase.params.path).toBe('/board/{{route.slug}}/write');
|
||||
});
|
||||
|
||||
it('no_permission 케이스: toast warning 표시', () => {
|
||||
const mainContainer = boardIndexLayoutJson.components[2];
|
||||
const writeBtn = mainContainer.children.find(
|
||||
(c: any) => c.props?.['data-testid'] === 'write-btn'
|
||||
);
|
||||
|
||||
const noPermCase = writeBtn.actions[0].cases.no_permission;
|
||||
expect(noPermCase.handler).toBe('toast');
|
||||
expect(noPermCase.params.type).toBe('warning');
|
||||
});
|
||||
|
||||
it('not_logged_in 케이스: sequence로 toast + navigate (로그인 페이지)', () => {
|
||||
const mainContainer = boardIndexLayoutJson.components[2];
|
||||
const writeBtn = mainContainer.children.find(
|
||||
(c: any) => c.props?.['data-testid'] === 'write-btn'
|
||||
);
|
||||
|
||||
const notLoggedInCase = writeBtn.actions[0].cases.not_logged_in;
|
||||
expect(notLoggedInCase.handler).toBe('sequence');
|
||||
expect(notLoggedInCase.actions).toHaveLength(2);
|
||||
expect(notLoggedInCase.actions[0].handler).toBe('toast');
|
||||
expect(notLoggedInCase.actions[1].handler).toBe('navigate');
|
||||
expect(notLoggedInCase.actions[1].params.path).toBe('/login');
|
||||
expect(notLoggedInCase.actions[1].params.query.redirect).toBe(
|
||||
'/board/{{route.slug}}/write'
|
||||
);
|
||||
});
|
||||
|
||||
it('글쓰기 버튼에 pencil 아이콘과 텍스트가 있다', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
initialData: { posts: boardWithPostsResponse },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
const writeBtn = screen.queryByTestId('write-btn');
|
||||
expect(writeBtn).toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
});
|
||||
|
||||
describe('페이지네이션 항상 표시', () => {
|
||||
it('게시글이 있을 때 페이지네이션 표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
initialData: { posts: boardWithPostsResponse },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('pagination')).toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
|
||||
it('게시글이 없을 때도 페이지네이션 표시', async () => {
|
||||
const testUtils = createLayoutTest(boardIndexLayoutJson, {
|
||||
componentRegistry: registry,
|
||||
routeParams: { slug: 'test-board' },
|
||||
initialData: { posts: emptyBoardResponse },
|
||||
});
|
||||
|
||||
await testUtils.render();
|
||||
|
||||
expect(screen.queryByTestId('pagination')).toBeInTheDocument();
|
||||
|
||||
testUtils.cleanup();
|
||||
});
|
||||
});
|
||||
});
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 게시판 모듈 레이아웃 — 활성 언어팩 locale fallback 회귀 테스트
|
||||
*
|
||||
* 이슈 #263 후속 — 활성 언어팩(ja 등) 환경에서 새로고침 직후 _global.locale 미동기 시점에
|
||||
* `?? 'ko'` 하드코딩 fallback 으로 인해 ja 환경에서도 ko 라벨이 표시되던 회귀 차단.
|
||||
*
|
||||
* 검증 대상 (4 파일):
|
||||
* - _tab_basic.json (게시판 폼 — board_types 옵션 라벨)
|
||||
* - _tab_board_settings_basic.json (게시판 설정 — board_types 옵션 라벨)
|
||||
* - _board_type_manage_modal.json (게시판 타입 관리 모달 — 이름 표시)
|
||||
* - _tab_basic_defaults.json (기본값 탭 — board_types 옵션 라벨)
|
||||
*
|
||||
* 참조 패턴: sirsoft-page admin_page_detail.json 의 `_local.lang ?? $locale ?? 'ko'`
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import tabBasic from '../../../layouts/admin/partials/admin_board_form/_tab_basic.json';
|
||||
import tabBoardSettingsBasic from '../../../layouts/admin/partials/admin_board_settings/_tab_board_settings_basic.json';
|
||||
import boardTypeManageModal from '../../../layouts/admin/partials/admin_board_form/_board_type_manage_modal.json';
|
||||
import tabBasicDefaults from '../../../layouts/admin/partials/admin_board_settings/_tab_basic_defaults.json';
|
||||
|
||||
const layouts: Array<[string, unknown]> = [
|
||||
['_tab_basic.json', tabBasic],
|
||||
['_tab_board_settings_basic.json', tabBoardSettingsBasic],
|
||||
['_board_type_manage_modal.json', boardTypeManageModal],
|
||||
['_tab_basic_defaults.json', tabBasicDefaults],
|
||||
];
|
||||
|
||||
describe('게시판 모듈 — locale fallback 하드코딩 회귀 가드', () => {
|
||||
it.each(layouts)("%s — _global.locale fallback 이 정적 'ko' 가 아닌 $locale 을 우선 사용함", (_name, layout) => {
|
||||
const layoutStr = JSON.stringify(layout);
|
||||
// 단순 `_global.locale ?? 'ko'` 형태 금지 — 활성 언어팩 환경에서 ja 가 아닌 ko 라벨로 표시되는 회귀 발생
|
||||
expect(layoutStr).not.toMatch(/_global\.locale \?\? 'ko'/);
|
||||
});
|
||||
});
|
||||
-12
@@ -24,9 +24,6 @@ import postForm from '../../../../../../../templates/_bundled/sirsoft-basic/layo
|
||||
import typeRenderer from '../../../../../../../templates/_bundled/sirsoft-basic/layouts/partials/board/form/_type_renderer.json';
|
||||
import passwordVerifyModal from '../../../../../../../templates/_bundled/sirsoft-basic/layouts/partials/board/form/_password_verify_modal.json';
|
||||
|
||||
// === Shop QnA (게시판 abilities 사용) ===
|
||||
import tabQna from '../../../../../../../templates/_bundled/sirsoft-basic/layouts/partials/shop/detail/_tab_qna.json';
|
||||
|
||||
// === Board Index 타입별 ===
|
||||
import galleryIndex from '../../../../../../../templates/_bundled/sirsoft-basic/layouts/partials/board/types/gallery/index.json';
|
||||
|
||||
@@ -97,7 +94,6 @@ const allBoardLayouts: Array<{ name: string; json: unknown }> = [
|
||||
{ name: 'form/_post_form.json', json: postForm },
|
||||
{ name: 'form/_type_renderer.json', json: typeRenderer },
|
||||
{ name: 'form/_password_verify_modal.json', json: passwordVerifyModal },
|
||||
{ name: 'shop/detail/_tab_qna.json', json: tabQna },
|
||||
{ name: 'types/gallery/index.json', json: galleryIndex },
|
||||
];
|
||||
|
||||
@@ -264,14 +260,6 @@ describe('게시판 사용자 레이아웃 abilities 키 마이그레이션 검
|
||||
expect(canManage.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('shop/detail/_tab_qna.json: abilities?.can_write 표현식 포함', () => {
|
||||
const expressions = findExpressionsInJson(tabQna);
|
||||
const canWrite = findExpressionsContaining(
|
||||
expressions,
|
||||
'abilities?.can_write'
|
||||
);
|
||||
expect(canWrite.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findExpressionsInJson 헬퍼 정합성 검증', () => {
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* 게시판 환경설정 > 본인인증 정책 탭 — 삭제 핸들러 회귀 테스트.
|
||||
*
|
||||
* 회귀 사례 (#297):
|
||||
* 삭제 버튼이 등록되지 않은 `confirm` 핸들러를 호출하여 "Unknown action handler: confirm" 토스트
|
||||
* 에러로 삭제 자체가 실행되지 않던 문제. setState + openModal 시퀀스 + 별도 확인 모달 패턴으로 교체.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
const tabPartial = require('../../../layouts/admin/partials/admin_board_settings/_tab_identity_policies.json');
|
||||
const deleteModal = require('../../../layouts/admin/partials/admin_board_settings/_modal_identity_policy_delete.json');
|
||||
const settingsLayout = require('../../../layouts/admin/admin_board_settings.json');
|
||||
|
||||
function collectNodes(node: any, predicate: (n: any) => boolean): any[] {
|
||||
const result: any[] = [];
|
||||
const visit = (n: any) => {
|
||||
if (!n || typeof n !== 'object') return;
|
||||
if (Array.isArray(n)) {
|
||||
n.forEach(visit);
|
||||
return;
|
||||
}
|
||||
if (predicate(n)) result.push(n);
|
||||
if (n.children) visit(n.children);
|
||||
if (n.actions) visit(n.actions);
|
||||
if (n.params) visit(n.params);
|
||||
if (n.onSuccess) visit(n.onSuccess);
|
||||
if (n.onError) visit(n.onError);
|
||||
};
|
||||
visit(node);
|
||||
return result;
|
||||
}
|
||||
|
||||
describe('게시판 본인인증 정책 삭제 — confirm 핸들러 미사용, 모달 + 스피너 패턴 (#297)', () => {
|
||||
it('탭 partial 에 confirm 핸들러가 존재하지 않는다', () => {
|
||||
expect(JSON.stringify(tabPartial)).not.toMatch(/"handler"\s*:\s*"confirm"/);
|
||||
});
|
||||
|
||||
it('삭제 버튼은 setState boardIdentityPolicyDeleteId + openModal board_identity_policy_delete_modal 시퀀스 사용 (PC + 모바일)', () => {
|
||||
const sequences = collectNodes(tabPartial, (n) => n.handler === 'sequence');
|
||||
const deleteSequences = sequences.filter((seq) => {
|
||||
const actions = seq.actions ?? [];
|
||||
const hasSetDeleteId = actions.some(
|
||||
(a: any) =>
|
||||
a.handler === 'setState' && a.params?.boardIdentityPolicyDeleteId !== undefined,
|
||||
);
|
||||
const hasOpenDeleteModal = actions.some(
|
||||
(a: any) =>
|
||||
a.handler === 'openModal' && a.target === 'board_identity_policy_delete_modal',
|
||||
);
|
||||
return hasSetDeleteId && hasOpenDeleteModal;
|
||||
});
|
||||
expect(deleteSequences.length).toBeGreaterThanOrEqual(2);
|
||||
});
|
||||
|
||||
it('삭제 모달이 부모 레이아웃의 modals 배열에 등록되어 있다', () => {
|
||||
const partials = (settingsLayout.modals ?? []).map((m: any) => m.partial);
|
||||
expect(partials).toContain('partials/admin_board_settings/_modal_identity_policy_delete.json');
|
||||
});
|
||||
|
||||
it('삭제 모달은 boardIdentityPolicyDeleteId 를 사용한 DELETE API 호출 + boardIdentityPolicies 데이터소스 refetch 를 수행', () => {
|
||||
const apiCalls = collectNodes(deleteModal, (n) => n.handler === 'apiCall');
|
||||
const matching = apiCalls.find(
|
||||
(c) =>
|
||||
typeof c.target === 'string' &&
|
||||
c.target.includes('{{_global.boardIdentityPolicyDeleteId}}') &&
|
||||
c.params?.method === 'DELETE',
|
||||
);
|
||||
expect(matching).toBeTruthy();
|
||||
|
||||
const refetches = collectNodes(matching, (n) => n.handler === 'refetchDataSource');
|
||||
expect(refetches.some((r) => r.params?.dataSourceId === 'boardIdentityPolicies')).toBe(true);
|
||||
});
|
||||
|
||||
it('삭제 모달은 _global.boardIdentityPolicyDeleting 기준으로 disabled + 스피너 노출', () => {
|
||||
const stringified = JSON.stringify(deleteModal);
|
||||
expect(stringified).toMatch(/_global\.boardIdentityPolicyDeleting/);
|
||||
const icons = collectNodes(deleteModal, (n) => n.name === 'Icon' && n.props?.name === 'spinner');
|
||||
expect(icons.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 본인인증 정책 데이터소스/네비게이션의 source_identifier 형식 회귀 테스트.
|
||||
*
|
||||
* 회귀 사례 (#297): 모듈 본인인증 정책 탭에서 데이터소스가
|
||||
* `source_identifier: "module:sirsoft-board"` (잘못된 접두사 포함) 으로 필터하여
|
||||
* DB 의 `source_identifier='sirsoft-board'` (모듈 식별자만 저장) 와 매칭되지 않아
|
||||
* 정책 목록이 항상 비어있던 문제.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
const settingsLayout = require('../../../layouts/admin/admin_board_settings.json');
|
||||
const identityPoliciesPartial = require('../../../layouts/admin/partials/admin_board_settings/_tab_identity_policies.json');
|
||||
|
||||
const MODULE_IDENTIFIER = 'sirsoft-board';
|
||||
const FORBIDDEN_PREFIX_VALUE = `module:${MODULE_IDENTIFIER}`;
|
||||
|
||||
function findValuesByKey(node: any, targetKey: string, results: string[] = []): string[] {
|
||||
if (!node || typeof node !== 'object') return results;
|
||||
if (Array.isArray(node)) {
|
||||
node.forEach((n) => findValuesByKey(n, targetKey, results));
|
||||
return results;
|
||||
}
|
||||
for (const [k, v] of Object.entries(node)) {
|
||||
if (k === targetKey && typeof v === 'string') results.push(v);
|
||||
if (v && typeof v === 'object') findValuesByKey(v, targetKey, results);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
describe('게시판 본인인증 정책 — source_identifier 형식 회귀 (#297)', () => {
|
||||
it('데이터소스 source_identifier 는 모듈 식별자만 사용 (module: 접두사 금지)', () => {
|
||||
const ds = (settingsLayout.data_sources ?? []).find(
|
||||
(d: any) => d.id === 'boardIdentityPolicies'
|
||||
);
|
||||
// 데이터소스가 정의되어 있다면 형식 검증
|
||||
if (ds) {
|
||||
expect(ds.params?.source_identifier).toBe(MODULE_IDENTIFIER);
|
||||
}
|
||||
});
|
||||
|
||||
it('partial 내 모든 source_identifier 등장은 모듈 식별자 형식만 허용', () => {
|
||||
const all = [
|
||||
...findValuesByKey(settingsLayout, 'source_identifier'),
|
||||
...findValuesByKey(identityPoliciesPartial, 'source_identifier'),
|
||||
];
|
||||
expect(all.length).toBeGreaterThan(0);
|
||||
for (const v of all) {
|
||||
expect(v).toBe(MODULE_IDENTIFIER);
|
||||
}
|
||||
expect(JSON.stringify({ settingsLayout, identityPoliciesPartial }))
|
||||
.not.toContain(FORBIDDEN_PREFIX_VALUE);
|
||||
});
|
||||
});
|
||||
@@ -14,7 +14,8 @@
|
||||
"spam_security": "Security",
|
||||
"seo": "SEO Settings",
|
||||
"mail_templates": "Mail Templates",
|
||||
"notification_definitions": "Notification Settings"
|
||||
"notification_definitions": "Notification Settings",
|
||||
"identity_policies": "Identity Policies"
|
||||
},
|
||||
"board_settings_tabs": {
|
||||
"basic": "Basic",
|
||||
@@ -113,6 +114,16 @@
|
||||
"notify_admin_on_report_scope": "Notification Scope",
|
||||
"notify_admin_on_report_scope_per_case": "First report only (per post/comment)",
|
||||
"notify_admin_on_report_scope_per_report": "Every time a report is submitted",
|
||||
"notify_admin_on_report_channels": "Notification Channels",
|
||||
"notify_admin_on_report_channels_placeholder": "Select channels",
|
||||
"notify_admin_on_report_channels_help": "Admin notifications will be sent through the selected channels",
|
||||
"notify_author_on_report_action_channels": "Notification Channels",
|
||||
"notify_author_on_report_action_channels_placeholder": "Select channels",
|
||||
"notify_author_on_report_action_channels_help": "Author notifications will be sent through the selected channels",
|
||||
"notification_channels": {
|
||||
"mail": "Email",
|
||||
"database": "Site Notification"
|
||||
},
|
||||
"report_view_roles": "View Reports Permission",
|
||||
"report_view_roles_description": "Permission to view the report list and report details.",
|
||||
"report_manage_roles": "Process Reports Permission",
|
||||
@@ -389,5 +400,41 @@
|
||||
"subject_label": "Subject",
|
||||
"body_label": "Body"
|
||||
}
|
||||
},
|
||||
"identity": {
|
||||
"intro_title": "Board Identity Verification Policies",
|
||||
"intro": "Manage policies declared by the board module and policies added by operators. Module default policies allow only enabled/grace adjustments; operator-defined policies can be freely edited or removed in core settings.",
|
||||
"purposes_section_title": "Identity Purposes Registered by This Module",
|
||||
"purposes_section_description": "Purposes declared by the board module. Selectable in the policy \"Purpose\" column.",
|
||||
"purposes_empty": "No identity purposes registered by this module.",
|
||||
"list_title": "Policy List",
|
||||
"add_policy": "Add Policy",
|
||||
"empty": "No policies registered.",
|
||||
"edit": "Edit",
|
||||
"grace_minutes": "{minutes} min",
|
||||
"enable_success": "Policy enabled.",
|
||||
"disable_success": "Policy disabled.",
|
||||
"toggle_failed": "Failed to update policy state.",
|
||||
"col": {
|
||||
"key": "Key",
|
||||
"scope": "Scope",
|
||||
"target": "Target",
|
||||
"purpose": "Purpose",
|
||||
"enabled": "Enabled",
|
||||
"grace": "Grace",
|
||||
"source": "Source",
|
||||
"actions": "Actions"
|
||||
},
|
||||
"scope": {
|
||||
"route": "Route",
|
||||
"hook": "Hook",
|
||||
"custom": "Custom"
|
||||
},
|
||||
"source": {
|
||||
"core": "Core",
|
||||
"module": "Module",
|
||||
"plugin": "Plugin",
|
||||
"admin": "Admin"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,8 @@
|
||||
"spam_security": "보안 설정",
|
||||
"mail_templates": "메일 템플릿",
|
||||
"notification_definitions": "알림 설정",
|
||||
"seo": "SEO 설정"
|
||||
"seo": "SEO 설정",
|
||||
"identity_policies": "본인인증 정책"
|
||||
},
|
||||
"board_settings_tabs": {
|
||||
"basic": "기본",
|
||||
@@ -113,6 +114,16 @@
|
||||
"notify_admin_on_report_scope": "알림 발송 범위",
|
||||
"notify_admin_on_report_scope_per_case": "게시글\/댓글당 최초 1회만",
|
||||
"notify_admin_on_report_scope_per_report": "신고가 접수될 때마다",
|
||||
"notify_admin_on_report_channels": "알림 채널",
|
||||
"notify_admin_on_report_channels_placeholder": "채널 선택",
|
||||
"notify_admin_on_report_channels_help": "선택한 채널로 관리자 알림이 발송됩니다",
|
||||
"notify_author_on_report_action_channels": "알림 채널",
|
||||
"notify_author_on_report_action_channels_placeholder": "채널 선택",
|
||||
"notify_author_on_report_action_channels_help": "선택한 채널로 작성자 알림이 발송됩니다",
|
||||
"notification_channels": {
|
||||
"mail": "이메일",
|
||||
"database": "사이트 알림"
|
||||
},
|
||||
"report_view_roles": "신고 조회 권한",
|
||||
"report_view_roles_description": "신고 목록과 상세 내용을 열람할 수 있는 권한입니다.",
|
||||
"report_manage_roles": "신고 처리 권한",
|
||||
@@ -389,5 +400,41 @@
|
||||
"subject_label": "제목",
|
||||
"body_label": "본문"
|
||||
}
|
||||
},
|
||||
"identity": {
|
||||
"intro_title": "게시판 본인인증 정책",
|
||||
"intro": "게시판 모듈이 선언한 정책과 운영자가 추가한 정책을 관리합니다. 모듈 기본 정책은 활성/유예시간 등 일부만 조정 가능하며, 운영자가 추가한 정책은 코어 환경설정에서 자유롭게 편집·삭제할 수 있습니다.",
|
||||
"purposes_section_title": "이 모듈이 등록한 본인인증 목적",
|
||||
"purposes_section_description": "게시판 모듈이 선언한 본인인증 목적입니다. 정책의 \"인증 목적\" 컬럼에서 선택할 수 있습니다.",
|
||||
"purposes_empty": "이 모듈이 등록한 본인인증 목적이 없습니다.",
|
||||
"list_title": "정책 목록",
|
||||
"add_policy": "정책 추가",
|
||||
"empty": "등록된 정책이 없습니다.",
|
||||
"edit": "편집",
|
||||
"grace_minutes": "{minutes}분",
|
||||
"enable_success": "정책이 활성화되었습니다.",
|
||||
"disable_success": "정책이 비활성화되었습니다.",
|
||||
"toggle_failed": "정책 상태 변경에 실패했습니다.",
|
||||
"col": {
|
||||
"key": "정책 키",
|
||||
"scope": "범위",
|
||||
"target": "대상",
|
||||
"purpose": "목적",
|
||||
"enabled": "활성",
|
||||
"grace": "유예",
|
||||
"source": "출처",
|
||||
"actions": "작업"
|
||||
},
|
||||
"scope": {
|
||||
"route": "라우트",
|
||||
"hook": "훅",
|
||||
"custom": "커스텀"
|
||||
},
|
||||
"source": {
|
||||
"core": "코어",
|
||||
"module": "모듈",
|
||||
"plugin": "플러그인",
|
||||
"admin": "관리자"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@
|
||||
"id": "replies_section",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{(post?.data?.replies ?? []).length > 0}}",
|
||||
"if": "{{(post?.data?.reply_count ?? 0) > 0}}",
|
||||
"children": [
|
||||
{
|
||||
"id": "replies_header",
|
||||
@@ -188,7 +188,7 @@
|
||||
"props": {
|
||||
"className": "text-lg font-semibold text-gray-900 dark:text-white"
|
||||
},
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.replies_title|count={{(post?.data?.replies ?? []).length}}"
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.replies_title|count={{post?.data?.reply_count ?? 0}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -144,6 +144,48 @@
|
||||
"fallback": {
|
||||
"data": { "channels": [] }
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "boardIdentityPolicies",
|
||||
"type": "api",
|
||||
"endpoint": "/api/admin/identity/policies",
|
||||
"method": "GET",
|
||||
"auto_fetch": true,
|
||||
"auth_required": true,
|
||||
"params": {
|
||||
"source_identifier": "sirsoft-board",
|
||||
"source_type": "{{query.source_type ?? ''}}",
|
||||
"scope": "{{query.scope ?? ''}}",
|
||||
"purpose": "{{query.purpose ?? ''}}",
|
||||
"search": "{{query.search ?? ''}}",
|
||||
"page": "{{query.page || 1}}",
|
||||
"per_page": "{{query.per_page || 10}}"
|
||||
},
|
||||
"fallback": {
|
||||
"data": { "data": [], "meta": {} }
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "boardIdentityPurposes",
|
||||
"type": "api",
|
||||
"endpoint": "/api/identity/purposes",
|
||||
"method": "GET",
|
||||
"auto_fetch": true,
|
||||
"auth_required": true,
|
||||
"fallback": {
|
||||
"data": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "identityProviders",
|
||||
"type": "api",
|
||||
"endpoint": "/api/admin/identity/providers",
|
||||
"method": "GET",
|
||||
"auto_fetch": true,
|
||||
"auth_required": true,
|
||||
"fallback": {
|
||||
"data": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"init_actions": [
|
||||
@@ -437,6 +479,10 @@
|
||||
{
|
||||
"id": "notification_definitions",
|
||||
"label": "$t:sirsoft-board.admin.settings.tabs.notification_definitions"
|
||||
},
|
||||
{
|
||||
"id": "identity_policies",
|
||||
"label": "$t:sirsoft-board.admin.settings.tabs.identity_policies"
|
||||
}
|
||||
],
|
||||
"activeTabId": "{{_global.activeBoardSettingsTab || query.tab || 'general'}}",
|
||||
@@ -655,6 +701,9 @@
|
||||
},
|
||||
{
|
||||
"partial": "partials/admin_board_settings/_tab_notification_definitions.json"
|
||||
},
|
||||
{
|
||||
"partial": "partials/admin_board_settings/_tab_identity_policies.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -677,6 +726,12 @@
|
||||
},
|
||||
{
|
||||
"partial": "partials/admin_board_settings/_modal_notification_definition_reset.json"
|
||||
},
|
||||
{
|
||||
"partial": "partials/admin_board_settings/_modal_identity_policy_form.json"
|
||||
},
|
||||
{
|
||||
"partial": "partials/admin_board_settings/_modal_identity_policy_delete.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
+4
-4
@@ -175,7 +175,7 @@
|
||||
"props": {
|
||||
"className": "px-3 py-2 text-sm text-gray-900 dark:text-gray-100"
|
||||
},
|
||||
"text": "{{btItem.name[_global.locale ?? 'ko'] ?? btItem.name.ko ?? btItem.slug}}"
|
||||
"text": "{{btItem.name[_global.locale ?? $locale ?? 'ko'] ?? btItem.name.ko ?? btItem.slug}}"
|
||||
},
|
||||
{
|
||||
"id": "bt_td_actions",
|
||||
@@ -212,7 +212,7 @@
|
||||
"btEditingItem": "{{btItem}}",
|
||||
"btFormMode": "edit",
|
||||
"btFormSlug": "{{btItem.slug}}",
|
||||
"btFormName": "{{typeof btItem.name === 'object' ? btItem.name : {ko: btItem.name ?? '', en: ''}}}",
|
||||
"btFormName": "{{typeof btItem.name === 'object' ? btItem.name : {ko: btItem.name ?? '', en: ''} }}",
|
||||
"btFormErrors": null
|
||||
}
|
||||
}
|
||||
@@ -515,7 +515,7 @@
|
||||
"type": "composite",
|
||||
"name": "MultilingualInput",
|
||||
"props": {
|
||||
"value": "{{_global.btFormName ?? {ko: '', en: ''}}}",
|
||||
"value": "{{_global.btFormName ?? {ko: '', en: ''} }}",
|
||||
"layout": "tabs",
|
||||
"name": "bt_form_name",
|
||||
"placeholder": "$t:sirsoft-board.admin.board_types.name_placeholder",
|
||||
@@ -588,7 +588,7 @@
|
||||
"method": "{{_global.btFormMode === 'edit' ? 'PUT' : 'POST'}}",
|
||||
"body": {
|
||||
"slug": "{{_global.btFormSlug}}",
|
||||
"name": "{{_global.btFormName ?? {ko: '', en: ''}}}"
|
||||
"name": "{{_global.btFormName ?? {ko: '', en: ''} }}"
|
||||
}
|
||||
},
|
||||
"onSuccess": [
|
||||
|
||||
+1
-1
@@ -480,7 +480,7 @@
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"name": "type",
|
||||
"options": "{{boards?.data?.board_types?.map(t => ({value: t.slug, label: (t.name[_global.locale ?? 'ko'] ?? t.name.ko ?? t.slug) + ' (' + t.slug + ')'})) ?? []}}",
|
||||
"options": "{{boards?.data?.board_types?.map(t => ({value: t.slug, label: (t.name[_global.locale ?? $locale ?? 'ko'] ?? t.name.ko ?? t.slug) + ' (' + t.slug + ')'})) ?? []}}",
|
||||
"placeholder": "$t:sirsoft-board.admin.form.placeholders.select_type",
|
||||
"disabled": "{{_computed.isReadOnly}}",
|
||||
"className": "w-full"
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@
|
||||
"props": {
|
||||
"className": "text-lg font-semibold text-gray-900 dark:text-white"
|
||||
},
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.comments_title|count={{(post?.data?.comments ?? []).length}}"
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.comments_title|count={{post?.data?.comment_count ?? 0}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -49,7 +49,7 @@
|
||||
"props": {
|
||||
"className": ""
|
||||
},
|
||||
"if": "{{(post?.data?.comments ?? []).length > 0}}",
|
||||
"if": "{{(post?.data?.comment_count ?? 0) > 0}}",
|
||||
"children": [
|
||||
{
|
||||
"id": "comment_wrapper",
|
||||
@@ -304,7 +304,7 @@
|
||||
"props": {
|
||||
"className": "p-12 text-center"
|
||||
},
|
||||
"if": "{{(post?.data?.comments ?? []).length === 0}}",
|
||||
"if": "{{(post?.data?.comment_count ?? 0) === 0}}",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
|
||||
+174
-174
@@ -448,7 +448,7 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.comments_title|count={{(post?.data?.comments ?? []).length}}"
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.comments_title|count={{post?.data?.comment_count ?? 0}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -472,7 +472,178 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "원글 정보 (답글인 경우에만 표시) - 인용 스타일, 작성자 정보 아래에 위치",
|
||||
"id": "attachments_section",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "px-6 py-4 border-b border-gray-200 dark:border-gray-700"
|
||||
},
|
||||
"if": "{{post?.data?.has_attachment}}",
|
||||
"children": [
|
||||
{
|
||||
"id": "attachments_toggle",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex items-center justify-between cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"showAttachments": "{{!_local.showAttachments}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "paperclip",
|
||||
"className": "w-4 h-4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.attachments|count={{post?.data?.attachment_count ?? 0}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "{{_local.showAttachments ? 'chevron-up' : 'chevron-down'}}",
|
||||
"className": "w-4 h-4 text-gray-500 dark:text-gray-400"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "attachments_list",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "mt-3 ml-4 space-y-2"
|
||||
},
|
||||
"if": "{{_local.showAttachments}}",
|
||||
"iteration": {
|
||||
"source": "post?.data?.attachments ?? []",
|
||||
"item_var": "attachment",
|
||||
"index_var": "index"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "attachment_card",
|
||||
"type": "basic",
|
||||
"name": "A",
|
||||
"props": {
|
||||
"href": "{{attachment?.download_url}}",
|
||||
"className": "group flex items-center gap-2 px-2 py-1.5 bg-gray-50 dark:bg-gray-800/50 rounded hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer no-underline"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"comment": "이미지 썸네일 (이미지 파일인 경우) - preview_url 사용",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{attachment?.is_image}}",
|
||||
"props": {
|
||||
"className": "flex-shrink-0 w-8 h-8 rounded overflow-hidden bg-white dark:bg-gray-700"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Img",
|
||||
"props": {
|
||||
"src": "{{attachment?.preview_url}}",
|
||||
"alt": "{{attachment?.original_filename}}",
|
||||
"className": "w-full h-full object-cover"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "파일 아이콘 (일반 파일인 경우)",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{!attachment?.is_image}}",
|
||||
"props": {
|
||||
"className": "flex-shrink-0 w-8 h-8 rounded bg-white dark:bg-gray-700 flex items-center justify-center"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "file",
|
||||
"className": "text-lg text-gray-400 dark:text-gray-500"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "파일 정보",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex-1 min-w-0"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "text-xs font-medium text-gray-700 dark:text-gray-200 truncate"
|
||||
},
|
||||
"text": "{{attachment?.original_filename}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "text-[10px] text-gray-500 dark:text-gray-400"
|
||||
},
|
||||
"text": "{{attachment?.size_formatted}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "다운로드 아이콘",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex-shrink-0"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "download",
|
||||
"className": "w-3.5 h-3.5 text-gray-400 dark:text-gray-500 group-hover:text-blue-500 dark:text-blue-400 dark:group-hover:text-blue-400 transition-colors"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "원글 정보 (답글인 경우에만 표시) - 인용 스타일, 첨부파일 아래에 위치",
|
||||
"id": "parent_post_card",
|
||||
"if": "{{post?.data?.parent}}",
|
||||
"type": "basic",
|
||||
@@ -763,177 +934,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "attachments_section",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "px-6 py-4 border-b border-gray-200 dark:border-gray-700"
|
||||
},
|
||||
"if": "{{(post?.data?.attachments ?? []).length > 0}}",
|
||||
"children": [
|
||||
{
|
||||
"id": "attachments_toggle",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex items-center justify-between cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"showAttachments": "{{!_local.showAttachments}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "paperclip",
|
||||
"className": "w-4 h-4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.attachments|count={{(post?.data?.attachments ?? []).length}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "{{_local.showAttachments ? 'chevron-up' : 'chevron-down'}}",
|
||||
"className": "w-4 h-4 text-gray-500 dark:text-gray-400"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "attachments_list",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "mt-3 ml-4 space-y-2"
|
||||
},
|
||||
"if": "{{_local.showAttachments}}",
|
||||
"iteration": {
|
||||
"source": "post?.data?.attachments ?? []",
|
||||
"item_var": "attachment",
|
||||
"index_var": "index"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "attachment_card",
|
||||
"type": "basic",
|
||||
"name": "A",
|
||||
"props": {
|
||||
"href": "{{attachment?.download_url}}",
|
||||
"className": "group flex items-center gap-2 px-2 py-1.5 bg-gray-50 dark:bg-gray-800/50 rounded hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors cursor-pointer no-underline"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"comment": "이미지 썸네일 (이미지 파일인 경우)",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{attachment?.is_image}}",
|
||||
"props": {
|
||||
"className": "flex-shrink-0 w-8 h-8 rounded overflow-hidden bg-white dark:bg-gray-700"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Img",
|
||||
"props": {
|
||||
"src": "{{attachment?.download_url}}",
|
||||
"alt": "{{attachment?.original_filename}}",
|
||||
"className": "w-full h-full object-cover"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "파일 아이콘 (일반 파일인 경우)",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{!attachment?.is_image}}",
|
||||
"props": {
|
||||
"className": "flex-shrink-0 w-8 h-8 rounded bg-white dark:bg-gray-700 flex items-center justify-center"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "file",
|
||||
"className": "text-lg text-gray-400 dark:text-gray-500"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "파일 정보",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex-1 min-w-0"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "text-xs font-medium text-gray-700 dark:text-gray-200 truncate"
|
||||
},
|
||||
"text": "{{attachment?.original_filename}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "text-[10px] text-gray-500 dark:text-gray-400"
|
||||
},
|
||||
"text": "{{attachment?.size_formatted}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "다운로드 아이콘",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex-shrink-0"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "download",
|
||||
"className": "w-3.5 h-3.5 text-gray-400 dark:text-gray-500 group-hover:text-blue-500 dark:text-blue-400 dark:group-hover:text-blue-400 transition-colors"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "card_content",
|
||||
"type": "basic",
|
||||
@@ -1284,4 +1284,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -305,7 +305,7 @@
|
||||
"props": {
|
||||
"className": "px-6 py-4 border-b border-gray-200 dark:border-gray-700"
|
||||
},
|
||||
"if": "{{(item.attachments ?? []).length > 0}}",
|
||||
"if": "{{item.has_attachment}}",
|
||||
"children": [
|
||||
{
|
||||
"id": "attachments_toggle",
|
||||
@@ -343,7 +343,7 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.attachments|count={{(item.attachments ?? []).length}}"
|
||||
"text": "$t:sirsoft-board.admin.posts.detail.attachments|count={{item.attachment_count ?? 0}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
{
|
||||
"meta": {
|
||||
"is_partial": true,
|
||||
"description": "게시판 본인인증 정책 삭제 확인 모달"
|
||||
},
|
||||
"id": "board_identity_policy_delete_modal",
|
||||
"type": "composite",
|
||||
"name": "Modal",
|
||||
"props": {
|
||||
"title": "$t:admin.identity.policies.delete_title",
|
||||
"size": "small"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "P",
|
||||
"props": {
|
||||
"className": "text-gray-700 dark:text-gray-300"
|
||||
},
|
||||
"text": "$t:admin.identity.policies.delete_confirm"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex justify-end gap-3 mt-6"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Button",
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "px-4 py-2 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed",
|
||||
"disabled": "{{_global.boardIdentityPolicyDeleting}}"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "closeModal",
|
||||
"target": "board_identity_policy_delete_modal"
|
||||
}
|
||||
],
|
||||
"text": "$t:common.cancel"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Button",
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "flex items-center gap-2 px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed",
|
||||
"disabled": "{{_global.boardIdentityPolicyDeleting}}"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "sequence",
|
||||
"actions": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"boardIdentityPolicyDeleting": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "apiCall",
|
||||
"auth_required": true,
|
||||
"target": "/api/admin/identity/policies/{{_global.boardIdentityPolicyDeleteId}}",
|
||||
"params": {
|
||||
"method": "DELETE"
|
||||
},
|
||||
"onSuccess": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"boardIdentityPolicyDeleting": false,
|
||||
"boardIdentityPolicyDeleteId": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"type": "success",
|
||||
"message": "$t:admin.identity.policies.delete_success"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "refetchDataSource",
|
||||
"params": {
|
||||
"dataSourceId": "boardIdentityPolicies"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "closeModal",
|
||||
"target": "board_identity_policy_delete_modal"
|
||||
}
|
||||
],
|
||||
"onError": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"boardIdentityPolicyDeleting": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"type": "error",
|
||||
"message": "{{error.message ?? '$t:admin.identity.policies.delete_failed'}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Icon",
|
||||
"if": "{{_global.boardIdentityPolicyDeleting}}",
|
||||
"props": {
|
||||
"name": "spinner",
|
||||
"className": "w-4 h-4 animate-spin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "{{_global.boardIdentityPolicyDeleting ? '$t:common.deleting' : '$t:common.delete'}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
+662
@@ -0,0 +1,662 @@
|
||||
{
|
||||
"meta": {
|
||||
"is_partial": true,
|
||||
"description": "게시판 환경설정 > 본인인증 정책 탭 내 정책 추가/편집 모달. _global.identity_policy_form_modal 단일 진실 패턴 — list 가 매 진입마다 객체 통째 set, 모달 표시/입력 모두 _global 참조 (사례 13 회피 + modals 섹션 isolated 스코프 회피)"
|
||||
},
|
||||
"id": "identity_policy_form_modal",
|
||||
"type": "composite",
|
||||
"name": "Modal",
|
||||
"props": {
|
||||
"title": "{{_global.identity_policy_form_modal?.isNew ? '$t:admin.identity.policies.create_title' : '$t:admin.identity.policies.edit_title'}}",
|
||||
"size": "lg",
|
||||
"closeOnOverlayClick": false
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex flex-col max-h-[calc(90vh-140px)] -my-4"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"id": "policy_form_body",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex-1 overflow-y-auto space-y-4 px-4 py-4 pr-2"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors}}",
|
||||
"props": {
|
||||
"className": "p-3 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-lg"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "flex gap-2" },
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Icon",
|
||||
"props": {
|
||||
"name": "triangle-exclamation",
|
||||
"className": "w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "flex-1" },
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "P",
|
||||
"props": {
|
||||
"className": "text-sm font-medium text-red-800 dark:text-red-200"
|
||||
},
|
||||
"text": "{{_global.identity_policy_form_modal?.errors?.message ?? '$t:common.validation_error'}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Ul",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors?.errors && Object.keys(_global.identity_policy_form_modal.errors.errors).length > 0}}",
|
||||
"props": {
|
||||
"className": "mt-1 list-disc list-inside space-y-0.5"
|
||||
},
|
||||
"iteration": {
|
||||
"source": "Object.entries(_global.identity_policy_form_modal?.errors?.errors ?? {}).flatMap(([f, m]) => Array.isArray(m) ? m : [m])",
|
||||
"item_var": "msg"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Li",
|
||||
"props": {
|
||||
"className": "text-xs text-red-700 dark:text-red-300"
|
||||
},
|
||||
"text": "{{msg}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.key"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "text",
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.key ?? ''}}",
|
||||
"disabled": "{{!_global.identity_policy_form_modal?.isNew && _global.identity_policy_form_modal?.form?.source_type !== 'admin'}}",
|
||||
"className": "{{_global.identity_policy_form_modal?.errors?.errors?.key ? 'w-full px-3 py-2 border border-red-500 dark:border-red-500 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm font-mono focus:ring-2 focus:ring-red-500 focus:border-red-500 disabled:bg-gray-100 dark:disabled:bg-gray-900' : 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm font-mono disabled:bg-gray-100 dark:disabled:bg-gray-900'}}"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.key": "{{$event.target.value}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors?.errors?.key}}",
|
||||
"props": { "className": "text-red-500 text-xs mt-1 block" },
|
||||
"text": "{{_global.identity_policy_form_modal?.errors?.errors?.key?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "grid grid-cols-1 md:grid-cols-2 gap-3" },
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.scope"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.scope ?? 'route'}}",
|
||||
"disabled": "{{!_global.identity_policy_form_modal?.isNew && _global.identity_policy_form_modal?.form?.source_type !== 'admin'}}",
|
||||
"className": "{{_global.identity_policy_form_modal?.errors?.errors?.scope ? 'w-full px-3 py-2 border border-red-500 dark:border-red-500 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-red-500 focus:border-red-500 disabled:bg-gray-100 dark:disabled:bg-gray-900' : 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm disabled:bg-gray-100 dark:disabled:bg-gray-900'}}",
|
||||
"options": [
|
||||
{ "value": "route", "label": "$t:admin.identity.policies.scope.route" },
|
||||
{ "value": "hook", "label": "$t:admin.identity.policies.scope.hook" },
|
||||
{ "value": "custom", "label": "$t:admin.identity.policies.scope.custom" }
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.scope": "{{$event.target.value}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors?.errors?.scope}}",
|
||||
"props": { "className": "text-red-500 text-xs mt-1 block" },
|
||||
"text": "{{_global.identity_policy_form_modal?.errors?.errors?.scope?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.target"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "text",
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.target ?? ''}}",
|
||||
"disabled": "{{!_global.identity_policy_form_modal?.isNew && _global.identity_policy_form_modal?.form?.source_type !== 'admin'}}",
|
||||
"className": "{{_global.identity_policy_form_modal?.errors?.errors?.target ? 'w-full px-3 py-2 border border-red-500 dark:border-red-500 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm font-mono focus:ring-2 focus:ring-red-500 focus:border-red-500 disabled:bg-gray-100 dark:disabled:bg-gray-900' : 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm font-mono disabled:bg-gray-100 dark:disabled:bg-gray-900'}}"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.target": "{{$event.target.value}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors?.errors?.target}}",
|
||||
"props": { "className": "text-red-500 text-xs mt-1 block" },
|
||||
"text": "{{_global.identity_policy_form_modal?.errors?.errors?.target?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "grid grid-cols-1 md:grid-cols-2 gap-3" },
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.purpose"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.purpose ?? 'sensitive_action'}}",
|
||||
"className": "{{_global.identity_policy_form_modal?.errors?.errors?.purpose ? 'w-full px-3 py-2 border border-red-500 dark:border-red-500 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-red-500 focus:border-red-500' : 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm'}}",
|
||||
"options": "{{(boardIdentityPurposes?.data ?? []).map(function(p) { return {value: p.id, label: p.label ?? p.id}; })}}"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.purpose": "{{$event.target.value}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors?.errors?.purpose}}",
|
||||
"props": { "className": "text-red-500 text-xs mt-1 block" },
|
||||
"text": "{{_global.identity_policy_form_modal?.errors?.errors?.purpose?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.provider_id"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.provider_id ?? ''}}",
|
||||
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm",
|
||||
"options": "{{[{value: '', label: '$t:admin.identity.policies.form.use_default_provider'}].concat((identityProviders?.data ?? []).map(function(p) { return {value: p.id, label: p.label}; }))}}"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.provider_id": "{{$event.target.value}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "grid grid-cols-1 md:grid-cols-2 gap-3" },
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.grace_minutes"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "number",
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.grace_minutes ?? 0}}",
|
||||
"min": 0,
|
||||
"max": 1440,
|
||||
"className": "{{_global.identity_policy_form_modal?.errors?.errors?.grace_minutes ? 'w-full px-3 py-2 border border-red-500 dark:border-red-500 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-red-500 focus:border-red-500' : 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm'}}"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.grace_minutes": "{{Number($event.target.value)}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors?.errors?.grace_minutes}}",
|
||||
"props": { "className": "text-red-500 text-xs mt-1 block" },
|
||||
"text": "{{_global.identity_policy_form_modal?.errors?.errors?.grace_minutes?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.applies_to"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.applies_to ?? 'both'}}",
|
||||
"disabled": "{{!_global.identity_policy_form_modal?.isNew && _global.identity_policy_form_modal?.form?.source_type !== 'admin'}}",
|
||||
"className": "{{_global.identity_policy_form_modal?.errors?.errors?.applies_to ? 'w-full px-3 py-2 border border-red-500 dark:border-red-500 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-red-500 focus:border-red-500 disabled:bg-gray-100 dark:disabled:bg-gray-900' : 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm disabled:bg-gray-100 dark:disabled:bg-gray-900'}}",
|
||||
"options": [
|
||||
{ "value": "self", "label": "$t:admin.identity.policies.applies_to.self" },
|
||||
{ "value": "admin", "label": "$t:admin.identity.policies.applies_to.admin" },
|
||||
{ "value": "both", "label": "$t:admin.identity.policies.applies_to.both" }
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.applies_to": "{{$event.target.value}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors?.errors?.applies_to}}",
|
||||
"props": { "className": "text-red-500 text-xs mt-1 block" },
|
||||
"text": "{{_global.identity_policy_form_modal?.errors?.errors?.applies_to?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "grid grid-cols-1 md:grid-cols-2 gap-3" },
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.fail_mode"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.fail_mode ?? 'block'}}",
|
||||
"className": "{{_global.identity_policy_form_modal?.errors?.errors?.fail_mode ? 'w-full px-3 py-2 border border-red-500 dark:border-red-500 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-red-500 focus:border-red-500' : 'w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm'}}",
|
||||
"options": [
|
||||
{ "value": "block", "label": "$t:admin.identity.policies.fail_mode.block" },
|
||||
{ "value": "log_only", "label": "$t:admin.identity.policies.fail_mode.log_only" }
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.fail_mode": "{{$event.target.value}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"if": "{{_global.identity_policy_form_modal?.errors?.errors?.fail_mode}}",
|
||||
"props": { "className": "text-red-500 text-xs mt-1 block" },
|
||||
"text": "{{_global.identity_policy_form_modal?.errors?.errors?.fail_mode?.[0] ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "flex items-end justify-between gap-2 pb-2" },
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300" },
|
||||
"text": "$t:admin.identity.policies.form.enabled"
|
||||
},
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "Toggle",
|
||||
"props": {
|
||||
"checked": "{{Boolean(_global.identity_policy_form_modal?.form?.enabled)}}",
|
||||
"size": "md"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.enabled": "{{!_global.identity_policy_form_modal?.form?.enabled}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{_global.identity_policy_form_modal?.form?.purpose === 'signup'}}",
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1" },
|
||||
"text": "$t:admin.identity.policies.form.signup_stage"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"value": "{{_global.identity_policy_form_modal?.form?.conditions?.signup_stage ?? ''}}",
|
||||
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm",
|
||||
"options": [
|
||||
{ "value": "", "label": "$t:admin.identity.policies.form.signup_stage_unset" },
|
||||
{ "value": "before_submit", "label": "$t:admin.identity.policies.form.signup_stage_before_submit" },
|
||||
{ "value": "after_create", "label": "$t:admin.identity.policies.form.signup_stage_after_create" }
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.form.conditions.signup_stage": "{{$event.target.value}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "P",
|
||||
"props": { "className": "text-xs text-gray-400 dark:text-gray-500 mt-1" },
|
||||
"text": "$t:admin.identity.policies.form.signup_stage_desc"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{!_global.identity_policy_form_modal?.isNew && _global.identity_policy_form_modal?.form?.source_type !== 'admin'}}",
|
||||
"props": {
|
||||
"className": "p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg text-xs text-yellow-800 dark:text-yellow-200"
|
||||
},
|
||||
"text": "$t:admin.identity.policies.form.declared_policy_notice"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "policy_form_footer",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": {
|
||||
"className": "flex justify-end items-center gap-2 px-4 py-3 border-t border-gray-200 dark:border-gray-700 flex-shrink-0 bg-white dark:bg-gray-800"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Button",
|
||||
"props": {
|
||||
"type": "button",
|
||||
"disabled": "{{_global.identity_policy_form_modal?.isSaving ?? false}}",
|
||||
"className": "px-4 py-2 text-sm font-medium bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "closeModal",
|
||||
"target": "identity_policy_form_modal"
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "$t:common.cancel"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Button",
|
||||
"props": {
|
||||
"type": "button",
|
||||
"disabled": "{{_global.identity_policy_form_modal?.isSaving}}",
|
||||
"className": "flex items-center gap-2 px-4 py-2 text-sm font-medium bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-lg"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "sequence",
|
||||
"params": {
|
||||
"actions": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.isSaving": true,
|
||||
"identity_policy_form_modal.errors": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "apiCall",
|
||||
"auth_required": true,
|
||||
"target": "{{_global.identity_policy_form_modal?.isNew ? '/api/admin/identity/policies' : '/api/admin/identity/policies/' + _global.identity_policy_form_modal?.form?.id}}",
|
||||
"params": {
|
||||
"method": "{{_global.identity_policy_form_modal?.isNew ? 'POST' : 'PUT'}}",
|
||||
"body": {
|
||||
"key": "{{_global.identity_policy_form_modal?.form?.key}}",
|
||||
"scope": "{{_global.identity_policy_form_modal?.form?.scope}}",
|
||||
"target": "{{_global.identity_policy_form_modal?.form?.target}}",
|
||||
"purpose": "{{_global.identity_policy_form_modal?.form?.purpose}}",
|
||||
"provider_id": "{{_global.identity_policy_form_modal?.form?.provider_id || null}}",
|
||||
"grace_minutes": "{{Number(_global.identity_policy_form_modal?.form?.grace_minutes ?? 0)}}",
|
||||
"applies_to": "{{_global.identity_policy_form_modal?.form?.applies_to}}",
|
||||
"fail_mode": "{{_global.identity_policy_form_modal?.form?.fail_mode}}",
|
||||
"enabled": "{{Boolean(_global.identity_policy_form_modal?.form?.enabled)}}",
|
||||
"priority": "{{Number(_global.identity_policy_form_modal?.form?.priority ?? 100)}}",
|
||||
"conditions": "{{_global.identity_policy_form_modal?.form?.conditions ?? null}}",
|
||||
"source_type": "{{_global.identity_policy_form_modal?.isNew ? 'admin' : (_global.identity_policy_form_modal?.form?.source_type ?? 'admin')}}",
|
||||
"source_identifier": "{{_global.identity_policy_form_modal?.isNew ? 'sirsoft-board' : (_global.identity_policy_form_modal?.form?.source_identifier ?? 'sirsoft-board')}}"
|
||||
}
|
||||
},
|
||||
"onSuccess": [
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"message": "$t:admin.identity.policies.save_success",
|
||||
"type": "success"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "closeModal",
|
||||
"target": "identity_policy_form_modal"
|
||||
},
|
||||
{
|
||||
"handler": "refetchDataSource",
|
||||
"params": { "dataSourceId": "boardIdentityPolicies" }
|
||||
},
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"onError": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"identity_policy_form_modal.isSaving": false,
|
||||
"identity_policy_form_modal.errors": "{{error}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Icon",
|
||||
"if": "{{_global.identity_policy_form_modal?.isSaving}}",
|
||||
"props": {
|
||||
"name": "spinner",
|
||||
"className": "animate-spin",
|
||||
"size": "sm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "{{_global.identity_policy_form_modal?.isSaving ? '$t:common.saving' : '$t:common.save'}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
+135
-129
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"meta": {
|
||||
"is_partial": true,
|
||||
"description": "이커머스 알림 템플릿 편집 모달"
|
||||
"description": "게시판 알림 템플릿 편집 모달 — _global.ecommerce_board_notification_template_form_modal 단일 진실 패턴. list 가 매 진입마다 객체 통째 set, 모달 표시/입력 모두 _global 참조 (사례 13 회피 + modals 섹션 isolated 스코프 회피). 미리보기 데이터도 같은 namespace 의 preview 키에 저장."
|
||||
},
|
||||
"id": "modal_board_notification_template_edit",
|
||||
"type": "composite",
|
||||
@@ -16,7 +16,7 @@
|
||||
"id": "board_template_form_container",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"blur_until_loaded": "{{$parent._local.isSaving}}",
|
||||
"blur_until_loaded": "{{_global.board_notification_template_form_modal?.isSaving}}",
|
||||
"props": {
|
||||
"className": "flex flex-col max-h-[calc(90vh-140px)] -my-4"
|
||||
},
|
||||
@@ -32,7 +32,7 @@
|
||||
"id": "board_template_validation_error",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{$parent._local.templateErrors}}",
|
||||
"if": "{{_global.board_notification_template_form_modal?.errors}}",
|
||||
"props": {
|
||||
"className": "bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4"
|
||||
},
|
||||
@@ -68,12 +68,12 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Ul",
|
||||
"if": "{{typeof $parent._local.templateErrors === 'object' && Object.keys($parent._local.templateErrors).length > 0}}",
|
||||
"if": "{{typeof _global.board_notification_template_form_modal?.errors === 'object' && Object.keys(_global.board_notification_template_form_modal.errors).length > 0}}",
|
||||
"props": {
|
||||
"className": "mt-2 list-disc list-inside space-y-1"
|
||||
},
|
||||
"iteration": {
|
||||
"source": "Object.entries($parent._local.templateErrors ?? {}).flatMap(([field, messages]) => Array.isArray(messages) ? messages : [messages])",
|
||||
"source": "Object.entries(_global.board_notification_template_form_modal?.errors ?? {}).flatMap(([field, messages]) => Array.isArray(messages) ? messages : [messages])",
|
||||
"item_var": "errMsg"
|
||||
},
|
||||
"children": [
|
||||
@@ -115,7 +115,7 @@
|
||||
"props": {
|
||||
"className": "text-sm font-semibold text-gray-900 dark:text-white"
|
||||
},
|
||||
"text": "$t:sirsoft-board.admin.settings.notification_definitions.types.{{$parent._local.editingDefinition?.type ?? ''}}"
|
||||
"text": "$t:sirsoft-board.admin.settings.notification_definitions.types.{{_global.board_notification_template_form_modal?.definition?.type ?? ''}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -123,7 +123,7 @@
|
||||
"props": {
|
||||
"className": "text-xs font-mono px-1.5 py-0.5 bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 rounded"
|
||||
},
|
||||
"text": "{{$parent._local.editingDefinition?.type ?? ''}}"
|
||||
"text": "{{_global.board_notification_template_form_modal?.definition?.type ?? ''}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -147,7 +147,7 @@
|
||||
"props": {
|
||||
"className": "text-sm font-medium text-indigo-600 dark:text-indigo-400"
|
||||
},
|
||||
"text": "{{(availableChannels?.data?.channels ?? []).find(c => c.id === $parent._local.editingTemplate?.channel)?.name?.[$locale] ?? $parent._local.editingTemplate?.channel ?? ''}}"
|
||||
"text": "{{(availableChannels?.data?.channels ?? []).find(c => c.id === _global.board_notification_template_form_modal?.template?.channel)?.name ?? _global.board_notification_template_form_modal?.template?.channel ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -170,13 +170,15 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "space-y-3" },
|
||||
"props": {
|
||||
"className": "space-y-3"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"iteration": {
|
||||
"source": "{{$parent._local.editingRecipients ?? []}}",
|
||||
"source": "{{_global.board_notification_template_form_modal?.recipients ?? []}}",
|
||||
"item_var": "rcpt",
|
||||
"index_var": "rcptIdx"
|
||||
},
|
||||
@@ -187,12 +189,16 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "flex items-center justify-between" },
|
||||
"props": {
|
||||
"className": "flex items-center justify-between"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"props": { "className": "text-xs font-medium text-purple-700 dark:text-purple-300" },
|
||||
"props": {
|
||||
"className": "text-xs font-medium text-purple-700 dark:text-purple-300"
|
||||
},
|
||||
"text": "$t:admin.settings.notification_definitions.recipients.rule_label|index={{rcptIdx + 1}}"
|
||||
},
|
||||
{
|
||||
@@ -214,8 +220,8 @@
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingRecipients": "{{($parent._local.editingRecipients ?? []).filter((_, i) => i !== rcptIdx)}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.recipients": "{{(_global.board_notification_template_form_modal?.recipients ?? []).filter((_, i) => i !== rcptIdx)}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -225,7 +231,9 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "space-y-2" },
|
||||
"props": {
|
||||
"className": "space-y-2"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -256,8 +264,8 @@
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingRecipients": "{{($parent._local.editingRecipients ?? []).map((r, i) => i === rcptIdx ? {...r, type: $event.target.value} : r)}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.recipients": "{{(_global.board_notification_template_form_modal?.recipients ?? []).map((r, i) => i === rcptIdx ? {...r, type: $event.target.value} : r)}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -303,7 +311,7 @@
|
||||
"name": "SearchableDropdown",
|
||||
"props": {
|
||||
"value": "{{rcpt.value ?? ''}}",
|
||||
"options": "{{$parent._local.recipientRoleSearchResults ?? []}}",
|
||||
"options": "{{_global.board_notification_template_form_modal?.roleSearchResults ?? []}}",
|
||||
"searchPlaceholder": "$t:admin.settings.notification_definitions.recipients.role_search_placeholder",
|
||||
"noResultsText": "$t:admin.settings.notification_definitions.recipients.users_no_options",
|
||||
"initialText": "$t:admin.settings.notification_definitions.recipients.role_search_placeholder",
|
||||
@@ -328,8 +336,8 @@
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"recipientRoleSearchResults": "{{(response.data?.data ?? []).map(r => ({ value: r.identifier, label: r.name, description: r.identifier }))}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.roleSearchResults": "{{(response.data?.data ?? []).map(r => ({ value: r.identifier, label: r.name, description: r.identifier }))}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -337,8 +345,8 @@
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"recipientRoleSearchResults": []
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.roleSearchResults": []
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -347,8 +355,8 @@
|
||||
"event": "onChange",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingRecipients": "{{($parent._local.editingRecipients ?? []).map((r, i) => i === rcptIdx ? {...r, value: $args[0]} : r)}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.recipients": "{{(_global.board_notification_template_form_modal?.recipients ?? []).map((r, i) => i === rcptIdx ? {...r, value: $args[0]} : r)}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -368,13 +376,13 @@
|
||||
"text": "$t:admin.settings.notification_definitions.recipients.users_label"
|
||||
},
|
||||
{
|
||||
"id": "ecom_rcpt_users_{{rcptIdx}}",
|
||||
"id": "board_rcpt_users_{{rcptIdx}}",
|
||||
"type": "composite",
|
||||
"name": "SearchableDropdown",
|
||||
"props": {
|
||||
"multiple": true,
|
||||
"value": "{{rcpt.value ?? []}}",
|
||||
"options": "{{$parent._local.recipientUserSearchResults ?? []}}",
|
||||
"options": "{{_global.board_notification_template_form_modal?.userSearchResults ?? []}}",
|
||||
"searchPlaceholder": "$t:admin.settings.notification_definitions.recipients.users_placeholder",
|
||||
"noResultsText": "$t:admin.settings.notification_definitions.recipients.users_no_options",
|
||||
"initialText": "$t:admin.settings.notification_definitions.recipients.users_placeholder",
|
||||
@@ -398,8 +406,8 @@
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"recipientUserSearchResults": "{{(response.data ?? []).map(u => ({ value: u.uuid, label: u.name, description: u.email }))}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.userSearchResults": "{{(response.data ?? []).map(u => ({ value: u.uuid, label: u.name, description: u.email }))}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -407,8 +415,8 @@
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"recipientUserSearchResults": []
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.userSearchResults": []
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -417,8 +425,8 @@
|
||||
"event": "onChange",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingRecipients": "{{($parent._local.editingRecipients ?? []).map((r, i) => i === rcptIdx ? {...r, value: $args[0]} : r)}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.recipients": "{{(_global.board_notification_template_form_modal?.recipients ?? []).map((r, i) => i === rcptIdx ? {...r, value: $args[0]} : r)}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -442,8 +450,8 @@
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingRecipients": "{{($parent._local.editingRecipients ?? []).map((r, i) => i === rcptIdx ? {...r, exclude_trigger_user: !(r.exclude_trigger_user ?? false)} : r)}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.recipients": "{{(_global.board_notification_template_form_modal?.recipients ?? []).map((r, i) => i === rcptIdx ? {...r, exclude_trigger_user: !(r.exclude_trigger_user ?? false)} : r)}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -475,8 +483,8 @@
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingRecipients": "{{[...($parent._local.editingRecipients ?? []), {type: 'trigger_user'}]}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.recipients": "{{[...(_global.board_notification_template_form_modal?.recipients ?? []), {type: 'trigger_user'}]}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -500,7 +508,7 @@
|
||||
},
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "{{($parent._local.editLang ?? $locale) === loc ? 'border-b-2 border-indigo-500 text-indigo-600 dark:text-indigo-400' : 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300'}} px-4 py-2 text-sm font-medium focus:outline-none"
|
||||
"className": "{{(_global.board_notification_template_form_modal?.editLang ?? $locale) === loc ? 'border-b-2 border-indigo-500 dark:border-indigo-400 text-indigo-600 dark:text-indigo-400' : 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300'}} px-4 py-2 text-sm font-medium focus:outline-none"
|
||||
},
|
||||
"text": "{{_global.appConfig?.localeNames?.[loc] ?? loc}}",
|
||||
"actions": [
|
||||
@@ -508,8 +516,8 @@
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editLang": "{{loc}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.editLang": "{{loc}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -549,16 +557,16 @@
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "text",
|
||||
"value": "{{$parent._local.editingTemplate?.subject?.[$parent._local.editLang ?? $locale] ?? ''}}",
|
||||
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
|
||||
"value": "{{_global.board_notification_template_form_modal?.template?.subject?.[_global.board_notification_template_form_modal?.editLang ?? $locale] ?? ''}}",
|
||||
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-indigo-500 dark:focus:ring-indigo-400 focus:border-indigo-500 dark:focus:border-indigo-400"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingTemplate": "{{Object.assign({}, $parent._local.editingTemplate, {subject: Object.assign({}, $parent._local.editingTemplate?.subject, {[$parent._local.editLang ?? $locale]: $event.target.value})})}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.template.subject": "{{Object.assign({}, _global.board_notification_template_form_modal?.template?.subject, {[_global.board_notification_template_form_modal?.editLang ?? $locale]: $event.target.value})}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -597,7 +605,7 @@
|
||||
"type": "composite",
|
||||
"name": "HtmlEditor",
|
||||
"props": {
|
||||
"content": "{{$parent._local.editingTemplate?.body?.[$parent._local.editLang ?? $locale] ?? ''}}",
|
||||
"content": "{{_global.board_notification_template_form_modal?.template?.body?.[_global.board_notification_template_form_modal?.editLang ?? $locale] ?? ''}}",
|
||||
"isHtml": true,
|
||||
"showHtmlModeToggle": false,
|
||||
"className": "min-h-[200px]"
|
||||
@@ -607,8 +615,8 @@
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingTemplate": "{{Object.assign({}, $parent._local.editingTemplate, {body: Object.assign({}, $parent._local.editingTemplate?.body, {[$parent._local.editLang ?? $locale]: $event.target.value})})}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.template.body": "{{Object.assign({}, _global.board_notification_template_form_modal?.template?.body, {[_global.board_notification_template_form_modal?.editLang ?? $locale]: $event.target.value})}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -619,7 +627,7 @@
|
||||
"id": "board_template_click_url_input",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{$parent._local.editingTemplate?.channel === 'database'}}",
|
||||
"if": "{{_global.board_notification_template_form_modal?.template?.channel === 'database'}}",
|
||||
"props": {
|
||||
"className": "space-y-1"
|
||||
},
|
||||
@@ -637,17 +645,17 @@
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "text",
|
||||
"value": "{{$parent._local.editingTemplate?.click_url ?? ''}}",
|
||||
"value": "{{_global.board_notification_template_form_modal?.template?.click_url ?? ''}}",
|
||||
"placeholder": "/mypage/orders/{order_number}",
|
||||
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
|
||||
"className": "w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-blue-500 dark:focus:border-blue-400"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"editingTemplate": "{{Object.assign({}, $parent._local.editingTemplate, {click_url: $event.target.value || null})}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.template.click_url": "{{$event.target.value || null}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -666,7 +674,7 @@
|
||||
"id": "board_template_variables_info",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{($parent._local.editingDefinition?.variables ?? []).length > 0}}",
|
||||
"if": "{{(_global.board_notification_template_form_modal?.definition?.variables ?? []).length > 0}}",
|
||||
"props": {
|
||||
"className": "bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-md p-4"
|
||||
},
|
||||
@@ -690,7 +698,7 @@
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"iteration": {
|
||||
"source": "{{$parent._local.editingDefinition?.variables ?? []}}",
|
||||
"source": "{{_global.board_notification_template_form_modal?.definition?.variables ?? []}}",
|
||||
"item_var": "v"
|
||||
},
|
||||
"props": {
|
||||
@@ -746,7 +754,7 @@
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "text-sm px-4 py-2 rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",
|
||||
"disabled": "{{$parent._local.isSaving ?? false}}"
|
||||
"disabled": "{{_global.board_notification_template_form_modal?.isSaving ?? false}}"
|
||||
},
|
||||
"text": "$t:sirsoft-board.admin.settings.notification_definitions.edit_modal.btn_preview",
|
||||
"actions": [
|
||||
@@ -758,18 +766,18 @@
|
||||
"params": {
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"definition_id": "{{$parent._local.editingDefinition?.id}}",
|
||||
"subject": "{{$parent._local.editingTemplate?.subject}}",
|
||||
"body": "{{$parent._local.editingTemplate?.body}}",
|
||||
"locale": "{{$parent._local.editLang ?? $locale}}"
|
||||
"definition_id": "{{_global.board_notification_template_form_modal?.definition?.id}}",
|
||||
"subject": "{{_global.board_notification_template_form_modal?.template?.subject}}",
|
||||
"body": "{{_global.board_notification_template_form_modal?.template?.body}}",
|
||||
"locale": "{{_global.board_notification_template_form_modal?.editLang ?? $locale}}"
|
||||
}
|
||||
},
|
||||
"onSuccess": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"previewData": "{{response.data}}"
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.preview": "{{response.data}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -795,7 +803,7 @@
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "text-sm px-4 py-2 rounded-md border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
||||
"disabled": "{{$parent._local.isSaving ?? false}}"
|
||||
"disabled": "{{_global.board_notification_template_form_modal?.isSaving ?? false}}"
|
||||
},
|
||||
"text": "$t:common.cancel",
|
||||
"actions": [
|
||||
@@ -812,96 +820,94 @@
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "flex items-center gap-2 text-sm px-4 py-2 rounded-md bg-indigo-600 text-white hover:bg-indigo-700 dark:bg-indigo-500 dark:hover:bg-indigo-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
||||
"disabled": "{{$parent._local.isSaving ?? false}}"
|
||||
"disabled": "{{_global.board_notification_template_form_modal?.isSaving ?? false}}"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Icon",
|
||||
"if": "{{$parent._local.isSaving}}",
|
||||
"if": "{{_global.board_notification_template_form_modal?.isSaving}}",
|
||||
"props": { "name": "spinner", "className": "animate-spin", "size": "sm" }
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "{{$parent._local.isSaving ? '$t:common.saving' : '$t:common.save'}}"
|
||||
"text": "{{_global.board_notification_template_form_modal?.isSaving ? '$t:common.saving' : '$t:common.save'}}"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "sequence",
|
||||
"actions": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"isSaving": true,
|
||||
"templateErrors": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "apiCall",
|
||||
"auth_required": true,
|
||||
"target": "{{'/api/admin/notification-templates/' + $parent._local.editingTemplate?.id}}",
|
||||
"params": {
|
||||
"method": "PUT",
|
||||
"body": {
|
||||
"subject": "{{$parent._local.editingTemplate?.subject}}",
|
||||
"body": "{{$parent._local.editingTemplate?.body}}",
|
||||
"click_url": "{{$parent._local.editingTemplate?.click_url ?? null}}",
|
||||
"recipients": "{{$parent._local.editingRecipients ?? []}}"
|
||||
"params": {
|
||||
"actions": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.isSaving": true,
|
||||
"board_notification_template_form_modal.errors": null
|
||||
}
|
||||
},
|
||||
"onSuccess": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"isSaving": false,
|
||||
"templateErrors": null,
|
||||
"editingTemplate": null,
|
||||
"editingDefinition": null,
|
||||
"editingRecipients": null
|
||||
{
|
||||
"handler": "apiCall",
|
||||
"auth_required": true,
|
||||
"target": "{{'/api/admin/notification-templates/' + _global.board_notification_template_form_modal?.template?.id}}",
|
||||
"params": {
|
||||
"method": "PUT",
|
||||
"body": {
|
||||
"subject": "{{_global.board_notification_template_form_modal?.template?.subject}}",
|
||||
"body": "{{_global.board_notification_template_form_modal?.template?.body}}",
|
||||
"click_url": "{{_global.board_notification_template_form_modal?.template?.click_url ?? null}}",
|
||||
"recipients": "{{_global.board_notification_template_form_modal?.recipients ?? []}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "closeModal",
|
||||
"target": "modal_board_notification_template_edit"
|
||||
},
|
||||
{
|
||||
"handler": "refetchDataSource",
|
||||
"params": {
|
||||
"dataSourceId": "boardNotificationDefinitions"
|
||||
"onSuccess": [
|
||||
{
|
||||
"handler": "refetchDataSource",
|
||||
"params": {
|
||||
"dataSourceId": "boardNotificationDefinitions"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"message": "$t:sirsoft-board.admin.settings.notification_definitions.save_success",
|
||||
"type": "success"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "closeModal",
|
||||
"target": "modal_board_notification_template_edit"
|
||||
},
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"message": "$t:sirsoft-board.admin.settings.notification_definitions.save_success",
|
||||
"type": "success"
|
||||
],
|
||||
"onError": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal.isSaving": false,
|
||||
"board_notification_template_form_modal.errors": "{{error.errors}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"message": "$t:sirsoft-board.admin.settings.notification_definitions.save_error",
|
||||
"type": "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"onError": [
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "$parent._local",
|
||||
"isSaving": false,
|
||||
"templateErrors": "{{error.errors}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"handler": "toast",
|
||||
"params": {
|
||||
"message": "$t:sirsoft-board.admin.settings.notification_definitions.save_error",
|
||||
"type": "error"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@
|
||||
"props": {
|
||||
"className": "text-base font-medium text-gray-900 dark:text-white bg-gray-50 dark:bg-gray-900 rounded-md px-3 py-2"
|
||||
},
|
||||
"text": "{{$parent._local.previewData?.subject ?? ''}}"
|
||||
"text": "{{_global.board_notification_template_form_modal?.preview?.subject ?? ''}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -63,7 +63,7 @@
|
||||
"type": "composite",
|
||||
"name": "HtmlContent",
|
||||
"props": {
|
||||
"content": "{{$parent._local.previewData?.body ?? ''}}",
|
||||
"content": "{{_global.board_notification_template_form_modal?.preview?.body ?? ''}}",
|
||||
"isHtml": true,
|
||||
"className": "prose dark:prose-invert prose-sm max-w-none border border-gray-200 dark:border-gray-700 rounded-md p-4 max-h-[400px] overflow-y-auto bg-white dark:bg-gray-900"
|
||||
}
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"name": "basic_defaults.type",
|
||||
"options": "{{board_types?.data?.map(t => ({value: t.slug, label: (t.name[_global.locale ?? 'ko'] ?? t.name.ko ?? t.slug) + ' (' + t.slug + ')'})) ?? []}}",
|
||||
"options": "{{board_types?.data?.map(t => ({value: t.slug, label: (t.name[_global.locale ?? $locale ?? 'ko'] ?? t.name.ko ?? t.slug) + ' (' + t.slug + ')'})) ?? []}}",
|
||||
"className": "w-48 flex-shrink-0 text-sm",
|
||||
"disabled": "{{_computed.isReadOnly}}"
|
||||
}
|
||||
|
||||
+4
-8
@@ -44,9 +44,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('use_file_upload') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'use_file_upload') : [...(_local.bulkApplyFields ?? []), 'use_file_upload']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('use_file_upload')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('use_file_upload')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('use_file_upload') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'use_file_upload') : [...(_local.bulkApplyFields ?? []), 'use_file_upload']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.use_file_upload" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.use_file_upload" }
|
||||
@@ -68,9 +67,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_file_size') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_file_size') : [...(_local.bulkApplyFields ?? []), 'max_file_size']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_file_size')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_file_size')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_file_size') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_file_size') : [...(_local.bulkApplyFields ?? []), 'max_file_size']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.max_file_size" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.max_file_size" }
|
||||
@@ -95,9 +93,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_file_count') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_file_count') : [...(_local.bulkApplyFields ?? []), 'max_file_count']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_file_count')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_file_count')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_file_count') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_file_count') : [...(_local.bulkApplyFields ?? []), 'max_file_count']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.max_file_count" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.max_file_count" }
|
||||
@@ -122,9 +119,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer mb-2" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('allowed_extensions') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'allowed_extensions') : [...(_local.bulkApplyFields ?? []), 'allowed_extensions']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('allowed_extensions')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('allowed_extensions')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('allowed_extensions') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'allowed_extensions') : [...(_local.bulkApplyFields ?? []), 'allowed_extensions']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.allowed_extensions" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.allowed_extensions" }
|
||||
|
||||
+45
-45
@@ -106,16 +106,6 @@
|
||||
"props": {
|
||||
"className": "flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('type') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'type') : [...(_local.bulkApplyFields ?? []), 'type']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -124,7 +114,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('type')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('type') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'type') : [...(_local.bulkApplyFields ?? []), 'type']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -219,7 +219,7 @@
|
||||
"name": "Select",
|
||||
"props": {
|
||||
"name": "basic_defaults.type",
|
||||
"options": "{{board_types?.data?.map(t => ({value: t.slug, label: (t.name[_global.locale ?? 'ko'] ?? t.name.ko ?? t.slug) + ' (' + t.slug + ')'})) ?? []}}",
|
||||
"options": "{{board_types?.data?.map(t => ({value: t.slug, label: (t.name[_global.locale ?? $locale ?? 'ko'] ?? t.name.ko ?? t.slug) + ' (' + t.slug + ')'})) ?? []}}",
|
||||
"className": "w-48 flex-shrink-0 text-sm",
|
||||
"disabled": "{{_computed.isReadOnly}}"
|
||||
}
|
||||
@@ -249,16 +249,6 @@
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('secret_mode') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'secret_mode') : [...(_local.bulkApplyFields ?? []), 'secret_mode']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -267,7 +257,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('secret_mode')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('secret_mode') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'secret_mode') : [...(_local.bulkApplyFields ?? []), 'secret_mode']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -329,16 +329,6 @@
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('show_view_count') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'show_view_count') : [...(_local.bulkApplyFields ?? []), 'show_view_count']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -347,7 +337,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('show_view_count')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('show_view_count') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'show_view_count') : [...(_local.bulkApplyFields ?? []), 'show_view_count']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -404,16 +404,6 @@
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('use_report') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'use_report') : [...(_local.bulkApplyFields ?? []), 'use_report']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -422,7 +412,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('use_report')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('use_report') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'use_report') : [...(_local.bulkApplyFields ?? []), 'use_report']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
|
||||
+5
-10
@@ -47,9 +47,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('use_comment') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'use_comment') : [...(_local.bulkApplyFields ?? []), 'use_comment']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('use_comment')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('use_comment')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('use_comment') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'use_comment') : [...(_local.bulkApplyFields ?? []), 'use_comment']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.use_comment" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.use_comment" }
|
||||
@@ -71,9 +70,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_comment_depth') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_comment_depth') : [...(_local.bulkApplyFields ?? []), 'max_comment_depth']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_comment_depth')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_comment_depth')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_comment_depth') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_comment_depth') : [...(_local.bulkApplyFields ?? []), 'max_comment_depth']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.max_comment_depth" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.max_comment_depth" }
|
||||
@@ -98,9 +96,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('comment_order') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'comment_order') : [...(_local.bulkApplyFields ?? []), 'comment_order']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('comment_order')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('comment_order')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('comment_order') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'comment_order') : [...(_local.bulkApplyFields ?? []), 'comment_order']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.comment_order" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.comment_order" }
|
||||
@@ -122,9 +119,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('min_comment_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'min_comment_length') : [...(_local.bulkApplyFields ?? []), 'min_comment_length']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('min_comment_length')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('min_comment_length')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('min_comment_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'min_comment_length') : [...(_local.bulkApplyFields ?? []), 'min_comment_length']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.min_comment_length" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.min_comment_length" }
|
||||
@@ -149,9 +145,8 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic", "name": "Label", "props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_comment_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_comment_length') : [...(_local.bulkApplyFields ?? []), 'max_comment_length']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_comment_length')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_comment_length')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_comment_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_comment_length') : [...(_local.bulkApplyFields ?? []), 'max_comment_length']}}" } }] },
|
||||
{ "type": "basic", "name": "Div", "children": [
|
||||
{ "type": "basic", "name": "Span", "text": "$t:sirsoft-board.admin.settings.fields.max_comment_length" },
|
||||
{ "type": "basic", "name": "P", "props": { "className": "text-xs text-gray-500 dark:text-gray-400 mt-0.5 font-normal" }, "text": "$t:sirsoft-board.admin.settings.fields.descriptions.max_comment_length" }
|
||||
|
||||
+44
-44
@@ -55,16 +55,6 @@
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('order_by') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'order_by') : [...(_local.bulkApplyFields ?? []), 'order_by']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -73,7 +63,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('order_by')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('order_by') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'order_by') : [...(_local.bulkApplyFields ?? []), 'order_by']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -136,16 +136,6 @@
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('order_direction') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'order_direction') : [...(_local.bulkApplyFields ?? []), 'order_direction']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -154,7 +144,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('order_direction')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('order_direction') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'order_direction') : [...(_local.bulkApplyFields ?? []), 'order_direction']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -215,16 +215,6 @@
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('per_page') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'per_page') : [...(_local.bulkApplyFields ?? []), 'per_page']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -233,7 +223,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('per_page')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('per_page') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'per_page') : [...(_local.bulkApplyFields ?? []), 'per_page']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -307,16 +307,6 @@
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('per_page_mobile') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'per_page_mobile') : [...(_local.bulkApplyFields ?? []), 'per_page_mobile']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -325,7 +315,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('per_page_mobile')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('per_page_mobile') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'per_page_mobile') : [...(_local.bulkApplyFields ?? []), 'per_page_mobile']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
|
||||
+22
-22
@@ -51,16 +51,6 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer" },
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('notify_author') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'notify_author') : [...(_local.bulkApplyFields ?? []), 'notify_author']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -69,7 +59,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('notify_author')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('notify_author') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'notify_author') : [...(_local.bulkApplyFields ?? []), 'notify_author']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -116,16 +116,6 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer" },
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('notify_admin_on_post') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'notify_admin_on_post') : [...(_local.bulkApplyFields ?? []), 'notify_admin_on_post']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -134,7 +124,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('notify_admin_on_post')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('notify_admin_on_post') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'notify_admin_on_post') : [...(_local.bulkApplyFields ?? []), 'notify_admin_on_post']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
|
||||
+60
-60
@@ -76,29 +76,29 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"name": "Label",
|
||||
"props": {
|
||||
"className": "flex items-center gap-2 px-4 py-3 bg-gray-50 dark:bg-gray-700/50 border-b border-gray-200 dark:border-gray-700 cursor-pointer select-none"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => k.startsWith('admin.')).every(k => (_local.bulkApplyFields ?? []).includes(k)) ? (_local.bulkApplyFields ?? []).filter(k => !k.startsWith('admin.')) : (_local.bulkApplyFields ?? []).concat(Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => k.startsWith('admin.'))).filter((v, i, a) => a.indexOf(v) === i)}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 pointer-events-none",
|
||||
"className": "checkbox flex-shrink-0",
|
||||
"checked": "{{Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => k.startsWith('admin.')).length > 0 && Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => k.startsWith('admin.')).every(k => (_local.bulkApplyFields ?? []).includes(k))}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => k.startsWith('admin.')).every(k => (_local.bulkApplyFields ?? []).includes(k)) ? (_local.bulkApplyFields ?? []).filter(k => !k.startsWith('admin.')) : (_local.bulkApplyFields ?? []).concat(Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => k.startsWith('admin.'))).filter((v, i, a) => a.indexOf(v) === i)}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -106,14 +106,14 @@
|
||||
"props": {
|
||||
"name": "shield",
|
||||
"size": "sm",
|
||||
"className": "text-purple-500 dark:text-purple-400 pointer-events-none"
|
||||
"className": "text-purple-500 dark:text-purple-400"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"props": {
|
||||
"className": "text-base font-semibold text-gray-800 dark:text-gray-100 pointer-events-none"
|
||||
"className": "text-base font-semibold text-gray-800 dark:text-gray-100"
|
||||
},
|
||||
"text": "$t:sirsoft-board.admin.settings.permissions_table.admin_section"
|
||||
}
|
||||
@@ -134,24 +134,14 @@
|
||||
"item_var": "perm"
|
||||
},
|
||||
"props": {
|
||||
"className": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0]) ? 'bg-purple-50 dark:bg-purple-900/20' : 'bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700'}} flex flex-col gap-2 px-4 py-2.5 transition-colors cursor-pointer"
|
||||
"className": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0]) ? 'bg-purple-50 dark:bg-purple-900/20' : 'bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700'}} flex flex-col gap-2 px-4 py-2.5 transition-colors"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0]) ? (_local.bulkApplyFields ?? []).filter(f => f !== perm?.[0]) : [...(_local.bulkApplyFields ?? []), perm?.[0]]}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"name": "Label",
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 pointer-events-none"
|
||||
"className": "flex items-start gap-2 cursor-pointer"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
@@ -161,7 +151,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0])}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0]) ? (_local.bulkApplyFields ?? []).filter(f => f !== perm?.[0]) : [...(_local.bulkApplyFields ?? []), perm?.[0]]}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -172,7 +172,7 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"name": "Span",
|
||||
"props": {
|
||||
"className": "text-sm font-medium text-gray-700 dark:text-gray-300"
|
||||
},
|
||||
@@ -239,29 +239,29 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"name": "Label",
|
||||
"props": {
|
||||
"className": "flex items-center gap-2 px-4 py-3 bg-gray-50 dark:bg-gray-700/50 border-b border-gray-200 dark:border-gray-700 cursor-pointer select-none"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => !k.startsWith('admin.')).every(k => (_local.bulkApplyFields ?? []).includes(k)) ? (_local.bulkApplyFields ?? []).filter(k => k.startsWith('admin.')) : (_local.bulkApplyFields ?? []).concat(Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => !k.startsWith('admin.'))).filter((v, i, a) => a.indexOf(v) === i)}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Input",
|
||||
"props": {
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 pointer-events-none",
|
||||
"className": "checkbox flex-shrink-0",
|
||||
"checked": "{{Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => !k.startsWith('admin.')).length > 0 && Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => !k.startsWith('admin.')).every(k => (_local.bulkApplyFields ?? []).includes(k))}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => !k.startsWith('admin.')).every(k => (_local.bulkApplyFields ?? []).includes(k)) ? (_local.bulkApplyFields ?? []).filter(k => k.startsWith('admin.')) : (_local.bulkApplyFields ?? []).concat(Object.keys(settings?.data?.basic_defaults?.default_board_permissions ?? {}).filter(k => !k.startsWith('admin.'))).filter((v, i, a) => a.indexOf(v) === i)}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -269,14 +269,14 @@
|
||||
"props": {
|
||||
"name": "users",
|
||||
"size": "sm",
|
||||
"className": "text-blue-500 dark:text-blue-400 pointer-events-none"
|
||||
"className": "text-blue-500 dark:text-blue-400"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"props": {
|
||||
"className": "text-base font-semibold text-gray-800 dark:text-gray-100 pointer-events-none"
|
||||
"className": "text-base font-semibold text-gray-800 dark:text-gray-100"
|
||||
},
|
||||
"text": "$t:sirsoft-board.admin.settings.permissions_table.user_section"
|
||||
}
|
||||
@@ -297,24 +297,14 @@
|
||||
"item_var": "perm"
|
||||
},
|
||||
"props": {
|
||||
"className": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0]) ? 'bg-blue-50 dark:bg-blue-900/20' : 'bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700'}} flex flex-col gap-2 px-4 py-2.5 transition-colors cursor-pointer"
|
||||
"className": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0]) ? 'bg-blue-50 dark:bg-blue-900/20' : 'bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700'}} flex flex-col gap-2 px-4 py-2.5 transition-colors"
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0]) ? (_local.bulkApplyFields ?? []).filter(f => f !== perm?.[0]) : [...(_local.bulkApplyFields ?? []), perm?.[0]]}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"name": "Label",
|
||||
"props": {
|
||||
"className": "flex items-start gap-2 pointer-events-none"
|
||||
"className": "flex items-start gap-2 cursor-pointer"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
@@ -324,7 +314,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0])}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes(perm?.[0]) ? (_local.bulkApplyFields ?? []).filter(f => f !== perm?.[0]) : [...(_local.bulkApplyFields ?? []), perm?.[0]]}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -335,7 +335,7 @@
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"name": "Span",
|
||||
"props": {
|
||||
"className": "text-sm font-medium text-gray-700 dark:text-gray-300"
|
||||
},
|
||||
|
||||
+6
-12
@@ -51,9 +51,8 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('min_title_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'min_title_length') : [...(_local.bulkApplyFields ?? []), 'min_title_length']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('min_title_length')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('min_title_length')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('min_title_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'min_title_length') : [...(_local.bulkApplyFields ?? []), 'min_title_length']}}" } }] },
|
||||
{
|
||||
"type": "basic", "name": "Div",
|
||||
"children": [
|
||||
@@ -91,9 +90,8 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_title_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_title_length') : [...(_local.bulkApplyFields ?? []), 'max_title_length']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_title_length')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_title_length')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_title_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_title_length') : [...(_local.bulkApplyFields ?? []), 'max_title_length']}}" } }] },
|
||||
{
|
||||
"type": "basic", "name": "Div",
|
||||
"children": [
|
||||
@@ -131,9 +129,8 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('min_content_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'min_content_length') : [...(_local.bulkApplyFields ?? []), 'min_content_length']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('min_content_length')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('min_content_length')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('min_content_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'min_content_length') : [...(_local.bulkApplyFields ?? []), 'min_content_length']}}" } }] },
|
||||
{
|
||||
"type": "basic", "name": "Div",
|
||||
"children": [
|
||||
@@ -171,9 +168,8 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_content_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_content_length') : [...(_local.bulkApplyFields ?? []), 'max_content_length']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_content_length')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('max_content_length')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_content_length') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_content_length') : [...(_local.bulkApplyFields ?? []), 'max_content_length']}}" } }] },
|
||||
{
|
||||
"type": "basic", "name": "Div",
|
||||
"children": [
|
||||
@@ -211,9 +207,8 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white cursor-pointer mb-2" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('blocked_keywords') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'blocked_keywords') : [...(_local.bulkApplyFields ?? []), 'blocked_keywords']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('blocked_keywords')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('blocked_keywords')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('blocked_keywords') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'blocked_keywords') : [...(_local.bulkApplyFields ?? []), 'blocked_keywords']}}" } }] },
|
||||
{
|
||||
"type": "basic", "name": "Div",
|
||||
"children": [
|
||||
@@ -255,9 +250,8 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer" },
|
||||
"actions": [{ "type": "click", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('new_display_hours') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'new_display_hours') : [...(_local.bulkApplyFields ?? []), 'new_display_hours']}}" } }],
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('new_display_hours')}}" } },
|
||||
{ "type": "basic", "name": "Input", "props": { "type": "checkbox", "className": "checkbox flex-shrink-0 mt-0.5", "checked": "{{(_local.bulkApplyFields ?? []).includes('new_display_hours')}}" }, "actions": [{ "type": "change", "handler": "setState", "params": { "target": "local", "bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('new_display_hours') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'new_display_hours') : [...(_local.bulkApplyFields ?? []), 'new_display_hours']}}" } }] },
|
||||
{
|
||||
"type": "basic", "name": "Div",
|
||||
"children": [
|
||||
|
||||
+22
-22
@@ -51,16 +51,6 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-900 dark:text-white flex-1 cursor-pointer" },
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('use_reply') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'use_reply') : [...(_local.bulkApplyFields ?? []), 'use_reply']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -69,7 +59,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('use_reply')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('use_reply') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'use_reply') : [...(_local.bulkApplyFields ?? []), 'use_reply']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -116,16 +116,6 @@
|
||||
"type": "basic",
|
||||
"name": "Label",
|
||||
"props": { "className": "flex items-start gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 flex-1 cursor-pointer" },
|
||||
"actions": [
|
||||
{
|
||||
"type": "click",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_reply_depth') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_reply_depth') : [...(_local.bulkApplyFields ?? []), 'max_reply_depth']}}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -134,7 +124,17 @@
|
||||
"type": "checkbox",
|
||||
"className": "checkbox flex-shrink-0 mt-0.5",
|
||||
"checked": "{{(_local.bulkApplyFields ?? []).includes('max_reply_depth')}}"
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "change",
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"bulkApplyFields": "{{(_local.bulkApplyFields ?? []).includes('max_reply_depth') ? (_local.bulkApplyFields ?? []).filter(f => f !== 'max_reply_depth') : [...(_local.bulkApplyFields ?? []), 'max_reply_depth']}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
|
||||
+1144
File diff suppressed because it is too large.
Load diff
+27
-14
@@ -94,7 +94,7 @@
|
||||
"props": {
|
||||
"className": "text-sm font-medium text-gray-900 dark:text-white"
|
||||
},
|
||||
"text": "{{ch.name?.[$locale] ?? ch.name?.ko ?? ch.id}}"
|
||||
"text": "{{ch.name ?? ch.id}}"
|
||||
},
|
||||
{
|
||||
"type": "basic",
|
||||
@@ -102,7 +102,7 @@
|
||||
"props": {
|
||||
"className": "block text-xs text-gray-400 dark:text-gray-500"
|
||||
},
|
||||
"text": "{{ch.source_label?.[$locale] ?? ch.source_label?.ko ?? ch.source}}"
|
||||
"text": "{{ch.source_label ?? ch.source}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -151,7 +151,7 @@
|
||||
},
|
||||
"props": {
|
||||
"type": "button",
|
||||
"className": "{{(_local.activeNotificationChannel ?? query.channel ?? (availableChannels?.data?.channels ?? [])[0]?.id ?? 'mail') === ch.id ? 'border-b-2 border-indigo-500 text-indigo-600 dark:text-indigo-400' : 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300'}} px-4 py-2.5 text-sm font-medium whitespace-nowrap flex items-center gap-2"
|
||||
"className": "{{(_local.activeNotificationChannel ?? query.channel ?? (availableChannels?.data?.channels ?? [])[0]?.id ?? 'mail') === ch.id ? 'border-b-2 border-indigo-500 dark:border-indigo-400 text-indigo-600 dark:text-indigo-400' : 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300'}} px-4 py-2.5 text-sm font-medium whitespace-nowrap flex items-center gap-2"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
@@ -165,7 +165,7 @@
|
||||
{
|
||||
"type": "basic",
|
||||
"name": "Span",
|
||||
"text": "{{ch.name?.[$locale] ?? ch.name?.ko ?? ch.id}}"
|
||||
"text": "{{ch.name ?? ch.id}}"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
@@ -239,9 +239,18 @@
|
||||
"className": "w-20 px-3 py-1.5 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",
|
||||
"value": "{{String(query.per_page || 20)}}",
|
||||
"options": [
|
||||
{ "value": "10", "label": "10" },
|
||||
{ "value": "20", "label": "20" },
|
||||
{ "value": "50", "label": "50" }
|
||||
{
|
||||
"value": "10",
|
||||
"label": "10"
|
||||
},
|
||||
{
|
||||
"value": "20",
|
||||
"label": "20"
|
||||
},
|
||||
{
|
||||
"value": "50",
|
||||
"label": "50"
|
||||
}
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
@@ -555,13 +564,17 @@
|
||||
{
|
||||
"handler": "setState",
|
||||
"params": {
|
||||
"target": "local",
|
||||
"editingDefinition": "{{def}}",
|
||||
"editingTemplate": "{{(def.templates ?? []).find(t => t.channel === (_local.activeNotificationChannel ?? query.channel ?? 'mail'))}}",
|
||||
"editingRecipients": "{{JSON.parse(JSON.stringify((def.templates ?? []).find(t => t.channel === (_local.activeNotificationChannel ?? query.channel ?? 'mail'))?.recipients ?? []))}}",
|
||||
"editLang": "{{$locale}}",
|
||||
"templateErrors": null,
|
||||
"isSaving": false
|
||||
"target": "global",
|
||||
"board_notification_template_form_modal": {
|
||||
"template": "{{(def.templates ?? []).find(t => t.channel === (_local.activeNotificationChannel ?? query.channel ?? 'mail'))}}",
|
||||
"definition": "{{def}}",
|
||||
"recipients": "{{JSON.parse(JSON.stringify((def.templates ?? []).find(t => t.channel === (_local.activeNotificationChannel ?? query.channel ?? 'mail'))?.recipients ?? []))}}",
|
||||
"editLang": "{{$locale}}",
|
||||
"errors": null,
|
||||
"isSaving": false,
|
||||
"roleSearchResults": [],
|
||||
"userSearchResults": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+55
@@ -567,6 +567,29 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "field_notify_admin_on_report_channels",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "space-y-1.5" },
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Label", "props": { "className": "text-xs text-gray-500 dark:text-gray-400" }, "text": "$t:sirsoft-board.admin.settings.fields.notify_admin_on_report_channels" },
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "TagInput",
|
||||
"props": {
|
||||
"name": "report_policy.notify_admin_on_report_channels",
|
||||
"options": [
|
||||
{ "value": "mail", "label": "$t:sirsoft-board.admin.settings.fields.notification_channels.mail" },
|
||||
{ "value": "database", "label": "$t:sirsoft-board.admin.settings.fields.notification_channels.database" }
|
||||
],
|
||||
"placeholder": "$t:sirsoft-board.admin.settings.fields.notify_admin_on_report_channels_placeholder",
|
||||
"disabled": "{{_computed.isReadOnly}}"
|
||||
}
|
||||
},
|
||||
{ "type": "basic", "name": "Span", "props": { "className": "block text-xs text-gray-400 dark:text-gray-500" }, "text": "$t:sirsoft-board.admin.settings.fields.notify_admin_on_report_channels_help" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -596,6 +619,38 @@
|
||||
},
|
||||
{ "type": "composite", "name": "Toggle", "props": { "name": "report_policy.notify_author_on_report_action", "className": "flex-shrink-0 mt-0.5" } }
|
||||
]
|
||||
},
|
||||
{
|
||||
"comment": "하위 옵션 (토글 ON 시에만 표시)",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"if": "{{_local.form?.report_policy?.notify_author_on_report_action === true}}",
|
||||
"props": { "className": "px-4 py-4 space-y-4 border-t border-gray-200 dark:border-gray-700" },
|
||||
"children": [
|
||||
{
|
||||
"id": "field_notify_author_on_report_action_channels",
|
||||
"type": "basic",
|
||||
"name": "Div",
|
||||
"props": { "className": "space-y-1.5" },
|
||||
"children": [
|
||||
{ "type": "basic", "name": "Label", "props": { "className": "text-xs text-gray-500 dark:text-gray-400" }, "text": "$t:sirsoft-board.admin.settings.fields.notify_author_on_report_action_channels" },
|
||||
{
|
||||
"type": "composite",
|
||||
"name": "TagInput",
|
||||
"props": {
|
||||
"name": "report_policy.notify_author_on_report_action_channels",
|
||||
"options": [
|
||||
{ "value": "mail", "label": "$t:sirsoft-board.admin.settings.fields.notification_channels.mail" },
|
||||
{ "value": "database", "label": "$t:sirsoft-board.admin.settings.fields.notification_channels.database" }
|
||||
],
|
||||
"placeholder": "$t:sirsoft-board.admin.settings.fields.notify_author_on_report_action_channels_placeholder",
|
||||
"disabled": "{{_computed.isReadOnly}}"
|
||||
}
|
||||
},
|
||||
{ "type": "basic", "name": "Span", "props": { "className": "block text-xs text-gray-400 dark:text-gray-500" }, "text": "$t:sirsoft-board.admin.settings.fields.notify_author_on_report_action_channels_help" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -160,7 +160,11 @@ class StoreBoardSettingsRequest extends FormRequest
|
||||
'report_policy.rejection_limit_days' => ['nullable', 'integer', 'min:1', 'max:365'],
|
||||
'report_policy.notify_admin_on_report' => ['nullable', 'boolean'],
|
||||
'report_policy.notify_admin_on_report_scope' => ['nullable', 'string', 'in:per_case,per_report'],
|
||||
'report_policy.notify_admin_on_report_channels' => ['nullable', 'array'],
|
||||
'report_policy.notify_admin_on_report_channels.*' => ['string', 'in:mail,database'],
|
||||
'report_policy.notify_author_on_report_action' => ['nullable', 'boolean'],
|
||||
'report_policy.notify_author_on_report_action_channels' => ['nullable', 'array'],
|
||||
'report_policy.notify_author_on_report_action_channels.*' => ['string', 'in:mail,database'],
|
||||
|
||||
// ========================================
|
||||
// report_permissions (신고 관리 권한) — 설정값이 아닌 DB 권한 데이터
|
||||
|
||||
@@ -177,6 +177,7 @@ class PostResource extends BaseApiResource
|
||||
'view_count' => $this->view_count,
|
||||
'comment_count' => (int) ($this->comments_count ?? 0),
|
||||
'reply_count' => (int) ($this->replies_count ?? 0),
|
||||
'attachment_count' => (int) ($this->attachments_count ?? 0),
|
||||
'has_attachment' => ((int) ($this->attachments_count ?? 0)) > 0,
|
||||
|
||||
// 썸네일 이미지 (첫 번째 이미지 첨부파일)
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
namespace Modules\Sirsoft\Board\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use Modules\Sirsoft\Board\Models\Board;
|
||||
use Modules\Sirsoft\Board\Models\Post;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\BoardRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 게시판 활동 로그 description_params 해석 리스너
|
||||
@@ -16,6 +15,13 @@ use Modules\Sirsoft\Board\Models\Post;
|
||||
*/
|
||||
class ActivityLogDescriptionResolver implements HookListenerInterface
|
||||
{
|
||||
/**
|
||||
* @param BoardRepositoryInterface $boardRepository 게시판 Repository (ID/slug → 이름 변환)
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly BoardRepositoryInterface $boardRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 구독할 훅과 메서드 매핑 반환
|
||||
*
|
||||
@@ -98,7 +104,7 @@ class ActivityLogDescriptionResolver implements HookListenerInterface
|
||||
// 2순위: properties.board_id로 DB 조회
|
||||
$boardId = $properties['board_id'] ?? null;
|
||||
if ($boardId) {
|
||||
$board = Board::find($boardId);
|
||||
$board = $this->boardRepository->find((int) $boardId);
|
||||
$params['board_name'] = $board?->name ?? "ID: {$boardId}";
|
||||
}
|
||||
|
||||
@@ -164,7 +170,7 @@ class ActivityLogDescriptionResolver implements HookListenerInterface
|
||||
|
||||
// slug로 board_name 조회 (fallback)
|
||||
if (empty($params['board_name']) && ! empty($properties['slug'])) {
|
||||
$board = Board::where('slug', $properties['slug'])->first();
|
||||
$board = $this->boardRepository->findBySlug((string) $properties['slug']);
|
||||
if ($board) {
|
||||
$params['board_name'] = $board->name;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use Modules\Sirsoft\Board\Models\BoardType;
|
||||
use Modules\Sirsoft\Board\Models\Comment;
|
||||
use Modules\Sirsoft\Board\Models\Post;
|
||||
use Modules\Sirsoft\Board\Models\Report;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\ReportRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 게시판 모듈 활동 로그 리스너
|
||||
@@ -26,6 +27,13 @@ class BoardActivityLogListener implements HookListenerInterface
|
||||
{
|
||||
use ResolvesActivityLogType;
|
||||
|
||||
/**
|
||||
* @param ReportRepositoryInterface $reportRepository 신고 bulk lookup
|
||||
*/
|
||||
public function __construct(
|
||||
protected ReportRepositoryInterface $reportRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 구독할 훅과 메서드 매핑 반환
|
||||
*
|
||||
@@ -548,7 +556,7 @@ class BoardActivityLogListener implements HookListenerInterface
|
||||
*/
|
||||
public function handleReportAfterBulkUpdateStatus(array $ids, array $data, int $affectedRows, array $snapshots = []): void
|
||||
{
|
||||
$reports = Report::whereIn('id', $ids)->get()->keyBy('id');
|
||||
$reports = $this->reportRepository->findByIdsKeyed($ids);
|
||||
|
||||
foreach ($ids as $reportId) {
|
||||
$report = $reports->get($reportId);
|
||||
|
||||
@@ -3,14 +3,21 @@
|
||||
namespace Modules\Sirsoft\Board\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Sirsoft\Board\Models\Comment;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\BoardRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 댓글 생성/삭제/복원 시 게시판의 comments_count를 재카운팅합니다.
|
||||
*/
|
||||
class BoardCommentsCountSyncListener implements HookListenerInterface
|
||||
{
|
||||
/**
|
||||
* @param BoardRepositoryInterface $boardRepository 게시판 Repository
|
||||
*/
|
||||
public function __construct(
|
||||
protected BoardRepositoryInterface $boardRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 구독할 훅 목록을 반환합니다.
|
||||
*
|
||||
@@ -33,19 +40,12 @@ class BoardCommentsCountSyncListener implements HookListenerInterface
|
||||
/**
|
||||
* 게시판의 comments_count를 재카운팅합니다.
|
||||
*
|
||||
* @param Comment $comment 댓글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @param Comment $comment 댓글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @return void
|
||||
*/
|
||||
public function syncCommentsCount(Comment $comment, string $slug): void
|
||||
{
|
||||
$count = DB::table('board_comments')
|
||||
->where('board_id', $comment->board_id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
|
||||
DB::table('boards')
|
||||
->where('id', $comment->board_id)
|
||||
->update(['comments_count' => $count]);
|
||||
$this->boardRepository->recalculateCommentsCount((int) $comment->board_id);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Modules\Sirsoft\Board\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use App\Models\Role;
|
||||
use App\Contracts\Repositories\RoleRepositoryInterface;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use BackedEnum;
|
||||
@@ -32,6 +32,7 @@ class BoardNotificationDataListener implements HookListenerInterface
|
||||
private readonly PostRepositoryInterface $postRepository,
|
||||
private readonly CommentRepositoryInterface $commentRepository,
|
||||
private readonly UserNotificationSettingService $userNotificationSettingService,
|
||||
private readonly RoleRepositoryInterface $roleRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -72,9 +73,22 @@ class BoardNotificationDataListener implements HookListenerInterface
|
||||
*/
|
||||
public function contributeDefaultDefinitions(array $definitions, array $context = []): array
|
||||
{
|
||||
$seeder = new \Modules\Sirsoft\Board\Database\Seeders\BoardNotificationDefinitionSeeder();
|
||||
// module.php 의 getNotificationDefinitions() 가 SSoT — declarative getter 패턴
|
||||
/** @var \Modules\Sirsoft\Board\Module $module */
|
||||
$module = app(\App\Extension\ModuleManager::class)->getModule('sirsoft-board');
|
||||
if (! $module) {
|
||||
return $definitions;
|
||||
}
|
||||
|
||||
return array_merge($definitions, $seeder->getDefaultDefinitions());
|
||||
$contributed = [];
|
||||
foreach ($module->getNotificationDefinitions() as $data) {
|
||||
$contributed[] = array_merge($data, [
|
||||
'extension_type' => 'module',
|
||||
'extension_identifier' => $module->getIdentifier(),
|
||||
]);
|
||||
}
|
||||
|
||||
return array_merge($definitions, $contributed);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,7 +504,7 @@ class BoardNotificationDataListener implements HookListenerInterface
|
||||
}
|
||||
|
||||
// 게시판별 관리자 역할 조회, 없으면 superAdmin 폴백
|
||||
$managerRole = Role::where('identifier', "sirsoft-board.{$slug}.manager")->first();
|
||||
$managerRole = $this->roleRepository->findByIdentifier("sirsoft-board.{$slug}.manager");
|
||||
$managers = $managerRole ? $managerRole->users()->get() : collect();
|
||||
|
||||
if ($managers->isEmpty()) {
|
||||
@@ -687,6 +701,8 @@ class BoardNotificationDataListener implements HookListenerInterface
|
||||
*/
|
||||
private function emptyResult(): array
|
||||
{
|
||||
return ['notifiable' => null, 'notifiables' => null, 'data' => [], 'context' => []];
|
||||
// context.skip=true 로 NotificationHookListener 가 발송 자체를 스킵하도록 지시.
|
||||
// (template recipients 기반 해석이 Listener 의 정책 gate 를 우회하는 문제 대응)
|
||||
return ['notifiable' => null, 'notifiables' => null, 'data' => [], 'context' => ['skip' => true]];
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,21 @@
|
||||
namespace Modules\Sirsoft\Board\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Sirsoft\Board\Models\Post;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\BoardRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 게시글 생성/삭제/복원 시 게시판의 posts_count를 재카운팅합니다.
|
||||
*/
|
||||
class BoardPostsCountSyncListener implements HookListenerInterface
|
||||
{
|
||||
/**
|
||||
* @param BoardRepositoryInterface $boardRepository 게시판 Repository
|
||||
*/
|
||||
public function __construct(
|
||||
protected BoardRepositoryInterface $boardRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 구독할 훅 목록을 반환합니다.
|
||||
*
|
||||
@@ -33,20 +40,13 @@ class BoardPostsCountSyncListener implements HookListenerInterface
|
||||
/**
|
||||
* 게시판의 posts_count를 재카운팅합니다.
|
||||
*
|
||||
* @param Post $post 게시글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @param array $options 옵션 (after_create/after_delete만 전달)
|
||||
* @param Post $post 게시글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @param array $options 옵션 (after_create/after_delete만 전달)
|
||||
* @return void
|
||||
*/
|
||||
public function syncPostsCount(Post $post, string $slug, array $options = []): void
|
||||
{
|
||||
$count = DB::table('board_posts')
|
||||
->where('board_id', $post->board_id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
|
||||
DB::table('boards')
|
||||
->where('id', $post->board_id)
|
||||
->update(['posts_count' => $count]);
|
||||
$this->boardRepository->recalculatePostsCount((int) $post->board_id);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,21 @@
|
||||
namespace Modules\Sirsoft\Board\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Sirsoft\Board\Models\Comment;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\CommentRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 대댓글 생성/삭제/복원 시 부모 댓글의 replies_count를 재카운팅합니다.
|
||||
*/
|
||||
class CommentReplySyncListener implements HookListenerInterface
|
||||
{
|
||||
/**
|
||||
* @param CommentRepositoryInterface $commentRepository 댓글 Repository
|
||||
*/
|
||||
public function __construct(
|
||||
protected CommentRepositoryInterface $commentRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 구독할 훅 목록을 반환합니다.
|
||||
*
|
||||
@@ -33,8 +40,8 @@ class CommentReplySyncListener implements HookListenerInterface
|
||||
/**
|
||||
* 부모 댓글의 replies_count를 재카운팅합니다.
|
||||
*
|
||||
* @param Comment $comment 댓글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @param Comment $comment 댓글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @return void
|
||||
*/
|
||||
public function syncRepliesCount(Comment $comment, string $slug): void
|
||||
@@ -43,13 +50,6 @@ class CommentReplySyncListener implements HookListenerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$count = DB::table('board_comments')
|
||||
->where('parent_id', $comment->parent_id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
|
||||
DB::table('board_comments')
|
||||
->where('id', $comment->parent_id)
|
||||
->update(['replies_count' => $count]);
|
||||
$this->commentRepository->recalculateRepliesCount((int) $comment->parent_id);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,21 @@
|
||||
namespace Modules\Sirsoft\Board\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Sirsoft\Board\Models\Attachment;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\PostRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 첨부파일 업로드/삭제 시 게시글의 attachments_count를 재카운팅합니다.
|
||||
*/
|
||||
class PostAttachmentCountSyncListener implements HookListenerInterface
|
||||
{
|
||||
/**
|
||||
* @param PostRepositoryInterface $postRepository 게시글 Repository
|
||||
*/
|
||||
public function __construct(
|
||||
protected PostRepositoryInterface $postRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 구독할 훅 목록을 반환합니다.
|
||||
*
|
||||
@@ -33,7 +40,7 @@ class PostAttachmentCountSyncListener implements HookListenerInterface
|
||||
/**
|
||||
* 게시글의 attachments_count를 재카운팅합니다.
|
||||
*
|
||||
* @param Attachment $attachment 첨부파일 모델
|
||||
* @param Attachment $attachment 첨부파일 모델
|
||||
* @return void
|
||||
*/
|
||||
public function syncAttachmentsCount(Attachment $attachment): void
|
||||
@@ -42,13 +49,6 @@ class PostAttachmentCountSyncListener implements HookListenerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$count = DB::table('board_attachments')
|
||||
->where('post_id', $attachment->post_id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
|
||||
DB::table('board_posts')
|
||||
->where('id', $attachment->post_id)
|
||||
->update(['attachments_count' => $count]);
|
||||
$this->postRepository->recalculateAttachmentsCount((int) $attachment->post_id);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,21 @@
|
||||
namespace Modules\Sirsoft\Board\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Sirsoft\Board\Models\Comment;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\PostRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 댓글 생성/삭제/복원 시 게시글의 comments_count를 재카운팅합니다.
|
||||
*/
|
||||
class PostCountSyncListener implements HookListenerInterface
|
||||
{
|
||||
/**
|
||||
* @param PostRepositoryInterface $postRepository 게시글 Repository
|
||||
*/
|
||||
public function __construct(
|
||||
protected PostRepositoryInterface $postRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 구독할 훅 목록을 반환합니다.
|
||||
*
|
||||
@@ -33,19 +40,12 @@ class PostCountSyncListener implements HookListenerInterface
|
||||
/**
|
||||
* 게시글의 comments_count를 재카운팅합니다.
|
||||
*
|
||||
* @param Comment $comment 댓글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @param Comment $comment 댓글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @return void
|
||||
*/
|
||||
public function syncCommentsCount(Comment $comment, string $slug): void
|
||||
{
|
||||
$count = DB::table('board_comments')
|
||||
->where('post_id', $comment->post_id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
|
||||
DB::table('board_posts')
|
||||
->where('id', $comment->post_id)
|
||||
->update(['comments_count' => $count]);
|
||||
$this->postRepository->recalculateCommentsCount((int) $comment->post_id);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,21 @@
|
||||
namespace Modules\Sirsoft\Board\Listeners;
|
||||
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Sirsoft\Board\Models\Post;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\PostRepositoryInterface;
|
||||
|
||||
/**
|
||||
* 답글(게시글) 생성/삭제/복원 시 부모 게시글의 replies_count를 재카운팅합니다.
|
||||
*/
|
||||
class PostReplySyncListener implements HookListenerInterface
|
||||
{
|
||||
/**
|
||||
* @param PostRepositoryInterface $postRepository 게시글 Repository
|
||||
*/
|
||||
public function __construct(
|
||||
protected PostRepositoryInterface $postRepository,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 구독할 훅 목록을 반환합니다.
|
||||
*
|
||||
@@ -33,9 +40,9 @@ class PostReplySyncListener implements HookListenerInterface
|
||||
/**
|
||||
* 부모 게시글의 replies_count를 재카운팅합니다.
|
||||
*
|
||||
* @param Post $post 게시글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @param array $options 옵션 (after_create/after_delete만 전달)
|
||||
* @param Post $post 게시글 모델
|
||||
* @param string $slug 게시판 slug
|
||||
* @param array $options 옵션 (after_create/after_delete만 전달)
|
||||
* @return void
|
||||
*/
|
||||
public function syncRepliesCount(Post $post, string $slug, array $options = []): void
|
||||
@@ -44,13 +51,6 @@ class PostReplySyncListener implements HookListenerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$count = DB::table('board_posts')
|
||||
->where('parent_id', $post->parent_id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
|
||||
DB::table('board_posts')
|
||||
->where('id', $post->parent_id)
|
||||
->update(['replies_count' => $count]);
|
||||
$this->postRepository->recalculateRepliesCount((int) $post->parent_id);
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,10 @@ class Board extends Model
|
||||
// 기타 설정
|
||||
'blocked_keywords',
|
||||
|
||||
// 카운트 컬럼
|
||||
'posts_count',
|
||||
'comments_count',
|
||||
|
||||
// 생성자/수정자
|
||||
'created_by',
|
||||
'updated_by',
|
||||
@@ -159,6 +163,8 @@ class Board extends Model
|
||||
'order_direction' => OrderDirection::class,
|
||||
'max_comment_depth' => 'integer',
|
||||
'comment_order' => OrderDirection::class,
|
||||
'posts_count' => 'integer',
|
||||
'comments_count' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,13 @@ class BoardType extends Model
|
||||
*/
|
||||
protected array $trackableFields = ['name'];
|
||||
|
||||
/**
|
||||
* 다국어 JSON 컬럼 — sub-key dot-path 단위 user_overrides 보존.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected array $translatableTrackableFields = ['name'];
|
||||
|
||||
protected $table = 'board_types';
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
Loaded 100 of 1545 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user