|
110 | 110 | "uri": "<<uri>>"
|
111 | 111 | }
|
112 | 112 | }
|
| 113 | +` |
| 114 | + var baseContentsSendMessageItem = ` |
| 115 | +{ |
| 116 | + "type": "box", |
| 117 | + "layout": "vertical", |
| 118 | + "contents": [ |
| 119 | + { |
| 120 | + "type": "text", |
| 121 | + "text": "<<template>>", |
| 122 | + "color": "#2D558F", |
| 123 | + "wrap": true, |
| 124 | + "align": "center" |
| 125 | + } |
| 126 | + ], |
| 127 | + "paddingStart": "xl", |
| 128 | + "paddingEnd": "xl", |
| 129 | + "paddingTop": "md", |
| 130 | + "paddingBottom": "md", |
| 131 | + "action": { |
| 132 | + "type": "message", |
| 133 | + "label": "<<template>>", |
| 134 | + "text": "<<template>>" |
| 135 | + } |
| 136 | +} |
113 | 137 | `
|
114 | 138 |
|
115 | 139 | // テンプレートを使ってjsonを生成する
|
116 | 140 | generateJson = function (title, itemsArray) {
|
117 | 141 | var contents = []
|
118 | 142 | var contentItems = itemsArray.forEach(item => {
|
119 | 143 | let jsonStr;
|
120 |
| - if (item.uri) { |
| 144 | + if (item.isSendMessage) { |
| 145 | + jsonStr = baseContentsSendMessageItem.replace(/<<template>>/g, item.label) |
| 146 | + } else if (item.uri) { |
121 | 147 | jsonStr = baseContentsLinkItem.replace(/<<label>>/g, item.label).replace(/<<uri>>/g, item.uri)
|
122 | 148 | } else {
|
123 | 149 | jsonStr = baseContentsItem.replace(/<<template>>/g, item.label)
|
|
140 | 166 | // アイテム要素を追加
|
141 | 167 | $("#items").append(`
|
142 | 168 | <div class="item-wrap" >
|
143 |
| - <div class="col-sm-6"> |
| 169 | + <div class="col-sm-5"> |
144 | 170 | <input type="text" class="form-control item" id="item">
|
145 | 171 | </div>
|
146 | 172 | <div class="col-sm-4">
|
147 | 173 | <input type="text" class="form-control item" id="url-item">
|
148 | 174 | </div>
|
149 | 175 | <div class="col-sm-2">
|
| 176 | + <input class="form-check-input" type="checkbox" value="" id="isSendMessage"> |
| 177 | + <label class="form-check-label" for="isSendMessage"> |
| 178 | + isSendMessage |
| 179 | + </label> |
| 180 | + </div> |
| 181 | + <div class="col-sm-1"> |
150 | 182 | <button class="btn btn-primary btn-sm remove-item">Remove</button>
|
151 | 183 | </div>
|
152 | 184 | </div>
|
|
166 | 198 | // 配列内部のオブジェクト型は以下
|
167 | 199 | // {
|
168 | 200 | // label: <>,
|
169 |
| - // uri: <> |
| 201 | + // uri: <>, |
| 202 | + // isSendMessage: boolean |
170 | 203 | // }
|
171 | 204 |
|
172 | 205 | $(".item-wrap").each(function() {
|
173 | 206 | const label = $(this).find("#item").val();
|
174 | 207 | const uri = $(this).find("#url-item").val();
|
| 208 | + const isSendMessage = $(this).find("#isSendMessage").prop('checked'); |
175 | 209 | if (!label) {
|
176 | 210 | // skip
|
177 | 211 | } else if (!uri) {
|
178 | 212 | items.push({
|
179 | 213 | label,
|
180 |
| - uri: null |
| 214 | + uri: null, |
| 215 | + isSendMessage |
181 | 216 | })
|
182 | 217 | } else {
|
183 | 218 | items.push({
|
184 | 219 | label,
|
185 |
| - uri |
| 220 | + uri, |
| 221 | + isSendMessage |
186 | 222 | })
|
187 | 223 | }
|
188 | 224 | });
|
|
231 | 267 |
|
232 | 268 | <label for="item">Items:</label>
|
233 | 269 | <label for="url-item">2つめのボックスはURI(URIアクションの場合はここにURIを入力)</label>
|
| 270 | + <label for="isSendMessage">3つめのチェックボックスはSendMessageLinkにするかどうか(URIの入力よりも優先する)</label> |
234 | 271 | <div class="row" id="items">
|
235 | 272 | <div class="item-wrap" >
|
236 |
| - <div class="col-sm-6"> |
| 273 | + <div class="col-sm-5"> |
237 | 274 | <input type="text" class="form-control item" id="item">
|
238 | 275 | </div>
|
239 | 276 | <div class="col-sm-4">
|
240 | 277 | <input type="text" class="form-control item" id="url-item">
|
241 | 278 | </div>
|
242 | 279 | <div class="col-sm-2">
|
| 280 | + <input class="form-check-input" type="checkbox" value="" id="isSendMessage"> |
| 281 | + <label class="form-check-label" for="isSendMessage"> |
| 282 | + isSendMessage |
| 283 | + </label> |
| 284 | + </div> |
| 285 | + <div class="col-sm-1"> |
243 | 286 | <button class="btn btn-primary btn-sm remove-item">Remove</button>
|
244 | 287 | </div>
|
245 | 288 | </div>
|
|
0 commit comments