Categories can now be moved using the category ui in the content center

git-svn-id: https://svn.libreccm.org/ccm/trunk@2493 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-01-22 13:46:56 +00:00
parent 1ecc9a57f1
commit f6d8bb92cf
7 changed files with 141 additions and 99 deletions

View File

@ -1064,3 +1064,6 @@ cms.ui.section.new_section_root_category=Root category of the new Content Sectio
cms.ui.admin_center=Admin Center cms.ui.admin_center=Admin Center
cms.contentasset.image.ui.display.dimensions=Dimensions (width x height): cms.contentasset.image.ui.display.dimensions=Dimensions (width x height):
cms.ui.remove_home_folder=Remove home folder cms.ui.remove_home_folder=Remove home folder
cms.ui.move.category=Move category "{0}" to
cms.ui.category.move=Move category
cms.ui.category.cantmoved=This category can't be moved

View File

@ -1058,3 +1058,6 @@ cms.ui.section.new_section_root_category=Kategoriensystem der neuen Content Sect
cms.ui.admin_center=Admin Center cms.ui.admin_center=Admin Center
cms.contentasset.image.ui.display.dimensions=Ma\u00dfe (Breite x H\u00f6he): cms.contentasset.image.ui.display.dimensions=Ma\u00dfe (Breite x H\u00f6he):
cms.ui.remove_home_folder=Start-Ordner zur\u00fccksetzen cms.ui.remove_home_folder=Start-Ordner zur\u00fccksetzen
cms.ui.move.category=Verschiebe Kategorie "{0}" nach
cms.ui.category.move=Kategorie verschieben
cms.ui.category.cantmoved=Diese Kategorie kann nicht verschoben werden

View File

@ -112,3 +112,6 @@ cms.ui.section.new_section_root_category=
cms.ui.admin_center=Admin Center cms.ui.admin_center=Admin Center
cms.contentasset.image.ui.display.dimensions=Dimensions (width x height): cms.contentasset.image.ui.display.dimensions=Dimensions (width x height):
cms.ui.remove_home_folder=Remove home folder cms.ui.remove_home_folder=Remove home folder
cms.ui.move.category=
cms.ui.category.move=
cms.ui.category.cantmoved=

View File

@ -586,3 +586,6 @@ cms.ui.section.new_section_root_category=
cms.ui.admin_center=Admin Center cms.ui.admin_center=Admin Center
cms.contentasset.image.ui.display.dimensions=Dimensions (width x height): cms.contentasset.image.ui.display.dimensions=Dimensions (width x height):
cms.ui.remove_home_folder= cms.ui.remove_home_folder=
cms.ui.move.category=
cms.ui.category.move=
cms.ui.category.cantmoved=

View File

@ -35,15 +35,10 @@ import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.permissions.PermissionDescriptor; import com.arsdigita.kernel.permissions.PermissionDescriptor;
import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor; import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.toolbox.ui.ActionGroup; import com.arsdigita.toolbox.ui.ActionGroup;
import com.arsdigita.toolbox.ui.DataQueryBuilder;
import com.arsdigita.toolbox.ui.Section; import com.arsdigita.toolbox.ui.Section;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.TooManyListenersException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -69,8 +64,6 @@ public final class CategoryAdminPane extends BaseAdminPane {
m_contextModel = new UseContextSelectionModel(new StringParameter(CONTEXT_SELECTED)); m_contextModel = new UseContextSelectionModel(new StringParameter(CONTEXT_SELECTED));
/* Left column */ /* Left column */
/* Use context section */ /* Use context section */
List list = new List(new CategoryUseContextModelBuilder()); List list = new List(new CategoryUseContextModelBuilder());
@ -82,7 +75,6 @@ public final class CategoryAdminPane extends BaseAdminPane {
m_categoryTree.addChangeListener(new SelectionListener()); m_categoryTree.addChangeListener(new SelectionListener());
m_model = m_categoryTree.getSelectionModel(); m_model = m_categoryTree.getSelectionModel();
setSelectionModel(m_model); setSelectionModel(m_model);
setSelector(m_categoryTree); setSelector(m_categoryTree);
@ -94,7 +86,8 @@ public final class CategoryAdminPane extends BaseAdminPane {
contextGroup.setSubject(list); contextGroup.setSubject(list);
if (CMS.getConfig().getAllowCategoryCreateUseContext()) { if (CMS.getConfig().getAllowCategoryCreateUseContext()) {
ActionLink addContextAction = new ActionLink(new Label(gz("cms.ui.category.add_use_context"))); ActionLink addContextAction = new ActionLink(new Label(gz(
"cms.ui.category.add_use_context")));
Form addContextForm = new AddUseContextForm(m_contextModel); Form addContextForm = new AddUseContextForm(m_contextModel);
getBody().add(addContextForm); getBody().add(addContextForm);
getBody().connect(addContextAction, addContextForm); getBody().connect(addContextAction, addContextForm);
@ -113,7 +106,6 @@ public final class CategoryAdminPane extends BaseAdminPane {
leftContainer.add(categorySection); leftContainer.add(categorySection);
setLeft(leftContainer); setLeft(leftContainer);
m_parent = new ParentRequestLocal(); m_parent = new ParentRequestLocal();
m_category = new SelectionRequestLocal(); m_category = new SelectionRequestLocal();
@ -123,11 +115,14 @@ public final class CategoryAdminPane extends BaseAdminPane {
setEdit(gz("cms.ui.category.edit"), setEdit(gz("cms.ui.category.edit"),
new CategoryEditForm(m_parent, m_category)); new CategoryEditForm(m_parent, m_category));
setDelete(new DeleteLink(new Label(gz("cms.ui.category.delete"))), new DeleteForm(new SimpleContainer())); setDelete(new DeleteLink(new Label(gz("cms.ui.category.delete"))), new DeleteForm(
new SimpleContainer()));
setIntroPane(new Label(gz("cms.ui.category.intro"))); setIntroPane(new Label(gz("cms.ui.category.intro")));
setItemPane(new CategoryItemPane(m_model, m_category, setItemPane(new CategoryItemPane(m_model,
getAddLink(), getEditLink(), m_category,
getAddLink(),
getEditLink(),
getDeleteLink())); getDeleteLink()));
//m_contextList = new List(new ContextListModelBuilder()); //m_contextList = new List(new ContextListModelBuilder());
@ -179,7 +174,6 @@ public final class CategoryAdminPane extends BaseAdminPane {
prompt.add(new Label(gz("cms.ui.category.delete_prompt"))); prompt.add(new Label(gz("cms.ui.category.delete_prompt")));
Label catLabel = new Label(); Label catLabel = new Label();
catLabel.addPrintListener(new PrintListener() { catLabel.addPrintListener(new PrintListener() {
public void prepare(PrintEvent pe) { public void prepare(PrintEvent pe) {
Label label = (Label) pe.getTarget(); Label label = (Label) pe.getTarget();
Category cat = Category cat =
@ -221,7 +215,8 @@ public final class CategoryAdminPane extends BaseAdminPane {
PermissionService.assertPermission(new PermissionDescriptor(PrivilegeDescriptor.DELETE, PermissionService.assertPermission(new PermissionDescriptor(PrivilegeDescriptor.DELETE,
category, category,
Kernel.getContext().getParty())); Kernel.getContext().
getParty()));
if (category.isRoot()) { if (category.isRoot()) {
Category root = Category root =

View File

@ -22,7 +22,6 @@ import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.BaseLink; import com.arsdigita.bebop.BaseLink;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormModel;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link; import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
@ -48,6 +47,7 @@ import com.arsdigita.cms.ui.ContentItemPage;
import com.arsdigita.cms.ui.VisibilityComponent; import com.arsdigita.cms.ui.VisibilityComponent;
import com.arsdigita.cms.ui.permissions.CMSPermissionsPane; import com.arsdigita.cms.ui.permissions.CMSPermissionsPane;
import com.arsdigita.cms.ui.templates.CategoryTemplates; import com.arsdigita.cms.ui.templates.CategoryTemplates;
import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.kernel.ACSObject; import com.arsdigita.kernel.ACSObject;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.User; import com.arsdigita.kernel.User;
@ -63,6 +63,7 @@ import com.arsdigita.toolbox.ui.PropertyList;
import com.arsdigita.toolbox.ui.Section; import com.arsdigita.toolbox.ui.Section;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import com.arsdigita.xml.Element;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -127,14 +128,24 @@ class CategoryItemPane extends BaseItemPane {
final Form indexForm = new IndexItemSelectionForm(m_category); final Form indexForm = new IndexItemSelectionForm(m_category);
add(indexForm); add(indexForm);
//Move link
final ActionLink moveLink = new MoveLink(new Label(gz("cms.ui.category.move")));
final Form moveForm = new CategoryMoveForm(m_category);
add(moveForm);
ViewItemLink viewIndexLink = new ViewItemLink(new Label(gz( ViewItemLink viewIndexLink = new ViewItemLink(new Label(gz(
"cms.ui.category.view_index_item")), ""); "cms.ui.category.view_index_item")), "");
EditItemLink editIndexLink = new EditItemLink(new Label(gz( EditItemLink editIndexLink = new EditItemLink(new Label(gz(
"cms.ui.category.edit_index_item")), ""); "cms.ui.category.edit_index_item")), "");
// Summary // Summary
m_detailPane.add(new SummarySection(editLink, deleteLink, indexLink, m_detailPane.add(new SummarySection(editLink,
viewIndexLink, editIndexLink, orderItemsLink)); deleteLink,
indexLink,
moveLink,
viewIndexLink,
editIndexLink,
orderItemsLink));
// Quasimodo: BEGIN // Quasimodo: BEGIN
// Localizations // Localizations
@ -190,6 +201,9 @@ class CategoryItemPane extends BaseItemPane {
connect(indexLink, indexForm); connect(indexLink, indexForm);
connect(indexForm); connect(indexForm);
connect(moveLink, moveForm);
connect(moveForm);
connect(orderItemsLink, orderItemsForm); connect(orderItemsLink, orderItemsForm);
connect(orderItemsForm); connect(orderItemsForm);
@ -226,6 +240,7 @@ class CategoryItemPane extends BaseItemPane {
SummarySection(final ActionLink editLink, SummarySection(final ActionLink editLink,
final ActionLink deleteLink, final ActionLink deleteLink,
final ActionLink indexLink, final ActionLink indexLink,
final ActionLink moveLink,
final ActionLink orderItemsLink) { final ActionLink orderItemsLink) {
setHeading(new Label(gz("cms.ui.category.details"))); setHeading(new Label(gz("cms.ui.category.details")));
@ -236,6 +251,7 @@ class CategoryItemPane extends BaseItemPane {
group.addAction(new EditVisible(editLink), ActionGroup.EDIT); group.addAction(new EditVisible(editLink), ActionGroup.EDIT);
group.addAction(new EditVisible(orderItemsLink)); group.addAction(new EditVisible(orderItemsLink));
group.addAction(new EditVisible(moveLink));
group.addAction(new EditVisible(indexLink)); group.addAction(new EditVisible(indexLink));
group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE); group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE);
} }
@ -247,6 +263,7 @@ class CategoryItemPane extends BaseItemPane {
SummarySection(final ActionLink editLink, SummarySection(final ActionLink editLink,
final ActionLink deleteLink, final ActionLink deleteLink,
final ActionLink indexLink, final ActionLink indexLink,
final ActionLink moveLink,
final BaseLink viewIndexItem, final BaseLink viewIndexItem,
final BaseLink editIndexItem, final BaseLink editIndexItem,
final ActionLink orderItemsLink) { final ActionLink orderItemsLink) {
@ -260,6 +277,7 @@ class CategoryItemPane extends BaseItemPane {
group.addAction(new EditVisible(editLink), ActionGroup.EDIT); group.addAction(new EditVisible(editLink), ActionGroup.EDIT);
group.addAction(new EditVisible(orderItemsLink)); group.addAction(new EditVisible(orderItemsLink));
group.addAction(new EditVisible(indexLink)); group.addAction(new EditVisible(indexLink));
group.addAction(new EditVisible(moveLink));
group.addAction(new EditVisible(viewIndexItem)); group.addAction(new EditVisible(viewIndexItem));
group.addAction(new EditVisible(editIndexItem)); group.addAction(new EditVisible(editIndexItem));
group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE); group.addAction(new AdminVisible(deleteLink), ActionGroup.DELETE);
@ -360,7 +378,8 @@ class CategoryItemPane extends BaseItemPane {
group.setSubject(m_catLocalizationTable); group.setSubject(m_catLocalizationTable);
group.addAction(new AdminVisible(addLink), ActionGroup.ADD); group.addAction(new AdminVisible(addLink), ActionGroup.ADD);
m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category, m_catLocale); m_editCategoryLocalizationForm = new CategoryLocalizationEditForm(m_category,
m_catLocale);
add(m_editCategoryLocalizationForm); add(m_editCategoryLocalizationForm);
connect(m_editCategoryLocalizationForm); connect(m_editCategoryLocalizationForm);
connect(m_catLocalizationTable, 0, m_editCategoryLocalizationForm); connect(m_catLocalizationTable, 0, m_editCategoryLocalizationForm);
@ -449,7 +468,8 @@ class CategoryItemPane extends BaseItemPane {
privMap.put(Category.MAP_DESCRIPTOR.getName(), "Categorize Items"); privMap.put(Category.MAP_DESCRIPTOR.getName(), "Categorize Items");
privMap.put("admin", "Admin"); privMap.put("admin", "Admin");
final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap, new ACSObjectSelectionModel( final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap,
new ACSObjectSelectionModel(
m_model)) { m_model)) {
@Override @Override
public void showAdmin(PageState ps) { public void showAdmin(PageState ps) {
@ -672,4 +692,29 @@ class CategoryItemPane extends BaseItemPane {
} }
}; };
private class MoveLink extends ActionLink {
private final Label alternativeLabel;
public MoveLink(final Label label) {
super(label);
alternativeLabel = new Label(GlobalizationUtil.globalize("cms.ui.category.cantmoved"));
}
@Override
public void generateXML(final PageState state, final Element parent) {
if (!isVisible(state)) {
return;
}
final Category category = m_category.getCategory(state);
if (category.isRoot()) {
alternativeLabel.generateXML(state, parent);
} else {
super.generateXML(state, parent);
}
}
}
} }

View File

@ -56,15 +56,14 @@ import java.math.BigDecimal;
* @version $Revision: #18 $ $DateTime: 2004/08/17 23:15:09 $ * @version $Revision: #18 $ $DateTime: 2004/08/17 23:15:09 $
*/ */
public class IndexItemSelectionForm extends CMSForm { public class IndexItemSelectionForm extends CMSForm {
private static org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(IndexItemSelectionForm.class);
private static org.apache.log4j.Logger s_log =
org.apache.log4j.Logger.getLogger(
IndexItemSelectionForm.class);
private final CategoryRequestLocal m_category; private final CategoryRequestLocal m_category;
private RadioGroup m_options; private RadioGroup m_options;
private static final String NULL_OPTION_VALUE = ""; private static final String NULL_OPTION_VALUE = "";
private static final String NONE_OPTION_VALUE = "None"; private static final String NONE_OPTION_VALUE = "None";
private FormErrorDisplay m_errors; private FormErrorDisplay m_errors;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
@ -75,8 +74,7 @@ public class IndexItemSelectionForm extends CMSForm {
m_category = m; m_category = m;
// Form header // Form header
Label header = new Label(GlobalizationUtil.globalize Label header = new Label(GlobalizationUtil.globalize("cms.ui.category.select_index_item"));
("cms.ui.category.select_index_item"));
header.setFontWeight(Label.BOLD); header.setFontWeight(Label.BOLD);
add(header, ColumnPanel.FULL_WIDTH); add(header, ColumnPanel.FULL_WIDTH);
@ -89,11 +87,11 @@ public class IndexItemSelectionForm extends CMSForm {
try { try {
m_options.addPrintListener(new PrintListener() { m_options.addPrintListener(new PrintListener() {
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
RadioGroup group = (RadioGroup)event.getTarget(); RadioGroup group = (RadioGroup) event.getTarget();
PageState state = event.getPageState(); PageState state = event.getPageState();
Category category = getCategory(event.getPageState()); Category category = getCategory(event.getPageState());
CategorizedCollection children = category.getObjects CategorizedCollection children = category.getObjects(
(ContentItem.BASE_DATA_OBJECT_TYPE); ContentItem.BASE_DATA_OBJECT_TYPE);
// option for NO index Object // option for NO index Object
group.addOption(new Option(NONE_OPTION_VALUE, group.addOption(new Option(NONE_OPTION_VALUE,
@ -101,8 +99,7 @@ public class IndexItemSelectionForm extends CMSForm {
// option for inheriting from the parent category // option for inheriting from the parent category
if (category.getParentCategoryCount() > 0) { if (category.getParentCategoryCount() > 0) {
group.addOption group.addOption(new Option(NULL_OPTION_VALUE,
(new Option(NULL_OPTION_VALUE,
new Label("Inherit Index from Parent Category"))); new Label("Inherit Index from Parent Category")));
} }
@ -110,12 +107,10 @@ public class IndexItemSelectionForm extends CMSForm {
ACSObject item = ACSObject item =
(ACSObject) children.getDomainObject(); (ACSObject) children.getDomainObject();
if ((item instanceof ContentItem) && if ((item instanceof ContentItem) && ((ContentItem) item).getVersion().
((ContentItem) item).getVersion().equals(ContentItem.DRAFT)) equals(ContentItem.DRAFT)) {
{ group.addOption(new Option(item.getID().toString(),
group.addOption ((ContentItem) item).getName()));
(new Option(item.getID().toString(),
((ContentItem)item).getName()));
} }
} }
// get currently selected item // get currently selected item
@ -127,13 +122,13 @@ public class IndexItemSelectionForm extends CMSForm {
} else { } else {
String value = NONE_OPTION_VALUE; String value = NONE_OPTION_VALUE;
if (!category.ignoreParentIndexItem() if (!category.ignoreParentIndexItem()
&& category.getParentCategoryCount() > 0) && category.getParentCategoryCount() > 0) {
{
value = NULL_OPTION_VALUE; value = NULL_OPTION_VALUE;
} }
group.setValue(state, value); group.setValue(state, value);
} }
} }
}); });
} catch (java.util.TooManyListenersException e) { } catch (java.util.TooManyListenersException e) {
s_log.error("Error adding init listener to Radio Group", e); s_log.error("Error adding init listener to Radio Group", e);
@ -146,8 +141,7 @@ public class IndexItemSelectionForm extends CMSForm {
m_saveCancelSection = new SaveCancelSection(); m_saveCancelSection = new SaveCancelSection();
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT); add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
addSubmissionListener addSubmissionListener(new FormSecurityListener(SecurityManager.CATEGORY_ADMIN));
(new FormSecurityListener(SecurityManager.CATEGORY_ADMIN));
// Process listener // Process listener
addProcessListener(new FormProcessListener() { addProcessListener(new FormProcessListener() {
@ -155,9 +149,8 @@ public class IndexItemSelectionForm extends CMSForm {
throws FormProcessException { throws FormProcessException {
PageState state = event.getPageState(); PageState state = event.getPageState();
FormData data = event.getFormData(); FormData data = event.getFormData();
ParameterData param = data.getParameter ParameterData param = data.getParameter(m_options.getParameterModel().getName());
(m_options.getParameterModel().getName()); String selectedValue = (String) param.getValue();
String selectedValue = (String)param.getValue();
Category category = Category category =
getCategory(event.getPageState()); getCategory(event.getPageState());
@ -167,24 +160,22 @@ public class IndexItemSelectionForm extends CMSForm {
if (NULL_OPTION_VALUE.equals(selectedValue)) { if (NULL_OPTION_VALUE.equals(selectedValue)) {
category.setIgnoreParentIndexItem(false); category.setIgnoreParentIndexItem(false);
selectedValue = null; selectedValue = null;
} } else if (NONE_OPTION_VALUE.equals(selectedValue)) {
else if(NONE_OPTION_VALUE.equals(selectedValue)) {
category.setIgnoreParentIndexItem(true); category.setIgnoreParentIndexItem(true);
selectedValue = null; selectedValue = null;
} else { } else {
item = new ContentItem item = new ContentItem(new BigDecimal(selectedValue));
(new BigDecimal(selectedValue)); item = item.getWorkingVersion();
item = item.getWorkingVersion ();
} }
} }
category.setIndexObject(item); category.setIndexObject(item);
category.save(); category.save();
} }
}); });
} }
/** /**
* Get the cancel button. * Get the cancel button.
* *
@ -194,7 +185,6 @@ public class IndexItemSelectionForm extends CMSForm {
return m_saveCancelSection.getCancelButton(); return m_saveCancelSection.getCancelButton();
} }
/** /**
* Fetch the selected category. * Fetch the selected category.
* *