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 00000000..5c576a5a Binary files /dev/null and b/app/assets/images/icons/maps_location.png differ diff --git a/app/assets/images/supplier/settings/location-balloon.png b/app/assets/images/supplier/settings/location-balloon.png new file mode 100644 index 00000000..81f2f6f8 Binary files /dev/null and b/app/assets/images/supplier/settings/location-balloon.png differ 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: ''};