mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-22 00:36:28 +08:00
core&ui: support file renaming (#688)
Co-authored-by: undefined <i@undefined.moe>
This commit is contained in:
1 parent
746efef9bf
commit
01cb6944b7
19 files changed
+496
-144
No files matched your search
@@ -40,6 +40,25 @@ const page = new NamedPage('problem_config', () => {
|
||||
});
|
||||
}
|
||||
|
||||
async function handleClickRename(ev: JQuery.ClickEvent<Document, undefined, any, any>) {
|
||||
const file = [$(ev.currentTarget).parent().parent().attr('data-filename')];
|
||||
// eslint-disable-next-line no-alert
|
||||
const newName = prompt(i18n('Enter a new name for the file: '));
|
||||
if (!newName) return;
|
||||
try {
|
||||
await request.post('./files', {
|
||||
operation: 'rename_files',
|
||||
files: file,
|
||||
newNames: [newName],
|
||||
type: 'testdata',
|
||||
});
|
||||
Notification.success(i18n('File have been renamed.'));
|
||||
await pjax.request({ url: './files?d=testdata&sidebar=true', push: false });
|
||||
} catch (error) {
|
||||
Notification.error(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClickRemove(ev: JQuery.ClickEvent<Document, undefined, any, any>) {
|
||||
const file = [$(ev.currentTarget).parent().parent().attr('data-filename')];
|
||||
const action = await new ConfirmDialog({
|
||||
@@ -132,6 +151,7 @@ const page = new NamedPage('problem_config', () => {
|
||||
mountComponent();
|
||||
|
||||
$(document).on('click', '[name="testdata__upload"]', () => handleClickUpload());
|
||||
$(document).on('click', '[name="testdata__rename"]', (ev) => handleClickRename(ev));
|
||||
$(document).on('click', '[name="testdata__delete"]', (ev) => handleClickRemove(ev));
|
||||
$(document).on('click', '[name="testdata__download__all"]', () => handleClickDownloadAll());
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user