Bugfixes for sci-types-department

pull/1/head
Jens Pelzetter 2022-10-10 21:02:08 +02:00
parent 5ca6b18124
commit d6d49aed6a
12 changed files with 140 additions and 89 deletions

View File

@ -26,7 +26,8 @@ public class SciDepartmentAuthoringSteps implements MvcAuthoringSteps {
return Set.of(
SciDepartmentDescriptionContacts.class,
SciDepartmentDescriptionStepResources.class,
SciDepartmentDescriptionStepService.class
SciDepartmentDescriptionStepService.class,
SciDepartmentTextsResources.class
);
}

View File

@ -48,7 +48,7 @@ public class SciDepartmentDescriptionContacts {
public Response saveOrder(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM)
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
final List<String> order
) {

View File

@ -1,5 +1,7 @@
package org.scientificcms.contenttypes.scidepartment.ui;
import org.librecms.assets.Person;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
@ -25,6 +27,10 @@ public class SciDepartmentDescriptionMembersModel {
private String baseUrl;
public String getMemberType() {
return Person.class.getName();
}
public boolean getCanEdit() {
return canEdit;
}

View File

@ -95,8 +95,7 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep {
@Inject
private ConfigurationManager confManager;
@Inject
private ContentItemRepository itemRepo;
@ -144,7 +143,7 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep {
@Inject
private SciDepartmentTextsModel textsModel;
@Inject
private SciDepartmentTexts texts;
@ -394,7 +393,6 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep {
// );
// }
// }
@GET
@Path("/texts/view/{textKey}/{locale}")
@Transactional(Transactional.TxType.REQUIRED)
@ -551,7 +549,7 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep {
new Locale(localeParam).toString()
);
return "org/scientificcms/contenttypes/scidepartment/ui/texts/edit-text.xhtml";
return "org/scientificcms/contenttypes/scidepartment/ui/texts/edit.xhtml";
} else {
return documentUi.showAccessDenied(
getContentSection(),
@ -676,7 +674,7 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep {
}
departmentManager.removeText(getDepartment(), textKey);
return buildRedirectPathForStep();
} else {
return documentUi.showAccessDenied(
@ -1086,15 +1084,16 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep {
);
textsModel.setAvailableTextKeys(
texts
.entrySet()
.stream()
.filter(entry -> !textsModel.getTexts().containsKey(entry.getKey()))
.collect(
Collectors.toMap(
entry -> entry.getKey(),
entry -> entry.getValue()
.entrySet()
.stream()
.filter(entry -> !textsModel.getTexts().containsKey(entry
.getKey()))
.collect(
Collectors.toMap(
entry -> entry.getKey(),
entry -> entry.getValue()
)
)
)
);
contactsModel.setCanEdit(canEdit);
@ -1167,7 +1166,15 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep {
membership.getMember().getPersonName().getPrefix()
);
model.setRole(membership.getRole());
model.setStatus(Objects.toString(membership.getStatus()));
model.setStatus(
Optional
.ofNullable(membership.getStatus())
.map(status -> status.toString())
.map(String::toLowerCase)
.map(status -> String.format("members.status.%s", status))
.map(status -> messageBundle.get(status))
.orElse("")
);
model.setSuffix(
membership.getMember().getPersonName().getSuffix()
);
@ -1180,6 +1187,7 @@ public class SciDepartmentDescriptionStep extends AbstractMvcAuthoringStep {
private SciDepartmentTextModel buildTextModel(final DepartmentText text) {
final SciDepartmentTextModel model = new SciDepartmentTextModel();
model.setKey(text.getKey());
model.setTextValues(
text
.getText()

View File

@ -18,6 +18,10 @@ import java.util.Optional;
*/
public class SciDepartmentTextModel {
private String key;
private Map<String, String> textValues;
private List<CmsEditorLocaleVariantRow> variants;
@ -72,12 +76,24 @@ public class SciDepartmentTextModel {
.map(list -> (List<String>) list)
.orElse(Collections.emptyList());
}
public String getKey() {
return key;
}
protected void setKey(final String key) {
this.key = key;
}
public String getKeyId() {
return key.replace('.', '-');
}
public long getOrder() {
return order;
}
public void setOrder(final long order) {
protected void setOrder(final long order) {
this.order = order;
}

View File

@ -35,5 +35,10 @@
</ui:define>
<ui:define name="scripts">
<script src="#{request.contextPath}/assets/@content-sections/cms-editor.js"></script>
</ui:define>
</ui:composition>
</html>

View File

@ -133,7 +133,7 @@
</c:if>
#{contact.contactable}
</td>
<td>#{contact.contactType}</td>
<td>#{SciDepartmentContactTypes[contact.contactType]}</td>
<td>
<button class="btn btn-secondary"
data-toggle="modal"
@ -149,6 +149,7 @@
tabindex="-1">
<div class="modal-dialog">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/contacts/edit/#{contact.contactId}"
class="modal-content"
method="post">
<div class="modal-header">
<h4 class="modal-title"
@ -196,7 +197,7 @@
confirmLabel="#{SciDepartmentMessageBundle['contacts.delete.confirm']}"
dialogId="contact-delete-dialog-#{contact.contactId}"
dialogTitle="#{SciDepartmentMessageBundle['contacts.delete.title']}"
message="#{SciDepartmentMessageBundle.getMessage('contacts.delete.message', [contact.contactable, contact.contactType])}"
message="#{SciDepartmentMessageBundle.getMessage('contacts.delete.message', [contact.contactable, SciDepartmentContactTypes[contact.contactType]])}"
/>
</td>
@ -274,15 +275,15 @@
<td>
<button class="btn btn-secondary"
data-toggle="modal"
data-target="#membership-edit-dialog"
data-target="#membership-#{member.membershipId}-edit-dialog"
type="button">
<bootstrap:svgIcon icon="pen"/>
<span class="sr-only">#{SciDepartmentMessageBundle['memberships.edit.label']}</span>
</button>
<div aria-hidden="true"
aria-labelledby="membership-edit-dialog-title"
aria-labelledby="membership-#{member.membershipId}-edit-dialog-title"
class="modal fade"
id="membership-edit-dialog"
id="membership-#{member.membershipId}-edit-dialog"
tabindex="-1">
<div class="modal-dialog">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/members/edit/#{member.membershipId}"
@ -290,7 +291,7 @@
method="post">
<div class="modal-header">
<h4 class="modal-title"
id="membership-edit-dialog-title">
id="membership-#{member.membershipId}-edit-dialog-title">
</h4>
<button
aria-label="#{SciDepartmentMessageBundle['memberships.edit.cancel']}"
@ -337,10 +338,10 @@
<td>
<libreccm:deleteDialog
actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/members/remove/#{member.membershipId}"
buttonText="#{SciDepartmentMessageBundle['>memberships.delete.label']}"
buttonText="#{SciDepartmentMessageBundle['memberships.delete.label']}"
cancelLabel="#{SciDepartmentMessageBundle['memberships.delete.cancel']}"
confirmLabel="#{SciDepartmentMessageBundle['memberships.delete.confirm']}"
dialogId="membership-delete-dialog"
dialogId="membership-#{member.membershipId}-delete-dialog"
dialogTitle="#{SciDepartmentMessageBundle['memberships.delete.title']}"
message="#{SciDepartmentMessageBundle.getMessage('memberships.delete.message', [member.name])}"
/>
@ -361,50 +362,51 @@
<bootstrap:svgIcon icon="plus-circle" />
<span class="sr-only">#{SciDepartmentMessageBundle['texts.add.label']}</span>
</button>
<div aria-hidden="true"
aria-labelledby="department-text-add-dialog-title"
class="modal fade"
id="department-text-add-dialog"
tabindex="-1">
<div class="modal-dialog">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/add"
method="post">
<div class="modal-header">
<h4 class="modal-title"
id="department-text-add-dialog-title">
#{SciDepartmentMessageBundle['texts.add.dialog.title']}
</h4>
<button aria-label="#{SciDepartmentMessageBundle['texts.add.cancel']}"
class="close"
data-dismiss="modal"
type="button">
<bootstrap:svgIcon icon="x" />
</button>
</div>
<div class="modal-body">
<bootstrap:formGroupSelect
help="#{SciDepartmentMessageBundle['texts.add.key.help']}"
inputId="text-key"
label="#{SciDepartmentMessageBundle['texts.add.key.label']}"
name="textKey"
options="#{SciDepartmentTextsModel.availableTextKeys}"
/>
</div>
<div class="modal-footer">
<button class="btn btn-warning"
data-dismiss="modal"
type="button">
#{SciDepartmentMessageBundle['texts.add.cancel']}
</button>
<button class="btn btn-success"
type="submit">
#{SciDepartmentMessageBundle['texts.add.submit']}
</button>
</div>
</form>
</div>
</div>
</h3>
<div aria-hidden="true"
aria-labelledby="department-text-add-dialog-title"
class="modal fade"
id="department-text-add-dialog"
tabindex="-1">
<div class="modal-dialog">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/add"
class="modal-content"
method="post">
<div class="modal-header">
<h4 class="modal-title"
id="department-text-add-dialog-title">
#{SciDepartmentMessageBundle['texts.add.dialog.title']}
</h4>
<button aria-label="#{SciDepartmentMessageBundle['texts.add.cancel']}"
class="close"
data-dismiss="modal"
type="button">
<bootstrap:svgIcon icon="x" />
</button>
</div>
<div class="modal-body">
<bootstrap:formGroupSelect
help="#{SciDepartmentMessageBundle['texts.add.key.help']}"
inputId="text-key"
label="#{SciDepartmentMessageBundle['texts.add.key.label']}"
name="textKey"
options="#{SciDepartmentTextsModel.availableTextKeys}"
/>
</div>
<div class="modal-footer">
<button class="btn btn-warning"
data-dismiss="modal"
type="button">
#{SciDepartmentMessageBundle['texts.add.cancel']}
</button>
<button class="btn btn-success"
type="submit">
#{SciDepartmentMessageBundle['texts.add.submit']}
</button>
</div>
</form>
</div>
</div>
<c:choose>
<c:when test="#{SciDepartmentTextsModel.texts.isEmpty()}">
<p>#{SciDepartmentMessageBundle['texts.none']}</p>
@ -412,33 +414,34 @@
<c:otherwise>
<c:forEach items="#{SciDepartmentTextsModel.texts.entrySet()}"
var="text">
<h4>
#{SciDepartmentTexts[text.key]}
<div class="d-flex">
<h4 class="mr-2">#{SciDepartmentTexts[text.key]}</h4>
<libreccm:deleteDialog
actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/remove/#{text.key}"
buttonText="#{SciDepartmentMessageBundle['texts.delete.label']}"
cancelLabel="#{SciDepartmentMessageBundle['texts.delete.cancel']}"
confirmLabel="#{SciDepartmentMessageBundle['texts.delete.confirm']}"
dialogId="text-#{text.key}-delete-dialog"
dialogId="text-#{text.value.keyId}-delete-dialog"
dialogTitle="#{SciDepartmentMessageBundle['texts.delete.title']}"
message="#{SciDepartmentMessageBundle.getMessage('texts.delete.message', [text.key])}"
message="#{SciDepartmentMessageBundle.getMessage('texts.delete.message', [SciDepartmentTexts[text.key]])}"
/>
</h4>
</div>
<librecms:cmsEditorVariants
addButtonLabel="#{SciDepartmentMessageBundle['texts.editor.add_variant']}"
addDialogLocaleSelectHelp="#{SciDepartmentMessageBundle['texts.editor.add.locale.help']}"
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/add/#{text.eky}"
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/add/#{text.key}"
canEdit="#{SciDepartmentDescriptionModel.canEdit}"
editorPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/edit/#{text.key}"
hasUnusedLocales="#{text.value.unusedLocales.isEmpty()}"
hasUnusedLocales="#{!text.value.unusedLocales.isEmpty()}"
headingLevel="5"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidpartment-description-texts/remove/#{text.key}"
sourceEditorPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidpartment-description-texts/edit-source/#{text.key}"
title="#{SciDepartmentMessageBundle.getMessage('texts.editor.header', [text.key])}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/remove/#{text.key}"
sourceEditorPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/edit-source/#{text.key}"
title="#{SciDepartmentMessageBundle.getMessage('texts.editor.header', [SciDepartmentTexts[text.key]])}"
unusedLocales="#{text.value.unusedLocales}"
variants="#{text.value.variants}"
variantsId="text-#{text.key}"
viewPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidpartment-description-texts/view/#{text.key}"
variantsId="text-#{text.value.keyId}"
viewPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-description/texts/view/#{text.key}"
/>
</c:forEach>
</c:otherwise>

View File

@ -15,7 +15,7 @@
<span class="sr-only">#{SciDepartmentMessageBundle['description_step.back']}</span>
</a>
<h2>#{SciDepartmentMessageBundle.getMessage('description_step.text.header.edit', [SciDepartmentTextsModel.selectedText])}</h2>
<h2>#{SciDepartmentMessageBundle.getMessage('description_step.text.header.edit', [SciDepartmentTexts[SciDepartmentTextsModel.selectedText]])}</h2>
</div>
<c:if test="#{SciDepartmentDescriptionModel.canEdit}">
@ -28,13 +28,17 @@
editorId="scidepartment-texts-editor"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
selectedLocale="#{SciDepartmentTextsModel.selectedLocale}"
title="#{SciDepartmentMessageBundle['texts.editor.header']}"
variantUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-texts-resources/department-texts"
title="#{SciDepartmentMessageBundle.getMessage('texts.editor.header', [SciDepartmentTexts[SciDepartmentTextsModel.selectedText]])}"
variantUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@scidepartment-texts-resources/department-texts/#{SciDepartmentTextsModel.selectedText}"
/>
</c:if>
</ui:define>
<ui:define name="scripts">
<script src="#{request.contextPath}/assets/@content-sections/cms-editor.js"></script>
</ui:define>
</ui:composition>
</html>

View File

@ -15,7 +15,7 @@
<span class="sr-only">#{SciDepartmentMessageBundle['description_step.back']}</span>
</a>
<h2>#{SciDepartmentMessageBundle.getMessage('description_step.texts.header.view', [SciDepartmentTextsModel.selectedText])}</h2>
<h2>#{SciDepartmentMessageBundle.getMessage('description_step.texts.header.view', [SciDepartmentTexts[SciDepartmentTextsModel.selectedText]])}</h2>
</div>
<c:if test="#{SciDepartmentDescriptionModel.canEdit}">
@ -29,7 +29,7 @@
</c:if>
<div class="cms-text-preview article-text border p-2">
<h:outputText escape="false"
value="#{SciDepartmentTextsModel.texts.get(SciDepartmentTextsModel.selectedText).get(SciDepartmentTextsModel.selectedLocale)}" />
value="#{SciDepartmentTextsModel.texts.get(SciDepartmentTextsModel.selectedText).textValues.get(SciDepartmentTextsModel.selectedLocale)}" />
</div>
</ui:define>

View File

@ -144,3 +144,7 @@ description_step.texts.header.view=View text {0}
description_step.edit=Edit
description_step.description.header.view=Description
basicproperties.name.edit.submit=Save
contacts.order.save=Save order
members.status.active=Active
members.status.associated=Associated
members.status.former=Former

View File

@ -144,3 +144,7 @@ description_step.texts.header.view=Text {0}
description_step.edit=Bearbeiten
description_step.description.header.view=Beschreibung
basicproperties.name.edit.submit=Speichern
contacts.order.save=Sortierung speichern
members.status.active=Aktiv
members.status.associated=Assoziert
members.status.former=Ehemalig

View File

@ -134,7 +134,7 @@
</c:if>
#{contact.contactable}
</td>
<td>#{SciProjectContactTables[contact.contactType]}</td>
<td>#{SciProjectContactTypes[contact.contactType]}</td>
<td>
<button class="btn btn-secondary"
data-toggle="modal"