Editing of localized titles and descriptions for categories in cms admin finished
Former-commit-id: 066d873b5c70a49fdd24812f60f92045b8d444ffpull/10/head
parent
66cdcaf820
commit
32d79121a6
|
|
@ -220,46 +220,16 @@ public class CategoriesController {
|
||||||
public String addTitle(
|
public String addTitle(
|
||||||
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
@PathParam("context") final String context,
|
@PathParam("context") final String context,
|
||||||
@PathParam("categoryPath") final String categoryPath,
|
@PathParam("categoryPath") final String categoryPathParam,
|
||||||
@FormParam("locale") final String localeParam,
|
@FormParam("locale") final String localeParam,
|
||||||
@FormParam("value") final String value
|
@FormParam("value") final String value
|
||||||
) {
|
) {
|
||||||
// final Optional<ContentSection> sectionResult = retrieveContentSection(
|
final String categoryPath;
|
||||||
// sectionIdentifier);
|
if (categoryPathParam == null || categoryPathParam.isEmpty()) {
|
||||||
// if (!sectionResult.isPresent()) {
|
categoryPath = "/";
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
} else {
|
||||||
// return "org/librecms/ui/contentsection/contentsection-not-found.xhtml";
|
categoryPath = categoryPathParam;
|
||||||
// }
|
}
|
||||||
// final ContentSection section = sectionResult.get();
|
|
||||||
//
|
|
||||||
// final Optional<DomainOwnership> domainResult = section
|
|
||||||
// .getDomains()
|
|
||||||
// .stream()
|
|
||||||
// .filter(domain -> domain.getContext().equals(context))
|
|
||||||
// .findAny();
|
|
||||||
// if (!domainResult.isPresent()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/categorysystem-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// final Domain domain = domainResult.get().getDomain();
|
|
||||||
// if (categoryPath.isEmpty()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// models.put("categoryPath", categoryPath);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/category-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// final Category category;
|
|
||||||
// final Optional<Category> categoryResult = categoryRepo
|
|
||||||
// .findByPath(domain, categoryPath);
|
|
||||||
// if (!categoryResult.isPresent()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// models.put("categoryPath", categoryPath);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/category-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// category = categoryResult.get();
|
|
||||||
|
|
||||||
final RetrieveResult<Category> result = retrieveCategory(
|
final RetrieveResult<Category> result = retrieveCategory(
|
||||||
sectionIdentifier, context, categoryPath
|
sectionIdentifier, context, categoryPath
|
||||||
);
|
);
|
||||||
|
|
@ -273,7 +243,7 @@ public class CategoriesController {
|
||||||
"redirect:/%s/categorysystems/%s/categories/%s",
|
"redirect:/%s/categorysystems/%s/categories/%s",
|
||||||
sectionIdentifier,
|
sectionIdentifier,
|
||||||
context,
|
context,
|
||||||
categoryPath
|
categoryPathParam
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return result.getResponseTemplate();
|
return result.getResponseTemplate();
|
||||||
|
|
@ -296,52 +266,22 @@ public class CategoriesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/{context}/categories/{categoryPath:(.+)?}/@title/edit")
|
@Path("/{context}/categories/{categoryPath:(.+)?}/@title/edit/{locale}")
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public String editTitle(
|
public String editTitle(
|
||||||
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
@PathParam("context") final String context,
|
@PathParam("context") final String context,
|
||||||
@PathParam("categoryPath") final String categoryPath,
|
@PathParam("categoryPath") final String categoryPathParam,
|
||||||
@PathParam("locale") final String localeParam,
|
@PathParam("locale") final String localeParam,
|
||||||
@FormParam("value") final String value
|
@FormParam("value") final String value
|
||||||
) {
|
) {
|
||||||
// final Optional<ContentSection> sectionResult = retrieveContentSection(
|
final String categoryPath;
|
||||||
// sectionIdentifier);
|
if (categoryPathParam == null || categoryPathParam.isEmpty()) {
|
||||||
// if (!sectionResult.isPresent()) {
|
categoryPath = "/";
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
} else {
|
||||||
// return "org/librecms/ui/contentsection/contentsection-not-found.xhtml";
|
categoryPath = categoryPathParam;
|
||||||
// }
|
}
|
||||||
// final ContentSection section = sectionResult.get();
|
|
||||||
//
|
|
||||||
// final Optional<DomainOwnership> domainResult = section
|
|
||||||
// .getDomains()
|
|
||||||
// .stream()
|
|
||||||
// .filter(domain -> domain.getContext().equals(context))
|
|
||||||
// .findAny();
|
|
||||||
// if (!domainResult.isPresent()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/categorysystem-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// final Domain domain = domainResult.get().getDomain();
|
|
||||||
// if (categoryPath.isEmpty()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// models.put("categoryPath", categoryPath);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/category-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// final Category category;
|
|
||||||
// final Optional<Category> categoryResult = categoryRepo
|
|
||||||
// .findByPath(domain, categoryPath);
|
|
||||||
// if (!categoryResult.isPresent()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// models.put("categoryPath", categoryPath);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/category-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// category = categoryResult.get();
|
|
||||||
|
|
||||||
final RetrieveResult<Category> result = retrieveCategory(
|
final RetrieveResult<Category> result = retrieveCategory(
|
||||||
sectionIdentifier, context, categoryPath
|
sectionIdentifier, context, categoryPath
|
||||||
);
|
);
|
||||||
|
|
@ -355,7 +295,7 @@ public class CategoriesController {
|
||||||
"redirect:/%s/categorysystems/%s/categories/%s",
|
"redirect:/%s/categorysystems/%s/categories/%s",
|
||||||
sectionIdentifier,
|
sectionIdentifier,
|
||||||
context,
|
context,
|
||||||
categoryPath
|
categoryPathParam
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return result.getResponseTemplate();
|
return result.getResponseTemplate();
|
||||||
|
|
@ -382,46 +322,16 @@ public class CategoriesController {
|
||||||
public String removeTitle(
|
public String removeTitle(
|
||||||
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
@PathParam("context") final String context,
|
@PathParam("context") final String context,
|
||||||
@PathParam("categoryPath") final String categoryPath,
|
@PathParam("categoryPath") final String categoryPathParam,
|
||||||
@PathParam("locale") final String localeParam,
|
@PathParam("locale") final String localeParam,
|
||||||
@FormParam("value") final String value
|
@FormParam("value") final String value
|
||||||
) {
|
) {
|
||||||
// final Optional<ContentSection> sectionResult = retrieveContentSection(
|
final String categoryPath;
|
||||||
// sectionIdentifier);
|
if (categoryPathParam == null || categoryPathParam.isEmpty()) {
|
||||||
// if (!sectionResult.isPresent()) {
|
categoryPath = "/";
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
} else {
|
||||||
// return "org/librecms/ui/contentsection/contentsection-not-found.xhtml";
|
categoryPath = categoryPathParam;
|
||||||
// }
|
}
|
||||||
// final ContentSection section = sectionResult.get();
|
|
||||||
//
|
|
||||||
// final Optional<DomainOwnership> domainResult = section
|
|
||||||
// .getDomains()
|
|
||||||
// .stream()
|
|
||||||
// .filter(domain -> domain.getContext().equals(context))
|
|
||||||
// .findAny();
|
|
||||||
// if (!domainResult.isPresent()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/categorysystem-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// final Domain domain = domainResult.get().getDomain();
|
|
||||||
// if (categoryPath.isEmpty()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// models.put("categoryPath", categoryPath);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/category-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// final Category category;
|
|
||||||
// final Optional<Category> categoryResult = categoryRepo
|
|
||||||
// .findByPath(domain, categoryPath);
|
|
||||||
// if (!categoryResult.isPresent()) {
|
|
||||||
// models.put("sectionIdentifier", sectionIdentifier);
|
|
||||||
// models.put("context", context);
|
|
||||||
// models.put("categoryPath", categoryPath);
|
|
||||||
// return "org/librecms/ui/contentsection/categorysystems/category-not-found.xhtml";
|
|
||||||
// }
|
|
||||||
// category = categoryResult.get();
|
|
||||||
|
|
||||||
final RetrieveResult<Category> result = retrieveCategory(
|
final RetrieveResult<Category> result = retrieveCategory(
|
||||||
sectionIdentifier, context, categoryPath
|
sectionIdentifier, context, categoryPath
|
||||||
);
|
);
|
||||||
|
|
@ -434,7 +344,166 @@ public class CategoriesController {
|
||||||
"redirect:/%s/categorysystems/%s/categories/%s",
|
"redirect:/%s/categorysystems/%s/categories/%s",
|
||||||
sectionIdentifier,
|
sectionIdentifier,
|
||||||
context,
|
context,
|
||||||
categoryPath
|
categoryPathParam
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return result.getResponseTemplate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/{context}/categories/@description/add")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String addDescription(
|
||||||
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
|
@PathParam("context") final String context,
|
||||||
|
@FormParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
return addDescription(
|
||||||
|
sectionIdentifier, context, "", localeParam, value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/{context}/categories/{categoryPath:(.+)?}/@description/add")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String addDescription(
|
||||||
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
|
@PathParam("context") final String context,
|
||||||
|
@PathParam("categoryPath") final String categoryPathParam,
|
||||||
|
@FormParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
final String categoryPath;
|
||||||
|
if (categoryPathParam == null || categoryPathParam.isEmpty()) {
|
||||||
|
categoryPath = "/";
|
||||||
|
} else {
|
||||||
|
categoryPath = categoryPathParam;
|
||||||
|
}
|
||||||
|
final RetrieveResult<Category> result = retrieveCategory(
|
||||||
|
sectionIdentifier, context, categoryPath
|
||||||
|
);
|
||||||
|
if (result.isSuccessful()) {
|
||||||
|
final Category category = result.getResult();
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
category.getDescription().addValue(locale, value);
|
||||||
|
categoryRepo.save(category);
|
||||||
|
|
||||||
|
return String.format(
|
||||||
|
"redirect:/%s/categorysystems/%s/categories/%s",
|
||||||
|
sectionIdentifier,
|
||||||
|
context,
|
||||||
|
categoryPathParam
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return result.getResponseTemplate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/{context}/categories/@description/edit/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String editDescription(
|
||||||
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
|
@PathParam("context") final String context,
|
||||||
|
@PathParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
return editDescription(
|
||||||
|
sectionIdentifier, context, "", localeParam, value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path(
|
||||||
|
"/{context}/categories/{categoryPath:(.+)?}/@description/edit/{locale}"
|
||||||
|
)
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String editDescription(
|
||||||
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
|
@PathParam("context") final String context,
|
||||||
|
@PathParam("categoryPath") final String categoryPathParam,
|
||||||
|
@PathParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
final String categoryPath;
|
||||||
|
if (categoryPathParam == null || categoryPathParam.isEmpty()) {
|
||||||
|
categoryPath = "/";
|
||||||
|
} else {
|
||||||
|
categoryPath = categoryPathParam;
|
||||||
|
}
|
||||||
|
final RetrieveResult<Category> result = retrieveCategory(
|
||||||
|
sectionIdentifier, context, categoryPath
|
||||||
|
);
|
||||||
|
if (result.isSuccessful()) {
|
||||||
|
final Category category = result.getResult();
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
category.getDescription().addValue(locale, value);
|
||||||
|
categoryRepo.save(category);
|
||||||
|
|
||||||
|
return String.format(
|
||||||
|
"redirect:/%s/categorysystems/%s/categories/%s",
|
||||||
|
sectionIdentifier,
|
||||||
|
context,
|
||||||
|
categoryPathParam
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return result.getResponseTemplate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/{context}/categories/@description/remove/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String removeDescription(
|
||||||
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
|
@PathParam("context") final String context,
|
||||||
|
@PathParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
return removeDescription(
|
||||||
|
sectionIdentifier, context, "", localeParam, value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path(
|
||||||
|
"/{context}/categories/{categoryPath:(.+)?}/@description/remove/{locale}"
|
||||||
|
)
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String removeDescription(
|
||||||
|
@PathParam("sectionIdentifier") final String sectionIdentifier,
|
||||||
|
@PathParam("context") final String context,
|
||||||
|
@PathParam("categoryPath") final String categoryPathParam,
|
||||||
|
@PathParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
final String categoryPath;
|
||||||
|
if (categoryPathParam == null || categoryPathParam.isEmpty()) {
|
||||||
|
categoryPath = "/";
|
||||||
|
} else {
|
||||||
|
categoryPath = categoryPathParam;
|
||||||
|
}
|
||||||
|
final RetrieveResult<Category> result = retrieveCategory(
|
||||||
|
sectionIdentifier, context, categoryPath
|
||||||
|
);
|
||||||
|
if (result.isSuccessful()) {
|
||||||
|
final Category category = result.getResult();
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
category.getDescription().removeValue(locale);
|
||||||
|
categoryRepo.save(category);
|
||||||
|
return String.format(
|
||||||
|
"redirect:/%s/categorysystems/%s/categories/%s",
|
||||||
|
sectionIdentifier,
|
||||||
|
context,
|
||||||
|
categoryPathParam
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return result.getResponseTemplate();
|
return result.getResponseTemplate();
|
||||||
|
|
@ -961,7 +1030,12 @@ public class CategoriesController {
|
||||||
.map(this::buildCategorizedObjectModel)
|
.map(this::buildCategorizedObjectModel)
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
model.setPath(categoryManager.getCategoryPath(category));
|
final String categoryPath = categoryManager.getCategoryPath(category);
|
||||||
|
if ("/".equals(categoryPath)) {
|
||||||
|
model.setPath("");
|
||||||
|
} else {
|
||||||
|
model.setPath(categoryPath);
|
||||||
|
}
|
||||||
model.setSubCategories(
|
model.setSubCategories(
|
||||||
category
|
category
|
||||||
.getSubCategories()
|
.getSubCategories()
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,7 @@
|
||||||
tableValueHeading="#{CmsAdminMessages['contentsection.categorysystems.category.descriptions.value.heading']}"
|
tableValueHeading="#{CmsAdminMessages['contentsection.categorysystems.category.descriptions.value.heading']}"
|
||||||
title="#{CmsAdminMessages['contentsection.categorysystems.category.descriptions.title']}"
|
title="#{CmsAdminMessages['contentsection.categorysystems.category.descriptions.title']}"
|
||||||
unusedLocales="#{CategorySystemModel.selectedCategory.unusedDescriptionLocales}"
|
unusedLocales="#{CategorySystemModel.selectedCategory.unusedDescriptionLocales}"
|
||||||
|
useTextarea="true"
|
||||||
values="#{CategorySystemModel.selectedCategory.localizedDescriptions}" />
|
values="#{CategorySystemModel.selectedCategory.localizedDescriptions}" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -230,3 +230,4 @@ contentsection.categorysystems.category.descriptions.delete.title=Confirm remova
|
||||||
contentsection.categorysystems.category.descriptions.add.add.title=Add localized description
|
contentsection.categorysystems.category.descriptions.add.add.title=Add localized description
|
||||||
contentsection.categorysystems.category.titles.value.heading=Localized title
|
contentsection.categorysystems.category.titles.value.heading=Localized title
|
||||||
contentsection.categorysystems.category.descriptions.value.heading=Localized description
|
contentsection.categorysystems.category.descriptions.value.heading=Localized description
|
||||||
|
contentsection.categorysystems.category.descriptions.title=Localized Descriptions
|
||||||
|
|
|
||||||
|
|
@ -231,3 +231,4 @@ contentsection.categorysystems.category.descriptions.delete.description=Entferne
|
||||||
contentsection.categorysystems.category.descriptions.locale.description=Lokalisierte Beschreibungen
|
contentsection.categorysystems.category.descriptions.locale.description=Lokalisierte Beschreibungen
|
||||||
contentsection.categorysystems.category.titles.value.heading=Lokalisierter Titel
|
contentsection.categorysystems.category.titles.value.heading=Lokalisierter Titel
|
||||||
contentsection.categorysystems.category.descriptions.value.heading=Lokalisierte Beschreibung
|
contentsection.categorysystems.category.descriptions.value.heading=Lokalisierte Beschreibung
|
||||||
|
contentsection.categorysystems.category.descriptions.title=Lokaliserte Beschreibungen
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue