Moved some code to the abstract base classes of the create/edit steps for assets, steps for creating and editing side notes.
parent
101f802d9c
commit
0cce876a5b
|
|
@ -19,9 +19,13 @@
|
||||||
package org.librecms.assets;
|
package org.librecms.assets;
|
||||||
|
|
||||||
import com.arsdigita.cms.ui.assets.forms.SideNoteForm;
|
import com.arsdigita.cms.ui.assets.forms.SideNoteForm;
|
||||||
|
|
||||||
import org.librecms.contentsection.Asset;
|
import org.librecms.contentsection.Asset;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
import org.librecms.ui.contentsections.assets.MvcAssetEditKit;
|
||||||
|
import org.librecms.ui.contentsections.assets.SideNoteCreateStep;
|
||||||
|
import org.librecms.ui.contentsections.assets.SideNoteEditStep;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -44,11 +48,17 @@ import static org.librecms.assets.AssetConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "SIDE_NOTES", schema = DB_SCHEMA)
|
@Table(name = "SIDE_NOTES", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
@AssetType(assetForm = SideNoteForm.class,
|
@AssetType(
|
||||||
labelBundle= ASSETS_BUNDLE,
|
assetForm = SideNoteForm.class,
|
||||||
labelKey = "sidenote.label",
|
labelBundle = ASSETS_BUNDLE,
|
||||||
descriptionBundle = ASSETS_BUNDLE,
|
labelKey = "sidenote.label",
|
||||||
descriptionKey = "sidenote.description")
|
descriptionBundle = ASSETS_BUNDLE,
|
||||||
|
descriptionKey = "sidenote.description"
|
||||||
|
)
|
||||||
|
@MvcAssetEditKit(
|
||||||
|
createStep = SideNoteCreateStep.class,
|
||||||
|
editStep = SideNoteEditStep.class
|
||||||
|
)
|
||||||
public class SideNote extends Asset implements Serializable {
|
public class SideNote extends Asset implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -4566222634780521726L;
|
private static final long serialVersionUID = -4566222634780521726L;
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,17 @@
|
||||||
package org.librecms.ui.contentsections.assets;
|
package org.librecms.ui.contentsections.assets;
|
||||||
|
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
|
import org.librecms.assets.PostalAddress;
|
||||||
import org.librecms.contentsection.Asset;
|
import org.librecms.contentsection.Asset;
|
||||||
|
import org.librecms.contentsection.AssetManager;
|
||||||
import org.librecms.contentsection.ContentSection;
|
import org.librecms.contentsection.ContentSection;
|
||||||
import org.librecms.contentsection.Folder;
|
import org.librecms.contentsection.Folder;
|
||||||
import org.librecms.contentsection.FolderManager;
|
import org.librecms.contentsection.FolderManager;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
@ -42,6 +46,15 @@ import javax.transaction.Transactional;
|
||||||
public abstract class AbstractMvcAssetCreateStep<T extends Asset>
|
public abstract class AbstractMvcAssetCreateStep<T extends Asset>
|
||||||
implements MvcAssetCreateStep<T> {
|
implements MvcAssetCreateStep<T> {
|
||||||
|
|
||||||
|
private static final String FORM_PARAMS_NAME = "name";
|
||||||
|
|
||||||
|
private static final String FORM_PARAMS_TITLE = "title";
|
||||||
|
|
||||||
|
private static final String FORM_PARAM_INITIAL_LOCALE = "locale";
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetManager assetManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides operations for folders.
|
* Provides operations for folders.
|
||||||
*/
|
*/
|
||||||
|
|
@ -71,6 +84,12 @@ public abstract class AbstractMvcAssetCreateStep<T extends Asset>
|
||||||
*/
|
*/
|
||||||
private SortedMap<String, String> messages;
|
private SortedMap<String, String> messages;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String initialLocale;
|
||||||
|
|
||||||
public AbstractMvcAssetCreateStep() {
|
public AbstractMvcAssetCreateStep() {
|
||||||
messages = new TreeMap<>();
|
messages = new TreeMap<>();
|
||||||
}
|
}
|
||||||
|
|
@ -154,4 +173,92 @@ public abstract class AbstractMvcAssetCreateStep<T extends Asset>
|
||||||
this.messages = new TreeMap<>(messages);
|
this.messages = new TreeMap<>(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInitialLocale() {
|
||||||
|
return initialLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAssetType() {
|
||||||
|
return getAssetClass().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@Override
|
||||||
|
public String createAsset(final Map<String, String[]> formParams) {
|
||||||
|
if (!formParams.containsKey(FORM_PARAMS_NAME)
|
||||||
|
|| formParams.get(FORM_PARAMS_NAME) == null
|
||||||
|
|| formParams.get(FORM_PARAMS_NAME).length == 0) {
|
||||||
|
addMessage(
|
||||||
|
"danger",
|
||||||
|
globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("postaladdress.createstep.name.error.missing")
|
||||||
|
);
|
||||||
|
return showCreateStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
name = formParams.get(FORM_PARAMS_NAME)[0];
|
||||||
|
if (!name.matches("^([a-zA-Z0-9_-]*)$")) {
|
||||||
|
addMessage(
|
||||||
|
"danger",
|
||||||
|
globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("postaladdress.createstep.name.error.invalid")
|
||||||
|
);
|
||||||
|
return showCreateStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formParams.containsKey(FORM_PARAMS_TITLE)
|
||||||
|
|| formParams.get(FORM_PARAMS_TITLE) == null
|
||||||
|
|| formParams.get(FORM_PARAMS_TITLE).length == 0) {
|
||||||
|
addMessage(
|
||||||
|
"danger",
|
||||||
|
globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("postaladdress.createstep.title.error.missing")
|
||||||
|
);
|
||||||
|
return showCreateStep();
|
||||||
|
}
|
||||||
|
title = formParams.get(FORM_PARAMS_TITLE)[0];
|
||||||
|
|
||||||
|
if (!formParams.containsKey(FORM_PARAM_INITIAL_LOCALE)
|
||||||
|
|| formParams.get(FORM_PARAM_INITIAL_LOCALE) == null
|
||||||
|
|| formParams.get(FORM_PARAM_INITIAL_LOCALE).length == 0) {
|
||||||
|
addMessage(
|
||||||
|
"danger",
|
||||||
|
globalizationHelper.getLocalizedTextsUtil(
|
||||||
|
getBundle()
|
||||||
|
).getText("createstep.initial_locale.error.missing")
|
||||||
|
);
|
||||||
|
return showCreateStep();
|
||||||
|
}
|
||||||
|
initialLocale = formParams.get(FORM_PARAM_INITIAL_LOCALE)[0];
|
||||||
|
final Locale locale = new Locale(initialLocale);
|
||||||
|
|
||||||
|
// final T asset = createAsset(name, title, locale, folder);
|
||||||
|
|
||||||
|
final T asset = assetManager.createAsset(
|
||||||
|
name,
|
||||||
|
title,
|
||||||
|
locale,
|
||||||
|
folder,
|
||||||
|
getAssetClass()
|
||||||
|
);
|
||||||
|
|
||||||
|
return setAssetProperties(asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Class<T> getAssetClass();
|
||||||
|
|
||||||
|
protected abstract String setAssetProperties(final T asset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package org.librecms.ui.contentsections.assets;
|
package org.librecms.ui.contentsections.assets;
|
||||||
|
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
import org.librecms.contentsection.Asset;
|
import org.librecms.contentsection.Asset;
|
||||||
import org.librecms.contentsection.AssetManager;
|
import org.librecms.contentsection.AssetManager;
|
||||||
import org.librecms.contentsection.AssetRepository;
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
|
@ -28,13 +29,23 @@ import org.librecms.ui.contentsections.ContentSectionModel;
|
||||||
import org.librecms.ui.contentsections.ContentSectionsUi;
|
import org.librecms.ui.contentsections.ContentSectionsUi;
|
||||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.mvc.Controller;
|
||||||
import javax.mvc.Models;
|
import javax.mvc.Models;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import javax.ws.rs.DefaultValue;
|
||||||
|
import javax.ws.rs.FormParam;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
|
@ -44,8 +55,12 @@ import javax.ws.rs.core.UriBuilder;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
|
@Controller
|
||||||
public abstract class AbstractMvcAssetEditStep implements MvcAssetEditStep {
|
public abstract class AbstractMvcAssetEditStep implements MvcAssetEditStep {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetStepsDefaultMessagesBundle messageBundle;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AssetUi assetUi;
|
private AssetUi assetUi;
|
||||||
|
|
||||||
|
|
@ -90,6 +105,10 @@ public abstract class AbstractMvcAssetEditStep implements MvcAssetEditStep {
|
||||||
|
|
||||||
private String stepPath;
|
private String stepPath;
|
||||||
|
|
||||||
|
private Map<String, String> titleValues;
|
||||||
|
|
||||||
|
private List<String> unusedTitleLocales;
|
||||||
|
|
||||||
protected void init() throws ContentSectionNotFoundException,
|
protected void init() throws ContentSectionNotFoundException,
|
||||||
AssetNotFoundException {
|
AssetNotFoundException {
|
||||||
contentSection = sectionsUi
|
contentSection = sectionsUi
|
||||||
|
|
@ -143,6 +162,29 @@ public abstract class AbstractMvcAssetEditStep implements MvcAssetEditStep {
|
||||||
)
|
)
|
||||||
.orElse("");
|
.orElse("");
|
||||||
|
|
||||||
|
titleValues = getAsset()
|
||||||
|
.getTitle()
|
||||||
|
.getValues()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(
|
||||||
|
entry -> entry.getKey().toString(),
|
||||||
|
entry -> entry.getValue()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Set<Locale> titleLocales = getAsset()
|
||||||
|
.getTitle()
|
||||||
|
.getAvailableLocales();
|
||||||
|
|
||||||
|
unusedTitleLocales = globalizationHelper
|
||||||
|
.getAvailableLocales()
|
||||||
|
.stream()
|
||||||
|
.filter(locale -> !titleLocales.contains(locale))
|
||||||
|
.map(Locale::toString)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
models.put("activeAssetTab", "editTab");
|
models.put("activeAssetTab", "editTab");
|
||||||
models.put("stepPath", stepPath);
|
models.put("stepPath", stepPath);
|
||||||
}
|
}
|
||||||
|
|
@ -252,9 +294,9 @@ public abstract class AbstractMvcAssetEditStep implements MvcAssetEditStep {
|
||||||
.map(Path::value)
|
.map(Path::value)
|
||||||
.map(
|
.map(
|
||||||
path -> UriBuilder
|
path -> UriBuilder
|
||||||
.fromPath(path)
|
.fromPath(path)
|
||||||
.buildFromMap(values)
|
.buildFromMap(values)
|
||||||
.toString()
|
.toString()
|
||||||
)
|
)
|
||||||
.map(path -> String.format("redirect:%s", path))
|
.map(path -> String.format("redirect:%s", path))
|
||||||
.orElse("");
|
.orElse("");
|
||||||
|
|
@ -302,15 +344,166 @@ public abstract class AbstractMvcAssetEditStep implements MvcAssetEditStep {
|
||||||
.map(Path::value)
|
.map(Path::value)
|
||||||
.map(
|
.map(
|
||||||
path -> UriBuilder
|
path -> UriBuilder
|
||||||
.fromPath(path)
|
.fromPath(path)
|
||||||
.path(subPath)
|
.path(subPath)
|
||||||
.buildFromMap(values)
|
.buildFromMap(values)
|
||||||
.toString()
|
.toString()
|
||||||
)
|
)
|
||||||
.map(path -> String.format("redirect:%s", path))
|
.map(path -> String.format("redirect:%s", path))
|
||||||
.orElse("");
|
.orElse("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return getAsset().getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/name")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String updateName(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@FormParam("name") @DefaultValue("") final String name
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
if (name.isEmpty() || name.matches("\\s*")) {
|
||||||
|
models.put("nameMissing", true);
|
||||||
|
|
||||||
|
return showStep(sectionIdentifier, assetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
getAsset().setDisplayName(name);
|
||||||
|
assetRepo.save(getAsset());
|
||||||
|
|
||||||
|
updateAssetPath();
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getTitleValues() {
|
||||||
|
return Collections.unmodifiableMap(titleValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUnusedTitleLocales() {
|
||||||
|
return Collections.unmodifiableList(unusedTitleLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/title/@add")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
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
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getAsset().getTitle().addValue(locale, value);
|
||||||
|
assetRepo.save(getAsset());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/title/@edit/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
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
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getAsset().getTitle().addValue(locale, value);
|
||||||
|
assetRepo.save(getAsset());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
final Locale locale = new Locale(localeParam);
|
||||||
|
getAsset().getTitle().removeValue(locale);
|
||||||
|
assetRepo.save(getAsset());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.ui.contentsections.assets;
|
package org.librecms.ui.contentsections.assets;
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
@ -32,6 +33,7 @@ public class CmsAssetEditSteps implements MvcAssetEditSteps {
|
||||||
final Set<Class<?>> classes = new HashSet<>();
|
final Set<Class<?>> classes = new HashSet<>();
|
||||||
|
|
||||||
classes.add(PostalAddressEditStep.class);
|
classes.add(PostalAddressEditStep.class);
|
||||||
|
classes.add(SideNoteEditStep.class);
|
||||||
|
|
||||||
return classes;
|
return classes;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.librecms.ui.contentsections.assets;
|
package org.librecms.ui.contentsections.assets;
|
||||||
|
|
||||||
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
import org.librecms.contentsection.Asset;
|
import org.librecms.contentsection.Asset;
|
||||||
import org.librecms.contentsection.ContentSection;
|
import org.librecms.contentsection.ContentSection;
|
||||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
|
@ -61,9 +67,20 @@ public interface MvcAssetEditStep {
|
||||||
String getStepPath();
|
String getStepPath();
|
||||||
|
|
||||||
String buildRedirectPathForStep() throws ContentSectionNotFoundException,
|
String buildRedirectPathForStep() throws ContentSectionNotFoundException,
|
||||||
AssetNotFoundException;
|
AssetNotFoundException;
|
||||||
|
|
||||||
String buildRedirectPathForStep(final String subPath)
|
String buildRedirectPathForStep(final String subPath)
|
||||||
throws ContentSectionNotFoundException, AssetNotFoundException;
|
throws ContentSectionNotFoundException, AssetNotFoundException;
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
String showStep(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ package org.librecms.ui.contentsections.assets;
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
import org.libreccm.security.AuthorizationRequired;
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
import org.librecms.assets.PostalAddress;
|
import org.librecms.assets.PostalAddress;
|
||||||
import org.librecms.contentsection.AssetManager;
|
|
||||||
import org.librecms.contentsection.AssetRepository;
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -46,27 +45,12 @@ import javax.transaction.Transactional;
|
||||||
public class PostalAddressCreateStep
|
public class PostalAddressCreateStep
|
||||||
extends AbstractMvcAssetCreateStep<PostalAddress> {
|
extends AbstractMvcAssetCreateStep<PostalAddress> {
|
||||||
|
|
||||||
private static final String FORM_PARAMS_NAME = "name";
|
|
||||||
|
|
||||||
private static final String FORM_PARAMS_TITLE = "title";
|
|
||||||
|
|
||||||
private static final String FORM_PARAM_INITIAL_LOCALE = "locale";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AssetManager assetManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AssetRepository assetRepo;
|
private AssetRepository assetRepo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private GlobalizationHelper globalizationHelper;
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
private String initialLocale;
|
|
||||||
|
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
private String postalCode;
|
private String postalCode;
|
||||||
|
|
@ -82,74 +66,15 @@ public class PostalAddressCreateStep
|
||||||
return "org/librecms/ui/contentsection/assets/postaladdress/create-postaladdress.xhtml";
|
return "org/librecms/ui/contentsection/assets/postaladdress/create-postaladdress.xhtml";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<PostalAddress> getAssetClass() {
|
||||||
|
return PostalAddress.class;
|
||||||
|
}
|
||||||
|
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public String createAsset(final Map<String, String[]> formParams) {
|
protected String setAssetProperties(final PostalAddress postalAddress) {
|
||||||
if (!formParams.containsKey(FORM_PARAMS_NAME)
|
|
||||||
|| formParams.get(FORM_PARAMS_NAME) == null
|
|
||||||
|| formParams.get(FORM_PARAMS_NAME).length == 0) {
|
|
||||||
addMessage(
|
|
||||||
"danger",
|
|
||||||
globalizationHelper
|
|
||||||
.getLocalizedTextsUtil(getBundle())
|
|
||||||
.getText("postaladdress.createstep.name.error.missing")
|
|
||||||
);
|
|
||||||
return showCreateStep();
|
|
||||||
}
|
|
||||||
|
|
||||||
name = formParams.get(FORM_PARAMS_NAME)[0];
|
|
||||||
if (!name.matches("^([a-zA-Z0-9_-]*)$")) {
|
|
||||||
addMessage(
|
|
||||||
"danger",
|
|
||||||
globalizationHelper
|
|
||||||
.getLocalizedTextsUtil(getBundle())
|
|
||||||
.getText("postaladdress.createstep.name.error.invalid")
|
|
||||||
);
|
|
||||||
return showCreateStep();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!formParams.containsKey(FORM_PARAMS_TITLE)
|
|
||||||
|| formParams.get(FORM_PARAMS_TITLE) == null
|
|
||||||
|| formParams.get(FORM_PARAMS_TITLE).length == 0) {
|
|
||||||
addMessage(
|
|
||||||
"danger",
|
|
||||||
globalizationHelper
|
|
||||||
.getLocalizedTextsUtil(getBundle())
|
|
||||||
.getText("postaladdress.createstep.title.error.missing")
|
|
||||||
);
|
|
||||||
return showCreateStep();
|
|
||||||
}
|
|
||||||
title = formParams.get(FORM_PARAMS_TITLE)[0];
|
|
||||||
|
|
||||||
if (!formParams.containsKey(FORM_PARAM_INITIAL_LOCALE)
|
|
||||||
|| formParams.get(FORM_PARAM_INITIAL_LOCALE) == null
|
|
||||||
|| formParams.get(FORM_PARAM_INITIAL_LOCALE).length == 0) {
|
|
||||||
addMessage(
|
|
||||||
"danger",
|
|
||||||
globalizationHelper.getLocalizedTextsUtil(
|
|
||||||
getBundle()
|
|
||||||
).getText("createstep.initial_locale.error.missing")
|
|
||||||
);
|
|
||||||
return showCreateStep();
|
|
||||||
}
|
|
||||||
initialLocale = formParams.get(FORM_PARAM_INITIAL_LOCALE)[0];
|
|
||||||
final Locale locale = new Locale(initialLocale);
|
|
||||||
|
|
||||||
address = formParams.get("address")[0];
|
|
||||||
postalCode = formParams.get("postalCode")[0];
|
|
||||||
city = formParams.get("city")[0];
|
|
||||||
state = formParams.get("state")[0];
|
|
||||||
isoCountryCode = formParams.get("isoCountryCode")[0];
|
|
||||||
|
|
||||||
final PostalAddress postalAddress = assetManager.createAsset(
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
locale,
|
|
||||||
getFolder(),
|
|
||||||
PostalAddress.class
|
|
||||||
);
|
|
||||||
|
|
||||||
postalAddress.setAddress(address);
|
postalAddress.setAddress(address);
|
||||||
postalAddress.setPostalCode(postalCode);
|
postalAddress.setPostalCode(postalCode);
|
||||||
postalAddress.setCity(city);
|
postalAddress.setCity(city);
|
||||||
|
|
@ -162,7 +87,7 @@ public class PostalAddressCreateStep
|
||||||
"redirect:/%s/assets/%s/%s/@postaladdress-edit",
|
"redirect:/%s/assets/%s/%s/@postaladdress-edit",
|
||||||
getContentSectionLabel(),
|
getContentSectionLabel(),
|
||||||
getFolderPath(),
|
getFolderPath(),
|
||||||
name
|
getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -190,18 +115,6 @@ public class PostalAddressCreateStep
|
||||||
return MvcAssetStepsConstants.BUNDLE;
|
return MvcAssetStepsConstants.BUNDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInitialLocale() {
|
|
||||||
return initialLocale;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
@ -230,6 +143,7 @@ public class PostalAddressCreateStep
|
||||||
|
|
||||||
final Map<String, String> countriesMap = countries
|
final Map<String, String> countriesMap = countries
|
||||||
.stream()
|
.stream()
|
||||||
|
.sorted(this::sortCountries)
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.toMap(
|
Collectors.toMap(
|
||||||
Locale::getCountry,
|
Locale::getCountry,
|
||||||
|
|
@ -248,4 +162,12 @@ public class PostalAddressCreateStep
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int sortCountries(final Locale locale1, final Locale locale2) {
|
||||||
|
final Locale negotiated = globalizationHelper.getNegotiatedLocale();
|
||||||
|
final String country1 = locale1.getDisplayCountry(negotiated);
|
||||||
|
final String country2 = locale2.getDisplayCountry(negotiated);
|
||||||
|
|
||||||
|
return country1.compareTo(country2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -43,7 +42,6 @@ import javax.inject.Named;
|
||||||
import javax.mvc.Controller;
|
import javax.mvc.Controller;
|
||||||
import javax.mvc.Models;
|
import javax.mvc.Models;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import javax.ws.rs.DefaultValue;
|
|
||||||
import javax.ws.rs.FormParam;
|
import javax.ws.rs.FormParam;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
|
|
@ -69,18 +67,12 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
@Inject
|
@Inject
|
||||||
private AssetStepsDefaultMessagesBundle messageBundle;
|
private AssetStepsDefaultMessagesBundle messageBundle;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AssetManager assetManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AssetUi assetUi;
|
private AssetUi assetUi;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AssetRepository assetRepo;
|
private AssetRepository assetRepo;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private FolderManager folderManager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private GlobalizationHelper globalizationHelper;
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
|
@ -90,10 +82,6 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
@Inject
|
@Inject
|
||||||
private Models models;
|
private Models models;
|
||||||
|
|
||||||
private Map<String, String> titleValues;
|
|
||||||
|
|
||||||
private List<String> unusedTitleLocales;
|
|
||||||
|
|
||||||
private Map<String, String> countries;
|
private Map<String, String> countries;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -101,6 +89,14 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
return PostalAddressEditStep.class;
|
return PostalAddressEditStep.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int sortCountries(final Locale locale1, final Locale locale2) {
|
||||||
|
final Locale negotiated = globalizationHelper.getNegotiatedLocale();
|
||||||
|
final String country1 = locale1.getDisplayCountry(negotiated);
|
||||||
|
final String country2 = locale2.getDisplayCountry(negotiated);
|
||||||
|
|
||||||
|
return country1.compareTo(country2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() throws ContentSectionNotFoundException,
|
protected void init() throws ContentSectionNotFoundException,
|
||||||
AssetNotFoundException {
|
AssetNotFoundException {
|
||||||
|
|
@ -113,6 +109,7 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
|
|
||||||
final Map<String, String> countriesMap = countryLocales
|
final Map<String, String> countriesMap = countryLocales
|
||||||
.stream()
|
.stream()
|
||||||
|
.sorted(this::sortCountries)
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.toMap(
|
Collectors.toMap(
|
||||||
Locale::getCountry,
|
Locale::getCountry,
|
||||||
|
|
@ -133,6 +130,7 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@Override
|
||||||
public String showStep(
|
public String showStep(
|
||||||
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
final String sectionIdentifier,
|
final String sectionIdentifier,
|
||||||
|
|
@ -148,29 +146,6 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
titleValues = getAsset()
|
|
||||||
.getTitle()
|
|
||||||
.getValues()
|
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.collect(
|
|
||||||
Collectors.toMap(
|
|
||||||
entry -> entry.getKey().toString(),
|
|
||||||
entry -> entry.getValue()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
final Set<Locale> titleLocales = getAsset()
|
|
||||||
.getTitle()
|
|
||||||
.getAvailableLocales();
|
|
||||||
|
|
||||||
unusedTitleLocales = globalizationHelper
|
|
||||||
.getAvailableLocales()
|
|
||||||
.stream()
|
|
||||||
.filter(locale -> !titleLocales.contains(locale))
|
|
||||||
.map(Locale::toString)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
return "org/librecms/ui/contentsection/assets/postaladdress/edit-postaladdress.xhtml";
|
return "org/librecms/ui/contentsection/assets/postaladdress/edit-postaladdress.xhtml";
|
||||||
} else {
|
} else {
|
||||||
return assetUi.showAccessDenied(
|
return assetUi.showAccessDenied(
|
||||||
|
|
@ -179,164 +154,15 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
messageBundle.get("asset.edit.denied"));
|
messageBundle.get("asset.edit.denied"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
public String getName() {
|
// public String getName() {
|
||||||
return getAsset().getDisplayName();
|
// return getAsset().getDisplayName();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public PostalAddress getPostalAddress() {
|
public PostalAddress getPostalAddress() {
|
||||||
return (PostalAddress) getAsset();
|
return (PostalAddress) getAsset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/name")
|
|
||||||
@AuthorizationRequired
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
public String updateName(
|
|
||||||
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
|
||||||
final String sectionIdentifier,
|
|
||||||
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
|
||||||
final String assetPath,
|
|
||||||
@FormParam("name") @DefaultValue("") final String name
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
init();
|
|
||||||
} catch (ContentSectionNotFoundException ex) {
|
|
||||||
return ex.showErrorMessage();
|
|
||||||
} catch (AssetNotFoundException ex) {
|
|
||||||
return ex.showErrorMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
|
||||||
if (name.isEmpty() || name.matches("\\s*")) {
|
|
||||||
models.put("nameMissing", true);
|
|
||||||
|
|
||||||
return showStep(sectionIdentifier, assetPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAsset().setDisplayName(name);
|
|
||||||
assetRepo.save(getAsset());
|
|
||||||
|
|
||||||
updateAssetPath();
|
|
||||||
|
|
||||||
return buildRedirectPathForStep();
|
|
||||||
} else {
|
|
||||||
return assetUi.showAccessDenied(
|
|
||||||
getContentSection(),
|
|
||||||
getAsset(),
|
|
||||||
messageBundle.get("asset.edit.denied"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> getTitleValues() {
|
|
||||||
return Collections.unmodifiableMap(titleValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getUnusedTitleLocales() {
|
|
||||||
return Collections.unmodifiableList(unusedTitleLocales);
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/title/@add")
|
|
||||||
@AuthorizationRequired
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
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
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
init();
|
|
||||||
} catch (ContentSectionNotFoundException ex) {
|
|
||||||
return ex.showErrorMessage();
|
|
||||||
} catch (AssetNotFoundException ex) {
|
|
||||||
return ex.showErrorMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
|
||||||
final Locale locale = new Locale(localeParam);
|
|
||||||
getAsset().getTitle().addValue(locale, value);
|
|
||||||
assetRepo.save(getAsset());
|
|
||||||
|
|
||||||
return buildRedirectPathForStep();
|
|
||||||
} else {
|
|
||||||
return assetUi.showAccessDenied(
|
|
||||||
getContentSection(),
|
|
||||||
getAsset(),
|
|
||||||
messageBundle.get("asset.edit.denied"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/title/@edit/{locale}")
|
|
||||||
@AuthorizationRequired
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
|
||||||
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,
|
|
||||||
@PathParam("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);
|
|
||||||
getAsset().getTitle().addValue(locale, value);
|
|
||||||
assetRepo.save(getAsset());
|
|
||||||
|
|
||||||
return buildRedirectPathForStep();
|
|
||||||
} else {
|
|
||||||
return assetUi.showAccessDenied(
|
|
||||||
getContentSection(),
|
|
||||||
getAsset(),
|
|
||||||
messageBundle.get("asset.edit.denied"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
init();
|
|
||||||
} catch (ContentSectionNotFoundException ex) {
|
|
||||||
return ex.showErrorMessage();
|
|
||||||
} catch (AssetNotFoundException ex) {
|
|
||||||
return ex.showErrorMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
|
||||||
final Locale locale = new Locale(localeParam);
|
|
||||||
getAsset().getTitle().removeValue(locale);
|
|
||||||
assetRepo.save(getAsset());
|
|
||||||
|
|
||||||
return buildRedirectPathForStep();
|
|
||||||
} else {
|
|
||||||
return assetUi.showAccessDenied(
|
|
||||||
getContentSection(),
|
|
||||||
getAsset(),
|
|
||||||
messageBundle.get("asset.edit.denied"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return getPostalAddress().getAddress();
|
return getPostalAddress().getAddress();
|
||||||
}
|
}
|
||||||
|
|
@ -358,8 +184,12 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCountry() {
|
public String getCountry() {
|
||||||
return new Locale("", getPostalAddress().getIsoCountryCode())
|
if (getPostalAddress().getIsoCountryCode() == null) {
|
||||||
.getDisplayCountry(globalizationHelper.getNegotiatedLocale());
|
return "";
|
||||||
|
} else {
|
||||||
|
return new Locale("", getPostalAddress().getIsoCountryCode())
|
||||||
|
.getDisplayCountry(globalizationHelper.getNegotiatedLocale());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
|
|
@ -405,7 +235,9 @@ public class PostalAddressEditStep extends AbstractMvcAssetEditStep {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getCountries() {
|
public Map<String, String> getCountries() {
|
||||||
return countries;
|
final LinkedHashMap<String, String> result = new LinkedHashMap<>();
|
||||||
|
result.putAll(countries);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.ui.contentsections.assets;
|
||||||
|
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
|
import org.librecms.assets.SideNote;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
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("CmsSideNoteCreateStep")
|
||||||
|
public class SideNoteCreateStep extends AbstractMvcAssetCreateStep<SideNote> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String showCreateStep() {
|
||||||
|
return "org/librecms/ui/contentsection/assets/sidenote/create-sidenote.xhtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("side_note.label");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("side_note.description");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBundle() {
|
||||||
|
return MvcAssetStepsConstants.BUNDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<SideNote> getAssetClass() {
|
||||||
|
return SideNote.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
@Override
|
||||||
|
public String setAssetProperties(final SideNote sideNote) {
|
||||||
|
sideNote.getText().addValue(new Locale(getInitialLocale()), text);
|
||||||
|
assetRepo.save(sideNote);
|
||||||
|
|
||||||
|
return String.format(
|
||||||
|
"redirect:/%s/assets/%s/%s/@sidenote-edit",
|
||||||
|
getContentSectionLabel(),
|
||||||
|
getFolderPath(),
|
||||||
|
name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,282 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.ui.contentsections.assets;
|
||||||
|
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
|
import org.librecms.assets.SideNote;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
import org.librecms.ui.contentsections.AssetPermissionsChecker;
|
||||||
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
|
import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
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.inject.Named;
|
||||||
|
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 + "sidenote-edit")
|
||||||
|
@Controller
|
||||||
|
@Named("CmsSideNoteEditStep")
|
||||||
|
@MvcAssetEditStepDef(
|
||||||
|
bundle = MvcAssetStepsConstants.BUNDLE,
|
||||||
|
descriptionKey = "postaladdress.editstep.description",
|
||||||
|
labelKey = "postaladdress.editstep.label",
|
||||||
|
supportedAssetType = SideNote.class
|
||||||
|
)
|
||||||
|
public class SideNoteEditStep extends AbstractMvcAssetEditStep {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetStepsDefaultMessagesBundle messageBundle;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetUi assetUi;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetPermissionsChecker assetPermissionsChecker;
|
||||||
|
|
||||||
|
private Map<String, String> textValues;
|
||||||
|
|
||||||
|
private List<CmsEditorLocaleVariantRow> variants;
|
||||||
|
|
||||||
|
private List<String> unusedTextLocales;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends MvcAssetEditStep> getStepClass() {
|
||||||
|
return SideNoteEditStep.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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())) {
|
||||||
|
textValues = getSideNote()
|
||||||
|
.getText()
|
||||||
|
.getValues()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(
|
||||||
|
entry -> entry.getKey().toString(),
|
||||||
|
entry -> entry.getValue()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Set<Locale> textLocales = getSideNote()
|
||||||
|
.getText()
|
||||||
|
.getAvailableLocales();
|
||||||
|
unusedTextLocales = globalizationHelper
|
||||||
|
.getAvailableLocales()
|
||||||
|
.stream()
|
||||||
|
.filter(locale -> !textLocales.contains(locale))
|
||||||
|
.map(Locale::toString)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
variants = getSideNote()
|
||||||
|
.getText()
|
||||||
|
.getValues()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.map(this::buildVariantRow)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
return "org/librecms/ui/contentsection/assets/sidenote/edit-sidenote.xhtml";
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SideNote getSideNote() {
|
||||||
|
return (SideNote) getAsset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getTextValues() {
|
||||||
|
return Collections.unmodifiableMap(textValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CmsEditorLocaleVariantRow> getVariants() {
|
||||||
|
return Collections.unmodifiableList(variants);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUnusedTextLocales() {
|
||||||
|
return Collections.unmodifiableList(unusedTextLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/text/add")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String addText(
|
||||||
|
@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);
|
||||||
|
getSideNote().getText().addValue(locale, value);
|
||||||
|
assetRepo.save(getSideNote());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/text/edit/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String editText(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@PathParam("locale") final String localeParam,
|
||||||
|
@PathParam("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);
|
||||||
|
getSideNote().getText().addValue(locale, value);
|
||||||
|
assetRepo.save(getSideNote());
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/text/remove/{locale}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String removeText(
|
||||||
|
@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);
|
||||||
|
getSideNote().getText().removeValue(locale);
|
||||||
|
assetRepo.save(getSideNote());
|
||||||
|
|
||||||
|
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());
|
||||||
|
final Document document = Jsoup.parseBodyFragment(entry.getValue());
|
||||||
|
variant.setWordCount(
|
||||||
|
new StringTokenizer(document.body().text()).countTokens()
|
||||||
|
);
|
||||||
|
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
<!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>#{CmsAssetsStepsDefaultMessagesBundle["sidenote.createform.title"]}</h1>
|
||||||
|
|
||||||
|
<c:forEach items="#{CmsSideNoteCreateStep.messages.entrySet()}"
|
||||||
|
var="message">
|
||||||
|
<div class="alert alert-#{message.key}" role="alert">
|
||||||
|
#{message.value}
|
||||||
|
</div>
|
||||||
|
</c:forEach>
|
||||||
|
|
||||||
|
<form action="#{mvc.basePath}/#{CmsSideNoteCreateStep.contentSectionLabel}/assets/#{CmsSideNoteCreateStep.folderPath}@create/#{CmsSideNoteCreateStep.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="#{CmsSideNoteCreateStep.name}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupSelect
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.initial_locale.help']}"
|
||||||
|
inputId="locale"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.initial_locale.label']}"
|
||||||
|
name="locale"
|
||||||
|
options="#{CmsSideNoteCreateStep.availableLocales}"
|
||||||
|
required="true"
|
||||||
|
selectedOptions="#{[CmsSideNoteCreate.initialLocale]}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupText
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.title.help']}"
|
||||||
|
inputId="title"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.title.label']}"
|
||||||
|
name="title"
|
||||||
|
required="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<a class="btn btn-warning"
|
||||||
|
href="#{mvc.basePath}/#{CmsSideNoteCreateStep.contentSectionLabel}/assetfolders/#{CmsSideNoteCreateStep.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,138 @@
|
||||||
|
<!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:librecms="http://xmlns.jcp.org/jsf/composite/components/librecms"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||||
|
|
||||||
|
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/assets/editstep.xhtml">
|
||||||
|
|
||||||
|
<ui:define name="editStep">
|
||||||
|
<div class="container">
|
||||||
|
<h2>#{CmsAssetsStepsDefaultMessagesBundle.getMessage('sidenote.editstep.header', [CmsSideNoteEditStep.name])}</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>#{CmsAssetsStepsDefaultMessagesBundle['editstep.name.header']}</h3>
|
||||||
|
<div class="d-flex">
|
||||||
|
<pre class="mr-2">#{CmsSideNoteEditStep.name}</pre>
|
||||||
|
<c:if test="#{CmsSideNoteEditStep.canEdit}">
|
||||||
|
<button class="btn btn-primary btn-sm"
|
||||||
|
data-toggle="modal"
|
||||||
|
data-target="#name-edit-dialog"
|
||||||
|
type="button">
|
||||||
|
<bootstrap:svgIcon icon="pen" />
|
||||||
|
<span class="sr-only">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['editstep.name.edit']}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</c:if>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<c:if test="#{CmsSideNoteEditStep.canEdit}">
|
||||||
|
<div aria-hidden="true"
|
||||||
|
aria-labelledby="name-edit-dialog-title"
|
||||||
|
class="modal fade"
|
||||||
|
id="name-edit-dialog"
|
||||||
|
tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@sidenote-edit/name"
|
||||||
|
class="modal-content"
|
||||||
|
method="post">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title"
|
||||||
|
id="name-edit-dialog-title">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['editstep.name.edit.title']}
|
||||||
|
</h4>
|
||||||
|
<button aria-label="#{CmsAssetsStepsDefaultMessagesBundle['editstep.name.edit.close']}"
|
||||||
|
class="close"
|
||||||
|
data-dismiss="modal"
|
||||||
|
type="button">
|
||||||
|
<bootstrap:svgIcon icon="x" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<bootstrap:formGroupText
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['editstep.name.help']}"
|
||||||
|
inputId="name"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['editstep.name.label']}"
|
||||||
|
name="name"
|
||||||
|
pattern="^([a-zA-Z0-9_-]*)$"
|
||||||
|
required="true"
|
||||||
|
value="#{CmsSideNoteEditStep.name}"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-warning"
|
||||||
|
data-dismiss="modal"
|
||||||
|
type="button">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['editstep.name.close']}
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-success"
|
||||||
|
type="submit">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['editstep.name.submit']}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</c:if>
|
||||||
|
|
||||||
|
<libreccm:localizedStringEditor
|
||||||
|
addButtonLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.add_button.label']}"
|
||||||
|
addDialogCancelLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.add.cancel']}"
|
||||||
|
addDialogLocaleSelectHelp="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.add.locale.help']}"
|
||||||
|
addDialogLocaleSelectLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.add.locale.label']}"
|
||||||
|
addDialogSubmitLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.add.submit']}"
|
||||||
|
addDialogTitle="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.add.header']}"
|
||||||
|
addDialogValueHelp="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.add.value.help']}"
|
||||||
|
addDialogValueLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.add.value.label']}"
|
||||||
|
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@sidenote-edit/title/@add"
|
||||||
|
editButtonLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.edit']}"
|
||||||
|
editDialogCancelLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.edit.cancel']}"
|
||||||
|
editDialogSubmitLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.edit.submit']}"
|
||||||
|
editDialogTitle="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.edit.header']}"
|
||||||
|
editDialogValueHelp="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.edit.value.help']}"
|
||||||
|
editDialogValueLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.edit.value.label']}"
|
||||||
|
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@sidenote-edit/title/@edit"
|
||||||
|
editorId="title-editor"
|
||||||
|
hasUnusedLocales="#{!CmsSideNoteEditStep.unusedTitleLocales.isEmpty()}"
|
||||||
|
headingLevel="3"
|
||||||
|
objectIdentifier="#{CmsSelectedAssetModel.assetPath}"
|
||||||
|
readOnly="#{!CmsSideNoteEditStep.canEdit}"
|
||||||
|
removeButtonLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.remove']}"
|
||||||
|
removeDialogCancelLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.remove.cancel']}"
|
||||||
|
removeDialogSubmitLabel="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.remove.submit']}"
|
||||||
|
removeDialogText="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.remove.text']}"
|
||||||
|
removeDialogTitle="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.remove.title']}"
|
||||||
|
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@sidenote-edit/title/@remove"
|
||||||
|
title="#{CmsAssetsStepsDefaultMessagesBundle['editstep.title.header']}"
|
||||||
|
unusedLocales="#{CmsSideNoteEditStep.unusedTitleLocales}"
|
||||||
|
values="#{CmsSideNoteEditStep.titleValues}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<h3>#{CmsAssetsStepsDefaultMessagesBundle['sidenote.editstep.text.header']}</h3>
|
||||||
|
|
||||||
|
<c:if test="#{CmsPostalAddressEditStep.canEdit}">
|
||||||
|
<librecms:cmsEditor addButtonLabel="#{CmsAssetsStepsDefaultMessagesBundle['sidenote.sidenote.text.editor.add_variant']}"
|
||||||
|
addDialogLocaleSelectHelp="#{CmsAdminMessages['sidenote.text.editor.add.locale.help']}"
|
||||||
|
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSideNoteEditStep.assetPath}/@edit-sidenote/text/add"
|
||||||
|
editDialogValueHelp="#{CmsAdminMessages['sidenote.text.editor.edit.value.help']}"
|
||||||
|
editDialogValueLabel="#{CmsAdminMessages['sidenote.text.editor.edit.value.label']}"
|
||||||
|
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSideNoteEditStep.assetPath}/@edit-sidenote/text/edit"
|
||||||
|
editorId="sidenote-text-editor"
|
||||||
|
hasUnusedLocales="#{!CmsSideNoteEditStep.unusedTextLocales.isEmpty()}"
|
||||||
|
headingLevel="3"
|
||||||
|
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
|
||||||
|
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSideNoteEditStep.assetPath}/@edit-sidenote/text/remove"
|
||||||
|
title="#{CmsAssetsStepsDefaultMessagesBundle['sidenote.text.editor.header']}"
|
||||||
|
unusedLocales="#{CmsArticleTextBodyStep.unusedLocales}"
|
||||||
|
variantUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSideNoteEditStep.assetPath}/@edit-sidenote/text/variants"
|
||||||
|
variants="#{CmsSideNoteEditStep.variants}"
|
||||||
|
wordCountUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSideNoteEditStep.assetPath}/@edit-sidenote/text/variants/wordcount"
|
||||||
|
/>
|
||||||
|
</c:if>
|
||||||
|
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
|
|
@ -65,3 +65,7 @@ postaladdress.editstep.properties.country.label=Country
|
||||||
postaladdress.editstep.properties.edit.submit=Save
|
postaladdress.editstep.properties.edit.submit=Save
|
||||||
postal_address.label=Postal address
|
postal_address.label=Postal address
|
||||||
editstep.name.close=Cancel
|
editstep.name.close=Cancel
|
||||||
|
postal_address.description=A postal address.
|
||||||
|
side_note.label=Side Note
|
||||||
|
side_note.description=A side note.
|
||||||
|
sidenote.createform.title=Create a new side note
|
||||||
|
|
|
||||||
|
|
@ -65,3 +65,7 @@ postaladdress.editstep.properties.country.label=Land
|
||||||
postaladdress.editstep.properties.edit.submit=Speichern
|
postaladdress.editstep.properties.edit.submit=Speichern
|
||||||
postal_address.label=Postanschrift
|
postal_address.label=Postanschrift
|
||||||
editstep.name.close=Abbrechen
|
editstep.name.close=Abbrechen
|
||||||
|
postal_address.description=Eine Postanschrift.
|
||||||
|
side_note.label=Randbemerkung
|
||||||
|
side_note.description=Eine Randbemerkung.
|
||||||
|
sidenote.createform.title=Eine neue Randbemerkungen anlegen
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue