if(typeof window.PriceListModule ==="undefined") {
    class PriceListModule extends ModuleBase{

        datatableRowActionAttachment(rowData,node) {
            debug('call datatableRowActionAttachment');
            super.datatableRowActionAttachment(rowData,node,{defaultFileName:"arlista.xls"});
        }
        datatableRowActionView(rowData,node) {
            debug('call datatableRowActionView');
        }

        datatableRowActionButtonClick(event) {
            debug('datatableRowActionButtonClick');
            let rootObj=APP.PriceListModule;
            let node = $(event[0].currentTarget);
            let row = $(rootObj.Opts.dataTable.CSSSelector).DataTable().row(node.parents('tr'));
            let rowData = row.data();
            let actionName = 'datatableRowAction' + node.data('buttontype').capitalize();
            if (typeof rootObj[actionName] === "function") {
                return rootObj[actionName](rowData, node)
            }
        }
        initViewList(options={}) {
            debug('listview inicialization');
            let dataTableCSSSelector=this.Opts.CSSSelectorContainer+' .dataTable'; //
            let colNum=$(dataTableCSSSelector+' thead th').length; //buttons insert position need
            APP.setOpts({
                //datatableRowActionButtonClickCallBack:this.datatableRowActionButtonClick,
                datatableRowActionButtonClickCallBack:this.datatableRowActionButtonClick,
            })
            let orderDirective=this.Opts.dataTable.orderDirective;

            if(typeof options['orderDirective']!='undefined'){
                orderDirective=options['orderDirective'];
            }
            //let ajaxUrl=this.Opts.URL.getDataTableContent;
            $(dataTableCSSSelector).DataTable( {
                language: {
                    url: '//cdn.datatables.net/plug-ins/1.10.24/i18n/Hungarian.json'
                },

                //"ajax": "{{asset('exapmle2.json')}}",
                "ajax": {
                    url:this.Opts.URL.getDataTableContent,
                    data:function (data) {
                        /*
                                                data.searchStr=dataTableSearchStr;
                                                data.groupId=selectedProductGroup;
                                                data.supplierId=Order.supplierId;
                                                data.deliveryDate=Order.deliveryDate;
                        */
                    }
                },
                "columnDefs": [
                    {
                        "targets": colNum-1,
                        "render": function ( data, type, row ) {
                            if(row.fileUrl){
                                let buttons=APP.datatableAddRowAttachmentButton(0,arguments);
                                return buttons;
                            }else{
                                return '';
                            }
                        },
                    },
                   /* {
                        "targets": 1,
                        "render": function ( data, type, row ) {
                            row=null;
                            return type === "sort" ? data.latinise() : data;
                        },
                    },*/
                    //{ "visible": false,  "targets": [ 0 ] }
                ],
                buttons:{
                    buttons: [
                  /*      'excel','pdf',
                        {
                            extend: 'print',
                            //text: 'Print current page',
                            'title': 'title custom text',
                            'messageTop': 'Message On Top',
                            autoPrint: true
                        },
                  */      /**/
                    ]
                },
                "columns": [
                    { "data": "id" },
                    { "data": "supplierName" },
                    { "data": "available" },
                    { "data": "created_at" },
                    { "data": "note" },
                    null,
                ],
                "order": orderDirective,
                //"stateSave": true,
                "drawCallback": function( settings ) {
                    settings=null;
                    APP.datatableAddRowAction(dataTableCSSSelector);
                }
            } );
            debug('listview end');
        }

    };
    window.PriceListModule=PriceListModule;
};
