Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var CSDModel = require('./models/CSDModel');
- var _ = require('lodash');
- module.exports = {//<-- Required by Node
- "routes" : {
- "partial/:fileName": {
- get: function(nerd, rez){
- return rez.sendFile('./views/' + nerd.params.fileName);
- },
- post: function(nerd, success, error){
- return success("");
- }
- },
- "style/:fileName": {
- get: function(nerd, rez){
- return rez.sendFile('./style/' + nerd.params.fileName);
- }
- },
- "images/:fileName": {
- get: function(nerd, rez){
- return rez.sendFile('./images/' + nerd.params.fileName);
- }
- },
- "itemTable":{
- get: function(nerd, rez){
- var Vendors ={};
- var Clients ={};
- var Warehouse = nerd.query.warehouse;
- var Supplier = nerd.query.supplier;
- GetVendors(nerd.user,function(VendorList){
- Vendors = VendorList;
- console.log('yay');
- console.log(Vendors);
- urmom();
- });
- nerd.user.getAppInfo('3plink','client')
- .then(function(data){
- var ClientString = _.pluck(data,'value').join("','");
- Clients = "('" + ClientString + "')";
- urmom();
- })
- .catch(function(err){
- return rez.error(err);
- });
- var urmom = _.after(2,function(){
- var input = {};
- input.vendor = Vendors;
- input.client = Clients;
- input.name = nerd.user.user_name;
- if(Warehouse != undefined)
- input.warehouse = Warehouse;
- if(Supplier != undefined)
- input.Supplier = Supplier;
- CSDModel(input).item()
- .then(function(record){
- return rez({data: record});
- })
- .catch(function(err){
- return rez.error(err);
- });
- });
- }
- },
- "LotsForItem/":{
- get: function(nerd, rez){
- var reservationData;
- var lotData;
- CSDModel(nerd).LotsForItem()
- .then(function(record){
- lotData = record;
- loadDropdown();
- })
- .catch(function(err){
- return rez.error(err);
- });
- CSDModel(nerd).LotsForItem()
- .then(function(record){
- reservationData = record;
- loadDropdown();
- })
- .catch(function(err){
- return rez.error(err);
- });
- var loadDropdown = _.after(2,function(){
- var lots = lotData;
- console.log(lots);
- });
- }
- }
- }
- };
- //Pass User and callback function, not NERD
- function GetVendors(user, fn){<-- fn = passed callback function
- user.getAppInfo('3plink','vendorname')
- .then(function(data){
- var VendorString = _.pluck(data,'value').join("','");
- var VendorList = "('" + VendorString + "')";
- return fn(VendorList);<-- Run callback function and pass vendor list when retrieved
- })
- .catch(function(err){
- return fn(err);<-- return error or possibly null
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement