Description Edit for SciProject
parent
795bc99f2d
commit
afb642498e
|
|
@ -6,6 +6,7 @@
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
import org.libreccm.configuration.ConfigurationManager;
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
|
import org.libreccm.l10n.LocalizedString;
|
||||||
import org.librecms.assets.ContactableEntity;
|
import org.librecms.assets.ContactableEntity;
|
||||||
import org.librecms.assets.ContactableEntityRepository;
|
import org.librecms.assets.ContactableEntityRepository;
|
||||||
import org.scientificcms.contenttypes.sciproject.Contact;
|
import org.scientificcms.contenttypes.sciproject.Contact;
|
||||||
|
|
@ -282,6 +283,26 @@ class SciProjectController {
|
||||||
.anyMatch(current -> filterContact(current, project, contactable));
|
.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)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public void save(final long projectId,
|
public void save(final long projectId,
|
||||||
final Locale selectedLocale,
|
final Locale selectedLocale,
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,14 @@ import org.scientificcms.contenttypes.sciproject.SciProjectConstants;
|
||||||
public class SciProjectDescriptionStep extends SimpleEditStep {
|
public class SciProjectDescriptionStep extends SimpleEditStep {
|
||||||
|
|
||||||
private final SegmentedPanel segmentedPanel;
|
private final SegmentedPanel segmentedPanel;
|
||||||
|
private final StringParameter selectedLanguageParam;
|
||||||
|
|
||||||
public SciProjectDescriptionStep(
|
public SciProjectDescriptionStep(
|
||||||
final ItemSelectionModel itemModel,
|
final ItemSelectionModel itemModel,
|
||||||
final AuthoringKitWizard parent,
|
final AuthoringKitWizard parent,
|
||||||
final StringParameter selectedLanguageParameter) {
|
final StringParameter selectedLanguageParam) {
|
||||||
|
|
||||||
super(itemModel, parent, selectedLanguageParameter);
|
super(itemModel, parent, selectedLanguageParam);
|
||||||
|
|
||||||
segmentedPanel = new SegmentedPanel();
|
segmentedPanel = new SegmentedPanel();
|
||||||
setDefaultEditKey(SciProjectUiConstants.EDIT_DESC_SHEET_NAME);
|
setDefaultEditKey(SciProjectUiConstants.EDIT_DESC_SHEET_NAME);
|
||||||
|
|
@ -37,6 +38,7 @@ public class SciProjectDescriptionStep extends SimpleEditStep {
|
||||||
addSteps(itemModel, parent);
|
addSteps(itemModel, parent);
|
||||||
|
|
||||||
setDisplayComponent(segmentedPanel);
|
setDisplayComponent(segmentedPanel);
|
||||||
|
this.selectedLanguageParam = selectedLanguageParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SegmentedPanel getSegmentedPanel() {
|
protected SegmentedPanel getSegmentedPanel() {
|
||||||
|
|
@ -46,7 +48,9 @@ public class SciProjectDescriptionStep extends SimpleEditStep {
|
||||||
protected void addSteps(final ItemSelectionModel itemModel,
|
protected void addSteps(final ItemSelectionModel itemModel,
|
||||||
final AuthoringKitWizard parent) {
|
final AuthoringKitWizard parent) {
|
||||||
|
|
||||||
addStep(new SciProjectDescriptionTextStep(item, parent),
|
addStep(new SciProjectDescriptionTextStep(itemModel,
|
||||||
|
parent,
|
||||||
|
selectedLanguageParam),
|
||||||
"sciproject.ui.steps.description.title");
|
"sciproject.ui.steps.description.title");
|
||||||
|
|
||||||
final SciProjectConfig config = SciProjectConfig.getConfig();
|
final SciProjectConfig config = SciProjectConfig.getConfig();
|
||||||
|
|
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ public class SciProjectDescriptionTextStep extends SimpleEditStep {
|
||||||
super(itemModel, parent, selectedLanguageParam, suffix);
|
super(itemModel, parent, selectedLanguageParam, suffix);
|
||||||
|
|
||||||
final BasicItemForm descTextEditSheet
|
final BasicItemForm descTextEditSheet
|
||||||
= new SciProjectDescriptionTextForm(
|
= new SciProjectDescriptionTextEditForm(
|
||||||
itemModel, selectedLanguageParam);
|
itemModel, selectedLanguageParam);
|
||||||
add(SciProjectUiConstants.EDIT_DESC_TEXT_SHEET_NAME,
|
add(SciProjectUiConstants.EDIT_DESC_TEXT_SHEET_NAME,
|
||||||
new GlobalizedMessage("sciproject.ui.desc.text.edit",
|
new GlobalizedMessage("sciproject.ui.desc.text.edit",
|
||||||
|
|
@ -55,6 +55,7 @@ public class SciProjectDescriptionTextStep extends SimpleEditStep {
|
||||||
add(SciProjectUiConstants.UPLOAD_DESC_TEXT_SHEET_NAME,
|
add(SciProjectUiConstants.UPLOAD_DESC_TEXT_SHEET_NAME,
|
||||||
new GlobalizedMessage("sciproject.ui.desc.upload",
|
new GlobalizedMessage("sciproject.ui.desc.upload",
|
||||||
SciProjectConstants.SCI_PROJECT_BUNDLE),
|
SciProjectConstants.SCI_PROJECT_BUNDLE),
|
||||||
|
new WorkflowLockedComponentAccess(uploadDescForm, itemModel),
|
||||||
uploadDescForm.getSaveCancelSection().getCancelButton());
|
uploadDescForm.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
setDisplayComponent(
|
setDisplayComponent(
|
||||||
|
|
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -32,6 +32,8 @@ public final class SciProjectUiConstants {
|
||||||
|
|
||||||
public static final String PROJECT_DESCRIPTION = "description";
|
public static final String PROJECT_DESCRIPTION = "description";
|
||||||
|
|
||||||
|
public static final String SPONSOR_STEP = "SciProjectSponsorStep";
|
||||||
|
|
||||||
public static final String TITLE = "title";
|
public static final String TITLE = "title";
|
||||||
|
|
||||||
private SciProjectUiConstants() {
|
private SciProjectUiConstants() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue