diff --git a/Gemfile b/Gemfile index 79ee3faf..871398b9 100644 --- a/Gemfile +++ b/Gemfile @@ -21,9 +21,9 @@ group :assets do gem 'sass-rails' #, '~> 4.0.2' gem 'coffee-rails' #, '~> 3.2.1' #gem 'twitter-bootstrap-rails' - gem 'bootstrap-sass', '~>2.3' - gem 'bourbon' - gem 'compass-rails' + #gem 'bootstrap-sass', '~>2.3' + #gem 'bourbon' + #gem 'compass-rails' gem 'js-routes' gem "font-awesome-rails" diff --git a/Gemfile.lock b/Gemfile.lock index e7f9fd6b..58e9431b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,8 +90,6 @@ GEM barber (>= 0.4.1) emblem-source bcrypt (3.1.7) - bootstrap-sass (2.3.2.2) - sass (~> 3.2) bourbon (3.2.0) sass (~> 3.2) thor @@ -105,7 +103,6 @@ GEM capybara-webkit (1.1.0) capybara (~> 2.0, >= 2.0.2) json - chunky_png (1.3.0) climate_control (0.0.3) activesupport (>= 3.0) cocaine (0.5.4) @@ -118,12 +115,6 @@ GEM coffee-script-source execjs coffee-script-source (1.7.0) - compass (0.12.6) - chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.2.19) - compass-rails (1.1.6) - compass (>= 0.12.2) connection_pool (1.2.0) cookiejar (0.3.2) couchbase (1.3.7) @@ -201,7 +192,6 @@ GEM foundation-rails (5.2.2.0) railties (>= 3.1.0) sass (>= 3.2.0) - fssm (0.2.10) fuubar (1.3.2) rspec (>= 2.14.0, < 3.1.0) ruby-progressbar (~> 1.3) @@ -388,13 +378,10 @@ PLATFORMS DEPENDENCIES active_decorator - bootstrap-sass (~> 2.3) - bourbon capybara capybara-webkit cmtool! coffee-rails - compass-rails couch_potato! couchbase couchbase-docstore diff --git a/app/assets/javascripts/theme1/application.js b/app/assets/javascripts/theme1/application.js index e0ef15b0..b62445ac 100644 --- a/app/assets/javascripts/theme1/application.js +++ b/app/assets/javascripts/theme1/application.js @@ -13,7 +13,7 @@ //= require jquery //= require jquery_ujs //= require jquery.ui.all -//= require bootstrap +// require bootstrap // require twitter/bootstrap //= require_directory . //= require_self diff --git a/app/assets/javascripts/user/app/controllers/application_controller.js.coffee b/app/assets/javascripts/user/app/controllers/application_controller.js.coffee index c6018061..76ca4cdb 100644 --- a/app/assets/javascripts/user/app/controllers/application_controller.js.coffee +++ b/app/assets/javascripts/user/app/controllers/application_controller.js.coffee @@ -58,7 +58,7 @@ App.ApplicationController = Ember.Controller.extend if list.get('join_requests').toArray().length @transitionToRoute 'join_requests' callback.call(@) if callback - error = (emberError)=> + error = @ajaxError (emberError)=> # if jqXHR.status == 404 officially, now assume close list on error #@redirect_to 'index', message: 'the_list_has_been_closed' console.log "Error: #{emberError.message}" if emberError.message diff --git a/app/assets/javascripts/user/app/modifications/controller_modifications.js.coffee b/app/assets/javascripts/user/app/modifications/controller_modifications.js.coffee index a6201d4e..d1a1ada8 100644 --- a/app/assets/javascripts/user/app/modifications/controller_modifications.js.coffee +++ b/app/assets/javascripts/user/app/modifications/controller_modifications.js.coffee @@ -1,10 +1,11 @@ ControllerExtensions = Ember.Mixin.create ajaxError: (callback)-> - handler = (jqXHR, textStatus, errorThrown)=> - console.log "Error: #{textStatus}: #{errorThrown}" - callback.call(@, jqXHR) - if jqXHR.status == 401 + handler = (emberError)=> + console.log "Error: status #{emberError.status}" + if emberError.status == 401 App.__container__.lookup('route:application').unauthorized() + else + callback.call(@, emberError) handler showModal: (options={})-> $(document).foundation('reflow') # needed (stupid!!!) @@ -12,6 +13,7 @@ ControllerExtensions = Ember.Mixin.create @set 'controllers.application.modal.title', options.title if options.title @set 'controllers.application.modal.content', options.content if options.content Ember.ArrayController.reopen ControllerExtensions +Ember.Controller.reopen ControllerExtensions Ember.Controller.reopen needs: ['application'] secured: (callback)-> diff --git a/app/assets/javascripts/user/app/routes/application_route.js.coffee b/app/assets/javascripts/user/app/routes/application_route.js.coffee index f46171a4..3664324a 100644 --- a/app/assets/javascripts/user/app/routes/application_route.js.coffee +++ b/app/assets/javascripts/user/app/routes/application_route.js.coffee @@ -14,6 +14,7 @@ App.ApplicationRoute = Ember.Route.extend Qstorage.setItem('auth_token', '') @controllerFor('application').set 'list', null App.obtain_token(t('messages.unauthorized')) + @controllerFor('application').redirect_to 'index', message: 'unauthorized' actions: openModal: (modalName, model)-> @controllerFor(modalName).set('model', model) diff --git a/app/assets/javascripts/user/app/templates/application.emblem b/app/assets/javascripts/user/app/templates/application.emblem index 8ccdecef..2d7ba7e3 100644 --- a/app/assets/javascripts/user/app/templates/application.emblem +++ b/app/assets/javascripts/user/app/templates/application.emblem @@ -59,20 +59,21 @@ header.top-menu App.MenuItemListNeedsHelpView App.MenuItemListNeedsPaymentView section.extra-info - .supplier-info-row - .supplier-name= list.supplier.name - .table-number - | - = t 'models.table' - | - = list.table.number - .supplier-info-row - .counter.supplier-orders-placed-count - = list.supplier.orders_placed_count - span.orders-placed-count-icon - .counter.supplier-orders-in-process-count - = list.supplier.orders_in_process_count - span.orders-in-process-count-icon + if list + .supplier-info-row + .supplier-name= list.supplier.name + .table-number + | + = t 'models.table' + | + = list.table.number + .supplier-info-row + .counter.supplier-orders-placed-count + = list.supplier.orders_placed_count + span.orders-placed-count-icon + .counter.supplier-orders-in-process-count + = list.supplier.orders_in_process_count + span.orders-in-process-count-icon aside.side-menu ul li diff --git a/app/assets/javascripts/user/app/templates/table.emblem b/app/assets/javascripts/user/app/templates/table.emblem index 22f97794..0ddd1a00 100644 --- a/app/assets/javascripts/user/app/templates/table.emblem +++ b/app/assets/javascripts/user/app/templates/table.emblem @@ -45,7 +45,7 @@ hr ul.product_category-products each product in product_category.products - li + li class="order-product-#{unbound product.id}" if product.description button.show-product-description{action showProductDescription product} span diff --git a/app/assets/javascripts/user/application.js.erb b/app/assets/javascripts/user/application.js.erb deleted file mode 100644 index 68b34f00..00000000 --- a/app/assets/javascripts/user/application.js.erb +++ /dev/null @@ -1,217 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// the compiled file. -// -// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD -// GO AFTER THE REQUIRES BELOW. -// -//= require jquery -//= require jquery_ujs -// require bootstrap-transition -// require bootstrap-affix -// require bootstrap-alert -// require bootstrap-button -// require bootstrap-carousel -// require bootstrap-collapse -// require bootstrap-dropdown -// require bootstrap-modal -// require bootstrap-scrollspy -// require bootstrap-tab -// require bootstrap-tooltip -// require bootstrap-popover -// require bootstrap-typeahead -//= require bootstrap -//= require qwaiter -//= require supplier/order -//= require supplier/list -//= require mustache -//= require faye -//= require_directory . -//= require_self -var path_mapping = { - user_root: '/index', - join_occupied_table: '/join_occupied_table', - list_products_for_table: '/list_products_for_table', - list_products: '/list_products', - active_list: '/active_list', - history_list: '/history_list', - obtain_token: '/obtain_token', - lists_history: '/list_history' -} -var $translations = { - en: { - messages: <%= I18n.t('messages', locale: :en).to_json %>, - confirmations: { - }, - // Moved to yml - list_needs_help: { - help_is_on_its_way: 'Help is already on its way', - title: 'Request a waiter', - content: 'Request a waiter to your table' - }, - // Moved to yml - list_needs_payment: { - payment_already_requested: 'You already asked for the bill', - title: 'Ask for the check', - content: 'Do you want to pay?' - }, - selected_products: { - order: 'Order', - clear: 'Clear' - }, - join_request: { - title: 'Join request', - body: '%{email} wants to join the table', - reject: 'Reject', - approve: 'Approve', - requestor: { - title: 'This table is occupied', - go_back: 'Back', - show_the_products: 'Show the menu', - join_this_table: 'Join this table', - waiting_for_confirmation: 'Waiting for approval of the person on this table...' - } - }, - // Moved to yml - move_table: { - cannot_move_to_occupied_table: 'You cannot move to an occupied table', - moved_to_another_table: 'The table is changed.', - confirmation_title: 'Move to another table?', - confirmation_body: 'Do you want to move to another table?' - }, - models: <%= I18n.t('activemodel.models', locale: :en).to_json %>, - attributes: <%= I18n.t('activemodel.attributes', locale: :en).to_json %>, - <%= I18n.t('user', locale: :en).to_json[1..-2] %> - }, - nl: { - messages: <%= I18n.t('messages', locale: :nl).to_json %>, - confirmations: { - }, - // Moved to yml - list_needs_help: { - help_is_on_its_way: 'Er wordt al iemand naar je tafel gestuurd', - title: 'Ik heb een vraag', - content: 'Wil je een vraag stellen?' - }, - // Moved to yml - list_needs_payment: { - payment_already_requested: 'De rekening is reeds gevraagd', - title: 'Vraag om de rekening', - content: 'Wil je betalen?' - }, - selected_products: { - order: 'Bestellen', - clear: 'Leegmaken' - }, - join_request: { - title: 'Lijst deling', - body: '%{email} wil ook op jouw lijst bestellen', - reject: 'Afwijzen', - approve: 'Toestaan', - requestor: { - title: 'Deze tafel is bezet', - go_back: 'Terug', - show_the_products: 'Toon het menu', - join_this_table: 'Ook bestellen aan deze tafel', - waiting_for_confirmation: 'Wachten op toestemming van huidige gebruikers om hier te kunnen bestellen...' - } - }, - move_table: { - cannot_move_to_occupied_table: 'Je kan niet verhuizen naar een tafel die reeds gebruikt wordt.', - moved_to_another_table: 'De tafel is gewijzigd.', - confirmation_title: 'Naar een andere tafel verhuizen?', - confirmation_body: 'Wil je aan een andere tafel gaan zitten?' - }, - models: <%= I18n.t('activemodel.models', locale: :nl).to_json %>, - attributes: <%= I18n.t('activemodel.attributes', locale: :nl).to_json %>, - <%= I18n.t('user', locale: :nl).to_json[1..-2] %> - } -} -function redirect_to(mapping, variables){ - window.redirecting = true; - variables || (variables = {}); - var vars = []; - for(var name in variables){ - vars.push(name + '=' +variables[name]); - Qstorage.setItem(name, variables[name]); - } - window.location.href = QMobile.root_url() + path_mapping[mapping] + '.html' -} -function direct_to_site(mapping, variables){ - variables || (variables = {}); - var vars = [] - for(var name in variables){ - vars.push(name + '=' +variables[name]) - } - window.location = data_host + path_mapping[mapping] + '.html?' + vars.join('&') -} -function currency(num) { - return Qwaiter.currency(num); -} -String.prototype.capitalize = function() { - return this.charAt(0).toUpperCase() + this.slice(1); -} -function t(path, vars){ - vars || (vars = {}); - var parts = path.split('.'); - var locale = Qstorage.getItem('locale') || 'en'; - var accessor = '$translations.'+locale+'["' + parts.join('"]["')+ '"]'; - var result; - try{ - result = eval(accessor); - } catch(err){ - result = parts[parts.length - 1].capitalize(); - } - if(!result) return parts[parts.length - 1].capitalize(); - $.each(vars, function(v, value){ result = result.replace('%{'+v+'}', value)}); - return result; -} -$.ajaxSetup({ - error: function(xhr, ajaxOptions, error, another){ - if(xhr.status == 401){ - redirect_to('obtain_token'); - }else if(xhr.status == 0){ - QMobile.connection_problem(); - } - } -}); -$(function(){ - if(Qstorage.getItem('message')){ - var container = $('.alert-success'); - var msg_finder = Qstorage.getItem('message'); - if(msg_finder.indexOf('.') == -1) msg_finder = 'messages.'+msg_finder; - container.find('div').text(t(msg_finder)); - container.show(); - Qstorage.removeItem('message'); - } - if(Qstorage.getItem('list_closed')){ - var container = $('.alert-error'); - container.find('div').text(t('messages.the_list_has_been_closed')); - container.show(); - Qstorage.removeItem('list_closed'); - } - setTranslations(); -}); -function setLocale(locale){ - Qstorage.setItem('locale', locale); - setTranslations(); -} -function Qupdate(selector){ - setTranslations(selector); -} -function setTranslations(selector){ - var list = $('#top-navigation-list'); - var locale = Qstorage.getItem('locale'); - list.find('.locale').show(); - list.find('.locale-'+locale).hide(); - if(selector){ - $(selector).find('[data-t]').each(function(){$(this).text(t($(this).attr('data-t')))}) - }else{ - $('[data-t]').each(function(){$(this).text(t($(this).attr('data-t')))}) - } -} diff --git a/app/assets/javascripts/user/base64.js b/app/assets/javascripts/user/base64.js deleted file mode 100644 index e6ed5788..00000000 --- a/app/assets/javascripts/user/base64.js +++ /dev/null @@ -1,136 +0,0 @@ -var Base64 = { - -// private property -_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - -// public method for encoding -encode : function (input) { - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - - input = Base64._utf8_encode(input); - - while (i < input.length) { - - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + - this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + - this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); - - } - - return output; -}, - -// public method for decoding -decode : function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - - } - - output = Base64._utf8_decode(output); - - return output; - -}, - -// private method for UTF-8 encoding -_utf8_encode : function (string) { - string = string.replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - - } - - return utftext; -}, - -// private method for UTF-8 decoding -_utf8_decode : function (utftext) { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - - while ( i < utftext.length ) { - - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; -} - -} - diff --git a/app/assets/stylesheets/user/foundation/forms.css.sass b/app/assets/stylesheets/user/foundation/_form_additions.css.sass similarity index 93% rename from app/assets/stylesheets/user/foundation/forms.css.sass rename to app/assets/stylesheets/user/foundation/_form_additions.css.sass index af2fb428..3f7575d8 100644 --- a/app/assets/stylesheets/user/foundation/forms.css.sass +++ b/app/assets/stylesheets/user/foundation/_form_additions.css.sass @@ -1,5 +1,3 @@ -@import ./foundation_and_overrides - .form-row @extend .row .form-label diff --git a/app/assets/stylesheets/user/foundation/menu_main.css.sass b/app/assets/stylesheets/user/foundation/_menu_main.css.sass similarity index 96% rename from app/assets/stylesheets/user/foundation/menu_main.css.sass rename to app/assets/stylesheets/user/foundation/_menu_main.css.sass index 4109d9db..ea57906b 100644 --- a/app/assets/stylesheets/user/foundation/menu_main.css.sass +++ b/app/assets/stylesheets/user/foundation/_menu_main.css.sass @@ -1,6 +1,3 @@ -@import constants -@import font-awesome -@import foundation_and_overrides header.top-menu height: 90px background-color: transparent diff --git a/app/assets/stylesheets/user/foundation/_qconstants.css.sass b/app/assets/stylesheets/user/foundation/_qconstants.css.sass new file mode 100644 index 00000000..1a3502fa --- /dev/null +++ b/app/assets/stylesheets/user/foundation/_qconstants.css.sass @@ -0,0 +1,7 @@ +//$qbrown: #634227 +$qbrown: #853d15 +$qbrown-active: lighten($qbrown, 20%) +$green: #7BB459 //Heineken +//$wood: image-url('textures/wood001-vertical.jpg') +$wood: image-url('textures/theme1.jpg') +$background-brown: #57351f diff --git a/app/assets/stylesheets/user/foundation/index.css.sass b/app/assets/stylesheets/user/foundation/_qindex.css.sass similarity index 91% rename from app/assets/stylesheets/user/foundation/index.css.sass rename to app/assets/stylesheets/user/foundation/_qindex.css.sass index 8d889536..3aca4042 100644 --- a/app/assets/stylesheets/user/foundation/index.css.sass +++ b/app/assets/stylesheets/user/foundation/_qindex.css.sass @@ -1,4 +1,3 @@ -@import foundation .home-panel +panel() margin: 30px auto 20px auto diff --git a/app/assets/stylesheets/user/foundation/join_requests.css.sass b/app/assets/stylesheets/user/foundation/_qjoin_requests.css.sass similarity index 85% rename from app/assets/stylesheets/user/foundation/join_requests.css.sass rename to app/assets/stylesheets/user/foundation/_qjoin_requests.css.sass index f2e622c4..acea29dd 100644 --- a/app/assets/stylesheets/user/foundation/join_requests.css.sass +++ b/app/assets/stylesheets/user/foundation/_qjoin_requests.css.sass @@ -1,4 +1,3 @@ -@import ./foundation_and_overrides .join-request-container .user-email padding-left: 12px diff --git a/app/assets/stylesheets/user/foundation/lists.css.sass b/app/assets/stylesheets/user/foundation/_qlists.css.sass similarity index 96% rename from app/assets/stylesheets/user/foundation/lists.css.sass rename to app/assets/stylesheets/user/foundation/_qlists.css.sass index d5dcd809..7400d0c3 100644 --- a/app/assets/stylesheets/user/foundation/lists.css.sass +++ b/app/assets/stylesheets/user/foundation/_qlists.css.sass @@ -1,4 +1,3 @@ -@import "foundation_and_overrides" .lists-overview-entry +grid-column(12) @media #{$medium-only} diff --git a/app/assets/stylesheets/user/foundation/modal.css.sass b/app/assets/stylesheets/user/foundation/_qmodal.css.sass similarity index 100% rename from app/assets/stylesheets/user/foundation/modal.css.sass rename to app/assets/stylesheets/user/foundation/_qmodal.css.sass diff --git a/app/assets/stylesheets/user/foundation/_qproduct_categories.css.sass b/app/assets/stylesheets/user/foundation/_qproduct_categories.css.sass new file mode 100644 index 00000000..e3e139aa --- /dev/null +++ b/app/assets/stylesheets/user/foundation/_qproduct_categories.css.sass @@ -0,0 +1,35 @@ +ul.product_category-products + list-style: none +.product_category-title + cursor: pointer + .icon + @extend .fa + @extend .fa-arrow-down + color: #ccc + padding-right: 10px + &.collapsed + @extend .fa-arrow-right +.product_category-products + .product-price + float: right + .show-product-description + +button($bg: $secondary-color) + +button-icon-only + margin-right: 7px + span + @extend .fa + @extend .fa-info + @extend .fa-lg + .no-product-description + // Empty space to match the product description for layout + display: inline-block + width: 1.65rem + .add-product-to-list + +button($bg: $secondary-color) + +button-icon-only + float: right + margin-left: 5px + span + @extend .fa + @extend .fa-plus + @extend .fa-lg diff --git a/app/assets/stylesheets/user/foundation/product-orders.css.sass b/app/assets/stylesheets/user/foundation/_qproduct_orders.css.sass similarity index 88% rename from app/assets/stylesheets/user/foundation/product-orders.css.sass rename to app/assets/stylesheets/user/foundation/_qproduct_orders.css.sass index 420442a1..0b3e9a3a 100644 --- a/app/assets/stylesheets/user/foundation/product-orders.css.sass +++ b/app/assets/stylesheets/user/foundation/_qproduct_orders.css.sass @@ -1,5 +1,3 @@ -@import foundation_and_overrides -@import font-awesome ul.product-orders list-style: none li diff --git a/app/assets/stylesheets/user/foundation/structure.css.sass b/app/assets/stylesheets/user/foundation/_structure.css.sass similarity index 76% rename from app/assets/stylesheets/user/foundation/structure.css.sass rename to app/assets/stylesheets/user/foundation/_structure.css.sass index 0d62ee16..aa7358c9 100644 --- a/app/assets/stylesheets/user/foundation/structure.css.sass +++ b/app/assets/stylesheets/user/foundation/_structure.css.sass @@ -1,8 +1,5 @@ -@import constants -@import font-awesome -@import foundation_and_overrides #ember-app-container - background-image: $wood + background-image: image-url('textures/theme1.jpg') background-repeat: repeat main.main-section +panel($bg:rgba(200,200,200,0.8)) diff --git a/app/assets/stylesheets/user/foundation/application.css.sass b/app/assets/stylesheets/user/foundation/application.css.sass index 0662c2b8..9422893c 100644 --- a/app/assets/stylesheets/user/foundation/application.css.sass +++ b/app/assets/stylesheets/user/foundation/application.css.sass @@ -1,3 +1,15 @@ -//= require ./foundation_and_overrides -//= require font-awesome -//= require_directory . +@import ./qconstants +@import ./foundation_and_overrides +@import font-awesome +@import constants +@import ./structure +@import ./menu_main +@import ./menu_side +@import ./qmodal +@import ./qproduct_orders +@import ./qproduct_categories +@import ./form_additions +@import ./qindex +@import ./qlists +@import ./qjoin_requests + diff --git a/app/assets/stylesheets/user/foundation/foundation_and_overrides.css.sass b/app/assets/stylesheets/user/foundation/foundation_and_overrides.css.sass index a348de51..537ef495 100644 --- a/app/assets/stylesheets/user/foundation/foundation_and_overrides.css.sass +++ b/app/assets/stylesheets/user/foundation/foundation_and_overrides.css.sass @@ -13,8 +13,6 @@ // $rem-base: 16px; // Allows the use of rem-calc() or lower-bound() in your settings -a.unused-class - display: inline-block @import "foundation/functions" // $experimental: true; diff --git a/app/assets/stylesheets/user/foundation/menu_side.css.sass b/app/assets/stylesheets/user/foundation/menu_side.css.sass index 9034f44e..7c4e5081 100644 --- a/app/assets/stylesheets/user/foundation/menu_side.css.sass +++ b/app/assets/stylesheets/user/foundation/menu_side.css.sass @@ -1,4 +1,3 @@ -@import constants aside.side-menu background-color: #444 position: fixed diff --git a/app/assets/stylesheets/user/foundation/product_categories.css.sass b/app/assets/stylesheets/user/foundation/product_categories.css.sass deleted file mode 100644 index b8965992..00000000 --- a/app/assets/stylesheets/user/foundation/product_categories.css.sass +++ /dev/null @@ -1,37 +0,0 @@ -//@import ./foundation_and_overrides -//@import font-awesome -//ul.product_category-products - //list-style: none -//.product_category-title - //cursor: pointer - //.icon - //@extend .fa - //@extend .fa-arrow-down - //color: #ccc - //padding-right: 10px - //&.collapsed - //@extend .fa-arrow-right -//.product_category-products - //.product-price - //float: right - //.show-product-description - //+button($bg: $secondary-color) - //+button-icon-only - //margin-right: 7px - //span - //@extend .fa - //@extend .fa-info - //@extend .fa-lg - //.no-product-description - //// Empty space to match the product description for layout - //display: inline-block - //width: 1.65rem - //.add-product-to-list - //+button($bg: $secondary-color) - //+button-icon-only - //float: right - //margin-left: 5px - //span - //@extend .fa - //@extend .fa-plus - //@extend .fa-lg diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 6eb05d60..f8ec2e32 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -8,7 +8,7 @@ class DashboardController < ApplicationController # Testing action def select_qrcode #@tables = Table.all.sample(2) | List.active.map(&:table) - @tables = Supplier.first.tables.sample(5) | List.active.map(&:table) + @tables = (current_supplier || Supplier.first).tables.sample(5) | List.active.map(&:table) respond_to do |format| format.html { render layout: 'phone' } format.json { render json: @tables.to_json } diff --git a/app/controllers/suppliers/lists_controller.rb b/app/controllers/suppliers/lists_controller.rb index c100fd60..385d2ddf 100644 --- a/app/controllers/suppliers/lists_controller.rb +++ b/app/controllers/suppliers/lists_controller.rb @@ -21,7 +21,7 @@ module Suppliers respond_to do |format| format.html # index.html.erb - format.json { render json: @lists } + format.json { render json: @lists, each_serializer: ListSerializer } end end diff --git a/app/models/product.rb b/app/models/product.rb index 482cb516..b0dfb2f4 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -29,6 +29,7 @@ class Product private def persist_product_category_ids + return unless defined?(@product_category_ids) # Do not do anything if nothing happened to this attribute @product_category_ids ||= [] existing_product_categories = product_categories diff --git a/app/serializers/user_supplier_serializer.rb b/app/serializers/user_supplier_serializer.rb index 04e2ebcd..7700dcd7 100644 --- a/app/serializers/user_supplier_serializer.rb +++ b/app/serializers/user_supplier_serializer.rb @@ -1,4 +1,4 @@ -class UserExtendedSupplierSerializer < Qwaiter::Serializer +class UserSupplierSerializer < Qwaiter::Serializer self.root = :supplier attributes :extended_version, :open, :name diff --git a/config/application.rb b/config/application.rb index 4d0e8a78..f2d15a7d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -101,7 +101,7 @@ module Qwaiter # Enable the asset pipeline config.assets.enabled = true - config.assets.precompile += ['supplier/application.css', 'user/application.css', 'qr_sheet/application.css', 'waiter/application.css'] + #config.assets.precompile += ['supplier/application.css', 'user/application.css', 'qr_sheet/application.css', 'waiter/application.css'] config.default_url_options = {format: 'html'} config.to_prepare do diff --git a/config/environments/development.rb b/config/environments/development.rb index abdcbb2b..f6d40573 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -53,4 +53,9 @@ Qwaiter::Application.configure do # Expands the lines which load the assets config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 0b9ceab6..e73656ad 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -11,12 +11,13 @@ Qwaiter::Application.configure do config.eager_load = true # Full error reports are disabled and caching is turned on - config.consider_all_requests_local = false - config.action_controller.perform_caching = true + config.consider_all_requests_local = true + config.action_controller.perform_caching = false config.action_controller.action_on_unpermitted_parameters = :log - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' # Compress JavaScripts and CSS config.assets.compress = true @@ -85,4 +86,7 @@ Qwaiter::Application.configure do # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) # config.active_record.auto_explain_threshold_in_seconds = 0.5 + # + # # Print deprecation notices to the stderr. + config.active_support.deprecation = :stder end diff --git a/config/environments/test.rb b/config/environments/test.rb index d2648c8d..f22e196a 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,8 +13,11 @@ Qwaiter::Application.configure do config.eager_load = true # Configure static asset server for tests with Cache-Control for performance + config.assets.compile = true + config.assets.digest = false config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" + config.assets.compress = false config.ember.variant = :development diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 00000000..2c4b6def --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 9ec349cd45bb7bd16cdfa40d2deeeb39e8b287f23ac39aa64ded980af40fb002db5d1c9bdc91bc0ce1dc12f89c2ab86c07394c305fefffe2fb01fb00be281f4f + +test: + secret_key_base: 0cef7a55e2fbd104a5cb4539434a628489f833c67c1386583ed2b89ffa492bf3b05e98547a72eda9760f9482c765e52b1ea3cc94b57394cdee5b3debfd7912ec + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/lib/qwaiter/serializer.rb b/lib/qwaiter/serializer.rb index 390e5b09..933fcac1 100644 --- a/lib/qwaiter/serializer.rb +++ b/lib/qwaiter/serializer.rb @@ -2,5 +2,19 @@ module Qwaiter class Serializer < ActiveModel::Serializer attribute :_id, key: :id attributes :created_at, :updated_at + # Bug in rails 4.1 serializing symbols in jsonify + def to_json(*args) + as_json.to_json(*args) + end + end +end + +require 'active_model/array_serializer' +module ActiveModel + class ArraySerializer + # Bug in rails 4.1 serializing symbols in jsonify + def to_json(*args) + as_json.to_json(*args) + end end end diff --git a/spec/acceptance/users/get_product_information.feature b/spec/acceptance/users/get_product_information.feature index a4658f59..1980ffcf 100644 --- a/spec/acceptance/users/get_product_information.feature +++ b/spec/acceptance/users/get_product_information.feature @@ -5,8 +5,7 @@ Feature: Getting product information during an order Given There is an open supplier with a menu And the product 'Heineken beer' has description 'Brewed in Amsterdam' And I am signed in as a user - #And I open the debugger And I am on the user homepage - #When the user scans a table QR code - #And the user clicks on the more info button for the product with name 'Heineken beer' - #Then the page should have content 'Brewed in Amsterdam' + When the user scans a table QR code + And the user clicks on the more info button for the product with name 'Heineken beer' + Then the user page should have product information 'Brewed in Amsterdam' diff --git a/spec/acceptance_steps/global_product_steps.rb b/spec/acceptance_steps/global_product_steps.rb index e3915779..62fa154a 100644 --- a/spec/acceptance_steps/global_product_steps.rb +++ b/spec/acceptance_steps/global_product_steps.rb @@ -1,5 +1,6 @@ step "the product :product_name has description :product_description" do |product_name, product_description| - product = @product && @product.name == product_name ? @product : Product.find_by_name(product_name) + #product = @product && @product.name == product_name ? @product : Product.find_by_name(product_name) + product = Product.find_by_name(product_name) product.description = product_description product.save or raise "Cannot save product: #{product.errors.full_messages.to_sentence}" @product ||= product diff --git a/spec/acceptance_steps/global_table_steps.rb b/spec/acceptance_steps/global_table_steps.rb index 284aa8bd..fda9792d 100644 --- a/spec/acceptance_steps/global_table_steps.rb +++ b/spec/acceptance_steps/global_table_steps.rb @@ -1,16 +1,3 @@ -step "the user scans a table QR code" do - step 'there is a table' - page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})" -end - -step "another user scans the QR code on the table" do - step 'there is another signed in user user' - visit user_root_path - binding.pry - page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})" -end - - step 'there is a table' do step 'there is a section' @table ||= create :table, section: @section, supplier: @supplier diff --git a/spec/acceptance_steps/global_user_steps.rb b/spec/acceptance_steps/global_user_steps.rb index d4a1bd58..ffa7a141 100644 --- a/spec/acceptance_steps/global_user_steps.rb +++ b/spec/acceptance_steps/global_user_steps.rb @@ -1,3 +1,16 @@ +step "the user scans a table QR code" do + step 'there is a table' + #page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})" + page.execute_script "App.__container__.lookup('route:application').transitionTo('table','#{@table.id}')" +end + +step "another user scans the QR code on the table" do + step 'there is another signed in user user' + visit user_root_path + #page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})" + page.execute_script "App.__container__.lookup('route:application').transitionTo('table','#{@table.id}')" +end + step "I am on the user homepage" do step "the user is on the homepage" end diff --git a/spec/acceptance_steps/supplier_steps.rb b/spec/acceptance_steps/supplier_steps.rb index a333c0d6..fc55e333 100644 --- a/spec/acceptance_steps/supplier_steps.rb +++ b/spec/acceptance_steps/supplier_steps.rb @@ -1,11 +1,15 @@ step "There is an open supplier with a menu" do step 'there is a confirmed and open supplier' - @category_beer = create :product_category, name: 'Beer', supplier: @supplier - @category_lunch = create :product_category, name: 'Lunch', supplier: @supplier - @heineken_beer = create :product, name: 'Heineken beer', supplier: @supplier, price: 2.34 @apple_pie= create :product, name: 'Apple pie', supplier: @supplier, price: 4.28 - @heineken_beer.add_product_category @category_beer - @apple_pie.add_product_category @category_lunch + @heineken_beer = create :product, name: 'Heineken beer', supplier: @supplier, price: 2.34 + + @category_beer = create :product_category, name: 'Beer', supplier: @supplier, product_ids: [@heineken_beer.id] + @category_lunch = create :product_category, name: 'Lunch', supplier: @supplier, product_ids: [@apple_pie.id] + #@heineken_beer.add_product_category @category_beer + #@category_beer.save + #@category_lunch.save + #@apple_pie.add_product_category @category_lunch + #@apple_pie.save end step "the supplier is in :time_zone" do |time_zone| diff --git a/spec/acceptance_steps/users/changing_table_steps.rb b/spec/acceptance_steps/users/changing_table_steps.rb index 251e1d31..e2e5d19a 100644 --- a/spec/acceptance_steps/users/changing_table_steps.rb +++ b/spec/acceptance_steps/users/changing_table_steps.rb @@ -3,10 +3,6 @@ step "there is another table" do @other_table = create :table, number: 89, section: @section, supplier: @supplier end -step "the user scans a QR code of another not occupied table" do - page.execute_script "Quser.actions_for_table({table_id: '#{@other_table.id}'})" -end - step "the user should see a popup asking the user if he would like to change table" do move_table_body = page.evaluate_script "t('move_table.confirmation_body')" move_table_body.should be_present @@ -35,6 +31,10 @@ step "there is another table with an active list of another user" do end +step "the user scans a QR code of another not occupied table" do + page.execute_script "Quser.actions_for_table({table_id: '#{@other_table.id}'})" +end + step "the user scans a QR code of another occupied table" do # same as not, since this is just a scan action. Whether the table # is occupied is a responsibility of other steps diff --git a/spec/acceptance_steps/users/order_products_steps.rb b/spec/acceptance_steps/users/order_products_steps.rb index 3ed49aa0..54701a36 100644 --- a/spec/acceptance_steps/users/order_products_steps.rb +++ b/spec/acceptance_steps/users/order_products_steps.rb @@ -32,3 +32,7 @@ step "the user clicks on the more info button for the product with name :product product = @product && @product.name == product_name ? @product : Product.find_by_name(product_name) find(".order-product-#{product.id} .show-product-description").click end + +step "the user page should have product information :product_description" do |product_description| + page.should have_content product_description +end diff --git a/spec/serializers_spec.rb b/spec/serializers_spec.rb new file mode 100644 index 00000000..30c7df8f --- /dev/null +++ b/spec/serializers_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe 'Serializers' do + let(:serializer_classes){ Dir.glob(Rails.root.join('app/serializers/*_serializer.rb')).map{|f| File.basename(f).sub(/\.rb$/,'').classify.constantize}} + describe 'classes' do + it 'inherits from Qwaiter::Serializer' do + serializer_classes.each do |serializer| + serializer.ancestors.should include Qwaiter::Serializer + end + end + end +end