diff --git a/Gemfile b/Gemfile index dff74f62..984276b9 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,7 @@ group :assets do gem 'uglifier', '>= 1.0.3' #gem "emblem-source", github: "machty/emblem.js" + gem 'emblem-source', '0.3.18' gem 'emblem-rails' gem 'ember-validations-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 844cd3c3..5220ce37 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -198,7 +198,7 @@ GEM emblem-rails (0.2.2) barber-emblem (~> 0.1.1) ember-rails (>= 0.14.0) - emblem-source (0.4.0) + emblem-source (0.3.18) erubis (2.7.0) eventmachine (1.0.7) execjs (2.3.0) @@ -470,6 +470,7 @@ DEPENDENCIES ember-validations-rails ember_script-rails! emblem-rails + emblem-source (= 0.3.18) factory_girl_rails faye font-awesome-rails diff --git a/app/assets/javascripts/theme1/application.js.coffee b/app/assets/javascripts/theme1/application.js.coffee index 6c37c48d..7df0ed67 100644 --- a/app/assets/javascripts/theme1/application.js.coffee +++ b/app/assets/javascripts/theme1/application.js.coffee @@ -5,5 +5,8 @@ #= require_directory . #= require_self $ -> + # Responsive menu $('.menu-secondary-toggle').click -> $('.nav.secondary').toggleClass('active') + + # Foundation javascript support $(document).foundation() diff --git a/app/assets/javascripts/waiter/app/models/table.js.coffee b/app/assets/javascripts/waiter/app/models/table.js.coffee index 134ae87d..4e587062 100644 --- a/app/assets/javascripts/waiter/app/models/table.js.coffee +++ b/app/assets/javascripts/waiter/app/models/table.js.coffee @@ -8,7 +8,7 @@ App.Table = DS.Model.extend occupied: attr 'boolean' section: DS.belongsTo('section') product_orders: DS.hasMany('product_order') - #active_list: DS.belongsTo('list') + active_list: DS.belongsTo('list') #active_list: (-> #@get('list') #).property('list') diff --git a/app/assets/javascripts/waiter/app/store.js.coffee b/app/assets/javascripts/waiter/app/store.js.coffee index f85a03e7..56351dee 100644 --- a/app/assets/javascripts/waiter/app/store.js.coffee +++ b/app/assets/javascripts/waiter/app/store.js.coffee @@ -1,6 +1,6 @@ # http://emberjs.com/guides/models/defining-a-store/ -DS.RESTAdapter.reopen - namespace: 'waiter' +#DS.RESTAdapter.reopen + #namespace: 'waiter' App.ApplicationSerializer = DS.ActiveModelSerializer App.CustomAdapter = DS.RESTAdapter.extend @@ -9,5 +9,8 @@ App.CustomAdapter = DS.RESTAdapter.extend pathForType: (type)-> decamelized = Ember.String.decamelize(type) Ember.String.pluralize(decamelized) -App.Store = DS.Store.extend - adapter: App.CustomAdapter +#App.Store = DS.Store.extend + #adapter: App.CustomAdapter +App.ApplicationStore = DS.Store.extend + adapter: DS.ActiveModelAdapter.extend + namespace: 'waiter' diff --git a/app/assets/javascripts/waiter/app/templates/product_categories.emblem b/app/assets/javascripts/waiter/app/templates/product_categories.emblem index 72916756..b19622a6 100644 --- a/app/assets/javascripts/waiter/app/templates/product_categories.emblem +++ b/app/assets/javascripts/waiter/app/templates/product_categories.emblem @@ -5,5 +5,5 @@ each product_category in controller ul.product_category-products each product in product_category.products li - a{action addProduct product } href="#" = product.name + a{action "addProduct" product } href="#" = product.name diff --git a/app/assets/stylesheets/theme1/elements/_nav.css.sass b/app/assets/stylesheets/theme1/elements/_nav.css.sass index 815c4712..12153262 100644 --- a/app/assets/stylesheets/theme1/elements/_nav.css.sass +++ b/app/assets/stylesheets/theme1/elements/_nav.css.sass @@ -22,6 +22,8 @@ position: relative list-style: none float: left + &.contact + float: right a border: 0 color: white diff --git a/app/controllers/contact_forms_controller.rb b/app/controllers/contact_forms_controller.rb new file mode 100644 index 00000000..35395a67 --- /dev/null +++ b/app/controllers/contact_forms_controller.rb @@ -0,0 +1,16 @@ +class ContactFormsController < ApplicationController + def create + @contact_form = Cmtool::ContactForm.new(contact_form_params) + if @contact_form.save + redirect_to root_path, notice: t('contact_form.submitted') + else + redirect_to go_to_path('contact', locale: I18n.locale), alert: @contact_form.errors.full_messages.join(', ') + end + end + + private + + def contact_form_params + params.require(:contact_form).permit! + end +end diff --git a/app/controllers/waiter/application_controller.rb b/app/controllers/waiter/application_controller.rb new file mode 100644 index 00000000..fd4cea19 --- /dev/null +++ b/app/controllers/waiter/application_controller.rb @@ -0,0 +1,3 @@ +class Waiter::ApplicationController < Suppliers::ApplicationController + layout 'waiter' +end diff --git a/app/controllers/waiter/dashboard_controller.rb b/app/controllers/waiter/dashboard_controller.rb new file mode 100644 index 00000000..3312531a --- /dev/null +++ b/app/controllers/waiter/dashboard_controller.rb @@ -0,0 +1,6 @@ +class Waiter::DashboardController < Waiter::ApplicationController + skip_load_and_authorize_resource + def index + + end +end diff --git a/app/controllers/waiter_controller.rb b/app/controllers/waiter_controller.rb index d695eb37..eed19fe6 100644 --- a/app/controllers/waiter_controller.rb +++ b/app/controllers/waiter_controller.rb @@ -5,10 +5,10 @@ class WaiterController < ApplicationController end def sections - json = '{"tables":[{"id":"0903d04a003991835f9f32d1821ee05c","number":102,"width":2.0,"height":2.0,"position_x":14.242294520547945,"position_y":3.1862955032119915,"section_id":"1a9d4cc551dac96f87a21c97ba1e710b","occupied":true,"active_list_id":"1cef487ec268169687f481cb828924c2"},{"id":"0903d04a003991835f9f32d1821efb50","number":100,"width":2.0,"height":2.0,"position_x":6.5,"position_y":6.5,"section_id":"1a9d4cc551dac96f87a21c97ba1e710b","occupied":false,"active_list_id":null},{"id":"1a9d4cc551dac96f87a21c97ba3d15fa","number":11,"width":2.0,"height":2.0,"position_x":6.5,"position_y":1.5,"section_id":"1a9d4cc551dac96f87a21c97ba1e710b","occupied":false,"active_list_id":null},{"id":"0903d04a003991835f9f32d1821ededd","number":103,"width":2.0,"height":2.0,"position_x":9.0,"position_y":6.5,"section_id":"222fcd43b55e397d11d92ccb601e70dc","occupied":false,"active_list_id":null},{"id":"0903d04a003991835f9f32d1821eee07","number":101,"width":2.0,"height":2.0,"position_x":2.3333333333333335,"position_y":6.5,"section_id":"222fcd43b55e397d11d92ccb601e70dc","occupied":false,"active_list_id":null},{"id":"1a9d4cc551dac96f87a21c97ba3d0dbd","number":12,"width":2.0,"height":2.0,"position_x":9.854452054794521,"position_y":2.7054794520547945,"section_id":"222fcd43b55e397d11d92ccb601e70dc","occupied":false,"active_list_id":null},{"id":"1a9d4cc551dac96f87a21c97ba3d2221","number":10,"width":2.0,"height":2.0,"position_x":6.4811643835616435,"position_y":2.0034246575342465,"section_id":"222fcd43b55e397d11d92ccb601e70dc","occupied":false,"active_list_id":null},{"id":"1a9d4cc551dac96f87a21c97ba3d2cf7","number":1,"width":2.0,"height":2.0,"position_x":2.3333333333333335,"position_y":1.5,"section_id":"222fcd43b55e397d11d92ccb601e70dc","occupied":false,"active_list_id":null}],"lists":[{"id":"1cef487ec268169687f481cb828924c2","state":"active","needs_help":true,"needs_payment":false,"is_paid":false,"price":46.8,"table_id":"0903d04a003991835f9f32d1821ee05c","table_number":102,"section_id":"1a9d4cc551dac96f87a21c97ba1e710b","has_active_orders":true,"user_ids":["8afe7cccf1c690e60aa2ace1bf1d8a71"]}],"sections":[{"id":"1a9d4cc551dac96f87a21c97ba1e710b","title":"Ruimte2","path":[[0.0,0.0],[30.0,12.0],[30.0,12.0],[0.0,12.0]],"width":30.0,"height":12.0,"table_ids":["0903d04a003991835f9f32d1821ee05c","0903d04a003991835f9f32d1821efb50","1a9d4cc551dac96f87a21c97ba3d15fa"]},{"id":"222fcd43b55e397d11d92ccb601e70dc","title":"Buiten","path":[[0.0,0.0],[20.0,20.0],[20.0,20.0],[0.0,20.0]],"width":20.0,"height":20.0,"table_ids":["0903d04a003991835f9f32d1821ededd","0903d04a003991835f9f32d1821eee07","1a9d4cc551dac96f87a21c97ba3d0dbd","1a9d4cc551dac96f87a21c97ba3d2221","1a9d4cc551dac96f87a21c97ba3d2cf7"]}]}' + sections = current_supplier.sections.include_relation(:tables) respond_to do |format| format.html { redirect_to '/waiter'} - format.json { render json: json } + format.json { render json: sections, each_serializer: Waiter::SectionSerializer } end end diff --git a/app/serializers/waiter/section_serializer.rb b/app/serializers/waiter/section_serializer.rb new file mode 100644 index 00000000..a28079a1 --- /dev/null +++ b/app/serializers/waiter/section_serializer.rb @@ -0,0 +1,4 @@ +class Waiter::SectionSerializer < Qwaiter::Serializer + self.root = :section + attributes :title, :path, :width, :height +end diff --git a/app/serializers/waiter/table_serializer.rb b/app/serializers/waiter/table_serializer.rb new file mode 100644 index 00000000..d24a621d --- /dev/null +++ b/app/serializers/waiter/table_serializer.rb @@ -0,0 +1,3 @@ +class Waiter::TableSerializer < Qwaiter::Serializer + attributes :number, :width, :height, :position_x, :position_y, :section_id, :needs_help +end diff --git a/app/views/waiter/index.html.slim b/app/views/application/_contact_form.html.slim similarity index 100% rename from app/views/waiter/index.html.slim rename to app/views/application/_contact_form.html.slim diff --git a/app/views/employees/passwords/new.html.slim b/app/views/employees/passwords/new.html.slim index f246458e..53b9183a 100644 --- a/app/views/employees/passwords/new.html.slim +++ b/app/views/employees/passwords/new.html.slim @@ -3,6 +3,6 @@ h2= t('devise.passwords.title') = devise_error_messages! = f.row :email do .form-label= f.label :email, class: 'control-label' - .form-field= f.email_field :email + .form-field= f.email_field :email, autofocus: true .form-row.form-actions= f.submit t('devise.passwords.button'), class: 'button' = render "devise/links" diff --git a/app/views/new_suppliers/new.html.slim b/app/views/new_suppliers/new.html.slim index 9d76b2a1..55c310a2 100644 --- a/app/views/new_suppliers/new.html.slim +++ b/app/views/new_suppliers/new.html.slim @@ -1,3 +1,4 @@ +h1.page-title= t 'devise.registrations.title' .row .small-12.columns ul @@ -10,28 +11,28 @@ li Download the app on your phone to test as a user li Scan a qr-code from you restaurant screen with your phone, and you can test ordering products!!! .row - .large-7.large-offset-1.columns + .large-8.large-offset-1.columns = form_for @new_supplier do |f| = f.row :supplier_name .large-4.columns= f.label :supplier_name - .large-4.columns= f.text_field :supplier_name - .large-4.columns= f.error_message :supplier_name + .large-6.columns= f.text_field :supplier_name, autofocus: true + .large-2.columns= f.error_message :supplier_name = f.row :email .large-4.columns= f.label :email - .large-4.columns + .large-6.columns - if @new_supplier.current_employee.present? = @new_supplier.current_employee.email - else = f.email_field :email - .large-4.columns= f.error_message :email + .large-2.columns= f.error_message :email - if not @new_supplier.current_employee.present? = f.row :password .large-4.columns= f.label :password - .large-4.columns= f.text_field :password + .large-4.columns= f.password_field :password .large-4.columns= f.error_message :password = f.row :password_confirmation .large-4.columns= f.label :password_confirmation - .large-4.columns= f.text_field :password_confirmation + .large-4.columns= f.password_field :password_confirmation .large-4.columns= f.error_message :password_confirmation .form-actions diff --git a/app/views/pages/contact.html.slim b/app/views/pages/contact.html.slim new file mode 100644 index 00000000..efc06099 --- /dev/null +++ b/app/views/pages/contact.html.slim @@ -0,0 +1,22 @@ +.row + .large-9.columns + .row: .small-12.columns=raw @page.body + = form_for Cmtool::ContactForm.new, url: contact_forms_path, html: {class: 'contact'} do |f| + .row + .large-4.columns: label Uw naam: + .large-2.columns= f.select :gender, [['Dhr.', 'male'], ['Mevr.', 'female']] + .large-6.columns.end= f.text_field :name + .row + .small-12.columns.end + label Uw vraag of opmerking:* + br + = f.text_area :body, cols: 32, rows: 8 + .row + .large-4.columns: label Uw e-mail adres:* + .large-8.columns.end= f.email_field :email + .row + .large-12.columns + = f.submit 'verstuur', class: 'button' + br + span * Verplicht veld + .large-3.columns== @page.sidebar diff --git a/app/views/suppliers/sessions/new.html.slim b/app/views/suppliers/sessions/new.html.slim index 21b2a767..433de9bf 100644 --- a/app/views/suppliers/sessions/new.html.slim +++ b/app/views/suppliers/sessions/new.html.slim @@ -6,7 +6,7 @@ h2= t('devise.sign_in.title') .form-field= f.email_field :email = f.row :email do .form-label= f.label :password - .form-field= f.password_field :password + .form-field= f.password_field :password, autofocus: true .form-row = f.label :remember_me do = f.check_box :remember_me diff --git a/app/views/theme1/_navigation.html.slim b/app/views/theme1/_navigation.html.slim index a126f719..2aaef26f 100644 --- a/app/views/theme1/_navigation.html.slim +++ b/app/views/theme1/_navigation.html.slim @@ -1,8 +1,8 @@ a.menu-secondary-toggle href="#" span ul.nav - li[class=(current_page?(controller: '/pages', action: 'home') ? :active : nil)]= link_to find_page('home').try(:menu_text), locale_root_path - li[class=(current_page?(controller: '/pages', action: 'show', name: 'about') ? :active : nil)]= link_to find_page('about').try(:menu_text), page_path('about') + li[class=(current_page?(controller: '/pages', action: 'home') ? ['home', :active] : ['home'])]= link_to find_page('home').try(:menu_text), locale_root_path + li[class=(current_page?(controller: '/pages', action: 'show', name: 'about') ? ['about', :active] : ['about'])]= link_to find_page('about').try(:menu_text), page_path('about') ul.nav.secondary - Page.menu_roots.each do |page| - li[class=(current_page?(controller: '/pages', action: 'show', name: page.name) ? :active : nil)]= link_to page.menu_text, page_path(page.name) + li[class=(current_page?(controller: '/pages', action: 'show', name: page.name) ? [page.name, :active] : [page.name])]= link_to page.menu_text, page_path(page.name) diff --git a/app/views/waiter/dashboard/index.html.slim b/app/views/waiter/dashboard/index.html.slim new file mode 100644 index 00000000..e69de29b diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 3b194112..0eb50020 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -13,6 +13,7 @@ en: title: Change your password button: Change password registrations: + title: Sign up for mozo as a restaurant link: Sign up links: prefix: 'OR:' diff --git a/config/locales/devise.nl.yml b/config/locales/devise.nl.yml index 59727ef6..0b38ce5a 100644 --- a/config/locales/devise.nl.yml +++ b/config/locales/devise.nl.yml @@ -3,10 +3,17 @@ nl: sign_in: title: Inloggen remember_me: Mij onthouden + link: Inloggen button: Inloggen - recoverable: - button: Wachtwoord vergeten + passwords: + title: Wachtwoord vergeten + link: Wachtwoord vergeten + button: Stuur reset + edit: + title: Change your password + button: Change password registrations: - button: Aanmelden + title: Aanmelden als restaurant + link: Aanmelden links: prefix: 'OF:' diff --git a/config/locales/models.en.yml b/config/locales/models.en.yml index 776f55aa..0154746a 100644 --- a/config/locales/models.en.yml +++ b/config/locales/models.en.yml @@ -68,6 +68,11 @@ en: postal_code: Postal code city: City country: Country + new_supplier: + supplier_name: Restaurant name + email: E-mail + password: Password + password_confirmation: Password confirmation table: number: Number from_number: From number diff --git a/config/locales/models.nl.yml b/config/locales/models.nl.yml index 4643fc6e..f5566078 100644 --- a/config/locales/models.nl.yml +++ b/config/locales/models.nl.yml @@ -67,6 +67,11 @@ nl: postal_code: Postcode city: Stad country: Land + new_supplier: + supplier_name: Restaurant name + email: E-mail + password: Wachtwoord + password_confirmation: Nogmaals wachtwoord table: number: Nummer from_number: Vanaf nummer diff --git a/config/routes.rb b/config/routes.rb index 95620819..f52e8ebe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,17 +32,20 @@ Qwaiter::Application.routes.draw do root to: 'users#index' end - resources :new_suppliers post '/user_app' => 'dashboard#user_app_log' #TODO: separate high speed app at log.mozo.bar post '/user_feedback' => 'user#feedback' #WAITER - get '/waiter' => 'waiter#index' #, controller: 'waiter', action: 'index' + #get '/waiter' => 'waiter#index' #, controller: 'waiter', action: 'index' get '/waiter/sections' => 'waiter#sections' get '/waiter/product_categories' => 'waiter#product_categories' get '/waiter/*rest' => redirect('/waiter') # Ember app refresh post '/waiter/order_products' => 'waiter#order_products', as: :order_products_waiter + namespace :waiter do + root to: 'dashboard#index' + + end # USER @@ -172,12 +175,15 @@ Qwaiter::Application.routes.draw do mount Cmtool::Engine => '/cmtool' - #get '/:locale' => 'pages#home', constraints: {locale: ALLOWED_LOCALES} + # /nl is not matched to pages#home with locale => nl + get '/:locale' => 'pages#home', constraints: {locale: ALLOWED_LOCALES} #devise_scope :supplier do #get '/:locale/suppliers/sign_up' => 'registrations#new', constraints: {locale: ALLOWED_LOCALES} #end scope '(/:locale)', constraints: {locale: ALLOWED_LOCALES}, defaults: { locale: 'en' } do root to: 'pages#home' + resources :contact_forms, only: [:create] + resources :new_suppliers get "/:name" => "pages#show", constraints: {name: /.*/}, as: :go_to end end diff --git a/spec/acceptance/website/contact_form.feature b/spec/acceptance/website/contact_form.feature new file mode 100644 index 00000000..58d639cf --- /dev/null +++ b/spec/acceptance/website/contact_form.feature @@ -0,0 +1,5 @@ +Feature: Submitting contact form + Scenario: Website visitor submits contact form + Given there are standard website pages + When I visit '/contact' + diff --git a/spec/acceptance_steps/global_website_steps.rb b/spec/acceptance_steps/global_website_steps.rb new file mode 100644 index 00000000..2d7c8ff6 --- /dev/null +++ b/spec/acceptance_steps/global_website_steps.rb @@ -0,0 +1,3 @@ +step "there are standard website pages" do + create_site_pages +end diff --git a/spec/factories/page_factory.rb b/spec/factories/page_factory.rb index d8ffe9d0..8920d07d 100644 --- a/spec/factories/page_factory.rb +++ b/spec/factories/page_factory.rb @@ -1,4 +1,6 @@ FactoryGirl.define do factory :page do + locale 'en' + layout 'theme1' end end diff --git a/spec/support/features/basic_helpers.rb b/spec/support/features/basic_helpers.rb index cc381c9d..2003b58d 100644 --- a/spec/support/features/basic_helpers.rb +++ b/spec/support/features/basic_helpers.rb @@ -28,6 +28,12 @@ module Features submit_form end + def create_site_pages + @home = create :page, name: 'home', layout: 'theme1-home', title: 'Home' + @about = create :page, name: 'about', title: 'About mozo' + @contact = create :page, name: 'contact', title: 'Contact' + end + def submit_form find("[type=submit]").click end