UI for bookmark assets
parent
050beb3efb
commit
c8bf618eb1
|
|
@ -34,8 +34,12 @@ import javax.persistence.JoinTable;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import org.libreccm.l10n.LocalizedString;
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
import org.librecms.ui.contentsections.assets.BookmarkCreateStep;
|
||||||
|
import org.librecms.ui.contentsections.assets.BookmarkEditStep;
|
||||||
|
import org.librecms.ui.contentsections.assets.MvcAssetEditKit;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
import static org.librecms.assets.AssetConstants.*;
|
import static org.librecms.assets.AssetConstants.*;
|
||||||
|
|
@ -54,6 +58,10 @@ import static org.librecms.assets.AssetConstants.*;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "BOOKMARKS", schema = DB_SCHEMA)
|
@Table(name = "BOOKMARKS", schema = DB_SCHEMA)
|
||||||
@Audited
|
@Audited
|
||||||
|
@MvcAssetEditKit(
|
||||||
|
createStep = BookmarkCreateStep.class,
|
||||||
|
editStep = BookmarkEditStep.class
|
||||||
|
)
|
||||||
public class Bookmark extends Asset implements Serializable {
|
public class Bookmark extends Asset implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2077380735104791483L;
|
private static final long serialVersionUID = -2077380735104791483L;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* 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.librecms.assets.Bookmark;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Named("CmsBookmarkCreateStep")
|
||||||
|
public class BookmarkCreateStep extends AbstractMvcAssetCreateStep<Bookmark> {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepository;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
private String bookmarkDescription;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String showCreateStep() {
|
||||||
|
return "org/librecms/ui/contentsection/assets/bookmark/create-bookmark.xhtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("bookmark.label");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("bookmark.description");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBundle() {
|
||||||
|
return MvcAssetStepsConstants.BUNDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBookmarkDescription() {
|
||||||
|
return bookmarkDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<Bookmark> getAssetClass() {
|
||||||
|
return Bookmark.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String setAssetProperties(
|
||||||
|
final Bookmark bookmark, final Map<String, String[]> formParams
|
||||||
|
) {
|
||||||
|
url = Optional
|
||||||
|
.ofNullable(formParams.get("url"))
|
||||||
|
.filter(value -> value.length > 0)
|
||||||
|
.map(value -> value[0])
|
||||||
|
.orElse("");
|
||||||
|
bookmarkDescription = Optional
|
||||||
|
.ofNullable(formParams.get("description"))
|
||||||
|
.filter(value -> value.length > 0)
|
||||||
|
.map(value -> value[0])
|
||||||
|
.orElse("");
|
||||||
|
|
||||||
|
if (url.isEmpty() || url.matches("\\s*")) {
|
||||||
|
addMessage(
|
||||||
|
"warning",
|
||||||
|
globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(getBundle())
|
||||||
|
.getText("bookmark.create.url.missing")
|
||||||
|
);
|
||||||
|
return showCreateStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
bookmark.setUrl(url);
|
||||||
|
bookmark
|
||||||
|
.getDescription()
|
||||||
|
.addValue(new Locale(getInitialLocale()), bookmarkDescription);
|
||||||
|
assetRepository.save(bookmark);
|
||||||
|
|
||||||
|
return String.format(
|
||||||
|
"redirect:/%s/assets/%s/%s/@bookmark-edit",
|
||||||
|
getContentSectionLabel(),
|
||||||
|
getFolderPath(),
|
||||||
|
getName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,301 @@
|
||||||
|
/*
|
||||||
|
* 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.Bookmark;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
|
import org.librecms.ui.contentsections.AssetPermissionsChecker;
|
||||||
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.mvc.Controller;
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
import javax.ws.rs.FormParam;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
@Path(MvcAssetEditSteps.PATH_PREFIX + "bookmark-edit")
|
||||||
|
@Controller
|
||||||
|
@MvcAssetEditStepDef(
|
||||||
|
bundle = MvcAssetStepsConstants.BUNDLE,
|
||||||
|
descriptionKey = "bookmark.editstep.description",
|
||||||
|
labelKey = "bookmark.editstep.label",
|
||||||
|
supportedAssetType = Bookmark.class
|
||||||
|
)
|
||||||
|
public class BookmarkEditStep extends AbstractMvcAssetEditStep {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetStepsDefaultMessagesBundle messageBundle;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetUi assetUi;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepository;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetPermissionsChecker assetPermissionsChecker;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BookmarkEditStepModel bookmarkEditStepModel;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends MvcAssetEditStep> getStepClass() {
|
||||||
|
return BookmarkEditStep.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() throws ContentSectionNotFoundException,
|
||||||
|
AssetNotFoundException {
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
if (getAsset() instanceof Bookmark) {
|
||||||
|
bookmarkEditStepModel.setUrl(getBookmark().getUrl());
|
||||||
|
|
||||||
|
bookmarkEditStepModel.setDescriptionValues(
|
||||||
|
getBookmark()
|
||||||
|
.getDescription()
|
||||||
|
.getValues()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(
|
||||||
|
entry -> entry.getKey().toString(),
|
||||||
|
entry -> entry.getValue()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
final Set<Locale> descriptionLocales = getBookmark()
|
||||||
|
.getDescription()
|
||||||
|
.getAvailableLocales();
|
||||||
|
bookmarkEditStepModel.setUnusedDescriptionLocales(
|
||||||
|
globalizationHelper
|
||||||
|
.getAvailableLocales()
|
||||||
|
.stream()
|
||||||
|
.filter(locale -> !descriptionLocales.contains(locale))
|
||||||
|
.map(Locale::toString)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new AssetNotFoundException(
|
||||||
|
assetUi.showAssetNotFound(
|
||||||
|
getContentSection(), getAssetPath()
|
||||||
|
),
|
||||||
|
String.format(
|
||||||
|
"No asset for path %s found in section %s.",
|
||||||
|
getAssetPath(),
|
||||||
|
getContentSection().getLabel()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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/librecms/ui/contentsection/bookmark/bookmark/edit-bookmark.xhtml";
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bookmark getBookmark() {
|
||||||
|
return (Bookmark) getAsset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/properties")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String updateProperties(
|
||||||
|
@PathParam(MvcAssetEditSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||||
|
final String sectionIdentifier,
|
||||||
|
@PathParam(MvcAssetEditSteps.ASSET_PATH_PATH_PARAM_NAME)
|
||||||
|
final String assetPath,
|
||||||
|
@FormParam("url") final String url
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
init();
|
||||||
|
} catch (ContentSectionNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
} catch (AssetNotFoundException ex) {
|
||||||
|
return ex.showErrorMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetPermissionsChecker.canEditAsset(getAsset())) {
|
||||||
|
final Bookmark bookmark = getBookmark();
|
||||||
|
bookmark.setUrl(url);
|
||||||
|
|
||||||
|
assetRepository.save(bookmark);
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/description/add")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
public String addDescription(
|
||||||
|
@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);
|
||||||
|
final Bookmark bookmark = getBookmark();
|
||||||
|
bookmark.getDescription().addValue(locale, value);
|
||||||
|
|
||||||
|
assetRepository.save(bookmark);
|
||||||
|
|
||||||
|
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 editDescription(
|
||||||
|
@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);
|
||||||
|
final Bookmark bookmark = getBookmark();
|
||||||
|
bookmark.getDescription().addValue(locale, value);
|
||||||
|
|
||||||
|
assetRepository.save(bookmark);
|
||||||
|
|
||||||
|
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 removeDescription(
|
||||||
|
@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);
|
||||||
|
final Bookmark bookmark = getBookmark();
|
||||||
|
bookmark.getDescription().removeValue(locale);
|
||||||
|
|
||||||
|
assetRepository.save(bookmark);
|
||||||
|
|
||||||
|
return buildRedirectPathForStep();
|
||||||
|
} else {
|
||||||
|
return assetUi.showAccessDenied(
|
||||||
|
getContentSection(),
|
||||||
|
getAsset(),
|
||||||
|
messageBundle.get("asset.edit.denied"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* 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 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("CmsBookmarkEditStep")
|
||||||
|
public class BookmarkEditStepModel {
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private Map<String, String> descriptionValues;
|
||||||
|
|
||||||
|
private List<String> unusedDescriptionLocales;
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUrl(final String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getDescriptionValues() {
|
||||||
|
return Collections.unmodifiableMap(descriptionValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDescriptionValues(
|
||||||
|
final Map<String, String> descriptionValues
|
||||||
|
) {
|
||||||
|
this.descriptionValues = new HashMap<>(descriptionValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUnusedDescriptionLocales() {
|
||||||
|
return Collections.unmodifiableList(unusedDescriptionLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUnusedDescriptionLocales(
|
||||||
|
final List<String> unusedDescriptionLocales
|
||||||
|
) {
|
||||||
|
this.unusedDescriptionLocales = new ArrayList<>(
|
||||||
|
unusedDescriptionLocales
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -31,6 +31,7 @@ public class CmsAssetEditSteps implements MvcAssetEditSteps {
|
||||||
public Set<Class<?>> getClasses() {
|
public Set<Class<?>> getClasses() {
|
||||||
final Set<Class<?>> classes = new HashSet<>();
|
final Set<Class<?>> classes = new HashSet<>();
|
||||||
|
|
||||||
|
classes.add(BookmarkEditStep.class);
|
||||||
classes.add(LegalMetadataEditStep.class);
|
classes.add(LegalMetadataEditStep.class);
|
||||||
classes.add(PostalAddressEditStep.class);
|
classes.add(PostalAddressEditStep.class);
|
||||||
classes.add(SideNoteEditStep.class);
|
classes.add(SideNoteEditStep.class);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
<!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["bookmark.createform.title"]}</h1>
|
||||||
|
|
||||||
|
<c:forEach items="#{CmsBookmarkCreateStep.messages.entrySet()}"
|
||||||
|
var="message">
|
||||||
|
<div class="alert alert-#{message.key}" role="alert">
|
||||||
|
#{message.value}
|
||||||
|
</div>
|
||||||
|
</c:forEach>
|
||||||
|
|
||||||
|
<form action="#{mvc.basePath}/#{CmsBookmarkCreateStep.contentSectionLabel}/assets/#{CmsBookmarkCreateStep.folderPath}@create/#{CmsBookmarkCreateStep.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="#{CmsBookmarkCreateStep.name}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupSelect
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.initial_locale.help']}"
|
||||||
|
inputId="locale"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.initial_locale.label']}"
|
||||||
|
name="locale"
|
||||||
|
options="#{CmsBookmarkCreateStep.availableLocales}"
|
||||||
|
required="true"
|
||||||
|
selectedOptions="#{[CmsBookmarkCreateStep.initialLocale]}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupText
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.title.help']}"
|
||||||
|
inputId="title"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.title.label']}"
|
||||||
|
name="title"
|
||||||
|
required="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupUrl
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.bookmark.url.help']}"
|
||||||
|
inputId="url"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.bookmark.url.label']}"
|
||||||
|
name="url"
|
||||||
|
required="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<bootstrap:formGroupTextarea
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['createform.bookmark.description.help']}"
|
||||||
|
inputId="description"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['createform.bookmark.description.label']}"
|
||||||
|
name="description"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<a class="btn btn-warning"
|
||||||
|
href="#{mvc.basePath}/#{CmsBookmarkCreateStep.contentSectionLabel}/assetfolders/#{CmsBookmarkCreateStep.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,116 @@
|
||||||
|
<!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="@bookmark-edit"
|
||||||
|
/>
|
||||||
|
<ui:param name="title"
|
||||||
|
value="#{CmsAssetsStepsDefaultMessagesBundle.getMessage('bookmark.editstep.header', [MvcAssetEditStepModel.name])}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ui:define name="editStep">
|
||||||
|
<h3>#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.url.header']}</h3>
|
||||||
|
|
||||||
|
<c:if test="#{MvcAssetEditStepModel.canEdit}">
|
||||||
|
<div class="text-right">
|
||||||
|
<button class="btn btn-primary"
|
||||||
|
data-toggle="modal"
|
||||||
|
data-target="#url-edit-dialog"
|
||||||
|
type="button">
|
||||||
|
<bootstrap:svgIcon icon="pen" />
|
||||||
|
<span class="sr-only">#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.url.edit']}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div aria-hidden="true"
|
||||||
|
aria-labelledby="url-edit-dialog-title"
|
||||||
|
class="modal fade"
|
||||||
|
id="url-edit-dialog"
|
||||||
|
tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@bookmark-edit/properties"
|
||||||
|
class="modal-content"
|
||||||
|
method="post">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title"
|
||||||
|
id="url-edit-dialog-title">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.url.edit.title']}
|
||||||
|
</h4>
|
||||||
|
<button
|
||||||
|
aria-label="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.url.edit.close']}"
|
||||||
|
class="close"
|
||||||
|
data-dismiss="modal"
|
||||||
|
type="button">
|
||||||
|
<bootstrap:svgIcon icon="x" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<bootstrap:formGroupUrl
|
||||||
|
help="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.url.edit.help']}"
|
||||||
|
inputId="url"
|
||||||
|
label="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.url.edit.label']}"
|
||||||
|
name="url"
|
||||||
|
required="true"
|
||||||
|
value="#{CmsBookmarkEditStep.url}"/>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-warning"
|
||||||
|
data-dismiss="modal"
|
||||||
|
type="button">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.url.edit.close']}
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-success"
|
||||||
|
type="submit">
|
||||||
|
#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.url.edit.submit']}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</c:if>
|
||||||
|
<pre>#{CmsBookmarkEditStep.url}</pre>
|
||||||
|
|
||||||
|
<libreccm:localizedStringEditor
|
||||||
|
addButtonLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.add_button.label']}"
|
||||||
|
addDialogCancelLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.add.cancel']}"
|
||||||
|
addDialogLocaleSelectHelp="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.add.locale.help']}"
|
||||||
|
addDialogLocaleSelectLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.add.locale.label']}"
|
||||||
|
addDialogSubmitLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.add.submit']}"
|
||||||
|
addDialogTitle="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.add.title']}"
|
||||||
|
addDialogValueHelp="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.add.value.help']}"
|
||||||
|
addDialogValueLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.add.value.label']}"
|
||||||
|
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@bookmark-edit/description/add"
|
||||||
|
editButtonLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.edit_button.label']}"
|
||||||
|
editDialogCancelLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.edit.cancel']}"
|
||||||
|
editDialogSubmitLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.edit.submit']}"
|
||||||
|
editDialogTitle="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.edit.title']}"
|
||||||
|
editDialogValueHelp="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.edit.value.help']}"
|
||||||
|
editDialogValueLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.edit.value.label']}"
|
||||||
|
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@bookmark-edit/description/edit"
|
||||||
|
editorId="description-editor"
|
||||||
|
hasUnusedLocales="#{!CmsBookmarkEditStep.unusedDescriptionLocales.isEmpty()}"
|
||||||
|
headingLevel="3"
|
||||||
|
objectIdentifier="#{CmsSelectedAssetModel.assetPath}"
|
||||||
|
readOnly="#{!MvcAssetEditStepModel.canEdit}"
|
||||||
|
removeButtonLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.remove_button.label']}"
|
||||||
|
removeDialogCancelLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.remove.cancel']}"
|
||||||
|
removeDialogSubmitLabel="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.remove.submit']}"
|
||||||
|
removeDialogText="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.remove.text']}"
|
||||||
|
removeDialogTitle="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.remove.title']}"
|
||||||
|
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/assets/#{CmsSelectedAssetModel.assetPath}/@bookmark-edit/description/remove"
|
||||||
|
title="#{CmsAssetsStepsDefaultMessagesBundle['bookmark.editstep.description.title']}"
|
||||||
|
unusedLocales="#{CmsBookmarkEditStep.unusedDescriptionLocales}"
|
||||||
|
useTextarea="true"
|
||||||
|
values="#{CmsBookmarkEditStep.descriptionValues}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
</ui:composition>
|
||||||
|
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue