mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
@DisableEdit
This commit is contained in:
parent
a05ce27d24
commit
b84a139d12
@ -284,9 +284,15 @@ public class DefaultDbAdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/model/{className}/edit/{id}")
|
@GetMapping("/model/{className}/edit/{id}")
|
||||||
public String edit(Model model, @PathVariable String className, @PathVariable String id) {
|
public String edit(Model model, @PathVariable String className, @PathVariable String id, RedirectAttributes attr) {
|
||||||
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
DbObjectSchema schema = dbAdmin.findSchemaByClassName(className);
|
||||||
|
|
||||||
|
if (!schema.isEditEnabled()) {
|
||||||
|
attr.addFlashAttribute("errorTitle", "Unauthorized");
|
||||||
|
attr.addFlashAttribute("error", "EDIT operations have been disabled on this type (" + schema.getJavaClass().getSimpleName() + ").");
|
||||||
|
return "redirect:/" + properties.getBaseUrl() + "/model/" + className;
|
||||||
|
}
|
||||||
|
|
||||||
DbObject object = repository.findById(schema, id).orElseThrow(() -> {
|
DbObject object = repository.findById(schema, id).orElseThrow(() -> {
|
||||||
return new ResponseStatusException(
|
return new ResponseStatusException(
|
||||||
HttpStatus.NOT_FOUND, "Object " + className + " with id " + id + " not found"
|
HttpStatus.NOT_FOUND, "Object " + className + " with id " + id + " not found"
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
th:classAppend="|${!schema.isDeleteEnabled() ? 'disable' : ''}|">
|
th:classAppend="|${!schema.isDeleteEnabled() ? 'disable' : ''}|">
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center row-icons">
|
<td class="text-center row-icons">
|
||||||
<a class="ps-1" th:href="|/${baseUrl}/model/${schema.getJavaClass().getName()}/edit/${row.getPrimaryKeyValue()}|">
|
<a class="ps-1"
|
||||||
|
th:classAppend="|${!schema.isEditEnabled() ? 'disable' : ''}|"
|
||||||
|
th:href="|/${baseUrl}/model/${schema.getJavaClass().getName()}/edit/${row.getPrimaryKeyValue()}|">
|
||||||
<i class="bi bi-pencil-square"></i></a>
|
<i class="bi bi-pencil-square"></i></a>
|
||||||
<form class="delete-form" method="POST"
|
<form class="delete-form" method="POST"
|
||||||
th:action="|/${baseUrl}/model/${schema.getJavaClass().getName()}/delete/${row.getPrimaryKeyValue()}|">
|
th:action="|/${baseUrl}/model/${schema.getJavaClass().getName()}/delete/${row.getPrimaryKeyValue()}|">
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<h3>
|
<h3 class="create-button">
|
||||||
<a th:title="|${!schema.isCreateEnabled() ? 'CREATE disabled for this type' : 'Create new item'}|"
|
<a th:title="|${!schema.isCreateEnabled() ? 'CREATE disabled for this type' : 'Create new item'}|"
|
||||||
th:class="|${!schema.isCreateEnabled() ? 'disable' : ''}|"
|
th:class="|${!schema.isCreateEnabled() ? 'disable' : ''}|"
|
||||||
th:href="|/${baseUrl}/model/${schema.getClassName()}/create|"><i class="bi bi-plus-square"></i></a>
|
th:href="|/${baseUrl}/model/${schema.getClassName()}/create|"><i class="bi bi-plus-square"></i></a>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
[[ ${schema.getTableName()} ]]
|
[[ ${schema.getTableName()} ]]
|
||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<h3><a th:title="|${!schema.isCreateEnabled() ? 'CREATE disabled for this type' : 'Create new item'}|"
|
<h3 class="create-button"><a th:title="|${!schema.isCreateEnabled() ? 'CREATE disabled for this type' : 'Create new item'}|"
|
||||||
th:href="|/${baseUrl}/model/${schema.getClassName()}/create|"
|
th:href="|/${baseUrl}/model/${schema.getClassName()}/create|"
|
||||||
th:class="|${!schema.isCreateEnabled() ? 'disable' : ''}|"><i class="bi bi-plus-square"></i></a></h3>
|
th:class="|${!schema.isCreateEnabled() ? 'disable' : ''}|"><i class="bi bi-plus-square"></i></a></h3>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user