mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. Soft Delete UI - filters implemented:
- Filter by date (Today, Last 7 days, Last 30 days) - Admin user can filter by username also git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2842 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -814,7 +814,14 @@ delete_item_success=The item \"{0}\" has been permanently deleted.
|
|||||||
title_deleted_item_details=Deleted Item Details
|
title_deleted_item_details=Deleted Item Details
|
||||||
deleteditem_details_description=Details of the deleted item
|
deleteditem_details_description=Details of the deleted item
|
||||||
alternative_destination=You may select a destination where you wish the recovered items to be placed. If you do not select a destination, the original location of the item is used. Recovery of an item may fail if the destination does not exist or you do not have permission to add items there.
|
alternative_destination=You may select a destination where you wish the recovered items to be placed. If you do not select a destination, the original location of the item is used. Recovery of an item may fail if the destination does not exist or you do not have permission to add items there.
|
||||||
deleted_when=When
|
user_filter_who=Who
|
||||||
|
user_filter_all=All
|
||||||
|
user_filter_user=User
|
||||||
|
date_filter_when=When
|
||||||
|
date_filter_all=All
|
||||||
|
date_filter_today=Today
|
||||||
|
date_filter_week=Last 7 days
|
||||||
|
date_filter_month=Last 30 days
|
||||||
|
|
||||||
# Admin Console messages
|
# Admin Console messages
|
||||||
title_admin_console=Administration Console
|
title_admin_console=Administration Console
|
||||||
|
@@ -17,8 +17,10 @@
|
|||||||
package org.alfresco.web.bean;
|
package org.alfresco.web.bean;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -42,6 +44,7 @@ import org.alfresco.service.cmr.search.ResultSetRow;
|
|||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.CachingDateFormat;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.app.context.IContextListener;
|
import org.alfresco.web.app.context.IContextListener;
|
||||||
import org.alfresco.web.bean.repository.MapNode;
|
import org.alfresco.web.bean.repository.MapNode;
|
||||||
@@ -53,6 +56,7 @@ import org.alfresco.web.bean.wizard.NewSpaceWizard;
|
|||||||
import org.alfresco.web.ui.common.Utils;
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.alfresco.web.ui.common.Utils.URLMode;
|
import org.alfresco.web.ui.common.Utils.URLMode;
|
||||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||||
|
import org.alfresco.web.ui.common.component.UIModeList;
|
||||||
import org.alfresco.web.ui.common.component.data.UIRichList;
|
import org.alfresco.web.ui.common.component.data.UIRichList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,6 +64,13 @@ import org.alfresco.web.ui.common.component.data.UIRichList;
|
|||||||
*/
|
*/
|
||||||
public class TrashcanBean implements IContextListener
|
public class TrashcanBean implements IContextListener
|
||||||
{
|
{
|
||||||
|
private static final String FILTER_DATE_ALL = "all";
|
||||||
|
private static final String FILTER_DATE_TODAY = "today";
|
||||||
|
private static final String FILTER_DATE_WEEK = "week";
|
||||||
|
private static final String FILTER_DATE_MONTH = "month";
|
||||||
|
private static final String FILTER_USER_ALL = "all";
|
||||||
|
private static final String FILTER_USER_USER = "user";
|
||||||
|
|
||||||
private static final String MSG_DELETED_ITEMS_FOR = "deleted_items_for";
|
private static final String MSG_DELETED_ITEMS_FOR = "deleted_items_for";
|
||||||
private static final String MSG_DELETED_ITEMS = "deleted_items";
|
private static final String MSG_DELETED_ITEMS = "deleted_items";
|
||||||
private static final String MSG_RECOVERED_ITEM_INTEGRITY = "recovered_item_integrity";
|
private static final String MSG_RECOVERED_ITEM_INTEGRITY = "recovered_item_integrity";
|
||||||
@@ -75,6 +86,7 @@ public class TrashcanBean implements IContextListener
|
|||||||
|
|
||||||
private final static String NAME_ATTR = Repository.escapeQName(ContentModel.PROP_NAME);
|
private final static String NAME_ATTR = Repository.escapeQName(ContentModel.PROP_NAME);
|
||||||
private final static String USER_ATTR = Repository.escapeQName(ContentModel.PROP_ARCHIVED_BY);
|
private final static String USER_ATTR = Repository.escapeQName(ContentModel.PROP_ARCHIVED_BY);
|
||||||
|
private final static String DATE_ATTR = Repository.escapeQName(ContentModel.PROP_ARCHIVED_DATE);
|
||||||
|
|
||||||
private final static String SEARCH_ALL = "PARENT:\"%s\" AND ASPECT:\"%s\"";
|
private final static String SEARCH_ALL = "PARENT:\"%s\" AND ASPECT:\"%s\"";
|
||||||
private final static String SEARCH_NAME = "PARENT:\"%s\" AND ASPECT:\"%s\" AND @" + NAME_ATTR + ":*%s*";
|
private final static String SEARCH_NAME = "PARENT:\"%s\" AND ASPECT:\"%s\" AND @" + NAME_ATTR + ":*%s*";
|
||||||
@@ -118,6 +130,15 @@ public class TrashcanBean implements IContextListener
|
|||||||
/** Alternative destination for recovered items */
|
/** Alternative destination for recovered items */
|
||||||
private NodeRef destination = null;
|
private NodeRef destination = null;
|
||||||
|
|
||||||
|
/** Date filter selection */
|
||||||
|
private String dateFilter = FILTER_DATE_ALL;
|
||||||
|
|
||||||
|
/** User filter selection */
|
||||||
|
private String userFilter = FILTER_USER_ALL;
|
||||||
|
|
||||||
|
/** User filter search box text */
|
||||||
|
private String userSearchText = null;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Bean property getters and setters
|
// Bean property getters and setters
|
||||||
@@ -202,6 +223,54 @@ public class TrashcanBean implements IContextListener
|
|||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the dateFilter.
|
||||||
|
*/
|
||||||
|
public String getDateFilter()
|
||||||
|
{
|
||||||
|
return this.dateFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dateFilter The dateFilter to set.
|
||||||
|
*/
|
||||||
|
public void setDateFilter(String dateFilter)
|
||||||
|
{
|
||||||
|
this.dateFilter = dateFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the userFilter.
|
||||||
|
*/
|
||||||
|
public String getUserFilter()
|
||||||
|
{
|
||||||
|
return this.userFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userFilter The userFilter to set.
|
||||||
|
*/
|
||||||
|
public void setUserFilter(String userFilter)
|
||||||
|
{
|
||||||
|
this.userFilter = userFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the userSearchText.
|
||||||
|
*/
|
||||||
|
public String getUserSearchText()
|
||||||
|
{
|
||||||
|
return this.userSearchText;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userSearchText The userSearchText to set.
|
||||||
|
*/
|
||||||
|
public void setUserSearchText(String userSearchText)
|
||||||
|
{
|
||||||
|
this.userSearchText = userSearchText;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Message to display in the title of the panel area
|
* @return Message to display in the title of the panel area
|
||||||
*/
|
*/
|
||||||
@@ -298,7 +367,7 @@ public class TrashcanBean implements IContextListener
|
|||||||
// get the root node to the deleted items store
|
// get the root node to the deleted items store
|
||||||
if (getArchiveRootRef() != null && this.showItems == true)
|
if (getArchiveRootRef() != null && this.showItems == true)
|
||||||
{
|
{
|
||||||
String query = getSearchQuery();
|
String query = buildSearchQuery();
|
||||||
SearchParameters sp = new SearchParameters();
|
SearchParameters sp = new SearchParameters();
|
||||||
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||||
sp.setQuery(query);
|
sp.setQuery(query);
|
||||||
@@ -620,14 +689,6 @@ public class TrashcanBean implements IContextListener
|
|||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Action handler to reset all filters and search
|
|
||||||
*/
|
|
||||||
public void resetAll(ActionEvent event)
|
|
||||||
{
|
|
||||||
// TODO: reset all filters
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action handler to initially setup the trashcan screen
|
* Action handler to initially setup the trashcan screen
|
||||||
*/
|
*/
|
||||||
@@ -636,6 +697,28 @@ public class TrashcanBean implements IContextListener
|
|||||||
contextUpdated();
|
contextUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action handler called when the Date filter is changed by the user
|
||||||
|
*/
|
||||||
|
public void dateFilterChanged(ActionEvent event)
|
||||||
|
{
|
||||||
|
UIModeList filterComponent = (UIModeList)event.getComponent();
|
||||||
|
setDateFilter(filterComponent.getValue().toString());
|
||||||
|
contextUpdated();
|
||||||
|
this.showItems = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action handler called when the User filter is changed by the user
|
||||||
|
*/
|
||||||
|
public void userFilterChanged(ActionEvent event)
|
||||||
|
{
|
||||||
|
UIModeList filterComponent = (UIModeList)event.getComponent();
|
||||||
|
setUserFilter(filterComponent.getValue().toString());
|
||||||
|
contextUpdated();
|
||||||
|
this.showItems = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Private helpers
|
// Private helpers
|
||||||
@@ -655,7 +738,7 @@ public class TrashcanBean implements IContextListener
|
|||||||
/**
|
/**
|
||||||
* @return the search query to use when displaying the list of deleted items
|
* @return the search query to use when displaying the list of deleted items
|
||||||
*/
|
*/
|
||||||
private String getSearchQuery()
|
private String buildSearchQuery()
|
||||||
{
|
{
|
||||||
String query;
|
String query;
|
||||||
if (this.searchText == null || this.searchText.length() == 0)
|
if (this.searchText == null || this.searchText.length() == 0)
|
||||||
@@ -691,13 +774,54 @@ public class TrashcanBean implements IContextListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// append user search clause
|
||||||
|
String username = null;
|
||||||
if (isAdminUser() == false)
|
if (isAdminUser() == false)
|
||||||
{
|
{
|
||||||
// prefix username clause
|
// prefix the current username
|
||||||
String username = Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName();
|
username = Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName();
|
||||||
|
}
|
||||||
|
else if (FILTER_USER_USER.equals(getUserFilter()))
|
||||||
|
{
|
||||||
|
// append the entered user if admin has requested a search
|
||||||
|
username = getUserSearchText();
|
||||||
|
}
|
||||||
|
if (username != null && username.length() != 0)
|
||||||
|
{
|
||||||
query = String.format(SEARCH_USERPREFIX, username) + query;
|
query = String.format(SEARCH_USERPREFIX, username) + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// append date search clause
|
||||||
|
if (FILTER_DATE_ALL.equals(getDateFilter()) == false)
|
||||||
|
{
|
||||||
|
Date toDate = new Date();
|
||||||
|
Date fromDate = null;
|
||||||
|
if (FILTER_DATE_TODAY.equals(getDateFilter()))
|
||||||
|
{
|
||||||
|
fromDate = new Date(toDate.getYear(), toDate.getMonth(), toDate.getDate(), 0, 0, 0);
|
||||||
|
}
|
||||||
|
else if (FILTER_DATE_WEEK.equals(getDateFilter()))
|
||||||
|
{
|
||||||
|
fromDate = new Date(toDate.getTime() - (1000L*60L*60L*24L*7L));
|
||||||
|
}
|
||||||
|
else if (FILTER_DATE_MONTH.equals(getDateFilter()))
|
||||||
|
{
|
||||||
|
fromDate = new Date(toDate.getTime() - (1000L*60L*60L*24L*30L));
|
||||||
|
}
|
||||||
|
if (fromDate != null)
|
||||||
|
{
|
||||||
|
SimpleDateFormat df = CachingDateFormat.getDateFormat();
|
||||||
|
String strFromDate = QueryParser.escape(df.format(fromDate));
|
||||||
|
String strToDate = QueryParser.escape(df.format(toDate));
|
||||||
|
StringBuilder buf = new StringBuilder(128);
|
||||||
|
buf.append("@").append(DATE_ATTR)
|
||||||
|
.append(":").append("[").append(strFromDate)
|
||||||
|
.append(" TO ").append(strToDate).append("] AND ");
|
||||||
|
|
||||||
|
query = buf.toString() + query;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,6 +49,20 @@
|
|||||||
document.getElementById("trashcan:search-btn2").disabled = false;
|
document.getElementById("trashcan:search-btn2").disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function userSearch(e)
|
||||||
|
{
|
||||||
|
var keycode;
|
||||||
|
if (window.event) keycode = window.event.keyCode;
|
||||||
|
else if (e) keycode = e.which;
|
||||||
|
if (keycode == 13)
|
||||||
|
{
|
||||||
|
document.forms['trashcan']['trashcan:modelist'].value='trashcan:user-filter:user';
|
||||||
|
document.forms['trashcan'].submit();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<f:view>
|
<f:view>
|
||||||
@@ -153,28 +167,46 @@
|
|||||||
<table cellspacing=2 cellpadding=0 width=100%>
|
<table cellspacing=2 cellpadding=0 width=100%>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="<%=request.getContextPath()%>/images/icons/filter.gif" width=16 height=16></td>
|
<td><img src="<%=request.getContextPath()%>/images/icons/filter.gif" width=16 height=16></td>
|
||||||
<td style="padding-left:8px"><nobr><h:outputText value="#{msg.deleted_when}" />:</nobr></td>
|
<td style="padding-left:8px;width:120px"><nobr><h:outputText value="#{msg.date_filter_when}" />:</nobr></td>
|
||||||
<td style="padding-left:12px" width=100%><b>All</b> Today This Week This Month</td>
|
<td width=100%>
|
||||||
|
<a:modeList itemSpacing="2" iconColumnWidth="0" horizontal="true" selectedLinkStyle="font-weight:bold"
|
||||||
|
value="#{TrashcanBean.dateFilter}" actionListener="#{TrashcanBean.dateFilterChanged}">
|
||||||
|
<a:listItem value="all" label="#{msg.date_filter_all}" />
|
||||||
|
<a:listItem value="today" label="#{msg.date_filter_today}" />
|
||||||
|
<a:listItem value="week" label="#{msg.date_filter_week}" />
|
||||||
|
<a:listItem value="month" label="#{msg.date_filter_month}" />
|
||||||
|
</a:modeList>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
<td align=right><h:commandButton id="reset-btn" value="#{msg.resetall}" actionListener="#{TrashcanBean.resetAll}" /></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
<%-- Only the admin user needs the username filter --%>
|
||||||
|
<a:panel id="userfilter-panel" rendered="#{NavigationBean.currentUser.admin == true}">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="filterBorders" width=100%>
|
<td class="filterBorders" width=100%>
|
||||||
<table cellspacing=2 cellpadding=0 width=100%>
|
<table cellspacing=2 cellpadding=0 width=100%>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="<%=request.getContextPath()%>/images/icons/filter.gif" width=16 height=16></td>
|
<td><img src="<%=request.getContextPath()%>/images/icons/filter.gif" width=16 height=16></td>
|
||||||
<td style="padding-left:8px"><nobr><h:outputText value="#{msg.deleted_user}" />:</nobr></td>
|
<td style="padding-left:8px;width:120px"><nobr><h:outputText value="#{msg.user_filter_who}" />:</nobr></td>
|
||||||
<td style="padding-left:12px" width=100%><b>All</b> User <h:inputText id="user-search" size="12" maxlength="100" style="font-size:10px" onkeyup="" /></td>
|
<td width=100%>
|
||||||
|
<table cellspacing=0 cellpadding=0 border=0><tr><td>
|
||||||
|
<a:modeList id="user-filter" itemSpacing="2" iconColumnWidth="0" horizontal="true" selectedLinkStyle="font-weight:bold"
|
||||||
|
value="#{TrashcanBean.userFilter}" actionListener="#{TrashcanBean.userFilterChanged}">
|
||||||
|
<a:listItem value="all" label="#{msg.user_filter_all}" />
|
||||||
|
<a:listItem value="user" label="#{msg.user_filter_user}" />
|
||||||
|
</a:modeList>
|
||||||
|
</td><td>
|
||||||
|
<h:inputText id="user-search" value="#{TrashcanBean.userSearchText}" size="12" maxlength="100" style="font-size:10px" onkeyup="return userSearch(event);" />
|
||||||
|
</td></tr></table>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
</a:panel>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%-- TODO: only show user filter for admin user --%>
|
|
||||||
<div style="padding: 4px;"></div>
|
<div style="padding: 4px;"></div>
|
||||||
|
|
||||||
<%-- Recover Listed Items actions --%>
|
<%-- Recover Listed Items actions --%>
|
||||||
|
Reference in New Issue
Block a user