78 lines
3.6 KiB
Plaintext
78 lines
3.6 KiB
Plaintext
- model_class = Product
|
|
.page-header= title :index, model_class
|
|
.span7
|
|
.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.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 class="product-row-#{product.id}"
|
|
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 edit-resource-button'
|
|
'
|
|
= 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')
|
|
.products_preview-time-container
|
|
.products_preview-date= text_field_tag :date, Date.today.iso8601, class: 'datepicker'
|
|
.products_preview-hour= select_tag :preview_hour, options_for_select(0..23)
|
|
.products_preview-minute= select_tag :preview_minute, options_for_select(1..60)
|
|
.clear
|
|
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:
|
|
var now = new Date();
|
|
//var hour = now.getHours();
|
|
//var minute = now.getMinutes();
|
|
$('.products_preview-hour select').val(now.getHours());
|
|
$('.products_preview-minute select').val(now.getMinutes());
|
|
|
|
function update_preview_products(){
|
|
var date = $('.products_preview-date input').val();
|
|
var body = $('#products-table tbody');
|
|
var hour = $('.products_preview-hour select').val()
|
|
var minute = $('.products_preview-minute select').val()
|
|
|
|
body.html('<tr><td>#{spinner}</td></tr>');
|
|
if(!date) return;
|
|
$.get('#{preview_products_suppliers_products_path(format: :json)}', {date: date, hour: hour, minute: minute}, 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 = Handlebars.compile($('#products-category-template').html())(obj)
|
|
body.append(result_html)
|
|
}
|
|
})
|
|
}
|
|
update_preview_products();
|
|
$('.products_preview-date input,.products_preview-hour select,.products_preview-minute select').change(function(){
|
|
update_preview_products();
|
|
})
|