Ajax picker enhancements and fixes. Ajax File Picker component implemented (ready for web-client collaboration UI). Ajax space/category pickers replace old JSF pickers in existing JSP pages. Advanced Search category selector now support multi-selection of categories.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7446 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-11-27 15:07:08 +00:00
parent 1d3647e0ba
commit ab0ef44804
32 changed files with 643 additions and 181 deletions

View File

@@ -72,6 +72,7 @@ import org.alfresco.web.data.QuickSort;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIModeList; import org.alfresco.web.ui.common.component.UIModeList;
import org.alfresco.web.ui.common.component.UIPanel.ExpandedEvent; import org.alfresco.web.ui.common.component.UIPanel.ExpandedEvent;
import org.alfresco.web.ui.repo.component.UIAjaxCategoryPicker;
import org.alfresco.web.ui.repo.component.UICategorySelector; import org.alfresco.web.ui.repo.component.UICategorySelector;
import org.alfresco.web.ui.repo.component.UISearchCustomProperties; import org.alfresco.web.ui.repo.component.UISearchCustomProperties;
@@ -936,16 +937,21 @@ public class AdvancedSearchDialog extends BaseDialogBean
*/ */
public void addCategory(ActionEvent event) public void addCategory(ActionEvent event)
{ {
UICategorySelector selector = (UICategorySelector)event.getComponent().findComponent("catSelector"); UIAjaxCategoryPicker selector = (UIAjaxCategoryPicker)event.getComponent().findComponent("catSelector");
UISelectBoolean chkChildren = (UISelectBoolean)event.getComponent().findComponent("chkCatChildren"); UISelectBoolean chkChildren = (UISelectBoolean)event.getComponent().findComponent("chkCatChildren");
NodeRef categoryRef = (NodeRef)selector.getValue(); List<NodeRef> categoryRefs = (List<NodeRef>)selector.getValue();
if (categoryRef != null) if (categoryRefs != null)
{ {
Node categoryNode = new MapNode(categoryRef); for (NodeRef categoryRef : categoryRefs)
// add a value bound propery used to indicate if searching across children is selected {
categoryNode.getProperties().put(INCLUDE_CHILDREN, chkChildren.isSelected()); Node categoryNode = new MapNode(categoryRef);
properties.getCategories().add(categoryNode); // add a value bound propery used to indicate if searching across children is selected
categoryNode.getProperties().put(INCLUDE_CHILDREN, chkChildren.isSelected());
properties.getCategories().add(categoryNode);
}
// clear selector value after the list has been populated
selector.setValue(null);
} }
} }

View File

@@ -527,8 +527,7 @@ public class BrowseBean implements IContextListener
MapNode node = null; MapNode node = null;
// look for Space folder node // look for Space folder node
if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER) == true && if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER))
this.dictionaryService.isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
{ {
// create our Node representation // create our Node representation
node = new MapNode(nodeRef, this.nodeService, fileInfo.getProperties()); node = new MapNode(nodeRef, this.nodeService, fileInfo.getProperties());
@@ -782,8 +781,7 @@ public class BrowseBean implements IContextListener
this.contentNodes.add(node); this.contentNodes.add(node);
} }
// look for Space folder node // look for Space folder node
else if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER) == true && else if (this.dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER))
this.dictionaryService.isSubClass(type, ContentModel.TYPE_SYSTEM_FOLDER) == false)
{ {
// create our Node representation // create our Node representation
node = new MapNode(nodeRef, this.nodeService, fileInfo.getProperties()); node = new MapNode(nodeRef, this.nodeService, fileInfo.getProperties());

View File

@@ -34,13 +34,16 @@ import javax.transaction.UserTransaction;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.CategoryService; import org.alfresco.service.cmr.search.CategoryService;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.app.servlet.ajax.InvokeCommand; import org.alfresco.web.app.servlet.ajax.InvokeCommand;
import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
@@ -55,6 +58,8 @@ import org.apache.commons.logging.LogFactory;
*/ */
public class PickerBean public class PickerBean
{ {
private static final String FOLDER_IMAGE_PREFIX = "/images/icons/";
private static Log logger = LogFactory.getLog(PickerBean.class); private static Log logger = LogFactory.getLog(PickerBean.class);
private CategoryService categoryService; private CategoryService categoryService;
@@ -134,6 +139,8 @@ public class PickerBean
{ {
out.writeNullValue("id"); out.writeNullValue("id");
out.writeValue("name", "Categories"); out.writeValue("name", "Categories");
out.writeValue("isroot", true);
out.writeValue("selectable", false);
} }
else else
{ {
@@ -178,12 +185,14 @@ public class PickerBean
tx.begin(); tx.begin();
List<ChildAssociationRef> childRefs; List<ChildAssociationRef> childRefs;
NodeRef companyHomeRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
NodeRef parentRef = null; NodeRef parentRef = null;
Map params = fc.getExternalContext().getRequestParameterMap(); Map params = fc.getExternalContext().getRequestParameterMap();
String strParentRef = (String)params.get("parent"); String strParentRef = (String)params.get("parent");
if (strParentRef == null || strParentRef.length() == 0) if (strParentRef == null || strParentRef.length() == 0)
{ {
parentRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc)); parentRef = companyHomeRef;
strParentRef = parentRef.toString();
} }
else else
{ {
@@ -195,15 +204,11 @@ public class PickerBean
out.startObject(); out.startObject();
out.startValue("parent"); out.startValue("parent");
out.startObject(); out.startObject();
if (strParentRef == null || strParentRef.length() == 0) out.writeValue("id", strParentRef);
out.writeValue("name", Repository.getNameForNode(this.internalNodeService, parentRef));
if (parentRef.equals(companyHomeRef))
{ {
out.writeNullValue("id"); out.writeValue("isroot", true);
out.writeValue("name", Repository.getNameForNode(this.internalNodeService, parentRef));
}
else
{
out.writeValue("id", strParentRef);
out.writeValue("name", Repository.getNameForNode(this.internalNodeService, parentRef));
} }
out.endObject(); out.endObject();
out.endValue(); out.endValue();
@@ -217,7 +222,7 @@ public class PickerBean
out.writeValue("id", folder.getNodeRef().toString()); out.writeValue("id", folder.getNodeRef().toString());
out.writeValue("name", (String)folder.getProperties().get(ContentModel.PROP_NAME)); out.writeValue("name", (String)folder.getProperties().get(ContentModel.PROP_NAME));
String icon = (String)folder.getProperties().get(ApplicationModel.PROP_ICON); String icon = (String)folder.getProperties().get(ApplicationModel.PROP_ICON);
out.writeValue("icon", (icon != null ? icon + "-16.gif" : BrowseBean.SPACE_SMALL_DEFAULT + ".gif")); out.writeValue("icon", FOLDER_IMAGE_PREFIX + (icon != null ? icon + "-16.gif" : BrowseBean.SPACE_SMALL_DEFAULT + ".gif"));
out.endObject(); out.endObject();
} }
@@ -234,4 +239,87 @@ public class PickerBean
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
} }
} }
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
public void getFileFolderNodes() throws Exception
{
FacesContext fc = FacesContext.getCurrentInstance();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
List<ChildAssociationRef> childRefs;
NodeRef companyHomeRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
NodeRef parentRef = null;
Map params = fc.getExternalContext().getRequestParameterMap();
String strParentRef = (String)params.get("parent");
if (strParentRef == null || strParentRef.length() == 0)
{
parentRef = companyHomeRef;
strParentRef = parentRef.toString();
}
else
{
parentRef = new NodeRef(strParentRef);
}
List<FileInfo> items = this.fileFolderService.list(parentRef);
JSONWriter out = new JSONWriter(fc.getResponseWriter());
out.startObject();
out.startValue("parent");
out.startObject();
out.writeValue("id", strParentRef);
out.writeValue("name", Repository.getNameForNode(this.internalNodeService, parentRef));
if (parentRef.equals(companyHomeRef))
{
out.writeValue("isroot", true);
}
out.writeValue("selectable", false);
out.endObject();
out.endValue();
out.startValue("children");
out.startArray();
// filter out those children that are not spaces
for (FileInfo item : items)
{
out.startObject();
out.writeValue("id", item.getNodeRef().toString());
String name = (String)item.getProperties().get(ContentModel.PROP_NAME);
out.writeValue("name", name);
if (dd.isSubClass(this.internalNodeService.getType(item.getNodeRef()), ContentModel.TYPE_FOLDER))
{
// found a folder
String icon = (String)item.getProperties().get(ApplicationModel.PROP_ICON);
out.writeValue("icon", FOLDER_IMAGE_PREFIX + (icon != null ? icon + "-16.gif" : BrowseBean.SPACE_SMALL_DEFAULT + ".gif"));
out.writeValue("selectable", false);
}
else
{
// must be a file
String icon = Utils.getFileTypeImage(fc, name, FileTypeImageSize.Small);
out.writeValue("icon", icon);
out.writeValue("url", DownloadContentServlet.generateBrowserURL(item.getNodeRef(), name));
}
out.endObject();
}
out.endArray();
out.endValue();
out.endObject();
tx.commit();
}
catch (Throwable err)
{
Utils.addErrorMessage("PickerBean exception in getFileFolderNodes()", err);
fc.getResponseWriter().write("ERROR: " + err.getMessage());
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
} }

View File

@@ -25,17 +25,25 @@
package org.alfresco.web.ui.repo.component; package org.alfresco.web.ui.repo.component;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.StringTokenizer;
import javax.faces.component.UIInput; import javax.faces.component.UIInput;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter; import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding; import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException; import javax.transaction.UserTransaction;
import javax.faces.event.FacesEvent;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.springframework.web.jsf.FacesContextUtils;
/** /**
* @author Kevin Roast * @author Kevin Roast
@@ -110,16 +118,23 @@ public abstract class BaseAjaxItemPicker extends UIInput
Map requestMap = context.getExternalContext().getRequestParameterMap(); Map requestMap = context.getExternalContext().getRequestParameterMap();
String fieldId = getHiddenFieldName(); String fieldId = getHiddenFieldName();
String value = (String)requestMap.get(fieldId); String value = (String)requestMap.get(fieldId);
if (value != null && value.length() != 0)
{
} if (getSingleSelect() == true)
{
/** NodeRef ref = new NodeRef(value);
* @see javax.faces.component.UIInput#broadcast(javax.faces.event.FacesEvent) this.setSubmittedValue(ref);
*/ }
public void broadcast(FacesEvent event) throws AbortProcessingException else
{ {
super.broadcast(event); List<NodeRef> refs = new ArrayList<NodeRef>(5);
for (StringTokenizer t = new StringTokenizer(value, ","); t.hasMoreTokens(); /**/)
{
refs.add(new NodeRef(t.nextToken()));
}
this.setSubmittedValue(refs);
}
}
} }
/** /**
@@ -134,17 +149,83 @@ public abstract class BaseAjaxItemPicker extends UIInput
ResponseWriter out = fc.getResponseWriter(); ResponseWriter out = fc.getResponseWriter();
String formClientId = Utils.getParentForm(fc, this).getClientId(fc);
Map attrs = this.getAttributes();
ResourceBundle msg = Application.getBundle(fc); ResourceBundle msg = Application.getBundle(fc);
// TODO: from submitted value or 'none' // get values from submitted value or none selected
String selection = "none"; String selection = null;
List<NodeRef> submitted = null;
if (getSingleSelect() == true)
{
NodeRef ref = (NodeRef)getSubmittedValue();
if (ref == null)
{
Object objRef = getValue();
if (objRef instanceof String)
{
ref = new NodeRef((String)objRef);
}
else if (objRef instanceof NodeRef)
{
ref = (NodeRef)objRef;
}
}
if (ref != null)
{
submitted = new ArrayList<NodeRef>(1);
submitted.add(ref);
}
}
else
{
submitted = (List<NodeRef>)getSubmittedValue();
if (submitted == null)
{
submitted = (List<NodeRef>)getValue();
}
}
if (submitted != null)
{
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(fc, true);
tx.begin();
StringBuilder buf = new StringBuilder(128);
NodeService nodeService = (NodeService)FacesContextUtils.getRequiredWebApplicationContext(
fc).getBean("nodeService");
for (NodeRef value : submitted)
{
String name = (String)nodeService.getProperty(value, ContentModel.PROP_NAME);
if (buf.length() != 0)
{
buf.append(", ");
}
buf.append(name);
}
selection = buf.toString();
// commit the transaction
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
// generate the Ids for our script object and containing DIV element
String divId = getId(); String divId = getId();
String objId = divId + "Obj"; String objId = divId + "Obj";
// generate the script to create and init our script object
String contextPath = fc.getExternalContext().getRequestContextPath(); String contextPath = fc.getExternalContext().getRequestContextPath();
out.write("<script type='text/javascript'>"); out.write("<script type='text/javascript'>");
out.write("function init" + divId + "() {"); out.write("function init" + divId + "() {");
out.write(" window." + objId + " = new AlfPicker('" + divId + "','" + objId + "','" + getServiceCall() + "'," + getSingleSelect() + ");"); out.write(" window." + objId + " = new AlfPicker('" + divId + "','" + objId + "','" + getServiceCall() +
"','" + formClientId + "'," + getSingleSelect() + ");");
if (getInitialSelection() != null) if (getInitialSelection() != null)
{ {
out.write(" window." + objId + ".setStartId('" + getInitialSelection() + "');"); out.write(" window." + objId + ".setStartId('" + getInitialSelection() + "');");
@@ -157,12 +238,32 @@ public abstract class BaseAjaxItemPicker extends UIInput
out.write("window.addEvent('domready', init" + divId + ");"); out.write("window.addEvent('domready', init" + divId + ");");
out.write("</script>"); out.write("</script>");
// generate the DIV structure for our component as expected by the script object
out.write("<div id='" + divId + "' class='picker'>") ; out.write("<div id='" + divId + "' class='picker'>") ;
out.write(" <input id='" + divId + "-value' name='" + divId + "-value' type='hidden'>"); out.write(" <input id='" + getHiddenFieldName() + "' name='" + getHiddenFieldName() + "' type='hidden'>");
out.write(" <div id='" + divId + "-noitems' class='pickerNoSelectedItems'>"); // current selection displayed as link and message to launch the selector
out.write(" <span>&lt;" + selection + "&gt;</span>"); out.write(" <div id='" + divId + "-noitems'");
out.write(" <span class='pickerActionButton'><a href='#' onclick='" + objId + ".showSelector();'>"); if (attrs.get("style") != null)
out.write(msg.getString(getLabel())); {
out.write(" style=\"");
out.write((String)attrs.get("style"));
out.write('"');
}
if (attrs.get("styleClass") != null)
{
out.write(" class=");
out.write((String)attrs.get("styleClass"));
}
out.write(">");
out.write(" <span class='pickerActionButton'><a href='javascript:" + objId + ".showSelector();'>");
if (selection == null)
{
out.write(getLabel());
}
else
{
out.write(selection);
}
out.write("</a></span>"); out.write("</a></span>");
out.write(" </div>"); out.write(" </div>");
// container for item navigation // container for item navigation
@@ -181,10 +282,11 @@ public abstract class BaseAjaxItemPicker extends UIInput
out.write(" </span>"); out.write(" </span>");
out.write(" <span class='pickerNavBreadcrumb'>"); out.write(" <span class='pickerNavBreadcrumb'>");
out.write(" <div id='" + divId + "-nav-bread' class='pickerNavBreadcrumbPanel'></div>"); out.write(" <div id='" + divId + "-nav-bread' class='pickerNavBreadcrumbPanel'></div>");
out.write(" <a href='#' onclick='" + objId + ".breadcrumbToggle();'><span id='" + divId + "-nav-txt'></span><img border='0' src='"); out.write(" <a href='javascript:" + objId + ".breadcrumbToggle();'><span id='" + divId + "-nav-txt'></span><img border='0' src='");
out.write(contextPath); out.write(contextPath);
out.write("/images/icons/arrow_open.gif'></a>"); out.write("/images/icons/arrow_open.gif'></a>");
out.write(" </span>"); out.write(" </span>");
out.write(" <span id='" + divId + "-nav-add'></span>");
out.write(" </div>"); out.write(" </div>");
out.write(" </div>"); out.write(" </div>");
// container for item selection // container for item selection
@@ -193,14 +295,17 @@ public abstract class BaseAjaxItemPicker extends UIInput
out.write(" <div id='" + divId + "-results-list' class='pickerResultsList'></div>"); out.write(" <div id='" + divId + "-results-list' class='pickerResultsList'></div>");
out.write(" </div>"); out.write(" </div>");
out.write(" </div>"); out.write(" </div>");
out.write(" <div id='" + divId + "-finish' class='pickerFinishControls'>"); // controls (OK & Cancel buttons etc.)
out.write(" <div class='pickerDoneButton'><a href='#' onclick='" + objId + ".doneClicked();'>"); out.write(" <div class='pickerFinishControls'>");
out.write(" <div id='" + divId + "-finish' style='float:left' class='pickerButtons'><a href='javascript:" + objId + ".doneClicked();'>");
out.write(msg.getString(MSG_OK)); out.write(msg.getString(MSG_OK));
out.write("</a></div>"); out.write("</a></div>");
// TODO: Cancel button out.write(" <div style='float:right' class='pickerButtons'><a href='javascript:" + objId + ".cancelClicked();'>");
out.write(msg.getString(MSG_CANCEL));
out.write("</a></div>");
out.write(" </div>"); out.write(" </div>");
out.write(" </div>"); out.write(" </div>");
// container for selected items // container for the selected items
out.write(" <div id='" + divId + "-selected' class='pickerSelectedItems'></div>"); out.write(" <div id='" + divId + "-selected' class='pickerSelectedItems'></div>");
out.write("</div>"); out.write("</div>");
} }
@@ -331,6 +436,6 @@ public abstract class BaseAjaxItemPicker extends UIInput
*/ */
protected String getHiddenFieldName() protected String getHiddenFieldName()
{ {
return this.getClientId(getFacesContext()); return this.getId() + "-value";
} }
} }

View File

@@ -44,6 +44,6 @@ public class UIAjaxCategoryPicker extends BaseAjaxItemPicker
@Override @Override
protected String getDefaultIcon() protected String getDefaultIcon()
{ {
return "category_small.gif"; return "/images/icons/category_small.gif";
} }
} }

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.web.ui.repo.component;
/**
* @author Kevin Roast
*/
public class UIAjaxFilePicker extends BaseAjaxItemPicker
{
@Override
public String getFamily()
{
return "org.alfresco.faces.AjaxFilePicker";
}
@Override
protected String getServiceCall()
{
return "PickerBean.getFileFolderNodes";
}
@Override
protected String getDefaultIcon()
{
// none required - we always return an icon name in the service call
return null;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
/*
* Created on 25-May-2005
*/
package org.alfresco.web.ui.repo.tag;
/**
* @author Kevin Roast
*/
public class AjaxFileSelectorTag extends AjaxItemSelectorTag
{
/**
* @see javax.faces.webapp.UIComponentTag#getComponentType()
*/
public String getComponentType()
{
return "org.alfresco.faces.AjaxFilePicker";
}
}

View File

@@ -29,14 +29,14 @@ package org.alfresco.web.ui.repo.tag;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponent;
import org.alfresco.web.ui.common.tag.BaseComponentTag; import org.alfresco.web.ui.common.tag.HtmlComponentTag;
/** /**
* Base class for the item selector tag * Base class for the item selector tag
* *
* @author Kevin Roast * @author Kevin Roast
*/ */
public abstract class AjaxItemSelectorTag extends BaseComponentTag public abstract class AjaxItemSelectorTag extends HtmlComponentTag
{ {
/** the value */ /** the value */
private String value; private String value;

View File

@@ -218,6 +218,11 @@
<component-type>org.alfresco.faces.AjaxCategoryPicker</component-type> <component-type>org.alfresco.faces.AjaxCategoryPicker</component-type>
<component-class>org.alfresco.web.ui.repo.component.UIAjaxCategoryPicker</component-class> <component-class>org.alfresco.web.ui.repo.component.UIAjaxCategoryPicker</component-class>
</component> </component>
<component>
<component-type>org.alfresco.faces.AjaxFilePicker</component-type>
<component-class>org.alfresco.web.ui.repo.component.UIAjaxFilePicker</component-class>
</component>
<!-- ==================== CONVERTERS ==================== --> <!-- ==================== CONVERTERS ==================== -->

View File

@@ -2227,6 +2227,18 @@
<rtexprvalue>true</rtexprvalue> <rtexprvalue>true</rtexprvalue>
</attribute> </attribute>
<attribute>
<name>style</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute> <attribute>
<name>value</name> <name>value</name>
<required>false</required> <required>false</required>
@@ -2281,6 +2293,84 @@
<rtexprvalue>true</rtexprvalue> <rtexprvalue>true</rtexprvalue>
</attribute> </attribute>
<attribute>
<name>style</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>label</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>initialSelection</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>singleSelect</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>ajaxFileSelector</name>
<tag-class>org.alfresco.web.ui.repo.tag.AjaxFileSelectorTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>binding</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>rendered</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>style</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute> <attribute>
<name>value</name> <name>value</name>
<required>false</required> <required>false</required>

View File

@@ -422,6 +422,7 @@ a.topToolbarLinkHighlight, a.topToolbarLinkHighlight:link, a.topToolbarLinkHighl
{ {
border: 1px dashed #cccccc; border: 1px dashed #cccccc;
padding: 4px; padding: 4px;
display: inline;
} }
.selectedItems .selectedItems

View File

@@ -1,8 +1,3 @@
.pickerNoSelectedItems
{
margin-top: 2px
}
.pickerSelectedItems .pickerSelectedItems
{ {
padding-left: 6px; padding-left: 6px;
@@ -112,7 +107,7 @@ img.pickerActionButton
div.pickerResultsRow div.pickerResultsRow
{ {
padding: 4px; padding: 4px;
height: 16px; height: auto;
} }
.pickerResultsOddRow .pickerResultsOddRow
@@ -142,7 +137,7 @@ div.pickerResultsRow
float: right; float: right;
} }
div.pickerDoneButton div.pickerButtons
{ {
margin: 0 auto; margin: 0 auto;
width: 50px; width: 50px;
@@ -155,6 +150,8 @@ div.pickerDoneButton
div.pickerFinishControls div.pickerFinishControls
{ {
text-align: center; text-align: center;
padding: 0px 64px 0px 64px;
height: 2em;
} }
.pickerNavBreadcrumb .pickerNavBreadcrumb

View File

@@ -113,10 +113,10 @@
<tr> <tr>
<td><nobr><h:outputText value="#{msg.checkout_location}"/>:</nobr></td> <td><nobr><h:outputText value="#{msg.checkout_location}"/>:</nobr></td>
<td width="100%"> <td width="100%">
<r:spaceSelector id="space-selector" label="#{msg.select_checkout_prompt}" <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_checkout_prompt}"
value="#{WizardManager.bean.actionProperties.destinationLocation}" value="#{WizardManager.bean.actionProperties.destinationLocation}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector"/> styleClass="selector" />
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>

View File

@@ -113,10 +113,10 @@
<tr> <tr>
<td><h:outputText value="#{msg.destination}"/>:</td> <td><h:outputText value="#{msg.destination}"/>:</td>
<td width="90%"> <td width="90%">
<r:spaceSelector id="space-selector" label="#{msg.select_destination_prompt}" <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_destination_prompt}"
value="#{WizardManager.bean.actionProperties.destinationLocation}" value="#{WizardManager.bean.actionProperties.destinationLocation}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector"/> styleClass="selector" />
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>

View File

@@ -113,11 +113,10 @@
<tr> <tr>
<td><h:outputText value="#{msg.import_to}"/>:</td> <td><h:outputText value="#{msg.import_to}"/>:</td>
<td width="90%"> <td width="90%">
<r:spaceSelector id="category-selector" <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_destination_prompt}"
label="#{msg.select_destination_prompt}" value="#{WizardManager.bean.actionProperties.destinationLocation}"
value="#{WizardManager.bean.actionProperties.destinationLocation}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
initialSelection="#{NavigationBean.currentNodeId}" style="border: 1px dashed #cccccc; padding: 6px; display: inline;" />
style="border: 1px dashed #cccccc; padding: 6px;"/>
</td> </td>
</tr> </tr>
<%-- <%--

View File

@@ -113,9 +113,9 @@
<tr> <tr>
<td valign="top"><h:outputText value="#{msg.category}"/>:</td> <td valign="top"><h:outputText value="#{msg.category}"/>:</td>
<td width="90%"> <td width="90%">
<r:categorySelector id="category-selector" label="#{msg.select_category_prompt}" <r:ajaxCategorySelector id="catSelector" styleClass="selector"
value="#{WizardManager.bean.actionProperties.category}" value="#{WizardManager.bean.actionProperties.category}"
styleClass="selector"/> label="#{msg.select_category_prompt}" />
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>

View File

@@ -113,10 +113,10 @@
<tr> <tr>
<td><h:outputText value="#{msg.destination}"/>:</td> <td><h:outputText value="#{msg.destination}"/>:</td>
<td width="90%"> <td width="90%">
<r:spaceSelector id="space-selector" label="#{msg.select_destination_prompt}" <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_destination_prompt}"
value="#{WizardManager.bean.actionProperties.destinationLocation}" value="#{WizardManager.bean.actionProperties.destinationLocation}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector"/> styleClass="selector" />
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>

View File

@@ -175,11 +175,11 @@
<td valign="top" style="padding-top:10px;"><h:outputText value="#{msg.to}"/>:</td> <td valign="top" style="padding-top:10px;"><h:outputText value="#{msg.to}"/>:</td>
<td style="padding-left:6px;"></td> <td style="padding-left:6px;"></td>
<td style="padding-top:6px;"> <td style="padding-top:6px;">
<r:spaceSelector id="client-approve-folder" <r:ajaxFolderSelector id="clientApproveFolder"
label="#{msg.select_destination_prompt}" label="#{msg.select_destination_prompt}"
value="#{WizardManager.bean.actionProperties.approveFolder}" value="#{WizardManager.bean.actionProperties.approveFolder}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector"/> styleClass="selector" />
</td> </td>
</tr> </tr>
</table> </table>
@@ -231,11 +231,11 @@
<td valign="top" style="padding-top:10px;"><h:outputText value="#{msg.to}"/>:</td> <td valign="top" style="padding-top:10px;"><h:outputText value="#{msg.to}"/>:</td>
<td style="padding-left:6px;"></td> <td style="padding-left:6px;"></td>
<td style="padding-top:6px;"> <td style="padding-top:6px;">
<r:spaceSelector id="client-reject-folder" <r:ajaxFolderSelector id="clientRejectFolder"
label="#{msg.select_destination_prompt}" label="#{msg.select_destination_prompt}"
value="#{WizardManager.bean.actionProperties.rejectFolder}" value="#{WizardManager.bean.actionProperties.rejectFolder}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector"/> styleClass="selector" />
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -128,10 +128,10 @@
<tr> <tr>
<td><h:outputText value="#{msg.destination}"/>:</td> <td><h:outputText value="#{msg.destination}"/>:</td>
<td> <td>
<r:spaceSelector id="space-selector" label="#{msg.select_destination_prompt}" <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_destination_prompt}"
value="#{WizardManager.bean.actionProperties.destinationLocation}" value="#{WizardManager.bean.actionProperties.destinationLocation}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector"/> styleClass="selector" />
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>

View File

@@ -122,10 +122,10 @@
<tr> <tr>
<td><h:outputText value="#{msg.destination}"/>:</td> <td><h:outputText value="#{msg.destination}"/>:</td>
<td> <td>
<r:spaceSelector id="space-selector" label="#{msg.select_destination_prompt}" <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_destination_prompt}"
value="#{WizardManager.bean.actionProperties.destinationLocation}" value="#{WizardManager.bean.actionProperties.destinationLocation}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector"/> styleClass="selector" />
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>

View File

@@ -44,8 +44,9 @@
noSelectedItemsMsg="#{msg.no_selected_categories}" noSelectedItemsMsg="#{msg.no_selected_categories}"
styleClass="selector"> styleClass="selector">
<f:subview id="categorySelector"> <f:subview id="categorySelector">
<r:categorySelector id="category-selector" label="#{msg.select_category_prompt}" <r:ajaxCategorySelector id="catSelector" styleClass="selector"
styleClass="selector" value="#{DialogManager.bean.addedCategory}" /> value="#{DialogManager.bean.addedCategory}"
label="#{msg.select_category_prompt}" />
</f:subview> </f:subview>
</r:multiValueSelector> </r:multiValueSelector>
<f:verbatim> <f:verbatim>

View File

@@ -184,7 +184,7 @@
</tr> </tr>
<tr> <tr>
<td style="padding-left:26px"> <td style="padding-left:26px">
<r:spaceSelector label="#{msg.select_space_prompt}" value="#{SearchProperties.location}" initialSelection="#{NavigationBean.currentNodeId}" styleClass="selector" id="spaceSelector" /> <r:ajaxFolderSelector id="spaceSelector" styleClass="selector" label="#{msg.select_space_prompt}" value="#{SearchProperties.location}" singleSelect="true" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}" />
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -203,7 +203,7 @@
<table cellpadding="2" cellspacing="2" border="0"> <table cellpadding="2" cellspacing="2" border="0">
<tr> <tr>
<td style="padding-left:8px;padding-top:8px"> <td style="padding-left:8px;padding-top:8px">
<r:categorySelector id="catSelector" label="#{msg.select_category_prompt}" styleClass="selector" /> <r:ajaxCategorySelector id="catSelector" styleClass="selector" label="#{msg.select_category_prompt}" singleSelect="false" />
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -69,10 +69,11 @@
<td style="padding-left:26px"> <td style="padding-left:26px">
<%-- Space selector to allow user to pick a Space --%> <%-- Space selector to allow user to pick a Space --%>
</f:verbatim> </f:verbatim>
<r:spaceSelector id="space-selector" label="#{msg.select_space_prompt}" <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_space_prompt}"
value="#{CCProperties.selectedSpaceId}" value="#{CCProperties.selectedSpaceId}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector"/><f:verbatim> styleClass="selector" />
<f:verbatim>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -98,12 +98,12 @@
<td valign="top" style="padding-top:10px;"></f:verbatim><h:outputText <td valign="top" style="padding-top:10px;"></f:verbatim><h:outputText
value="#{msg.to}" /><f:verbatim>:</td> value="#{msg.to}" /><f:verbatim>:</td>
<td style="padding-left:6px;"></td> <td style="padding-left:6px;"></td>
<td style="padding-top:6px;"></f:verbatim><r:spaceSelector <td style="padding-top:6px;"></f:verbatim><r:ajaxFolderSelector
id="client-approve-folder" id="clientApproveFolder"
label="#{msg.select_destination_prompt}" label="#{msg.select_destination_prompt}"
value="#{EditSimpleWorkflowDialog.workflowProperties.approveFolder}" value="#{EditSimpleWorkflowDialog.workflowProperties.approveFolder}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector" /><f:verbatim></td> styleClass="selector" /><f:verbatim></td>
</tr> </tr>
</table> </table>
</td> </td>
@@ -158,12 +158,12 @@
<td valign="top" style="padding-top:10px;"></f:verbatim><h:outputText <td valign="top" style="padding-top:10px;"></f:verbatim><h:outputText
value="#{msg.to}" /><f:verbatim>:</td> value="#{msg.to}" /><f:verbatim>:</td>
<td style="padding-left:6px;"></td> <td style="padding-left:6px;"></td>
<td style="padding-top:6px;"></f:verbatim><r:spaceSelector <td style="padding-top:6px;"></f:verbatim><r:ajaxFolderSelector
id="client-reject-folder" id="clientRejectFolder"
label="#{msg.select_destination_prompt}" label="#{msg.select_destination_prompt}"
value="#{EditSimpleWorkflowDialog.workflowProperties.rejectFolder}" value="#{EditSimpleWorkflowDialog.workflowProperties.rejectFolder}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector" /><f:verbatim></td> styleClass="selector" /><f:verbatim></td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@@ -102,12 +102,12 @@
<td valign="top" style="padding-top:10px;"></f:verbatim><h:outputText <td valign="top" style="padding-top:10px;"></f:verbatim><h:outputText
value="#{msg.to}" /><f:verbatim>:</td> value="#{msg.to}" /><f:verbatim>:</td>
<td style="padding-left:6px;"></td> <td style="padding-left:6px;"></td>
<td style="padding-top:6px;"></f:verbatim><r:spaceSelector <td style="padding-top:6px;"></f:verbatim><r:ajaxFolderSelector
id="client-approve-folder" id="clientApproveFolder"
label="#{msg.select_destination_prompt}" label="#{msg.select_destination_prompt}"
value="#{EditSpaceSimpleWorkflowDialog.workflowProperties.approveFolder}" value="#{EditSpaceSimpleWorkflowDialog.workflowProperties.approveFolder}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector" /><f:verbatim></td> styleClass="selector" /><f:verbatim></td>
</tr> </tr>
</table> </table>
</td> </td>
@@ -162,12 +162,12 @@
<td valign="top" style="padding-top:10px;"></f:verbatim><h:outputText <td valign="top" style="padding-top:10px;"></f:verbatim><h:outputText
value="#{msg.to}" /><f:verbatim>:</td> value="#{msg.to}" /><f:verbatim>:</td>
<td style="padding-left:6px;"></td> <td style="padding-left:6px;"></td>
<td style="padding-top:6px;"></f:verbatim><r:spaceSelector <td style="padding-top:6px;"></f:verbatim><r:ajaxFolderSelector
id="client-reject-folder" id="clientRejectFolder"
label="#{msg.select_destination_prompt}" label="#{msg.select_destination_prompt}"
value="#{EditSpaceSimpleWorkflowDialog.workflowProperties.rejectFolder}" value="#{EditSpaceSimpleWorkflowDialog.workflowProperties.rejectFolder}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector" /><f:verbatim></td> styleClass="selector" /><f:verbatim></td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@@ -64,10 +64,12 @@ onkeyup="javascript:checkButtonState();" /><f:verbatim>
<tr> <tr>
<td><nobr></f:verbatim><h:outputText value="#{msg.destination}"/><f:verbatim>:</nobr></td> <td><nobr></f:verbatim><h:outputText value="#{msg.destination}"/><f:verbatim>:</nobr></td>
<td> <td>
</f:verbatim><r:spaceSelector id="destination" label="#{msg.select_destination_prompt}" </f:verbatim>
value="#{DialogManager.bean.destination}" <r:ajaxFolderSelector id="destination" label="#{msg.select_destination_prompt}"
initialSelection="#{NavigationBean.currentNodeId}" value="#{DialogManager.bean.destination}"
styleClass="selector"/><f:verbatim> initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector" />
<f:verbatim>
</td> </td>
</tr> </tr>
<tr><td class="paddingRow"></td></tr> <tr><td class="paddingRow"></td></tr>

View File

@@ -113,9 +113,9 @@
<tr> <tr>
<td valign="top"><h:outputText value="#{msg.category}"/>:</td> <td valign="top"><h:outputText value="#{msg.category}"/>:</td>
<td width="90%"> <td width="90%">
<r:categorySelector id="category-selector" label="#{msg.select_category_prompt}" <r:ajaxCategorySelector id="catSelector" styleClass="selector"
value="#{WizardManager.bean.conditionProperties.category}" value="#{WizardManager.bean.conditionProperties.category}"
styleClass="selector"/> label="#{msg.select_category_prompt}" />
</td> </td>
</tr> </tr>
<tr><td colspan="2" class="paddingRow"></td></tr> <tr><td colspan="2" class="paddingRow"></td></tr>

View File

@@ -63,10 +63,10 @@
<tr> <tr>
<td> <td>
</f:verbatim> </f:verbatim>
<r:spaceSelector id="space-selector" label="#{msg.select_existing_space_prompt}" <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_existing_space_prompt}"
value="#{WizardManager.bean.existingSpaceId}" value="#{WizardManager.bean.existingSpaceId}"
initialSelection="#{NavigationBean.currentNodeId}" initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
styleClass="selector" /> styleClass="selector" />
<f:verbatim> <f:verbatim>
</td> </td>
</tr> </tr>

View File

@@ -63,8 +63,10 @@
</td> </td>
<td width=100%> <td width=100%>
</f:verbatim><r:spaceSelector id="space-selector" label="#{msg.select_destination_prompt}" </f:verbatim>
value="#{TrashcanDialogProperty.destination}" styleClass="selector" /> <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_destination_prompt}"
value="#{TrashcanDialogProperty.destination}"
styleClass="selector" />
<f:verbatim> <f:verbatim>
</td> </td>
</tr> </tr>

View File

@@ -68,8 +68,10 @@
</f:verbatim><h:outputText value="#{msg.destination}" /><f:verbatim>:&nbsp; </f:verbatim><h:outputText value="#{msg.destination}" /><f:verbatim>:&nbsp;
</td> </td>
<td width=100%> <td width=100%>
</f:verbatim><r:spaceSelector id="space-selector" label="#{msg.select_destination_prompt}" </f:verbatim>
value="#{TrashcanDialogProperty.destination}" styleClass="selector" /> <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_destination_prompt}"
value="#{TrashcanDialogProperty.destination}"
styleClass="selector" />
<f:verbatim> <f:verbatim>
</td> </td>
</tr> </tr>

View File

@@ -203,7 +203,10 @@
<tr> <tr>
<td><h:outputText value="#{msg.home_space_location}"/>:</td> <td><h:outputText value="#{msg.home_space_location}"/>:</td>
<td> <td>
<r:spaceSelector id="space-selector" label="#{msg.select_home_space_prompt}" value="#{NewUserWizard.homeSpaceLocation}" initialSelection="#{NavigationBean.currentNodeId}" style="border: 1px dashed #cccccc; padding: 2px;"/> <r:ajaxFolderSelector id="spaceSelector" label="#{msg.select_home_space_prompt}"
value="#{NewUserWizard.homeSpaceLocation}"
initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
style="border: 1px dashed #cccccc; padding: 2px; display: inline;" />
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -28,7 +28,10 @@ var AlfPicker = new Class(
id: null, id: null,
/* variable name being used */ /* variable name being used */
varName: null, varName: null,
/* form Id to submit when selection complete */
formClientId: null,
/* the item the picker will start with */ /* the item the picker will start with */
startId: null, startId: null,
@@ -57,13 +60,15 @@ var AlfPicker = new Class(
/* single selection mode flag */ /* single selection mode flag */
singleSelect: false, singleSelect: false,
initialize: function(id, varName, service, singleSelect) /* initial display style of the outer div */
initialDisplayStyle: null,
initialize: function(id, varName, service, formClientId, singleSelect)
{ {
this.id = id; this.id = id;
this.varName = varName; this.varName = varName;
this.parent = this.startId;
this.selected = [];
this.service = service; this.service = service;
this.formClientId = formClientId;
if (singleSelect != undefined) if (singleSelect != undefined)
{ {
this.singleSelect = singleSelect; this.singleSelect = singleSelect;
@@ -82,7 +87,13 @@ var AlfPicker = new Class(
showSelector: function() showSelector: function()
{ {
// init selector state
this.selected = [];
this.stack = [];
this.initialDisplayStyle = $(this.id + "-noitems").getStyle("display");
$(this.id + "-selector").setStyle("display", "block"); $(this.id + "-selector").setStyle("display", "block");
$(this.id + "-selected").empty();
$(this.id + "-selected").setStyle("display", "block"); $(this.id + "-selected").setStyle("display", "block");
$(this.id + "-noitems").setStyle("display", "none"); $(this.id + "-noitems").setStyle("display", "none");
if (this.singleSelect) if (this.singleSelect)
@@ -90,7 +101,7 @@ var AlfPicker = new Class(
$(this.id + "-finish").setStyle("display", "none"); $(this.id + "-finish").setStyle("display", "none");
} }
// simulate an ajax request for children of start item // first ajax request for the children of the start item
this.getChildData(this.startId, this.populateChildren); this.getChildData(this.startId, this.populateChildren);
}, },
@@ -115,7 +126,15 @@ var AlfPicker = new Class(
addItem: function(index) addItem: function(index)
{ {
var item = this.items[index]; var item;
if (index != -1)
{
item = this.items[index];
}
else
{
item = this.parent;
}
// add item to list of selected items // add item to list of selected items
this.selected.push(item); this.selected.push(item);
@@ -154,7 +173,7 @@ var AlfPicker = new Class(
itemDiv.injectInside($(this.id + "-selected")); itemDiv.injectInside($(this.id + "-selected"));
// set the background image now the itemdiv has been added to the DOM (for IE) // set the background image now the itemdiv has been added to the DOM (for IE)
itemDiv.setStyle("background-image", "url(" + getContextPath() + "/images/icons/" + item.icon + ")"); itemDiv.setStyle("background-image", "url(" + getContextPath() + item.icon + ")");
// set opacity the style now the item has been added to the DOM (for IE) // set opacity the style now the item has been added to the DOM (for IE)
$E('.pickerSelectedIcon', itemDiv).setStyle("opacity", 0); $E('.pickerSelectedIcon', itemDiv).setStyle("opacity", 0);
@@ -253,10 +272,23 @@ var AlfPicker = new Class(
doneClicked: function() doneClicked: function()
{ {
$(this.id + "-selector").setStyle("display", "none"); var ids = "";
$(this.id + "-value").setProperty("value", this.selected); for (i=0; i<this.selected.length; i++)
{
if (i != 0) ids += ",";
ids += this.selected[i].id;
}
$(this.id + "-value").setProperty("value", ids);
alert("The following items have been selected: " + $(this.id + "-value").value); document.forms[this.formClientId].submit();
return false;
},
cancelClicked: function()
{
$(this.id + "-selector").setStyle("display", "none");
$(this.id + "-selected").setStyle("display", "none");
$(this.id + "-noitems").setStyle("display", this.initialDisplayStyle);
}, },
populateChildren: function(response, picker, scrollpos) populateChildren: function(response, picker, scrollpos)
@@ -266,18 +298,18 @@ var AlfPicker = new Class(
results.empty(); results.empty();
// set the new parent // set the new parent
picker.parent = response.parent.id; picker.parent = {id: response.parent.id, name: response.parent.name};
// if nav stack is empty - add an item to represent the parent as the first entry // if nav stack is empty - add the parent item as the first entry
if (picker.stack.length == 0) if (picker.stack.length == 0)
{ {
picker.stack.push({id: response.parent.id, name: response.parent.name}); picker.stack.push(picker.parent);
} }
// if the parent is null we're at the root so hide the up link // if the parent is null we're at the root so hide the up link
// otherwise we need to render it with the correct details // otherwise we need to render it with the correct details
var upLink = $(picker.id + "-nav-up"); var upLink = $(picker.id + "-nav-up");
if (picker.parent == null) if (picker.parent.id == null || response.parent.isroot == true)
{ {
upLink.setStyle("display", "none"); upLink.setStyle("display", "none");
upLink.setProperty("href", "#"); upLink.setProperty("href", "#");
@@ -285,11 +317,37 @@ var AlfPicker = new Class(
else else
{ {
upLink.setStyle("display", "block"); upLink.setStyle("display", "block");
upLink.setProperty("href", "javascript:" + picker.varName + ".upClicked('" + picker.parent + "');"); upLink.setProperty("href", "javascript:" + picker.varName + ".upClicked('" + picker.parent.id + "');");
} }
// show what the parent next to the breadcrumb drop-down // show what the parent next to the breadcrumb drop-down
$(picker.id + "-nav-txt").setText(response.parent.name); $(picker.id + "-nav-txt").setText(picker.parent.name);
// render action for parent item (as it may be the root and not shown in child list!)
$(picker.id + "-nav-add").empty();
if (response.parent.selectable != false)
{
var isSelected = false;
for (i=0; i<picker.selected.length; i++)
{
if (picker.selected[i].id == picker.parent.id)
{
isSelected = true; break;
}
}
if (isSelected == false)
{
var actionId = picker.id + "-add-" + picker.parent.id;
var actionScript = "javascript:" + picker.varName + ".addItem(-1);";
var actionLink = new Element("a", {"href": actionScript});
var actionImg = new Element("img", {"id": actionId, "src": getContextPath() + "/images/icons/plus.gif", "class": "pickerActionButton",
"border": 0, "title": "Add", "alt": "Add"});
actionImg.injectInside(actionLink);
actionLink.injectInside($(picker.id + "-nav-add"));
// style modification for this Add button - it's inside a floating div unlike the others
if (document.all == undefined) actionImg.setStyle("vertical-align", "-18px");
}
}
// iterate through the children and render a row for each one // iterate through the children and render a row for each one
picker.items = []; picker.items = [];
@@ -322,37 +380,48 @@ var AlfPicker = new Class(
// render icon // render icon
var iconSpan = new Element("span", {"class": "pickerResultIcon"}); var iconSpan = new Element("span", {"class": "pickerResultIcon"});
var iconImg = new Element("img", {"src": getContextPath() + "/images/icons/" + item.icon}); var iconImg = new Element("img", {"src": getContextPath() + item.icon});
iconImg.injectInside(iconSpan); iconImg.injectInside(iconSpan);
iconSpan.injectInside(div); iconSpan.injectInside(div);
// render actions // render actions
var actionsSpan = new Element("span", {"class": "pickerResultActions"}); var isSelected = false;
if (item.selectable != false)
// see if the item exists in the selected items array - don't display Add button if it does
var found = false;
for (i=0; i<this.selected.length; i++)
{ {
if (this.selected[i].id == item.id) var actionsSpan = new Element("span", {"class": "pickerResultActions"});
// display Add button for the item
for (i=0; i<this.selected.length; i++)
{ {
found = true; break; if (this.selected[i].id == item.id)
{
isSelected = true; break;
}
} }
// even if found in the selected list, still need to generate the button - but hide it later
var actionId = this.id + "-add-" + item.id;
var actionScript = "javascript:" + this.varName + ".addItem(" + index + ");";
var actionLink = new Element("a", {"href": actionScript});
var actionImg = new Element("img", {"id": actionId, "src": getContextPath() + "/images/icons/plus.gif", "class": "pickerActionButton",
"border": 0, "title": "Add", "alt": "Add"});
actionImg.injectInside(actionLink);
actionLink.injectInside(actionsSpan);
actionsSpan.injectInside(div);
} }
var actionId = this.id + "-add-" + item.id;
var actionScript = "javascript:" + this.varName + ".addItem(" + index + ");";
var actionLink = new Element("a", {"href": actionScript});
var actionImg = new Element("img", {"id": actionId, "src": getContextPath() + "/images/icons/plus.gif", "class": "pickerActionButton",
"border": 0, "title": "Add", "alt": "Add"});
actionImg.injectInside(actionLink);
actionLink.injectInside(actionsSpan);
actionsSpan.injectInside(div);
// render name // render name link
var nameSpan = new Element("span", {"class": "pickerResultName"}); var nameSpan = new Element("span", {"class": "pickerResultName"});
var nameLink;
var link = "javascript:" + this.varName + ".childClicked(" + index + ");"; if (item.url == undefined)
{
var nameLink = new Element("a", {"href": link}); var link = "javascript:" + this.varName + ".childClicked(" + index + ");";
nameLink = new Element("a", {"href": link});
}
else
{
nameLink = new Element("a", {"href": getContextPath() + item.url, "target": "new"});
}
nameLink.appendText(item.name); nameLink.appendText(item.name);
nameLink.injectInside(nameSpan); nameLink.injectInside(nameSpan);
nameSpan.injectInside(div); nameSpan.injectInside(div);
@@ -361,7 +430,7 @@ var AlfPicker = new Class(
div.injectInside($(this.id + "-results-list")); div.injectInside($(this.id + "-results-list"));
// hide the Add button (now this item is in the DOM) if in the selected list // hide the Add button (now this item is in the DOM) if in the selected list
if (found) if (isSelected)
{ {
actionImg.setStyle("display", "none"); actionImg.setStyle("display", "none");
} }