55 columnHide ,
66 ColumnsAggrData ,
77 COLUMN_CHILDREN_KEY ,
8- filterData ,
9- genSelectionParams ,
108 getColumnsAggr ,
119 getOriDisplayData ,
1210 OB_ROW_ORI_INDEX ,
@@ -28,8 +26,6 @@ import {
2826 withExposingConfigs ,
2927} from "comps/generators/withExposing" ;
3028import { withMethodExposing } from "comps/generators/withMethodExposing" ;
31- import { MAP_KEY } from "comps/generators/withMultiContext" ;
32- import { NameGenerator } from "comps/utils" ;
3329import { trans } from "i18n" ;
3430import _ , { isArray } from "lodash" ;
3531import {
@@ -39,11 +35,9 @@ import {
3935 deferAction ,
4036 executeQueryAction ,
4137 fromRecord ,
42- FunctionNode ,
4338 Node ,
4439 onlyEvalAction ,
4540 RecordNode ,
46- RecordNodeToValue ,
4741 routeByNameAction ,
4842 ValueAndMsg ,
4943 withFunction ,
@@ -353,111 +347,7 @@ export class TableImplComp extends TableInitComp {
353347 shallowEqual ( a [ 1 ] , b [ 1 ] )
354348 ) [ 0 ] ;
355349 }
356-
357- displayDataIndexesNode ( ) {
358- const nodes = {
359- oriDisplayData : this . oriDisplayDataNode ( ) ,
360- } ;
361- const resNode = withFunction ( fromRecord ( nodes ) , ( input ) => {
362- return _ ( input . oriDisplayData )
363- . map ( ( row , idx ) => [ row [ OB_ROW_ORI_INDEX ] , idx ] as [ string , number ] )
364- . fromPairs ( )
365- . value ( ) ;
366- } ) ;
367- return lastValueIfEqual ( this , "displayDataIndexesNode" , [ resNode , nodes ] as const , ( a , b ) =>
368- shallowEqual ( a [ 1 ] , b [ 1 ] )
369- ) [ 0 ] ;
370- }
371-
372- private getUpsertSetResNode (
373- nodes : Record < string , RecordNode < Record < string , Node < any > > > > ,
374- filterNewRows ?: boolean ,
375- ) {
376- return withFunction ( fromRecord ( nodes ) , ( input ) => {
377- // merge input.dataIndexes and input.withParams into one structure
378- const dataIndexRenderDict = _ ( input . dataIndexes )
379- . mapValues ( ( dataIndex , idx ) => input . renders [ idx ] )
380- . mapKeys ( ( render , idx ) => input . dataIndexes [ idx ] )
381- . value ( ) ;
382- const record : Record < string , Record < string , JSONValue > > = { } ;
383- _ . forEach ( dataIndexRenderDict , ( render , dataIndex ) => {
384- _ . forEach ( render [ MAP_KEY ] , ( value , key ) => {
385- const changeValue = ( value . comp as any ) . comp . changeValue ;
386- if ( ! _ . isNil ( changeValue ) ) {
387- if ( ! record [ key ] ) record [ key ] = { } ;
388- record [ key ] [ dataIndex ] = changeValue ;
389- }
390- } ) ;
391- } ) ;
392- return record ;
393- } ) ;
394- }
395-
396- changeSetNode ( ) {
397- const nodes = {
398- dataIndexes : this . children . columns . getColumnsNode ( "dataIndex" ) ,
399- renders : this . children . columns . getColumnsNode ( "render" ) ,
400- } ;
401-
402- const resNode = this . getUpsertSetResNode ( nodes ) ;
403- return lastValueIfEqual ( this , "changeSetNode" , [ resNode , nodes ] as const , ( a , b ) =>
404- shallowEqual ( a [ 1 ] , b [ 1 ] )
405- ) [ 0 ] ;
406- }
407-
408- insertSetNode ( ) {
409- const nodes = {
410- dataIndexes : this . children . columns . getColumnsNode ( "dataIndex" ) ,
411- renders : this . children . columns . getColumnsNode ( "render" ) ,
412- } ;
413-
414- const resNode = this . getUpsertSetResNode ( nodes , true ) ;
415- return lastValueIfEqual ( this , "insertSetNode" , [ resNode , nodes ] as const , ( a , b ) =>
416- shallowEqual ( a [ 1 ] , b [ 1 ] )
417- ) [ 0 ] ;
418- }
419-
420- private getToUpsertRowsResNodes (
421- nodes : Record < string , FunctionNode < any , any > >
422- ) {
423- return withFunction ( fromRecord ( nodes ) , ( input ) => {
424- const res = _ ( input . changeSet )
425- . map ( ( changeValues , oriIndex ) => {
426- const idx = input . indexes [ oriIndex ] ;
427- const oriRow = _ . omit ( input . oriDisplayData [ idx ] , OB_ROW_ORI_INDEX ) ;
428- return { ...oriRow , ...changeValues } ;
429- } )
430- . value ( ) ;
431- // console.info("toUpdateRowsNode. input: ", input, " res: ", res);
432- return res ;
433- } ) ;
434- }
435-
436- toUpdateRowsNode ( ) {
437- const nodes = {
438- oriDisplayData : this . oriDisplayDataNode ( ) ,
439- indexes : this . displayDataIndexesNode ( ) ,
440- changeSet : this . changeSetNode ( ) ,
441- } ;
442-
443- const resNode = this . getToUpsertRowsResNodes ( nodes ) ;
444- return lastValueIfEqual ( this , "toUpdateRowsNode" , [ resNode , nodes ] as const , ( a , b ) =>
445- shallowEqual ( a [ 1 ] , b [ 1 ] )
446- ) [ 0 ] ;
447- }
448-
449- toInsertRowsNode ( ) {
450- const nodes = {
451- oriDisplayData : this . oriDisplayDataNode ( ) ,
452- indexes : this . displayDataIndexesNode ( ) ,
453- changeSet : this . insertSetNode ( ) ,
454- } ;
455-
456- const resNode = this . getToUpsertRowsResNodes ( nodes ) ;
457- return lastValueIfEqual ( this , "toInsertRowsNode" , [ resNode , nodes ] as const , ( a , b ) =>
458- shallowEqual ( a [ 1 ] , b [ 1 ] )
459- ) [ 0 ] ;
460- }
350+
461351
462352 columnAggrNode ( ) {
463353 const nodes = {
@@ -652,26 +542,7 @@ TableTmpComp = withMethodExposing(TableTmpComp, [
652542 comp . children . selection . children . selectedRowKeys . dispatchChangeValueAction ( allKeys ) ;
653543 } ,
654544 } ,
655- {
656- method : {
657- name : "cancelChanges" ,
658- description : "" ,
659- params : [ ] ,
660- } ,
661- execute : ( comp , values ) => {
662- comp . children . columns . dispatchClearChangeSet ( ) ;
663- } ,
664- } ,
665- {
666- method : {
667- name : "cancelInsertChanges" ,
668- description : "" ,
669- params : [ ] ,
670- } ,
671- execute : ( comp , values ) => {
672- comp . children . columns . dispatchClearInsertSet ( ) ;
673- } ,
674- } ,
545+
675546] ) ;
676547
677548// exposing data
@@ -740,42 +611,7 @@ export const TableLiteComp = withExposingConfigs(TableTmpComp, [
740611 } ,
741612 trans ( "table.selectedIndexDesc" )
742613 ) ,
743- new CompDepsConfig (
744- "changeSet" ,
745- ( comp ) => ( {
746- changeSet : comp . changeSetNode ( ) ,
747- } ) ,
748- ( input ) => input . changeSet ,
749- trans ( "table.changeSetDesc" )
750- ) ,
751- new CompDepsConfig (
752- "insertSet" ,
753- ( comp ) => ( {
754- insertSet : comp . insertSetNode ( ) ,
755- } ) ,
756- ( input ) => input . insertSet ,
757- trans ( "table.changeSetDesc" )
758- ) ,
759- new CompDepsConfig (
760- "toUpdateRows" ,
761- ( comp ) => ( {
762- toUpdateRows : comp . toUpdateRowsNode ( ) ,
763- } ) ,
764- ( input ) => {
765- return input . toUpdateRows ;
766- } ,
767- trans ( "table.toUpdateRowsDesc" )
768- ) ,
769- new CompDepsConfig (
770- "toInsertRows" ,
771- ( comp ) => ( {
772- toInsertRows : comp . toInsertRowsNode ( ) ,
773- } ) ,
774- ( input ) => {
775- return input . toInsertRows ;
776- } ,
777- trans ( "table.toUpdateRowsDesc" )
778- ) ,
614+
779615 new DepsConfig (
780616 "pageNo" ,
781617 ( children ) => {
0 commit comments