Skip to content

Commit

Permalink
fix baserproject#2585 [カスタムコンテンツ] カスタムテーブルの編集画面で識別名と利用中のフィールドが同時に編集できない
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Jul 14, 2023
1 parent 1ca98d2 commit 31e3343
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions plugins/bc-custom-content/src/Service/CustomTablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,6 @@ public function update(EntityInterface $entity, array $postData)
$entity = $this->CustomTables->patchEntity($entity, $postData);
$entity = $this->CustomTables->saveOrFail($entity);

// 関連フィードの削除されたフィールドの反映、並び順の更新を実行
/** @var CustomLinksServiceInterface $customEntriesService */
$customLinksService = $this->getService(CustomLinksServiceInterface::class);
$customLinksService->updateFields(
$entity->id,
$entity->custom_links
);

/** @var CustomEntriesService $customEntriesService */
$customEntriesService = $this->getService(CustomEntriesServiceInterface::class);

Expand All @@ -234,6 +226,14 @@ public function update(EntityInterface $entity, array $postData)
throw new BcException(__d('baser_core', 'データベースに問題があります。エントリー保存用テーブルのリネーム処理に失敗しました。'));
}

// 関連フィードの削除されたフィールドの反映、並び順の更新を実行
/** @var CustomLinksServiceInterface $customEntriesService */
$customLinksService = $this->getService(CustomLinksServiceInterface::class);
$customLinksService->updateFields(
$entity->id,
$entity->custom_links
);

// フィールドの追加処理
$customEntriesService->addFields($entity->id, $entity->custom_links);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function test_update()

//カスタムリンクを追加するテスト
$postData = [
'name' => 'contact_edit',
'name' => 'contact_edit_2',
'new' => [
[
'no' => NULL,
Expand All @@ -371,12 +371,12 @@ public function test_update()
//アップデートメソッドを呼ぶ
$rs = $this->CustomTablesService->update($this->CustomTablesService->get(1), $postData);
//戻る値を確認
$this->assertEquals('contact_edit', $rs->name);
$this->assertEquals('contact_edit_2', $rs->name);
//カスタムリンクが追加できるか確認する事
$this->assertEquals('add_new', $rs->custom_links[0]->name);

//不要なテーブルを削除
$dataBaseService->dropTable('custom_entry_1_contact_edit');
$dataBaseService->dropTable('custom_entry_1_contact_edit_2');

//エラーする時をテスト
$this->expectException(PersistenceFailedException::class);
Expand Down

0 comments on commit 31e3343

Please sign in to comment.