-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
155 additions
and
37 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/js/menu/application/service/UserSettingMenuLayerSettingChangeEventService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { execute } from "./UserSettingMenuLayerSettingChangeEventService"; | ||
import { execute as userSettingObjectGetService } from "../../../user/service/UserSettingObjectGetService"; | ||
|
||
describe("UserSettingMenuLayerSettingChangeEventServiceTest", () => | ||
{ | ||
test("execute test", () => | ||
{ | ||
const object1 = userSettingObjectGetService(); | ||
expect(object1.layer).toBe(false); | ||
|
||
const mock1 = { | ||
"stopPropagation": () => { return null }, | ||
"target": { | ||
"value": "1" | ||
} | ||
}; | ||
execute(mock1); | ||
|
||
const object2 = userSettingObjectGetService(); | ||
expect(object2.layer).toBe(true); | ||
|
||
const mock2 = { | ||
"stopPropagation": () => { return null }, | ||
"target": { | ||
"value": "0" | ||
} | ||
}; | ||
execute(mock2); | ||
|
||
const object3 = userSettingObjectGetService(); | ||
expect(object3.layer).toBe(false); | ||
}); | ||
}); |
23 changes: 19 additions & 4 deletions
23
src/js/menu/application/service/UserSettingMenuLayerSettingChangeEventService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
import type { UserSettingObjectImpl } from "../../../interface/UserSettingObjectImpl"; | ||
import { execute as userSettingObjectGetService } from "../../../user/service/UserSettingObjectGetService"; | ||
import { execute as userSettingObjectUpdateService } from "../../../user/service/UserSettingObjectUpdateService"; | ||
|
||
/** | ||
* @description ユーザー設定メニューに配置された各Elementにイベント登録を行う | ||
* Register events in each Element placed in the User Settings menu. | ||
* @description ユーザー設定メニューの非表示レイヤーの設定情報更新 | ||
* Updated setting information for hidden layers in the user settings menu | ||
* | ||
* @param {Event} event | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = (): void => | ||
export const execute = (event: Event): void => | ||
{ | ||
|
||
// 親のイベントを中止 | ||
event.stopPropagation(); | ||
|
||
if (event.target) { | ||
const userSettingObject: UserSettingObjectImpl = userSettingObjectGetService(); | ||
|
||
const element = event.target as HTMLSelectElement; | ||
userSettingObject.layer = element.value === "1"; | ||
|
||
userSettingObjectUpdateService(userSettingObject); | ||
} | ||
}; |
41 changes: 41 additions & 0 deletions
41
src/js/menu/application/service/UserSettingMenuLayerSettingOptionSelectedService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { execute } from "./UserSettingMenuLayerSettingOptionSelectedService"; | ||
import { execute as userSettingObjectUpdateService } from "../../../user/service/UserSettingObjectUpdateService"; | ||
|
||
describe("UserSettingMenuLayerSettingOptionSelectedServiceTest", () => | ||
{ | ||
test("execute test", () => | ||
{ | ||
const select = document.createElement("select"); | ||
const option1 = document.createElement("option"); | ||
select.appendChild(option1); | ||
|
||
const option2 = document.createElement("option"); | ||
select.appendChild(option2); | ||
|
||
execute(select); | ||
expect(option1.selected).toBe(true); | ||
expect(option2.selected).toBe(false); | ||
|
||
const mock1 = { | ||
"layer": true, | ||
"modal": true, | ||
"type": "zlib" | ||
}; | ||
|
||
userSettingObjectUpdateService(mock1); | ||
execute(select); | ||
expect(option1.selected).toBe(false); | ||
expect(option2.selected).toBe(true); | ||
|
||
const mock2 = { | ||
"layer": false, | ||
"modal": true, | ||
"type": "zlib" | ||
}; | ||
|
||
userSettingObjectUpdateService(mock2); | ||
execute(select); | ||
expect(option1.selected).toBe(true); | ||
expect(option2.selected).toBe(false); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
src/js/menu/application/service/UserSettingMenuLayerSettingOptionSelectedService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { execute as userSettingObjectGetService } from "../../../user/service/UserSettingObjectGetService"; | ||
import { UserSettingObjectImpl } from "../../../interface/UserSettingObjectImpl"; | ||
|
||
/** | ||
* @description 非表示レイヤーの選択状態を保存情報に合わせて表示を切り替える | ||
* Switching the display of the selection state of hidden layers to match the saved information | ||
* | ||
* @param {HTMLSelectElement} element | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = (element: HTMLSelectElement): void => | ||
{ | ||
const userSettingObject: UserSettingObjectImpl = userSettingObjectGetService(); | ||
|
||
const optionElement = element | ||
.children[userSettingObject.layer ? 1 : 0] as HTMLOptionElement; | ||
|
||
optionElement.selected = true; | ||
}; |
24 changes: 0 additions & 24 deletions
24
src/js/menu/application/service/UserSettingMenuRegisterEventService.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/js/menu/application/usecase/UserSettingMenuLayerSettingRegisterEventUseCase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { $USER_PUBLISH_LAYER_SETTING_ID } from "../../../config/UserSettingConfig"; | ||
import { EventType } from "../../../tool/domain/event/EventType"; | ||
import { execute as userSettingMenuLayerSettingChangeEventService } from "../service/UserSettingMenuLayerSettingChangeEventService"; | ||
import { execute as userSettingMenuLayerSettingOptionSelectedService } from "../service/UserSettingMenuLayerSettingOptionSelectedService"; | ||
|
||
/** | ||
* @description ユーザー設定メニューの非表示レイヤーのイベント登録のユースケース | ||
* Use case of event registration for hidden layers in the user settings menu | ||
* | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = (): void => | ||
{ | ||
const element: HTMLSelectElement | null = document | ||
.getElementById($USER_PUBLISH_LAYER_SETTING_ID) as HTMLSelectElement; | ||
|
||
if (element) { | ||
|
||
// ユーザー個別のデータから表示を切り替える | ||
userSettingMenuLayerSettingOptionSelectedService(element); | ||
|
||
element | ||
.addEventListener(EventType.CHANGE, (event: Event): void => | ||
{ | ||
userSettingMenuLayerSettingChangeEventService(event); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters