Verknüpfung Profil Person in CreateStep verlagert
git-svn-id: https://svn.libreccm.org/ccm/trunk@1022 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
87461d5b3d
commit
9a21b549ea
|
|
@ -751,7 +751,7 @@ cms.ui.type.data_entry_method=Methode der Dateneingabe
|
||||||
cms.ui.type.default_date=Voreingestelltes Datum
|
cms.ui.type.default_date=Voreingestelltes Datum
|
||||||
cms.ui.type.delete=Typ l\u00f6schen
|
cms.ui.type.delete=Typ l\u00f6schen
|
||||||
cms.ui.type.delete_prompt=Sind Sie sicher, diesen Dokumententyp zu l\u00f6schen?
|
cms.ui.type.delete_prompt=Sind Sie sicher, diesen Dokumententyp zu l\u00f6schen?
|
||||||
cms.ui.type.details=Dokumententyp Einzelheiten
|
cms.ui.type.details=Dokumententyp Details
|
||||||
cms.ui.type.edit=Dokumententyp bearbeiten
|
cms.ui.type.edit=Dokumententyp bearbeiten
|
||||||
cms.ui.type.element.delete=Element l\u00f6schen
|
cms.ui.type.element.delete=Element l\u00f6schen
|
||||||
cms.ui.type.element.type=Element Typ
|
cms.ui.type.element.type=Element Typ
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
objectType="com.arsdigita.cms.contenttypes.SciPublicPersonalProfile"
|
objectType="com.arsdigita.cms.contenttypes.SciPublicPersonalProfile"
|
||||||
classname="com.arsdigita.cms.contenttypes.SciPublicPersonalProfile">
|
classname="com.arsdigita.cms.contenttypes.SciPublicPersonalProfile">
|
||||||
|
|
||||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
|
<!-- <ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">-->
|
||||||
|
<ctd:authoring-kit createComponent="com.arsdigita.cms.contenttypes.ui.SciPublicPersonalProfileCreate">
|
||||||
|
|
||||||
<ctd:authoring-step
|
<ctd:authoring-step
|
||||||
labelKey="scipublicpersonalprofile.ui.profile_properties.title"
|
labelKey="scipublicpersonalprofile.ui.profile_properties.title"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.parameters.DateParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ContentBundle;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.Folder;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.SciMember;
|
||||||
|
import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile;
|
||||||
|
import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection;
|
||||||
|
import com.arsdigita.cms.ui.authoring.CreationSelector;
|
||||||
|
import com.arsdigita.cms.ui.authoring.LanguageWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.PageCreate;
|
||||||
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class SciPublicPersonalProfileCreate extends PageCreate {
|
||||||
|
|
||||||
|
private static final String SELECTED_PERSON = "selectedPerson";
|
||||||
|
|
||||||
|
public SciPublicPersonalProfileCreate(final ItemSelectionModel itemModel,
|
||||||
|
final CreationSelector parent) {
|
||||||
|
super(itemModel, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addWidgets() {
|
||||||
|
//super.addWidgets();
|
||||||
|
|
||||||
|
ContentType type = getItemSelectionModel().getContentType();
|
||||||
|
m_workflowSection = new ApplyWorkflowFormSection(type);
|
||||||
|
add(m_workflowSection, ColumnPanel.INSERT);
|
||||||
|
add(new Label(GlobalizationUtil.globalize(
|
||||||
|
"cms.ui.authoring.content_type")));
|
||||||
|
add(new Label(type.getLabel()));
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.ui.language.field")));
|
||||||
|
add(new LanguageWidget(LANGUAGE));
|
||||||
|
|
||||||
|
add(new Label(SciPublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
|
"scipublicpersonalprofile.ui.create.select_person")));
|
||||||
|
ParameterModel ownerModel =
|
||||||
|
new StringParameter(SciPublicPersonalProfile.OWNER);
|
||||||
|
SingleSelect ownerSelect = new SingleSelect(ownerModel);
|
||||||
|
ownerSelect.addValidationListener(new NotNullValidationListener());
|
||||||
|
DataCollection persons = SessionManager.getSession().retrieve(
|
||||||
|
SciMember.BASE_DATA_OBJECT_TYPE);
|
||||||
|
persons.addFilter("profile is null");
|
||||||
|
while (persons.next()) {
|
||||||
|
SciMember member =
|
||||||
|
(SciMember) DomainObjectFactory.newInstance(persons.
|
||||||
|
getDataObject());
|
||||||
|
ownerSelect.addOption(new Option(member.getID().toString(), member.
|
||||||
|
getFullName()));
|
||||||
|
}
|
||||||
|
add(ownerSelect);
|
||||||
|
|
||||||
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
|
add(new Label(GlobalizationUtil.globalize(
|
||||||
|
"cms.ui.authoring.page_launch_date")));
|
||||||
|
ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE);
|
||||||
|
com.arsdigita.bebop.form.Date launchDate =
|
||||||
|
new com.arsdigita.bebop.form.Date(
|
||||||
|
launchDateParam);
|
||||||
|
if (ContentSection.getConfig().getRequireLaunchDate()) {
|
||||||
|
launchDate.addValidationListener(
|
||||||
|
new LaunchDateValidationListener());
|
||||||
|
// if launch date is required, help user by suggesting today's date
|
||||||
|
launchDateParam.setDefaultValue(new Date());
|
||||||
|
}
|
||||||
|
add(launchDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
Folder folder = m_parent.getFolder(fse.getPageState());
|
||||||
|
Assert.exists(folder);
|
||||||
|
String id = (String) fse.getFormData().get(
|
||||||
|
SciPublicPersonalProfile.OWNER);
|
||||||
|
|
||||||
|
SciMember owner = new SciMember(new BigDecimal(id));
|
||||||
|
|
||||||
|
validateNameUniqueness(folder,
|
||||||
|
fse,
|
||||||
|
String.format("%s-profile",
|
||||||
|
SciMember.urlSave(
|
||||||
|
owner.getFullName())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
final FormData data = fse.getFormData();
|
||||||
|
final PageState state = fse.getPageState();
|
||||||
|
final ContentSection section = m_parent.getContentSection(state);
|
||||||
|
final Folder folder = m_parent.getFolder(state);
|
||||||
|
|
||||||
|
Assert.exists(section, ContentSection.class);
|
||||||
|
|
||||||
|
String id = (String) fse.getFormData().get(
|
||||||
|
SciPublicPersonalProfile.OWNER);
|
||||||
|
|
||||||
|
SciMember owner = new SciMember(new BigDecimal(id));
|
||||||
|
String name = String.format("%s-profile",
|
||||||
|
SciMember.urlSave(owner.getFullName()));
|
||||||
|
String title = String.format("%s (Profil)", owner.getFullName());
|
||||||
|
|
||||||
|
final ContentPage item = createContentPage(state);
|
||||||
|
item.setLanguage((String) data.get(LANGUAGE));
|
||||||
|
item.setName(name);
|
||||||
|
item.setTitle(title);
|
||||||
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
|
item.setLaunchDate((Date) data.get(LAUNCH_DATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
final ContentBundle bundle = new ContentBundle(item);
|
||||||
|
bundle.setParent(folder);
|
||||||
|
bundle.setContentSection(m_parent.getContentSection(state));
|
||||||
|
bundle.save();
|
||||||
|
|
||||||
|
SciPublicPersonalProfile profile = new SciPublicPersonalProfile(item.getOID());
|
||||||
|
profile.setOwner(owner);
|
||||||
|
profile.save();
|
||||||
|
|
||||||
|
m_parent.editItem(state, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,11 +10,8 @@ import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ContentType;
|
|
||||||
import com.arsdigita.cms.ItemSelectionModel;
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
import com.arsdigita.cms.contenttypes.SciMember;
|
|
||||||
import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile;
|
import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile;
|
||||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
|
||||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -27,9 +24,7 @@ public class SciPublicPersonalProfilePropertyForm
|
||||||
implements FormProcessListener,
|
implements FormProcessListener,
|
||||||
FormInitListener {
|
FormInitListener {
|
||||||
|
|
||||||
private SciPublicPersonalProfilePropertiesStep step;
|
private SciPublicPersonalProfilePropertiesStep step;
|
||||||
private ItemSearchWidget itemSearch;
|
|
||||||
private final String ITEM_SEARCH = "owner";
|
|
||||||
public static final String ID = "SciPublicPersonalProfile_edit";
|
public static final String ID = "SciPublicPersonalProfile_edit";
|
||||||
|
|
||||||
public SciPublicPersonalProfilePropertyForm(ItemSelectionModel itemModel) {
|
public SciPublicPersonalProfilePropertyForm(ItemSelectionModel itemModel) {
|
||||||
|
|
@ -46,13 +41,7 @@ public class SciPublicPersonalProfilePropertyForm
|
||||||
@Override
|
@Override
|
||||||
public void addWidgets() {
|
public void addWidgets() {
|
||||||
super.addWidgets();
|
super.addWidgets();
|
||||||
|
|
||||||
add(new Label(SciPublicPersonalProfileGlobalizationUtil.globalize(
|
|
||||||
"scipublicpersonalprofile.ui.profile.owner")));
|
|
||||||
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
|
|
||||||
findByAssociatedObjectType(SciMember.class.getName()));
|
|
||||||
add(itemSearch);
|
|
||||||
|
|
||||||
add(new Label(SciPublicPersonalProfileGlobalizationUtil.globalize(
|
add(new Label(SciPublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
"scipublicpersonalprofile.ui.profile.url")));
|
"scipublicpersonalprofile.ui.profile.url")));
|
||||||
ParameterModel profileUrlParam =
|
ParameterModel profileUrlParam =
|
||||||
|
|
@ -81,25 +70,11 @@ public class SciPublicPersonalProfilePropertyForm
|
||||||
final PageState state = fse.getPageState();
|
final PageState state = fse.getPageState();
|
||||||
|
|
||||||
if ((profile != null)
|
if ((profile != null)
|
||||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||||
SciMember owner = (SciMember) data.get(ITEM_SEARCH);
|
|
||||||
profile.setOwner(owner);
|
|
||||||
|
|
||||||
profile.setProfileUrl((String) data.get(
|
profile.setProfileUrl((String) data.get(
|
||||||
SciPublicPersonalProfile.PROFILE_URL));
|
SciPublicPersonalProfile.PROFILE_URL));
|
||||||
|
|
||||||
profile.save();
|
profile.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validate(FormSectionEvent fse) throws FormProcessException {
|
|
||||||
final PageState state = fse.getPageState();
|
|
||||||
final FormData data = fse.getFormData();
|
|
||||||
|
|
||||||
if (data.get(ITEM_SEARCH) == null) {
|
|
||||||
data.addError(SciPublicPersonalProfileGlobalizationUtil.globalize(
|
|
||||||
"scipublicpersonalprofile.ui.profile.missing_owner"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue