Advertisement
al_himik

Why do I hate js

Jul 12th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. this.load = (getManagersOptionsM, callback) => {
  2.                 clearTimeout(getManagerUsers);
  3.                 getManagerUsers = setTimeout(() => {
  4.                     var notNull = getManagersOptionsM.DepartmentCodes != null && getManagersOptionsM.ProjectCodes != null && getManagersOptionsM.ClauseCodes != null;
  5.                     var hasValues = getManagersOptionsM.DepartmentCodes.length > 0 && getManagersOptionsM.ProjectCodes.length > 0 && getManagersOptionsM.ClauseCodes.length > 0;
  6.                     var valueNotNull = hasValues && getManagersOptionsM.DepartmentCodes[0] !== "" && getManagersOptionsM.ProjectCodes[0] !== "" && getManagersOptionsM.ClauseCodes[0] !== "";
  7.                     if (notNull && valueNotNull) {
  8.                         getManagersOptionsM.InvoiceId = this.invoiceId;
  9.                         Api.AsyncClient.current.getManagersUsers(getManagersOptionsM, (result) => {
  10.                             var canAgreeInvoice = result.filter((u) => { return u.CanAgreeInvoice });
  11.                             var canApproveInvoice = result.filter((u) => { return u.CanApproveInvoice });
  12.                             var otherUsers = result.filter((u) => { return !u.CanAgreeInvoice && !u.CanApproveInvoice });
  13.                             var values = [];
  14.                             var emptyAgreeAndApprove = canAgreeInvoice.length === 0 && canApproveInvoice.length === 0;
  15.  
  16.                             if (this.userRole === Api.Roles.Inspector) {
  17.                                 values = canApproveInvoice.concat(canAgreeInvoice).concat(otherUsers);
  18.                             } else {
  19.                                 values = canAgreeInvoice.concat(canApproveInvoice).concat(otherUsers);
  20.                             }
  21.                             callback(values, emptyAgreeAndApprove);
  22.                         });
  23.                     }
  24.                 }, 300);
  25.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement