カスタムダイアログの追加
最終更新日: 2024年7月18日
作成対象:
- ユーザー
- 管理者
レビューアプリにカスタムダイアログを追加する方法を確認するには、次の手順に従います。
使用例
const acceptWithModification = {
id: 'accept_with_modification_dialog',
view: {
component: "dialog",
"header": {
"items": [
{
component: 'label',
extraclass: "header",
label: 'Accept With Modifications',
}
]
},
content: {
items: [
{
component: 'div',
"extraclass": "revised-text",
items: [
{
component: 'label',
label: 'Revised Text (Required)',
extraclass: 'revised-text-label'
},
{
component: "textarea",
"extraclass": "revised-text-textarea",
"data": "@extraProps.revisedText",
"stopKeyPropagation": true,
}
]
},
{
component: 'div',
"extraclass": "adjudication-rationale",
items: [
{
component: 'label',
label: 'Adjudicator Comment Rationale (Required)',
extraclass: 'adjudication-rationale-label'
},
{
component: "textarea",
extraclass: "adjudication-rationale-textarea",
"data": "@extraProps.adjudicationRationale",
"on-keyup": {
"name": "",
"eventArgs": {
"keys": [
"ENTER"
]
}
},
"stopKeyPropagation": true
}
]
},
],
},
footer: {
"items": [
{
"component": "button",
"label": "Cancel",
"on-click": "handleClose",
"variant": "secondary"
},
{
"component": "button",
"label": "Submit",
"variant": "cta",
"on-click": "submitAcceptWithModification"
}
]
}
},
model: {
deps: [],
},
controller:{
submitAcceptWithModification: function () {
const extraProps = {
'revisedText': this.getValue("revisedText"),
'adjudicationRationale': this.getValue("adjudicationRationale"),
}
this.args.onSuccess(extraProps)
this.next('handleClose')
},
handleClose() {
tcx.eventHandler.next(tcx.eventHandler.KEYS.APP_HIDE_DIALOG, { id: 'accept_with_modification_dialog' })
}
}
}
カスタムダイアログの呼び出し
この例では、カスタムダイアログを開くためのボタンを追加する方法に関する情報について説明します。
このためのパネル review_comment
考えてみましょう。 完全な拡張機能については、次を参照してください。
レビューのコメント
const reviewComment = {
id: 'review_comment',
view: {
items: [
...
{
component: "button",
"icon": "MultipleAdd",
"variant": "action",
"quiet": true,
"extraclass": "hover-item",
"title": "Accept with Modifications",
"on-click": "acceptWithModification",
target: {
key: 'title',
value: 'Reject comment',
viewState: VIEW_STATE.APPEND,
},
}
],
},
controller: {
...
sendAcceptWithModificationProps(args) {
this.next('updateExtraProps', args)
},
acceptWithModification() {
tcx.eventHandler.next(tcx.eventHandler.KEYS.APP_SHOW_DIALOG,
{
id: 'accept_with_modification_dialog',
args: {
onSuccess: (extraProps) => this.next('sendAcceptWithModificationProps', extraProps),
}
})
}
...
}
}
カスタムダイアログに引数を渡す方法
ここでは、ダイアログ ID を使用して args
を渡し、成功イベントの場合にコールバックを処理するために、これを使用して onSuccess を渡しています。
キャンセルのクリック時にカスタムコールバックを提供し、ダイアログのキャンセルイベント内で処理する場合は、onCancel
を渡すこともできます。
recommendation-more-help
11125c99-e1a1-4369-b5d7-fb3098b9b178