- ItemSearchWidget aktueller Stand

- Testweise Integration der neuen Features in PublicationAuthorAddForm


git-svn-id: https://svn.libreccm.org/ccm/trunk@1769 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-07-15 10:20:10 +00:00
parent fc69327e92
commit 2e137a3c94
5 changed files with 69 additions and 30 deletions

View File

@ -29,5 +29,4 @@ package com.arsdigita.cms;
public interface PageLocations {
public String SECTION_PAGE = "admin/index.jsp";
public String ITEM_PAGE = "admin/item.jsp";
public String ITEM_SEARCH_ITEM_PAGE = "admin/itemsearchitem.jsp";
}

View File

@ -54,6 +54,7 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
public static final String WIDGET_PARAM = "widget";
public static final String SEARCHWIDGET_PARAM = "searchWidget";
public static final String PUBLISHWIDGET_PARAM = "publishWidget";
private static final String CONTENT_TYPE_ID = "ct";
private static final String FOLDER_ID = "folder_id";
private final NewItemForm m_newItem;
@ -156,15 +157,19 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
final String widget = (String) state.getValue(new StringParameter(WIDGET_PARAM));
final String searchWidget = (String) state.getValue(new StringParameter(SEARCHWIDGET_PARAM));
final String publishWidget = (String) state.getValue(new StringParameter(PUBLISHWIDGET_PARAM));
target.setOnClick(String.format("window.opener.document.%s.value=\"%s\";"
+ "window.opener.document.%s.value=\"%s\";"
+ "window.opener.document.%s.value=\"%s\";"
+ "self.close();"
+ "return false;",
widget,
item.getID().toString(),
searchWidget,
title));
title,
publishWidget,
Boolean.TRUE.toString()));
}
});
@ -187,6 +192,7 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
final String widget = (String) state.getValue(new StringParameter(WIDGET_PARAM));
final String searchWidget = (String) state.getValue(new StringParameter(SEARCHWIDGET_PARAM));
final String publishWidget = (String) state.getValue(new StringParameter(PUBLISHWIDGET_PARAM));
final ContentSection section = item.getContentSection();
final String nodeURL = section.getPath() + "/";
@ -194,11 +200,14 @@ class ItemSearchCreateItemPane extends CMSContainer implements FormProcessListen
ContentItemPage.AUTHORING_TAB, true);
target.setTarget(linkTarget);
target.setOnClick(String.format("window.opener.document.%s.value=\"%s\";"
+ "window.opener.document.%s.value=\"%s\";"
+ "window.opener.document.%s.value=\"%s\";",
widget,
item.getID().toString(),
searchWidget,
title));
title,
publishWidget,
Boolean.TRUE.toString()));
}

View File

@ -78,6 +78,7 @@ public class ItemSearchPage extends CMSPage {
addGlobalStateParam(new BigDecimalParameter(ItemSearch.SINGLE_TYPE_PARAM));
addGlobalStateParam(new StringParameter(ItemSearchPopup.WIDGET_PARAM));
addGlobalStateParam(new StringParameter("searchWidget"));
addGlobalStateParam(new StringParameter("publishWidget"));
m_sectionId = new BigDecimalParameter(CONTENT_SECTION);
addGlobalStateParam(m_sectionId);

View File

@ -268,7 +268,7 @@ public class ItemSearchWidget extends FormSection
if (typeURLFrag != null) {
params.setParameter("single_type", typeURLFrag);
}
params.setParameter("publishWidget", formName + ".elements['" + m_publish.getName() + "']");
String searchURL = WorkspaceServlet.getURLStubForClass(
ItemSearchPage.class.getName());
@ -286,10 +286,18 @@ public class ItemSearchWidget extends FormSection
//+ m_item.getName().replace('.', '_')
+ m_selected.getName().replace('.', '_')
+ "Popup(theForm) { \n"
+ "var width = screen.width * 0.5;\n"
+ "var height = screen.height * 0.5;\n"
+ "if ((width < 800) && (screen.width >= 800)) {\n"
+ "width = 800;\n"
+ "}\n"
+ "if ((height < 600) && (screen.height >= 600)) {\n"
+ "height = 600;\n"
+ "}\n"
+ " aWindow = window.open(\"" + url + "&query=\" + document.getElementById('" + m_item.
getName() + "').value , "
//+ "\"search\", \"toolbar=no,width=800,height=600,status=no,scrollbars=yes,resize=yes\");\n"
+ "\"search\", \"toolbar=yes,width=\" + screen.width*0.5 + \",height=\" + screen.height*0.5 + \",status=no,scrollbars=yes,resize=yes\");\n "
+ "\"search\", \"toolbar=no,width=\" + width + \",height=\" + height + \",status=no,scrollbars=yes,resize=yes\");\n "
+ "return false;\n"
+ " } \n"
+ " --> \n"
@ -373,7 +381,7 @@ public class ItemSearchWidget extends FormSection
m_topHR.setVisible(s, false);
m_bottomHR.setVisible(s, false);
m_search.setVisible(s, true);
e.getFormData().put(PUBLISH, Boolean.TRUE.toString());
e.getFormData().put(PUBLISH, Boolean.FALSE.toString());
} catch (IllegalStateException ex) {
// component is in metaform. nothing to do here. Custom generateXML must hide for us
}

View File

@ -30,14 +30,21 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.form.CheckboxGroup;
import com.arsdigita.bebop.form.Option;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.lifecycle.Lifecycle;
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.workflow.simple.TaskException;
import com.arsdigita.workflow.simple.Workflow;
import java.util.Date;
import java.util.logging.Level;
import org.apache.log4j.Logger;
/**
@ -75,8 +82,7 @@ public class PublicationAuthorAddForm
"publications.ui.authors.selectAuthor").localize()));
m_itemSearch = new ItemSearchWidget(
ITEM_SEARCH,
ContentType.findByAssociatedObjectType(GenericPerson.class.
getName()));
ContentType.findByAssociatedObjectType(GenericPerson.class.getName()));
add(m_itemSearch);
selectedAuthorLabel = new Label("");
@ -98,8 +104,7 @@ public class PublicationAuthorAddForm
Boolean editor;
author = ((PublicationAuthorsPropertyStep) editStep).getSelectedAuthor();
editor = ((PublicationAuthorsPropertyStep) editStep).
isSelectedAuthorEditor();
editor = ((PublicationAuthorsPropertyStep) editStep).isSelectedAuthorEditor();
if (author == null) {
s_log.warn("No author selected.");
@ -134,8 +139,7 @@ public class PublicationAuthorAddForm
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
GenericPerson author;
author = ((PublicationAuthorsPropertyStep) editStep).
getSelectedAuthor();
author = ((PublicationAuthorsPropertyStep) editStep).getSelectedAuthor();
Boolean editor;
@ -152,6 +156,25 @@ public class PublicationAuthorAddForm
getInstance(publication.getLanguage());
publication.addAuthor(authorToAdd, editor);
final String publishStr = data.getString(ItemSearchWidget.PUBLISH);
final Boolean publish = Boolean.valueOf(publishStr);
if (publish) {
final LifecycleDefinition lifecycleDef = ContentTypeLifecycleDefinition.getLifecycleDefinition(
authorToAdd.getContentSection(), authorToAdd.getContentType());
if (lifecycleDef == null) {
s_log.warn(String.format("Cannot publish item %s because it has no default lifecycle",
authorToAdd.getOID().toString()));
} else {
authorToAdd.publish(lifecycleDef, new Date());
authorToAdd.getLifecycle().start();
final Workflow workflow = Workflow.getObjectWorkflow(authorToAdd);
if (workflow != null) {
workflow.delete();
}
}
}
} else {
AuthorshipCollection authors;
@ -167,8 +190,7 @@ public class PublicationAuthorAddForm
((PublicationAuthorsPropertyStep) editStep).setSelectedAuthor(
null);
((PublicationAuthorsPropertyStep) editStep).
setSelectedAuthorEditor(null);
((PublicationAuthorsPropertyStep) editStep).setSelectedAuthorEditor(null);
authors.close();
}
@ -208,8 +230,7 @@ public class PublicationAuthorAddForm
getSelectedObject(state);
GenericPerson author = (GenericPerson) data.get(ITEM_SEARCH);
if (author == null) {
author = ((PublicationAuthorsPropertyStep) editStep).
getSelectedAuthor();
author = ((PublicationAuthorsPropertyStep) editStep).getSelectedAuthor();
editing = true;
}
@ -234,4 +255,5 @@ public class PublicationAuthorAddForm
authors.close();
}
}
}