More work on the authoring steps for publications.
parent
137d31bfc9
commit
9ab3e1a42c
|
|
@ -6,7 +6,13 @@
|
|||
package org.scientificcms.publications.contenttypes;
|
||||
|
||||
import org.librecms.contenttypes.ContentTypeDescription;
|
||||
import org.librecms.ui.contentsections.documents.MvcAuthoringKit;
|
||||
import org.scientificcms.publications.Monograph;
|
||||
import org.scientificcms.publications.ui.contenttypes.MonographExtendedPropertiesStep;
|
||||
import org.scientificcms.publications.ui.contenttypes.MonographItemCreateStep;
|
||||
import org.scientificcms.publications.ui.contenttypes.MonographPropertiesStep;
|
||||
import org.scientificcms.publications.ui.contenttypes.PublicationAbstractStep;
|
||||
import org.scientificcms.publications.ui.contenttypes.PublicationMiscStep;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
|
@ -23,6 +29,15 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
|||
labelBundle = "org.scientificcms.publications.contenttypes.Monograph",
|
||||
descriptionBundle = "org.scientificcms.publications.contenttypes.Monograph"
|
||||
)
|
||||
@MvcAuthoringKit(
|
||||
createStep = MonographItemCreateStep.class,
|
||||
authoringSteps = {
|
||||
MonographPropertiesStep.class,
|
||||
MonographExtendedPropertiesStep.class,
|
||||
PublicationAbstractStep.class,
|
||||
PublicationMiscStep.class
|
||||
}
|
||||
)
|
||||
public class MonographItem extends PublicationWithPublisherItem<Monograph> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,6 @@ public abstract class AbstractPublicationPropertiesStep<T extends PublicationIte
|
|||
final Set<Locale> shortDescriptionLocales = publication
|
||||
.getShortDescription()
|
||||
.getAvailableLocales();
|
||||
|
||||
propertiesStepModel.setUnusedShortDescriptionLocales(
|
||||
globalizationHelper
|
||||
.getAvailableLocales()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.scientificcms.publications.ui.contenttypes;
|
||||
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||
import org.librecms.ui.contentsections.ItemPermissionChecker;
|
||||
|
|
@ -11,7 +12,10 @@ import org.scientificcms.publications.PublicationWithPublisher;
|
|||
import org.scientificcms.publications.contenttypes.PublicationWithPublisherItem;
|
||||
import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
|
@ -32,6 +36,9 @@ public abstract class AbstractPublicationWithPublisherExtendedPropertiesStep<T e
|
|||
@Inject
|
||||
private DocumentUi documentUi;
|
||||
|
||||
@Inject
|
||||
private GlobalizationHelper globalizationHelper;
|
||||
|
||||
@Inject
|
||||
private ItemPermissionChecker itemPermissionChecker;
|
||||
|
||||
|
|
@ -59,6 +66,32 @@ public abstract class AbstractPublicationWithPublisherExtendedPropertiesStep<T e
|
|||
publication.getNumberOfVolumes()
|
||||
);
|
||||
propertiesStepModel.setVolume(publication.getVolume());
|
||||
|
||||
propertiesStepModel.setEditionValues(
|
||||
publication
|
||||
.getEdition()
|
||||
.getValues()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
entry -> entry.getKey().toString(),
|
||||
entry -> entry.getValue()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final Set<Locale> editionLocales = publication
|
||||
.getEdition()
|
||||
.getAvailableLocales();
|
||||
propertiesStepModel.setUnusedEditionLocales(
|
||||
globalizationHelper
|
||||
.getAvailableLocales()
|
||||
.stream()
|
||||
.filter(locale -> !editionLocales.contains(locale))
|
||||
.map(Locale::toString)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
@POST
|
||||
|
|
@ -146,4 +179,110 @@ public abstract class AbstractPublicationWithPublisherExtendedPropertiesStep<T e
|
|||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/edition/@add")
|
||||
@AuthorizationRequired
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public String addEditionValue(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
@FormParam("locale") final String localeParam,
|
||||
@FormParam("value") final String value
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||
final Locale locale = new Locale(localeParam);
|
||||
getPublication().getEdition().putValue(locale, value);
|
||||
|
||||
publicationRepo.save(getPublication());
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getDocument(),
|
||||
getLabel()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/edition/@edit/{locale}")
|
||||
@AuthorizationRequired
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public String editEditionValue(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
@PathParam("locale") final String localeParam,
|
||||
@FormParam("value") final String value
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||
final Locale locale = new Locale(localeParam);
|
||||
getPublication().getEdition().putValue(locale, value);
|
||||
|
||||
publicationRepo.save(getPublication());
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getDocument(),
|
||||
getLabel()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/edition/@remove/{locale}")
|
||||
@AuthorizationRequired
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public String removeEditionValue(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
@PathParam("locale") final String localeParam
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getDocument())) {
|
||||
final Locale locale = new Locale(localeParam);
|
||||
getPublication().getEdition().removeValue(locale);
|
||||
publicationRepo.save(getPublication());
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getDocument(),
|
||||
getLabel()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package org.scientificcms.publications.ui.contenttypes;
|
||||
|
||||
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
|
||||
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
|
||||
import org.scientificcms.publications.Monograph;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.contenttypes.MonographItem;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.mvc.Controller;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Path(MvcAuthoringSteps.PATH_PREFIX + "publication-extendedproperties")
|
||||
@Controller
|
||||
@MvcAuthoringStepDef(
|
||||
bundle = SciPublicationsConstants.BUNDLE,
|
||||
descriptionKey = "authoringsteps.extendedproperties.description",
|
||||
labelKey = "authoringsteps.extendedproperties.label",
|
||||
supportedDocumentType = MonographItem.class
|
||||
)
|
||||
public class MonographExtendedPropertiesStep extends AbstractPublicationWithPublisherExtendedPropertiesStep<MonographItem, Monograph> {
|
||||
|
||||
@Override
|
||||
public Class<MonographExtendedPropertiesStep> getStepClass() {
|
||||
return MonographExtendedPropertiesStep.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getStepTemplatePath() {
|
||||
return "/org/scientificcms/contenttypes/monograph/ui/edit-extended.xhtml";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,12 +4,16 @@ import org.libreccm.l10n.GlobalizationHelper;
|
|||
import org.scientificcms.publications.Monograph;
|
||||
import org.scientificcms.publications.contenttypes.MonographItem;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Named("SciPublicationsMonographCreateStep")
|
||||
public class MonographItemCreateStep extends AbstractPublicationItemCreateStep<MonographItem, Monograph> {
|
||||
|
||||
@Inject
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ import javax.ws.rs.PathParam;
|
|||
@Controller
|
||||
@MvcAuthoringStepDef(
|
||||
bundle = EventStepsConstants.BUNDLE,
|
||||
descriptionKey = "monograph.authoringsteps.basicproperties.description",
|
||||
labelKey = "monograph.authoringsteps.basicproperties.label",
|
||||
descriptionKey = "authoringsteps.basicproperties.description",
|
||||
labelKey = "authoringsteps.basicproperties.label",
|
||||
supportedDocumentType = MonographItem.class
|
||||
)
|
||||
public class MonographPropertiesStep extends AbstractPublicationWithPublisherPropertiesStep<MonographItem, Monograph> {
|
||||
|
|
|
|||
|
|
@ -319,19 +319,19 @@ public class PublicationAbstractStep extends AbstractMvcAuthoringStep {
|
|||
.map(CmsEditorUtil::buildVariantRow)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
final Set<Locale> abstractLocales = getPublication()
|
||||
.getPublicationAbstract()
|
||||
.getAvailableLocales();
|
||||
abstractStepModel.setUnusedLocales(
|
||||
globalizationHelper
|
||||
.getAvailableLocales()
|
||||
.stream()
|
||||
.filter(locale -> !abstractLocales.contains(locale))
|
||||
.map(Locale::toString)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
|
||||
final Set<Locale> abstractLocales = getPublication()
|
||||
.getPublicationAbstract()
|
||||
.getAvailableLocales();
|
||||
abstractStepModel.setUnusedLocales(
|
||||
globalizationHelper
|
||||
.getAvailableLocales()
|
||||
.stream()
|
||||
.filter(locale -> !abstractLocales.contains(locale))
|
||||
.map(Locale::toString)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private PublicationItem<?> getPublicationItem() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
package org.scientificcms.publications.ui.contenttypes;
|
||||
|
||||
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class PublicationAuthoringSteps implements MvcAuthoringSteps {
|
||||
|
||||
@Override
|
||||
public Set<Class<?>> getClasses() {
|
||||
return Set.of(
|
||||
MonographPropertiesStep.class,
|
||||
MonographExtendedPropertiesStep.class,
|
||||
PublicationAbstractStep.class,
|
||||
PublicationMiscStep.class
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Class<?>> getResourceClasses() {
|
||||
return Set.of(
|
||||
PublicationAbstractStepResources.class,
|
||||
PublicationMiscStepResources.class
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,342 @@
|
|||
package org.scientificcms.publications.ui.contenttypes;
|
||||
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
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 org.scientificcms.publications.Publication;
|
||||
import org.scientificcms.publications.PublicationRepository;
|
||||
import org.scientificcms.publications.SciPublicationsConstants;
|
||||
import org.scientificcms.publications.contenttypes.PublicationItem;
|
||||
import org.scientificcms.publications.ui.SciPublicationsUiMessageBundle;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.mvc.Controller;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Path(MvcAuthoringSteps.PATH_PREFIX + "publication-misc")
|
||||
@Controller
|
||||
@MvcAuthoringStepDef(
|
||||
bundle = SciPublicationsConstants.BUNDLE,
|
||||
descriptionKey = "authoringsteps.misc.description",
|
||||
labelKey = "authoringsteps.misc.label",
|
||||
supportedDocumentType = PublicationItem.class
|
||||
)
|
||||
public class PublicationMiscStep extends AbstractMvcAuthoringStep {
|
||||
|
||||
@Inject
|
||||
private DocumentUi documentUi;
|
||||
|
||||
@Inject
|
||||
private GlobalizationHelper globalizationHelper;
|
||||
|
||||
@Inject
|
||||
private ItemPermissionChecker itemPermissionChecker;
|
||||
|
||||
@Inject
|
||||
private SciPublicationsUiMessageBundle messageBundle;
|
||||
|
||||
@Inject
|
||||
private PublicationMiscStepModel miscStepModel;
|
||||
|
||||
@Inject
|
||||
private PublicationRepository publicationRepo;
|
||||
|
||||
@Override
|
||||
public Class<PublicationMiscStep> getStepClass() {
|
||||
return PublicationMiscStep.class;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public String showStep(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||
return "/org/scientificcms/contenttypes/publications/ui/publication/misc.xhtml";
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getPublicationItem(),
|
||||
messageBundle.getMessage("publication.edit.denied")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/misc/view/{locale}")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public String viewMisc(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
@PathParam("locale") final String localeParam
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
miscStepModel.setSelectedLocale(
|
||||
new Locale(localeParam).toString()
|
||||
);
|
||||
|
||||
return "/org/scientificcms/contenttypes/publications/ui/publication/misc/view.xhtml";
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getPublicationItem(),
|
||||
messageBundle.getMessage("publication.edit.denied")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/misc/add")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public String addMiscValue(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
@FormParam("locale") final String localeParam
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||
final String value;
|
||||
if (getPublication().getMisc().getAvailableLocales().isEmpty()) {
|
||||
value = "";
|
||||
} else {
|
||||
value = globalizationHelper.getValueFromLocalizedString(
|
||||
getPublication().getMisc()
|
||||
);
|
||||
}
|
||||
|
||||
final Locale locale = new Locale(localeParam);
|
||||
getPublication().getMisc().putValue(locale, value);
|
||||
publicationRepo.save(getPublication());
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getPublicationItem(),
|
||||
messageBundle.getMessage("publication.edit.denied")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/misc/edit/{locale}")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public String editMiscValue(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
@PathParam("locale") final String localeParam
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||
miscStepModel.setSelectedLocale(new Locale(localeParam).toString());
|
||||
|
||||
return "/org/scientificcms/contenttypes/publications/ui/publication/misc/edit.xhtml";
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getPublicationItem(),
|
||||
messageBundle.getMessage("publication.edit.denied")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/misc/edit/{locale}")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public String editMiscValue(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
@PathParam("locale") final String localeParam,
|
||||
@FormParam("value")
|
||||
final String value
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||
final Locale locale = new Locale(localeParam);
|
||||
getPublication().getMisc().putValue(locale, value);
|
||||
publicationRepo.save(getPublication());
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getPublicationItem(),
|
||||
messageBundle.getMessage("publication.edit.denied")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/misc/remove/{locale}")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
public String removeMiscValue(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
final String documentPath,
|
||||
@PathParam("locale") final String localeParam
|
||||
) {
|
||||
try {
|
||||
init();
|
||||
} catch (ContentSectionNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
} catch (DocumentNotFoundException ex) {
|
||||
return ex.showErrorMessage();
|
||||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getPublicationItem())) {
|
||||
final Locale locale = new Locale(localeParam);
|
||||
getPublication().getMisc().removeValue(locale);
|
||||
publicationRepo.save(getPublication());
|
||||
|
||||
return buildRedirectPathForStep();
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
getContentSection(),
|
||||
getPublicationItem(),
|
||||
messageBundle.getMessage("publication.edit.denied")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws ContentSectionNotFoundException,
|
||||
DocumentNotFoundException {
|
||||
super.init();
|
||||
|
||||
final boolean canEdit = itemPermissionChecker.canEditItem(
|
||||
getPublicationItem()
|
||||
);
|
||||
if (canEdit) {
|
||||
miscStepModel.setCanEdit(canEdit);
|
||||
miscStepModel.setMiscValues(
|
||||
getPublication()
|
||||
.getMisc()
|
||||
.getValues()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
entry -> entry.getKey().toString(),
|
||||
entry -> entry.getValue()
|
||||
)
|
||||
)
|
||||
);
|
||||
miscStepModel.setVariants(
|
||||
getPublication()
|
||||
.getMisc()
|
||||
.getValues()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.map(CmsEditorUtil::buildVariantRow)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
final Set<Locale> miscLocales = getPublication()
|
||||
.getMisc()
|
||||
.getAvailableLocales();
|
||||
miscStepModel.setUnusedLocales(
|
||||
globalizationHelper
|
||||
.getAvailableLocales()
|
||||
.stream()
|
||||
.filter(locale -> !miscLocales.contains(locale))
|
||||
.map(Locale::toString)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
private PublicationItem<?> getPublicationItem() {
|
||||
return (PublicationItem<?>) getDocument();
|
||||
}
|
||||
|
||||
private Publication getPublication() {
|
||||
return getPublicationItem().getPublication();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
package org.scientificcms.publications.ui.contenttypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
|
|
@ -21,6 +27,10 @@ public class PublicationWithPublisherExtendedPropertiesStepModel {
|
|||
|
||||
private int numberOfPages;
|
||||
|
||||
private Map<String, String> editionValues;
|
||||
|
||||
private List<String> unusedEditionLocales;
|
||||
|
||||
public String getIsbn10() {
|
||||
return isbn10;
|
||||
}
|
||||
|
|
@ -61,4 +71,22 @@ public class PublicationWithPublisherExtendedPropertiesStepModel {
|
|||
this.numberOfPages = numberOfPages;
|
||||
}
|
||||
|
||||
public Map<String, String> getEditionValues() {
|
||||
return Collections.unmodifiableMap(editionValues);
|
||||
}
|
||||
|
||||
public void setEditionValues(final Map<String, String> editionValues) {
|
||||
this.editionValues = new HashMap<>(editionValues);
|
||||
}
|
||||
|
||||
public List<String> getUnusedEditionLocales() {
|
||||
return Collections.unmodifiableList(unusedEditionLocales);
|
||||
}
|
||||
|
||||
public void setUnusedEditionLocales(
|
||||
final List<String> unusedEditionLocales
|
||||
) {
|
||||
this.unusedEditionLocales = new ArrayList<>(unusedEditionLocales);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
<!DOCTYPE html [<!ENTITY times '×'>]>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
|
||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/contentsection.xhtml">
|
||||
|
||||
<ui:define name="main">
|
||||
<div class="container">
|
||||
<h1>#{publicationCreateStepTitle}</h1>
|
||||
|
||||
<c:forEach items="#{messages}"
|
||||
var="message">
|
||||
<div class="alert alert-#{message.key}"
|
||||
role="alert">
|
||||
#{message.value}
|
||||
</div>
|
||||
</c:forEach>
|
||||
|
||||
<form action="#{mvc.basePath}/#{contentSection}/documents/#{folderPath}@create/#{documentType}"
|
||||
method="post
|
||||
">
|
||||
<bootstrap:formGroupText
|
||||
help="#{SciPublicationsUiMessageBundle['createstep.name.help']}"
|
||||
inputId="name"
|
||||
label="#{SciPublicationsUiMessageBundle['createstep.name.label']}"
|
||||
name="name"
|
||||
pattern="^([a-zA-Z0-9_-]*)$"
|
||||
required="true"
|
||||
value="#{nameValue}"
|
||||
/>
|
||||
|
||||
<bootstrap:formGroupSelect
|
||||
help="#{SciPublicationsUiMessageBundle['createform.initial_locale.help']}"
|
||||
inputId="locale"
|
||||
label="#{SciPublicationsUiMessageBundle['createform.initial_locale.label']}"
|
||||
name="locale"
|
||||
options="#{availableLocales}"
|
||||
required="true"
|
||||
selectedOptions="#{[initialLocale]}"
|
||||
/>
|
||||
|
||||
<bootstrap:formGroupText
|
||||
help="#{SciPublicationsUiMessageBundle['createform.title.help']}"
|
||||
inputId="title"
|
||||
label="#{SciPublicationsUiMessageBundle['createform.title.label']}"
|
||||
name="title"
|
||||
required="true"
|
||||
value="#{title}"
|
||||
/>
|
||||
|
||||
<bootstrap:formGroupSelect
|
||||
help="#{SciPublicationsUiMessageBundle['createform.workflow.help']}"
|
||||
inputId="workflow"
|
||||
label="#{SciPublicationsUiMessageBundle['createform.workflow.label']}"
|
||||
name="workflow"
|
||||
options="#{availableWorkflows}"
|
||||
selectedOptions="#{[selectedWorkflow]}"
|
||||
/>
|
||||
|
||||
<a class="btn btn-warning"
|
||||
href="#{mvc.basePath}/#{contentSection}/documentsfolders/#{folderPath}">
|
||||
#{SciPublicationsUiMessageBundle['createform.cancel']}
|
||||
</a>
|
||||
<button class="btn btn-success"
|
||||
type="submit">
|
||||
#{createFormSubmitLabel}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html [<!ENTITY times '×'>]>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
|
||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
<ui:composition template="/WEB-INF/views/org/scientificcms/contenttypes/ui/create-publication.xhtml">
|
||||
|
||||
<ui:param name="availableLocales"
|
||||
value="#{SciPublicationsMonographCreateStep.availableLocales}" />
|
||||
|
||||
<ui:param name="availableWorkflows"
|
||||
value="#{SciPublicationsMonographCreateStep.availableWorkflows}" />
|
||||
|
||||
<ui:param name="contentSection"
|
||||
value="#{SciPublicationsMonographCreateStep.contentSectionLabel}" />
|
||||
|
||||
<ui:param name="createFormSubmitLabel"
|
||||
value="#{SciPublicationsUiMessageBundle['monograph.createform.submit']}" />
|
||||
|
||||
<ui:param name="documentType"
|
||||
value="#{SciPublicationsMonographCreateStep.documentType}" />
|
||||
|
||||
<ui:param name="folderPath"
|
||||
value="#{SciPublicationsMonographCreateStep.folderPath}" />
|
||||
|
||||
<ui:param name="initialLocale"
|
||||
value="#{SciPublicationsMonographCreateStep.initialLocale}" />
|
||||
|
||||
<ui:param name="messages"
|
||||
value="#{SciPublicationsMonographCreateStep.messages}" />
|
||||
|
||||
<ui:param name="nameValue"
|
||||
value="#{SciPublicationsMonographCreateStep.name}" />
|
||||
|
||||
<ui:param name="publicationCreateStepTitle"
|
||||
value="#{SciPublicationsUiMessageBundle['monograph.createform.title']}" />
|
||||
|
||||
<ui:param name="selectedWorkflow"
|
||||
value="#{SciPublicationsMonographCreateStep.selectedWorkflow}" />
|
||||
|
||||
<ui:param name="title"
|
||||
value="#{SciPublicationsMonographCreateStep.title}" />
|
||||
|
||||
</ui:composition>
|
||||
</html>
|
||||
|
|
@ -253,4 +253,24 @@ proceedings.editstep.shortdescription.remove.text=Are you sure to remove the fol
|
|||
proceedings.editstep.shortdescription.remove.title=Confirm removal of localized description
|
||||
proceedings.editstep.shortdescription.title=Description
|
||||
proceedings.editstep.properties.edit.submit=Save
|
||||
monographitem.createstep.description=Create new monograph item.
|
||||
monographitem.createstep.description=Create a new monograph item.
|
||||
authoringsteps.abstract.description=An abstract of the publication (blurb).
|
||||
authoringsteps.abstract.label=Abstract
|
||||
authoringsteps.misc.description=Additional information about the publication.
|
||||
authoringsteps.misc.label=Misc
|
||||
publication.edit.denied=Access denied
|
||||
authoringsteps.extendedproperties.description=Optional properties for publications
|
||||
authoringsteps.extendedproperties.label=Extended properties
|
||||
authoringsteps.basicproperties.description=Basic properties of the publication
|
||||
authoringsteps.basicproperties.label=Properties
|
||||
monograph.createform.title=Create a new monograph
|
||||
createstep.name.help=The name (URL fragment) of the publication item. Can only contain the letters a to z, A to Z, numbers, the dash ("-") and the underscore ("_").
|
||||
createstep.name.label=Name
|
||||
createform.initial_locale.help=Initial locale for the new publication item.
|
||||
createform.initial_locale.label=Locale
|
||||
createform.title.help=The title of the publication.
|
||||
createform.title.label=Title
|
||||
createform.workflow.help=The workflow to use for the new publication item.
|
||||
createform.workflow.label=Workflow
|
||||
createform.cancel=Cancel
|
||||
monograph.createform.submit=Create monograph
|
||||
|
|
|
|||
|
|
@ -254,3 +254,23 @@ proceedings.editstep.shortdescription.remove.title=Entfernen einer lokalisierten
|
|||
proceedings.editstep.shortdescription.title=Beschreibung
|
||||
proceedings.editstep.properties.edit.submit=Speichern
|
||||
monographitem.createstep.description=Legt ein neues Item f\u00fcr eine Monographie an.
|
||||
authoringsteps.abstract.description=Eine Zusammenfassung der Publikation (Klappentext).
|
||||
authoringsteps.abstract.label=Zusammenfassung
|
||||
authoringsteps.misc.description=Zus\u00e4tzliche Informationen \u00fcber die Publikation.
|
||||
authoringsteps.misc.label=Zus\u00e4tzliche Informationen
|
||||
publication.edit.denied=Zugriff verweigert
|
||||
authoringsteps.extendedproperties.description=Optionale Eigenschaften f\u00fcr Publikationen
|
||||
authoringsteps.extendedproperties.label=Erweiterte Eigenschaften
|
||||
authoringsteps.basicproperties.description=Basiseigenschaften der Publikation
|
||||
authoringsteps.basicproperties.label=Eigenschaften
|
||||
monograph.createform.title=Neue Monographie anlegen
|
||||
createstep.name.help=Der Name (URL-Fragment) des Publikations-Items. Darf nur die Buchstaben A bis Z und a bis z, Zahlen, den Bindestrich ("-") und den Unterstrich ("_") enthalten.
|
||||
createstep.name.label=Name
|
||||
createform.initial_locale.help=Initiale Sprache des neuen Publikations-Items.
|
||||
createform.initial_locale.label=Sprache
|
||||
createform.title.help=Der Titel der Publikation.
|
||||
createform.title.label=Titel
|
||||
createform.workflow.help=Der Arbeitsablauf, der f\u00fcr das neuen Publikations-Item verwendet werden soll.
|
||||
createform.workflow.label=Arbeitsablauf
|
||||
createform.cancel=Abbrechen
|
||||
monograph.createform.submit=Monographie anlegen
|
||||
|
|
|
|||
Loading…
Reference in New Issue