Weitere Einstellung "Sichtbar" für Kategorien (Ticket #1634). Dafür wird eine weitere Spalte in cat_categories benötigt. Upgrade-Skript enthalten.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2172 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-06-05 15:07:46 +00:00
parent 7125d102df
commit 4edddb7faa
12 changed files with 172 additions and 85 deletions

View File

@ -1120,3 +1120,5 @@ cms.ui.contentcenter.action=Action
cms.ui.set_home_folder=Set as home folder
cms.ui.go_to_home_folder=Go to home folder
cms.ui.no_home_folder_selected=No home folder selected
cms.ui.cateogry.is_visible=Visible?
cms.ui.category.is_visible=Visible?

View File

@ -1112,3 +1112,5 @@ cms.ui.contentcenter.action=Aktion
cms.ui.set_home_folder=Als Start-Ordner festlegen
cms.ui.go_to_home_folder=Zum Start-Ordner
cms.ui.no_home_folder_selected=Kein Start-Ordner festgelegt
cms.ui.cateogry.is_visible=Sichtbar?
cms.ui.category.is_visible=Sichtbar?

View File

@ -59,3 +59,5 @@ cms.ui.set_home_folder=Set as home folder
cms.ui.go_to_home_folder=Go to home folder
cms.ui.no_home_folder_selected=No home folder selected
cms.ui.contentcenter.action=Action
cms.ui.cateogry.is_visible=
cms.ui.category.is_visible=

View File

@ -590,3 +590,5 @@ cms.ui.contentcenter.action=
cms.ui.set_home_folder=Set as home folder
cms.ui.go_to_home_folder=
cms.ui.no_home_folder_selected=No home folder selected
cms.ui.cateogry.is_visible=
cms.ui.category.is_visible=

View File

@ -38,7 +38,6 @@ import com.arsdigita.xml.Element;
import org.apache.log4j.Logger;
/**
* A form which creates a new category. Extends the edit form for
* convenience.
@ -49,25 +48,23 @@ import org.apache.log4j.Logger;
* @version $Id: BaseCategoryForm.java 1951 2009-06-30 04:35:04Z terry $
*/
class BaseCategoryForm extends BaseForm {
private static final Logger s_log = Logger.getLogger
(BaseCategoryForm.class);
private static final Logger s_log = Logger.getLogger(BaseCategoryForm.class);
final CategoryRequestLocal m_parent;
final TextField m_name;
final TextArea m_description;
final TextField m_url;
final RadioGroup m_isAbstract;
final RadioGroup m_isVisible;
final RadioGroup m_isEnabled;
private Label m_script = new Label(
"<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>",
false);
private final static String NAME = "name";
private final static String DESCRIPTION = "description";
private final static String URL = "url";
private final static String IS_ABSTRACT = "isAbstract";
private final static String IS_VISIBLE = "isVisible";
private final static String IS_ENABLED = "isEnabled";
/**
@ -86,11 +83,9 @@ class BaseCategoryForm extends BaseForm {
m_name.setSize(30);
m_name.setMaxLength(200);
m_name.addValidationListener(new NotNullValidationListener());
m_name.setOnFocus("if (this.form." + URL + ".value == '') { " +
" defaulting = true; this.form." + URL +
".value = urlize(this.value); }");
m_name.setOnKeyUp("if (defaulting) { this.form." + URL +
".value = urlize(this.value) }");
m_name.setOnFocus("if (this.form." + URL + ".value == '') { " + " defaulting = true; this.form." + URL
+ ".value = urlize(this.value); }");
m_name.setOnKeyUp("if (defaulting) { this.form." + URL + ".value = urlize(this.value) }");
// is abstract?
m_isAbstract = new RadioGroup(IS_ABSTRACT);
@ -98,6 +93,12 @@ class BaseCategoryForm extends BaseForm {
m_isAbstract.addOption(new Option("yes", new Label(gz("cms.ui.yes"))));
addField(gz("cms.ui.category.is_not_abstract"), m_isAbstract);
// is visible
m_isVisible = new RadioGroup(IS_VISIBLE);
m_isVisible.addOption(new Option("no", new Label(gz("cms.ui.no"))));
m_isVisible.addOption(new Option("yes", new Label(gz("cms.ui.yes"))));
addField(gz("cms.ui.category.is_visible"), m_isVisible);
// is enabled?
m_isEnabled = new RadioGroup(IS_ENABLED);
m_isEnabled.addOption(new Option("no", new Label(gz("cms.ui.no"))));
@ -105,8 +106,7 @@ class BaseCategoryForm extends BaseForm {
addField(gz("cms.ui.category.is_enabled"), m_isEnabled);
m_description = new TextArea
(new TrimmedStringParameter(DESCRIPTION));
m_description = new TextArea(new TrimmedStringParameter(DESCRIPTION));
addField(gz("cms.ui.description"), m_description);
m_description.setWrap(TextArea.SOFT);
@ -130,10 +130,8 @@ class BaseCategoryForm extends BaseForm {
m_url.setMaxLength(200);
m_url.addValidationListener(new NotNullValidationListener());
m_url.setOnFocus("defaulting = false");
m_url.setOnBlur("if (this.value == '') " +
"{ defaulting = true; this.value = urlize(this.form." + NAME +
".value) } " +
"else { this.value = urlize(this.value); }");
m_url.setOnBlur("if (this.value == '') " + "{ defaulting = true; this.value = urlize(this.form." + NAME
+ ".value) } " + "else { this.value = urlize(this.value); }");
addField(gz("cms.ui.category.url"), m_url);
addAction(new Finish());
@ -146,6 +144,7 @@ class BaseCategoryForm extends BaseForm {
}
class NameUniqueListener implements ParameterListener {
private final CategoryRequestLocal m_category;
private final Widget m_widget;
private final int m_type;
@ -155,6 +154,7 @@ class BaseCategoryForm extends BaseForm {
NameUniqueListener(final CategoryRequestLocal category) {
this(category, m_name, NAME_FIELD);
}
NameUniqueListener(final CategoryRequestLocal category,
Widget widget, int type) {
m_category = category;
@ -178,10 +178,10 @@ class BaseCategoryForm extends BaseForm {
if (compField.equalsIgnoreCase(title)
&& (m_category == null
|| !m_category.getCategory(state).equals(child))) {
throw new FormProcessException
(lz("cms.ui.category.name_not_unique"));
throw new FormProcessException(lz("cms.ui.category.name_not_unique"));
}
}
}
}
}

View File

@ -35,9 +35,9 @@ import org.apache.log4j.Logger;
*/
final class CategoryEditForm extends BaseCategoryForm {
private static final Logger s_log = Logger.getLogger
(CategoryEditForm.class);
private static final Logger s_log = Logger.getLogger(CategoryEditForm.class);
private static final String NO = "no";
private static final String YES = "yes";
private final CategoryRequestLocal m_category;
public CategoryEditForm(final CategoryRequestLocal parent,
@ -54,6 +54,8 @@ final class CategoryEditForm extends BaseCategoryForm {
}
private class InitListener implements FormInitListener {
@Override
public final void init(final FormSectionEvent e)
throws FormProcessException {
final PageState state = e.getPageState();
@ -70,20 +72,30 @@ final class CategoryEditForm extends BaseCategoryForm {
// items in this category. If the user says "yes" then the
// category is not abstract
if (category.isAbstract()) {
m_isAbstract.setValue(state, "no");
m_isAbstract.setValue(state, NO);
} else {
m_isAbstract.setValue(state, "yes");
m_isAbstract.setValue(state, YES);
}
if (category.isEnabled("")) {
m_isEnabled.setValue(state, "yes");
if (category.isVisible()) {
m_isVisible.setValue(state, YES);
} else {
m_isEnabled.setValue(state, "no");
m_isVisible.setValue(state, NO);
}
if (category.isEnabled("")) {
m_isEnabled.setValue(state, YES);
} else {
m_isEnabled.setValue(state, NO);
}
}
}
private class ProcessListener implements FormProcessListener {
@Override
public final void process(final FormSectionEvent e)
throws FormProcessException {
final PageState state = e.getPageState();
@ -93,20 +105,28 @@ final class CategoryEditForm extends BaseCategoryForm {
category.setName((String) m_name.getValue(state));
category.setDescription((String) m_description.getValue(state));
category.setURL((String) m_url.getValue(state));
String isAbstract = (String)m_isAbstract.getValue(state);
final String isAbstract = (String) m_isAbstract.getValue(state);
// this seems anti-intuitive but the question is "can you place
// items in this category. If the user says "yes" then the
// category is not abstract
if ("yes".equals(isAbstract)) {
if (YES.equals(isAbstract)) {
category.setAbstract(false);
} else if ("no".equals(isAbstract)) {
} else if (NO.equals(isAbstract)) {
category.setAbstract(true);
}
String isEnabled = (String)m_isEnabled.getValue(state);
if ("yes".equals(isEnabled)) {
final String isVisible = (String) m_isVisible.getValue(state);
if (YES.equals(isVisible)) {
category.setVisible(true);
} else {
category.setVisible(false);
}
final String isEnabled = (String) m_isEnabled.getValue(state);
if (YES.equals(isEnabled)) {
category.setEnabled(true);
} else if ("no".equals(isEnabled)) {
} else if (NO.equals(isEnabled)) {
category.setEnabled(false);
}
@ -115,5 +135,6 @@ final class CategoryEditForm extends BaseCategoryForm {
throw new AccessDeniedException();
}
}
}
}

View File

@ -106,12 +106,14 @@ class CategoryItemPane extends BaseItemPane {
if (!super.isVisible(state)) {
return false;
}
CategorizedCollection items = m_category.getCategory(state).getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
CategorizedCollection items = m_category.getCategory(state).
getObjects(ContentItem.BASE_DATA_OBJECT_TYPE);
items.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
boolean canOrder = items.size() > 1;
items.close();
return canOrder;
}
};
@ -155,6 +157,7 @@ class CategoryItemPane extends BaseItemPane {
return false;
}
}
};
CategoryLocalizationAddForm addCategoryLocalizationForm =
@ -203,6 +206,7 @@ class CategoryItemPane extends BaseItemPane {
public boolean hasPermission(PageState ps) {
return m_category.getCategory(ps).canEdit();
}
}
private class AdminVisible extends VisibilityComponent {
@ -215,6 +219,7 @@ class CategoryItemPane extends BaseItemPane {
public boolean hasPermission(PageState ps) {
return m_category.getCategory(ps).canAdmin();
}
}
private class SummarySection extends Section {
@ -298,6 +303,10 @@ class CategoryItemPane extends BaseItemPane {
category.isAbstract()
? gz("cms.ui.no")
: gz("cms.ui.yes")));
props.add(new Property(gz("cms.ui.cateogry.is_visible"),
category.isVisible()
? gz("cms.ui.yes")
: gz("cms.ui.no")));
props.add(new Property(gz("cms.ui.category.is_enabled"),
category.isEnabled("")
? gz("cms.ui.yes")
@ -307,6 +316,7 @@ class CategoryItemPane extends BaseItemPane {
return props;
}
}
}
@ -362,6 +372,7 @@ class CategoryItemPane extends BaseItemPane {
super.register(page);
page.addComponentStateParam(m_editCategoryLocalizationForm, m_catLocaleParam);
}
}
private class SubcategorySection extends Section {
@ -375,6 +386,7 @@ class CategoryItemPane extends BaseItemPane {
group.setSubject(new SubcategoryList(m_category, m_model));
group.addAction(new AdminVisible(addLink), ActionGroup.ADD);
}
}
private class LinkedCategorySection extends Section {
@ -393,6 +405,7 @@ class CategoryItemPane extends BaseItemPane {
public final boolean isVisible(final PageState state) {
return !m_category.getCategory(state).isRoot();
}
}
private class CategoryTemplateSection extends Section {
@ -407,6 +420,7 @@ class CategoryItemPane extends BaseItemPane {
// XXX secvis
//group.addAction(link);
}
}
private class PermissionsSection extends Section {
@ -436,7 +450,8 @@ class CategoryItemPane extends BaseItemPane {
privMap.put(Category.MAP_DESCRIPTOR.getName(), "Categorize Items");
privMap.put("admin", "Admin");
final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap, new ACSObjectSelectionModel(m_model)) {
final CMSPermissionsPane permPane = new CMSPermissionsPane(privs, privMap, new ACSObjectSelectionModel(
m_model)) {
@Override
public void showAdmin(PageState ps) {
Assert.exists(m_model.getSelectedKey(ps));
@ -444,6 +459,7 @@ class CategoryItemPane extends BaseItemPane {
super.showAdmin(ps);
getAdminListingPanel().setVisible(ps, false);
}
};
final ActionLink restoreDefault = new ActionLink(new Label(gz(
@ -453,6 +469,7 @@ class CategoryItemPane extends BaseItemPane {
Category cat = m_category.getCategory(ps);
return PermissionService.getContext(cat) == null;
}
};
final ActionLink useCustom = new ActionLink(new Label(gz(
@ -462,6 +479,7 @@ class CategoryItemPane extends BaseItemPane {
Category cat = m_category.getCategory(ps);
return PermissionService.getContext(cat) != null;
}
};
ActionListener al = new ActionListener() {
@ -500,6 +518,7 @@ class CategoryItemPane extends BaseItemPane {
}
permPane.reset(state);
}
};
restoreDefault.addActionListener(al);
@ -516,8 +535,10 @@ class CategoryItemPane extends BaseItemPane {
public void stateChanged(ChangeEvent e) {
PageState ps = e.getPageState();
}
});
}
}
private static class OrderItemsForm extends CMSForm {
@ -532,6 +553,7 @@ class CategoryItemPane extends BaseItemPane {
add(new Submit("Done"));
}
}
/*
@ -571,6 +593,7 @@ class CategoryItemPane extends BaseItemPane {
return true;
}
}
};
private class EditItemLink extends Link {
@ -648,5 +671,6 @@ class CategoryItemPane extends BaseItemPane {
}
return false;
}
};
}

View File

@ -28,7 +28,7 @@ object type Category extends ACSObject {
String[1..1] name = cat_categories.name VARCHAR(200);
String[0..1] url = cat_categories.url VARCHAR(200);
Boolean[1..1] isEnabled = cat_categories.enabled_p CHAR(1);
Boolean[1..1] isVisible = cat_categories.visible_p CHAR(1);
Boolean[1..1] isAbstract = cat_categories.abstract_p CHAR(1);
String[1..1] defaultAncestors = cat_categories.default_ancestors VARCHAR(3209);
Boolean[1..1] ignoreParentIndexItem = cat_categories.ignore_parent_index_p CHAR(1);

View File

@ -0,0 +1,21 @@
--
-- Copyright (C) 2013 Jens Pelzetter. All Rights Reserved.
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public License
-- as published by the Free Software Foundation; either version 2.1 of
-- the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- $Id$
ALTER TABLE cat_categories ADD COLUMN visible_p CHAR(1);
UPDATE cat_categories SET visible_p = 1;

View File

@ -1,5 +1,5 @@
--
-- Copyright (C) 2013 Peter Boy. All Rights Reserved.
-- Copyright (C) 2013 Jens Pelzetter. All Rights Reserved.
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public License

View File

@ -25,6 +25,6 @@
begin;
\i default/6.6.5-6.6.6/set_singleton.sql
\i default/6.6.5-6.6.6/add_cat_visible.sql
commit;

View File

@ -173,6 +173,7 @@ public class Category extends ACSObject {
* An attribute name for the underlying data object.
*/
public static final String IS_ENABLED = "isEnabled";
public static final String IS_VISIBLE = "isVisible";
/**
* An attribute name for the underlying data object.
*/
@ -213,6 +214,7 @@ public class Category extends ACSObject {
/**
* Returns the model name of {@link #BASE_DATA_OBJECT_TYPE}.
*
* @return
*/
public static String getBaseDataObjectPackage() {
return BASE_DATA_OBJECT_PACKAGE;
@ -290,6 +292,8 @@ public class Category extends ACSObject {
* storage mechanism. This method is just a wrapper for the {@link
* #Category(OID)} constructor.
*
* @param id
*
* @throws DataObjectNotFoundException
*/
public Category(BigDecimal id) {
@ -389,6 +393,7 @@ public class Category extends ACSObject {
setName("name me");
}
setEnabled(true);
setVisible(true);
setAbstract(false);
//by default do not ignore the parent index item
setIgnoreParentIndexItem(false);
@ -807,6 +812,14 @@ public class Category extends ACSObject {
set(IS_ENABLED, isEnabled);
}
public boolean isVisible() {
return ((Boolean) get(IS_VISIBLE)).booleanValue();
}
public void setVisible(final boolean visible) {
set(IS_VISIBLE, visible);
}
/**
* An abstract category cannot have any child objects, but it can have child
* categories.