diff options
Diffstat (limited to 'StoneIsland/www/js/lib/account/ShippingView.js')
| -rw-r--r-- | StoneIsland/www/js/lib/account/ShippingView.js | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/StoneIsland/www/js/lib/account/ShippingView.js b/StoneIsland/www/js/lib/account/ShippingView.js index e2426d2e..b8b260ab 100644 --- a/StoneIsland/www/js/lib/account/ShippingView.js +++ b/StoneIsland/www/js/lib/account/ShippingView.js @@ -2,8 +2,7 @@ var ShippingView = FormView.extend({ el: "#shipping", - createAction: sdk.address.add, - updateAction: sdk.address.update, + action: sdk.address.add, events: { }, @@ -11,14 +10,14 @@ var ShippingView = FormView.extend({ test_data: { "Name":"name", "Surname":"surname", - "Address":"address", + "Address":"address1\naddress2", "IsDefault":false, "IsBillingDefault":false, "IsOwner":false, "ZipCode":"88040", "City":"City", - "Province":"Province", - "Phone":"Phone", + "Province":"NY", + "Phone":"1234567890", "Mobile":"Mobile", "Mail":"Mail", "UserId": sdk.auth.user_id, @@ -27,37 +26,51 @@ var ShippingView = FormView.extend({ initialize: function(){ this.$form = this.$("form") this.$msg = this.$(".msg") - this.$isDefault = this.$("[name=IsDefault]") this.address = new AddressView ({ parent: this }) this.scroller = new IScroll('#shipping', app.iscroll_options) - this.preload() }, show: function(){ if (! auth.logged_in()) { return app.router.go("intro") } +// this.preload( this.data || this.test_data ) app.footer.show("SAVE", "CANCEL") document.body.className = "shipping" }, + populate: function(data){ + this.data = data || this.data + this.address.populate(data) + }, + finalize: function(data){ if (this.address.data && this.address.data.Id) { sdk.address.destroy({ id: this.address.data.Id, - success: function(){ console.log("destroyed") }, - error: function(){ console.log("destroyed") }, + success: function(){}, + error: function(){}, }) - this.action = this.updateAction - } - else { - this.action = this.createAction } - data.IsDefault = data.IsDefault ? "true" : "false" - data.Address = data.Address1 + "\n" + data.Address2 - delete data.Address1 - delete data.Address2 + + data.IsDefault = "true" // this.$isDefault.prop("checked") ? "true" : "false" + data.UserId = sdk.auth.user_id + console.log(data) - return return data }, + + success: function(data){ + app.curtain.show("loading") + app.account.listAddresses(function(){ + app.curtain.hide("loading") + }) + }, + + error: function(data){ + console.log(data) + }, + + cancel: function(){ + app.router.go("intro") + }, })
\ No newline at end of file |
