diff --git a/Gemfile.lock b/Gemfile.lock index fca091a2..6d506d4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -247,8 +247,8 @@ GEM omniauth (1.2.2) hashie (>= 1.2, < 4) rack (~> 1.0) - omniauth-facebook (1.6.0) - omniauth-oauth2 (~> 1.1) + omniauth-facebook (2.0.0) + omniauth-oauth2 (~> 1.2) omniauth-oauth2 (1.2.0) faraday (>= 0.8, < 0.10) multi_json (~> 1.3) @@ -375,7 +375,7 @@ GEM turnip (1.2.2) gherkin (>= 2.5) rspec (>= 2.0, < 4.0) - tzinfo (1.2.1) + tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (2.5.3) execjs (>= 0.3.0) diff --git a/app/assets/javascripts/shared-ember-helpers/image_tag.js.coffee b/app/assets/javascripts/shared-ember-helpers/image_tag.js.coffee index b33ae266..41d7449c 100644 --- a/app/assets/javascripts/shared-ember-helpers/image_tag.js.coffee +++ b/app/assets/javascripts/shared-ember-helpers/image_tag.js.coffee @@ -1,4 +1,7 @@ -Ember.Handlebars.registerBoundHelper 'image_tag', (path, params..., options={})-> - alt = options.hash.alt ||= '' +Ember.Handlebars.helper 'image_tag', (path, options={})-> + alt = options.hash.alt || '' image_path = if path.substring(0,4) == 'http' then path else "/assets/#{path}" - new Handlebars.SafeString "\"#{alt}\"" + extra_attributes = '' + extra_attributes += " width=\"#{options.hash.width}\"" if options.hash.width + extra_attributes += " height=\"#{options.hash.height}\"" if options.hash.height + new Handlebars.SafeString "\"#{alt}\"" diff --git a/app/assets/javascripts/supplier/app/controllers/settings_controller.js.coffee b/app/assets/javascripts/supplier/app/controllers/settings_controller.js.coffee index c3c99879..3aa9880d 100644 --- a/app/assets/javascripts/supplier/app/controllers/settings_controller.js.coffee +++ b/app/assets/javascripts/supplier/app/controllers/settings_controller.js.coffee @@ -1,6 +1,6 @@ App.SettingsController = Ember.ObjectController.extend needs: ['application'] - model: (-> @get('controllers.application.supplier')).property('controllers.application.supplier') + # model: (-> @get('controllers.application.supplier')).property('controllers.application.supplier') time_zones: (-> window.time_zones ).property() countries: (-> window.countries ).property() editIensProfile: (-> @get('model.country') is 'Netherlands' ).property('model.country') diff --git a/app/assets/javascripts/supplier/app/routes/settings_route.js.coffee b/app/assets/javascripts/supplier/app/routes/settings_route.js.coffee index 7599102a..d07bc4fe 100644 --- a/app/assets/javascripts/supplier/app/routes/settings_route.js.coffee +++ b/app/assets/javascripts/supplier/app/routes/settings_route.js.coffee @@ -1,7 +1,5 @@ App.SettingsRoute = Ember.Route.extend - model: -> - Em.RSVP.hash - supplier: @controllerFor('application').get('supplier') - setupController: (controller, model)-> - #controller.set 'model', controller.get('controllers.application.supplier') - controller.set 'model', model.supplier + model: -> @container.lookup('route:application').supplier + # setupController: (controller, model)-> + # #controller.set 'model', controller.get('controllers.application.supplier') + # controller.set 'model', model.supplier diff --git a/app/assets/javascripts/user/app/app.js.coffee b/app/assets/javascripts/user/app/app.js.coffee index 9a38e23c..e84ae8a5 100644 --- a/app/assets/javascripts/user/app/app.js.coffee +++ b/app/assets/javascripts/user/app/app.js.coffee @@ -12,7 +12,10 @@ rootElement: '#ember-app-container' obtain_token: (message)-> message ||= '' - window.location = "#{$root_url}/obtain_token?message=#{message}" + # frame = $('').addClass('obtain-token-frame').attr 'src', $obtain_token_url + # frame.css width: $('body').outerWidth(), height: $('body').outerHeight() + # $('body').append frame + window.location = "#{$obtain_token_url}" Ember.$.ajaxPrefilter (options) -> if options.type.toUpperCase() == 'GET' diff --git a/app/assets/javascripts/user/app/templates/_list_content.emblem b/app/assets/javascripts/user/app/templates/_list_content.emblem index 53e6ad9b..8ffdc9df 100644 --- a/app/assets/javascripts/user/app/templates/_list_content.emblem +++ b/app/assets/javascripts/user/app/templates/_list_content.emblem @@ -10,18 +10,21 @@ if list.closed_at .display-row .display-label=t 'attributes.list.state' .display-field=state 'list' list.state -if list.sorted_orders - .list-orders-container - each order in list.sorted_orders - App.ListOrderView contentBinding="order" - if showTotal - .list-orders-total.total - = t 'total' - span.currency= currency list.total +if list.orders.isLoaded + if list.sorted_orders + .list-orders-container + each order in list.sorted_orders + App.ListOrderView contentBinding="order" + if showTotal + .list-orders-total.total + = t 'total' + span.currency= currency list.total + else + p + span=t 'active_list.no_orders_explanation' + br + if list.table + link-to 'table' list.table class="button" + span=t 'list_products.title' else - p - span=t 'active_list.no_orders_explanation' - br - if list.table - link-to 'table' list.table class="button" - span=t 'list_products.title' + span.loading.large diff --git a/app/assets/javascripts/user/app/templates/active_list.emblem b/app/assets/javascripts/user/app/templates/active_list.emblem index 43f9e306..67a30643 100644 --- a/app/assets/javascripts/user/app/templates/active_list.emblem +++ b/app/assets/javascripts/user/app/templates/active_list.emblem @@ -1,10 +1,13 @@ .row h2=t 'active_list.title' - if list - partial "list_content" + if list.orders.isLoaded + if list + partial "list_content" + else + p + span=t 'active_list.not_active.message' + br + link-to 'index' class="button" + span= t 'active_list.not_active.home_button_text' else - p - span=t 'active_list.not_active.message' - br - link-to 'index' class="button" - span= t 'active_list.not_active.home_button_text' + span.loading.large diff --git a/app/assets/javascripts/user/app/templates/application.emblem b/app/assets/javascripts/user/app/templates/application.emblem index 281611db..ce0705ff 100644 --- a/app/assets/javascripts/user/app/templates/application.emblem +++ b/app/assets/javascripts/user/app/templates/application.emblem @@ -17,7 +17,7 @@ header.top-menu .table-number | = t 'models.table' - | + |  = list.table.number .supplier-info-row .counter.supplier-orders-placed-count diff --git a/app/assets/javascripts/user/app/templates/index.emblem b/app/assets/javascripts/user/app/templates/index.emblem index 43a8396b..07a6a96e 100644 --- a/app/assets/javascripts/user/app/templates/index.emblem +++ b/app/assets/javascripts/user/app/templates/index.emblem @@ -1,6 +1,6 @@ .home-panel - .home-header = image_tag 'logo.png' + .home-header= image_tag 'logo.png' width=100 height=115 alt="Logo" .home-center - a{action scanQr} href="#"= image_tag 'scan-logo.png' + a{ action "scanQr" } href="#"= image_tag 'scan-logo.png' width=148 height=177 alt="Scan" .home-footer .home-footer-content diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index e0b3b94b..2f67e669 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -292,6 +292,12 @@ class UserController < Users::ApplicationController def obtain_token redirect_to user_omniauth_authorize_path('facebook') and return unless current_user.present? + # redirect_to case platform + # when 'android' then "file:///android_asset/user/index.html?user_id=#{current_user.id}&auth_token=#{current_user.authentication_token}" + # when + # else user_root_path(user_id: current_user.id, auth_token: current_user.authentication_token) + # end + # return respond_to do |format| format.html { render layout: 'user/obtain_token' } format.json do diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a2883a27..f81cd43f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -32,8 +32,16 @@ module ApplicationHelper def user_dynamic_root_url case Rails.env - when 'test' then "$root_url = 'http://#{request.host}:#{request.port}/user';".html_safe - when 'development' then "$root_url = 'http://localhost:3000/user';".html_safe + when 'test' then "Qstorage.setItem('root_url', 'http://#{request.host}:#{request.port}/user/index.html');".html_safe + when 'development' then "Qstorage.setItem('root_url', 'http://localhost:3000/user/index.html');".html_safe + else '' + end + end + + def user_dynamic_obtain_token_url + case Rails.env + when 'test' then "$obtain_token_url = 'http://#{request.host}:#{request.port}/user/obtain_token.html';".html_safe + when 'development' then "$obtain_token_url = 'http://localhost:3000/user/obtain_token.html';".html_safe else '' end end diff --git a/app/views/layouts/obtain_token.html.slim b/app/views/layouts/obtain_token.html.slim index 852c0df3..842875b0 100644 --- a/app/views/layouts/obtain_token.html.slim +++ b/app/views/layouts/obtain_token.html.slim @@ -4,10 +4,10 @@ html lang="en" meta charset="utf-8" meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" meta name="viewport" content="width=device-width, initial-scale=1.0" - title= content_for?(:title) ? yield(:title) : application_title - = stylesheet_link_tag 'obtain_token/application' - = csrf_meta_tags - body class=action_name + title= application_title + / = stylesheet_link_tag 'obtain_token/application' + / = csrf_meta_tags + body - if flash[:alert].present? .alert.alert-error a.close data-dismiss="alert" × diff --git a/app/views/layouts/user/foundation.html.slim b/app/views/layouts/user/foundation.html.slim index d14ed326..0eafe9ac 100644 --- a/app/views/layouts/user/foundation.html.slim +++ b/app/views/layouts/user/foundation.html.slim @@ -5,9 +5,9 @@ html lang="en" meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" meta name="viewport" content="width=device-width, initial-scale=1.0" title= application_title - = stylesheet_link_tag "user/foundation/application" = javascript_include_tag "vendor/modernizr" - = javascript_include_tag 'http://connect.facebook.net/en_US/all.js' + = stylesheet_link_tag "user/foundation/application" + / = javascript_include_tag 'http://connect.facebook.net/en_US/all.js' = javascript_include_tag "user/flat/application" - if ENV['QWAITER_MOBILE_EXPORT'] == 'yes' javascript: @@ -15,35 +15,20 @@ html lang="en" var $data_host = 'http://data.mozo.bar'; var $event_host = '#{Qwaiter.event_host}'; var $asset_path = '##assets_path##'; - var Qstorage = localStorage; - var $root_url = 'http://www.mozo.bar/user'; + var Qstorage = window.localStorage; + var Qstorage.setItem('root_url', '##root_url##'); + var $platform = '##platform##'; + var $obtain_token_url = 'http://mozo.bar/user/obtain_token'; + - else javascript: var QMobile, Qwaiter, Quser; var $event_host = '#{Qwaiter.event_host}'; var $asset_path = '/assets/'; - var Qstorage = localStorage; + var Qstorage = window.localStorage; #{user_dynamic_data_host}; #{user_dynamic_root_url}; - QMobile || (QMobile = { - scanQr: function(){window.location = '/select_qrcode'}, - activateRotation: function(){}, - mobile: function(){return false}, - authentication_string: function(){return this.authentication_string_storage || ''}, - authentication_object: function(){return this.authentication_object_storage || '{}'}, - setAuthToken: function(token){ - this.auth_token = token; - this.authentication_string_storage = 'auth_token='+token; - this.authentication_object_storage = '{"auth_token": "'+token+'"}' - }, - root_url: function(){return 'file:///Users/bterkuile/Documents/workspace/Qwaiter/assets/user'}, - $root_url: function(){return '/user'}, - goHome: function(){ redirect_to('user_root')}, - connection_problem: function(){alert('There is a problem connecting to the server')}, - token: function(){return this.auth_token}, - setUserId: function(id){ this.stored_user_id = id}, - user_id: function(){return this.stored_user_id }, - log: function(str){console.log(str)} - }); + #{user_dynamic_obtain_token_url}; + var $platform = 'web' body #ember-app-container diff --git a/app/views/user/obtain_token.html.slim b/app/views/user/obtain_token.html.slim index ab7e2c5f..eca9e668 100644 --- a/app/views/user/obtain_token.html.slim +++ b/app/views/user/obtain_token.html.slim @@ -18,6 +18,12 @@ button.btn.btn-primary data-t="obtain_token.obtain" onclick="Quser.authenticate_user(); return false" = t('user.obtain_token.obtain') - unless current_user.blank? || ENV['QWAITER_MOBILE_EXPORT']=='yes' javascript: + Qstorage = window.localStorage; Qstorage.setItem('auth_token', '#{current_user.authentication_token}'); Qstorage.setItem('user_id', '#{current_user.id}'); - window.location = '/index.html'; + window.location = (Qstorage.getItem('root_url') || '/index.html') + '?user_id=#{current_user.id}&auth_token=#{current_user.authentication_token}'; + // localStorage.setItem('auth_token', '#{current_user.authentication_token}'); + // localStorage.setItem('user_id', '#{current_user.id}'); + // window.location = $root_url + '?user_id=#{current_user.id}&auth_token=#{current_user.authentication_token}'; + // debugger; + // QMobile.signed_in({user_id: '#{current_user.id}', auth_token: '#{current_user.authentication_token}'}); diff --git a/bin/build_mobile_app.rb b/bin/build_mobile_app.rb index 68c3ed75..6b89a7b5 100644 --- a/bin/build_mobile_app.rb +++ b/bin/build_mobile_app.rb @@ -79,6 +79,7 @@ for action in uc.action_methods ios_view = ios_view.gsub /(href|src)="\/assets\/([^"]+)/, %|\\1="./assets/\\2| # make assets calls relative ios_view.sub! /<\/title>/, '' ios_view.gsub! '##assets_path##', './assets/' + android_view.gsub! '##platform##', 'ios' File.open(File.join(ios_root, "#{action}.html"), 'w'){|f| f.puts ios_view} ## MODIFY FOR ANDROID @@ -87,6 +88,8 @@ for action in uc.action_methods android_view.gsub! /(href|src)="([^#])/, %|\\1="#{android_root_url}\\2| # replace relative uri's with android specific one android_view.sub! /<\/title>/, '' android_view.gsub! '##assets_path##', 'file:///android_asset/assets/' + android_view.gsub! '##root_url##', 'file:///android_asset/user/index.html' + android_view.gsub! '##platform##', 'android' if testhost = ENV['TEST_HOST'].presence android_view.gsub! /data.mozo.bar|www.mozo.bar/, "#{testhost}:3000" android_view.gsub! /events.mozo.bar/, "#{testhost}:9296" diff --git a/spec/acceptance/users/active_list.feature b/spec/acceptance/users/active_list.feature index 153315f8..5b47bbfc 100644 --- a/spec/acceptance/users/active_list.feature +++ b/spec/acceptance/users/active_list.feature @@ -1,7 +1,7 @@ Feature: Active list view @javascript - Scenario: Loading lists and switching back to the active list + Scenario: Loading lists and switching back to the active list works, lists loading may unlink active list orders Given There is an open supplier with a menu And there is a signed in user with an active order And the user is on the active list page diff --git a/spec/acceptance_steps/global_steps.rb b/spec/acceptance_steps/global_steps.rb index 3a35c3fe..dac5d32c 100644 --- a/spec/acceptance_steps/global_steps.rb +++ b/spec/acceptance_steps/global_steps.rb @@ -22,7 +22,8 @@ step "I wait :number second/seconds" do |number| end placeholder :number do - match /[-+]?\d+(\.\d+)?/ do |number_string| + # match /[-+]?\d+(\.\d+)?/ do |number_string| + match /\d+\.?\d?/ do |number_string| number_string.to_f end end diff --git a/spec/acceptance_steps/suppliers/section_view_steps.rb b/spec/acceptance_steps/suppliers/section_view_steps.rb index dbe88dcd..ddd737d5 100644 --- a/spec/acceptance_steps/suppliers/section_view_steps.rb +++ b/spec/acceptance_steps/suppliers/section_view_steps.rb @@ -31,9 +31,9 @@ step "the section table should not be marked as in need of help" do table['class'].should_not include 'needs_help' end -step 'Then the table should be marked as occupied and having an active order' do +step 'the table should be marked as occupied and having an active order' do classes = find(".section-table-#{@table.id}")['class'].split(/\s+/) - expect(classes & %w[occupied active_order]).to eq & %w[occupied active_order] + expect(classes & %w[occupied active_order]).to eq %w[occupied active_order] end step "I click on section table as a supplier" do @@ -70,7 +70,6 @@ end step "the section table should not have any active list markings anymore" do table = page.find(".section-table-#{@table.id}") css_class = table['class'] - binding.pry css_class.should_not include 'needs_help' css_class.should_not include 'occupied' css_class.should_not include 'active_order' @@ -80,7 +79,8 @@ end step "I should be redirected to the supplier section view" do sleep 1 #page.current_path.should == "/supplier/sections/#{@section.id}" - page.evaluate_script('window.location.pathname').should == "/supplier/sections/#{@section.id}" + # page.evaluate_script('window.location.pathname').should == "/supplier/sections/#{@section.id}" + js_path.should == "/supplier#/sections/#{@section.id}" end step "the last supplier section has a table with known coordinates" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2147663e..0e61bb10 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -118,7 +118,6 @@ RSpec.configure do |config| #config.use_transactional_fixtures = true config.before :suite do Qwaiter::Couchbase.load_design_docs! - # NOT THREADSAFE!!!!!! but good enough for testing since the real couchbase flush is slowwwwww.... Qwaiter::Counter.connection = TestCounter.new end