Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var fake = {};
- fake.dl = function (fn, r) { setTimeout(function () { fn(r); }, 200); };
- app.sds = (function () {
- // on error
- onE = function (efn, e) {
- e = e || "";
- if (console && console.log) { console.log("error " + e); }
- if (efn) { efn(e); }
- };
- function postit(commandName, data, fn, donotRefresh){
- $.ajax({
- url: "/c/"+app.currentPortfolio.portfolioId+commandName,
- type: "POST",
- data: JSON.stringify(data),
- contentType: "application/json",
- success: function(){
- // refresh the main model
- alert('success');
- // if(!donotRefresh){
- // self.views.getPortfolioView(fn);
- // }else{
- // fn();
- // }
- },
- error: function (res) {
- alert('fail');
- // app.logger.log(res);
- }
- });
- }
- var self = {
- saveQuickStartWizard: function (qprop, success, error) {
- postit("/wizards/quickStart", qprop, function(res){
- success(res);
- });
- },
- // not done
- //////////////////////////////////////////////////
- createMessage: function (messageData, success, error) {
- postit("/messaging/createMessage", messageData, function (res) {
- app.sds.messages = undefined;
- success(res);
- });
- },
- addMessageComment: function (commentData, success, error) {
- postit("/messaging/addMessageComment", commentData, function(res) {
- app.sds.messages = undefined;
- success(res);
- });
- },
- addShare: function (shareData, success, error) {
- postit("/portfolio/addShare", shareData, function(res) {
- success(res);
- });
- },
- updatePortfolio: function (portfolioData, success, error) {
- postit("/portfolio/update", portfolioData, function(res) {
- success(res);
- });
- },
- saveManualIncome: function(incCmd, success, error){
- postit("/income/recordManualsIncome", incCmd, function(res){
- success(res);
- }, true /*skip refresh*/);
- },
- saveBillIncome: function(incomeFromBillsModel, success, error){
- postit("/income/recordBillsIncome", incomeFromBillsModel, function(res){
- success(res);
- }, true /*skip refresh*/);
- },
- createExpense: function (expense, success, error) {
- postit("/expense/record", expense, function(res){
- success(res);
- }, true /*skip refresh*/);
- },
- createTenant: function (tenant, success, error) {
- postit("/tenant/create", tenant, function(res){
- success(res);
- });
- },
- createUnit: function (unit, success, error) {
- postit("/unit/create", unit, function(res){
- success(res);
- });
- },
- saveUnit: function(unit, success, error){
- // TODO: need to hook sds#saveUnit to backend
- success();
- },
- createProperty: function (prop, success, error){
- postit("/property/create", prop, function(res){
- success(res);
- });
- },
- saveProperty: function(prop, success, error){
- // TODO: need to hook sds#saveProperty to backend
- success();
- },
- saveTenant: function (tenant, success, error) {
- // TODO: need to hook sds#saveTenant to backend
- fake.dl(success, null, error);
- },
- createRentalBill: function(rentalBill, success, error){
- // TODO: need to hook sds#createRentalBill to backend
- fake.dl(success, null, error);
- },
- saveRentalBill : function (rentalBill, success, error) { fake.dl(success, null, error); },
- deactivateBill : function (id, success, error) { fake.dl(success, null, error); },
- //
- editTransaction: function (transaction, success, error) {
- // expect back a transaction view item
- var newTransactionView = transaction;
- fake.dl(function () { success(newTransactionView); }, null, error);
- },
- createPortfolio: function (portfolioData, success, error) {
- postit("/portfolio/create", portfolioData, function(res) {
- success(res);
- });
- }
- };
- return self;
- } ());
Add Comment
Please, Sign In to add comment