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

    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',
                        href: '/domain-restriction/add'
                    },{
                        componentType: 'Jsw.bar.Separator'
                    },{
                        componentType: 'Jsw.SmallButton',
                        <?php if ($this->listIsEnabled) : ?>
                            id: 'buttonDisableList',
                            attrs: { 'data-method': 'post' },
                            title: <?php echo $this->restrictedDomainsList->jsLmsg('buttonDisableList');?>,
                            description: <?php echo $this->restrictedDomainsList->jsLmsg('hintDisableList') ?>,
                            addCls: 'sb-suspend',
                            href: '/domain-restriction/disable?redirect=/domain-restriction/list/'
                        <?php else: ?>
                            id: 'buttonEnableList',
                            attrs: { 'data-method': 'post' },
                            title: <?php echo $this->restrictedDomainsList->jsLmsg('buttonEnableList');?>,
                            description: <?php echo $this->restrictedDomainsList->jsLmsg('hintEnableList') ?>,
                            addCls: 'sb-activate',
                            href: '/domain-restriction/enable?redirect=/domain-restriction/list/'
                        <?php endif; ?>
                    }, {
                        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>
