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
+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'}