supplier improvements

This commit is contained in:
2013-03-09 14:18:21 +01:00
parent 730f910881
commit cc13797f5a
53 changed files with 819 additions and 156 deletions
+1 -2
View File
@@ -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
+2 -13
View File
@@ -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
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:ooo="http://xml.openoffice.org/svg/export"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.2"
width="210mm"
height="297mm"
viewBox="0 0 21000 29700"
preserveAspectRatio="xMidYMid"
fill-rule="evenodd"
clip-path="url(#presentation_clip_path)"
stroke-width="28.222"
stroke-linejoin="round"
xml:space="preserve"
id="svg2"
inkscape:version="0.48.2 r9819"
sodipodi:docname="location-balloon.svg"><metadata
id="metadata89"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1432"
inkscape:window-height="771"
id="namedview87"
showgrid="false"
inkscape:zoom="1.4941487"
inkscape:cx="273.18572"
inkscape:cy="568.54313"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="g49" />
<defs
class="ClipPathGroup"
id="defs4">
<clipPath
id="presentation_clip_path"
clipPathUnits="userSpaceOnUse">
<rect
x="0"
y="0"
width="21000"
height="29700"
id="rect7" />
</clipPath>
</defs>
<defs
class="TextShapeIndex"
id="defs9">
<g
ooo:slide="id1"
ooo:id-list="id3"
id="g11" />
</defs>
<defs
class="EmbeddedBulletChars"
id="defs13">
<g
id="bullet-char-template(57356)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M 580,1141 L 1163,571 580,0 -4,571 580,1141 Z"
id="path16" />
</g>
<g
id="bullet-char-template(57354)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M 8,1128 L 1137,1128 1137,0 8,0 8,1128 Z"
id="path19" />
</g>
<g
id="bullet-char-template(10146)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M 174,0 L 602,739 174,1481 1456,739 174,0 Z M 1358,739 L 309,1346 659,739 1358,739 Z"
id="path22" />
</g>
<g
id="bullet-char-template(10132)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M 2015,739 L 1276,0 717,0 1260,543 174,543 174,936 1260,936 717,1481 1274,1481 2015,739 Z"
id="path25" />
</g>
<g
id="bullet-char-template(10007)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M 0,-2 C -7,14 -16,27 -25,37 L 356,567 C 262,823 215,952 215,954 215,979 228,992 255,992 264,992 276,990 289,987 310,991 331,999 354,1012 L 381,999 492,748 772,1049 836,1024 860,1049 C 881,1039 901,1025 922,1006 886,937 835,863 770,784 769,783 710,716 594,584 L 774,223 C 774,196 753,168 711,139 L 727,119 C 717,90 699,76 672,76 641,76 570,178 457,381 L 164,-76 C 142,-110 111,-127 72,-127 30,-127 9,-110 8,-76 1,-67 -2,-52 -2,-32 -2,-23 -1,-13 0,-2 Z"
id="path28" />
</g>
<g
id="bullet-char-template(10004)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M 285,-33 C 182,-33 111,30 74,156 52,228 41,333 41,471 41,549 55,616 82,672 116,743 169,778 240,778 293,778 328,747 346,684 L 369,508 C 377,444 397,411 428,410 L 1163,1116 C 1174,1127 1196,1133 1229,1133 1271,1133 1292,1118 1292,1087 L 1292,965 C 1292,929 1282,901 1262,881 L 442,47 C 390,-6 338,-33 285,-33 Z"
id="path31" />
</g>
<g
id="bullet-char-template(9679)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M 813,0 C 632,0 489,54 383,161 276,268 223,411 223,592 223,773 276,916 383,1023 489,1130 632,1184 813,1184 992,1184 1136,1130 1245,1023 1353,916 1407,772 1407,592 1407,412 1353,268 1245,161 1136,54 992,0 813,0 Z"
id="path34" />
</g>
<g
id="bullet-char-template(8226)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M 346,457 C 273,457 209,483 155,535 101,586 74,649 74,723 74,796 101,859 155,911 209,963 273,989 346,989 419,989 480,963 531,910 582,859 608,796 608,723 608,648 583,586 532,535 482,483 420,457 346,457 Z"
id="path37" />
</g>
<g
id="bullet-char-template(8211)"
transform="scale(0.00048828125,-0.00048828125)">
<path
d="M -4,459 L 1135,459 1135,606 -4,606 -4,459 Z"
id="path40" />
</g>
</defs>
<defs
class="TextEmbeddedBitmaps"
id="defs42" />
<g
id="g44">
<g
id="id2"
class="Master_Slide">
<g
id="bg-id2"
class="Background" />
<g
id="bo-id2"
class="BackgroundObjects" />
</g>
</g>
<g
class="SlideGroup"
id="g49">
<path
style="fill:#ffffff;stroke:none"
inkscape:connector-curvature="0"
id="path59"
d="m 7388.007,10723.32 c -814,0 -1628,415 -1628,831 l 0,622 0,623 0,848 0,623 0,622 c 0,416 814,832 1628,832 l -3736.9999,1936 6179,-1936 1659.9999,0 1221,0 1221,0 c 814,0 1629,-416 1629,-832 l 0,-622 0,-623 0,-848 0,-623 0,-622 c 0,-416 -815,-831 -1629,-831 l -1221,0 -1221,0 -1659.9999,0 -1221,0 -1221.0001,0 z m -1628,0 0,0 z m 9801,5001 0,0 z" /><path
style="fill:none;stroke:#faa732;stroke-width:64.91110992;stroke-miterlimit:4;stroke-dasharray:none"
inkscape:connector-curvature="0"
id="path61"
d="m 7388.007,10723.32 c -814,0 -1628,415 -1628,831 l 0,622 0,623 0,848 0,623 0,622 c 0,416 814,832 1628,832 0,0 -257.6153,652.507 -500.6945,891.35 -675.1155,663.349 -2499.654,1346.866 -2499.654,1346.866 0,0 1937.451,-380.518 2845.1246,-752.656 922.8078,-378.343 2597.224,-1485.56 2597.224,-1485.56 l 1659.9999,0 1221,0 1221,0 c 814,0 1629,-416 1629,-832 l 0,-622 0,-623 0,-848 0,-623 0,-622 c 0,-416 -815,-831 -1629,-831 l -1221,0 -1221,0 -1659.9999,0 -1221,0 z"
sodipodi:nodetypes="ssccccscacacccssccccssccccs" /><text
id="text63"
class="TextShape"
x="-339.99295"
y="623.32043"><tspan
style="font-size:1128px;font-weight:400;font-family:'Arial, sans-serif'"
id="tspan65"
font-weight="400"
font-size="1128px"
class="TextParagraph"><tspan
id="tspan67"
y="12358.32"
x="6772.0068"
class="TextPosition"><tspan
style="fill:#000000;stroke:none"
id="tspan69">Klik op de kaart</tspan></tspan></tspan><tspan
style="font-size:1128px;font-weight:400;font-family:'Arial, sans-serif'"
id="tspan71"
font-weight="400"
font-size="1128px"
class="TextParagraph"><tspan
id="tspan73"
y="13615.32"
x="7338.0068"
class="TextPosition"><tspan
style="fill:#000000;stroke:none"
id="tspan75"> </tspan><tspan
style="fill:#000000;stroke:none"
id="tspan77">om je locatie</tspan></tspan></tspan><tspan
style="font-size:1128px;font-weight:400;font-family:'Arial, sans-serif'"
id="tspan79"
font-weight="400"
font-size="1128px"
class="TextParagraph"><tspan
id="tspan81"
y="14872.32"
x="7242.0068"
class="TextPosition"><tspan
style="fill:#000000;stroke:none"
id="tspan83"> </tspan><tspan
style="fill:#000000;stroke:none"
id="tspan85">aan te geven</tspan></tspan></tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.3 KiB

+2 -12
View File
@@ -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();
});
@@ -1,13 +1,8 @@
$( ->
week_days_container = $('#week_days-group')
$('.week-day-select').each( (i)->
select = $(this)
toggle = $('<button type="button" class="btn"></button>')
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 = $('<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 = $('<input type="text">')
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('<div><strong>' + place.name + '</strong><br>' + address + '</div>')
infowindow.open(map, search_marker)
)
)
)
@@ -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()
@@ -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])
}
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+4 -6
View File
@@ -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
+5
View File
@@ -0,0 +1,5 @@
module SupplierDecorator
def products
ActiveDecorator::Decorator.instance.decorate super
end
end
+19 -2
View File
@@ -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!(/^<script[^>]+>/,'') if script
script.sub!(/<\/script>$/, '') if script
script.present? ? (@onload_javascripts ||= []) << script : (@onload_javascripts || []).join(';').html_safe
end
def mustache_template(template)
+9 -2
View File
@@ -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
+14 -7
View File
@@ -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?
+4
View File
@@ -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
+13
View File
@@ -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? -%>
<li>
<%= link_to raw(t 'views.pagination.first'), url, {:remote => remote, data: {t: 'pagination.first'}} %>
</li>
<% end -%>
+8
View File
@@ -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
-%>
<li class="page gap disabled"><a href="javascript:void(0)"><%= raw(t 'views.pagination.truncate') %></a></li>
+13
View File
@@ -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? -%>
<li>
<%= link_to raw(t 'views.pagination.last'), url, {:remote => remote, data: {t: 'pagination.last'}} %>
</li>
<% end -%>
+14
View File
@@ -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? -%>
<li>
<%= link_to raw(t 'views.pagination.next'), url, :remote => remote, :rel => 'next', data: {t: 'pagination.next'} %>
</li>
<% end -%>
+12
View File
@@ -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
-%>
<li class="page<%= ' active' if page.current? %>">
<%= link_to page, (page.current? ? 'javascript:void(0)' : url), opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
</li>
+27
View File
@@ -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 -%>
<nav class="pagination">
<% if total_pages > 0 -%>
<ul>
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</ul>
<% end -%>
</nav>
<% end -%>
+13
View File
@@ -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? -%>
<li>
<%= link_to raw(t 'views.pagination.previous'), url, :remote => remote, :rel => 'prev', data: {t: 'pagination.previous'} %>
</li>
<% end -%>
+8 -5
View File
@@ -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}});
+5 -4
View File
@@ -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)
+20 -22
View File
@@ -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()}
@@ -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
@@ -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'
'
@@ -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'}
+61 -26
View File
@@ -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('<tr><td>"#{spinner}"</td></tr>');
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();
})
@@ -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'
+1 -1
View File
@@ -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
@@ -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'
@@ -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'
@@ -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}';
+3 -3
View File
@@ -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'
'
+4 -4
View File
@@ -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'}
-1
View File
@@ -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"
+9
View File
@@ -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
+4
View File
@@ -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
-1
View File
@@ -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"
+9 -1
View File
@@ -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:'
+9 -1
View File
@@ -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:'
+5 -1
View File
@@ -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
@@ -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
+17
View File
@@ -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
+16
View File
@@ -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
}
+18
View File
@@ -0,0 +1,18 @@
/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Mathias Bynens <http://mathiasbynens.be/> */
$.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: ''};