Korrekturen für Admin-Oberfläche PublicPersonalProfile
git-svn-id: https://svn.libreccm.org/ccm/trunk@1087 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
4c07fd2cb5
commit
ffa87f230e
|
|
@ -7,6 +7,8 @@ import com.arsdigita.bebop.FormSection;
|
||||||
import com.arsdigita.bebop.Page;
|
import com.arsdigita.bebop.Page;
|
||||||
import com.arsdigita.bebop.PageFactory;
|
import com.arsdigita.bebop.PageFactory;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.cms.ContentItem;
|
import com.arsdigita.cms.ContentItem;
|
||||||
import com.arsdigita.cms.contentassets.RelatedLink;
|
import com.arsdigita.cms.contentassets.RelatedLink;
|
||||||
import com.arsdigita.cms.contenttypes.GenericAddress;
|
import com.arsdigita.cms.contenttypes.GenericAddress;
|
||||||
|
|
@ -522,14 +524,22 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
page.setClassAttr("adminPage");
|
page.setClassAttr("adminPage");
|
||||||
|
|
||||||
|
final StringParameter navItemKeyParam = new StringParameter(
|
||||||
|
"selectedNavItem");
|
||||||
|
final ParameterSingleSelectionModel navItemSelect =
|
||||||
|
new ParameterSingleSelectionModel(
|
||||||
|
navItemKeyParam);
|
||||||
|
|
||||||
|
page.addGlobalStateParam(navItemKeyParam);
|
||||||
|
|
||||||
final BoxPanel box = new BoxPanel(BoxPanel.VERTICAL);
|
final BoxPanel box = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
final FormSection tableSection = new FormSection(box);
|
final FormSection tableSection = new FormSection(box);
|
||||||
|
|
||||||
final PublicPersonalProfileNavItemsAddForm addForm =
|
final PublicPersonalProfileNavItemsAddForm addForm =
|
||||||
new PublicPersonalProfileNavItemsAddForm();
|
new PublicPersonalProfileNavItemsAddForm(navItemSelect);
|
||||||
final PublicPersonalProfileNavItemsTable table =
|
final PublicPersonalProfileNavItemsTable table =
|
||||||
new PublicPersonalProfileNavItemsTable(
|
new PublicPersonalProfileNavItemsTable(
|
||||||
addForm);
|
navItemSelect);
|
||||||
|
|
||||||
box.add(table);
|
box.add(table);
|
||||||
form.add(tableSection);
|
form.add(tableSection);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.arsdigita.bebop.FormProcessException;
|
||||||
import com.arsdigita.bebop.FormSection;
|
import com.arsdigita.bebop.FormSection;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
import com.arsdigita.bebop.SaveCancelSection;
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
import com.arsdigita.bebop.event.FormProcessListener;
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
|
@ -48,11 +49,14 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
|
|
||||||
private final FormSection widgetSection;
|
private final FormSection widgetSection;
|
||||||
private final SaveCancelSection saveCancelSection;
|
private final SaveCancelSection saveCancelSection;
|
||||||
private PublicPersonalProfileNavItem selected;
|
private final ParameterSingleSelectionModel navItemSelect;
|
||||||
|
|
||||||
public PublicPersonalProfileNavItemsAddForm() {
|
public PublicPersonalProfileNavItemsAddForm(
|
||||||
|
final ParameterSingleSelectionModel navItemSelect) {
|
||||||
super(new ColumnPanel(2));
|
super(new ColumnPanel(2));
|
||||||
|
|
||||||
|
this.navItemSelect = navItemSelect;
|
||||||
|
|
||||||
widgetSection = new FormSection(new ColumnPanel(2, true));
|
widgetSection = new FormSection(new ColumnPanel(2, true));
|
||||||
super.add(widgetSection, ColumnPanel.INSERT);
|
super.add(widgetSection, ColumnPanel.INSERT);
|
||||||
|
|
||||||
|
|
@ -124,12 +128,30 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
final FormData data = fse.getFormData();
|
final FormData data = fse.getFormData();
|
||||||
final PageState state = fse.getPageState();
|
final PageState state = fse.getPageState();
|
||||||
|
|
||||||
if (selected == null) {
|
if (navItemSelect.getSelectedKey(state) == null) {
|
||||||
data.put(PublicPersonalProfileNavItem.KEY, "");
|
data.put(PublicPersonalProfileNavItem.KEY, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LANG, "");
|
data.put(PublicPersonalProfileNavItem.LANG, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
||||||
data.put(PublicPersonalProfileNavItem.GENERATOR_CLASS, "");
|
data.put(PublicPersonalProfileNavItem.GENERATOR_CLASS, "");
|
||||||
} else {
|
} else {
|
||||||
|
PublicPersonalProfileNavItemCollection navItems =
|
||||||
|
new PublicPersonalProfileNavItemCollection();
|
||||||
|
navItems.addFilter(
|
||||||
|
String.format("navItemId = %s",
|
||||||
|
navItemSelect.getSelectedKey(state).
|
||||||
|
toString()));
|
||||||
|
|
||||||
|
if (navItems.size() == 0) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
String.format("No nav item with id '%s' found.",
|
||||||
|
navItemSelect.getSelectedKey(
|
||||||
|
state).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
navItems.next();
|
||||||
|
PublicPersonalProfileNavItem selected = navItems.getNavItem();
|
||||||
|
navItems.close();
|
||||||
|
|
||||||
data.put(PublicPersonalProfileNavItem.KEY,
|
data.put(PublicPersonalProfileNavItem.KEY,
|
||||||
selected.getKey());
|
selected.getKey());
|
||||||
data.put(PublicPersonalProfileNavItem.LANG,
|
data.put(PublicPersonalProfileNavItem.LANG,
|
||||||
|
|
@ -160,10 +182,8 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
new ArrayList<PublicPersonalProfileNavItem>(navItemMap.
|
new ArrayList<PublicPersonalProfileNavItem>(navItemMap.
|
||||||
values());
|
values());
|
||||||
|
|
||||||
final int numberOfKeys = navItemMap.size();
|
|
||||||
|
|
||||||
PublicPersonalProfileNavItem item;
|
PublicPersonalProfileNavItem item;
|
||||||
if (selected == null) {
|
if (navItemSelect.getSelectedKey(state) == null) {
|
||||||
item = new PublicPersonalProfileNavItem();
|
item = new PublicPersonalProfileNavItem();
|
||||||
Collections.sort(navItemsList,
|
Collections.sort(navItemsList,
|
||||||
new Comparator<PublicPersonalProfileNavItem>() {
|
new Comparator<PublicPersonalProfileNavItem>() {
|
||||||
|
|
@ -173,10 +193,30 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
return item1.getId().compareTo(item2.getId());
|
return item1.getId().compareTo(item2.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
item.setId(navItemsList.get(navItemsList.size() - 1).getId().add(
|
if (navItemsList.size() > 0) {
|
||||||
|
item.setId(navItemsList.get(navItemsList.size() - 1).getId().
|
||||||
|
add(
|
||||||
BigDecimal.ONE));
|
BigDecimal.ONE));
|
||||||
} else {
|
} else {
|
||||||
item = selected;
|
item.setId(BigDecimal.ONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
navItems.reset();
|
||||||
|
navItems.addFilter(
|
||||||
|
String.format("navItemId = %s",
|
||||||
|
navItemSelect.getSelectedKey(state).
|
||||||
|
toString()));
|
||||||
|
|
||||||
|
if (navItems.size() == 0) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
String.format("No nav item with id '%s' found.",
|
||||||
|
navItemSelect.getSelectedKey(
|
||||||
|
state).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
navItems.next();
|
||||||
|
item = navItems.getNavItem();
|
||||||
|
navItems.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
item.setKey((String) data.get(PublicPersonalProfileNavItem.KEY));
|
item.setKey((String) data.get(PublicPersonalProfileNavItem.KEY));
|
||||||
|
|
@ -198,8 +238,13 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
return item1.getOrder().compareTo(item2.getOrder());
|
return item1.getOrder().compareTo(item2.getOrder());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
item.setOrder(navItemsList.get(navItemsList.size() - 1).getOrder()
|
if (navItemsList.size() > 0) {
|
||||||
|
item.setOrder(navItemsList.get(navItemsList.size() - 1).
|
||||||
|
getOrder()
|
||||||
+ 1);
|
+ 1);
|
||||||
|
} else {
|
||||||
|
item.setOrder(1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
item.setOrder(navItem.getOrder());
|
item.setOrder(navItem.getOrder());
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +252,7 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
item.save();
|
item.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selected = null;
|
navItemSelect.clearSelection(state);
|
||||||
data.put(PublicPersonalProfileNavItem.KEY, "");
|
data.put(PublicPersonalProfileNavItem.KEY, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LANG, "");
|
data.put(PublicPersonalProfileNavItem.LANG, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
||||||
|
|
@ -226,16 +271,11 @@ public class PublicPersonalProfileNavItemsAddForm
|
||||||
final FormData data = fse.getFormData();
|
final FormData data = fse.getFormData();
|
||||||
|
|
||||||
if (saveCancelSection.getCancelButton().isSelected(state)) {
|
if (saveCancelSection.getCancelButton().isSelected(state)) {
|
||||||
this.selected = null;
|
navItemSelect.clearSelection(state);
|
||||||
data.put(PublicPersonalProfileNavItem.KEY, "");
|
data.put(PublicPersonalProfileNavItem.KEY, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LANG, "");
|
data.put(PublicPersonalProfileNavItem.LANG, "");
|
||||||
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
data.put(PublicPersonalProfileNavItem.LABEL, "");
|
||||||
data.put(PublicPersonalProfileNavItem.GENERATOR_CLASS, "");
|
data.put(PublicPersonalProfileNavItem.GENERATOR_CLASS, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setSelectedNavItem(
|
|
||||||
final PublicPersonalProfileNavItem selected) {
|
|
||||||
this.selected = selected;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.ControlLink;
|
import com.arsdigita.bebop.ControlLink;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||||
import com.arsdigita.bebop.Table;
|
import com.arsdigita.bebop.Table;
|
||||||
import com.arsdigita.bebop.event.TableActionEvent;
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
import com.arsdigita.bebop.event.TableActionListener;
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
|
@ -33,12 +34,12 @@ public class PublicPersonalProfileNavItemsTable
|
||||||
private final static String TABLE_COL_DOWN = "table_col_down";
|
private final static String TABLE_COL_DOWN = "table_col_down";
|
||||||
private final static String TABLE_COL_DELETE = "table_col_delete";
|
private final static String TABLE_COL_DELETE = "table_col_delete";
|
||||||
private final static String TABLE_COL_EDIT = "table_col_edit";
|
private final static String TABLE_COL_EDIT = "table_col_edit";
|
||||||
private final PublicPersonalProfileNavItemsAddForm addForm;
|
private final ParameterSingleSelectionModel navItemSelect;
|
||||||
|
|
||||||
public PublicPersonalProfileNavItemsTable(
|
public PublicPersonalProfileNavItemsTable(
|
||||||
final PublicPersonalProfileNavItemsAddForm addForm) {
|
final ParameterSingleSelectionModel navItemSelect) {
|
||||||
|
|
||||||
this.addForm = addForm;
|
this.navItemSelect = navItemSelect;
|
||||||
|
|
||||||
setEmptyView(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
setEmptyView(new Label(PublicPersonalProfileGlobalizationUtil.globalize(
|
||||||
"publicpersonalprofile.ui.no_nav_items")));
|
"publicpersonalprofile.ui.no_nav_items")));
|
||||||
|
|
@ -294,7 +295,7 @@ public class PublicPersonalProfileNavItemsTable
|
||||||
intValue());
|
intValue());
|
||||||
|
|
||||||
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||||
addForm.setSelectedNavItem(navItem);
|
navItemSelect.setSelectedKey(state, navItem.getId());
|
||||||
} else if (TABLE_COL_DELETE.equals(column.getHeaderKey().toString())) {
|
} else if (TABLE_COL_DELETE.equals(column.getHeaderKey().toString())) {
|
||||||
navItem.delete();
|
navItem.delete();
|
||||||
} else if (TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
|
} else if (TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue