diff --git a/back-office/app/models/delivery_destination.rb b/back-office/app/models/delivery_destination.rb index 01ebde4..ecb39d0 100644 --- a/back-office/app/models/delivery_destination.rb +++ b/back-office/app/models/delivery_destination.rb @@ -1,2 +1,2 @@ -class DeliveryDestination < ActiveRecord::Base +class DeliveryDestination < ActiveRecord::Base end diff --git a/front-api/db/migrate/20150222053732_add_user_to_delivery_destination.rb b/front-api/db/migrate/20150222053732_add_user_to_delivery_destination.rb new file mode 100644 index 0000000..a8cf194 --- /dev/null +++ b/front-api/db/migrate/20150222053732_add_user_to_delivery_destination.rb @@ -0,0 +1,6 @@ +class AddUserToDeliveryDestination < ActiveRecord::Migration + def change + add_column :delivery_destinations, :user_id, :integer + add_column :delivery_destinations, :anonymous_id_string, :string + end +end diff --git a/front-api/db/migrate/20150222055517_add_address_to_cart.rb b/front-api/db/migrate/20150222055517_add_address_to_cart.rb new file mode 100644 index 0000000..0157306 --- /dev/null +++ b/front-api/db/migrate/20150222055517_add_address_to_cart.rb @@ -0,0 +1,5 @@ +class AddAddressToCart < ActiveRecord::Migration + def change + add_column :carts, :delivery_destination_id, :integer + end +end diff --git a/front-api/db/schema.rb b/front-api/db/schema.rb index 29c6457..317216c 100644 --- a/front-api/db/schema.rb +++ b/front-api/db/schema.rb @@ -11,18 +11,18 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150220062314) do - +ActiveRecord::Schema.define(version: 20150222055517) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" create_table "carts", force: :cascade do |t| t.integer "user_id" - t.boolean "ordered", default: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.boolean "ordered", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "anonymous_id_string" + t.integer "delivery_destination_id" end create_table "categories", force: :cascade do |t| @@ -45,6 +45,8 @@ ActiveRecord::Schema.define(version: 20150220062314) do t.string "email_verification_code" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "user_id" + t.string "anonymous_id_string" end create_table "filter_criteria", force: :cascade do |t| @@ -103,8 +105,10 @@ ActiveRecord::Schema.define(version: 20150220062314) do end create_table "sub_categories", force: :cascade do |t| - t.string "name" - t.integer "category_id" + t.string "name" + t.integer "category_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "units", force: :cascade do |t| diff --git a/front-ui/app/components/rootApp.js b/front-ui/app/components/rootApp.js index 1b2d7de..785fb22 100644 --- a/front-ui/app/components/rootApp.js +++ b/front-ui/app/components/rootApp.js @@ -15,7 +15,7 @@ var RootApp = React.createClass({
-

ribica.ba

+

ribica.ba

diff --git a/front-ui/app/constants/cartConstants.js b/front-ui/app/constants/cartConstants.js index da84ee5..5f8414d 100644 --- a/front-ui/app/constants/cartConstants.js +++ b/front-ui/app/constants/cartConstants.js @@ -8,5 +8,6 @@ module.exports = keyMirror({ // and not just decrease count by 1 TAKE_ITEM_OUT: null , CART_DATA_LOADED: null, - SAVE_CART_STATE_FOR_ITEM: null + SAVE_CART_STATE_FOR_ITEM: null, + CHANGE_DELIVERY_DESTINATION_PROPERTY: null }); diff --git a/front-ui/app/models/deliveryDestination.js b/front-ui/app/models/deliveryDestination.js new file mode 100644 index 0000000..52712d2 --- /dev/null +++ b/front-ui/app/models/deliveryDestination.js @@ -0,0 +1,22 @@ +var Backbone = require('backbone'); +var Globals = require('../globals'); + +var DeliveryDestination = Backbone.Model.extend({ + + initialize: function() { + $.ajaxPrefilter( + function(options, originalOptions, jqXHR) { + options.xhrFields = { + withCredentials: true + } + } + ); + }, + + url: Globals.ApiUrl + '/cart/delivery_destination', + defaults: { + count: 0 + } +}); + +module.exports = DeliveryDestination; \ No newline at end of file diff --git a/front-ui/app/stores/cartStore.js b/front-ui/app/stores/cartStore.js index af2ca2f..4710e3b 100644 --- a/front-ui/app/stores/cartStore.js +++ b/front-ui/app/stores/cartStore.js @@ -5,6 +5,7 @@ var CartActions = require('../actions/cartActions'); var ItemInCart = require('../models/itemInCart'); var ItemInCartCollection = require('../models/itemInCartCollection'); var ItemCollection = require('../models/itemCollection'); +var DeliveryDestination = require('../models/deliveryDestination'); var _ = require('underscore'); @@ -13,6 +14,7 @@ var states = {} var _itemsInCart = new ItemInCartCollection(); var _itemsForDisplay = new ItemCollection(); _itemsForDisplay.setFromCart(true); +var _deliveryDestination = new DeliveryDestination(); var loadCart = function() { @@ -103,7 +105,8 @@ var CartStore = _.extend({}, EventEmitter.prototype, { var state = { count: numberOfItems, items: _itemsForDisplay, - itemCounts: states + itemCounts: states, + deliveryDestination: _deliveryDestination }; return state; },