Some more bugfixes for the authoring steps of the event content type.

pull/15/head
Jens Pelzetter 2022-02-06 09:48:29 +01:00
parent 53956098fb
commit 84c2f9a858
3 changed files with 146 additions and 18 deletions

View File

@ -25,12 +25,16 @@ import org.librecms.contenttypes.Event;
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
import org.librecms.ui.contentsections.ItemPermissionChecker;
import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep;
import org.librecms.ui.contentsections.documents.CmsEditorUtil;
import org.librecms.ui.contentsections.documents.DocumentNotFoundException;
import org.librecms.ui.contentsections.documents.DocumentUi;
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
@ -771,7 +775,7 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep {
final Locale locale = new Locale(localeParam);
getEvent().getEventType().removeValue(locale);
itemRepo.save(getEvent());
return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
@ -787,24 +791,148 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep {
DocumentNotFoundException {
super.init();
if (itemPermissionChecker.canEditItem(getEvent())) {
eventDateModel.setCanEdit(
itemPermissionChecker.canEditItem(getEvent())
final boolean canEdit = itemPermissionChecker.canEditItem(getEvent());
if (canEdit) {
eventDateModel.setCanEdit(canEdit);
eventDateModel.setEventDateValues(
getEvent()
.getEventDate()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
Map.Entry::getValue
)
)
);
eventDateModel.setVariants(
getEvent()
.getEventDate()
.getValues()
.entrySet()
.stream()
.map(CmsEditorUtil::buildVariantRow)
.collect(Collectors.toList())
);
final Set<Locale> eventDateLocales = getEvent()
.getEventDate()
.getAvailableLocales();
eventDateModel.setUnusedLocales(
globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !eventDateLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList())
);
locationModel.setCanEdit(
itemPermissionChecker.canEditItem(getEvent())
locationModel.setCanEdit(canEdit);
locationModel.setLocationValues(
getEvent()
.getLocation()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
Map.Entry::getValue
)
)
);
locationModel.setVariants(
getEvent()
.getEventDate()
.getValues()
.entrySet()
.stream()
.map(CmsEditorUtil::buildVariantRow)
.collect(Collectors.toList())
);
final Set<Locale> locationLocales = getEvent()
.getLocation()
.getAvailableLocales();
locationModel.setUnusedLocales(
globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !locationLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList())
);
mainContributorModel.setCanEdit(
itemPermissionChecker.canEditItem(getEvent())
mainContributorModel.setCanEdit(canEdit);
mainContributorModel.setContributorValues(
getEvent()
.getMainContributor()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
Map.Entry::getValue
)
)
);
mainContributorModel.setVariants(
getEvent()
.getMainContributor()
.getValues()
.entrySet()
.stream()
.map(CmsEditorUtil::buildVariantRow)
.collect(Collectors.toList())
);
final Set<Locale> contributorLocales = getEvent()
.getMainContributor()
.getAvailableLocales();
mainContributorModel.setUnusedLocales(
globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !contributorLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList())
);
eventTypeModel.setCanEdit(
itemPermissionChecker.canEditItem(getEvent())
eventTypeModel.setCanEdit(canEdit);
eventTypeModel.setEventTypeValues(
getEvent()
.getEventType()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
Map.Entry::getValue
)
)
);
eventTypeModel.setVariants(
getEvent()
.getEventType()
.getValues()
.entrySet()
.stream()
.map(CmsEditorUtil::buildVariantRow)
.collect(Collectors.toList())
);
final Set<Locale> eventTypeLocales = getEvent()
.getEventType()
.getAvailableLocales();
eventTypeModel.setUnusedLocales(
globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !eventTypeLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList())
);
// toDo
}
}

View File

@ -36,7 +36,7 @@ import javax.inject.Named;
*/
@RequestScoped
@Named("CmsEventInfoStepEventDate")
class MvcEventInfoStepEventDateModel {
public class MvcEventInfoStepEventDateModel {
private boolean canEdit;
@ -81,12 +81,12 @@ class MvcEventInfoStepEventDateModel {
}
public List<String> getUnusedLocales() {
return Optional
return Optional
.ofNullable(unusedLocales)
.map(Collections::unmodifiableList)
.orElse(Collections.emptyList());
}
protected void setUnusedLocales(final List<String> unusedLocales) {
this.unusedLocales = Optional
.ofNullable(unusedLocales)

View File

@ -28,7 +28,7 @@
variants="#{CmsEventInfoStepEventDate.variants}"
viewPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@event-info/view"
/>
<librecms:cmsEditorVariants
addButtonLabel="#{CmsEventMessageBundle['location.editor.add_variant']}"
addDialogLocaleSelectHelp="#{CmsAdminMessages['text.editor.add.locale.help']}"
@ -43,7 +43,7 @@
variants="#{CmsEventInfoStepLocation.variants}"
viewPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@event-info/view"
/>
<librecms:cmsEditorVariants
addButtonLabel="#{CmsEventMessageBundle['main_contributor.editor.add_variant']}"
addDialogLocaleSelectHelp="#{CmsAdminMessages['text.editor.add.locale.help']}"
@ -58,7 +58,7 @@
variants="#{CmsEventInfoStepMainContributor.variants}"
viewPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@event-info/view"
/>
<librecms:cmsEditorVariants
addButtonLabel="#{CmsEventMessageBundle['eventtype.editor.add_variant']}"
addDialogLocaleSelectHelp="#{CmsAdminMessages['text.editor.add.locale.help']}"