feat(web/lists): add redirect after create list
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-01-14 08:51:00 +08:00
parent 5f15f832af
commit 6a4f9a370a
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 21 additions and 9 deletions

View File

@ -9,16 +9,28 @@ Auth::check() || redirectToLogin();
UOJUser::checkPermission(Auth::user(), 'lists.view') || UOJResponse::page403(); UOJUser::checkPermission(Auth::user(), 'lists.view') || UOJResponse::page403();
if (UOJList::userCanCreateList(Auth::user())) { if (UOJList::userCanCreateList(Auth::user())) {
$new_list_form = new UOJBs4Form('new_list'); $new_list_form = new UOJForm('new_list');
$new_list_form->handle = function () { $new_list_form->handle = function () {
DB::insert("insert into lists (title, is_hidden) values ('未命名题单', 1)"); DB::insert([
$id = DB::insert_id(); "insert into lists",
DB::insert("insert into lists_contents (id, content, content_md) values ($id, '', '')"); DB::bracketed_fields(['title', 'is_hidden']),
"values",
DB::tuple(['未命名题单', 1]),
]);
$list_id = DB::insert_id();
DB::insert([
"insert into lists_contents",
DB::bracketed_fields(['id', 'content', 'content_md']),
"values",
DB::tuple([$list_id, '', '']),
]);
redirectTo("/list/{$list_id}");
die();
}; };
$new_list_form->submit_button_config['align'] = 'right'; $new_list_form->config['submit_container']['class'] = 'text-end';
$new_list_form->submit_button_config['class_str'] = 'btn btn-primary'; $new_list_form->config['submit_button']['class'] = 'btn btn-primary';
$new_list_form->submit_button_config['text'] = UOJLocale::get('problems::add new list'); $new_list_form->config['submit_button']['text'] = UOJLocale::get('problems::add new list');
$new_list_form->submit_button_config['smart_confirm'] = ''; $new_list_form->config['confirm']['smart'] = true;
$new_list_form->runAtServer(); $new_list_form->runAtServer();
} }

View File

@ -346,7 +346,7 @@ class UOJForm {
} }
if ($this->config['confirm']['smart']) { if ($this->config['confirm']['smart']) {
$this->config['confirm']['text'] = '你真的要' . $this->config['submit']['text'] . '吗?'; $this->config['confirm']['text'] = '你真的要' . $this->config['submit_button']['text'] . '吗?';
} }
if ($this->config['confirm']['text']) { if ($this->config['confirm']['text']) {
echo <<<EOD echo <<<EOD