/**
 * @package     DOCman
 * @copyright   Copyright (C) 2019 Timble CVBA. (http://www.timble.net)
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.joomlatools.com
 */

(function(wp, editor, blockEditor, components, blocks)
{
    document.addEventListener("DOMContentLoaded", function()
    {
        var el = wp.element.createElement;

        var blockName = 'docman/submit';
        var config = FoliokitBlockConfigurations[blockName];

        Docman.Block.setConfig(config);

        config.edit = function(props) {

            var _ = Foliokit.translate;

            return [
                el(
                    blockEditor.InspectorControls,
                    null,
                    el(components.PanelBody, {
                        title: _('General'),
                        initialOpen: true
                    }, [
                        Docman.Block.getControl('category_id', config.attributes.category_id, props),
                        Docman.Block.getControl('category_children', config.attributes.category_children, props),
                        Docman.Block.getControl('auto_publish', config.attributes.auto_publish, props),
                        Docman.Block.getControl('show_description', config.attributes.show_description, props),
                    ]),
                    el(components.PanelBody, {
                        title: _('Notifications'),
                        initialOpen: true
                    }, [
                        Docman.Block.getControl('notification_emails', config.attributes.notification_emails, props),
                    ])
                ),
                el(components.Placeholder, {
                    label: config.title,
                    icon: config.icon
                }, [

                ])
            ];
        };

        config.save = function()  {
            return null; //save has to exist. This all we need
        };

        config.icon = Docman.Block.icon;


        blocks.registerBlockType(blockName, config);
    });
})(wp, wp.editor, wp.blockEditor, wp.components, wp.blocks);
