class MailingMappingDialog extends EICDialogContent { actions = [ { label: 'Cancel', onclick: this.cancel.bind(this), severity: 'secondary', role: 'cancel' }, { label: 'Link', onclick: this.link.bind(this), severity: 'primary', role: 'link', disabled: false } ] DOMContentLoaded(options) { this.model = options.model this.token = options.token this.sourceId = options.sourceId this.currentMailing = options.currentMailing this.oneMapping = this.currentMailing.mappings.find(item => item.sourceId==options.sourceId) || { mappings: {} } this.oneImport = this.currentMailing.imports.find(item => item.sourceId == options.sourceId) let value = this.oneMapping.mappings[this.token] ? this.oneMapping.mappings[this.token].value : null let components = ui.eicfy(this.el) this.warning = this.find('[data-output="warning"]') ui.hide(this.warning) this.selector = components.find(component => component.el.name == 'column') for(let column of this.oneImport.availableColumns ) { let opt = `' this.selector.el.append(ui.create(opt)) } this.sampleGrid = new DataGrid(this.find('.sample-grid'), { headers: [ {label: 'Sample data'} ], height: '20vh' }) this.selector.value = value this.selector.change(this.onColChange.bind(this)); this.onColChange() this.btResample = new Button(null, {icon: 'icon-refresh', rounded: true, size: 'xsmall', hint: 'Resample'}) this.btResample.click = this.onColChange.bind(this) this.sampleGrid.el.querySelector('header .cell.actions').append(this.btResample.el) } onColChange(event){ const size = Math.min(10, this.oneImport.dataCount) const colIdx = this.selector.value let warnings = [] this.sampleGrid.clear() if(this.selector.value){ for(let[idx, row] of this._makeSample(this.oneImport.data).entries()) { let value = String(row[colIdx] || '').trim() || `Empty !` this.sampleGrid.addRow( idx, [ value ] ) } if(this.oneImport.data.some(row => (row[colIdx].trim()==''))){ warnings.push('