Merged in feature/PMCORE-1198 (pull request #7303)

PMCORE-1198

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Fabio Guachalla
2020-04-08 15:52:03 +00:00
committed by Julio Cesar Laura Avendaño
9 changed files with 151 additions and 74 deletions

View File

@@ -0,0 +1,113 @@
/**
* @class Ext.state.LocalStorageProvider
* A Provider implementation which saves and retrieves state via the HTML5 localStorage object.
* If the browser does not support local storage, there will be no attempt to read the state.
* @param {Object} config The configuration object
*/
Ext.state.LocalStorageProvider = Ext.extend(Ext.state.Provider, {
constructor: function(config) {
Ext.state.LocalStorageProvider.superclass.constructor.call(this);
Ext.apply(this, config);
// get all items from localStorage
this.state = this.readLocalStorage();
},
readLocalStorage: function() {
var data = {},
i,
name;
for (i = 0; i <= localStorage.length - 1; i++) {
name = localStorage.key(i);
if (name) {
data[name] = this.decodeValue2(localStorage.getItem(name));
}
}
return data;
},
set: function(name, value) {
if (typeof value == "undefined" || value === null) {
this.clear(name);
return;
}
// write to localStorage
localStorage.setItem(name, this.encodeValue(value));
Ext.state.LocalStorageProvider.superclass.set.call(this, name, value);
},
// private
clear: function(name) {
localStorage.removeItem(name);
Ext.state.LocalStorageProvider.superclass.clear.call(this, name);
},
getStorageObject: function() {
if (Ext.supports.LocalStorage) {
return window.localStorage;
}
return false;
},
decodeValue2: function(value) {
/**
* a -> Array
* n -> Number
* d -> Date
* b -> Boolean
* s -> String
* o -> Object
* -> Empty (null)
*/
var re = /^(a|n|d|b|s|o|e)\:(.*)$/,
matches = re.exec(unescape(value)),
all,
type,
keyValue,
values,
vLen,
v;
if (!matches || !matches[1]) {
return; // non state
}
type = matches[1];
value = matches[2];
switch (type) {
case 'e':
return null;
case 'n':
return parseFloat(value);
case 'd':
return new Date(Date.parse(value));
case 'b':
return (value == '1');
case 'a':
all = [];
if (value != '') {
values = value.split('^');
vLen = values.length;
for (v = 0; v < vLen; v++) {
value = values[v];
all.push(this.decodeValue2(value));
}
}
return all;
case 'o':
all = {};
if(value != ''){
values = value.split('^');
vLen = values.length;
for (v = 0; v < vLen; v++) {
value = values[v];
keyValue = value.split('=');
all[keyValue[0]] = this.decodeValue2(keyValue[1]);
}
}
return all;
default:
return value;
}
}
});

View File

@@ -67,10 +67,9 @@ function stringReplace(strSearch,strReplace,str)
{var expression=eval("/"+strSearch+"/g");return str.replace(expression,strReplace);}
function getBrowserTimeZoneOffset()
{return-1*((new Date()).getTimezoneOffset()*60);}
function setExtStateManagerSetProvider(cache,additionalPrefix){var workspace='ws-undefined';var pathname=location.pathname.split('/');var cookieProvider=new Ext.state.CookieProvider();var i;if(additionalPrefix===undefined){additionalPrefix='';}
function setExtStateManagerSetProvider(cache,additionalPrefix){var workspace='ws-undefined',pathname=location.pathname.split('/'),localStorageProvider=new Ext.state.LocalStorageProvider(),i;if(additionalPrefix===undefined){additionalPrefix='';}
if(pathname.length>1){workspace=pathname[1].replace('sys','');}
workspace=workspace+additionalPrefix;cookieProvider.on('statechange',function(provider,key,value){if(value!==null&&JSON.stringify(Ext.state.Manager.get(workspace+window.userUid+cache))!==JSON.stringify(value)){Ext.state.Manager.set(workspace+window.userUid+cache,value);}});Ext.state.Manager.setProvider(cookieProvider);Ext.state.Manager.clear(cache);try{if(window.extJsViewState!==undefined){for(i in extJsViewState){Ext.state.Manager.clear(i);}
Ext.state.Manager.set(cache,Ext.state.Manager.getProvider().decodeValue(extJsViewState[workspace+window.userUid+cache]));}}catch(e){}}
workspace=workspace+additionalPrefix;localStorageProvider.on('statechange',function(provider,key,value){if(value!==null&&JSON.stringify(Ext.state.Manager.get(workspace+window.userUid+cache))!==JSON.stringify(value)){Ext.state.Manager.set(workspace+window.userUid+cache,value);}});Ext.state.Manager.setProvider(localStorageProvider);}
function downloadFile(method,url,headers,formData,callBack){var xhr,win=window,value='blob',loadingFile=new Ext.LoadMask(Ext.getBody(),{msg:_('ID_LOADING')});method=method||'POST';loadingFile.show();if(win.XMLHttpRequest){xhr=new XMLHttpRequest();}else if(win.ActiveXObject){xhr=new ActiveXObject('Microsoft.XMLHTTP');}
win.URL=win.URL||win.webkitURL;xhr.open(method,url,true);xhr.responseType=value;Object.keys(headers).forEach(function(key){xhr.setRequestHeader(key,headers[key]);});xhr.onload=function(e){loadingFile.hide();if(xhr.status===200){if(xhr.getResponseHeader("Content-Disposition")!==null){var fileName=xhr.getResponseHeader("Content-Disposition").match(/\sfilename="([^"]+)"(\s|$)/)[1];var blob=xhr.response;if((navigator.userAgent.indexOf("MSIE")!==-1)||(navigator.userAgent.indexOf("Trident")!==-1)||(navigator.userAgent.indexOf("Edge")!==-1)){win.navigator.msSaveBlob(blob,fileName);}else{var doc=win.document,a=doc.createElementNS('http://www.w3.org/1999/xhtml','a'),event=doc.createEvent('MouseEvents');event.initMouseEvent('click',true,false,win,0,0,0,0,0,false,false,false,false,0,null);a.href=win.URL.createObjectURL(blob);a.download=fileName;a.dispatchEvent(event);}
if(typeof(callBack)!=='undefined'){callBack(xhr);}}else{PMExt.error(_('ID_ERROR'),_('ID_UNEXPECTED_ERROR_OCCURRED_PLEASE'));}}else{PMExt.error(_('ID_ERROR'),xhr.statusText);}};xhr.send(formData);}
@@ -96,6 +95,13 @@ this.add({cls:'x-btn-icon',ctCls:'x-locationbar-location x-locationbar-location-
this.add(' ');}else{this.add({cls:'x-btn-icon',iconCls:this.folderIconCls,ctCls:'x-locationbar-location x-locationbar-location-first',disabled:true});if(this.emptyText){this.add({xtype:'lbtext',text:this.emptyText});}
this.addItem(new Ext.ux.LocationBar.Fill());this.add({cls:'x-btn-icon',ctCls:'x-locationbar-location x-locationbar-location-last',menuAlign:'tr-br?',disabled:true});this.add(' ');this.add({cls:'x-btn-icon',iconCls:this.reloadIconCls,disabled:true});this.add(' ');}
if(_doLayout===true){this.doLayout();}}});Ext.reg('locationbar',Ext.ux.LocationBar);Ext.ux.Fill=Ext.extend(Ext.Toolbar.Spacer,{render:function(td){td.style.width='100%';Ext.fly(td).addClass('x-locationbar-location');Ext.ux.Fill.superclass.render.call(this,td);}});Ext.reg('tbfill',Ext.ux.Fill);Ext.ux.LocationBar.Fill=Ext.extend(Ext.Toolbar.Fill,{render:function(td){td.className='x-locationbar-location';var data=document.createTextNode('\u00a0');this.el.appendChild(data);Ext.ux.LocationBar.Fill.superclass.render.call(this,td);}});Ext.reg('lbfill',Ext.ux.LocationBar.Fill);Ext.ux.LocationBar.TextItem=Ext.extend(Ext.Toolbar.TextItem,{render:function(td){td.className='x-locationbar-location';Ext.ux.LocationBar.Fill.superclass.render.call(this,td);}});Ext.reg('lbtext',Ext.ux.LocationBar.TextItem);
Ext.state.LocalStorageProvider=Ext.extend(Ext.state.Provider,{constructor:function(config){Ext.state.LocalStorageProvider.superclass.constructor.call(this);Ext.apply(this,config);this.state=this.readLocalStorage();},readLocalStorage:function(){var data={},i,name;for(i=0;i<=localStorage.length-1;i++){name=localStorage.key(i);if(name){data[name]=this.decodeValue2(localStorage.getItem(name));}}
return data;},set:function(name,value){if(typeof value=="undefined"||value===null){this.clear(name);return;}
localStorage.setItem(name,this.encodeValue(value));Ext.state.LocalStorageProvider.superclass.set.call(this,name,value);},clear:function(name){localStorage.removeItem(name);Ext.state.LocalStorageProvider.superclass.clear.call(this,name);},getStorageObject:function(){if(Ext.supports.LocalStorage){return window.localStorage;}
return false;},decodeValue2:function(value){var re=/^(a|n|d|b|s|o|e)\:(.*)$/,matches=re.exec(unescape(value)),all,type,keyValue,values,vLen,v;if(!matches||!matches[1]){return;}
type=matches[1];value=matches[2];switch(type){case'e':return null;case'n':return parseFloat(value);case'd':return new Date(Date.parse(value));case'b':return(value=='1');case'a':all=[];if(value!=''){values=value.split('^');vLen=values.length;for(v=0;v<vLen;v++){value=values[v];all.push(this.decodeValue2(value));}}
return all;case'o':all={};if(value!=''){values=value.split('^');vLen=values.length;for(v=0;v<vLen;v++){value=values[v];keyValue=value.split('=');all[keyValue[0]]=this.decodeValue2(keyValue[1]);}}
return all;default:return value;}}});
Ext.ux.StatusBar=Ext.extend(Ext.Toolbar,{cls:'x-statusbar',busyIconCls:'x-status-busy',busyText:'Loading...',autoClear:5000,emptyText:'&nbsp;',activeThreadId:0,initComponent:function(){if(this.statusAlign=='right'){this.cls+=' x-status-right';}
Ext.ux.StatusBar.superclass.initComponent.call(this);},afterRender:function(){Ext.ux.StatusBar.superclass.afterRender.call(this);var right=this.statusAlign=='right';this.currIconCls=this.iconCls||this.defaultIconCls;this.statusEl=new Ext.Toolbar.TextItem({cls:'x-status-text '+(this.currIconCls||''),text:this.text||this.defaultText||''});if(right){this.add('->');this.add(this.statusEl);}else{this.insert(0,this.statusEl);this.insert(1,'->');}
this.doLayout();},setStatus:function(o){o=o||{};if(typeof o=='string'){o={text:o};}

View File

@@ -597,10 +597,10 @@ function getBrowserTimeZoneOffset()
* @returns {undefined}
*/
function setExtStateManagerSetProvider(cache, additionalPrefix) {
var workspace = 'ws-undefined';
var pathname = location.pathname.split('/');
var cookieProvider = new Ext.state.CookieProvider();
var i;
var workspace = 'ws-undefined',
pathname = location.pathname.split('/'),
localStorageProvider = new Ext.state.LocalStorageProvider(),
i;
if (additionalPrefix === undefined) {
additionalPrefix = '';
}
@@ -608,22 +608,12 @@ function setExtStateManagerSetProvider(cache, additionalPrefix) {
workspace = pathname[1].replace('sys', '');
}
workspace = workspace + additionalPrefix;
cookieProvider.on('statechange', function (provider, key, value) {
localStorageProvider.on('statechange', function (provider, key, value) {
if (value !== null && JSON.stringify(Ext.state.Manager.get(workspace + window.userUid + cache)) !== JSON.stringify(value)) {
Ext.state.Manager.set(workspace + window.userUid + cache, value);
}
});
Ext.state.Manager.setProvider(cookieProvider);
Ext.state.Manager.clear(cache);
try {
if (window.extJsViewState !== undefined) {
for (i in extJsViewState) {
Ext.state.Manager.clear(i);
}
Ext.state.Manager.set(cache, Ext.state.Manager.getProvider().decodeValue(extJsViewState[workspace + window.userUid + cache]));
}
} catch (e) {
}
Ext.state.Manager.setProvider(localStorageProvider);
}
/**

View File

@@ -740,44 +740,5 @@ class headPublisher
{
$this->disableHeaderScripts = true;
}
/**
* Gets an array that contains the status of the view.
*
* @return array $views
*/
public function getExtJsViewState($userUid = '')
{
$json = new stdClass();
$views = array();
$keyState = "extJsViewState" . $userUid;
$prefixExtJs = "ys-";
$oServerConf = ServerConf::getSingleton();
$deleteCache = true;
$sjson = $oServerConf->getProperty($keyState);
if ($sjson !== "") {
$json = G::json_decode($sjson);
if (is_iterable($json)) {
foreach ($json as $key => $value) {
$views[$key] = $value;
}
}
}
$httpCookies = explode("; ", $_SERVER['HTTP_COOKIE']);
foreach ($httpCookies as $cookie) {
$value = explode("=", $cookie);
if (count($value) > 1 && substr($value[0], 0, 3) === $prefixExtJs) {
$deleteCache = false;
$key = substr($value[0], 3);
$views[$key] = $value[1];
}
}
if ((array)$json != $views) {
$oServerConf->setProperty($keyState, G::json_encode($views));
}
return $views;
}
}

View File

@@ -208,6 +208,12 @@
"mini": "gulliver/js/ext/ux.locationbar/Ext.ux.LocationBar.js",
"minify": true
},
{
"name": "Ext.state.LocalStorageProvider",
"full": "gulliver/js/ext/ext-localStorage.js",
"mini": "gulliver/js/ext/ext-localStorage.js",
"minify": true
},
{
"name": "ext-statusbar",
"full": "gulliver/js/ext/ux.statusbar/ext-statusbar.js",

View File

@@ -164,6 +164,7 @@ $headPublisher->assign('solrEnabled', $solrEnabled); //Sending the status of sol
$headPublisher->assign('enableEnterprise', $enableEnterprise); //sending the page size
$headPublisher->assign('columnSearchValues', $columnToSearch); //Sending the list of column for search: caseTitle, caseNumber, tasTitle
$headPublisher->assign('filtersValues', $filters); //Sending filters defined
$headPublisher->assign('workspace', config('system.workspace'));
/*----------------------------------********---------------------------------*/
$licensedFeatures = PMLicensedFeatures::getSingleton();
@@ -197,7 +198,6 @@ $headPublisher->addExtJsScript('cases/casesList', false); //adding a javascript
$headPublisher->addContent('cases/casesListExtJs'); //adding a html file .html.
$headPublisher->assign('FORMATS', $c->getFormats());
$headPublisher->assign('userUid', $userUid);
$headPublisher->assign('extJsViewState', $headPublisher->getExtJsViewState($userUid));
$headPublisher->assign('isIE', Bootstrap::isIE());
$headPublisher->assign('__OPEN_APPLICATION_UID__', $openApplicationUid);

View File

@@ -88,7 +88,6 @@ $oHeadPublisher->assign("arrayFlagImportFileExtension", $arrayFlagImportFileExte
$oHeadPublisher->assign("arrayFlagMenuNewOption", $arrayFlagMenuNewOption);
$oHeadPublisher->assign("arrayMenuNewOptionPlugin", $arrayMenuNewOptionPlugin);
$oHeadPublisher->assign("arrayContextMenuOptionPlugin", $arrayContextMenuOptionPlugin);
$oHeadPublisher->assign('extJsViewState', $oHeadPublisher->getExtJsViewState());
$designer = new Designer();
$oHeadPublisher->assign('SYS_SYS', config("system.workspace"));
@@ -99,6 +98,7 @@ $oHeadPublisher->assign('credentials', base64_encode(G::json_encode($designer->g
$userUid = (isset($_SESSION['USER_LOGGED']) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null;
$oHeadPublisher->assign('userUid', $userUid);
$oHeadPublisher->assign('workspace', config('system.workspace'));
$deleteCasesFlag = false;
global $RBAC;

View File

@@ -18,19 +18,19 @@ new Ext.KeyMap(document, {
/*** global variables **/
var storeCases;
var storeReassignCases;
var grid;
var textJump;
var ids = '';
var winReassignInCasesList;
var casesNewTab;
var mask;
var loadingMessage;
var timeoutMark = false;
var processProxy;
var processStore;
var comboCategory;
var storeCases,
storeReassignCases,
grid,
textJump,
ids = '',
winReassignInCasesList,
casesNewTab,
mask,
loadingMessage,
timeoutMark = false,
processProxy,
processStore,
comboCategory;
function formatAMPM(date, initVal, calendarDate) {
@@ -2246,6 +2246,7 @@ Ext.onReady ( function() {
grid = new Ext.grid.GridPanel({
region: 'center',
id: 'casesGrid',
stateId : workspace + parent._action + window.userUid + 'gridProcessMain',
store: storeCases,
cm: cm,
loadMask: mask,

View File

@@ -416,7 +416,7 @@ Ext.onReady(function(){
width:'',
title : '',
stateful : true,
stateId : 'gridProcessMain',
stateId : workspace + window.userUid + 'gridProcessMain',
enableColumnResize: false,
enableHdMenu: true,
frame:false,