From 4e1d7d8f1ad79b400dcb98b1f7670e260c2b629e Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Fri, 23 Dec 2022 22:12:42 +0800 Subject: [PATCH] refactor(web/problem/manage/managers): update_uploader_form --- .../controllers/problem_managers_manage.php | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/web/app/controllers/problem_managers_manage.php b/web/app/controllers/problem_managers_manage.php index a93b4a6..23bba87 100644 --- a/web/app/controllers/problem_managers_manage.php +++ b/web/app/controllers/problem_managers_manage.php @@ -32,26 +32,35 @@ $managers_form = newAddDelCmdForm( $managers_form->runAtServer(); if (isSuperUser(Auth::user())) { - $update_uploader_form = new UOJBs4Form('update_uploader'); + $update_uploader_form = new UOJForm('update_uploader'); + $update_uploader_form->appendHTML( + HTML::tag( + 'div', + ['class' => 'col-auto'], + HTML::tag('label', ['class' => 'col-form-label'], '上传者') + ) + ); $update_uploader_form->addInput( 'new_uploader_username', - 'text', - '用户名', - UOJProblem::info('uploader') ?: 'root', - function ($username, &$vdata) { - if (!UOJUser::query($username)) { - return '用户不存在'; - } + [ + 'div_class' => 'col-auto', + 'default_value' => UOJProblem::info('uploader') ?: 'root', + 'validator_php' => function ($username, &$vdata) { + if (!UOJUser::query($username)) { + return '用户不存在'; + } - $vdata['username'] = $username; + $vdata['username'] = $username; - return ''; - }, - null + return ''; + }, + ] ); - $update_uploader_form->submit_button_config['align'] = 'compressed'; - $update_uploader_form->submit_button_config['text'] = '修改上传者'; - $update_uploader_form->submit_button_config['class_str'] = 'mt-2 btn btn-warning'; + $update_uploader_form->config['form']['class'] = 'mt-2 row g-3 align-items-center'; + $update_uploader_form->config['submit_container']['class'] = 'col-auto'; + $update_uploader_form->config['submit_button']['class'] = 'btn btn-warning'; + $update_uploader_form->config['submit_button']['text'] = '修改上传者'; + $update_uploader_form->config['confirm']['smart'] = true; $update_uploader_form->handle = function (&$vdata) { DB::update([ "update problems",