UI for creating and editing series
parent
9900ff6465
commit
fdcda6b3fd
|
|
@ -1,8 +1,3 @@
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package org.scientificcms.publications;
|
package org.scientificcms.publications;
|
||||||
|
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,11 @@ package org.scientificcms.publications.assets;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.librecms.assets.AssetType;
|
import org.librecms.assets.AssetType;
|
||||||
import org.librecms.contentsection.Asset;
|
import org.librecms.contentsection.Asset;
|
||||||
|
import org.librecms.ui.contentsections.assets.MvcAssetEditKit;
|
||||||
import org.scientificcms.publications.SciPublicationsConstants;
|
import org.scientificcms.publications.SciPublicationsConstants;
|
||||||
import org.scientificcms.publications.Series;
|
import org.scientificcms.publications.Series;
|
||||||
|
import org.scientificcms.publications.ui.assets.SeriesAssetCreateStep;
|
||||||
|
import org.scientificcms.publications.ui.assets.SeriesAssetEditStep;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
@ -34,6 +37,10 @@ import static org.scientificcms.publications.SciPublicationsConstants.*;
|
||||||
descriptionBundle = SciPublicationsConstants.BUNDLE,
|
descriptionBundle = SciPublicationsConstants.BUNDLE,
|
||||||
descriptionKey = "journal.description"
|
descriptionKey = "journal.description"
|
||||||
)
|
)
|
||||||
|
@MvcAssetEditKit(
|
||||||
|
createStep = SeriesAssetCreateStep.class,
|
||||||
|
editStep = SeriesAssetEditStep.class
|
||||||
|
)
|
||||||
public class SeriesAsset extends Asset {
|
public class SeriesAsset extends Asset {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ import javax.ws.rs.PathParam;
|
||||||
@Controller
|
@Controller
|
||||||
@MvcAssetEditStepDef(
|
@MvcAssetEditStepDef(
|
||||||
bundle = SciPublicationsUiConstants.BUNDLE,
|
bundle = SciPublicationsUiConstants.BUNDLE,
|
||||||
descriptionKey = "joural.editstep.description",
|
descriptionKey = "journal.editstep.description",
|
||||||
labelKey = "journal.editstep.label",
|
labelKey = "journal.editstep.label",
|
||||||
supportedAssetType = JournalAsset.class
|
supportedAssetType = JournalAsset.class
|
||||||
)
|
)
|
||||||
|
|
@ -276,7 +276,7 @@ public class JournalAssetEditStep extends AbstractMvcAssetEditStep {
|
||||||
journalRepo.save(getJournal());
|
journalRepo.save(getJournal());
|
||||||
|
|
||||||
return buildRedirectPathForStep();
|
return buildRedirectPathForStep();
|
||||||
}else {
|
} else {
|
||||||
return assetUi.showAccessDenied(
|
return assetUi.showAccessDenied(
|
||||||
getContentSection(),
|
getContentSection(),
|
||||||
getAsset(),
|
getAsset(),
|
||||||
|
|
@ -310,7 +310,7 @@ public class JournalAssetEditStep extends AbstractMvcAssetEditStep {
|
||||||
journalRepo.save(getJournal());
|
journalRepo.save(getJournal());
|
||||||
|
|
||||||
return buildRedirectPathForStep();
|
return buildRedirectPathForStep();
|
||||||
}else {
|
} else {
|
||||||
return assetUi.showAccessDenied(
|
return assetUi.showAccessDenied(
|
||||||
getContentSection(),
|
getContentSection(),
|
||||||
getAsset(),
|
getAsset(),
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ public class SciPublicationsAssetSteps implements MvcAssetEditSteps {
|
||||||
public Set<Class<?>> getClasses() {
|
public Set<Class<?>> getClasses() {
|
||||||
return Set.of(
|
return Set.of(
|
||||||
JournalAssetEditStep.class,
|
JournalAssetEditStep.class,
|
||||||
PublisherAssetEditStep.class
|
PublisherAssetEditStep.class,
|
||||||
|
SeriesAssetEditStep.class
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
package org.scientificcms.publications.ui.assets;
|
||||||
|
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.librecms.ui.contentsections.assets.AbstractMvcAssetCreateStep;
|
||||||
|
import org.scientificcms.publications.Series;
|
||||||
|
import org.scientificcms.publications.SeriesRepository;
|
||||||
|
import org.scientificcms.publications.assets.SeriesAsset;
|
||||||
|
import org.scientificcms.publications.ui.SciPublicationsUiConstants;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Named("SciCmsSeriesAssetCreateStep")
|
||||||
|
public class SeriesAssetCreateStep
|
||||||
|
extends AbstractMvcAssetCreateStep<SeriesAsset> {
|
||||||
|
|
||||||
|
private static final String FORM_PARAMS_DESCRIPTION = "description";
|
||||||
|
|
||||||
|
private String seriesDescription;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SeriesRepository seriesRepo;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String showCreateStep() {
|
||||||
|
return "org/scientificcms/assets/series/ui/create-series.xhtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("series.label");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("series.description");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBundle() {
|
||||||
|
return SciPublicationsUiConstants.BUNDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<SeriesAsset> getAssetClass() {
|
||||||
|
return SeriesAsset.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSeriesDescription() {
|
||||||
|
return seriesDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
protected String setAssetProperties(
|
||||||
|
final SeriesAsset seriesAsset,
|
||||||
|
final Map<String, String[]> formParams
|
||||||
|
) {
|
||||||
|
final Series series = new Series();
|
||||||
|
final Locale locale = new Locale(getInitialLocale());
|
||||||
|
series.getTitle().putValue(
|
||||||
|
locale,
|
||||||
|
seriesAsset.getTitle().getValue(locale)
|
||||||
|
);
|
||||||
|
|
||||||
|
seriesDescription = Optional
|
||||||
|
.ofNullable(formParams.get(FORM_PARAMS_DESCRIPTION))
|
||||||
|
.filter(value -> value.length > 0)
|
||||||
|
.map(value -> value[0])
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
if (seriesDescription != null) {
|
||||||
|
series.getDescription().putValue(locale, seriesDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
seriesRepo.save(series);
|
||||||
|
|
||||||
|
seriesAsset.setSeries(series);
|
||||||
|
|
||||||
|
return String.format(
|
||||||
|
"redirect:/%s/assets/%s/%s/@series-edit",
|
||||||
|
getContentSectionLabel(),
|
||||||
|
getFolderPath(),
|
||||||
|
getName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,368 @@
|
||||||
|
package org.scientificcms.publications.ui.assets;
|
||||||
|
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
import org.librecms.ui.contentsections.AssetPermissionsChecker;
|
||||||
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
|
import org.librecms.ui.contentsections.assets.AbstractMvcAssetEditStep;
|
||||||
|
import org.librecms.ui.contentsections.assets.AssetNotFoundException;
|
||||||
|
import org.librecms.ui.contentsections.assets.AssetStepsDefaultMessagesBundle;
|
||||||
|
import org.librecms.ui.contentsections.assets.AssetUi;
|
||||||
|
import org.librecms.ui.contentsections.assets.MvcAssetEditStep;
|
||||||
|
import org.librecms.ui.contentsections.assets.MvcAssetEditStepDef;
|
||||||
|
import org.librecms.ui.contentsections.assets.MvcAssetEditSteps;
|
||||||
|
import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
|
||||||
|
import org.scientificcms.publications.Series;
|
||||||
|
import org.scientificcms.publications.SeriesRepository;
|
||||||
|
import org.scientificcms.publications.assets.SeriesAsset;
|
||||||
|
import org.scientificcms.publications.ui.SciPublicationsUiConstants;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
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(MvcAssetEditSteps.PATH_PREFIX + "series-edit")
|
||||||
|
@Controller
|
||||||
|
@MvcAssetEditStepDef(
|
||||||
|
bundle = SciPublicationsUiConstants.BUNDLE,
|
||||||
|
descriptionKey = "series.editstep.description",
|
||||||
|
labelKey = "series.editstep.label",
|
||||||
|
supportedAssetType = SeriesAsset.class
|
||||||
|
)
|
||||||
|
public class SeriesAssetEditStep extends AbstractMvcAssetEditStep {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetPermissionsChecker assetPermissionsChecker;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetStepsDefaultMessagesBundle messageBundle;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetUi assetUi;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SeriesRepository seriesRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private SeriesAssetEditStepModel editStepModel;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends MvcAssetEditStep> getStepClass() {
|
||||||
|
return SeriesAssetEditStep.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
protected void init() throws ContentSectionNotFoundException,
|
||||||
|
AssetNotFoundException {
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
if (getAsset() instanceof SeriesAsset) {
|
||||||
|
final Series series = getSeries();
|
||||||
|
|
||||||
|
editStepModel.setDescriptionValues(
|
||||||
|
series
|
||||||
|
.getDescription()
|
||||||
|
.getValues()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(
|
||||||
|
entry -> entry.getKey().toString(),
|
||||||
|
entry -> entry.getValue()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Set<Locale> descriptionLocales = series
|
||||||
|
.getDescription()
|
||||||
|
.getAvailableLocales();
|
||||||
|
editStepModel.setUnusedDescriptionLocales(
|
||||||
|
globalizationHelper
|
||||||
|
.getAvailableLocales()
|
||||||
|
.stream()
|
||||||
|
.filter(locale -> !descriptionLocales.contains(locale))
|
||||||
|
.map(Locale::toString)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
|
||||||
|
editStepModel.setDescriptionVariants(
|
||||||
|
series
|
||||||
|
.getDescription()
|
||||||
|
.getValues()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.map(this::buildVariantRow)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new AssetNotFoundException(
|
||||||
|
assetUi.showAssetNotFound(
|
||||||
|
getContentSection(), getAssetPath()
|
||||||
|
),
|
||||||
|
String.format(
|
||||||
|
"No SeriesAsset for path %s found in section %s.",
|
||||||
|
getAssetPath(),
|
||||||
|
getContentSection().getLabel()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SeriesAsset getSeriesAsset() {
|
||||||
|
return (SeriesAsset) getAsset();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Series getSeries() {
|
||||||
|
return getSeriesAsset().getSeries();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@Override
|
||||||
|
public String showStep(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
return "org/scientificcms/assets/series/ui/edit-series.xhtml";
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/title/@add")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@Override
|
||||||
|
public String addTitle(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@FormParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
final String redirect = super.addTitle(
|
||||||
|
sectionIdentifier,
|
||||||
|
assetPath,
|
||||||
|
localeParam,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
final Series series = getSeries();
|
||||||
|
series.getTitle().putValue(locale, value);
|
||||||
|
seriesRepo.save(series);
|
||||||
|
|
||||||
|
return redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/title/@edit/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@Override
|
||||||
|
public String editTitle(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@PathParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
final String redirect = super.editTitle(
|
||||||
|
sectionIdentifier,
|
||||||
|
assetPath,
|
||||||
|
localeParam,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
final Series series = getSeries();
|
||||||
|
series.getTitle().putValue(locale, value);
|
||||||
|
seriesRepo.save(series);
|
||||||
|
|
||||||
|
return redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/title/@remove/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String removeTitle(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@PathParam("locale") final String localeParam
|
||||||
|
) {
|
||||||
|
final String redirect = super.removeTitle(
|
||||||
|
sectionIdentifier,
|
||||||
|
assetPath,
|
||||||
|
localeParam
|
||||||
|
);
|
||||||
|
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
final Series series = getSeries();
|
||||||
|
series.getTitle().removeValue(locale);
|
||||||
|
seriesRepo.save(series);
|
||||||
|
return redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/description/add")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String addDescriptionValue(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@FormParam("locale")
|
||||||
|
final String localeParam,
|
||||||
|
@FormParam("value")
|
||||||
|
final String value
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getSeries().getDescription().putValue(locale, value);
|
||||||
|
seriesRepo.save(getSeries());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/description/edit/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String editDescriptionValue(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@PathParam("locale") final String localeParam,
|
||||||
|
@FormParam("value") final String value
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getSeries().getDescription().putValue(locale, value);
|
||||||
|
seriesRepo.save(getSeries());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/description/remove/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String removeDescriptionValue(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@PathParam("locale") final String localeParam
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getSeries().getDescription().removeValue(locale);
|
||||||
|
seriesRepo.save(getSeries());
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CmsEditorLocaleVariantRow buildVariantRow(
|
||||||
|
final Map.Entry<Locale, String> entry
|
||||||
|
) {
|
||||||
|
final CmsEditorLocaleVariantRow variant
|
||||||
|
= new CmsEditorLocaleVariantRow();
|
||||||
|
variant.setLocale(entry.getKey().toString());
|
||||||
|
variant.setWordCount(
|
||||||
|
new StringTokenizer(entry.getValue()).countTokens()
|
||||||
|
);
|
||||||
|
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package org.scientificcms.publications.ui.assets;
|
||||||
|
|
||||||
|
import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Named("SciCmsSeriesAssetEditStepModel")
|
||||||
|
public class SeriesAssetEditStepModel {
|
||||||
|
|
||||||
|
private Map<String, String> descriptionValues;
|
||||||
|
|
||||||
|
private List<CmsEditorLocaleVariantRow> descriptionVariants;
|
||||||
|
|
||||||
|
private List<String> unusedDescriptionLocales;
|
||||||
|
|
||||||
|
public Map<String, String> getDescriptionValues() {
|
||||||
|
return Collections.unmodifiableMap(descriptionValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionValues(
|
||||||
|
final Map<String, String> descriptionValues
|
||||||
|
) {
|
||||||
|
this.descriptionValues = new HashMap<>(descriptionValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CmsEditorLocaleVariantRow> getDescriptionVariants() {
|
||||||
|
return Collections.unmodifiableList(descriptionVariants);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionVariants(
|
||||||
|
final List<CmsEditorLocaleVariantRow> variants
|
||||||
|
) {
|
||||||
|
this.descriptionVariants = new ArrayList<>(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUnusedDescriptionLocales() {
|
||||||
|
return Collections.unmodifiableList(unusedDescriptionLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnusedDescriptionLocales(
|
||||||
|
final List<String> unusedDescriptionLocales
|
||||||
|
) {
|
||||||
|
this.unusedDescriptionLocales = new ArrayList<>(
|
||||||
|
unusedDescriptionLocales
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<!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>#{SciPublicationsUiMessageBundle['series.createform.title']}</h1>
|
||||||
|
|
||||||
|
<c:forEach items="#{SciCmsSeriesAssetCreateStep.messages.entrySet()}"
|
||||||
|
var="messages">
|
||||||
|
<div class="alert alert-#{message.key}" role="alert">
|
||||||
|
#{message.value}
|
||||||
|
</div>
|
||||||
|
</c:forEach>
|
||||||
|
|
||||||
|
<form action="#{mvc.basePath}/#{SciCmsSeriesAssetCreateStep.contentSectionLabel}/assets/#{SciCmsSeriesAssetCreateStep.folderPath}@create/#{SciCmsSeriesAssetCreateStep.assetType}"
|
||||||
|
method="post">
|
||||||
|
<bootstrap:formGroupText
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.name.help']}"
|
||||||
|
inputId="name"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.name.label']}"
|
||||||
|
name="name"
|
||||||
|
pattern="^([a-zA-Z0-9_-]*)$"
|
||||||
|
required="true"
|
||||||
|
value="#{SciCmsSeriesAssetCreateStep.name}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupSelect
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.initial_locale.help']}"
|
||||||
|
inputId="locale"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.initial_locale.label']}"
|
||||||
|
name="locale"
|
||||||
|
options="#{SciCmsSeriesAssetCreateStep.availableLocales}"
|
||||||
|
required="true"
|
||||||
|
selectedOptions="#{[SciCmsSeriesAssetCreateStep.initialLocale]}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupText
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.title.help']}"
|
||||||
|
inputId="title"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.title.label']}"
|
||||||
|
name="title"
|
||||||
|
required="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupTextarea
|
||||||
|
cols="80"
|
||||||
|
help="#{SciPublicationsUiMessageBundle['series.createform.description.help']}"
|
||||||
|
inputId="description"
|
||||||
|
label="#{SciPublicationsUiMessageBundle['series.createform.description.label']}"
|
||||||
|
name="description"
|
||||||
|
rows="20"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<a class="btn btn-warning"
|
||||||
|
href="#{mvc.basePath}/#{SciCmsSeriesAssetCreateStep.contentSectionLabel}/assetsfolders/#{SciCmsSeriesAssetCreateStep.folderPath}">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['createform.cancel']}
|
||||||
|
</a>
|
||||||
|
<button class="btn btn-success"
|
||||||
|
type="submit">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['createform.submit']}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
<!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/assets/editstep.xhtml">
|
||||||
|
|
||||||
|
<ui:param name="stepControllerUrl"
|
||||||
|
value="@series-edit"
|
||||||
|
/>
|
||||||
|
<ui:param name="title"
|
||||||
|
value="#{SciPublicationsUiMessageBundle.getMessage('series.editstep.header', [MvcAssetEditStepModel.name])}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ui:define name="editStep">
|
||||||
|
<c:if test="#{MvcAssetEditStepModel.canEdit}">
|
||||||
|
<libreccm:localizedStringEditor
|
||||||
|
addButtonLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.add.label']}"
|
||||||
|
addDialogCancelLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.add.cancel']}"
|
||||||
|
addDialogLocaleSelectHelp="#{SciPublicationsUiMessageBundle['series.editstep.description.add.locale.help']}"
|
||||||
|
addDialogLocaleSelectLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.locale.label']}"
|
||||||
|
addDialogSubmitLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.add.submit.label']}"
|
||||||
|
addDialogTitle="#{SciPublicationsUiMessageBundle['series.editstep.description.add.title']}"
|
||||||
|
addDialogValueHelp="#{SciPublicationsUiMessageBundle['series.editstep.description.add.value.help']}"
|
||||||
|
addDialogValueLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.add.value.label']}"
|
||||||
|
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@series-edit/description/add"
|
||||||
|
editButtonLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.edit.label']}"
|
||||||
|
editDialogCancelLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.edit.cancel']}"
|
||||||
|
editDialogSubmitLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.edit.submit']}"
|
||||||
|
editDialogTitle="#{SciPublicationsUiMessageBundle['series.editstep.description.edit.title']}"
|
||||||
|
editDialogValueHelp="#{SciPublicationsUiMessageBundle['series.editstep.description.edit.value.help']}"
|
||||||
|
editDialogValueLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.edit.value.label']}"
|
||||||
|
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@series-edit/description/edit"
|
||||||
|
editorId="series-description-editor"
|
||||||
|
hasUnusedLocales="#{!SciCmsSeriesAssetEditStepModel.unusedDescriptionLocales.isEmpty()}"
|
||||||
|
headingLevel="3"
|
||||||
|
objectIdentifier="#{CmsSelectedAssetModel.assetPath}"
|
||||||
|
readOnly="#{!MvcAssetEditStepModel.canEdit}"
|
||||||
|
removeButtonLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.remove.label']}"
|
||||||
|
removeDialogCancelLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.remove.cancel']}"
|
||||||
|
removeDialogSubmitLabel="#{SciPublicationsUiMessageBundle['series.editstep.description.remove.submit']}"
|
||||||
|
removeDialogText="#{SciPublicationsUiMessageBundle['series.editstep.description.remove.text']}"
|
||||||
|
removeDialogTitle="#{SciPublicationsUiMessageBundle['series.editstep.description.remove.title']}"
|
||||||
|
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@series-edit/description/remove"
|
||||||
|
title="#{SciPublicationsUiMessageBundle['series.editstep.description.title']}"
|
||||||
|
unusedLocales="#{SciCmsSeriesAssetEditStepModel.unusedDescriptionLocales}"
|
||||||
|
useTextarea="true"
|
||||||
|
values="#{SciCmsSeriesAssetEditStepModel.descriptionValues}"
|
||||||
|
/>
|
||||||
|
</c:if>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
|
|
@ -61,3 +61,29 @@ journal.editstep.description.remove.title=Remove localized description
|
||||||
journal.editstep.description.title=Description of the journal
|
journal.editstep.description.title=Description of the journal
|
||||||
journal.label=Journal
|
journal.label=Journal
|
||||||
journal.description=Creates a new journal
|
journal.description=Creates a new journal
|
||||||
|
series.createform.title=Create a new series
|
||||||
|
series.createform.description.help=A description of the series.
|
||||||
|
series.createform.description.label=Description
|
||||||
|
series.editstep.header=Edit series {0}
|
||||||
|
series.editstep.description.add.label=Add localized description
|
||||||
|
series.editstep.description.add.cancel=Cancel
|
||||||
|
series.editstep.description.add.value.help=A description of the series.
|
||||||
|
series.editstep.description.add.locale.help=The language of the localized description.
|
||||||
|
series.editstep.description.locale.label=Locale
|
||||||
|
series.editstep.description.add.submit.label=Add
|
||||||
|
series.editstep.description.add.title=Add localized description
|
||||||
|
series.editstep.description.add.value.label=Description
|
||||||
|
series.editstep.description.edit.label=Edit
|
||||||
|
series.editstep.description.edit.cancel=Cancel
|
||||||
|
series.editstep.description.edit.submit=Save
|
||||||
|
series.editstep.description.edit.title=Edit localized description
|
||||||
|
series.editstep.description.edit.value.help=A description of the series.
|
||||||
|
series.editstep.description.edit.value.label=Description
|
||||||
|
series.editstep.description.remove.label=Remove
|
||||||
|
series.editstep.description.remove.cancel=Cancel
|
||||||
|
series.editstep.description.remove.submit=Remove
|
||||||
|
series.editstep.description.remove.text=Are you sure to remove the following localized description:
|
||||||
|
series.editstep.description.remove.title=Confirm removal of localized description
|
||||||
|
series.editstep.description.title=Description
|
||||||
|
series.label=Series
|
||||||
|
series.description=Create a new series (of publications)
|
||||||
|
|
|
||||||
|
|
@ -61,3 +61,29 @@ journal.editstep.description.remove.title=Lokalisierte Beschreibung entfernen
|
||||||
journal.editstep.description.title=Beschreibung der Zeitschrift
|
journal.editstep.description.title=Beschreibung der Zeitschrift
|
||||||
journal.label=Zeitschrift
|
journal.label=Zeitschrift
|
||||||
journal.description=Neue Zeitschrift anlegen
|
journal.description=Neue Zeitschrift anlegen
|
||||||
|
series.createform.title=Neue Reihe anlegen
|
||||||
|
series.createform.description.help=Eine Beschreibung der Reihe.
|
||||||
|
series.createform.description.label=Beschreibung
|
||||||
|
series.editstep.header=Reihe {0} bearbeiten
|
||||||
|
series.editstep.description.add.label=Lokalisierte Beschreibung hinzuf\u00fcgen
|
||||||
|
series.editstep.description.add.cancel=Abbrechen
|
||||||
|
series.editstep.description.add.value.help=Eine Beschreibung der Reihe.
|
||||||
|
series.editstep.description.add.locale.help=Die Sprache der lokalisierten Beschreibung.
|
||||||
|
series.editstep.description.locale.label=Sprache
|
||||||
|
series.editstep.description.add.submit.label=Hinzuf\u00fcgen
|
||||||
|
series.editstep.description.add.title=Lokalisierte Beschreibung hinzuf\u00fcgen
|
||||||
|
series.editstep.description.add.value.label=Beschreibung
|
||||||
|
series.editstep.description.edit.label=Bearbeiten
|
||||||
|
series.editstep.description.edit.cancel=Abbrechen
|
||||||
|
series.editstep.description.edit.submit=Speichern
|
||||||
|
series.editstep.description.edit.title=Lokalisierte Beschreibung bearbeiten
|
||||||
|
series.editstep.description.edit.value.help=Eine Beschreibung der Reihe.
|
||||||
|
series.editstep.description.edit.value.label=Beschreibung
|
||||||
|
series.editstep.description.remove.label=Entfernen
|
||||||
|
series.editstep.description.remove.cancel=Abbrechen
|
||||||
|
series.editstep.description.remove.submit=Entfernen
|
||||||
|
series.editstep.description.remove.text=Sind Sie sicher, dass die die folgenden lokalisierte Beschreibung entfernen wollen:
|
||||||
|
series.editstep.description.remove.title=Entfernen einer lokaliserten Beschreibung best\u00e4tigen
|
||||||
|
series.editstep.description.title=Beschreibung
|
||||||
|
series.label=Reihe
|
||||||
|
series.description=Eine neue (Publikations-) Reihe anlegen
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue