111 lines
4.2 KiB
JavaScript
111 lines
4.2 KiB
JavaScript
if(typeof window.SupplierModule ==="undefined") {
|
|
class SupplierModule extends ModuleBase{
|
|
|
|
datatableRowActionAttachment(rowData,node) {
|
|
debug('call datatableRowActionAttachment');
|
|
super.datatableRowActionAttachment(rowData,node,{defaultFileName:"arlista.xls"});
|
|
}
|
|
datatableRowActionView(rowData,node) {
|
|
debug('call datatableRowActionView');
|
|
super.datatableRowActionView(rowData,node,APP.SupplierModule);
|
|
}
|
|
|
|
datatableRowActionButtonClick(event) {
|
|
debug('datatableRowActionButtonClick');
|
|
let rootObj=APP.SupplierModule;
|
|
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)
|
|
}
|
|
}
|
|
initViewShow(){
|
|
$('.productCategorySelect').select2(
|
|
{
|
|
disabled:true,
|
|
}
|
|
);
|
|
$('.serviceSelect').select2(
|
|
{
|
|
disabled:true,
|
|
}
|
|
);
|
|
|
|
APP.SupplierModule.renderContact();
|
|
}
|
|
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": {
|
|
url:this.Opts.URL.getDataTableContent,
|
|
data:function (data) {
|
|
}
|
|
},
|
|
"columnDefs": [
|
|
{
|
|
"targets": colNum-1,
|
|
"render": function ( data, type, row ) {
|
|
let buttons=APP.datatableAddRowViewButton(0,arguments);
|
|
return buttons;
|
|
},
|
|
},
|
|
],
|
|
buttons:{
|
|
buttons: [
|
|
]
|
|
},
|
|
"columns": [
|
|
{ "data": "name" },
|
|
{ "data": "product_group" },
|
|
{ "data": "service" },
|
|
/*
|
|
{ "data": "hooreycaId" },
|
|
{ "data": "nameId" },
|
|
{ "data": "created_at" },
|
|
*/
|
|
null,
|
|
],
|
|
"order": orderDirective,
|
|
//"stateSave": true,
|
|
"drawCallback": function( settings ) {
|
|
settings=null;
|
|
APP.datatableAddRowAction(dataTableCSSSelector);
|
|
}
|
|
} );
|
|
debug('listview end');
|
|
}
|
|
renderContact(){
|
|
let rowNum=1;
|
|
console.log('renderingContacts');
|
|
$.each(APP.Supplier.getData('contact'),function (){
|
|
let contactData=this;
|
|
contactData.rowNum=rowNum;
|
|
//console.log(contactData);
|
|
let template=$('template[data-name="supplierContactTableRow"]').html()
|
|
let render=Mustache.render(template,contactData);
|
|
$('.contactTable tbody').append(render);
|
|
rowNum++;
|
|
});
|
|
}
|
|
|
|
};
|
|
window.SupplierModule=SupplierModule;
|
|
};
|