Bugfixes for adding a contact to a SciProject
parent
f194231550
commit
c198617f0d
|
|
@ -1,6 +1,7 @@
|
||||||
package org.scientificcms.contenttypes.sciproject.ui;
|
package org.scientificcms.contenttypes.sciproject.ui;
|
||||||
|
|
||||||
import org.librecms.assets.ContactableEntity;
|
import org.librecms.assets.Organization;
|
||||||
|
import org.librecms.assets.Person;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -39,8 +40,10 @@ public class SciProjectDescriptionContactsModel {
|
||||||
this.contacts = new ArrayList<>(contacts);
|
this.contacts = new ArrayList<>(contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContactableType() {
|
public String getContactableTypes() {
|
||||||
return ContactableEntity.class.getName();
|
return String.join(
|
||||||
|
",", Person.class.getName(), Organization.class.getName()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBaseUrl() {
|
public String getBaseUrl() {
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.scientificcms.contenttypes.sciproject.ui;
|
package org.scientificcms.contenttypes.sciproject.ui;
|
||||||
|
|
||||||
|
import org.libreccm.api.Identifier;
|
||||||
|
import org.libreccm.api.IdentifierParser;
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
import org.libreccm.security.AuthorizationRequired;
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
import org.libreccm.ui.BaseUrl;
|
import org.libreccm.ui.BaseUrl;
|
||||||
import org.librecms.assets.ContactableEntity;
|
import org.librecms.assets.ContactableEntity;
|
||||||
import org.librecms.assets.Person;
|
import org.librecms.assets.Person;
|
||||||
|
import org.librecms.contentsection.Asset;
|
||||||
import org.librecms.contentsection.AssetRepository;
|
import org.librecms.contentsection.AssetRepository;
|
||||||
import org.librecms.contentsection.ContentItemRepository;
|
import org.librecms.contentsection.ContentItemRepository;
|
||||||
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
|
||||||
|
|
@ -99,6 +102,9 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
|
||||||
@Inject
|
@Inject
|
||||||
private GlobalizationHelper globalizationHelper;
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private IdentifierParser identifierParser;
|
||||||
|
|
||||||
@Context
|
@Context
|
||||||
private HttpServletRequest request;
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
|
@ -362,15 +368,34 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemPermissionChecker.canEditItem(getProject())) {
|
if (itemPermissionChecker.canEditItem(getProject())) {
|
||||||
final Optional<ContactableEntity> result = assetRepo
|
final Optional<Asset> result;
|
||||||
.findByUuidAndType(contactableUuid, ContactableEntity.class);
|
final Identifier identifier = identifierParser.parseIdentifier(
|
||||||
|
contactableUuid
|
||||||
if (!result.isPresent()) {
|
);
|
||||||
|
switch (identifier.getType()) {
|
||||||
|
case ID:
|
||||||
|
result = assetRepo.findById(
|
||||||
|
Long.parseLong(identifier.getIdentifier())
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case UUID:
|
||||||
|
result = assetRepo.findByUuid(
|
||||||
|
identifier.getIdentifier()
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
models.put("contactableNotFound", contactableUuid);
|
models.put("contactableNotFound", contactableUuid);
|
||||||
return showStep(sectionIdentifier, documentPath);
|
return showStep(sectionIdentifier, documentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ContactableEntity contactable = result.get();
|
if (!result.isPresent()
|
||||||
|
|| !(result.get() instanceof ContactableEntity)) {
|
||||||
|
models.put("contactableNotFound", contactableUuid);
|
||||||
|
return showStep(sectionIdentifier, documentPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
final ContactableEntity contactable = (ContactableEntity) result
|
||||||
|
.get();
|
||||||
projectManager.addContact(contactable, getProject(), type);
|
projectManager.addContact(contactable, getProject(), type);
|
||||||
|
|
||||||
return buildRedirectPathForStep();
|
return buildRedirectPathForStep();
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,12 @@
|
||||||
<ui:define name="authoringStep">
|
<ui:define name="authoringStep">
|
||||||
<h2>#{SciProjectMessageBundle['description_step.header']}</h2>
|
<h2>#{SciProjectMessageBundle['description_step.header']}</h2>
|
||||||
|
|
||||||
|
<c:if test="#{contactableNotFound != null}">
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
#{SciProjectMessageBundle.getMessage('description_step.errors.contactable_not_found', [contactableNotFound])}
|
||||||
|
</div>
|
||||||
|
</c:if>
|
||||||
|
|
||||||
<librecms:cmsEditorVariants
|
<librecms:cmsEditorVariants
|
||||||
addButtonLabel="#{SciProjectMessageBundle['description.editor.add_variant']}"
|
addButtonLabel="#{SciProjectMessageBundle['description.editor.add_variant']}"
|
||||||
addDialogLocaleSelectHelp="#{SciProjectMessageBundle['description.editor.add.locale.help']}"
|
addDialogLocaleSelectHelp="#{SciProjectMessageBundle['description.editor.add.locale.help']}"
|
||||||
|
|
@ -43,7 +49,7 @@
|
||||||
</div>
|
</div>
|
||||||
<librecms:assetPicker
|
<librecms:assetPicker
|
||||||
actionUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/contacts/add"
|
actionUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@sciproject-description/contacts/add"
|
||||||
assetType="#{SciProjectDescriptionContacts.contactableType}"
|
assetType="#{SciProjectDescriptionContacts.contactableTypes}"
|
||||||
assetPickerId="contacts-picker"
|
assetPickerId="contacts-picker"
|
||||||
baseUrl="#{SciProjectDescriptionContacts.baseUrl}"
|
baseUrl="#{SciProjectDescriptionContacts.baseUrl}"
|
||||||
contentSection="#{ContentSectionModel.sectionName}"
|
contentSection="#{ContentSectionModel.sectionName}"
|
||||||
|
|
@ -60,8 +66,6 @@
|
||||||
<p>#{SciProjectMessageBundle['contacts.none']}</p>
|
<p>#{SciProjectMessageBundle['contacts.none']}</p>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
@ -153,10 +157,9 @@
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<librecms:assetPickerButton
|
<librecms:assetPickerButton
|
||||||
assetPickerId="contacts-picker"
|
assetPickerId="members-picker"
|
||||||
buttonIcon="plus-circle"
|
buttonIcon="plus-circle"
|
||||||
buttonText="#{SciProjectMessageBundle['memberships.add_button.label']}"
|
buttonText="#{SciProjectMessageBundle['memberships.add_button.label']}"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -171,3 +171,4 @@ authoringsteps.projectdescription.description=Detailed description of the resear
|
||||||
authoringsteps.projectdescription.label=Description
|
authoringsteps.projectdescription.label=Description
|
||||||
memberships.none=No memberships assigned yet.
|
memberships.none=No memberships assigned yet.
|
||||||
contacts.none=No contacts assigned yet.
|
contacts.none=No contacts assigned yet.
|
||||||
|
description_step.errors.contactable_not_found=Selected contactable entity {0} not found.
|
||||||
|
|
|
||||||
|
|
@ -171,3 +171,4 @@ authoringsteps.projectdescription.description=Ausf\u00fchrliche Beschreibung des
|
||||||
authoringsteps.projectdescription.label=Beschreibung
|
authoringsteps.projectdescription.label=Beschreibung
|
||||||
memberships.none=Es wurden noch keine Mitglieder hinzugef\u00fcgt.
|
memberships.none=Es wurden noch keine Mitglieder hinzugef\u00fcgt.
|
||||||
contacts.none=Es wurden noch keine Kontakte hinzugef\u00fcgt.
|
contacts.none=Es wurden noch keine Kontakte hinzugef\u00fcgt.
|
||||||
|
description_step.errors.contactable_not_found=Die als Kontakt ausgew\u00e4hlte Entity {0} wurde nicht gefunden.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue