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.ContentSectionNotFoundException;
import org.librecms.ui.contentsections.ItemPermissionChecker; import org.librecms.ui.contentsections.ItemPermissionChecker;
import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep; 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.DocumentNotFoundException;
import org.librecms.ui.contentsections.documents.DocumentUi; import org.librecms.ui.contentsections.documents.DocumentUi;
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
@ -787,24 +791,148 @@ public class MvcEventInfoStep extends AbstractMvcAuthoringStep {
DocumentNotFoundException { DocumentNotFoundException {
super.init(); super.init();
if (itemPermissionChecker.canEditItem(getEvent())) { final boolean canEdit = itemPermissionChecker.canEditItem(getEvent());
eventDateModel.setCanEdit( if (canEdit) {
itemPermissionChecker.canEditItem(getEvent())
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( locationModel.setCanEdit(canEdit);
itemPermissionChecker.canEditItem(getEvent()) 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( mainContributorModel.setCanEdit(canEdit);
itemPermissionChecker.canEditItem(getEvent()) 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( eventTypeModel.setCanEdit(canEdit);
itemPermissionChecker.canEditItem(getEvent()) 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 @RequestScoped
@Named("CmsEventInfoStepEventDate") @Named("CmsEventInfoStepEventDate")
class MvcEventInfoStepEventDateModel { public class MvcEventInfoStepEventDateModel {
private boolean canEdit; private boolean canEdit;