Merge branch 'master' into i18n

Conflicts:
	app/assets/javascripts/application.js
This commit is contained in:
wvengen 2013-10-18 12:30:34 +02:00
commit 98e7189d31
24 changed files with 223 additions and 248 deletions

View file

@ -1,5 +1,4 @@
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require select2
//= require twitter/bootstrap
@ -7,12 +6,14 @@
//= require bootstrap-datepicker/core
//= require bootstrap-datepicker/locales/bootstrap-datepicker.de
//= require bootstrap-datepicker/locales/bootstrap-datepicker.nl
//= require bootstrap-datepicker/locales/bootstrap-datepicker.fr
//= require jquery.observe_field
//= require list
//= require list.unlist
//= require list.delay
//= require list.reset
//= require rails.validations
//= require rails.validations.simple_form
//= require i18n
//= require i18n/translations
//= require_self
@ -36,19 +37,19 @@ $.fn.extend({
$(function() {
// Show/Hide a specific DOM element
$('a[data-toggle-this]').live('click', function() {
$(document).on('click', 'a[data-toggle-this]', function() {
$($(this).data('toggle-this')).toggle();
return false;
});
// Remove this item from DOM
$('a[data-remove-this]').live('click', function() {
$(document).on('click', 'a[data-remove-this]', function() {
$($(this).data('remove-this')).remove();
return false;
});
// Check/Uncheck a single checkbox
$('[data-check-this]').live('click', function() {
$(document).on('click', '[data-check-this]', function() {
var checkbox = $($(this).data('check-this'));
checkbox.attr('checked', !checkbox.is(':checked'));
highlightRow(checkbox);
@ -56,7 +57,7 @@ $(function() {
});
// Check/Uncheck all checkboxes for a specific form
$('input[data-check-all]').live('click', function() {
$(document).on('click', 'input[data-check-all]', function() {
var status = $(this).is(':checked');
var context = $(this).data('check-all');
var elms = $('input[type="checkbox"]', context);
@ -68,7 +69,7 @@ $(function() {
});
// Submit form when changing a select menu.
$('form[data-submit-onchange] select').live('change', function() {
$(document).on('change', 'form[data-submit-onchange] select', function() {
var confirmMessage = $(this).children(':selected').data('confirm');
if (confirmMessage) {
if (confirm(confirmMessage)) {
@ -101,7 +102,7 @@ $(function() {
});
// Remote paginations
$('div.pagination[data-remote] a').live('click', function() {
$(document).on('click', 'div.pagination[data-remote] a', function() {
$.getScript($(this).attr('href'));
return false;
});
@ -122,6 +123,20 @@ $(function() {
// Use bootstrap datepicker for dateinput
$('.datepicker').datepicker({format: 'yyyy-mm-dd', language: I18n.locale});
// bootstrap tooltips (for price)
// Extra options don't work when using selector, so override defaults
// https://github.com/twbs/bootstrap/issues/3875 . These can still be
// overridden per tooltip using data-placement attributes and the like.
$.extend($.fn.tooltip.defaults, {
html: true,
animation: false,
placement: 'left',
container: 'body'
});
$(document).tooltip({
selector: '[data-toggle~="tooltip"]',
});
// See stupidtable.js for initialization of local table sorting
});
@ -148,3 +163,5 @@ function highlightRow(checkbox) {
function setHiddenId(text, li) {
$('hidden_id').value = li.id;
}

View file

@ -1,4 +1,3 @@
jQuery ->
$("a[rel=popover]").popover()
$(".tooltip").tooltip()
$("a[rel=tooltip]").tooltip()
$("a[rel~=popover], .has-popover").popover()
$("a[rel~=tooltip], .has-tooltip").tooltip()

View file

@ -1,24 +1,23 @@
@import "twitter/bootstrap/bootstrap";
@import "twitter/bootstrap/responsive";
body {
padding-top: 10px;
}
@import "twitter/bootstrap/responsive";
// Set the correct sprite paths
@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
@iconSpritePath: image-url('twitter/bootstrap/glyphicons-halflings.png');
@iconWhiteSpritePath: image-url('twitter/bootstrap/glyphicons-halflings-white.png');
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not
// have the proper paths. So for now we use the absolute path.
@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot';
@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff';
@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf';
@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg';
@fontAwesomeEotPath: asset-url('fontawesome-webfont.eot');
@fontAwesomeEotPath_iefix: asset-url('fontawesome-webfont.eot?#iefix');
@fontAwesomeWoffPath: asset-url('fontawesome-webfont.woff');
@fontAwesomeTtfPath: asset-url('fontawesome-webfont.ttf');
@fontAwesomeSvgPath: asset-url('fontawesome-webfont.svg#fontawesomeregular');
@import 'fontawesome/font-awesome';
// Font Awesome
@import "fontawesome";
// Glyphicons
//@import "twitter/bootstrap/sprites.less";
// Your custom LESS stylesheets goes here
//
@ -26,7 +25,7 @@ body {
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/less.html for their names and documentation
// See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation
//
// Example:
// @linkColor: #ff0000;

View file

@ -98,6 +98,8 @@ class OrdersController < ApplicationController
order = Order.find(params[:id])
order.finish!(@current_user)
redirect_to order, notice: I18n.t('orders.finish.notice')
rescue => error
redirect_to orders_url, alert: I18n.t('errors.general_msg', :msg => error.message)
end
# Renders the fax-text-file

View file

@ -155,7 +155,7 @@ class Order < ActiveRecord::Base
unless finished?
Order.transaction do
# set new order state (needed by notify_order_finished)
update_attributes(:state => 'finished', :ends => Time.now, :updated_by => user)
update_attributes!(:state => 'finished', :ends => Time.now, :updated_by => user)
# Update order_articles. Save the current article_price to keep price consistency
# Also save results for each group_order_result

View file

@ -66,7 +66,7 @@ class Ordergroup < Group
end
def avg_jobs_per_euro
stats[:orders_sum] != 0 ? stats[:jobs_size].to_f / stats[:orders_sum].to_f : 0
stats[:jobs_size].to_f / stats[:orders_sum].to_f rescue 0
end
# This is the ordergroup job per euro performance
@ -90,7 +90,7 @@ class Ordergroup < Group
# Global average
def self.avg_jobs_per_euro
stats = Ordergroup.pluck(:stats)
stats.sum {|s| s[:jobs_size].to_f } / stats.sum {|s| s[:orders_sum].to_f }
stats.sum {|s| s[:jobs_size].to_f } / stats.sum {|s| s[:orders_sum].to_f } rescue 0
end
def account_updated

View file

@ -61,8 +61,6 @@
return true;
}
});
enablePriceTooltips();
});
function mark_article_for_delivery(stock_article_id) {
@ -80,14 +78,6 @@
return ( 0 == $('#stock_change_stock_article_' + stock_article_id).length );
}
function enablePriceTooltips(context) {
$('[data-toggle~="tooltip"]', context).tooltip({
animation: false,
html: true,
placement: 'left'
});
}
= simple_form_for [@supplier, @delivery], validate: true do |f|
= f.error_notification
= base_errors f.object

View file

@ -13,7 +13,6 @@
var stock_change = $(
'<%= j(render(:partial => 'stock_change', :locals => {:stock_change => @stock_change})) %>'
).addClass('success');
enablePriceTooltips(stock_change);
$('input.stock-change-quantity', stock_change).val(quantity);
$('#stock_changes').append(stock_change);

View file

@ -8,7 +8,6 @@ $('div.container-fluid').prepend(
var stock_article_for_adding = $(
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>'
).addClass('success');
enablePriceTooltips(stock_article_for_adding);
$('#stock_articles_for_adding tbody').append(stock_article_for_adding);
updateSort('#stock_articles_for_adding');

View file

@ -10,7 +10,6 @@ $('div.container-fluid').prepend(
var stock_article_for_adding = $(
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article, :delivery => @delivery})) %>'
).addClass('success');
enablePriceTooltips(stock_article_for_adding);
$('#stock_article_<%= @stock_article.id %>').replaceWith(stock_article_for_adding);
updateSort('#stock_articles_for_adding');

View file

@ -5,12 +5,12 @@
var ordergroup = "#{escape_javascript(render('ordergroup'))}"
$(function() {
$('a[data-remove-transaction]').live('click', function() {
$(document).on('click', 'a[data-remove-transaction]', function() {
$(this).parents('tr').remove();
return false;
});
$('a[data-add-transaction]').click(function() {
$(document).on('click', 'a[data-add-transaction]', function() {
$('#ordergroups').append(ordergroup);
return false;
});

View file

@ -2,7 +2,7 @@
%h2= t '.title'
- if ordergroup.not_enough_apples?
.alert
= t '.not_enough_apples'
= t '.not_enough_apples'
- unless Order.open.empty?
%table.table.table-striped
%thead

View file

@ -1,20 +1,5 @@
- title t('.title')
- content_for :javascript do
:javascript
$(function() {
enablePriceTooltips();
});
function enablePriceTooltips(context) {
$('[data-toggle~="tooltip"]', context).tooltip({
animation: false,
html: true,
placement: 'left',
container: 'body'
});
}
- content_for :sidebar do
%p
%i= t('.text_deviations', inv_link: link_to(t('.temp_inventory'), stock_articles_path)).html_safe

View file

@ -1,7 +1,7 @@
= simple_form_for @supplier do |f|
- if @supplier.shared_supplier
.alert.alert-success
= t 'suppliers.shared_supplier_note'
.alert.alert-info
= t 'suppliers.shared_supplier_note'
= f.hidden_field :shared_supplier_id
= f.input :name
= f.input :address

View file

@ -4,7 +4,7 @@
.span6
- if shared_supplier = @supplier.shared_supplier
.alert.alert-info
= t 'suppliers.shared_supplier_note'
= t 'suppliers.shared_supplier_note'
%dl.dl-horizontal
%dt= heading_helper(Supplier, :address) + ':'