Source
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* @var CPartial $this
* @var array $data
*/
?>
<script type="text/javascript">
(() => {
document.querySelectorAll(`#${'<?= $data['table_id'] ?>'} .element-table-add`).forEach((element) =>
element.addEventListener('click', (event) => openAddPopup(event))
);
function openAddPopup(event) {
let valuemap_names = [];
let valuemap_table = event.target.closest('table');
valuemap_table.querySelectorAll('[name$="[name]"]').forEach((elm) => valuemap_names.push(elm.value));
PopUp('popup.valuemap.edit', {valuemap_names}, {dialogue_class: 'modal-popup-generic'});
}
})();
</script>
<script type="text/javascript">
var valuemap_number = 0;
var AddValueMap = class {
constructor(data, edit = null) {
this.data = data;
this.MAX_MAPPINGS = 3;
this.row = document.createElement('tr');
this.row.appendChild(this.createNameCell());
this.row.appendChild(this.createMappingCell());
this.row.appendChild(this.createRemoveCell());
if ('valuemapid' in this.data) {
this.row
.querySelector('td')
.appendChild(this.createHiddenInput('[valuemapid]', this.data.valuemapid));
}
this.render(edit);
valuemap_number++;
}
render(edit) {