Source
* Removes the linked template row and the template ID from linked templates object, triggers multiselect change
<?php declare(strict_types = 0);
/*
** 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 CView $this
*/
?>
window.template_edit_popup = new class {
init({templateid, warnings}) {
this.overlay = overlays_stack.getById('templates-form');
this.dialogue = this.overlay.$dialogue[0];
this.form = this.overlay.$dialogue.$body[0].querySelector('form');
this.templateid = templateid;
this.linked_templateids = this.#getLinkedTemplates();
this.macros_templateids = null;
if (warnings.length > 0) {
const message_box = warnings.length > 1
? makeMessageBox('warning', warnings,
<?= json_encode(_('Cloned template parameter values have been modified.')) ?>, true, false
)[0]
: makeMessageBox('warning', warnings, null, true, false)[0];
this.form.parentNode.insertBefore(message_box, this.form);
}
this.#initActions();
this.#initTemplateTab();
this.#initMacrosTab();
this.initial_form_fields = getFormFields(this.form);
}
#initActions() {
this.form.addEventListener('click', (e) => {
if (e.target.classList.contains('js-edit-linked-template')) {
this.#editLinkedTemplate(e.target.dataset.templateid);
}
else if (e.target.classList.contains('js-unlink')) {
this.#unlink(e);
}
else if (e.target.classList.contains('js-unlink-and-clear')) {
this.#unlink(e);
this.#clear(e.target.dataset.templateid);
}
});
// Add visible name input field placeholder.