mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 11:17:40 +08:00
Refs #798 ability to cancel table sort
This commit is contained in:
parent
b0ed154c21
commit
8fc98ddf87
@ -27,6 +27,7 @@ import com.vaadin.terminal.gwt.client.ui.VFilterSelect;
|
||||
import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
|
||||
import com.vaadin.terminal.gwt.client.ui.dd.VDragEvent;
|
||||
import com.vaadin.terminal.gwt.client.ui.dd.VTransferable;
|
||||
import org.apache.xpath.operations.Bool;
|
||||
import org.vaadin.hene.popupbutton.widgetset.client.ui.VPopupButton;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -158,6 +159,8 @@ public abstract class Table extends FlowPanel implements com.vaadin.terminal.gwt
|
||||
|
||||
protected boolean sortAscending;
|
||||
protected String sortColumn;
|
||||
protected boolean enableCancelSorting = false;
|
||||
protected int sortSwitchCounts = 0;
|
||||
protected boolean columnReordering;
|
||||
|
||||
/**
|
||||
@ -443,6 +446,10 @@ public abstract class Table extends FlowPanel implements com.vaadin.terminal.gwt
|
||||
sortColumn = uidl.getStringVariable("sortcolumn");
|
||||
}
|
||||
|
||||
if (uidl.hasVariable("enableCancelSorting")){
|
||||
enableCancelSorting = uidl.getBooleanVariable("enableCancelSorting");
|
||||
}
|
||||
|
||||
if (uidl.hasVariable("selected")) {
|
||||
final Set<String> selectedKeys = uidl
|
||||
.getStringArrayVariableAsSet("selected");
|
||||
@ -1440,11 +1447,21 @@ public abstract class Table extends FlowPanel implements com.vaadin.terminal.gwt
|
||||
// mouse event was a click to header -> sort column
|
||||
if (sortable) {
|
||||
if (sortColumn.equals(cid)) {
|
||||
// just toggle order
|
||||
client.updateVariable(paintableId, "sortascending",
|
||||
!sortAscending, true);
|
||||
sortSwitchCounts++;
|
||||
if (Boolean.TRUE.equals(enableCancelSorting) && (sortSwitchCounts % 3) == 0){
|
||||
// cancel sorting
|
||||
client.updateVariable(paintableId, "cancelsorting",
|
||||
"", true);
|
||||
sortSwitchCounts= 0;
|
||||
}
|
||||
else{
|
||||
// just toggle order
|
||||
client.updateVariable(paintableId, "sortascending",
|
||||
!sortAscending, true);
|
||||
}
|
||||
} else {
|
||||
// set table scrolled by this column
|
||||
sortSwitchCounts = 1;
|
||||
// set table sorted by this column
|
||||
client.updateVariable(paintableId, "sortcolumn",
|
||||
cid, true);
|
||||
}
|
||||
|
@ -129,6 +129,13 @@ public interface WebConfig extends Config
|
||||
@DefaultBoolean(false)
|
||||
boolean getAllowIdSuffix();
|
||||
|
||||
/**
|
||||
* Allows cancel sorting in table cell
|
||||
*/
|
||||
@Property("cuba.web.enableCancelTableSorting")
|
||||
@DefaultBoolean(false)
|
||||
boolean getEnableCancelTableSorting();
|
||||
|
||||
/**
|
||||
* Used to support automatic testing. Contains a name of request parameter
|
||||
* that marks a request from an automatic testing tool, for example jMeter.
|
||||
|
@ -17,10 +17,7 @@ import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.MessageProvider;
|
||||
import com.haulmont.cuba.core.global.MessageUtils;
|
||||
import com.haulmont.cuba.core.global.MetadataHelper;
|
||||
import com.haulmont.cuba.core.global.UserSessionProvider;
|
||||
import com.haulmont.cuba.core.global.*;
|
||||
import com.haulmont.cuba.core.sys.AppContext;
|
||||
import com.haulmont.cuba.gui.ComponentsHelper;
|
||||
import com.haulmont.cuba.gui.WindowManager;
|
||||
@ -38,6 +35,7 @@ import com.haulmont.cuba.security.entity.EntityOp;
|
||||
import com.haulmont.cuba.security.entity.Presentation;
|
||||
import com.haulmont.cuba.security.global.UserSession;
|
||||
import com.haulmont.cuba.web.App;
|
||||
import com.haulmont.cuba.web.WebConfig;
|
||||
import com.haulmont.cuba.web.gui.AbstractFieldFactory;
|
||||
import com.haulmont.cuba.web.gui.CompositionLayout;
|
||||
import com.haulmont.cuba.web.gui.components.presentations.TablePresentations;
|
||||
@ -320,6 +318,8 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
componentComposition.setSpacing(true);
|
||||
componentComposition.setMargin(false);
|
||||
componentComposition.setExpandRatio(component, 1);
|
||||
|
||||
component.setEnableCancelSorting(ConfigProvider.getConfig(WebConfig.class).getEnableCancelTableSorting());
|
||||
}
|
||||
|
||||
protected Collection<MetaPropertyPath> createColumns(com.vaadin.data.Container ds) {
|
||||
|
@ -339,6 +339,10 @@ public class GroupTable extends Table implements GroupTableContainer {
|
||||
target.addVariable(this, "sortascending", isSortAscending());
|
||||
}
|
||||
|
||||
if (isEnableCancelSorting()){
|
||||
target.addVariable(this, "enableCancelSorting", true);
|
||||
}
|
||||
|
||||
// Resets and paints "to be painted next" variables. Also reset
|
||||
// pageBuffer
|
||||
reqFirstRowToPaint = -1;
|
||||
|
@ -42,6 +42,8 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
|
||||
|
||||
protected boolean aggregatable = false;
|
||||
|
||||
protected boolean enableCancelSorting = false;
|
||||
|
||||
private boolean textSelectionEnabled;
|
||||
|
||||
private boolean showTotalAggregation = true;
|
||||
@ -133,12 +135,6 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
|
||||
|
||||
/**
|
||||
* Gets items ids from a range of key values
|
||||
*
|
||||
* @param startRowKey
|
||||
* The start key
|
||||
* @param endRowKey
|
||||
* The end key
|
||||
* @return
|
||||
*/
|
||||
protected Set<Object> getItemIdsInRange(Object itemId, final int length) {
|
||||
HashSet<Object> ids = new HashSet<Object>();
|
||||
@ -544,6 +540,10 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
|
||||
target.addVariable(this, "sortascending", isSortAscending());
|
||||
}
|
||||
|
||||
if (isEnableCancelSorting()){
|
||||
target.addVariable(this, "enableCancelSorting", true);
|
||||
}
|
||||
|
||||
// Resets and paints "to be painted next" variables. Also reset
|
||||
// pageBuffer
|
||||
reqFirstRowToPaint = -1;
|
||||
@ -1071,6 +1071,14 @@ public class Table extends com.vaadin.ui.Table implements AggregationContainer {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnableCancelSorting() {
|
||||
return enableCancelSorting;
|
||||
}
|
||||
|
||||
public void setEnableCancelSorting(boolean enableCancelSorting) {
|
||||
this.enableCancelSorting = enableCancelSorting;
|
||||
}
|
||||
|
||||
public boolean isStoreColWidth() {
|
||||
return storeColWidth;
|
||||
}
|
||||
|
@ -561,6 +561,10 @@ public class TreeTable extends Table implements Container.Hierarchical, TreeTabl
|
||||
target.addVariable(this, "sortascending", isSortAscending());
|
||||
}
|
||||
|
||||
if (isEnableCancelSorting()){
|
||||
target.addVariable(this, "enableCancelSorting", true);
|
||||
}
|
||||
|
||||
// Resets and paints "to be painted next" variables. Also reset
|
||||
// pageBuffer
|
||||
reqFirstRowToPaint = -1;
|
||||
|
@ -96,3 +96,6 @@ cuba.testMode=false
|
||||
# Enables using of Id's suffixes, for example 'PID_SRegistrationScreeen.username.1'.
|
||||
# In this example '1' is a unique suffix
|
||||
cuba.web.allowIdSuffix=false
|
||||
|
||||
# Allows to cancel sort in table
|
||||
cuba.web.enableCancelTableSorting=true
|
Loading…
Reference in New Issue
Block a user