TradeAgreementRefs = function( options ) { let instance = this; instance.partnerId = options.partnerId; instance.partnerType = options.partnerType; this.rootElement = null; } TradeAgreementRefs.prototype.constructor = TradeAgreementRefs; TradeAgreementRefs.prototype.element = function() { let instance = this; if( instance.rootElement ) { return instance.rootElement; } instance.rootElement = $("
").addClass( "TradeAgreementRefs" ).css({ "height": "100%" }); let sPartnerType = 'Operator'; if( instance.partnerType !== 'OPR' ) { sPartnerType = 'Distributor'; } //create elements //$( '

' ).html( 'The following Claim Contract Ref#s provided by this ' + sPartnerType + ' have been mapped to the associated Trade Contract#s below. If a Claim Contract Ref# is red, it has been mapped to more than one Trade Contract#. If a Trade Contract# is red, multiple Claim Contract Ref#s have been mapped to it.' ) $( '

' ).html( 'The following Claim Contract Ref#s provided by this ' + sPartnerType + ' have been mapped to the associated Trade Contract#s below.' ) .css( 'margin', '10px' ) .appendTo( instance.rootElement ); $( '

' ).text( 'Explicit mappings can be removed by checking the box next to the Explicit mapping (E) and clicking the "remove selected mappings" button. Removing a mapping will not affect any previously processed or in process claims. The Claim Contract Ref# is encountered again a new mapping will be established by the claim processing team.' ).css( 'margin', '10px' ).appendTo( instance.rootElement ); instance.createToolbar();// If a Trade Contract# is red, multiple Claim Contract Ref#s have been mapped to it. instance.createDataGrid(); //append elements instance.rootElement.append( instance.toolbar.element().css( { 'margin-top' : '5px', "margin-bottom" : "5px" } ) ); instance.rootElement.append( instance.dataGrid.element() ); return instance.rootElement.css( { "padding-left": "5px", "padding-right" : "5px" }); } TradeAgreementRefs.prototype.createDataGrid = function() { let instance = this; const appDataURL = $( '#appDataURL' ).attr( 'href' ); const agreementRefDataSource = Fse.Data.createDataSource({ customStore: { dataURL: appDataURL, object: 'TPM.agreementRefs', objectParams: { partnerId: this.partnerId, partnerType: this.partnerType }, } }); //let multipleMappingCount = {}; instance.dataGrid = $( '

' ).dxDataGrid({ dataSource: agreementRefDataSource, showBorders: true, filterRow: { visible: true }, scrolling: { mode: 'virtual' }, remoteOperations: { filtering: true, paging: true, sorting: true }, columns: [ { width: '200', dataField: 'contractRef', caption: 'Contract Ref#', allowSorting: false, groupIndex: 0, /*groupCellTemplate: function( container, options ) { multipleMappingCount = {}; const groupedData = options.component.getDataSource().items(); groupedData.forEach( group => { if( group.key ) { multipleMappingCount[ group.key ] = 0; let uniqueAssignedContractNbrs = new Set(); if( group.items ) { group.items.forEach( item => { if( item.assignedContractNbr ) { uniqueAssignedContractNbrs.add( item.assignedContractNbr ); } }); } multipleMappingCount[ group.key ] = uniqueAssignedContractNbrs.size; } }) let groupName = $( '
' ).text( options.value ); if( multipleMappingCount[ options.value ] > 1 ) { //console.log( 'This one has more than one mapping!' ); groupName.css( 'color', 'red' ); }; groupName.appendTo( container ); },*/ }, { width: '70', dataField: 'type', caption: 'Mapping', allowSorting: false, cellTemplate: function( container, options ) { let sTypeValue = 'I'; let sTypeTitle = 'Implicit'; if( options.data.type === 'E' ) { sTypeValue = 'E'; sTypeTitle = 'Explicit'; }; $( '