From e12c2b01d0fee99e0d3079edbbe66a105f82c238 Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Mon, 9 Mar 2015 07:09:34 +0100 Subject: [PATCH] application no longer thanks people for ordering nothing --- back-office/Gemfile.lock | 4 +- back-office/config/application.rb | 3 + front-api/Gemfile | 1 + front-api/Gemfile.lock | 18 +++++ front-api/db/schema.rb | 6 +- front-ui/app/components/cart/cartPage.js | 14 +++- ...ehmedpasa's conflicted copy 2015-03-07).js | 76 +++++++++++++++++++ .../shared/mixins/ribicaValidationMixin.js | 1 - 8 files changed, 115 insertions(+), 8 deletions(-) create mode 100644 front-ui/app/components/shared/mixins/ribicaValidationMixin (mehmedpasa's conflicted copy 2015-03-07).js diff --git a/back-office/Gemfile.lock b/back-office/Gemfile.lock index 32c03c3..9906f14 100644 --- a/back-office/Gemfile.lock +++ b/back-office/Gemfile.lock @@ -1,9 +1,9 @@ GIT remote: git://github.com/activescaffold/active_scaffold.git - revision: 4693e8a3278702143b1668fb5f6317b1c4f90388 + revision: 6f637d62c7b4eb7ae49a28f6b8c9b86997a326a3 branch: master specs: - active_scaffold (3.4.14) + active_scaffold (3.4.17) rails (>= 3.2.18, < 5) GEM diff --git a/back-office/config/application.rb b/back-office/config/application.rb index c15d433..c5c415e 100644 --- a/back-office/config/application.rb +++ b/back-office/config/application.rb @@ -22,5 +22,8 @@ module Ribicabackoffice # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true + config.assets.precompile += %w(*.svg *.eot *.woff *.ttf *.gif *.png *.ico) end end + + diff --git a/front-api/Gemfile b/front-api/Gemfile index 28560e4..38d0f55 100644 --- a/front-api/Gemfile +++ b/front-api/Gemfile @@ -20,3 +20,4 @@ gem "sinatra-activerecord" gem "json" gem 'puma' gem "sinatra-contrib" +gem 'rerun' diff --git a/front-api/Gemfile.lock b/front-api/Gemfile.lock index 976bd50..c321708 100644 --- a/front-api/Gemfile.lock +++ b/front-api/Gemfile.lock @@ -24,11 +24,21 @@ GEM bcrypt (3.1.10) bcrypt (3.1.10-java) builder (3.2.2) + celluloid (0.16.0) + timers (~> 4.0.0) + ffi (1.9.6) + ffi (1.9.6-java) + hitimes (1.2.2) + hitimes (1.2.2-java) i18n (0.7.0) jdbc-postgres (9.3.1102) jruby-openssl (0.9.6-java) json (1.8.1) json (1.8.1-java) + listen (2.8.5) + celluloid (>= 0.15.2) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) minitest (5.5.0) multi_json (1.10.1) pg (0.17.1) @@ -41,6 +51,11 @@ GEM rack rack-test (0.6.3) rack (>= 1.0) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + rerun (0.10.0) + listen (~> 2.7, >= 2.7.3) sinatra (1.4.5) rack (~> 1.4) rack-protection (~> 1.4) @@ -58,6 +73,8 @@ GEM thread_safe (0.3.4) thread_safe (0.3.4-java) tilt (1.4.1) + timers (4.0.1) + hitimes tzinfo (1.2.2) thread_safe (~> 0.1) @@ -73,6 +90,7 @@ DEPENDENCIES json pg puma + rerun sinatra sinatra-activerecord sinatra-contrib diff --git a/front-api/db/schema.rb b/front-api/db/schema.rb index 317216c..15568c9 100644 --- a/front-api/db/schema.rb +++ b/front-api/db/schema.rb @@ -105,10 +105,8 @@ ActiveRecord::Schema.define(version: 20150222055517) do end create_table "sub_categories", force: :cascade do |t| - t.string "name" - t.integer "category_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "name" + t.integer "category_id" end create_table "units", force: :cascade do |t| diff --git a/front-ui/app/components/cart/cartPage.js b/front-ui/app/components/cart/cartPage.js index afa5563..6750f39 100644 --- a/front-ui/app/components/cart/cartPage.js +++ b/front-ui/app/components/cart/cartPage.js @@ -15,7 +15,7 @@ var CartPage = React.createClass({ render: function() { - var counts = this.state.itemCounts; + var counts = this.state.itemCounts; var displayedItems = this.state.items.map(function (i) { @@ -35,6 +35,7 @@ var CartPage = React.createClass({ ) }); + console.log("bla :" , this.state.items.length); var cartTotal = (
@@ -43,12 +44,23 @@ var CartPage = React.createClass({
); + + var buySomethingMessage = (
); + + if (this.state.items.length <= 0) { + cartTotal = (
) + buySomethingMessage = (
Nemate ni jedan artikal u vašoj korpi. Kada vidite nešto što vam se sviđa - pritisnite dugme KUPI pored artikla kako biste ga dodali u korpu.
) + + }; + + console.log("length :" , this.state.items.length); return (
{cartTotal} {displayedItems} + {buySomethingMessage} {cartTotal}
); diff --git a/front-ui/app/components/shared/mixins/ribicaValidationMixin (mehmedpasa's conflicted copy 2015-03-07).js b/front-ui/app/components/shared/mixins/ribicaValidationMixin (mehmedpasa's conflicted copy 2015-03-07).js new file mode 100644 index 0000000..fc9809b --- /dev/null +++ b/front-ui/app/components/shared/mixins/ribicaValidationMixin (mehmedpasa's conflicted copy 2015-03-07).js @@ -0,0 +1,76 @@ +var RibicaValidationMixin = { + _updateState: function(prop, value, callback) { + var newState = {}; + newState[prop] = value; + this.setState(newState, function(){ + if(callback) { + callback(); + } + }.bind(this)); + }, + _validate: function(prop, value) { + if(this.validations && this.validations[prop]) { + var cb = function(err, revalidateFields) { + var errors = this.state.errors || {}; + if (err !== undefined) { + if(err.length > 0) { + errors[prop] = err; + } else { + delete errors[prop]; + } + } else { + delete errors[prop]; + } + this.setState({errors: errors}); + if (revalidateFields) { + for(var i = 0; i < revalidateFields.length; i++) { + this.validateField(revalidateFields[i], this.state[revalidateFields[i]]); + } + } + }.bind(this); + + var immediateErrors = this.validations[prop](value, cb); + cb(immediateErrors); + } + }, + handleChange: function(prop) { + return function(event) { + event.preventDefault(); + var target = event.target; + this._updateState(prop, target.value, function(){ + this._validate(prop, target.value); + }.bind(this)); + }.bind(this); + + }, + getValidationMessages:function(prop) { + var errors = this.state.errors || {}; + return (errors[prop] || []); + }, + validateField: function(field) { + this._validate(field, this.state[field]); + }, + validate: function() { + for (var key in this.state) { + if (this.state.hasOwnProperty(key)) { + this._validate(key, this.state[key]); + } + } + return this.isValid(); + }, + isValid: function() { + var errors = this.state.errors || {}; + return Object.keys(errors).length === 0; + }, + componentDidMount : function(){ + this.setState({errors: {}}); + if (this.validations) { + var self = this; + this.validations.getState = function() { + return self.state; + }; + } + }, +}; + +module.exports = RibicaValidationMixin; diff --git a/front-ui/app/components/shared/mixins/ribicaValidationMixin.js b/front-ui/app/components/shared/mixins/ribicaValidationMixin.js index fc9809b..e8bf0c1 100644 --- a/front-ui/app/components/shared/mixins/ribicaValidationMixin.js +++ b/front-ui/app/components/shared/mixins/ribicaValidationMixin.js @@ -63,7 +63,6 @@ var RibicaValidationMixin = { return Object.keys(errors).length === 0; }, componentDidMount : function(){ - this.setState({errors: {}}); if (this.validations) { var self = this; this.validations.getState = function() {