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 @@
+
+
\ 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!(/^