Skip to content

Commit

Permalink
Run prettier on manager lists js files.
Browse files Browse the repository at this point in the history
  • Loading branch information
somiaj committed Jan 10, 2024
1 parent 10e9d0c commit a2713ff
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 61 deletions.
46 changes: 31 additions & 15 deletions htdocs/js/AchievementList/achievementlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
if (achievement.checked) return true;
}
document.getElementById('select_achievement_err_msg')?.classList.remove('d-none');
document.getElementById('achievement-table')?.addEventListener('change', e => {
document.getElementById('select_achievement_err_msg')?.classList.add('d-none');
}, { once : true });
document.getElementById('achievement-table')?.addEventListener(
'change',
(e) => {
document.getElementById('select_achievement_err_msg')?.classList.add('d-none');
},
{ once: true }
);
return false;
};

document.getElementById('achievement-list')?.addEventListener('submit', e => {
document.getElementById('achievement-list')?.addEventListener('submit', (e) => {
const action = document.getElementById('current_action')?.value || '';
if (['edit', 'assign', 'export', 'score'].includes(action)) {
if (!is_achievement_selected()) {
Expand All @@ -25,10 +29,14 @@
e.stopPropagation();
document.getElementById('create_file_err_msg')?.classList.remove('d-none');
create_text.classList.add('is-invalid');
create_text.addEventListener('change', e => {
document.getElementById('create_file_err_msg')?.classList.add('d-none');
document.getElementById('create_text')?.classList.remove('is-invalid');
}, { once : true });
create_text.addEventListener(
'change',
(e) => {
document.getElementById('create_file_err_msg')?.classList.add('d-none');
document.getElementById('create_text')?.classList.remove('is-invalid');
},
{ once: true }
);
} else if (document.getElementById('create_select')?.selectedIndex == 1 && !is_achievement_selected()) {
e.preventDefault();
e.stopPropagation();
Expand All @@ -43,18 +51,26 @@
e.stopPropagation();
document.getElementById('delete_confirm_err_msg')?.classList.remove('d-none');
delete_confirm.classList.add('is-invalid');
delete_confirm.addEventListener('change', e => {
document.getElementById('delete_select')?.classList.remove('is-invalid');
document.getElementById('delete_confirm_err_msg')?.classList.add('d-none');
}, { once : true });
delete_confirm.addEventListener(
'change',
(e) => {
document.getElementById('delete_select')?.classList.remove('is-invalid');
document.getElementById('delete_confirm_err_msg')?.classList.add('d-none');
},
{ once: true }
);
}
}
});

// Remove select error message when changing tabs.
for (const tab of document.querySelectorAll('a[data-bs-toggle="tab"]')) {
tab.addEventListener('shown.bs.tab', e => {
document.getElementById('select_achievement_err_msg')?.classList.add('d-none');
}, { once : true });
tab.addEventListener(
'shown.bs.tab',
(e) => {
document.getElementById('select_achievement_err_msg')?.classList.add('d-none');
},
{ once: true }
);
}
})();
73 changes: 46 additions & 27 deletions htdocs/js/ProblemSetList/problemsetlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
if (set.checked) return true;
}
document.getElementById('select_set_err_msg')?.classList.remove('d-none');
document.getElementById('set_table_id')?.addEventListener('change', e => {
document.getElementById('select_set_err_msg')?.classList.add('d-none');
}, { once : true });
document.getElementById('set_table_id')?.addEventListener(
'change',
(e) => {
document.getElementById('select_set_err_msg')?.classList.add('d-none');
},
{ once: true }
);
return false;
};

document.getElementById('problemsetlist')?.addEventListener('submit', e => {
document.getElementById('problemsetlist')?.addEventListener('submit', (e) => {
const action = document.getElementById('current_action')?.value || '';
if (action === 'filter') {
const filter = document.getElementById('filter_select')?.selectedIndex || 0;
Expand All @@ -24,10 +28,14 @@
e.stopPropagation();
document.getElementById('filter_err_msg')?.classList.remove('d-none');
filter_text.classList.add('is-invalid');
filter_text.addEventListener('change', e => {
document.getElementById('filter_err_msg')?.classList.add('d-none');
document.getElementById('filter_text')?.classList.remove('is-invalid');
}, { once : true });
filter_text.addEventListener(
'change',
(e) => {
document.getElementById('filter_err_msg')?.classList.add('d-none');
document.getElementById('filter_text')?.classList.remove('is-invalid');
},
{ once: true }
);
}
} else if (['edit', 'publish', 'export', 'save_export', 'score'].includes(action)) {
if (!is_set_selected()) {
Expand All @@ -41,10 +49,14 @@
e.stopPropagation();
document.getElementById('import_file_err_msg')?.classList.remove('d-none');
import_select.classList.add('is-invalid');
import_select.addEventListener('change', e => {
document.getElementById('import_source_select')?.classList.remove('is-invalid');
document.getElementById('import_file_err_msg')?.classList.add('d-none');
}, { once : true });
import_select.addEventListener(
'change',
(e) => {
document.getElementById('import_source_select')?.classList.remove('is-invalid');
document.getElementById('import_file_err_msg')?.classList.add('d-none');
},
{ once: true }
);
}
} else if (action === 'create') {
const create_text = document.getElementById('create_text');
Expand All @@ -53,10 +65,14 @@
e.stopPropagation();
document.getElementById('create_file_err_msg')?.classList.remove('d-none');
create_text.classList.add('is-invalid');
create_text.addEventListener('change', e => {
document.getElementById('create_file_err_msg')?.classList.add('d-none');
document.getElementById('create_text')?.classList.remove('is-invalid');
}, { once : true });
create_text.addEventListener(
'change',
(e) => {
document.getElementById('create_file_err_msg')?.classList.add('d-none');
document.getElementById('create_text')?.classList.remove('is-invalid');
},
{ once: true }
);
} else if (document.getElementById('create_select')?.selectedIndex == 1 && !is_set_selected()) {
e.preventDefault();
e.stopPropagation();
Expand All @@ -71,17 +87,21 @@
e.stopPropagation();
document.getElementById('delete_confirm_err_msg')?.classList.remove('d-none');
delete_confirm.classList.add('is-invalid');
delete_confirm.addEventListener('change', e => {
document.getElementById('delete_select')?.classList.remove('is-invalid');
document.getElementById('delete_confirm_err_msg')?.classList.add('d-none');
}, { once : true });
delete_confirm.addEventListener(
'change',
(e) => {
document.getElementById('delete_select')?.classList.remove('is-invalid');
document.getElementById('delete_confirm_err_msg')?.classList.add('d-none');
},
{ once: true }
);
}
}
});

// Remove select error message when changing tabs.
for (const tab of document.querySelectorAll('a[data-bs-toggle="tab"]')) {
tab.addEventListener('shown.bs.tab', e => {
tab.addEventListener('shown.bs.tab', (e) => {
document.getElementById('select_set_err_msg')?.classList.add('d-none');
});
}
Expand Down Expand Up @@ -135,17 +155,16 @@
// Initialize the date/time picker for the import form.
const importDateShift = document.getElementById('import_date_shift');
if (importDateShift) {

luxon.Settings.defaultLocale = importDateShift.dataset.locale ?? 'en';

// Compute the time difference between the current browser timezone and the course timezone.
// flatpickr gives the time in the browser's timezone, and this is used to adjust to the course timezone.
// Note that this is in seconds.
const timezoneAdjustment = (
(new Date((new Date).toLocaleString('en-US'))).getTime() -
(new Date((new Date).toLocaleString('en-US',
{ timeZone: importDateShift.dataset.timezone ?? 'America/New_York' }))).getTime()
);
const timezoneAdjustment =
new Date(new Date().toLocaleString('en-US')).getTime() -
new Date(
new Date().toLocaleString('en-US', { timeZone: importDateShift.dataset.timezone ?? 'America/New_York' })
).getTime();

const fp = flatpickr(importDateShift.parentNode, {
allowInput: true,
Expand Down
56 changes: 37 additions & 19 deletions htdocs/js/UserList/userlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@
if (user.checked) return true;
}
document.getElementById('select_user_err_msg')?.classList.remove('d-none');
document.getElementById('classlist-table')?.addEventListener('change', e => {
document.getElementById('select_user_err_msg')?.classList.add('d-none');
}, { once : true });
document.getElementById('classlist-table')?.addEventListener(
'change',
(e) => {
document.getElementById('select_user_err_msg')?.classList.add('d-none');
},
{ once: true }
);
return false;
};

document.getElementById('user-list-form')?.addEventListener('submit', e => {
document.getElementById('user-list-form')?.addEventListener('submit', (e) => {
const action = document.getElementById('current_action')?.value || '';
if (action === 'filter') {
const filter = document.getElementById('filter_select')?.selectedIndex || 0;
Expand All @@ -50,10 +54,14 @@
e.stopPropagation();
document.getElementById('filter_err_msg')?.classList.remove('d-none');
filter_text.classList.add('is-invalid');
filter_text.addEventListener('change', e => {
document.getElementById('filter_text')?.classList.remove('is-invalid');
document.getElementById('filter_err_msg')?.classList.add('d-none');
}, { once : true });
filter_text.addEventListener(
'change',
(e) => {
document.getElementById('filter_text')?.classList.remove('is-invalid');
document.getElementById('filter_err_msg')?.classList.add('d-none');
},
{ once: true }
);
}
} else if (action === 'edit' || action === 'password') {
if (!is_user_selected()) {
Expand All @@ -65,16 +73,22 @@
if (!is_user_selected()) {
e.preventDefault();
e.stopPropagation();
} else if (document.getElementById('export_select_target')?.value === 'new' &&
export_filename.value === '') {
} else if (
document.getElementById('export_select_target')?.value === 'new' &&
export_filename.value === ''
) {
e.preventDefault();
e.stopPropagation();
document.getElementById('export_file_err_msg')?.classList.remove('d-none');
export_filename.classList.add('is-invalid');
export_filename.addEventListener('change', e => {
document.getElementById('export_filename')?.classList.remove('is-invalid');
document.getElementById('export_file_err_msg')?.classList.add('d-none');
}, { once : true });
export_filename.addEventListener(
'change',
(e) => {
document.getElementById('export_filename')?.classList.remove('is-invalid');
document.getElementById('export_file_err_msg')?.classList.add('d-none');
},
{ once: true }
);
}
} else if (action === 'delete') {
const delete_confirm = document.getElementById('delete_select');
Expand All @@ -86,17 +100,21 @@
e.stopPropagation();
document.getElementById('delete_confirm_err_msg')?.classList.remove('d-none');
delete_confirm.classList.add('is-invalid');
delete_confirm.addEventListener('change', e => {
document.getElementById('delete_select')?.classList.remove('is-invalid');
document.getElementById('delete_confirm_err_msg')?.classList.add('d-none');
}, { once : true });
delete_confirm.addEventListener(
'change',
(e) => {
document.getElementById('delete_select')?.classList.remove('is-invalid');
document.getElementById('delete_confirm_err_msg')?.classList.add('d-none');
},
{ once: true }
);
}
}
});

// Remove select error message when changing tabs.
for (const tab of document.querySelectorAll('a[data-bs-toggle="tab"]')) {
tab.addEventListener('shown.bs.tab', e => {
tab.addEventListener('shown.bs.tab', (e) => {
document.getElementById('select_user_err_msg')?.classList.add('d-none');
});
}
Expand Down

0 comments on commit a2713ff

Please sign in to comment.