Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "save and continue" button to admin menu node and content type editors #17515

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public async Task<IActionResult> Edit(string id, string treeNodeId)
}

[HttpPost]
public async Task<IActionResult> Edit(AdminNodeEditViewModel model)
public async Task<IActionResult> Edit(AdminNodeEditViewModel model, string submit)
{
if (!await _authorizationService.AuthorizeAsync(User, AdminMenuPermissions.ManageAdminMenu))
{
Expand Down Expand Up @@ -225,7 +225,15 @@ public async Task<IActionResult> Edit(AdminNodeEditViewModel model)
await _adminMenuService.SaveAsync(adminMenu);

await _notifier.SuccessAsync(H["Admin node updated successfully."]);
return RedirectToAction(nameof(List), new { id = model.AdminMenuId });
if (String.Equals(submit, "saveAndContinue", StringComparison.Ordinal))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the same in the other places.

Suggested change
if (String.Equals(submit, "saveAndContinue", StringComparison.Ordinal))
if (string.Equals(submit, "saveAndContinue", StringComparison.Ordinal))

{
model.Editor = editor;
return View(model);
}
else
{
return RedirectToAction(nameof(List), new { id = model.AdminMenuId });
}
}

await _notifier.ErrorAsync(H["The admin node has validation errors."]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
</div>

<div class="mb-3">
<button class="btn btn-success save" type="submit">@T["Save"]</button>
<div class="btn-group mb-1">
<button class="btn btn-success save" type="submit" name="submit" value="save">@T["Save"]</button>
<button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-reference="parent" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="visually-hidden">@T["Toggle Dropdown"]</span>
</button>
<div class="dropdown-menu">
<button class="dropdown-item save-continue" type="submit" name="submit" value="saveAndContinue">@T["and continue"]</button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's in line with the other such features. Also do the same for the content type editor.

Suggested change
<button class="dropdown-item save-continue" type="submit" name="submit" value="saveAndContinue">@T["and continue"]</button>
<button class="dropdown-item save-continue" type="submit" name="submit" value="SaveAndContinue">@T["and continue"]</button>

</div>
</div>

<a class="btn btn-danger delete"
asp-action="Delete"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public async Task<ActionResult> CreatePOST(CreateTypeViewModel viewModel)
}

[Admin("ContentTypes/Edit/{id}", "EditType")]
public async Task<ActionResult> Edit(string id)
public async Task<ActionResult> Edit(string id, string submit)
{
if (!await _authorizationService.AuthorizeAsync(User, ContentTypesPermissions.EditContentTypes))
{
Expand All @@ -164,7 +164,14 @@ public async Task<ActionResult> Edit(string id)
}

typeViewModel.Editor = await _contentDefinitionDisplayManager.BuildTypeEditorAsync(typeViewModel.TypeDefinition, _updateModelAccessor.ModelUpdater);

if (String.Equals(submit, "save", StringComparison.Ordinal))
{
return RedirectToAction(nameof(List));
}
else if (String.Equals(submit, "saveAndContinue", StringComparison.Ordinal))
{
await _notifier.SuccessAsync(H["Admin node updated successfully."]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await _notifier.SuccessAsync(H["Admin node updated successfully."]);
await _notifier.SuccessAsync(H["Content type updated successfully."]);

}
Comment on lines +167 to +174
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (String.Equals(submit, "save", StringComparison.Ordinal))
{
return RedirectToAction(nameof(List));
}
else if (String.Equals(submit, "saveAndContinue", StringComparison.Ordinal))
{
await _notifier.SuccessAsync(H["Admin node updated successfully."]);
}
if (string.Equals(submit, "saveAndContinue", StringComparison.Ordinal))
{
await _notifier.SuccessAsync(H["Admin node updated successfully."]);
return View(typeViewModel);
}
else
{
return RedirectToAction(nameof(List));
}

return View(typeViewModel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@
</div>

<div class="mb-3">
<button class="btn btn-primary save" type="submit" name="submit.Save" value="Save">@T["Save"]</button>
<div class="btn-group mb-1">
<button class="btn btn-success save" type="submit" name="submit" value="save">@T["Save"]</button>
<button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-reference="parent" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="visually-hidden">@T["Toggle Dropdown"]</span>
</button>
<div class="dropdown-menu">
<button class="dropdown-item save-continue" type="submit" name="submit" value="saveAndContinue">@T["and continue"]</button>
</div>
</div>

@if (contentSettings.IsSystemDefined)
{
Expand Down