load( local!serialNumbers: ri!serialNumbers, local!itemsToken, local!newItems, local!deletedItemIds, local!selectedIndex, local!searchResults, local!columnPage: 1, /*local!icamsDocuments: rule!ICAMS_getDocumentsByObjectTypeOBjectLinkIdAndType(*/ /* objectLinkType: cons!ICAMS_DOCUMENT_OBJECT_LINKE_TYPE_DEAL_MODULE,*/ /* documentType: cons!ICAMS_DOCUMENT_TYPE_DECON_CERT,*/ /* pagingInfo: a!pagingInfo(1, -1),*/ /* objectLinkIds: index(ri!displayModulesList, "dealModuleId", {})*/ /*),*/ /*local!documents: apply(*/ /* rule!ICAMS_returnDocumentOrNullForModule(*/ /* dealModuleId: _,*/ /* allDocuments: local!icamsDocuments*/ /* ),*/ /* index(ri!displayModulesList, "dealModuleId", {})*/ /*),*/ /*local!targetFolder: cons!ICAMS_ORPHAN_DOCUMENTS_FOLDER,*/ /*only query once and pass into sub rule */ local!allStandardDescriptions: rule!ICAMS_getAllStandardDescriptions(), { a!sectionLayout( label: "Add Modules to Logistics Group", firstColumnContents: { a!textField( label: "Serial Number", labelPosition: "ADJACENT", value: local!serialNumbers, saveInto: local!serialNumbers, required: true, validationGroup: "search" ) }, secondColumnContents: { a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Search ICAMS", value: "Search", saveInto: { a!save( local!searchResults, rule!ICAMS_searchModulesBySerialNumberInICAMSDb( serialNumber: local!serialNumbers, currentSerialNumbers: index( ri!displayModulesList, "serialNumber", null ) ) ), a!save( ri!displayModulesList, append( ri!displayModulesList, local!searchResults ) ), a!save( local!itemsToken, append( local!itemsToken, local!searchResults ) ), a!save( ri!icamsDocuments, append(ri!icamsDocuments, rule!ICAMS_getDocumentsByObjectTypeOBjectLinkIdAndType( objectLinkType: cons!ICAMS_DOCUMENT_OBJECT_LINKE_TYPE_DEAL_MODULE, documentType: cons!ICAMS_DOCUMENT_TYPE_DECON_CERT, pagingInfo: a!pagingInfo( 1, - 1 ), objectLinkIds: union( append( touniformstring( index( local!searchResults, "dealModuleId", {} ) ), touniformstring( index( local!searchResults, "serialNumber", {} ) ) ), append( touniformstring( index( local!searchResults, "dealModuleId", {} ) ), touniformstring( index( local!searchResults, "serialNumber", {} ) ) ) ) )) ), a!save( ri!documents, todocument( apply( rule!ICAMS_returnDocumentOrNullForModule( dealModuleId: _, allDocuments: ri!icamsDocuments ), union( append( touniformstring( index( ri!displayModulesList, "dealModuleId", {} ) ), touniformstring( index( ri!displayModulesList, "serialNumber", {} ) ) ), append( touniformstring( index( ri!displayModulesList, "dealModuleId", {} ) ), touniformstring( index( ri!displayModulesList, "serialNumber", {} ) ) ) ) /*union(*/ /* index(*/ /* ri!icamsDocuments,*/ /* "objectLinkId",*/ /* {}*/ /* ),*/ /* index(*/ /* ri!icamsDocuments,*/ /* "objectLinkId",*/ /* {}*/ /* )*/ /*)*/ ) ) ), a!save( local!serialNumbers, null ) /*append(*/ /* ri!documents,*/ /* todocument(*/ /* apply(*/ /* rule!ICAMS_returnDocumentOrNullForModule(*/ /* dealModuleId: _,*/ /* allDocuments: ri!icamsDocuments*/ /* ),*/ /* union(*/ /* index(*/ /* ri!icamsDocuments,*/ /* "objectLinkId",*/ /* {}*/ /* ),*/ /* index(*/ /* ri!icamsDocuments,*/ /* "objectLinkId",*/ /* {}*/ /* )*/ /* )*/ /* )*/ /* )*/ /*)*/ }, validate: true, validationGroup: "search" ) } ) } ), rule!ICAMS_logisticsGroupSerialNumberPageLinkSection( selectedPageNumber: local!columnPage, isEdit: false() ), a!sectionLayout( firstColumnContents: { a!gridLayout( totalcount: count( ri!displayModulesList ), headerCells: rule!ICAMS_LogisticsGroupEditModuleHeaderCells( selectedPageNumber: local!columnPage ), /* Only needed when some columns need to be narrow */ columnConfigs: rule!ICAMS_LogisticsGroupEditModuleColumnConfigs( selectedPageNumber: local!columnPage ), rows: a!applyComponents( function: rule!ICAMS_LogisticsGroupEditModuleItemRowEach( items: ri!displayModulesList, index: _, itemsToken: local!itemsToken, /*deletedItemIds: local!deletedItemIds,*/ /*selectedIndex: local!selectedIndex,*/ removedModulesList: ri!removedModulesList, allStdDescriptions: local!allStandardDescriptions, selectedPageNumber: local!columnPage, allDocuments: ri!documents, targetFolder: ri!targetFolder ), array: if( or( isnull( ri!displayModulesList ), count( ri!displayModulesList ) < 1 ), {}, 1 + enumerate( count( ri!displayModulesList ) ) ), arrayVariable: local!itemsToken ), validations: {if(rule!ICAMS_checkIfModuleBelongsToOtherLogisticsGroup( items: ri!displayModulesList, selectedLogisticsGroupingId : ri!logisticsGroupingId, isEdit: false ), "One of the modules belong to other Logistics Group", {})} ) } ) } )