<?php
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
?>
<script type="text/javascript">
//<![CDATA[
    new Jsw.Hint({
        renderTo: 'main',
        hint: <?php echo $this->jsLmsg('hint'); ?>
    });

    new Jsw.Container({
      renderTo: 'main',
      id: 'toggle-block',
      cls: 'actions-box',
    });

    new Jsw.Panel({
        cls: 'list-box',
        renderTo: 'main',
        items: [
            new Jsw.List({
                id: 'restricted-domains-list',
                searchFilters: <?php echo Zend_Json::encode($this->restrictedDomainsList->getSearchFilterConfig()); ?>,
                searchOveral: 'name',
                data: <?php echo Zend_Json::encode($this->restrictedDomainsList->fetchData()); ?>,
                dataUrl: '/domain-restriction/list-data',
                disabledSelectHint: <?php echo $this->restrictedDomainsList->jsLmsg('disabledSelectHint');?>,
                operations: [
                    {
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonAddNewDomain',
                        title: <?php echo $this->restrictedDomainsList->jsLmsg('buttonAddNewDomain');?>,
                        description: <?php echo $this->restrictedDomainsList->jsLmsg('hintAddNewDomain') ?>,
                        addCls: 'sb-new-domain btn-primary',
                        href: '/domain-restriction/add'
                    },{
                        componentType: 'Jsw.bar.Separator'
                    },{
                        componentType: 'Jsw.SmallButton',
                        id: 'buttonRemoveDomain',
                        title: <?php echo $this->restrictedDomainsList->jsLmsg('buttonRemoveDomain') ?>,
                        description: <?php echo $this->restrictedDomainsList->jsLmsg('hintRemoveDomain') ?>,
                        addCls: 'sb-remove-selected',
                        handler: function (event) {
                            Jsw.getComponent('restricted-domains-list').execGroupOperation({
                                url: '/domain-restriction/remove?redirect=/admin/domain-restriction/list/',
                                subtype: 'delete',
                                mouseEvent: event,
                                locale: {
                                    confirmOnGroupOperation: <?php echo $this->restrictedDomainsList->jsLmsg('confirmOnRemove'); ?>
                                }
                            });
                        }
                    }
                ],
                columns: [
                    Jsw.list.COLUMN_SELECTION,
                    {
                        header: <?php echo $this->restrictedDomainsList->jsLmsg('name');?>,
                        sortable: true,
                        dataIndex: 'name',
                        renderer: function (item) {
                            return '<a href="' + Jsw.prepareUrl('/domain-restriction/edit/id/' + encodeURIComponent(item.id)) + '">' + Jsw.escapeHtml(item.name) + '</a>';
                        }
                    }
                ]
            })
        ]
    });
//]]>
</script>

<?php echo $this->requireJs('app/domain/restriction', [
    'listToggleStatus' => $this->listIsEnabled,
    'resolutionToggleStatus' => $this->resolutionCheckerIsEnabled,
    'resolutionToggleIsAllowed' => $this->resolutionCheckerIsAllowed,
    'renderTo' => 'toggle-block',
]) ?>
