JS勉強中のkintone開発初心者です。
担当者別に日付の記事を更新していく機構を作りたいです。
カレンダービュー内に、文字列を表示→クリックでレコード詳細に飛ぶ
という挙動は実装しつつ、
添付ファイルフィールドに添付された画像を
各日付の背景に設定するような挙動を組みたいです。
以下のコードを設定してみたのですが機能せずでした。
勉強不足な質問で恐縮ですが、どなたかお力添えいただけますと幸いです。
(() => {
'use strict';
kintone.events.on('app.record.index.show', (event) => {
const records = event.records;
const targetNode = document.querySelector('.fc-view-container');
if (!targetNode) return;
const observer = new MutationObserver((mutationsList, observer) => {
records.forEach(record => {
const fileField = record.添付ファイル.value;
if (fileField.length > 0) {
const imageUrl = fileField[0].url; // 最初の添付ファイルのURLを取得
const calendarCells = document.querySelectorAll('.calendar-cell-gaia');
calendarCells.forEach(cell => {
cell.style.backgroundImage = `url(${imageUrl})`;
cell.style.backgroundSize = 'cover';
});
}
});
});
const config = { childList: true, subtree: true };
observer.observe(targetNode, config);
});
})();