diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java
index 372d83d..21c330a 100644
--- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java
+++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectController.java
@@ -6,6 +6,7 @@
package com.arsdigita.cms.contenttypes.ui;
import org.libreccm.configuration.ConfigurationManager;
+import org.libreccm.l10n.LocalizedString;
import org.librecms.assets.ContactableEntity;
import org.librecms.assets.ContactableEntityRepository;
import org.scientificcms.contenttypes.sciproject.Contact;
@@ -281,6 +282,26 @@ class SciProjectController {
.stream()
.anyMatch(current -> filterContact(current, project, contactable));
}
+
+ @Transactional(Transactional.TxType.REQUIRED)
+ public void updateDescription(final long projectId,
+ final String descriptionText,
+ final Locale language) {
+
+ final SciProject project = projectRepository
+ .findById(projectId, SciProject.class)
+ .orElseThrow(
+ () -> new IllegalArgumentException(
+ String.format("No SciProject with ID %d found.",
+ projectId))
+ );
+
+ final LocalizedString desc = project.getDescription();
+ desc.addValue(Objects.requireNonNull(language),
+ descriptionText);
+
+ projectRepository.save(project);
+ }
@Transactional(Transactional.TxType.REQUIRED)
public void save(final long projectId,
diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java
index 89b8644..a2342d2 100644
--- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java
+++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java
@@ -23,13 +23,14 @@ import org.scientificcms.contenttypes.sciproject.SciProjectConstants;
public class SciProjectDescriptionStep extends SimpleEditStep {
private final SegmentedPanel segmentedPanel;
+ private final StringParameter selectedLanguageParam;
public SciProjectDescriptionStep(
final ItemSelectionModel itemModel,
final AuthoringKitWizard parent,
- final StringParameter selectedLanguageParameter) {
+ final StringParameter selectedLanguageParam) {
- super(itemModel, parent, selectedLanguageParameter);
+ super(itemModel, parent, selectedLanguageParam);
segmentedPanel = new SegmentedPanel();
setDefaultEditKey(SciProjectUiConstants.EDIT_DESC_SHEET_NAME);
@@ -37,6 +38,7 @@ public class SciProjectDescriptionStep extends SimpleEditStep {
addSteps(itemModel, parent);
setDisplayComponent(segmentedPanel);
+ this.selectedLanguageParam = selectedLanguageParam;
}
protected SegmentedPanel getSegmentedPanel() {
@@ -46,7 +48,9 @@ public class SciProjectDescriptionStep extends SimpleEditStep {
protected void addSteps(final ItemSelectionModel itemModel,
final AuthoringKitWizard parent) {
- addStep(new SciProjectDescriptionTextStep(item, parent),
+ addStep(new SciProjectDescriptionTextStep(itemModel,
+ parent,
+ selectedLanguageParam),
"sciproject.ui.steps.description.title");
final SciProjectConfig config = SciProjectConfig.getConfig();
diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextEditForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextEditForm.java
new file mode 100644
index 0000000..cdcc7cb
--- /dev/null
+++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextEditForm.java
@@ -0,0 +1,103 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.arsdigita.cms.contenttypes.ui;
+
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.event.FormInitListener;
+import com.arsdigita.bebop.event.FormProcessListener;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.bebop.parameters.ParameterModel;
+import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.ui.CMSDHTMLEditor;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
+import com.arsdigita.globalization.GlobalizedMessage;
+
+import org.libreccm.cdi.utils.CdiUtil;
+import org.scientificcms.contenttypes.sciproject.SciProject;
+import org.scientificcms.contenttypes.sciproject.SciProjectConstants;
+
+import java.util.Locale;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciProjectDescriptionTextEditForm
+ extends BasicItemForm
+ implements FormProcessListener, FormInitListener {
+
+ private final StringParameter selectedLanguageParam;
+
+ public SciProjectDescriptionTextEditForm(
+ final ItemSelectionModel itemModel,
+ final StringParameter selectedLanguageParam) {
+
+ super("SciProjectDescriptionTextEditForm",
+ itemModel,
+ selectedLanguageParam);
+
+ this.selectedLanguageParam = selectedLanguageParam;
+ }
+
+ @Override
+ public void addWidgets() {
+
+ final ParameterModel descParam = new StringParameter(
+ SciProjectUiConstants.PROJECT_DESCRIPTION);
+ final CMSDHTMLEditor editor = new CMSDHTMLEditor(descParam);
+ editor.setLabel(new GlobalizedMessage(
+ "sciproject.ui.description",
+ SciProjectConstants.SCI_PROJECT_BUNDLE));
+ editor.setCols(80);
+ editor.setRows(25);
+ add(editor);
+ }
+
+ @Override
+ public void init(final FormSectionEvent event) throws FormProcessException {
+
+ final PageState state = event.getPageState();
+ final FormData data = event.getFormData();
+ final SciProject project = (SciProject) getItemSelectionModel()
+ .getSelectedItem(state);
+
+ data.put(SciProjectUiConstants.PROJECT_DESCRIPTION,
+ project.getProjectDescription());
+
+ setVisible(state, true);
+ }
+
+ @Override
+ public void process(final FormSectionEvent event) throws
+ FormProcessException {
+
+ final PageState state = event.getPageState();
+ final FormData data = event.getFormData();
+ final SciProject project = (SciProject) getItemSelectionModel()
+ .getSelectedItem(state);
+
+ if (project != null
+ && getSaveCancelSection().getSaveButton().isSelected(state)) {
+
+ final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
+ final SciProjectController controller = cdiUtil
+ .findBean(SciProjectController.class);
+ final Locale selectedLang = SelectedLanguageUtil
+ .selectedLocale(state, selectedLanguageParam);
+
+ controller.updateDescription(
+ project.getObjectId(),
+ (String) data.get(SciProjectUiConstants.PROJECT_DESCRIPTION),
+ selectedLang
+ );
+ }
+ }
+
+}
diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextStep.java
index f31c1c6..7b333dd 100644
--- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextStep.java
+++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionTextStep.java
@@ -40,7 +40,7 @@ public class SciProjectDescriptionTextStep extends SimpleEditStep {
super(itemModel, parent, selectedLanguageParam, suffix);
final BasicItemForm descTextEditSheet
- = new SciProjectDescriptionTextForm(
+ = new SciProjectDescriptionTextEditForm(
itemModel, selectedLanguageParam);
add(SciProjectUiConstants.EDIT_DESC_TEXT_SHEET_NAME,
new GlobalizedMessage("sciproject.ui.desc.text.edit",
@@ -55,6 +55,7 @@ public class SciProjectDescriptionTextStep extends SimpleEditStep {
add(SciProjectUiConstants.UPLOAD_DESC_TEXT_SHEET_NAME,
new GlobalizedMessage("sciproject.ui.desc.upload",
SciProjectConstants.SCI_PROJECT_BUNDLE),
+ new WorkflowLockedComponentAccess(uploadDescForm, itemModel),
uploadDescForm.getSaveCancelSection().getCancelButton());
setDisplayComponent(
diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java
new file mode 100644
index 0000000..2193f1d
--- /dev/null
+++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java
@@ -0,0 +1,71 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.arsdigita.cms.contenttypes.ui;
+
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.ui.authoring.SelectedLanguageUtil;
+import com.arsdigita.cms.ui.contenttypes.AbstractTextUploadForm;
+import com.arsdigita.globalization.GlobalizedMessage;
+
+import org.libreccm.cdi.utils.CdiUtil;
+import org.scientificcms.contenttypes.sciproject.SciProject;
+import org.scientificcms.contenttypes.sciproject.SciProjectConstants;
+
+import java.util.Locale;
+
+import static com.arsdigita.cms.ui.authoring.SelectedLanguageUtil.*;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciProjectDescriptionUploadForm extends AbstractTextUploadForm {
+
+ private StringParameter selectedLanguageParam;
+
+ public SciProjectDescriptionUploadForm(
+ final ItemSelectionModel itemModel,
+ final StringParameter selectedLanguageParam) {
+
+ super(itemModel);
+ }
+
+ @Override
+ public GlobalizedMessage getLabelText() {
+ return new GlobalizedMessage("sciproject.ui.description.upload",
+ SciProjectConstants.SCI_PROJECT_BUNDLE);
+ }
+
+ @Override
+ public GlobalizedMessage getMimeTypeLabel() {
+ return new GlobalizedMessage(
+ "sciproject.ui.description.upload.mimetype",
+ SciProjectConstants.SCI_PROJECT_BUNDLE);
+ }
+
+ @Override
+ public void setText(final ItemSelectionModel itemModel,
+ final PageState state,
+ final String text) {
+
+ final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
+ final SciProjectController controller = cdiUtil
+ .findBean(SciProjectController.class);
+
+ final SciProject project = (SciProject) itemModel
+ .getSelectedItem(state);
+
+ final Locale locale = SelectedLanguageUtil
+ .selectedLocale(state, selectedLanguageParam);
+
+ controller.updateDescription(project.getObjectId(),
+ text,
+ locale);
+ }
+
+}
diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorStep.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorStep.java
new file mode 100644
index 0000000..911f105
--- /dev/null
+++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectSponsorStep.java
@@ -0,0 +1,72 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.arsdigita.cms.contenttypes.ui;
+
+import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.cms.ItemSelectionModel;
+import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
+import com.arsdigita.cms.ui.authoring.BasicItemForm;
+import com.arsdigita.cms.ui.authoring.SimpleEditStep;
+import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
+import com.arsdigita.globalization.GlobalizedMessage;
+
+import org.librecms.assets.Organization;
+import org.scientificcms.contenttypes.sciproject.SciProjectConstants;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public class SciProjectSponsorStep extends SimpleEditStep {
+
+ private Organization selectedSponsor;
+ private String selectedSponsorFundingCode;
+
+ public SciProjectSponsorStep(final ItemSelectionModel itemModel,
+ final AuthoringKitWizard parent,
+ final StringParameter selectedLanguageParam) {
+ this(itemModel, parent, selectedLanguageParam, null);
+ }
+
+ public SciProjectSponsorStep(final ItemSelectionModel itemModel,
+ final AuthoringKitWizard parent,
+ final StringParameter selectedLanguageParam,
+ final String prefix) {
+
+ super(itemModel, parent, selectedLanguageParam, prefix);
+
+ final BasicItemForm sponsorForm = new SciProjectSponsorForm(itemModel,
+ this);
+ add(SciProjectUiConstants.SPONSOR_STEP,
+ new GlobalizedMessage("sciproject.ui.sponsor.add",
+ SciProjectConstants.SCI_PROJECT_BUNDLE),
+ new WorkflowLockedComponentAccess(sponsorForm, itemModel),
+ sponsorForm.getSaveCancelSection().getCancelButton());
+
+ final SciProjectSponsorSheet sheet = new SciProjectSponsorSheet(
+ itemModel, this);
+ setDisplayComponent(sheet);
+ }
+
+ protected Organization getSelectedSponsor() {
+ return selectedSponsor;
+ }
+
+ protected void setSelectedSponsor(
+ final Organization selectedSponsor) {
+ this.selectedSponsor = selectedSponsor;
+ }
+
+ protected String getSelectedSponsorFundingCode() {
+ return selectedSponsorFundingCode;
+ }
+
+ protected void setSelectedSponsorFundingCode(
+ final String selectedSponsorFundingCode) {
+ this.selectedSponsorFundingCode = selectedSponsorFundingCode;
+ }
+
+}
diff --git a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java
index e86e44e..6a068ff 100644
--- a/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java
+++ b/sci-types-project/src/main/java/com/arsdigita/cms/contenttypes/ui/SciProjectUiConstants.java
@@ -32,6 +32,8 @@ public final class SciProjectUiConstants {
public static final String PROJECT_DESCRIPTION = "description";
+ public static final String SPONSOR_STEP = "SciProjectSponsorStep";
+
public static final String TITLE = "title";
private SciProjectUiConstants() {