Skip to content

Commit

Permalink
Merge pull request #206 from kufu/features/auto_move_today
Browse files Browse the repository at this point in the history
Switch tab when tab date is today
  • Loading branch information
kinoppyd committed May 17, 2024
2 parents 9b6e85e + e3dba6d commit 4340c31
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/javascript/controllers/schedule_table_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ export default class extends Controller {
return;
}


if (id === '') {
tables[0].classList.remove('hidden');
buttons[0].classList.add('tab-btn-active');
const current = new Date();
const today = `${current.getFullYear()}-${("0"+(current.getMonth() + 1)).slice(-2)}-${current.getDate()}`;
var index = [...buttons].findIndex((button) => button.value.toString() === today );

if (index === -1) {
index = 0
}

tables[index].classList.remove('hidden');
buttons[index].classList.add('tab-btn-active');

return;
}

Expand Down

0 comments on commit 4340c31

Please sign in to comment.