fix classname to term

This commit is contained in:
2025-03-24 14:29:59 +08:00
parent 344e50b72c
commit 6b5f4f63a2
7 changed files with 103 additions and 74 deletions

View File

@@ -20,6 +20,15 @@ const classItems = [
{ label: "ゆり", value: "ゆり" },
]
const termItems = [
{ label: "0歳児", value: "0歳児" },
{ label: "1歳児", value: "1歳児" },
{ label: "2歳児", value: "2歳児" },
{ label: "3歳児", value: "3歳児" },
{ label: "4歳児", value: "4歳児" },
{ label: "5歳児", value: "5歳児" },
]
let notificationEl;
let loadingEl;
let dialogEl;
@@ -38,7 +47,7 @@ function getHeaderSpace(className, isDetailPage) {
return headerSpace;
}
function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, yearElId = false, monthElId = false, dateElId = false, classElId = false, defaultThisMonth = false, }) {
function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, yearElId = false, monthElId = false, dateElId = false, termElId = false, defaultThisMonth = false, }) {
const result = {};
if (document.getElementById(groupId)) {
@@ -59,11 +68,6 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
});
result[yearElId] = yearEl;
btnGroupAreaEl.appendChild(yearEl);
// const label = document.createElement('div');
// label.classList = 'label'
// label.textContent = '年';
// btnGroupAreaEl.appendChild(label);
}
if (monthElId) {
@@ -76,11 +80,6 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
});
result[monthElId] = monthEl;
btnGroupAreaEl.appendChild(monthEl);
// const label = document.createElement('div');
// label.classList = 'label'
// label.textContent = '月';
// btnGroupAreaEl.appendChild(label);
}
if (dateElId) {
@@ -93,27 +92,17 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
});
result[dateElId] = dateEl;
btnGroupAreaEl.appendChild(dateEl);
// const label = document.createElement('div');
// label.classList = 'label'
// label.textContent = '日';
// btnGroupAreaEl.appendChild(label);
}
if (classElId) {
// const label = document.createElement('div');
// label.classList = 'label'
// label.textContent = 'クラス';
// btnGroupAreaEl.appendChild(label);
const classEl = new Kuc.Combobox({
id: classElId,
items: classItems,
className: "classroom input",
label: 'クラス',
if (termElId) {
const termEl = new Kuc.Combobox({
id: termElId,
items: termItems,
className: "term input",
label: '学年',
});
result[classElId] = classEl;
btnGroupAreaEl.appendChild(classEl);
result[termElId] = termEl;
btnGroupAreaEl.appendChild(termEl);
}
const btnEl = new Kuc.Button({
@@ -125,7 +114,7 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
result[btnElId] = btnEl;
btnEl.addEventListener('click', (e) => {
showError(false);
const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, classElId });
const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, termElId });
if (checkResult) {
btnOnClick(e, checkResult);
}
@@ -135,11 +124,11 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
return result;
}
function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElId }) {
function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, termElId }) {
const year = yearElId && map[yearElId].value;
const month = monthElId && map[monthElId].value;
const date = dateElId && (map[dateElId].value === 'end' ? getLastDate(year, month).getDate() : map[dateElId].value);
const className = classElId && map[classElId].value;
const term = termElId && map[termElId].value;
const errorMsgs = [];
@@ -155,8 +144,8 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
if (dateElId && !date) {
errorMsgs.push(' · 日を選択してください。');
}
if (classElId && !className) {
errorMsgs.push(' · クラスを選択してください。');
if (termElId && !term) {
errorMsgs.push(' · 学年を選択してください。');
}
if (errorMsgs.length > 0) {
showError(true, btnLabel + 'エラー\n' + errorMsgs.join('\n'))
@@ -167,7 +156,7 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
year,
month,
date,
className,
term,
}
}