Category Systems create and list

Jens Pelzetter 2020-11-11 14:59:52 +01:00
parent 6608e091fb
commit 58dbc70353
9 changed files with 138 additions and 48 deletions

View File

@ -89,6 +89,10 @@ public class CategorySystemDetailsModel {
return Collections.unmodifiableList(owners);
}
public boolean isNew() {
return categorySystemId == 0;
}
public List<Message> getMessages() {
return Collections.unmodifiableList(messages);
}

View File

@ -57,6 +57,9 @@ public class CategorySystemFormController {
@Inject
private CategorySystemDetailsModel categorySystemDetailsModel;
@Inject
private DomainManager domainManager;
@Inject
private DomainRepository domainRepository;
@ -75,17 +78,17 @@ public class CategorySystemFormController {
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
public String createCategorySystem() {
final Domain domain = new Domain();
domain.setDomainKey(domainKey);
domain.setUri(uri);
final Domain domain = domainManager.createDomain(domainKey, domainKey);
domain.setUri(uri);
domainRepository.save(domain);
return "redirect:/categorymanager/categorysystems";
}
@POST
@Path("/{categorySystemIdentifier}/edit")
@Path("{categorySystemIdentifier}/edit")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)

View File

@ -54,7 +54,7 @@ import javax.ws.rs.PathParam;
*/
@RequestScoped
@Controller
@Path("/categorymanager")
@Path("/categorymanager/categorysystems")
public class CategorySystemsController {
@Inject
@ -78,16 +78,16 @@ public class CategorySystemsController {
@Inject
private Models models;
@GET
@Path("/")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String getCategoryManager() {
return getCategorySystems();
}
// @GET
// @Path("/")
// @AuthorizationRequired
// @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
// public String getCategoryManager() {
// return getCategorySystems();
// }
@GET
@Path("/categorysystems")
@Path("/")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String getCategorySystems() {
@ -95,7 +95,7 @@ public class CategorySystemsController {
}
@GET
@Path("/categorysystems/{categorySystemIdentifier}/details")
@Path("/{categorySystemIdentifier}/details")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -144,7 +144,7 @@ public class CategorySystemsController {
}
@GET
@Path("/categorysystems/new")
@Path("/new")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String newCategorySystem() {
@ -152,7 +152,7 @@ public class CategorySystemsController {
}
@GET
@Path("/categorysystems/{categorySystemIdentifier}/edit")
@Path("/{categorySystemIdentifier}/edit")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -201,7 +201,7 @@ public class CategorySystemsController {
}
@POST
@Path("/categorysystems/{categorySystemIdentifier}/delete")
@Path("/{categorySystemIdentifier}/delete")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -253,7 +253,7 @@ public class CategorySystemsController {
}
@POST
@Path("/categorysystems/{categorySystemIdentifier}/title/add")
@Path("/{categorySystemIdentifier}/title/add")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String addTitle(
@ -308,7 +308,7 @@ public class CategorySystemsController {
}
@POST
@Path("/categorysystems/{categorySystemIdentifier}/title/${locale}/edit")
@Path("/{categorySystemIdentifier}/title/${locale}/edit")
@AuthorizationRequired
public String editTitle(
@PathParam("categorySystemIdentifier")
@ -362,7 +362,7 @@ public class CategorySystemsController {
}
@POST
@Path("/categorysystems/{categorySystemIdentifier}/title/${locale}/remove")
@Path("/{categorySystemIdentifier}/title/${locale}/remove")
@AuthorizationRequired
public String removeTitle(
@PathParam("categorySystemIdentifier")
@ -415,7 +415,7 @@ public class CategorySystemsController {
}
@POST
@Path("/categorysystems/{categorySystemIdentifier}/description/add")
@Path("/{categorySystemIdentifier}/description/add")
@AuthorizationRequired
public String addDescription(
@PathParam("categorySystemIdentifier")
@ -470,7 +470,7 @@ public class CategorySystemsController {
@POST
@Path(
"/categorysystems/{categorySystemIdentifier}/description/${locale}/edit")
"categorysystems/{categorySystemIdentifier}/description/${locale}/edit")
@AuthorizationRequired
public String editDescription(
@PathParam("categorySystemIdentifier")
@ -525,7 +525,7 @@ public class CategorySystemsController {
@POST
@Path(
"/categorysystems/{categorySystemIdentifier}/description/${locale}/remove")
"categorysystems/{categorySystemIdentifier}/description/${locale}/remove")
@AuthorizationRequired
public String removeDescription(
@PathParam("categorySystemIdentifier")
@ -578,7 +578,7 @@ public class CategorySystemsController {
}
@POST
@Path("/categorysystems/{categorySystemIdentifier}/owners/add")
@Path("/{categorySystemIdentifier}/owners/add")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String addOwner(
@ -650,7 +650,7 @@ public class CategorySystemsController {
}
@POST
@Path("/categorysystems/{categorySystemIdentifier}/owners/remove")
@Path("/{categorySystemIdentifier}/owners/remove")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String removeOwner(

View File

@ -63,24 +63,27 @@ public class CategorySystemsTableModel {
row.setDomainKey(domain.getDomainKey());
row.setUri(domain.getUri());
row.setVersion(domain.getVersion());
row.setReleased(
DateTimeFormatter.ISO_DATE_TIME.format(
domain.getReleased().toInstant()
)
);
if (domain.getReleased() != null) {
row.setReleased(
DateTimeFormatter.ISO_DATE_TIME.format(
domain.getReleased().toInstant()
)
);
}
row.setTitle(
domain
.getTitle()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> entry.getValue()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> entry.getValue()
)
)
)
);
return row;
}
}

View File

@ -12,12 +12,74 @@
<li class="breadcrumb-item active">
#{AdminMessages['categories.label']}
</li>
<li class="breadcrumb-item active">
<a href="#{mvc.uri('CategorySystemsController#getCategorySystems')}">
#{AdminMessages['categorysystems.label']}
</a>
</li>
<c:choose>
<c:when test="#{CategorySystemDetailsModel.new}">
<li class="breadcrumb-item active">
#{AdminMessages['categorysystems.new.label']}
</li>
</c:when>
<c:otherwise>
<li class="breadcrumb-item active">
#{CategorySystemDetailsModel.domainKey}
</li>
</c:otherwise>
</c:choose>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>#{AdminMessages['categories.label']}</h1>
<p>ToDo</p>
<h1>#{CategorySystemDetailsModel.new ? AdminMessages['categorysystems.new.label'] : AdminMessages.getMessage('categorysystems.edit.label', CategorySystemDetailsModel.domainKey)}</h1>
<form action="#{CategorySystemDetailsModel.new ? mvc.uri('CategorySystemFormController#createCategorySystem') : mvc.uri('CategorySystemFormController#updateCategorySystem', {'categorySystemIdentifier': CategoryDetailsModel.domainKey })}"
method="post">
<div class="form-group">
<label for="domainKey">
#{AdminMessages['categorysystems.form.domainKey.label']}
</label>
<input aria-describedby="domainKey-help"
class="form-control"
name="domainKey"
type="text" />
<small class="form-text text-muted"
id="domainKey-help">
#{AdminMessages['categorysystems.form.domainKey.help']}
</small>
</div>
<div class="form-group">
<label for="uri">
#{AdminMessages['categorysystems.form.uri.label']}
</label>
<input aria-describedby="uri-help"
class="form-control"
name="domainKey"
type="text" />
<small class="form-text text-muted"
id="domainKey-help">
#{AdminMessages['categorysystems.form.uri.help']}
</small>
</div>
<a class="btn btn-warning"
href="#{mvc.uri('CategorySystemsController#getCategorySystems')}">
#{AdminMessages['categorysystems.form.buttons.cancel']}
</a>
<button class="btn btn-success" type="submit">
<c:choose>
<c:when test="#{UserDetailsModel.newUser}">
#{AdminMessages['categorysystems.form.buttons.create']}
</c:when>
<c:otherwise>
#{AdminMessages['categorysystems.form.buttons.save']}
</c:otherwise>
</c:choose>
</button>
</form>
</div>
</ui:define>

View File

@ -25,7 +25,7 @@
<div class="container">
<h1>#{AdminMessages['categorysystems.label']}</h1>
<div class="text-right m-b-2">
<div class="text-right mb-2">
<a class="btn btn-secondary"
href="#{mvc.uri('CategorySystemsController#newCategorySystem')}">
<svg class="bi"
@ -51,7 +51,7 @@
var="categorySystem">
<tr>
<td>
<a href="#{mvc.uri('CategorySystemsController#getCategorySystemDetails', categorySystem.identifier)}">
<a href="#{mvc.uri('CategorySystemsController#getCategorySystemDetails', { 'categorySystemIdentifier': categorySystem.identifier })}">
#{categorySystem.domainKey}
</a>
</td>

View File

@ -43,7 +43,7 @@
<label for="username">
#{AdminMessages['usersgroupsroles.users.form.username.label']}
</label>
<input aria-described-by="username-help"
<input aria-describedby="username-help"
class="form-control"
id="username"
name="userName"

View File

@ -248,3 +248,12 @@ categorysystems.table.headers.domainKey=Domain Key
categorysystems.table.headers.uri=URI
categorysystems.table.headers.version=Version
categorysystems.table.headers.released=Released
categorysystems.new.label=Create new categorysystem
categorysystems.edit.label=Edit Category System {0}
categorysystems.form.domainKey.label=Domain Key
categorysystems.form.domainKey.help=Unique key for category system
categorysystems.form.uri.label=URI
categorysystems.form.uri.help=URI stub of the categorysystem
categorysystems.form.buttons.create=Create new categorysystem
categorysystems.form.buttons.save=Apply changes
categorysystems.form.buttons.cancel=Cancel

View File

@ -248,3 +248,12 @@ categorysystems.table.headers.domainKey=Domain Key
categorysystems.table.headers.uri=URI
categorysystems.table.headers.version=Version
categorysystems.table.headers.released=Freigegeben
categorysystems.new.label=Neues Kategoriensystem erstellen
categorysystems.edit.label=Kategoriensystem {0} bearbeiten
categorysystems.form.domainKey.label=Domain Key
categorysystems.form.domainKey.help=Unique key for category system
categorysystems.form.uri.label=URI
categorysystems.form.uri.help=URI stub of the categorysystem
categorysystems.form.buttons.create=Neues Kategoriensystem anlegen
categorysystems.form.buttons.save=\u00c4nderungen anwenden
categorysystems.form.buttons.cancel=Abbrechen