@@ -8,7 +8,7 @@ import {PagingInfo} from "../jigsaw/core/data/component-data";
88@Injectable ( )
99export class AjaxInterceptor implements HttpInterceptor {
1010
11- private static _usingRealRDK : boolean = false ;
11+ private static _usingRealRDK : boolean = true ;
1212 private static _processors : any [ ] = [ ] ;
1313
1414 public static registerProcessor ( urlPattern : RegExp | string , processor : ( req : HttpRequest < any > ) => any , context ?: any ) {
@@ -49,9 +49,12 @@ export class AjaxInterceptor implements HttpInterceptor {
4949 dealServerSidePagingRequest ( req : HttpRequest < any > ) : Observable < HttpEvent < any > > {
5050 const params = req . method . toLowerCase ( ) == 'post' ? 'body' : 'params' ;
5151 const service = this . getParamValue ( req , params , 'service' ) ;
52- const paging = this . getParamValue ( req , params , 'paging' ) ? JSON . parse ( this . getParamValue ( req , params , 'paging' ) ) : null ;
53- const filter = this . getParamValue ( req , params , 'filter' ) ? JSON . parse ( this . getParamValue ( req , params , 'filter' ) ) : null ;
54- const sort = this . getParamValue ( req , params , 'sort' ) ? JSON . parse ( this . getParamValue ( req , params , 'sort' ) ) : null ;
52+ let paging = this . getParamValue ( req , params , 'paging' ) ? this . getParamValue ( req , params , 'paging' ) : null ;
53+ paging = typeof paging === 'string' ? JSON . stringify ( paging ) : paging ;
54+ let filter = this . getParamValue ( req , params , 'filter' ) ? this . getParamValue ( req , params , 'filter' ) : null ;
55+ filter = typeof filter === 'string' ? JSON . stringify ( filter ) : filter ;
56+ let sort = this . getParamValue ( req , params , 'sort' ) ? this . getParamValue ( req , params , 'sort' ) : null ;
57+ sort = typeof sort === 'string' ? JSON . stringify ( sort ) : sort ;
5558 return PageableData . get ( { service, paging, filter, sort} ) ;
5659 }
5760
@@ -176,7 +179,7 @@ class PageableData {
176179 }
177180
178181 private static _filter ( dataTable , filter ) {
179- return filter . hasOwnProperty ( 'rawFunction' ) ?
182+ return filter . hasOwnProperty ( 'rawFunction' ) && ! ! filter . rawFunction ?
180183 this . _filterWithFunction ( dataTable . data , filter . rawFunction , filter . context ) :
181184 this . _filterWithKeyword ( dataTable . data , filter . key , filter . field , dataTable . field ) ;
182185 }
@@ -222,7 +225,7 @@ class PageableData {
222225 private static _filterWithFunction ( data , rawFunction , context ) {
223226 let func ;
224227 try {
225- func = eval ( '(' + rawFunction . replace ( / \b _ t h i s \b / g , 'this' ) + ')' ) ;
228+ func = eval ( '(' + rawFunction + ')' ) ;
226229 } catch ( e ) {
227230 console . error ( 'eval raw filter function error, detail: ' + e . message ) ;
228231 return data ;
0 commit comments