Front End bug fixed
This commit is contained in:
@ -518,7 +518,7 @@ class EntryMember(models.Model):
|
||||
class GoalImages(models.Model):
|
||||
user=models.ForeignKey(CustomUser, on_delete=models.DO_NOTHING)
|
||||
goalimage = models.FileField(upload_to='goals/%y%m%d', blank=True, null=True)
|
||||
goaltime = models.DateTimeField(_("Goal time"), auto_now=False, auto_now_add=False)
|
||||
goaltime = models.DateTimeField(_("Goal time"), blank=True, null=True,auto_now=False, auto_now_add=False)
|
||||
team_name = models.CharField(_("Team name"), max_length=255)
|
||||
event_code = models.CharField(_("event code"), max_length=255)
|
||||
cp_number = models.IntegerField(_("CP numner"))
|
||||
|
||||
@ -245,15 +245,12 @@
|
||||
|
||||
const display = document.getElementById('goalTimeDisplay');
|
||||
const validateElement = document.getElementById('validate');
|
||||
setLatePoint(0);
|
||||
|
||||
if (!display) {
|
||||
console.error('Goal time display element not found');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const newTime = new Date(input.value);
|
||||
// inputがnullの場合は棄権処理
|
||||
if (!input) {
|
||||
const validateElement = document.getElementById('validate');
|
||||
display.textContent = '棄権';
|
||||
@ -263,8 +260,32 @@
|
||||
return;
|
||||
}
|
||||
|
||||
display.textContent = newTime.toLocaleString();
|
||||
const newTime = new Date(input.value);
|
||||
|
||||
updateValidationWithGoalTime(newTime)
|
||||
|
||||
display.classList.remove('hidden');
|
||||
input.classList.add('hidden');
|
||||
}
|
||||
|
||||
function updateValidationWithGoalTime(goaltime) {
|
||||
|
||||
const display = document.getElementById('goalTimeDisplay');
|
||||
|
||||
if (!goaltime) {
|
||||
const validateElement = document.getElementById('validate');
|
||||
display.textContent = '棄権';
|
||||
if (validateElement) {
|
||||
validateElement.textContent = '棄権';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
const newTime = new Date(goaltime);
|
||||
|
||||
display.textContent = newTime.toLocaleString();
|
||||
let late_point = 0;
|
||||
const eventCodeSelect = document.getElementById('eventCode');
|
||||
const event_code = eventCodeSelect.value;
|
||||
const zekkenNumberSelect = document.getElementById('zekkenNumber');
|
||||
@ -305,6 +326,8 @@
|
||||
lateElement.classList.remove('text-red-600');
|
||||
}
|
||||
}
|
||||
console.info('latePoint update=',late_point);
|
||||
calculatePoints(late_point); // 総合ポイントの計算
|
||||
})
|
||||
.catch(error => handleApiError(error));
|
||||
|
||||
@ -314,7 +337,7 @@
|
||||
const timeDiff = (newTime - startTime) / 1000; // 分単位の差
|
||||
const maxTime = team.duration + 15*60; // 制限時間+15分
|
||||
|
||||
//console.info('startTime=',startTime,',goalTime=',newTime,',timeDiff=',timeDiff,'duration=',team.duration,',maxTime=',maxTime);
|
||||
console.info('startTime=',startTime,',goalTime=',newTime,',timeDiff=',timeDiff,'duration=',team.duration,',maxTime=',maxTime);
|
||||
updateValidation(timeDiff, maxTime );
|
||||
|
||||
// 1秒でも遅刻すると、1分につき-50点
|
||||
@ -331,22 +354,26 @@
|
||||
lateElement.classList.remove('text-red-600');
|
||||
}
|
||||
}
|
||||
console.info('latePoint update=',late_point);
|
||||
calculatePoints(late_point); // 総合ポイントの計算
|
||||
});
|
||||
calculatePoints(); // 総合ポイントの計算
|
||||
|
||||
return late_point;
|
||||
} catch (e) {
|
||||
console.error('Error updating goal time:', e);
|
||||
alert('無効な日時形式です。');
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
display.classList.remove('hidden');
|
||||
input.classList.add('hidden');
|
||||
}
|
||||
function setLatePoint(points){
|
||||
|
||||
const lateElement = document.getElementById('latePoints');
|
||||
lateElement.textContent = points;
|
||||
}
|
||||
|
||||
// 判定の更新を行う補助関数
|
||||
function updateValidation(timeDiff, maxTime) {
|
||||
//console.log('updateValidation',timeDiff,' > ',maxTime)
|
||||
console.log('updateValidation:',timeDiff,' > ',maxTime)
|
||||
const validateElement = document.getElementById('validate');
|
||||
if (validateElement) {
|
||||
if (timeDiff > maxTime) {
|
||||
@ -439,7 +466,7 @@
|
||||
if (!checkinsResponse.ok)
|
||||
throw new Error(`Checkins fetch failed with status ${checkinsResponse.status}`);
|
||||
|
||||
|
||||
setLatePoint(0);
|
||||
const teamData = await teamResponse.json();
|
||||
const checkinsData = await checkinsResponse.json();
|
||||
|
||||
@ -447,6 +474,8 @@
|
||||
updateGoalTimeDisplay(teamData.end_datetime);
|
||||
original_goal_time = teamData.end_datetime;
|
||||
|
||||
latePoint = updateValidationWithGoalTime(teamData.end_datetime);
|
||||
|
||||
// イベントコードに対応するイベントを検索
|
||||
//const event = eventData.find(e => e.code === document.getElementById('eventCode').value);
|
||||
|
||||
@ -459,12 +488,14 @@
|
||||
//'(未ゴール)';
|
||||
|
||||
const goalTimeDisplay = document.getElementById('goalTimeDisplay');
|
||||
console.info('teamData=',teamData)
|
||||
console.info('end_datetime=',teamData.end_datetime)
|
||||
const goalTime = teamData.end_datetime ?
|
||||
new Date(teamData.end_datetime).toLocaleString() :
|
||||
'未ゴール';
|
||||
goalTimeDisplay.textContent = goalTime;
|
||||
|
||||
updateGoalTime(goalTime) // ゴール時刻の表示を更新
|
||||
//updateGoalTime(teamData.end_datetime) // ゴール時刻の表示を更新
|
||||
|
||||
console.info('teamData.goal_photo = ',teamData.goal_photo );
|
||||
|
||||
@ -572,7 +603,7 @@
|
||||
//document.getElementById('finalPoints').textContent =
|
||||
// totalPoints + buyPoints + (teamData.late_points || 0);
|
||||
|
||||
calculatePoints(); // 総合ポイントの計算
|
||||
calculatePoints(latePoint); // 総合ポイントの計算
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading team info:', error);
|
||||
@ -1007,13 +1038,12 @@ function applyImageOrientation(imgElement) {
|
||||
}
|
||||
|
||||
// 総合ポイントの計算
|
||||
function calculatePoints() {
|
||||
function calculatePoints(latePoints=0) {
|
||||
//console.info('calculatePoints');
|
||||
const rows = Array.from(document.getElementById('checkinList').children);
|
||||
let totalPoints = 0; // チェックインポイントの合計をクリア
|
||||
let cpPoints = 0; // チェックインポイントの合計をクリア
|
||||
let buyPoints = 0; // 買い物ポイントの合計をクリア
|
||||
let latePoints = 0; // 遅刻ポイントの合計をクリア
|
||||
|
||||
// 各行のチェックインポイント及び買い物ポイントを合算
|
||||
rows.forEach(row => {
|
||||
@ -1031,12 +1061,16 @@ function applyImageOrientation(imgElement) {
|
||||
});
|
||||
|
||||
// 遅刻ポイントの計算=ゴール時刻がEventのゴール時刻を超えていたら1分につき-50点を加算する。
|
||||
latePoints = parseInt(document.getElementById('latePoints').textContent) || 0;
|
||||
|
||||
if (latePoints===0){
|
||||
console.info('latePoints=',document.getElementById('latePoints').textContent);
|
||||
latePoints = parseInt(document.getElementById('latePoints').textContent) || 0;
|
||||
}
|
||||
// 総合得点を計算
|
||||
const finalPoints = totalPoints + latePoints;
|
||||
|
||||
// 判定を更新。順位を表示、ゴール時刻を15分経過したら失格
|
||||
//console.info('calculatePoints:totalPoints=',cpPoints,',buyPoints=',buyPoints,',finalPoints=',finalPoints);
|
||||
console.info('calculatePoints:totalPoints=',cpPoints,',buyPoints=',buyPoints,',latePoints=',latePoints,',finalPoints=',finalPoints);
|
||||
|
||||
document.getElementById('totalPoints').textContent = cpPoints;
|
||||
document.getElementById('buyPoints').textContent = buyPoints;
|
||||
|
||||
Reference in New Issue
Block a user