mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Fixes AR-238, AWC-505 and descending sort config issue
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2337 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -139,6 +139,16 @@ public abstract class AbstractWizardBean
|
||||
logger.debug("Started wizard : " + getWizardTitle() + " for editing");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the wizard is in edit mode
|
||||
*
|
||||
* @return true if the wizard is in edit mode, false if it is in creation mode
|
||||
*/
|
||||
public boolean isInEditMode()
|
||||
{
|
||||
return this.editMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deals with the next button being pressed
|
||||
*
|
||||
|
@@ -33,10 +33,13 @@ import org.alfresco.config.element.ConfigElementAdapter;
|
||||
public class ViewsConfigElement extends ConfigElementAdapter
|
||||
{
|
||||
public static final String CONFIG_ELEMENT_ID = "views";
|
||||
|
||||
public static final String VIEW_DETAILS = "details";
|
||||
public static final String VIEW_ICONS = "icons";
|
||||
public static final String VIEW_LIST = "list";
|
||||
public static final String VIEW_BUBBLE = "bubble";
|
||||
public static final String SORT_ASCENDING = "ascending";
|
||||
public static final String SORT_DESCENDING = "descending";
|
||||
|
||||
private static final String SEPARATOR = ":";
|
||||
|
||||
@@ -58,7 +61,7 @@ public class ViewsConfigElement extends ConfigElementAdapter
|
||||
private Map<String, String> sortColumns = new HashMap<String, String>(4);
|
||||
|
||||
// list of pages that have been configured to have ascending sorts
|
||||
private List<String> descendingSorts = new ArrayList<String>(1);
|
||||
private Map<String, String> sortDirections = new HashMap<String, String>(1);
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
@@ -127,9 +130,9 @@ public class ViewsConfigElement extends ConfigElementAdapter
|
||||
newElement.addDefaultSortColumn(page, this.sortColumns.get(page));
|
||||
}
|
||||
|
||||
for (String page : this.descendingSorts)
|
||||
for (String page : this.sortDirections.keySet())
|
||||
{
|
||||
newElement.addDescendingSort(page);
|
||||
newElement.addSortDirection(page, this.sortDirections.get(page));
|
||||
}
|
||||
|
||||
// copy all the config from the element to be combined into the new one
|
||||
@@ -161,11 +164,10 @@ public class ViewsConfigElement extends ConfigElementAdapter
|
||||
newElement.addDefaultSortColumn(page, existingSortColumns.get(page));
|
||||
}
|
||||
|
||||
// TODO: There is a potential problem here - how would you remove the
|
||||
// descending sort for a page
|
||||
for (String page : existingElement.getDescendingSorts())
|
||||
Map<String, String> existingSortDirs = existingElement.getSortDirections();
|
||||
for (String page : existingSortDirs.keySet())
|
||||
{
|
||||
newElement.addDescendingSort(page);
|
||||
newElement.addSortDirection(page, existingSortDirs.get(page));
|
||||
}
|
||||
|
||||
return newElement;
|
||||
@@ -322,13 +324,14 @@ public class ViewsConfigElement extends ConfigElementAdapter
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given page as using descending sorts
|
||||
* Sets the given page as using the given sort direction
|
||||
*
|
||||
* @param page The name of the page i.e. browse, forums etc.
|
||||
* @param dir The sort direction
|
||||
*/
|
||||
/*package*/ void addDescendingSort(String page)
|
||||
/*package*/ void addSortDirection(String page, String dir)
|
||||
{
|
||||
this.descendingSorts.add(page);
|
||||
this.sortDirections.put(page, dir);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,16 +343,24 @@ public class ViewsConfigElement extends ConfigElementAdapter
|
||||
*/
|
||||
public boolean hasDescendingSort(String page)
|
||||
{
|
||||
return this.descendingSorts.contains(page);
|
||||
boolean usesDescendingSort = false;
|
||||
|
||||
String sortDir = this.sortDirections.get(page);
|
||||
if (sortDir != null && sortDir.equalsIgnoreCase(SORT_DESCENDING))
|
||||
{
|
||||
usesDescendingSort = true;
|
||||
}
|
||||
|
||||
return usesDescendingSort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of pages that use a descending sort
|
||||
* Returns a map of the sort directions
|
||||
*
|
||||
* @return List of pages that use a descending sort
|
||||
* @return Map of sort directions
|
||||
*/
|
||||
/*package*/ List<String> getDescendingSorts()
|
||||
/*package*/ Map<String, String> getSortDirections()
|
||||
{
|
||||
return this.descendingSorts;
|
||||
return this.sortDirections;
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public class ViewsElementReader implements ConfigElementReader
|
||||
public static final String ELEMENT_VIEWDEFAULTS = "view-defaults";
|
||||
public static final String ELEMENT_PAGESIZE = "page-size";
|
||||
public static final String ELEMENT_SORTCOLUMN = "sort-column";
|
||||
public static final String ELEMENT_SORTDESCENDING = "sort-descending";
|
||||
public static final String ELEMENT_SORTDIRECTION = "sort-direction";
|
||||
|
||||
private static Log logger = LogFactory.getLog(ViewsElementReader.class);
|
||||
|
||||
@@ -95,15 +95,11 @@ public class ViewsElementReader implements ConfigElementReader
|
||||
configElement.addDefaultSortColumn(pageName, column);
|
||||
}
|
||||
|
||||
// get the sort descending option
|
||||
Element sortDesc = page.element(ELEMENT_SORTDESCENDING);
|
||||
if (sortDesc != null)
|
||||
// get the sort direction option
|
||||
Element sortDir = page.element(ELEMENT_SORTDIRECTION);
|
||||
if (sortDir != null)
|
||||
{
|
||||
Boolean descending = new Boolean(sortDesc.getTextTrim());
|
||||
if (descending.booleanValue() == true)
|
||||
{
|
||||
configElement.addDescendingSort(pageName);
|
||||
}
|
||||
configElement.addSortDirection(pageName, sortDir.getTextTrim());
|
||||
}
|
||||
|
||||
// process the page-size element
|
||||
|
@@ -529,9 +529,7 @@ public class WebClientConfigTest extends BaseTest
|
||||
assertFalse("default sort direction should be ascending", config.hasDescendingSort("not-there"));
|
||||
assertFalse("browse screen should use an ascending sort", config.hasDescendingSort("browse"));
|
||||
assertTrue("topic screen should use a descending sort", config.hasDescendingSort("forum"));
|
||||
|
||||
// TODO: uncomment this test once the override of descending sorts is fixed
|
||||
// assertFalse("topic screen should use a ascending sort", config.hasDescendingSort("topic"));
|
||||
assertFalse("topic screen should use an ascending sort", config.hasDescendingSort("topic"));
|
||||
|
||||
// make sure the getChildren method throws an exception
|
||||
try
|
||||
|
Reference in New Issue
Block a user