/** * Author: Thilina Hasantha */ function CompanyStructureAdapter(endPoint) { this.initAdapter(endPoint); } CompanyStructureAdapter.inherits(AdapterBase); CompanyStructureAdapter.method('getDataMapping', function() { return [ "id", "title", "address", "type", "country", "parent" ]; }); CompanyStructureAdapter.method('getHeaders', function() { return [ { "sTitle": "ID","bVisible":false }, { "sTitle": "Name" }, { "sTitle": "Address","bSortable":false}, { "sTitle": "Type"}, { "sTitle": "Country", "sClass": "center" }, { "sTitle": "Parent Structure"} ]; }); CompanyStructureAdapter.method('getFormFields', function() { return [ [ "id", {"label":"ID","type":"hidden","validation":""}], [ "title", {"label":"Name","type":"text","validation":""}], [ "description", {"label":"Details","type":"textarea","validation":""}], [ "address", {"label":"Address","type":"textarea","validation":"none"}], [ "type", {"label":"Type","type":"select","source":[["Company","Company"],["Head Office","Head Office"],["Regional Office","Regional Office"],["Department","Department"],["Unit","Unit"],["Sub Unit","Sub Unit"],["Other","Other"]]}], [ "country", {"label":"Country","type":"select","remote-source":["Country","code","name"]}], [ "parent", {"label":"Parent Structure","type":"select","allow-null":true,"remote-source":["CompanyStructure","id","title"]}] ]; }); /* * Company Graph */ function CompanyGraphAdapter(endPoint) { this.initAdapter(endPoint); this.nodeIdCounter = 0; } CompanyGraphAdapter.inherits(CompanyStructureAdapter); CompanyGraphAdapter.method('convertToTree', function(data) { var ice = {}; ice['id'] = -1; ice['title'] = ''; ice['name'] = ''; ice['children'] = []; var parent = null; var added = {}; for(var i=0;i"; obj.parent = null; break; } parentIdArr[parent.id] = 1; curObj = parent; } } if(errorMsg != ""){ this.showMessage("Company Structure is having a cyclic dependency","We found a cyclic dependency due to following reasons:
"+errorMsg); return false; } return true; }); CompanyGraphAdapter.method('getHelpLink', function () { return 'http://blog.icehrm.com/?page_id=61'; });