Created
February 23, 2016 17:56
-
-
Save rafael25/69ce7464fff9a2faa631 to your computer and use it in GitHub Desktop.
Setear objeto json usando el campo _id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "_id": 7, | |
| "assignmentDateFormats": {}, | |
| "idAssignment": 29, | |
| "assignmentDate": {}, | |
| "currentAssignment": 0, | |
| "idEmmployee": 24, | |
| "idDwEnterprise": 85, | |
| "idStock": 1, | |
| "idAccessLevel": 1, | |
| "dwEnterprises": { | |
| "_id": 8, | |
| "idDwEnterprise": 85, | |
| "idBrand": 0, | |
| "idGbranch": 0, | |
| "idGroup": 1, | |
| "idDistributor": 9, | |
| "idRegion": 3, | |
| "idBranch": 79, | |
| "idArea": 5, | |
| "budgetable": 1, | |
| "group": 3, | |
| "distributor": { | |
| "idDistributor": 9, | |
| "distributorName": "BID GROUP", | |
| "acronyms": "BID", | |
| "hasStock": 1 | |
| }, | |
| "region": { | |
| "idRegion": 3, | |
| "regionName": "CENTRO" | |
| }, | |
| "branch": { | |
| "idBranch": 79, | |
| "branchName": "CORPORATIVO", | |
| "branchShort": "CORPORATIVO", | |
| "location": "CORPORATIVO- TORRE VIRREYES", | |
| "address": null, | |
| }, | |
| "area": { | |
| "idArea": 5, | |
| "areaName": "RRHH" | |
| }, | |
| "budgetMonthBranchList": null, | |
| "dwEmployeesList": null | |
| }, | |
| "employee": 4, | |
| "stocks": null | |
| }, | |
| { | |
| "_id": 9, | |
| "assignmentDateFormats": {}, | |
| "idAssignment": 28, | |
| "assignmentDate": {}, | |
| "currentAssignment": 0, | |
| "idEmmployee": 19, | |
| "idDwEnterprise": 85, | |
| "idStock": 1, | |
| "idAccessLevel": 1, | |
| "dwEnterprises": 8, | |
| "employee": { | |
| "_id": 10, | |
| "firstName": "Rafael", | |
| "middleName": "", | |
| "parentalLast": "Viveros", | |
| "motherLast": "Badillo", | |
| "rfc": "_3", | |
| "claveSap": "_3", | |
| "curp": null, | |
| "imss": null, | |
| "infonavitNumber": null, | |
| "mail": null, | |
| "employeeType": null, | |
| "contractType": null, | |
| "salary": 0.00, | |
| "state": null, | |
| "joinDateFormats": {}, | |
| "bithDayFormats": {}, | |
| "idEmployee": 19, | |
| "employeeNumber": null, | |
| "joinDate": {}, | |
| "status": 1, | |
| "birthPlace": null, | |
| "birthday": {}, | |
| "street": null, | |
| "exteriorNumber": null, | |
| "interiorNumber": null, | |
| "colonia": null, | |
| "city": null, | |
| "postcode": null, | |
| "cellPhone": null, | |
| "fatherName": null, | |
| "motherName": null, | |
| "dwEmployeesList": null, | |
| "employeesAccountsList": null | |
| }, | |
| "stocks": null | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fetchStockAssignmentsRecord: function (article) { | |
| this.$http.get( | |
| ROOT_URL + "/stock/" + article.idStock + "/assignments/record" | |
| ).success(function(data) { | |
| var jsonObjectIndex = {}; | |
| data.forEach(function (el) { | |
| if (isNaN(el.dwEnterprises)) { | |
| jsonObjectIndex[el.dwEnterprises._id] = el.dwEnterprises; | |
| } else { | |
| el.dwEnterprises = jsonObjectIndex[el.dwEnterprises]; | |
| } | |
| if (isNaN(el.employee)) { | |
| jsonObjectIndex[el.employee._id] = el.employee; | |
| } else { | |
| el.employee = jsonObjectIndex[el.employee]; | |
| } | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment