blob: 037adf50fa3bc3c6308dc61a54cee2d92606c615 [file] [log] [blame]
/*
******************************************************************************
* Copyright © 2018 PTA GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*
******************************************************************************
*/
export class EmailDistributionListAgGridConfiguration {
static createColumnDefs() {
return [
{
headerName: '',
field: 'id',
cellRenderer: 'agGroupCellRenderer',
cellRendererParams: { innerRenderer: EmailDistributionListAgGridConfiguration.modeCellRenderer },
suppressFilter: true,
cellClass: 'grid-measure-mode',
colId: 'modeButton',
minWidth: 58
},
{
headerName: 'Verteilerliste',
field: 'emailAddress',
headerClass: 'grid-measures-header',
cellClass: 'grid-measure-tab-emailaddress',
suppressFilter: true,
colId: 'emailAddress',
width: 300
}
];
}
private static modeCellRenderer(params) {
const isEditMode =
params.context.componentParent.modeValidator.isEmailEditModeAllowed(params.context.componentParent.gridMeasureDetail);
const span = document.createElement('span');
const modeHtmlTemplate = (isEditMode && !params.data.delete && !params.data.preconfigured) &&
!params.context.componentParent.sessionContext.isLocked() &&
!params.context.componentParent.sessionContext.isReadOnlyForStatus(params.context.componentParent.gridMeasureDetail) ?
'<span style="cursor: default;">' +
'<button id="modeButton" class="btn btn-danger btn-sm" >' +
'<span class="glyphicon glyphicon-trash"></span>' +
'</button>' +
'</span>' :
'<span style="cursor: not-allowed;">' +
'<button id="modeButton" class="btn btn-default btn-sm" disabled>' +
'<span class="glyphicon glyphicon-trash"></span>' +
'</button></span>';
span.innerHTML = '<span style="cursor: default;">' +
modeHtmlTemplate +
'</span>';
const eButton = span.querySelector('#modeButton');
eButton.addEventListener('click', function () {
params.context.componentParent.deleteEmailAddress(params.data);
});
return span;
}
}