Skip to content

Commit

Permalink
Refactoring tables (masking, title updates, cleaner code), fix popup …
Browse files Browse the repository at this point in the history
…option as tabpanel (used in relations for now)
  • Loading branch information
uprel committed Jan 19, 2020
1 parent 588636c commit 97146ac
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 72 deletions.
3 changes: 2 additions & 1 deletion client/site/js/LayerActions.js
Expand Up @@ -649,7 +649,8 @@ function openAttTable() {
gridResultsPageSize: 20,
selectionLayer: myLayerName,
formItems: [],
doZoomToExtent: true
doZoomToExtent: true,
maskElement: btm.el ? btm.el : null
});

//Ext.getCmp('BottomPanel').setTitle(layer.gridTitle,'x-cols-icon');
Expand Down
85 changes: 22 additions & 63 deletions client/site/js/QGISExtensions.js
Expand Up @@ -878,6 +878,7 @@ QGIS.SearchPanel = Ext.extend(Ext.Panel, {
gridResultsPageSize: 20,
gridEditable: false,
tabClosable: true,
maskElement: null,

constructor: function (config) {
config = config || {};
Expand Down Expand Up @@ -964,6 +965,11 @@ QGIS.SearchPanel = Ext.extend(Ext.Panel, {

onSubmit: function(reload) {

//in case of maskElement not provided we take el of search panel, for other cases maskElement must be provided
if(this.maskElement == null) {
this.maskElement = this.el;
}

if(this.form !== null) {
if(this.form.getForm().isValid()===false){
return;
Expand All @@ -985,29 +991,27 @@ QGIS.SearchPanel = Ext.extend(Ext.Panel, {
this.fireEvent("searchformsubmitted");

//loading mask
var maskElement = this;
if(this.gridLocation=='bottom') {
maskElement = Ext.getCmp('BottomPanel');
}
//moved
// Make sure it's shown and expanded
//maskElement.show();
//maskElement.collapsible && maskElement.expand();
var maskElement = this.maskElement;

if (this.useWmsRequest) {
//alert(maskElement.id);
//check if we already have table for layer in case of open table call
if (this.resultsGrid !== null && this.resultsGrid.store !== null) {
if (maskElement.id=='BottomPanel' && this.gridResults === this.resultsGrid.store.maxResults && !this.useBbox && !reload) {
maskElement.activate(Ext.getCmp('table_' + this.queryLayer));
if (this.id=='BottomPanel' && this.gridResults === this.resultsGrid.store.maxResults && !this.useBbox && !reload) {
this.activate(Ext.getCmp('table_' + this.queryLayer));
}
else {
this.resultsGrid.store.maxResults = this.gridResults;
if(maskElement) {
maskElement.mask(pleaseWaitString[lang], 'x-mask-loading');
}
this.submitGetFeatureInfo();
}
}
else {
maskElement.el.mask(pleaseWaitString[lang], 'x-mask-loading');
if(maskElement) {
maskElement.mask(pleaseWaitString[lang], 'x-mask-loading');
}
this.submitGetFeatureInfo();
}
} else {
Expand Down Expand Up @@ -1170,49 +1174,7 @@ QGIS.SearchPanel = Ext.extend(Ext.Panel, {
queryLayer: this.queryLayer,
gridLocation: this.gridLocation,
maxResults: this.gridResults,
gridTitle: this.gridTitle,
listeners: {
datachanged: function() {
//console.log(this.totalCount);
//console.log(this.getTotalCount());

var complete = (this.totalCount == this.maxResults) ? false : true;

//only in this case we update title
if (this.gridLocation =='bottom') {

var cnt_all = this.totalCount;
var cnt_filt = this.getTotalCount();

var tableId = 'table_' + this.queryLayer;
var table = Ext.getCmp(tableId);

if(table != undefined) {
var loadmore = table.getBottomToolbar().getComponent('loadmore');
if (loadmore != undefined)
{
if (complete) {
loadmore.setVisible(false);
} else {
loadmore.setVisible(true);
}
}

if (cnt_filt < cnt_all) {
table.setTitle(this.gridTitle + "* (" + cnt_filt + ")");
} else {
table.setTitle(this.gridTitle + " (" + cnt_all + ")");
}
}
} else if (this.gridLocation =='default') {
var grid = Ext.getCmp('SearchPanelResultsGrid');
if(grid) {
var tt = searchResultString[lang] + " (" + grid.store.totalCount + ")";
grid.setTitle(tt);
}
}
}
}
gridTitle: this.gridTitle
});

}
Expand All @@ -1226,12 +1188,10 @@ QGIS.SearchPanel = Ext.extend(Ext.Panel, {
this.store.loadData(features, false);

//remove loading mask
var maskElement = this.el;
if(this.gridLocation=='bottom') {
maskElement = Ext.getCmp('BottomPanel').el;
var maskElement = this.maskElement;
if(maskElement) {
maskElement.unmask();
}
maskElement.unmask();

//if (destroyStore) {
// this.store = null;
//}
Expand Down Expand Up @@ -1260,11 +1220,10 @@ QGIS.SearchPanel = Ext.extend(Ext.Panel, {
showFailure: function(msg) {

//remove loading mask
var maskElement = this.el;
if(this.gridLocation=='bottom') {
maskElement = Ext.getCmp('BottomPanel').el;
var maskElement = this.maskElement;
if(maskElement) {
maskElement.unmask();
}
maskElement.unmask();

if (msg == "client") {
Ext.MessageBox.alert(searchPanelTitleString[lang], missingOrInvalidSearchParams[lang]);
Expand Down
53 changes: 45 additions & 8 deletions client/site/js/WebgisInit_functions.js
Expand Up @@ -1657,20 +1657,30 @@ function showSearchPanelResults(searchPanelInstance, features) {

break;
case 'popup':
if (typeof(Ext.getCmp('SearchResultsPopUp')) == 'undefined') {
targetComponent = new Ext.Window(
var win = Ext.getCmp('window_'+searchPanelInstance.selectionLayer);
//searchPanelId = 'popup_'+searchPanelInstance.queryLayer;
if (typeof(win) == 'undefined') {
new Ext.Window(
{
id: 'SearchResultsPopUp',
id: 'window_'+searchPanelInstance.selectionLayer,
layout: 'fit',
width: "80%",
height: 300,
width: "60%",
height: 250,
modal: false,
closeAction: 'hide'
});
title: searchPanelInstance.selectionLayer,
items: [{
xtype: 'tabpanel',
title: ''
}]
//closeAction: 'hide'
}).show();
win = Ext.getCmp('window_'+searchPanelInstance.selectionLayer);
} else {
win.toFront();
}
autoHeight = false; // No scrollbars if true
collapsible = false; // No collapsible in popup
targetComponent = Ext.getCmp('SearchResultsPopUp');
targetComponent = win.items.item(0);
break;
default:
collapsible = false;
Expand Down Expand Up @@ -1821,6 +1831,33 @@ function showSearchPanelResults(searchPanelInstance, features) {

});

//update title and other stuff on store datachanged event
searchPanelInstance.resultsGrid.store.on("datachanged", function() {
var grid = this;
var store = grid.store;

var cnt_all = store.totalCount;
var cnt_filt = store.getTotalCount();

if(grid.getBottomToolbar()) {
var complete = (store.totalCount == store.maxResults) ? false : true;
var loadmore = grid.getBottomToolbar().getComponent('loadmore');
if (loadmore != undefined) {
if (complete) {
loadmore.setVisible(false);
} else {
loadmore.setVisible(true);
}
}
}

if (cnt_filt < cnt_all) {
grid.setTitle(store.gridTitle + "* (" + cnt_filt + ")");
} else {
grid.setTitle(store.gridTitle + " (" + cnt_all + ")");
}
}, searchPanelInstance.resultsGrid);

//additional buttons in bottom toolbar
var toolBar = [{
iconCls: 'x-clearfilter-icon',
Expand Down

0 comments on commit 97146ac

Please sign in to comment.