const AccessDataTable = {
    templateUrl : 'js/app/components/settings/access-data-table.html',
    create : function( props )
    {
        var app = this.app,
            self = this;
        this.render( { members: props.get( 'members' ) } );

        $( this.container ).on( 'click', '[data-type="btnGrantManagerAccess"]', function( e )
        {
            e.stopPropagation();
            self.dispatchEvent( { type : 'grantManagerAccess', data : { memberId : $( this ).attr( 'data-member-id' ) } } );
        });

        $( this.container ).on( 'click', '[data-type="btnRemoveManagerAccess"]', function( e )
        {
            e.stopPropagation();
            self.dispatchEvent( { type : 'removeManagerAccess', data : { memberId : $( this ).attr( 'data-member-id' ) } } );
        });

        $( this.container ).find( '.datatable' ).DataTable( {
            pageLength: 50,
            responsive: true,
            dom: '<"html5buttons"B>lTfgitp',
            language : {
                search      : 'Suche',
                emptyTable  : 'Keine Einträge vorhanden.',
                zeroRecords : 'Keine Einträge vorhanden.',
                info        : 'Zeige _START_ bis _END_ von _TOTAL_ Einträgen',
                lengthMenu : 'Zeige _MENU_ Einträge',
                paginate : {
                    first : 'Erste',
                    previous : 'Vorherige',
                    next : 'Nächste',
                    last : 'Letzte'
                },
            },
            buttons: [
                { extend: 'copy'},
                {extend: 'csv'},
                {extend: 'excel', title: 'Mitgliederliste'},
                {extend: 'pdf', title: 'Mitgliederliste'},

                {extend: 'print',
                    customize: function (win){
                        $(win.document.body).addClass('white-bg');
                        $(win.document.body).css('font-size', '10px');

                        $(win.document.body).find('table')
                            .addClass('compact')
                            .css('font-size', 'inherit');
                    }
                }
            ]

        });
    },

    destroy : function()
    {

    }
};

export { AccessDataTable };