From cc13797f5ac3a51f9a27c41343eba3632fd33018 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Sat, 9 Mar 2013 14:18:21 +0100 Subject: [PATCH] supplier improvements --- Gemfile | 3 +- Gemfile.lock | 15 +- app/assets/images/icons/maps_location.png | Bin 0 -> 1356 bytes .../supplier/settings/location-balloon.png | Bin 0 -> 20570 bytes .../supplier/settings/location-balloon.svg | 219 ++++++++++++++++++ .../javascripts/supplier/application.js | 14 +- .../supplier/initializer.js.coffee | 71 +++++- .../javascripts/supplier/qsupplier.js.coffee | 5 +- .../javascripts/supplier/translations.js.erb | 8 +- .../supplier/section_tables.css.sass | 17 +- .../stylesheets/supplier/structure.css.sass | 13 +- app/controllers/suppliers/lists_controller.rb | 7 +- .../suppliers/products_controller.rb | 11 +- .../suppliers/tables_controller.rb | 2 + app/decorators/product_category_decorator.rb | 29 +++ app/decorators/product_decorator.rb | 10 +- app/decorators/supplier_decorator.rb | 5 + app/helpers/application_helper.rb | 21 +- app/models/list.rb | 11 +- app/models/product_category.rb | 21 +- app/models/supplier.rb | 4 + app/views/kaminari/_first_page.html.erb | 13 ++ app/views/kaminari/_gap.html.erb | 8 + app/views/kaminari/_last_page.html.erb | 13 ++ app/views/kaminari/_next_page.html.erb | 14 ++ app/views/kaminari/_page.html.erb | 12 + app/views/kaminari/_paginator.html.erb | 27 +++ app/views/kaminari/_prev_page.html.erb | 13 ++ app/views/layouts/tablet.html.slim | 13 +- app/views/supplier/edit.html.slim | 9 +- app/views/suppliers/lists/index.html.slim | 42 ++-- .../product_categories/_form.html.slim | 9 +- .../product_categories/index.html.slim | 1 + .../product_categories/show.html.slim | 18 +- app/views/suppliers/products/index.html.slim | 87 ++++--- app/views/suppliers/sections/_form.html.slim | 2 + app/views/suppliers/sections/index.html.slim | 2 +- .../sections/manage_tables.html.slim | 30 ++- app/views/suppliers/sections/show.html.slim | 2 + .../suppliers/sections/tables_view.html.slim | 4 + app/views/suppliers/tables/_form.html.slim | 6 +- app/views/suppliers/tables/index.html.slim | 8 +- config/locales/en.yml | 1 - config/locales/models.en.yml | 9 + config/locales/models.nl.yml | 4 + config/locales/nl.yml | 1 - config/locales/supplier.en.yml | 10 +- config/locales/supplier.nl.yml | 10 +- config/routes.rb | 6 +- .../product_category_decorator_spec.rb | 64 +++++ spec/i18n_spec.rb | 17 ++ .../javascripts/jquery.ui.datepicker-en.js | 16 ++ .../javascripts/jquery.ui.datepicker-nl.js | 18 ++ 53 files changed, 819 insertions(+), 156 deletions(-) create mode 100644 app/assets/images/icons/maps_location.png create mode 100644 app/assets/images/supplier/settings/location-balloon.png create mode 100644 app/assets/images/supplier/settings/location-balloon.svg create mode 100644 app/decorators/product_category_decorator.rb create mode 100644 app/decorators/supplier_decorator.rb create mode 100644 app/views/kaminari/_first_page.html.erb create mode 100644 app/views/kaminari/_gap.html.erb create mode 100644 app/views/kaminari/_last_page.html.erb create mode 100644 app/views/kaminari/_next_page.html.erb create mode 100644 app/views/kaminari/_page.html.erb create mode 100644 app/views/kaminari/_paginator.html.erb create mode 100644 app/views/kaminari/_prev_page.html.erb create mode 100644 spec/decorators/product_category_decorator_spec.rb create mode 100644 spec/i18n_spec.rb create mode 100644 vendor/assets/javascripts/jquery.ui.datepicker-en.js create mode 100644 vendor/assets/javascripts/jquery.ui.datepicker-nl.js diff --git a/Gemfile b/Gemfile index b05d5a04..ae1107d6 100644 --- a/Gemfile +++ b/Gemfile @@ -36,12 +36,11 @@ gem 'simply_stored' , :git => 'git://github.com/bterkuile/simply_stored.git' gem 'devise', '2.0.4' gem 'devise_simply_stored' gem 'simple_form' -gem 'draper' +gem 'active_decorator' gem 'cmtool', github: 'bterkuile/cmtool' gem 'rqrcode' gem 'mini_magick' -gem 'kaminari-bootstrap' #gem "less-rails-bootstrap-devise", :git => 'git://github.com/bigbento/less-rails-bootstrap-devise.git' # To use ActiveModel has_secure_password diff --git a/Gemfile.lock b/Gemfile.lock index 10bcd9b2..8e69f3e7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,6 +50,7 @@ GEM rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) + active_decorator (0.3.4) activemodel (3.2.11) activesupport (= 3.2.11) builder (~> 3.0.0) @@ -114,10 +115,6 @@ GEM devise_simply_stored (0.0.3) devise diff-lcs (1.2.1) - draper (1.1.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - request_store (~> 1.0.3) email_validator (1.3.0) activemodel erubis (2.7.0) @@ -154,12 +151,6 @@ GEM railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.7.7) - kaminari (0.14.1) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - kaminari-bootstrap (0.1.3) - kaminari (>= 0.13.0) - rails launchy (2.2.0) addressable (~> 2.3) letter_opener (1.1.0) @@ -219,7 +210,6 @@ GEM rb-fsevent (0.9.3) rdoc (3.12.2) json (~> 1.4) - request_store (1.0.5) rest-client (1.6.7) mime-types (>= 1.16) rqrcode (0.4.2) @@ -298,6 +288,7 @@ PLATFORMS ruby DEPENDENCIES + active_decorator bootstrap-sass bourbon cmtool! @@ -306,12 +297,10 @@ DEPENDENCIES couch_potato! devise (= 2.0.4) devise_simply_stored - draper factory_girl_rails guard-rspec haml-rails jquery-rails - kaminari-bootstrap letter_opener mini_magick mustache diff --git a/app/assets/images/icons/maps_location.png b/app/assets/images/icons/maps_location.png new file mode 100644 index 0000000000000000000000000000000000000000..5c576a5a2a876508938888a1967698b4554a4fec GIT binary patch literal 1356 zcmV-S1+)5zP)x^ zzrXW4zkBZy^7%XfJ9g}l01+@Nqr}om4v>K?Aouk2 z3uF|{_Vo1R1fS2Rg4+PQGFte5GLQjMKvEgA>MAV?c%#21cyWn=brOjBwkVe}kSk8T z&EFEd=(d<+Vr$Q7n5spqc0s6K zdq#XV9LuG=e2XrIm z7^d#GPne01VYN3PnU^sYdjNp5>pjf2da|i0oQ_5swjH7V%yweGoL`tgZmeH--@N+- zq9`ECdF@`6(6N=Y9h&6v+4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B`){qGWjg4VsTPvJlQ0Nt?! zzh{}^Qvwo-uo!W3B6n7P(7FMPF`t#!MJrW0yb!N*5Uv;J)b+cAVDJM%LHAa@t{$q! z?_7f4`IeGA*7R~>6(aMa$4g zw%RrI_%3wkoA{k?WY$&z3VT6bL({LuCatMywTl~L&RAX*tz=o@KndM19XbKQN%ujS zN%o#YTmE9|(b{#Hz1MfY3&(df{iPn2e~S3|(M?rLZLZ3g{E`<>50j-ugGK#J;D>;d z?gMaxi*bFv*RmH18}a+%=$>Wxy~~uwBTYlUIzis_s*7Uj^y~JDjWPKvr=3=+wD1~1 zW(wQ^h+Ht3V9->g_jN6Ik;cRLJD1!RcdgysA~#};$(h!l)0!nN*}w2Mff>LU0O>V?U~utSPq6E;?dbl>OrbikviY(E z5H_GxC{)DG>-;vizJI($?!y?97h11qm5=V4YG}Mq;bBqj3xf0>MKJJwQDq@kyQacR7nD(v3hlhM7Y30Ti32cmM zlg_QvdTDqx*^TjnP6vtrq{kp!|H-(^ZW1K;;_s#F(SvL8nc*IKcq7f8@YN~2=R_+s z)QafjHEZpJ8e>e8v+K0VM)gSh1u9gii1zBXlCewE=X__zn0Dzaby|tCqW&%n9|kuCw6jFJsOxt-?uv;> zmv3bLDS14zPU=uKzIGj2yDqbvXA_|gWrd<2IOmo|x*q)x284VLVE+UG{`#ljVSfpw*ypgt*7Y3nr}DoR!qZm<}s5r&Ttp zM=DJG2%#7l0DQVW0V?cs%5s!AfyN`}$x3csRiEX&#+VLH5+#Md5oJ0MYxa2(SOvsY ziTjAe?Ia~d5(==I*mv}VVu*SA(F~;Ph{{cD>iqruSqC)@x002ovPDHLk FV1ler-oyX^ literal 0 HcmV?d00001 diff --git a/app/assets/images/supplier/settings/location-balloon.svg b/app/assets/images/supplier/settings/location-balloon.svg new file mode 100644 index 00000000..809b4a2e --- /dev/null +++ b/app/assets/images/supplier/settings/location-balloon.svg @@ -0,0 +1,219 @@ + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Klik op de kaart om je locatie aan te geven + + + \ No newline at end of file diff --git a/app/assets/javascripts/supplier/application.js b/app/assets/javascripts/supplier/application.js index d39323ad..84470745 100644 --- a/app/assets/javascripts/supplier/application.js +++ b/app/assets/javascripts/supplier/application.js @@ -1,6 +1,8 @@ //= require jquery //= require jquery_ujs //= require jquery-ui +//= require jquery.ui.datepicker-en +//= require jquery.ui.datepicker-nl // require bootstrap-transition // require bootstrap-affix // require bootstrap-alert @@ -43,15 +45,3 @@ function redirect_to(mapping, variables){ function currency(num) { return Qwaiter.currency(num); } -$(function(){ - //$locale = Qstorage.getItem('locale') || 'en'; - 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'); - } - setTranslations(); -}); diff --git a/app/assets/javascripts/supplier/initializer.js.coffee b/app/assets/javascripts/supplier/initializer.js.coffee index 2198da02..f2845e55 100644 --- a/app/assets/javascripts/supplier/initializer.js.coffee +++ b/app/assets/javascripts/supplier/initializer.js.coffee @@ -1,13 +1,8 @@ $( -> - week_days_container = $('#week_days-group') - $('.week-day-select').each( (i)-> - select = $(this) - toggle = $('') - toggle.attr('data-t', 'product_category.week_days.abbreviation.'+select.data('day')) - toggle.addClass('active') if select.val() == '1' - week_days_container.append(toggle) - toggle.click( -> select.val(Math.abs(select.val() - 1))) - ) + $('.week-day-toggle').each -> + select = $('#week-day-select-'+$(@).data('day')) + $(@).addClass('active') if select.val() == '1' + $(@).click( -> select.val(Math.abs(select.val() - 1))) $('#full_day-controller').each -> control = $('#product_category_full_day') @@ -24,10 +19,22 @@ $( -> $(@).removeClass 'icon-white' $('#sub-day-container').addClass('hide') + if Qstorage.getItem('message') + container = $('.alert-success'); + msg_finder = Qstorage.getItem('message'); + msg_finder = 'messages.'+msg_finder if msg_finder.indexOf('.') == -1 + container.find('div').text(t(msg_finder)) + container.show() + Qstorage.removeItem('message') + + $('.datepicker').datepicker(window.datepicker_options) + + setTranslations() # GOOGLE LOCATION PICKER $("input.location_picker").each( (i)-> #return if typeof(google) == 'undefined' + iconBase = 'https://maps.google.com/mapfiles/kml/' location_input = $(this) map_div = $('
').addClass("location_picker_map") @@ -43,7 +50,7 @@ $( -> lng = values[1] center = new google.maps.LatLng(lat,lng) mapOptions = - zoom: 13 + zoom: 15 center: center mapTypeId: google.maps.MapTypeId.ROADMAP, zoomControl: true @@ -59,10 +66,54 @@ $( -> position: center map: map title: 'Location' + icon: '/assets/icons/maps_location.png' ) google.maps.event.addListener(map, 'click', (point)-> marker.setPosition(point.latLng) location_input.val point.latLng.lat() + ','+ point.latLng.lng() ) + + search_field = $('') + search_field.addClass('location_picker_search') + autocomplete = new google.maps.places.Autocomplete(search_field.get(0)) + autocomplete.bindTo('bounds', map) + search_field.keypress( (e) -> + if e.which == 13 + e.preventDefault() + ) + window.autocomplete = autocomplete + map_div.before(search_field) + infowindow = new google.maps.InfoWindow() + search_marker = new google.maps.Marker({map: map, icon: iconBase + 'shapes/placemark_circle.png'}) + google.maps.event.addListener(autocomplete, 'place_changed', -> + infowindow.close() + search_marker.setVisible(false) + place = autocomplete.getPlace() + return unless place.geometry + #if place.geometry.viewport + # map.fitBounds(place.geometry.viewport) + #else + map.setCenter(place.geometry.location) + map.setZoom(17) + image = + url: place.icon + size: new google.maps.Size(71, 71) + origin: new google.maps.Point(0, 0) + anchor: new google.maps.Point(17, 34) + scaledSize: new google.maps.Size(35, 35) + #search_marker.setIcon(image) + search_marker.setPosition(place.geometry.location) + search_marker.setVisible(true) + + address = '' + if place.address_components + address = [ + (place.address_components[0] && place.address_components[0].short_name || ''), + (place.address_components[1] && place.address_components[1].short_name || ''), + (place.address_components[2] && place.address_components[2].short_name || '') + ].join(' ') + infowindow.setContent('
' + place.name + '
' + address + '
') + infowindow.open(map, search_marker) + ) ) ) diff --git a/app/assets/javascripts/supplier/qsupplier.js.coffee b/app/assets/javascripts/supplier/qsupplier.js.coffee index 292f5ba5..f124c4a8 100644 --- a/app/assets/javascripts/supplier/qsupplier.js.coffee +++ b/app/assets/javascripts/supplier/qsupplier.js.coffee @@ -13,7 +13,8 @@ root.Qsupplier= else if(e.event == 'list_needs_payment') $('#list-needs-payment-indicator-'+e.data.id).removeClass('hide') else if(e.event == 'list_added') - $('#active-lists-table tbody').append @mustache('#active-list-template', new List(e.data)) + list = new List(e.data) + $('#active-lists-table tbody').append @mustache('#active-list-template', list) else if e.event == 'list_update' list = new List(e.data) row = $('#list-row-'+list.id()) @@ -146,6 +147,8 @@ root.Qsupplier= if table.occupied then to.addClass('occupied') else to.removeClass('occupied') if table.needs_help then to.addClass('needs_help') else to.removeClass('needs_help') if table.needs_payment then to.addClass('needs_payment') else to.removeClass('needs_payment') + if table.active_order then to.addClass('active_order') else to.removeClass('active_order') + ) add_tables_to_active_section: -> number_start = $('#add-tables-number-start').val() diff --git a/app/assets/javascripts/supplier/translations.js.erb b/app/assets/javascripts/supplier/translations.js.erb index 2fd9963e..1e755beb 100644 --- a/app/assets/javascripts/supplier/translations.js.erb +++ b/app/assets/javascripts/supplier/translations.js.erb @@ -3,17 +3,18 @@ var $translations = { models: <%= I18n.t('activemodel.models', locale: :en).to_json %>, attributes: <%= I18n.t('activemodel.attributes', locale: :en).to_json %>, helpers: <%= I18n.t('helpers', locale: :en).to_json %>, + pagination: <%= I18n.t('views.pagination', locale: :en).to_json %>, <%= I18n.t('supplier', locale: :en).to_json[1..-2] %> }, nl: { models: <%= I18n.t('activemodel.models', locale: :nl).to_json %>, attributes: <%= I18n.t('activemodel.attributes', locale: :nl).to_json %>, helpers: <%= I18n.t('helpers', locale: :nl).to_json %>, + pagination: <%= I18n.t('views.pagination', locale: :nl).to_json %>, <%= I18n.t('supplier', locale: :nl).to_json[1..-2] %> } } - $transformation_mappings = { downcase: 'toLowerCase', upcase: 'toUpperCase' @@ -29,6 +30,7 @@ function t(path, vars){ } catch(err){ result = parts[parts.length - 1].capitalize(); } + if(result == '') return ''; if(!result) return parts[parts.length - 1].capitalize(); $.each(vars, function(v, value){ result = result.replace('%{'+v+'}', value)}); isafety = 0; @@ -61,10 +63,12 @@ function setTranslations(selector){ if(selector){ $(selector).find('[data-t]').each(function(){$(this).text(t($(this).data('t'), $(this).data('tAttributes')))}) }else{ - $('[data-t]').each(function(){$(this).text(t($(this).data('t'),$(this).data('tAttributes')))}) + $('[data-t]').each(function(){$(this).html(t($(this).data('t'),$(this).data('tAttributes')))}) } moment.lang($locale); $('[data-time]').each(function(){ $(this).text(moment($(this).data('time')).format($(this).data('timeFormat') || 'dd D HH:MM')) }) + + $('.datepicker').datepicker("option", $.datepicker.regional[$locale]) } diff --git a/app/assets/stylesheets/supplier/section_tables.css.sass b/app/assets/stylesheets/supplier/section_tables.css.sass index ac3129b1..aade0451 100644 --- a/app/assets/stylesheets/supplier/section_tables.css.sass +++ b/app/assets/stylesheets/supplier/section_tables.css.sass @@ -1,4 +1,4 @@ -$table-width: 75px +$table-width: 83px .section-title font-size: 24px padding: 4px 0px @@ -7,7 +7,7 @@ $table-width: 75px margin: -26px 6px 4px 6px .section-table background-color: #ccc - height: 44px + height: 48px background-repeat: no-repeat width: $table-width color: black @@ -24,6 +24,12 @@ $table-width: 75px width: 45px font-size: 42px text-align: center + .status-icons + float: right + width: 16px + span + display: none + float: right .action-button-container margin-right: -20px &.section-tables-active @@ -39,9 +45,16 @@ $table-width: 75px background-color: #ffa &.needs_help background-color: #7f7 + .needs_help + display: block &.needs_payment background-image: image-url('icons/needs-payment.png') background-position: 40px 2px + .needs_payment + display: block + &.active_order + .active_order + display: block //background-color: #f77 a &:hover diff --git a/app/assets/stylesheets/supplier/structure.css.sass b/app/assets/stylesheets/supplier/structure.css.sass index fd78de03..4c5d44f4 100644 --- a/app/assets/stylesheets/supplier/structure.css.sass +++ b/app/assets/stylesheets/supplier/structure.css.sass @@ -29,12 +29,21 @@ body .alert form margin: 0 +.location_picker_search + float: left .location_picker_map - width: 300px - height: 200px + width: 600px + height: 500px border: 1px solid black padding: 2px display: inline-block + float: left + clear: left + img + max-width: none + label + width: auto + display:inline .handle cursor: move font-size: 0.8em diff --git a/app/controllers/suppliers/lists_controller.rb b/app/controllers/suppliers/lists_controller.rb index 77ab5cf0..18eb1963 100644 --- a/app/controllers/suppliers/lists_controller.rb +++ b/app/controllers/suppliers/lists_controller.rb @@ -11,7 +11,12 @@ module Suppliers @start_time += current_supplier.night_offset.to_f.hours @end_time += current_supplier.night_offset.to_f.hours end - @lists = List.for_supplier_created_at current_supplier, @start_time..@end_time + if params[:show_all] == 'yes' + @lists = List.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25) + else + @lists = List.for_supplier_created_at current_supplier, @start_time..@end_time + end + @lists.include_relation(:table) respond_to do |format| format.html # index.html.erb diff --git a/app/controllers/suppliers/products_controller.rb b/app/controllers/suppliers/products_controller.rb index c755958c..807c6541 100644 --- a/app/controllers/suppliers/products_controller.rb +++ b/app/controllers/suppliers/products_controller.rb @@ -4,7 +4,7 @@ module Suppliers # GET /products # GET /products.json def index - @products = ProductDecorator.decorate_collection(current_supplier.products) + @products = current_supplier.products respond_to do |format| format.html # index.html.erb @@ -15,7 +15,7 @@ module Suppliers # GET /products/1 # GET /products/1.json def show - @product = ProductDecorator.decorate(Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])) + @product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id]) respond_to do |format| format.html # show.html.erb @@ -84,5 +84,12 @@ module Suppliers format.json { head :no_content } end end + + def preview_products + @date = Date.parse(params[:date]) rescue Date.today + product_categories = ProductCategory.for_supplier_in_time(current_supplier, @date.to_time) + render json: {categories: product_categories.map(&:to_client_format).select(&:present?)} + + end end end diff --git a/app/controllers/suppliers/tables_controller.rb b/app/controllers/suppliers/tables_controller.rb index 77667a68..b8c75869 100644 --- a/app/controllers/suppliers/tables_controller.rb +++ b/app/controllers/suppliers/tables_controller.rb @@ -4,6 +4,7 @@ module Suppliers # GET /tables.json def index @tables = Table.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25, from_number: params[:from_number], to_number: params[:to_number]) + @tables.include_relation(:section) respond_to do |format| format.html # index.html.erb @@ -88,6 +89,7 @@ module Suppliers def qr_codes @tables = current_supplier.tables + @tables.select!{|t| t.section_id == params[:section_id]} if params[:section_id].present? render layout: 'qr_sheet' end end diff --git a/app/decorators/product_category_decorator.rb b/app/decorators/product_category_decorator.rb new file mode 100644 index 00000000..f7db6319 --- /dev/null +++ b/app/decorators/product_category_decorator.rb @@ -0,0 +1,29 @@ +module ProductCategoryDecorator + + def products + #ProductDecorator.decorate_collection(model.products) + @decorated_products ||= ActiveDecorator::Decorator.instance.decorate(super) + end + + def visible_on + sum = week_days.sum + return content_tag(:span, '', class: 'icon-eye-close icon-white') if sum.zero? + return content_tag(:span, '', class: 'icon-refresh icon-white') if sum == 7 && full_day + day_names = I18n.t('date.day_names') + days = week_days.map.with_index{|v,i| v == 1 ? day_names[i] : nil}.compact + days << days.shift if week_days.first == 1 && supplier.week_starts_on_monday? + days = days.join(', ') + unless full_day + from_time = start_from + from_time -= 1440 if from_time > 1440 + from_hour = from_time / 60.0 + to_time = end_on + to_time -= 1440 if to_time > 1440 + to_hour = to_time / 60.0 + time_display = "#{from_hour.floor}:#{'%02d' % (from_hour.modulo(1) * 60)} - #{to_hour.floor}:#{'%02d' % (to_hour.modulo(1)*60)}" + return time_display if sum == 7 + days << " #{time_display}" + end + days + end +end diff --git a/app/decorators/product_decorator.rb b/app/decorators/product_decorator.rb index 075b2ecd..ad53cf27 100644 --- a/app/decorators/product_decorator.rb +++ b/app/decorators/product_decorator.rb @@ -1,17 +1,15 @@ -class ProductDecorator < Draper::Decorator - decorates :product - delegate_all +module ProductDecorator def category_links(options = {}) if namespace = options[:namespace] - product_categories.map{|pc| h.link_to pc.name, [namespace, pc]}.join(', ').html_safe + product_categories.map{|pc| link_to pc.name, [namespace, pc]}.join(', ').html_safe else - product_categories.map{|pc| h.link_to pc.name, pc}.join(', ').html_safe + product_categories.map{|pc| link_to pc.name, pc}.join(', ').html_safe end end def display - "#{model.name} (#{h.currency(model.price)})".html_safe + "#{name} (#{currency(price)})".html_safe end # Accessing Helpers diff --git a/app/decorators/supplier_decorator.rb b/app/decorators/supplier_decorator.rb new file mode 100644 index 00000000..cb31aad2 --- /dev/null +++ b/app/decorators/supplier_decorator.rb @@ -0,0 +1,5 @@ +module SupplierDecorator + def products + ActiveDecorator::Decorator.instance.decorate super + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a1070ef8..43ac7d68 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -58,14 +58,29 @@ module ApplicationHelper current_user.try(:active_list_id) end + def week_days + @week_days ||= %w[sunday monday tuesday wednesday thursday friday saturday].freeze # Do not allow changing this value + end + + def current_supplier + #@current_supplier ||= ActiveDecorator::Decorator.instance.decorate(super) + @current_supplier ||= super + ActiveDecorator::Decorator.instance.decorate @current_supplier + @current_supplier + end + def no_content_given(model) - t('helpers.list.no_records') + content_tag(:p, t('helpers.list.no_records'), data: {t: 'helpers.list.no_records'}) end def slider_image image_tag('spinner.gif') end + def spinner + image_tag('spinner.gif') + end + def show_boolean(bool) t("general.boolean.boolean_#{bool.present? ? 'yes' : 'no'}") end @@ -90,7 +105,9 @@ module ApplicationHelper script += (buffer.presence || value).to_s end script = script.call if script.respond_to?(:call) - script.present? ? (@onload_javascripts ||= []) << script : (@onload_javascripts || []).join(';') + script.sub!(/^]+>/,'') if script + script.sub!(/<\/script>$/, '') if script + script.present? ? (@onload_javascripts ||= []) << script : (@onload_javascripts || []).join(';').html_safe end def mustache_template(template) diff --git a/app/models/list.rb b/app/models/list.rb index 68068ee5..11fc9513 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -23,8 +23,7 @@ class List validates :supplier_id, presence: true view :by_supplier_id_and_id, key: [:supplier_id, :_id] - view :by_supplier_id, key: :supplier_id - view :for_supplier_view, key: [:supplier_id, :created_at] + view :for_supplier_view, key: [:supplier_id, :state, :created_at] view :active_by_table_id_view, type: :custom, map_function: %|function(doc){ if(doc.ruby_class == 'List' && doc.state == 'active'){ @@ -75,6 +74,14 @@ class List list end + def self.for_supplier(supplier, options = {}) + total_entries = database.view(for_supplier_view({startkey: ["#{supplier.id}\u9999"], endkey: [supplier.id], include_docs: false, reduce: true, descending: true})) + options[:total_entries] = total_entries + with_pagination_options(options) do |options| + database.view(for_supplier_view({startkey: ["#{supplier.id}\u9999"], endkey: [supplier.id], include_docs: true, reduce: false, descending: true}.merge(options))) + end + end + def self.active_for_supplier(supplier_id, options = {}) database.view(active_by_supplier_id_view(key: supplier_id, reduce: false, include_docs: true)) end diff --git a/app/models/product_category.rb b/app/models/product_category.rb index 578d9589..bcfc11ce 100644 --- a/app/models/product_category.rb +++ b/app/models/product_category.rb @@ -44,6 +44,7 @@ class ProductCategory @week_days = typecasted_value end + #TODO I am uuuuggggllyyyyy def self.for_user(user, options = {}) table = options[:table] raise "ProductCategory.for_user requires a table" unless table.present? @@ -54,19 +55,17 @@ class ProductCategory product_categories = for_supplier_in_time(supplier, options[:time]) # The following part is creating the products hash. This should not be performed here!!!!!! #TODO fix this!!!@@!!@@!!@ - products = supplier.products - # sort categories - product_categories.sort_by!{|pc| (pc.position || 90000).to_i } + #products = supplier.products # Append other category if not defined by supplier - other = product_categories.find(&:other?) || (product_categories << self.other).last # Container for non categorized products + #other = product_categories.find(&:other?) || (product_categories << self.other).last # Container for non categorized products # Initialize base return object h = {table_number: table.number, table_occupied: table.occupied?, supplier_name: supplier.name, my_list: list.try(:user_ids).to_a.include?(user.id)} - (products - product_categories.map(&:products).flatten).each{ |p| other.add_product(p) } + #(products - product_categories.map(&:products).flatten).each{ |p| other.add_product(p) } - h[:categories] = product_categories.map{|pc| {name: pc.name, products: pc.products.to_a.map{|p| p.as_json}}}.select{|pc| pc && pc[:products].present?} + h[:categories] = product_categories.map(&:to_client_format).select(&:present?) h end @@ -81,7 +80,15 @@ class ProductCategory week_day = 6 if week_day < 0 # Saturday end view_options = {reduce: false, include_docs: true} - database.view(by_supplier_id_and_week_time(view_options.merge(keys: [[supplier.id, week_day], [supplier.id, week_day, minute]]))) + product_categories = database.view(by_supplier_id_and_week_time(view_options.merge(keys: [[supplier.id, week_day], [supplier.id, week_day, minute]]))) + product_categories.sort_by!{|pc| (pc.position || 90000).to_i } + # sort categories + product_categories + end + + def to_client_format + return {} unless products.present? + {name: name, products: products.to_a.map{|p| p.as_json}} end def other? diff --git a/app/models/supplier.rb b/app/models/supplier.rb index 2c169b54..08c94e64 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -116,6 +116,10 @@ class Supplier def send_creation_notifications SupplierMailer.creation(self).deliver end + + def week_starts_on_monday? + true + end private def add_section_on_create diff --git a/app/views/kaminari/_first_page.html.erb b/app/views/kaminari/_first_page.html.erb new file mode 100644 index 00000000..32d1f4b8 --- /dev/null +++ b/app/views/kaminari/_first_page.html.erb @@ -0,0 +1,13 @@ +<%# Link to the "First" page + - available local variables + url: url to the first page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +<% unless current_page.first? -%> +
  • + <%= link_to raw(t 'views.pagination.first'), url, {:remote => remote, data: {t: 'pagination.first'}} %> +
  • +<% end -%> diff --git a/app/views/kaminari/_gap.html.erb b/app/views/kaminari/_gap.html.erb new file mode 100644 index 00000000..24f27660 --- /dev/null +++ b/app/views/kaminari/_gap.html.erb @@ -0,0 +1,8 @@ +<%# Non-link tag that stands for skipped pages... + - available local variables + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +
  • <%= raw(t 'views.pagination.truncate') %>
  • diff --git a/app/views/kaminari/_last_page.html.erb b/app/views/kaminari/_last_page.html.erb new file mode 100644 index 00000000..d6ad7b37 --- /dev/null +++ b/app/views/kaminari/_last_page.html.erb @@ -0,0 +1,13 @@ +<%# Link to the "Last" page + - available local variables + url: url to the last page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +<% unless current_page.last? -%> +
  • + <%= link_to raw(t 'views.pagination.last'), url, {:remote => remote, data: {t: 'pagination.last'}} %> +
  • +<% end -%> diff --git a/app/views/kaminari/_next_page.html.erb b/app/views/kaminari/_next_page.html.erb new file mode 100644 index 00000000..e0f92822 --- /dev/null +++ b/app/views/kaminari/_next_page.html.erb @@ -0,0 +1,14 @@ +<%# Link to the "Next" page + - available local variables + url: url to the next page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> + +<% unless current_page.last? -%> +
  • + <%= link_to raw(t 'views.pagination.next'), url, :remote => remote, :rel => 'next', data: {t: 'pagination.next'} %> +
  • +<% end -%> diff --git a/app/views/kaminari/_page.html.erb b/app/views/kaminari/_page.html.erb new file mode 100644 index 00000000..ca0c26ba --- /dev/null +++ b/app/views/kaminari/_page.html.erb @@ -0,0 +1,12 @@ +<%# Link showing page number + - available local variables + page: a page object for "this" page + url: url to this page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +
  • + <%= link_to page, (page.current? ? 'javascript:void(0)' : url), opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %> +
  • diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb new file mode 100644 index 00000000..31404e91 --- /dev/null +++ b/app/views/kaminari/_paginator.html.erb @@ -0,0 +1,27 @@ +<%# The container tag + - available local variables + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote + paginator: the paginator that renders the pagination tags inside +-%> +<%= paginator.render do -%> + +<% end -%> diff --git a/app/views/kaminari/_prev_page.html.erb b/app/views/kaminari/_prev_page.html.erb new file mode 100644 index 00000000..17dd694d --- /dev/null +++ b/app/views/kaminari/_prev_page.html.erb @@ -0,0 +1,13 @@ +<%# Link to the "Previous" page + - available local variables + url: url to the previous page + current_page: a page object for the currently displayed page + total_pages: total number of pages + per_page: number of items to fetch per page + remote: data-remote +-%> +<% unless current_page.first? -%> +
  • + <%= link_to raw(t 'views.pagination.previous'), url, :remote => remote, :rel => 'prev', data: {t: 'pagination.previous'} %> +
  • +<% end -%> diff --git a/app/views/layouts/tablet.html.slim b/app/views/layouts/tablet.html.slim index f9404c7d..ceb5fd91 100644 --- a/app/views/layouts/tablet.html.slim +++ b/app/views/layouts/tablet.html.slim @@ -22,6 +22,7 @@ html lang="en" var supplier_id = '#{current_supplier.id}'; var data_host = ''; var event_host = '#{event_host}'; + var datepicker_options = {dateFormat: 'yy-mm-dd', firstDay: #{current_supplier.week_starts_on_monday? ? 1 : 0}}; = yield :head @@ -50,11 +51,11 @@ html lang="en" ul.nav#top-navigation-list //li= link_to t('supplier.menu.active_orders', orders: Order.model_name.human_plural), supplier_active_orders_path //li= link_to t('supplier.menu.active_lists', lists: List.model_name.human_plural), supplier_active_lists_path - li= link_to ProductCategory.model_name.human_plural, suppliers_product_categories_path - li= link_to Product.model_name.human_plural, suppliers_products_path - li= link_to Section.model_name.human_plural, suppliers_sections_path - li= link_to Table.model_name.human_plural, suppliers_tables_path - li= link_to List.model_name.human_plural, suppliers_lists_path + li= link_to ProductCategory.model_name.human_plural, suppliers_product_categories_path, data: {t: 'models.plural.product_category'} + li= link_to Product.model_name.human_plural, suppliers_products_path, data: {t: 'models.plural.product'} + li= link_to Section.model_name.human_plural, suppliers_sections_path, data: {t: 'models.plural.section'} + li= link_to Table.model_name.human_plural, suppliers_tables_path, data: {t: 'models.plural.table'} + li= link_to List.model_name.human_plural, suppliers_lists_path, data: {t: 'models.plural.list'} .container .content.main-content - if flash[:alert].present? @@ -81,3 +82,5 @@ html lang="en" = javascript_include_tag "supplier/application" script#alert-template[type="text/html"]= mustache_template 'supplier/alert' = yield :footer + javascript: + jQuery(function(){#{onload_javascript}}); diff --git a/app/views/supplier/edit.html.slim b/app/views/supplier/edit.html.slim index 2d73edaa..f733af03 100644 --- a/app/views/supplier/edit.html.slim +++ b/app/views/supplier/edit.html.slim @@ -1,5 +1,5 @@ - content_for :head do - = javascript_include_tag 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false' + = javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places&language=#{I18n.locale}" = form_for @supplier, url: supplier_update_settings_path, html: {class: 'form-horizontal'} do |f| = render 'suppliers/application/error_messages', target: current_supplier @@ -20,13 +20,14 @@ .control-group class=(@supplier.errors[:location].any? ? 'error' : nil) = f.label :location, class: 'control-label' .controls - = f.text_field :location, class: 'location_picker' + = f.text_field :location, class: 'location_picker' + = image_tag 'supplier/settings/location-balloon.png' .control-group = f.label :time_zone, class: 'control-label' .controls /= f.input :time_zone, collection: ActiveSupport::TimeZone.all, label_method: :to_s, value_method: :name, include_blank: false = f.collection_select :time_zone, ActiveSupport::TimeZone.all, :name, :to_s - .accordion-group + /.accordion-group .accordion-heading a.accordion-toggle data-toggle="collapse" data-parent="#settings-sections" href="#settings-wifi" data-t="attributes.supplier.offer_wifi" #settings-wifi.accordion-body.collapse @@ -46,7 +47,7 @@ = f.label :wifi_password, class: 'control-label' .controls = f.text_field :wifi_password, class: 'text_field' - .accordion-group + /.accordion-group .accordion-heading a.accordion-toggle data-toggle="collapse" data-parent="#settings-sections" href="#settings-reviews" data-t="settings.reviews.title" #settings-reviews.accordion-body.collapse class=(@supplier.errors[:iens_profile].any? ? 'in' : nil) diff --git a/app/views/suppliers/lists/index.html.slim b/app/views/suppliers/lists/index.html.slim index 67bab240..917630e4 100644 --- a/app/views/suppliers/lists/index.html.slim +++ b/app/views/suppliers/lists/index.html.slim @@ -1,41 +1,39 @@ - model_class = List div.page-header= title :index, model_class -form action='' method="get" - input#lists-date type="text" name="date" value=@date.to_s('%Y-%m-%d') +form#select-date-form action='' method="get" + - if params[:show_all] == 'yes' + - else + input#lists-date.datepicker type="text" name="date" value=@date.to_s('%Y-%m-%d') + = link_to '', {show_all: 'yes'}, class: 'btn', data: {t: 'lists.index.show_all'} .well - if @lists.any? + = paginate @lists if params[:show_all] == 'yes' table.table thead tr - th= model_class.human_attribute_name(:state) - th= model_class.human_attribute_name(:needs_help) - th= model_class.human_attribute_name(:needs_payment) - th= model_class.human_attribute_name(:closed_at) - th= Table.model_name.human - th.currency= model_class.human_attribute_name(:price) - th.timestamp= model_class.human_attribute_name(:created_at) - th.actions=t 'helpers.actions.title' + th data-t='attributes.list.state' = model_class.human_attribute_name(:state) + th data-t='attributes.list.needs_help' = model_class.human_attribute_name(:needs_help) + th data-t='attributes.list.needs_payment' = model_class.human_attribute_name(:needs_payment) + th data-t='attributes.list.closed_at' = model_class.human_attribute_name(:closed_at) + th data-t='models.table' = Table.model_name.human + th.currency data-t='attributes.list.price' = model_class.human_attribute_name(:price) + th.timestamp data-t='attributes.list.created_at' = model_class.human_attribute_name(:created_at) + th.actions data-t='helpers.actions.title' =t 'helpers.actions.title' tbody - @lists.each do |list| tr td= link_to list.state, [:suppliers, list] td=show_boolean list.needs_help td=show_boolean list.needs_payment - td=l list.closed_at, format: :short + td.timestamp data-time=list.closed_at.try(:utc).try(:iso8601) td= link_to_if list.table.present?, list.table.try(:number), [:suppliers, list.table] td.currency= list.price.present? ? currency(list.price) : '...' - td.timestamp=l list.created_at, format: :short + td.timestamp data-time=list.created_at.utc.iso8601 td.actions - = link_to t('helpers.links.edit'), [:edit, :suppliers, list], class: 'btn btn-mini' + = link_to t('helpers.links.edit'), [:edit, :suppliers, list], class: 'btn btn-mini', data: {t: 'helpers.links.edit'} ' - = link_to t("helpers.links.destroy"), [:suppliers, list], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' + = link_to t("helpers.links.destroy"), [:suppliers, list], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger', data: {t: 'helpers.links.destroy'} - else = no_content_given model_class -- content_for :footer do - javascript: - $('#lists-date').datepicker({ - dateFormat: 'yy-mm-dd', - onSelect: function(dateText, inst){ - $(this).parents('form').submit(); - } - }) +javascript: + window.datepicker_options['onSelect'] = function(dateText, inst){$('#select-date-form').submit()} diff --git a/app/views/suppliers/product_categories/_form.html.slim b/app/views/suppliers/product_categories/_form.html.slim index ab079db1..f742d782 100644 --- a/app/views/suppliers/product_categories/_form.html.slim +++ b/app/views/suppliers/product_categories/_form.html.slim @@ -5,7 +5,7 @@ = hidden_field_tag 'product_category[product_ids][]', '' = label_tag nil, Product.model_name.human_plural, class: 'control-label' .controls - - for product in ProductDecorator.decorate_collection(current_supplier.products) + - for product in current_supplier.products = check_box_tag "product_category[product_ids][]", product.id, @product_category.product_ids.to_a.include?(product.id), id: "product-checker-#{product.id}" = label_tag "product-checker-#{product.id}", product.display br @@ -13,13 +13,18 @@ = label_tag nil, ProductCategory.human_attribute_name(:week_days), class: 'control-label' .controls #week_days-group.btn-group data-toggle="buttons-checkbox" + - day_names = week_days.dup; day_names << day_names.shift if current_supplier.week_starts_on_monday? + - day_names.each do |day_name| + button.week-day-toggle.btn type="button" data-day=day_name data-t="product_category.week_days.abbreviation.#{day_name}" + + span#full_day-controller.icon.icon-time #sub-day-container.hide = f.input_field :start_from, as: :select, collection: (1..24).map{|h| ["#{h}:00", h*60]} = f.input_field :end_on, as: :select, collection: (1..24).map{|h| ["#{h}:00", h*60]} .hidden - @product_category.week_days.each.with_index do |day, i| - = select_tag 'product_category[week_days][]', options_for_select([0,1], day), class: 'week-day-select', data: {day:%w[sunday monday tuesday wednesday thursday friday saturday][i]} + = select_tag 'product_category[week_days][]', options_for_select([0,1], day), class: 'week-day-select', id: "week-day-select-#{week_days[i]}", data: {day: week_days[i] } /= f.input :full_day, as: :select, collection: [true, false], label: false, include_blank: false = f.input_field :full_day, as: :boolean, label: false, wrapper: false /= f.check_box :full_day diff --git a/app/views/suppliers/product_categories/index.html.slim b/app/views/suppliers/product_categories/index.html.slim index 8dd16ecb..5d17a1fc 100644 --- a/app/views/suppliers/product_categories/index.html.slim +++ b/app/views/suppliers/product_categories/index.html.slim @@ -7,6 +7,7 @@ = content_tag_for :li, product_category do span.handle.icon-move.icon-white span.name= link_to product_category.name, [:suppliers, product_category] + span= product_category.visible_on .pull-right.actions = link_to t('helpers.links.edit'), [:edit, :suppliers, product_category], class: 'btn btn-mini' ' diff --git a/app/views/suppliers/product_categories/show.html.slim b/app/views/suppliers/product_categories/show.html.slim index 211f71ee..2c7572aa 100644 --- a/app/views/suppliers/product_categories/show.html.slim +++ b/app/views/suppliers/product_categories/show.html.slim @@ -2,17 +2,19 @@ .page-header= title :show, @product_category dl.dl-horizontal.show-list - dt= model_class.human_attribute_name(:name) + dt data-t='attributes.product_category.name'= model_class.human_attribute_name(:name) dd= @product_category.name - dt= model_class.human_attribute_name(:position) + dt data-t='attributes.product_category.position'= model_class.human_attribute_name(:position) dd= @product_category.position + dt data-t='attributes.product_category.visible_on'= model_class.human_attribute_name(:visible_on) + dd= @product_category.visible_on + dt data-t='models.plural.product'= Product.model_name.human_plural + dd= @product_category.products.map{|product| link_to product.display, suppliers_product_path(product) }.join(', ').html_safe + .form-actions - = link_to t("helpers.links.back"), suppliers_product_categories_path, class: 'btn' + = link_to t("helpers.links.back"), suppliers_product_categories_path, class: 'btn', data: {t: 'helpers.links.back'} ' - = link_to t('helpers.links.edit'), [:edit, :suppliers, @product_category], class: 'btn' + = link_to t('helpers.links.edit'), [:edit, :suppliers, @product_category], class: 'btn', data: {t: 'helpers.links.edit'} ' - = link_to t("helpers.links.destroy"), [:suppliers, @product_category], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' -- content_for :row do - - @products = ProductDecorator.decorate_collection(@product_category.products) - = render template: 'suppliers/products/index' + = link_to t("helpers.links.destroy"), [:suppliers, @product_category], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger', data: {t: 'helpers.links.destroy'} diff --git a/app/views/suppliers/products/index.html.slim b/app/views/suppliers/products/index.html.slim index d28849a9..0d3a861b 100644 --- a/app/views/suppliers/products/index.html.slim +++ b/app/views/suppliers/products/index.html.slim @@ -1,29 +1,64 @@ - model_class = Product .page-header= title :index, model_class -.well - - if @products.any? - table.table - thead - tr - th data-t="attributes.product.name" = model_class.human_attribute_name(:name) - th data-t="attributes.product.code" = model_class.human_attribute_name(:code) - th.currency data-t="attributes.product.price" = model_class.human_attribute_name(:price) - th data-t="models.product_category" = ProductCategory.model_name.human_plural - th.timestamp data-t="attributes.product.created_at" = model_class.human_attribute_name(:created_at) - th.actions data-t="helpers.actions.title" =t 'helpers.actions.title' - tbody - - @products.each do |product| +.span7 + .well + - if @products.any? + table.table + thead tr - td.link= link_to product.name, [:suppliers, product] - td= product.code - td.currency=currency product.price - td.link= product.category_links namespace: :suppliers - td.timestamp=l product.created_at, format: :short - td.actions - = link_to t('helpers.links.edit'), [:edit, :suppliers, product], class: 'btn btn-mini' - ' - = link_to t("helpers.links.destroy"), [:suppliers, product], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' - - else - = no_content_given model_class -= link_to t("helpers.links.new"), new_suppliers_product_path(product_category_id: @product_category.try(:id)), class: 'btn btn-primary' -/a.btn.btn-primary data-t="helpers.links.new" href=new_suppliers_product_path + th data-t="attributes.product.name" = model_class.human_attribute_name(:name) + th data-t="attributes.product.code" = model_class.human_attribute_name(:code) + th.currency data-t="attributes.product.price" = model_class.human_attribute_name(:price) + th data-t="models.plural.product_category" = ProductCategory.model_name.human_plural + th.timestamp data-t="attributes.product.created_at" = model_class.human_attribute_name(:created_at) + th.actions data-t="helpers.actions.title" =t 'helpers.actions.title' + tbody + - @products.each do |product| + tr + td.link= link_to product.name, [:suppliers, product] + td= product.code + td.currency=currency product.price + td.link= product.category_links namespace: :suppliers + td.timestamp data-time=product.created_at.utc.iso8601 + td.actions + = link_to t('helpers.links.edit'), [:edit, :suppliers, product], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), [:suppliers, product], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' + - else + = no_content_given model_class + = link_to t("helpers.links.new"), new_suppliers_product_path(product_category_id: @product_category.try(:id)), class: 'btn btn-primary', data: {t: 'product.new'} + /a.btn.btn-primary data-t="helpers.links.new" href=new_suppliers_product_path +.span4 + h4 data-t='product.preview.header'= t('supplier.product.preview.header') + input#product_preview_date.datepicker type="text" value=Date.today.strftime('%Y-%m-%d') + p data-t='product.preview.description'= t('supplier.product.preview.description') + .well + table#products-table + tbody +script#products-category-template[type="text/html"]= mustache_template 'user/products_category' +- onload_javascript do + javascript: + function update_preview_products(){ + var date = $('#product_preview_date').val(); + var body = $('#products-table tbody'); + body.html('"#{spinner}"'); + if(!date) return; + $.get('#{preview_products_suppliers_products_path(format: :json)}', {date: date}, function(res){ + var i,j, category, obj, result_html; + body.find('tr').remove(); + for(i=0; i < res.categories.length; i++){ + category = res.categories[i]; + obj = { + category: category.name, + products: category.products, + include_order_buttons: false + } + result_html = Mustache.to_html($('#products-category-template').html(), obj) + body.append(result_html) + } + }) + } + update_preview_products(); + $('#product_preview_date').change(function(){ + update_preview_products(); + }) diff --git a/app/views/suppliers/sections/_form.html.slim b/app/views/suppliers/sections/_form.html.slim index f87b8bd5..d1ac2b3f 100644 --- a/app/views/suppliers/sections/_form.html.slim +++ b/app/views/suppliers/sections/_form.html.slim @@ -15,4 +15,6 @@ .form-actions = f.submit nil, class: 'btn btn-primary' ' + = link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: @section.id), class: 'btn btn-info', data: {t: 'tables.qr_codes.link'} + ' = link_to t("helpers.links.cancel"), suppliers_sections_path, class: 'btn' diff --git a/app/views/suppliers/sections/index.html.slim b/app/views/suppliers/sections/index.html.slim index 35963be4..e0cc17de 100644 --- a/app/views/suppliers/sections/index.html.slim +++ b/app/views/suppliers/sections/index.html.slim @@ -14,7 +14,7 @@ tbody - @sections.each do |section| tr - td.link= link_to section.title, [:suppliers, section] + td.link= link_to section.title, [:tables_view, :suppliers, section] td.table-info span.table-count= section.tables.size span.active-table-count= (@active_table_ids & section.tables.map(&:id)).size diff --git a/app/views/suppliers/sections/manage_tables.html.slim b/app/views/suppliers/sections/manage_tables.html.slim index 3eaa2702..a31b965b 100644 --- a/app/views/suppliers/sections/manage_tables.html.slim +++ b/app/views/suppliers/sections/manage_tables.html.slim @@ -13,7 +13,7 @@ = link_to :i, [:suppliers, table], class: 'btn btn-mini table-link' .table-number = table.number .span3 - h3= t('table.has_no_section') + h3 data-t='tables.has_no_section' = t('supplier.tables.has_no_section') .well.section-tables-container.section-tables-inactive - for table in @section.supplier.non_placed_tables .section-table{ id="section-table-#{table.id}" data-position-x=table.position_x data-position-y=table.position_y data-table-id=table.id} @@ -33,6 +33,8 @@ ' a.btn href='#arrange-tables-modal' role='button' data-toggle='modal' data-t='section.arrange_tables.button_label' = t('supplier.section.arrange_tables.button_label') ' + = link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: @section.id), class: 'btn btn-info', data: {t: 'tables.qr_codes.link'} + ' = link_to t("helpers.links.destroy"), [:suppliers, @section], method: :delete, data: {confirm: are_you_sure?, t: 'helpers.links.destroy' }, class: 'btn btn-danger' - content_for :footer do javascript: @@ -50,16 +52,16 @@ #add-tables-modal.modal.hide.fade tabindex=-1 role=:dialog aria-labeledby='add-tables-modal-label' aria-hidden=true .modal-header button.close type=:button data-dismiss=:modal aria-hidden=true x - h3#add-tables-modal-label= t('supplier.section.add_tables.modal.title') + h3#add-tables-modal-label data-t='section.add_tables.modal.title' = t('supplier.section.add_tables.modal.title') .modal-body - p= t('supplier.section.add_tables.modal.body_header') + p data-t='section.add_tables.modal.body_header' = t('supplier.section.add_tables.modal.body_header') form.form-horizontal .control-group - label.control-label for='add-tables-number-start' = t('supplier.section.add_tables.modal.number_start') + label.control-label for='add-tables-number-start' data-t='section.add_tables.modal.number_start' = t('supplier.section.add_tables.modal.number_start') .controls input.input-mini#add-tables-number-start type=:number value=100 .control-group - label.control-label for='add-tables-number-end' = t('supplier.section.add_tables.modal.number_end') + label.control-label for='add-tables-number-end' data-t='section.add_tables.modal.number_end' = t('supplier.section.add_tables.modal.number_end') .controls input.input-mini#add-tables-number-end type=:number value=120 .modal-footer @@ -67,26 +69,30 @@ button.btn.btn-primary onclick="Qsupplier.add_tables_to_active_section()" data-t='section.add_tables.modal.add_button' #arrange-tables-modal.modal.hide.fade tabindex=-1 role=:dialog aria-labeledby='add-tables-modal-label' aria-hidden=true button.close type=:button data-dismiss=:modal aria-hidden=true x - h3#arrange-tables-modal-label= t('supplier.section.arrange_tables.modal.title') + h3#arrange-tables-modal-label data-t='section.arrange_tables.modal.title' = t('supplier.section.arrange_tables.modal.title') .modal-body - p= t('supplier.section.arrange_tables.modal.body_header') + p data-t='section.arrange_tables.modal.body_header' = t('supplier.section.arrange_tables.modal.body_header') form.form-horizontal .control-group - label.control-label for='arrange-tables-distributed' = t('supplier.section.arrange_tables.modal.distributed') + label.control-label for='arrange-tables-distributed' data-t='section.arrange_tables.modal.distributed' = t('supplier.section.arrange_tables.modal.distributed') .controls input#arrange-tables-distributed type="radio" name="arrange-table-option" checked=true value="distributed" .control-group - label.control-label for='arrange-tables-by_row' = t('supplier.section.arrange_tables.modal.by_row') + label.control-label for='arrange-tables-by_row' data-t='section.arrange_tables.modal.by_row' = t('supplier.section.arrange_tables.modal.by_row') .controls input#arrange-tables-by_row type="radio" name="arrange-table-option" value="by_row" - label for="arrange-tables-by-row-count"= t('supplier.section.arrange_tables.modal.by_row_count') + label for="arrange-tables-by-row-count" data-t='section.arrange_tables.modal.by_row_count' = t('supplier.section.arrange_tables.modal.by_row_count') input.input-mini#arrange-tables-by-row-count type="text" value=0 + ' + span data-t='models.plural.table' .control-group - label.control-label for='arrange-tables-by_column' = t('supplier.section.arrange_tables.modal.by_column') + label.control-label for='arrange-tables-by_column' data-t='section.arrange_tables.modal.by_column' = t('supplier.section.arrange_tables.modal.by_column') .controls input#arrange-tables-by_column type="radio" name="arrange-table-option" value="by_column" - label for="arrange-tables-by-column-count"= t('supplier.section.arrange_tables.modal.by_column_count') + label for="arrange-tables-by-column-count" data-t='section.arrange_tables.modal.by_column_count' = t('supplier.section.arrange_tables.modal.by_column_count') input.input-mini#arrange-tables-by-column-count type="text" value=0 + ' + span data-t='models.plural.table' .modal-footer button.btn data-dismiss="modal" aria-hidden=true data-t='section.arrange_tables.modal.close_button' button.btn.btn-primary onclick="Qsupplier.arrange_tables_of_active_section()" data-t='section.arrange_tables.modal.arrange_button' diff --git a/app/views/suppliers/sections/show.html.slim b/app/views/suppliers/sections/show.html.slim index da279844..469bc795 100644 --- a/app/views/suppliers/sections/show.html.slim +++ b/app/views/suppliers/sections/show.html.slim @@ -19,4 +19,6 @@ dl.dl-horizontal.show-list ' = link_to t('supplier.section.tables_view.link'), [:tables_view, :suppliers, @section], class: 'btn btn-info', data: {t: 'section.tables_view.link'} ' + = link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path(section_id: @section.id), class: 'btn btn-info', data: {t: 'tables.qr_codes.link'} + ' = link_to t("helpers.links.destroy"), [:suppliers, @section], method: :delete, data: {confirm: are_you_sure?, t: 'helpers.links.destroy'}, class: 'btn btn-danger' diff --git a/app/views/suppliers/sections/tables_view.html.slim b/app/views/suppliers/sections/tables_view.html.slim index 1defc10a..6e7970ad 100644 --- a/app/views/suppliers/sections/tables_view.html.slim +++ b/app/views/suppliers/sections/tables_view.html.slim @@ -7,6 +7,10 @@ - for table in @section.tables .section-table.hide{ id="section-table-#{table.id}" data-position-x=table.position_x data-position-y=table.position_y data-table-id=table.id} .table-number = link_to table.number, suppliers_table_path(table) + .status-icons + span.needs_payment.icon-flag + span.needs_help.icon-bell + span.active_order.icon-glass - content_for :footer do javascript: var current_section_id = '#{@section.id}'; diff --git a/app/views/suppliers/tables/_form.html.slim b/app/views/suppliers/tables/_form.html.slim index f68b6ac2..8bd0caf6 100644 --- a/app/views/suppliers/tables/_form.html.slim +++ b/app/views/suppliers/tables/_form.html.slim @@ -1,13 +1,13 @@ = form_for [:suppliers, @table], html: {class: 'form-horizontal' } do |f| = render 'error_messages', target: @table .control-group class=(@table.errors[:number].any? ? 'error' : nil) - = f.label :number, class: 'control-label' + = f.label :number, class: 'control-label', data: {t: 'attributes.table.number'} .controls = f.text_field :number, class: 'text_field' .control-group class=(@table.errors[:section_id].any? ? 'error' : nil) - = f.label :section_id, Supplier.model_name.human, class: 'control-label' + = f.label :section_id, Section.model_name.human, class: 'control-label', data: {t: 'models.section'} .controls - = f.collection_select :section_id, current_supplier.sections, :id, :title, include_blank: "[#{t('table.has_no_section')}]" + = f.collection_select :section_id, current_supplier.sections, :id, :title, include_blank: "[#{t('supplier.tables.has_no_section')}]" .form-actions = f.submit nil, class: 'btn btn-primary' ' diff --git a/app/views/suppliers/tables/index.html.slim b/app/views/suppliers/tables/index.html.slim index defd124d..16485d4e 100644 --- a/app/views/suppliers/tables/index.html.slim +++ b/app/views/suppliers/tables/index.html.slim @@ -24,13 +24,13 @@ div.page-header= title :index, model_class td.link= link_to_if table.section.present?, table.section.try(:title), [:suppliers, table.section] td.timestamp data-time=table.created_at.utc.iso8601 td.actions - = link_to t('helpers.links.edit'), [:edit, :suppliers, table], class: 'btn btn-mini' + = link_to t('helpers.links.edit'), [:edit, :suppliers, table], class: 'btn btn-mini', data: {t: 'helpers.links.edit'} ' - = link_to t("helpers.links.destroy"), [:suppliers, table], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' + = link_to t("helpers.links.destroy"), [:suppliers, table], method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger', data: {t: 'helpers.links.destroy'} - else = no_content_given model_class .form-actions - = link_to t("helpers.links.new"), new_suppliers_table_path, class: 'btn btn-primary' + = link_to t("helpers.links.new"), new_suppliers_table_path, class: 'btn btn-primary', data: {t: 'helpers.links.new'} ' - = link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path, class: 'btn btn-info' + = link_to t('supplier.tables.qr_codes.link'), qr_codes_suppliers_tables_path, class: 'btn btn-info', data: {t: 'tables.qr_codes.link'} diff --git a/config/locales/en.yml b/config/locales/en.yml index e32aeb13..67f16053 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -66,7 +66,6 @@ en: successfull: '%{model} is successfully destroyed' table: is_occupied: This table is occupied - has_no_section: "Not placed" general: boolean: boolean_yes: "Yes" diff --git a/config/locales/models.en.yml b/config/locales/models.en.yml index 956b63b0..2c66c36f 100644 --- a/config/locales/models.en.yml +++ b/config/locales/models.en.yml @@ -26,6 +26,7 @@ en: full_day: Whole day start_from: From end_on: Till + visible_on: Active on product: name: Name code: Code @@ -37,14 +38,22 @@ en: needs_help: Needs attention needs_payment: Wants to pay closed_at: Closed at + section: + title: Title + width: Width + height: Length + created_at: Created supplier: name: Name email: 'Email' password: 'Password' password_confirmation: 'Confirmation' + location: Location + time_zone: Time zone iens_profile: Iens profile id table: number: Number from_number: From number to_number: To number created_at: Created + diff --git a/config/locales/models.nl.yml b/config/locales/models.nl.yml index 9b67e815..15ce8323 100644 --- a/config/locales/models.nl.yml +++ b/config/locales/models.nl.yml @@ -26,6 +26,7 @@ nl: full_day: De hele dag start_from: Van end_on: Tot + visible_on: Actief op product: name: Naam code: Code @@ -42,11 +43,14 @@ nl: title: Titel width: Breedte height: Lengte + created_at: Aangemaakt supplier: name: Naam email: 'E-mail' password: 'Wachtwoord' password_confirmation: 'Bevestiging' + location: 'Locatie' + time_zone: Tijdzone iens_profile: Iens profiel id table: number: Nummer diff --git a/config/locales/nl.yml b/config/locales/nl.yml index cb627cd6..5c52b950 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -65,7 +65,6 @@ nl: successfull: '%{model} is succesvol verwijderd' table: is_occupied: Deze tafel is bezet - has_no_section: "Niet geplaatst" general: boolean: boolean_yes: "Ja" diff --git a/config/locales/supplier.en.yml b/config/locales/supplier.en.yml index 422fbe15..39513bbf 100644 --- a/config/locales/supplier.en.yml +++ b/config/locales/supplier.en.yml @@ -19,8 +19,11 @@ en: table_number: Table tables: qr_codes: - link: Qr codes sheet + link: Print Qr codes sheet + has_no_section: "Not placed" lists: + index: + show_all: Show all ${models.plural.list} show: title: Show %{list} section: @@ -69,3 +72,8 @@ en: thursday: T friday: F saturday: S + product: + new: 'New ${model.product|downcase}' + preview: + header: 'Select moment to preview products' + description: 'Products visible to customers at chosen moment:' diff --git a/config/locales/supplier.nl.yml b/config/locales/supplier.nl.yml index 4ff4c10e..249f2ef5 100644 --- a/config/locales/supplier.nl.yml +++ b/config/locales/supplier.nl.yml @@ -19,8 +19,11 @@ nl: table_number: Tafel tables: qr_codes: - link: Qr codes + link: Print Qr codes + has_no_section: "Niet geplaatst" lists: + index: + show_all: Toon alle ${models.plural.list} show: title: "%{list} tonen" section: @@ -69,3 +72,8 @@ nl: thursday: D friday: V saturday: Z + product: + new: 'Nieuw ${model.product|downcase}' + preview: + header: 'Selecteer tijdstip voor voorbeeld' + description: 'Producten op gekozen tijdstip:' diff --git a/config/routes.rb b/config/routes.rb index cd161b2a..05f2997d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -87,7 +87,11 @@ Qwaiter::Application.routes.draw do get :qr_codes end end - resources :products + resources :products do + collection do + get :preview_products + end + end resources :lists resources :product_categories do collection do diff --git a/spec/decorators/product_category_decorator_spec.rb b/spec/decorators/product_category_decorator_spec.rb new file mode 100644 index 00000000..93de1a75 --- /dev/null +++ b/spec/decorators/product_category_decorator_spec.rb @@ -0,0 +1,64 @@ +require 'spec_helper' + +describe ProductCategoryDecorator do + let(:supplier) { build :supplier } + let(:product_category){ build :product_category, supplier: supplier } + let(:day_names) { %w[sunday monday tuesday wednesday thursday friday saturday]} + subject { ActiveDecorator::Decorator.instance.decorate product_category } + + describe '#visible_on' do + before do + ActiveDecorator::ViewContext.current = Suppliers::ApplicationController.new.view_context + product_category.stub(:week_days).and_return([1,1,0,0,0,1,0]) + I18n.stub(:t).with('date.day_names').and_return(day_names) + end + its(:visible_on) { should include 'sunday' } + its(:visible_on) { should include 'monday' } + its(:visible_on) { should_not include 'tuesday' } + its(:visible_on) { should_not include 'wednesday' } + its(:visible_on) { should_not include 'thursday' } + its(:visible_on) { should include 'friday' } + its(:visible_on) { should_not include 'saturday' } + its(:visible_on) { should start_with 'monday'} + + it "starts with sunday if week does not start on monday" do + supplier.stub(:week_starts_on_monday?).and_return(false) + subject.visible_on.should start_with 'sunday' + end + + it "includes the time when full day is false" do + product_category.full_day = false + product_category.start_from = 800 + product_category.end_on = 900 + subject.visible_on.should include '13:20 - 15:00' + end + + it "shows a dash when it is never visible" do + product_category.stub(:week_days).and_return([0,0,0,0,0,0,0]) + subject.visible_on.should include 'icon-eye-close' + end + + it "should display an icon when always visible" do + product_category.stub(:week_days).and_return([1,1,1,1,1,1,1]) + subject.visible_on.should include 'icon-refresh' + end + + it "should only display time when all days active and time range given" do + product_category.stub(:week_days).and_return([1,1,1,1,1,1,1]) + product_category.full_day = false + product_category.start_from = 800 + product_category.end_on = 900 + subject.visible_on.should == '13:20 - 15:00' + end + end + + describe '#products' do + it "decorates products" do + product = build :product + product_category.instance_variable_set('@products', all: [product]) + subject.products.first.should be_a ProductDecorator + end + end + + +end diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb new file mode 100644 index 00000000..724cc71b --- /dev/null +++ b/spec/i18n_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe I18n do + describe 'translate' do + describe 'day_names' do + it "returns english day names" do + I18n.locale = :en + I18n.t('date.day_names').first.should == 'Sunday' + end + it "returns dutch day names" do + I18n.locale = :nl + I18n.t('date.day_names').first.should == 'zondag' + end + end + + end +end diff --git a/vendor/assets/javascripts/jquery.ui.datepicker-en.js b/vendor/assets/javascripts/jquery.ui.datepicker-en.js new file mode 100644 index 00000000..0ff62096 --- /dev/null +++ b/vendor/assets/javascripts/jquery.ui.datepicker-en.js @@ -0,0 +1,16 @@ + $.datepicker.regional.en = { + closeText: "Done", // Display text for close link + prevText: "Prev", // Display text for previous month link + nextText: "Next", // Display text for next month link + currentText: "Today", // Display text for current month link + monthNames: ["January","February","March","April","May","June", + "July","August","September","October","November","December"], // Names of months for drop-down and formatting + monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting + dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting + dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting + dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday + weekHeader: "Wk", // Column header for week of the year + isRTL: false, // True if right-to-left language, false if left-to-right + showMonthAfterYear: false, // True if the year select precedes month, false for month then year + yearSuffix: "" // Additional text to append to the year in the month headers + } diff --git a/vendor/assets/javascripts/jquery.ui.datepicker-nl.js b/vendor/assets/javascripts/jquery.ui.datepicker-nl.js new file mode 100644 index 00000000..a2a66415 --- /dev/null +++ b/vendor/assets/javascripts/jquery.ui.datepicker-nl.js @@ -0,0 +1,18 @@ +/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */ +/* Written by Mathias Bynens */ + $.datepicker.regional.nl = { + closeText: 'Sluiten', + prevText: '←', + nextText: '→', + currentText: 'Vandaag', + monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', + 'juli', 'augustus', 'september', 'oktober', 'november', 'december'], + monthNamesShort: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', + 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'], + dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'], + dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'], + dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'], + weekHeader: 'Wk', + isRTL: false, + showMonthAfterYear: false, + yearSuffix: ''};