diff --git a/Gemfile b/Gemfile index 3690b194b8..48ff4349cb 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,8 @@ gem 'rails', '3.2.21' gem 'rails-i18n', '~> 3.0.0' gem 'i18n', '~> 0.6.11' -gem 'nokogiri' +# Patched version. See http://rubysec.com/advisories/CVE-2015-5312/. +gem 'nokogiri', '>= 1.6.7.1' gem 'pg' gem 'spree', github: 'openfoodfoundation/spree', branch: '1-3-stable' diff --git a/Gemfile.lock b/Gemfile.lock index 7d0022ccca..fcd0633483 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -450,7 +450,7 @@ GEM treetop (~> 1.4.8) method_source (0.8.2) mime-types (1.25.1) - mini_portile (0.6.2) + mini_portile2 (2.0.0) momentjs-rails (2.5.1) railties (>= 3.1) money (5.1.1) @@ -458,8 +458,8 @@ GEM multi_json (1.11.2) multi_xml (0.5.5) newrelic_rpm (3.12.0.288) - nokogiri (1.6.6.4) - mini_portile (~> 0.6.0) + nokogiri (1.6.7.2) + mini_portile2 (~> 2.0.0.rc2) oj (2.1.2) orm_adapter (0.5.0) paper_trail (3.0.8) @@ -693,7 +693,7 @@ DEPENDENCIES letter_opener momentjs-rails newrelic_rpm - nokogiri + nokogiri (>= 1.6.7.1) oj paper_trail (~> 3.0.8) paperclip @@ -732,3 +732,6 @@ DEPENDENCIES whenever wicked_pdf wkhtmltopdf-binary + +BUNDLED WITH + 1.10.6 diff --git a/app/assets/javascripts/admin/all.js b/app/assets/javascripts/admin/all.js index 344c5e8a5d..1e2b6f3898 100644 --- a/app/assets/javascripts/admin/all.js +++ b/app/assets/javascripts/admin/all.js @@ -45,5 +45,8 @@ //= require textAngular.min.js //= require textAngular-sanitize.min.js //= require ../shared/bindonce.min.js +//= require darkswarm/i18n.js +//= require darkswarm/i18n.translate.js + //= require_tree . diff --git a/app/assets/javascripts/admin/bulk_order_management.js.coffee b/app/assets/javascripts/admin/bulk_order_management.js.coffee index 7d0572635d..b747d3699e 100644 --- a/app/assets/javascripts/admin/bulk_order_management.js.coffee +++ b/app/assets/javascripts/admin/bulk_order_management.js.coffee @@ -12,25 +12,25 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [ $scope.startDate = formatDate start $scope.endDate = formatDate end $scope.quickSearch = "" - $scope.bulkActions = [ { name: "Delete Selected", callback: $scope.deleteLineItems } ] + $scope.bulkActions = [ { name: t("bom_actions_delete"), callback: $scope.deleteLineItems } ] $scope.selectedBulkAction = $scope.bulkActions[0] $scope.selectedUnitsProduct = {}; $scope.selectedUnitsVariant = {}; $scope.sharedResource = false $scope.columns = Columns.setColumns - order_no: { name: "Order No.", visible: false } - full_name: { name: "Name", visible: true } - email: { name: "Email", visible: false } - phone: { name: "Phone", visible: false } - order_date: { name: "Order Date", visible: true } - producer: { name: "Producer", visible: true } - order_cycle: { name: "Order Cycle", visible: false } - hub: { name: "Hub", visible: false } - variant: { name: "Variant", visible: true } - quantity: { name: "Quantity", visible: true } - max: { name: "Max", visible: true } - final_weight_volume: { name: "Weight/Volume", visible: false } - price: { name: "Price", visible: false } + order_no: { name: t("bom_no"), visible: false } + full_name: { name: t("name"), visible: true } + email: { name: t("email"), visible: false } + phone: { name: t("phone"), visible: false } + order_date: { name: t("bom_date"), visible: true } + producer: { name: t("producer"), visible: true } + order_cycle: { name: t("bom_cycle"), visible: false } + hub: { name: t("bom_hub"), visible: false } + variant: { name: t("bom_variant"), visible: true } + quantity: { name: t("bom_quantity"), visible: true } + max: { name: t("bom_max"), visible: true } + final_weight_volume: { name: t("bom_final_weigth_volume"), visible: false } + price: { name: t("price"), visible: false } $scope.initialise = -> $scope.initialiseVariables() authorise_api_reponse = "" diff --git a/app/assets/javascripts/admin/bulk_product_update.js.coffee b/app/assets/javascripts/admin/bulk_product_update.js.coffee index 6c85a4fd54..3d565f703a 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js.coffee +++ b/app/assets/javascripts/admin/bulk_product_update.js.coffee @@ -4,32 +4,32 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout $scope.StatusMessage = StatusMessage $scope.columns = Columns.setColumns - producer: {name: "Producer", visible: true} - sku: {name: "SKU", visible: false} - name: {name: "Name", visible: true} - unit: {name: "Unit", visible: true} - price: {name: "Price", visible: true} - on_hand: {name: "On Hand", visible: true} - on_demand: {name: "On Demand", visible: false} - category: {name: "Category", visible: false} - tax_category: {name: "Tax Category", visible: false} - inherits_properties: {name: "Inherits Properties?", visible: false} - available_on: {name: "Available On", visible: false} + producer: {name: t("products_producer"), visible: true} + sku: {name: t("products_sku"), visible: false} + name: {name: t("products_name"), visible: true} + unit: {name: t("products_unit"), visible: true} + price: {name: t("products_price"), visible: true} + on_hand: {name: t("products_on_hand"), visible: true} + on_demand: {name: t("products_on_demand"), visible: false} + category: {name: t("products_category"), visible: false} + tax_category: {name: t("products_tax_category"), visible: false} + inherits_properties: {name: t("products_inherits_properties"), visible: false} + available_on: {name: t("products_available_on"), visible: false} $scope.variant_unit_options = VariantUnitManager.variantUnitOptions() $scope.filterableColumns = [ - { name: "Producer", db_column: "producer_name" }, - { name: "Name", db_column: "name" } + { name: t("label_producers"), db_column: "producer_name" }, + { name: t("name"), db_column: "name" } ] $scope.filterTypes = [ - { name: "Equals", predicate: "eq" }, - { name: "Contains", predicate: "cont" } + { name: t("equals"), predicate: "eq" }, + { name: t("contains"), predicate: "cont" } ] $scope.optionTabs = - filters: { title: "Filter Products", visible: false } + filters: { title: t("filter_products"), visible: false } $scope.producers = producers @@ -105,7 +105,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout $scope.categoryFilter = "0" $scope.editWarn = (product, variant) -> - if (DirtyProducts.count() > 0 and confirm("Unsaved changes will be lost. Continue anyway?")) or (DirtyProducts.count() == 0) + if (DirtyProducts.count() > 0 and confirm(t("unsaved_changes_confirmation"))) or (DirtyProducts.count() == 0) window.location = "/admin/products/" + product.permalink_live + ((if variant then "/variants/" + variant.id else "")) + "/edit" @@ -150,14 +150,14 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout if !$scope.variantSaved(variant) $scope.removeVariant(product, variant) else - if confirm("Are you sure?") + if confirm(t("are_you_sure")) $http( method: "DELETE" url: "/api/products/" + product.permalink_live + "/variants/" + variant.id + "/soft_delete" ).success (data) -> $scope.removeVariant(product, variant) else - alert("The last variant cannot be deleted!") + alert(t("delete_product_variant")) $scope.removeVariant = (product, variant) -> product.variants.splice product.variants.indexOf(variant), 1 @@ -194,7 +194,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout if productsToSubmit.length > 0 $scope.updateProducts productsToSubmit # Don't submit an empty list else - StatusMessage.display 'alert', 'No changes to save.' + StatusMessage.display 'alert', t("products_change") $scope.updateProducts = (productsToSubmit) -> @@ -212,10 +212,10 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout ).error (data, status) -> if status == 400 && data.errors? && data.errors.length > 0 errors = error + "\n" for error in data.errors - alert "Saving failed with the following error(s):\n" + errors - $scope.displayFailure "Save failed due to invalid data" + alert t("products_update_error") + "\n" + errors + $scope.displayFailure t("products_update_error") else - $scope.displayFailure "Server returned with error status: " + status + $scope.displayFailure t("products_update_error_data") + status $scope.packProduct = (product) -> @@ -253,23 +253,23 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout $scope.displayUpdating = -> - StatusMessage.display 'progress', 'Saving...' + StatusMessage.display 'progress', t("saving") $scope.displaySuccess = -> - StatusMessage.display 'success', 'Changes saved.' + StatusMessage.display 'success',t("products_changes_saved") $scope.displayFailure = (failMessage) -> - StatusMessage.display 'failure', "Saving failed. #{failMessage}" + StatusMessage.display 'failure', t("products_update_error_msg") + "#{failMessage}" $scope.displayDirtyProducts = -> - if DirtyProducts.count() > 0 - message = if DirtyProducts.count() == 1 then "one product" else DirtyProducts.count() + " products" - StatusMessage.display 'notice', "Changes to #{message} remain unsaved." - else - StatusMessage.clear() + count = DirtyProducts.count() + switch count + when 0 then StatusMessage.clear() + when 1 then StatusMessage.display 'notice', t("one_product_unsaved") + else StatusMessage.display 'notice', t("products_unsaved", n: count) filterSubmitProducts = (productsToFilter) -> diff --git a/app/assets/javascripts/admin/controllers/enterprise_relationships_controller.js.coffee b/app/assets/javascripts/admin/controllers/enterprise_relationships_controller.js.coffee index 47083d443a..153acb2443 100644 --- a/app/assets/javascripts/admin/controllers/enterprise_relationships_controller.js.coffee +++ b/app/assets/javascripts/admin/controllers/enterprise_relationships_controller.js.coffee @@ -7,7 +7,7 @@ angular.module("ofn.admin").controller "AdminEnterpriseRelationshipsCtrl", ($sco $scope.EnterpriseRelationships.create($scope.parent_id, $scope.child_id, $scope.permissions) $scope.delete = (enterprise_relationship) -> - if confirm("Are you sure?") + if confirm(t("are_you_sure")) $scope.EnterpriseRelationships.delete enterprise_relationship $scope.toggleKeyword = (string, key) -> diff --git a/app/assets/javascripts/admin/controllers/enterprise_roles_controller.js.coffee b/app/assets/javascripts/admin/controllers/enterprise_roles_controller.js.coffee index 026913a263..71d0097c6b 100644 --- a/app/assets/javascripts/admin/controllers/enterprise_roles_controller.js.coffee +++ b/app/assets/javascripts/admin/controllers/enterprise_roles_controller.js.coffee @@ -7,5 +7,5 @@ angular.module("ofn.admin").controller "AdminEnterpriseRolesCtrl", ($scope, Ente $scope.EnterpriseRoles.create($scope.user_id, $scope.enterprise_id) $scope.delete = (enterprise_role) -> - if confirm("Are you sure?") + if confirm(t('are_you_sure')) $scope.EnterpriseRoles.delete enterprise_role diff --git a/app/assets/javascripts/admin/enterprise_groups/controllers/side_menu_controller.js.coffee b/app/assets/javascripts/admin/enterprise_groups/controllers/side_menu_controller.js.coffee index 7b9a8165a1..45ca04bfe7 100644 --- a/app/assets/javascripts/admin/enterprise_groups/controllers/side_menu_controller.js.coffee +++ b/app/assets/javascripts/admin/enterprise_groups/controllers/side_menu_controller.js.coffee @@ -5,11 +5,11 @@ angular.module("admin.enterprise_groups") $scope.menu.setItems [ { name: 'Primary Details', icon_class: "icon-user" } - { name: 'Users', icon_class: "icon-user" } - { name: 'About', icon_class: "icon-pencil" } - { name: 'Images', icon_class: "icon-picture" } - { name: 'Contact', icon_class: "icon-phone" } - { name: 'Web', icon_class: "icon-globe" } + { name: (t('users')), icon_class: "icon-user" } + { name: (t('about')), icon_class: "icon-pencil" } + { name: (t('images')), icon_class: "icon-picture" } + { name: (t('contact')), icon_class: "icon-phone" } + { name: (t('web')), icon_class: "icon-globe" } ] $scope.select(0) diff --git a/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee b/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee index d48f2a42f8..a806691465 100644 --- a/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee +++ b/app/assets/javascripts/admin/enterprises/controllers/enterprise_controller.js.coffee @@ -6,7 +6,7 @@ angular.module("admin.enterprises") $scope.navClear = NavigationCheck.clear $scope.pristineEmail = $scope.Enterprise.email $scope.menu = SideMenu - $scope.newManager = { id: '', email: 'Add a manager...' } + $scope.newManager = { id: '', email: (t('add_manager')) } # Provide a callback for generating warning messages displayed before leaving the page. This is passed in # from a directive "nav-check" in the page - if we pass it here it will be called in the test suite, @@ -31,4 +31,4 @@ angular.module("admin.enterprises") if (user for user in $scope.Enterprise.users when user.id == manager.id).length == 0 $scope.Enterprise.users.push manager else - alert "#{manager.email} is already a manager!" + alert ("#{manager.email}" + " " + t("is_already_manager")) diff --git a/app/assets/javascripts/admin/enterprises/controllers/side_menu_controller.js.coffee b/app/assets/javascripts/admin/enterprises/controllers/side_menu_controller.js.coffee index d464585f67..7981e498b6 100644 --- a/app/assets/javascripts/admin/enterprises/controllers/side_menu_controller.js.coffee +++ b/app/assets/javascripts/admin/enterprises/controllers/side_menu_controller.js.coffee @@ -5,20 +5,20 @@ angular.module("admin.enterprises") $scope.select = SideMenu.select $scope.menu.setItems [ - { name: 'Primary Details', icon_class: "icon-home" } - { name: 'Users', icon_class: "icon-user" } - { name: 'Address', icon_class: "icon-map-marker" } - { name: 'Contact', icon_class: "icon-phone" } - { name: 'Social', icon_class: "icon-twitter" } - { name: 'About', icon_class: "icon-pencil" } - { name: 'Business Details', icon_class: "icon-briefcase" } - { name: 'Images', icon_class: "icon-picture" } - { name: "Properties", icon_class: "icon-tags", show: "showProperties()" } - { name: "Shipping Methods", icon_class: "icon-truck", show: "showShippingMethods()" } - { name: "Payment Methods", icon_class: "icon-money", show: "showPaymentMethods()" } - { name: "Enterprise Fees", icon_class: "icon-tasks", show: "showEnterpriseFees()" } - { name: "Inventory Settings", icon_class: "icon-list-ol", show: "showInventorySettings()" } - { name: "Shop Preferences", icon_class: "icon-shopping-cart", show: "showShopPreferences()" } + { name: t('primary_details'), icon_class: "icon-home" } + { name: t('users'), icon_class: "icon-user" } + { name: t('address'), icon_class: "icon-map-marker" } + { name: t('contact'), icon_class: "icon-phone" } + { name: t('social'), icon_class: "icon-twitter" } + { name: t('about'), icon_class: "icon-pencil" } + { name: t('business_details'), icon_class: "icon-briefcase" } + { name: t('images'), icon_class: "icon-picture" } + { name: t('properties'), icon_class: "icon-tags", show: "showProperties()" } + { name: t('shipping_methods'), icon_class: "icon-truck", show: "showShippingMethods()" } + { name: t('payment_methods'), icon_class: "icon-money", show: "showPaymentMethods()" } + { name: t('enterprise_fees'), icon_class: "icon-tasks", show: "showEnterpriseFees()" } + { name: t('inventory_settings'), icon_class: "icon-list-ol", show: "showInventorySettings()" } + { name: t('shop_preferences'), icon_class: "icon-shopping-cart", show: "showShopPreferences()" } ] $scope.select(0) diff --git a/app/assets/javascripts/admin/filters/translate.js.coffee b/app/assets/javascripts/admin/filters/translate.js.coffee new file mode 100644 index 0000000000..20becc147a --- /dev/null +++ b/app/assets/javascripts/admin/filters/translate.js.coffee @@ -0,0 +1,7 @@ +angular.module('ofn.admin').filter "translate", -> + (key, options) -> + t(key, options) + +angular.module('ofn.admin').filter "t", -> + (key, options) -> + t(key, options) diff --git a/app/assets/javascripts/admin/line_items/controllers/line_items_controller.js.coffee b/app/assets/javascripts/admin/line_items/controllers/line_items_controller.js.coffee index c6709eb3b4..f905d33bfe 100644 --- a/app/assets/javascripts/admin/line_items/controllers/line_items_controller.js.coffee +++ b/app/assets/javascripts/admin/line_items/controllers/line_items_controller.js.coffee @@ -5,27 +5,27 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout, $scope.confirmDelete = true $scope.startDate = formatDate daysFromToday -7 $scope.endDate = formatDate daysFromToday 1 - $scope.bulkActions = [ { name: "Delete Selected", callback: 'deleteLineItems' } ] - $scope.selectedUnitsProduct = {}; - $scope.selectedUnitsVariant = {}; + $scope.bulkActions = [ { name: t("bom_actions_delete"), callback: 'deleteLineItems' } ] + $scope.selectedUnitsProduct = {} + $scope.selectedUnitsVariant = {} $scope.sharedResource = false $scope.columns = Columns.setColumns - order_no: { name: "Order No.", visible: false } - full_name: { name: "Name", visible: true } - email: { name: "Email", visible: false } - phone: { name: "Phone", visible: false } - order_date: { name: "Order Date", visible: true } - producer: { name: "Producer", visible: true } - order_cycle: { name: "Order Cycle", visible: false } - hub: { name: "Hub", visible: false } - variant: { name: "Variant", visible: true } - quantity: { name: "Quantity", visible: true } - max: { name: "Max", visible: true } - final_weight_volume: { name: "Weight/Volume", visible: false } - price: { name: "Price", visible: false } + order_no: { name: t("bom_no"), visible: false } + full_name: { name: t("name"), visible: true } + email: { name: t("email"), visible: false } + phone: { name: t("phone"), visible: false } + order_date: { name: t("bom_date"), visible: true } + producer: { name: t("producer"), visible: true } + order_cycle: { name: t("bom_cycle"), visible: false } + hub: { name: t("bom_hub"), visible: false } + variant: { name: t("bom_variant"), visible: true } + quantity: { name: t("bom_quantity"), visible: true } + max: { name: t("bom_max"), visible: true } + final_weight_volume: { name: t("bom_final_weigth_volume"), visible: false } + price: { name: t("price"), visible: false } $scope.confirmRefresh = -> - LineItems.allSaved() || confirm("Unsaved changes exist and will be lost if you continue.") + LineItems.allSaved() || confirm(t "unsaved_changes_warning") $scope.resetSelectFilters = -> $scope.distributorFilter = blankOption().id @@ -73,12 +73,12 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout, StatusMessage.display 'success', "All changes saved" $scope.bulk_order_form.$setPristine() ).catch -> - StatusMessage.display 'failure', "Fields with red borders contain errors." + StatusMessage.display 'failure', t "unsaved_changes_error" else - StatusMessage.display 'failure', "Fields with red borders contain errors." + StatusMessage.display 'failure', t "unsaved_changes_error" $scope.deleteLineItem = (lineItem) -> - if ($scope.confirmDelete && confirm("Are you sure?")) || !$scope.confirmDelete + if ($scope.confirmDelete && confirm(t "are_you_sure")) || !$scope.confirmDelete LineItems.delete lineItem, => $scope.lineItems.splice $scope.lineItems.indexOf(lineItem), 1 diff --git a/app/assets/javascripts/darkswarm/controllers/distributor_node_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/distributor_node_controller.js.coffee new file mode 100644 index 0000000000..6705634771 --- /dev/null +++ b/app/assets/javascripts/darkswarm/controllers/distributor_node_controller.js.coffee @@ -0,0 +1,9 @@ +Darkswarm.controller "DistributorNodeCtrl", ($scope, HashNavigation, $anchorScroll) -> + $scope.toggle = -> + HashNavigation.toggle $scope.distributor.hash + + $scope.open = -> + HashNavigation.active($scope.distributor.hash) + + if $scope.open() + $anchorScroll() diff --git a/app/assets/javascripts/darkswarm/controllers/orders_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/orders_controller.js.coffee new file mode 100644 index 0000000000..116a2b6fd8 --- /dev/null +++ b/app/assets/javascripts/darkswarm/controllers/orders_controller.js.coffee @@ -0,0 +1,2 @@ +Darkswarm.controller "OrdersCtrl", ($scope, $rootScope, $timeout, Orders, Search, $document, HashNavigation, FilterSelectorsService, EnterpriseModal, enterpriseMatchesNameQueryFilter, distanceWithinKmFilter) -> + $scope.Orders = Orders diff --git a/app/assets/javascripts/darkswarm/directives/logo_fallback.js.coffee b/app/assets/javascripts/darkswarm/directives/logo_fallback.js.coffee new file mode 100644 index 0000000000..85f697af3d --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/logo_fallback.js.coffee @@ -0,0 +1,6 @@ +Darkswarm.directive "logoFallback", () -> + restrict: "A" + link: (scope, elm, attr)-> + elm.bind('error', -> + elm.replaceWith("") + ) diff --git a/app/assets/javascripts/darkswarm/filters/format_balance.js.coffee b/app/assets/javascripts/darkswarm/filters/format_balance.js.coffee new file mode 100644 index 0000000000..1b42e9e75d --- /dev/null +++ b/app/assets/javascripts/darkswarm/filters/format_balance.js.coffee @@ -0,0 +1,7 @@ +Darkswarm.filter "formatBalance", (localizeCurrencyFilter, tFilter)-> + # Convert number to string currency using injected currency configuration. + (balance) -> + if balance < 0 + tFilter('credit') + ": " + localizeCurrencyFilter(Math.abs(balance)) + else + tFilter('balance_due') + ": " + localizeCurrencyFilter(Math.abs(balance)) diff --git a/app/assets/javascripts/darkswarm/i18n.translate.js.coffee b/app/assets/javascripts/darkswarm/i18n.translate.js.coffee index c455b6d9e1..eda092da83 100644 --- a/app/assets/javascripts/darkswarm/i18n.translate.js.coffee +++ b/app/assets/javascripts/darkswarm/i18n.translate.js.coffee @@ -4,8 +4,13 @@ window.translate = (key, options = {}) -> unless 'I18n' of window console.log 'The I18n object is undefined. Cannot translate text.' return key - return key unless key of I18n - text = I18n[key] + dict = I18n + parts = key.split '.' + while (parts.length) + part = parts.shift() + return key unless part of dict + dict = dict[part] + text = dict for name, value of options text = text.split("%{#{name}}").join(value) text diff --git a/app/assets/javascripts/darkswarm/services/orders.js.coffee b/app/assets/javascripts/darkswarm/services/orders.js.coffee new file mode 100644 index 0000000000..78ba65f79e --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/orders.js.coffee @@ -0,0 +1,16 @@ +Darkswarm.factory 'Orders', (orders_by_distributor, currencyConfig, CurrentHub, Taxons, Dereferencer, visibleFilter, Matcher, Geo, $rootScope)-> + new class Orders + constructor: -> + # Populate Orders.orders from json in page. + @orders_by_distributor = orders_by_distributor + @currency_symbol = currencyConfig.symbol + + for distributor in @orders_by_distributor + @updateRunningBalance(distributor.distributed_orders) + + + updateRunningBalance: (orders) -> + for order, i in orders + balances = orders.slice(i,orders.length).map (o) -> parseFloat(o.outstanding_balance) + running_balance = balances.reduce (a,b) -> a+b + order.running_balance = running_balance.toFixed(2) diff --git a/app/assets/stylesheets/admin/orders.css.scss b/app/assets/stylesheets/admin/orders.css.scss index 544abfa899..9a2dd4385c 100644 --- a/app/assets/stylesheets/admin/orders.css.scss +++ b/app/assets/stylesheets/admin/orders.css.scss @@ -70,3 +70,7 @@ div#group_buy_calculation { } } } + +th.actions { + white-space: nowrap; +} diff --git a/app/assets/stylesheets/darkswarm/account.css.sass b/app/assets/stylesheets/darkswarm/account.css.sass new file mode 100644 index 0000000000..f582545b74 --- /dev/null +++ b/app/assets/stylesheets/darkswarm/account.css.sass @@ -0,0 +1,63 @@ +@import branding +@import mixins + +.orders + @include sidepaddingSm + @include panepadding + padding-top: 10px + + h3 + padding-top: 2em + + a + color: $clr-brick + &:hover, &:active, &:focus + color: $clr-brick-med-bright + + img + display: block + width: 80px + height: auto + + i.ofn-i_059-producer, i.ofn-i_060-producer-reversed + font-size: 3rem + display: inline-block + margin-right: 0.25rem + float: left + color: $clr-turquoise + + .credit + color: green + + .debit + color: $clr-brick + + .distributor-balance.paid + visibility: hidden + + .transaction-group + + + table + border-radius: 0.5em 0.5em 0 0 + tr:nth-of-type(even) + background: transparent // clear previous + tbody.odd + tr + background-color: #f9f9f9 + border: none + // Column widths for order table + .order1 + width: 20% + .order2 + width: 20% + .order3 + width: 20% + .order4 + width: 10% + .order5 + width: 10% + .order6 + width: 10% + .order7 + width: 10% diff --git a/app/assets/stylesheets/darkswarm/producers.css.sass b/app/assets/stylesheets/darkswarm/producers.css.sass index 2055a45035..dce972629b 100644 --- a/app/assets/stylesheets/darkswarm/producers.css.sass +++ b/app/assets/stylesheets/darkswarm/producers.css.sass @@ -15,4 +15,4 @@ color: $clr-turquoise-bright a.button.primary &:hover, &:active, &:focus - color: white \ No newline at end of file + color: white diff --git a/app/helpers/injection_helper.rb b/app/helpers/injection_helper.rb index df67261fd7..c6be5dc63e 100644 --- a/app/helpers/injection_helper.rb +++ b/app/helpers/injection_helper.rb @@ -2,7 +2,7 @@ require 'open_food_network/enterprise_injection_data' module InjectionHelper def inject_enterprises - inject_json_ams "enterprises", Enterprise.activated.includes(:address).all, Api::EnterpriseSerializer, enterprise_injection_data + inject_json_ams "enterprises", Enterprise.activated.includes(address: :state).all, Api::EnterpriseSerializer, enterprise_injection_data end def inject_group_enterprises @@ -51,6 +51,11 @@ module InjectionHelper render partial: "json/injection_ams", locals: {name: 'enterpriseAttributes', json: "#{@enterprise_attributes.to_json}"} end + def inject_orders_by_distributor + data_array = spree_current_user.orders_by_distributor + inject_json_ams "orders_by_distributor", data_array, Api::OrdersByDistributorSerializer + end + def inject_json(name, partial, opts = {}) render partial: "json/injection", locals: {name: name, partial: partial}.merge(opts) end diff --git a/app/models/customer.rb b/app/models/customer.rb index 856f7e94d7..bcafd3246b 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -2,10 +2,10 @@ class Customer < ActiveRecord::Base acts_as_taggable belongs_to :enterprise - belongs_to :user, :class_name => Spree.user_class + belongs_to :user, class_name: Spree.user_class validates :code, uniqueness: { scope: :enterprise_id, allow_blank: true, allow_nil: true } - validates :email, presence: true, uniqueness: { scope: :enterprise_id, message: "is associated with an existing customer" } + validates :email, presence: true, uniqueness: { scope: :enterprise_id, message: I18n.t('validation_msg_is_associated_with_an_exising_customer') } validates :enterprise_id, presence: true scope :of, ->(enterprise) { where(enterprise_id: enterprise) } diff --git a/app/models/enterprise_relationship.rb b/app/models/enterprise_relationship.rb index da0996fdc5..9303cbae19 100644 --- a/app/models/enterprise_relationship.rb +++ b/app/models/enterprise_relationship.rb @@ -4,7 +4,7 @@ class EnterpriseRelationship < ActiveRecord::Base has_many :permissions, class_name: 'EnterpriseRelationshipPermission', dependent: :destroy validates_presence_of :parent_id, :child_id - validates_uniqueness_of :child_id, scope: :parent_id, message: "^That relationship is already established." + validates_uniqueness_of :child_id, scope: :parent_id, message: I18n.t('validation_msg_relationship_already_established') after_save :apply_variant_override_permissions diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index 1560bae727..e6acd440c7 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -24,8 +24,8 @@ Spree::Product.class_eval do # validates_presence_of :variants, unless: :new_record?, message: "Product must have at least one variant" validates_presence_of :supplier - validates :primary_taxon, presence: { message: "^Product Category can't be blank" } - validates :tax_category_id, presence: { message: "^Tax Category can't be blank" }, if: "Spree::Config.products_require_tax_category" + validates :primary_taxon, presence: { message: I18n.t("validation_msg_product_category_cant_be_blank") } + validates :tax_category_id, presence: { message: I18n.t("validation_msg_tax") }, if: "Spree::Config.products_require_tax_category" validates_presence_of :variant_unit validates_presence_of :variant_unit_scale, diff --git a/app/models/spree/user_decorator.rb b/app/models/spree/user_decorator.rb index b724a41d1b..17473fd521 100644 --- a/app/models/spree/user_decorator.rb +++ b/app/models/spree/user_decorator.rb @@ -49,6 +49,27 @@ Spree.user_class.class_eval do owned_enterprises(:reload).size < enterprise_limit end + # Returns Enterprise IDs for distributors that the user has shopped at + def enterprises_ordered_from + orders.where(state: :complete).map(&:distributor_id).uniq + end + + # Returns orders and their associated payments for all distributors that have been ordered from + def compelete_orders_by_distributor + Enterprise + .includes(distributed_orders: { payments: :payment_method }) + .where(enterprises: { id: enterprises_ordered_from }, + spree_orders: { state: 'complete', user_id: id }) + .order('spree_orders.completed_at DESC') + end + + def orders_by_distributor + # Remove uncompleted payments as these will not be reflected in order balance + data_array = compelete_orders_by_distributor.to_a + remove_uncompleted_payments(data_array) + data_array.sort! { |a, b| b.distributed_orders.length <=> a.distributed_orders.length } + end + private def limit_owned_enterprises @@ -56,4 +77,12 @@ Spree.user_class.class_eval do errors.add(:owned_enterprises, "^#{email} is not permitted to own any more enterprises (limit is #{enterprise_limit}).") end end + + def remove_uncompleted_payments(enterprises) + enterprises.each do |enterprise| + enterprise.distributed_orders.each do |order| + order.payments.keep_if { |payment| payment.state == "completed" } + end + end + end end diff --git a/app/serializers/api/order_serializer.rb b/app/serializers/api/order_serializer.rb new file mode 100644 index 0000000000..acbd0fdd01 --- /dev/null +++ b/app/serializers/api/order_serializer.rb @@ -0,0 +1,31 @@ +module Api + class OrderSerializer < ActiveModel::Serializer + attributes :number, :completed_at, :total, :state, :shipment_state, :payment_state, :outstanding_balance, :payments, :path + + has_many :payments, serializer: Api::PaymentSerializer + + def completed_at + object.completed_at.blank? ? "" : I18n.l(object.completed_at, format: :long) + end + + def total + object.total.to_money.to_s + end + + def shipment_state + object.shipment_state ? object.shipment_state : nil + end + + def payment_state + object.payment_state ? object.payment_state : nil + end + + def state + object.state ? object.state : nil + end + + def path + Spree::Core::Engine.routes_url_helpers.order_url(object.number, only_path: true) + end + end +end diff --git a/app/serializers/api/orders_by_distributor_serializer.rb b/app/serializers/api/orders_by_distributor_serializer.rb new file mode 100644 index 0000000000..b920272df2 --- /dev/null +++ b/app/serializers/api/orders_by_distributor_serializer.rb @@ -0,0 +1,18 @@ +module Api + class OrdersByDistributorSerializer < ActiveModel::Serializer + attributes :name, :id, :hash, :balance, :logo, :distributed_orders + has_many :distributed_orders, serializer: Api::OrderSerializer + + def balance + object.distributed_orders.map(&:outstanding_balance).reduce(:+).to_money.to_s + end + + def hash + object.to_param + end + + def logo + object.logo(:small) if object.logo? + end + end +end diff --git a/app/serializers/api/payment_serializer.rb b/app/serializers/api/payment_serializer.rb new file mode 100644 index 0000000000..d48f75a07f --- /dev/null +++ b/app/serializers/api/payment_serializer.rb @@ -0,0 +1,16 @@ +module Api + class PaymentSerializer < ActiveModel::Serializer + attributes :amount, :updated_at, :payment_method + def payment_method + object.payment_method.name + end + + def amount + object.amount.to_money.to_s + end + + def updated_at + I18n.l(object.updated_at, format: :long) + end + end +end diff --git a/app/views/admin/accounts_and_billing_settings/edit.html.haml b/app/views/admin/accounts_and_billing_settings/edit.html.haml index 71fac1fd28..2121719e75 100644 --- a/app/views/admin/accounts_and_billing_settings/edit.html.haml +++ b/app/views/admin/accounts_and_billing_settings/edit.html.haml @@ -8,9 +8,10 @@ -# - month_options = (0...12).map { |i| Time.zone.now.beginning_of_month - i.months }.map{ |t| [t.strftime("%b %Y"), t.strftime("%b %Y %z")]} %fieldset.no-border-bottom - %legend Settings + %legend + =t :admin_settings = form_for @settings, as: :settings, url: main_app.admin_accounts_and_billing_settings_path, :method => :put do |f| - .row{ ng: { app: 'admin.accounts_and_billing_settings' } } + .row{ ng: { app: t(:admin_accounts_and_billing) } } .twelve.columns.alpha.omega .field = f.label :accounts_distributor_id, t(:accounts_administration_distributor) @@ -23,26 +24,32 @@ .row .six.columns.alpha %fieldset.no-border-bottom - %legend Update Invoices + %legend + =t :update_invoice = f.check_box :auto_update_invoices - = f.label :auto_update_invoices, "Auto-update invoices nightly at 1:00am" + = f.label :auto_update_invoices, + t(:auto_update_invoices) .six.columns.omega %fieldset.no-border-bottom - %legend Finalise Invoices + %legend + =t :finalise_invoice = f.check_box :auto_finalize_invoices - = f.label :auto_finalize_invoices, "Auto-finalise invoices monthly on the 2nd at 1:30am" + = f.label :auto_finalize_invoices, + t(:auto_finalise_invoices) .row .twelve.columns.alpha.omega.form-buttons{"data-hook" => "buttons"} = button t(:update), 'icon-refresh', value: "update" %fieldset.no-border-bottom - %legend Manually Run Tasks + %legend + =t :manually_run_task .row .six.columns.alpha.step.text-center .form-buttons{"data-hook" => "buttons"} - =link_to_with_icon "icon-undo", "Update User Invoices", + =link_to_with_icon "icon-undo", + t(:update_user_invoices) , main_app.start_job_admin_accounts_and_billing_settings_path(job: { name: "update_account_invoices" }), class: "button fullwidth" @@ -51,22 +58,22 @@ - if @update_account_invoices_job %p.text-center - if @update_account_invoices_job.run_at < Time.zone.now - %strong In Progress + =t :in_progress %br - Started at: + =t :started_at - else - %strong Queued + %strong + =t :queued %br - Scheduled for: + =t :Scheduled_for = @update_account_invoices_job.run_at - else %p.explanation - Use this button to immediately update invoices for the month to date for each enterprise user in the system. This task can be set up to run automatically every night. - + =t :update_user_invoice_explained .six.columns.omega.step.text-center .form-buttons{"data-hook" => "buttons"} - =link_to_with_icon "icon-ok-sign", "Finalise User Invoices", + =link_to_with_icon "icon-ok-sign", t(:finalise_user_invoices ), main_app.start_job_admin_accounts_and_billing_settings_path(job: { name: "finalize_account_invoices" }), class: "button fullwidth" @@ -75,14 +82,16 @@ - if @finalize_account_invoices_job %p.text-center - if @finalize_account_invoices_job.run_at < Time.zone.now - %strong In Progress + %strong + =t :in_progress %br - Started at: + =t :started_at - else - %strong Queued + %strong + =t :queued %br - Scheduled for: + =t :scheduled_for = @finalize_account_invoices_job.run_at - else %p.explanation - Use this button to finalize all invoices in the system for the previous calendar month. This task can be set up to run automatically once a month. + =t :finalise_user_invoice_explained diff --git a/app/views/admin/customers/index.html.haml b/app/views/admin/customers/index.html.haml index 5647821bf5..f68ad37da1 100644 --- a/app/views/admin/customers/index.html.haml +++ b/app/views/admin/customers/index.html.haml @@ -1,12 +1,14 @@ - content_for :page_title do - %h1.page-title Customers + %h1.page-title + =t :customers = admin_inject_shops %div{ ng: { app: 'admin.customers', controller: 'customersCtrl' } } .row{ ng: { hide: "loaded() && filteredCustomers.length > 0" } } .five.columns.alpha - %h3 Please select a Hub: + %h3 + =t :please_select_hub .four.columns %select.select2.fullwidth#shop_id{ 'ng-model' => 'shop.id', name: 'shop_id', 'ng-options' => 'shop.id as shop.name for shop in shops' } .seven.columns.omega   @@ -22,9 +24,11 @@ .row{ 'ng-if' => 'shop && !loaded()' } .sixteen.columns.alpha#loading %img.spinner{ src: "/assets/spinning-circles.svg" } - %h1 LOADING CUSTOMERS + %h1 + =t :loading_customers .row{ :class => "sixteen columns alpha", 'ng-show' => 'loaded() && filteredCustomers.length == 0'} - %h1#no_results No customers found. + %h1#no_results + =t :no_customers_found .row{ ng: { show: "loaded() && filteredCustomers.length > 0" } } diff --git a/app/views/admin/enterprise_fees/index.html.haml b/app/views/admin/enterprise_fees/index.html.haml index 8a1e972a33..ec62fa5d36 100644 --- a/app/views/admin/enterprise_fees/index.html.haml +++ b/app/views/admin/enterprise_fees/index.html.haml @@ -1,5 +1,5 @@ = content_for :page_title do - Enterprise Fees + =t :Enterprise_Fees = ng_form_for @enterprise_fee_set, :url => main_app.bulk_update_admin_enterprise_fees_path, :html => {'ng-app' => 'admin.enterpriseFees', 'ng-controller' => 'enterpriseFeesCtrl'} do |enterprise_fee_set_form| = hidden_field_tag 'enterprise_id', @enterprise.id if @enterprise @@ -11,12 +11,18 @@ %table.index#listing_enterprise_fees %thead %tr - %th Enterprise - %th Fee Type - %th Name - %th Tax Category - %th Calculator - %th Calculator values + %th + =t'Enterprise' + %th + =t'fee_type' + %th + =t'name' + %th + =t'tax_category' + %th + =t'calculator' + %th + =t'calculator_values' %th.actions %tbody = enterprise_fee_set_form.ng_fields_for :collection do |f| @@ -37,4 +43,4 @@ %td{'ng-bind-html-unsafe-compiled' => 'enterprise_fee.calculator_settings'} %td.actions{'spree-delete-resource' => "1"} - = enterprise_fee_set_form.submit 'Update' + = enterprise_fee_set_form.submit t(:update) diff --git a/app/views/admin/enterprise_groups/_form_about.html.haml b/app/views/admin/enterprise_groups/_form_about.html.haml index a29fde22cd..1e97697a4e 100644 --- a/app/views/admin/enterprise_groups/_form_about.html.haml +++ b/app/views/admin/enterprise_groups/_form_about.html.haml @@ -1,5 +1,6 @@ %fieldset.alpha.no-border-bottom{ ng: { show: "menu.selected.name=='About'" } } - %legend About + %legend + = t 'admin_entreprise_groups_about' = f.field_container :long_description do %text-angular{'id' => 'enterprise_group_long_description', 'name' => 'enterprise_group[long_description]', 'class' => 'text-angular', 'ta-toolbar' => "[['h1','h2','h3','h4','p'],['bold','italics','underline','clear'],['insertLink']]"} diff --git a/app/views/admin/enterprise_groups/_form_address.html.haml b/app/views/admin/enterprise_groups/_form_address.html.haml index 12bb7ef315..fa7b1e7e75 100644 --- a/app/views/admin/enterprise_groups/_form_address.html.haml +++ b/app/views/admin/enterprise_groups/_form_address.html.haml @@ -1,11 +1,12 @@ = f.fields_for :address do |af| %fieldset.alpha.no-border-bottom{ ng: { show: "menu.selected.name=='Contact'" } } - %legend Contact + %legend + = t 'admin_entreprise_groups_contact' .row .alpha.three.columns = af.label :phone .omega.eight.columns - = af.text_field :phone, { placeholder: "eg. 98 7654 3210"} + = af.text_field :phone, { placeholder: t(:admin_entreprise_groups_contact_phone_placeholder)} .row .alpha.three.columns = f.label :email @@ -15,7 +16,7 @@ .three.columns.alpha = af.label :address1 .eight.columns.omega - = af.text_field :address1, { placeholder: "eg. 123 High Street"} + = af.text_field :address1, { placeholder: t(:admin_entreprise_groups_contact_address1_placeholder)} .row .alpha.three.columns = af.label :address2 @@ -23,18 +24,17 @@ = af.text_field :address2 .row .three.columns.alpha - = af.label :city, 'Suburb' + = af.label :city, t(:admin_entreprise_groups_contact_city) \/ - = af.label :zipcode, 'Postcode' + = af.label :zipcode, t(:admin_entreprise_groups_contact_zipcode) .four.columns - = af.text_field :city, { placeholder: "eg. Northcote"} + = af.text_field :city, { placeholder: t(:admin_entreprise_groups_contact_city_placeholder)} .four.columns.omega - = af.text_field :zipcode, { placeholder: "eg. 3070"} + = af.text_field :zipcode, { placeholder: t(:admin_entreprise_groups_contact_zipcode_placeholder)} .row .three.columns.alpha - = af.label :state_id, 'State' - \/ - = af.label :country_id, 'Country' + = af.label :state_id, t(:admin_entreprise_groups_contact_state_id) + = af.label :country_id, t(:admin_entreprise_groups_contact_country_id) .four.columns = af.collection_select :state_id, af.object.country.states, :id, :name, {}, :class => "select2 fullwidth" .four.columns.omega diff --git a/app/views/admin/enterprise_groups/_form_images.html.haml b/app/views/admin/enterprise_groups/_form_images.html.haml index 1bfffa86d2..24bfad3bf0 100644 --- a/app/views/admin/enterprise_groups/_form_images.html.haml +++ b/app/views/admin/enterprise_groups/_form_images.html.haml @@ -1,18 +1,19 @@ %fieldset.alpha.no-border-bottom{ ng: { show: "menu.selected.name=='Images'" } } - %legend Images + %legend + = t 'admin_entreprise_groups_images' .row .alpha.three.columns - = f.label :logo, 'ofn-with-tip' => 'This is the logo for the group' - %div{'ofn-with-tip' => 'This is the logo for the group'} - %a What's this? + = f.label :logo, 'ofn-with-tip' => t('admin_entreprise_groups_data_powertip_logo') + %div{'ofn-with-tip' => t('admin_entreprise_groups_data_powertip_logo')} + %a= t 'admin.whats_this' .omega.eight.columns = image_tag @object.logo.url if @object.logo.present? = f.file_field :logo .row .alpha.three.columns - = f.label :promo_image, 'ofn-with-tip' => 'This image is displayed at the top of the Group profile' - %div{'ofn-with-tip' => 'This image is displayed at the top of the Group profile'} - %a What's this? + = f.label :promo_image, 'ofn-with-tip' => t(:admin_entreprise_groups_data_powertip_promo_image) + %div{'ofn-with-tip' => t('admin_entreprise_groups_data_powertip_promo_image')} + %a= t 'admin.whats_this' .omega.eight.columns = image_tag @object.promo_image.url if @object.promo_image.present? = f.file_field :promo_image diff --git a/app/views/admin/enterprise_groups/_form_primary_details.html.haml b/app/views/admin/enterprise_groups/_form_primary_details.html.haml index d57333626f..56771c458c 100644 --- a/app/views/admin/enterprise_groups/_form_primary_details.html.haml +++ b/app/views/admin/enterprise_groups/_form_primary_details.html.haml @@ -1,5 +1,6 @@ %fieldset.alpha.no-border-bottom{ ng: { show: "menu.selected.name=='Primary Details'" } } - %legend Primary Details + %legend + = t "admin_entreprise_groups_primary_details" = f.field_container :name do = f.label :name %br/ @@ -11,12 +12,12 @@ = f.text_field :description = f.field_container :on_front_page do - = f.label :on_front_page, 'On front page?' + = f.label :on_front_page, t(:admin_entreprise_groups_on_front_page) %br/ = f.check_box :on_front_page = f.field_container :enterprise_ids do - = f.label :enterprise_ids, 'Enterprises' + = f.label :enterprise_ids, t(:admin_entreprise_groups_entreprise) %br/ = f.collection_select :enterprise_ids, @enterprises, :id, :name, {}, {class: "select2 fullwidth", multiple: true} diff --git a/app/views/admin/enterprise_groups/_form_users.html.haml b/app/views/admin/enterprise_groups/_form_users.html.haml index c4f57da48a..6bd6eaa4a3 100644 --- a/app/views/admin/enterprise_groups/_form_users.html.haml +++ b/app/views/admin/enterprise_groups/_form_users.html.haml @@ -1,10 +1,12 @@ %fieldset.alpha.no-border-bottom{ ng: { show: "menu.selected.name=='Users'" } } - %legend Users + %legend + = t(:users) .row .three.columns.alpha - =f.label :owner_id, 'Owner' - %div{'ofn-with-tip' => "The primary user responsible for this group."} - %a What's this? + =f.label :owner_id, t(:admin_entreprise_groups_owner) + .with-tip{'data-powertip' => t(:admin_entreprise_groups_data_powertip)} + %a + = t 'admin.whats_this' .eight.columns.omega - if spree_current_user.admin? = f.hidden_field :owner_id, diff --git a/app/views/admin/enterprise_groups/_form_web.html.haml b/app/views/admin/enterprise_groups/_form_web.html.haml index 42638d94c6..5d982f1bbb 100644 --- a/app/views/admin/enterprise_groups/_form_web.html.haml +++ b/app/views/admin/enterprise_groups/_form_web.html.haml @@ -1,10 +1,11 @@ %fieldset.alpha.no-border-bottom{ ng: { show: "menu.selected.name=='Web'" } } - %legend Web Resources + %legend + = t 'admin_entreprise_groups_web' .row .alpha.three.columns = f.label :website .omega.eight.columns - = f.text_field :website, { placeholder: "eg. www.truffles.com"} + = f.text_field :website, { placeholder: t(:admin_entreprise_groups_web_website_placeholder)} .row .alpha.three.columns = f.label :facebook, 'Facebook' @@ -24,4 +25,4 @@ .alpha.three.columns = f.label :twitter .omega.eight.columns - = f.text_field :twitter, { placeholder: "eg. @the_prof" } + = f.text_field :twitter, { placeholder: t(:admin_entreprise_groups_web_twitter) } diff --git a/app/views/admin/enterprise_groups/index.html.haml b/app/views/admin/enterprise_groups/index.html.haml index e78dadc72c..747eff0b94 100644 --- a/app/views/admin/enterprise_groups/index.html.haml +++ b/app/views/admin/enterprise_groups/index.html.haml @@ -1,5 +1,5 @@ = content_for :page_title do - Enterprise Groups + = t 'admin_entreprise_groups' - if admin_user? = content_for :page_actions do @@ -8,11 +8,15 @@ %table.index#listing_enterprise_groups %thead %tr - %th Name + %th + = t 'admin_entreprise_groups_name' - if spree_current_user.admin? - %th Owner - %th On front page? - %th Enterprises + %th + = t 'admin_entreprise_groups_owner' + %th + = t 'admin_entreprise_groups_on_front_page' + %th + = t 'admin_entreprise_groups_entreprise' %th.actions %tbody diff --git a/app/views/admin/enterprise_relationships/_enterprise_relationship.html.haml b/app/views/admin/enterprise_relationships/_enterprise_relationship.html.haml index 996bc487d8..05e6505868 100644 --- a/app/views/admin/enterprise_relationships/_enterprise_relationship.html.haml +++ b/app/views/admin/enterprise_relationships/_enterprise_relationship.html.haml @@ -1,6 +1,7 @@ %tr{"ng-repeat" => "enterprise_relationship in EnterpriseRelationships.enterprise_relationships | keywords:query"} %td {{ enterprise_relationship.parent_name }} - %td permits + %td + = t 'admin_entreprise_relationships_permits' %td {{ enterprise_relationship.child_name }} %td %ul diff --git a/app/views/admin/enterprise_relationships/_form.html.haml b/app/views/admin/enterprise_relationships/_form.html.haml index b130faeb1a..4d68d61e1b 100644 --- a/app/views/admin/enterprise_relationships/_form.html.haml +++ b/app/views/admin/enterprise_relationships/_form.html.haml @@ -3,17 +3,17 @@ %select.select2.fullwidth{id: "enterprise_relationship_parent_id", "ng-model" => "parent_id", "ng-options" => "e.id as e.name for e in Enterprises.my_enterprises"} %td - permits + = t 'admin_entreprise_relationships_permits' %td %select.select2.fullwidth{id: "enterprise_relationship_child_id", "ng-model" => "child_id", "ng-options" => "e.id as e.name for e in Enterprises.all_enterprises"} %td %label %input{type: "checkbox", ng: {checked: "allPermissionsChecked()", click: "checkAllPermissions()"}} - Everything + = t 'admin_entreprise_relationships_everything' %div{"ng-repeat" => "permission in EnterpriseRelationships.all_permissions"} %label %input{type: "checkbox", "ng-model" => "permissions[permission]"} to {{ EnterpriseRelationships.permission_presentation(permission) }} %td.actions - %input{type: "button", value: "Create", "ng-click" => "create()"} + %input{type: "button", value: t(:admin_entreprise_relationships_button_create), "ng-click" => "create()"} .errors {{ EnterpriseRelationships.create_errors }} diff --git a/app/views/admin/enterprise_relationships/_search_input.html.haml b/app/views/admin/enterprise_relationships/_search_input.html.haml index b8bcbc62c6..350089dc4f 100644 --- a/app/views/admin/enterprise_relationships/_search_input.html.haml +++ b/app/views/admin/enterprise_relationships/_search_input.html.haml @@ -1,4 +1,4 @@ -%input.search{"ng-model" => "query", "placeholder" => "Search"} +%input.search{"ng-model" => "query", "placeholder" => t(:admin_entreprise_relationships_seach_placeholder)} %label{ng: {repeat: "permission in EnterpriseRelationships.all_permissions"}} %input{type: "checkbox", ng: {click: "$parent.query = toggleKeyword($parent.query, permission)"}} diff --git a/app/views/admin/enterprise_relationships/index.html.haml b/app/views/admin/enterprise_relationships/index.html.haml index 163200a0fc..bdff595f09 100644 --- a/app/views/admin/enterprise_relationships/index.html.haml +++ b/app/views/admin/enterprise_relationships/index.html.haml @@ -1,5 +1,5 @@ - content_for :page_title do - Enterprise Relationships + = t 'admin_entreprise_relationships' = render 'admin/shared/enterprises_sub_menu' diff --git a/app/views/admin/enterprise_roles/index.html.haml b/app/views/admin/enterprise_roles/index.html.haml index a6e0985a99..45d8115597 100644 --- a/app/views/admin/enterprise_roles/index.html.haml +++ b/app/views/admin/enterprise_roles/index.html.haml @@ -1,5 +1,5 @@ - content_for :page_title do - Roles + =t :roles = render 'admin/shared/users_sub_menu' diff --git a/app/views/admin/order_cycles/edit.html.haml b/app/views/admin/order_cycles/edit.html.haml index d2b7605289..f3b0bdb721 100644 --- a/app/views/admin/order_cycles/edit.html.haml +++ b/app/views/admin/order_cycles/edit.html.haml @@ -22,7 +22,8 @@ #advanced_settings{ hidden: true } = render partial: "/admin/order_cycles/advanced_settings" -%h1 Edit Order Cycle +%h1 + = t :edit_order_cycle - ng_controller = order_cycles_simple_form ? 'AdminSimpleEditOrderCycleCtrl' : 'AdminEditOrderCycleCtrl' diff --git a/app/views/admin/order_cycles/index.html.haml b/app/views/admin/order_cycles/index.html.haml index 8f062ff7db..824aa66ee8 100644 --- a/app/views/admin/order_cycles/index.html.haml +++ b/app/views/admin/order_cycles/index.html.haml @@ -1,15 +1,15 @@ = content_for :page_title do - Order Cycles + = t :admin_order_cycles = content_for :page_actions do %li#new_order_cycle_link - = button_link_to "New Order Cycle", main_app.new_admin_order_cycle_path, :icon => 'icon-plus', :id => 'admin_new_order_cycle_link' + = button_link_to t(:new_order_cycle), main_app.new_admin_order_cycle_path, :icon => 'icon-plus', :id => 'admin_new_order_cycle_link' - if @show_more %li - = button_link_to "Show less", main_app.admin_order_cycles_path + = button_link_to t(:label_less), main_app.admin_order_cycles_path - else %li - = button_link_to "Show more", main_app.admin_order_cycles_path(params: { show_more: true }) + = button_link_to t(:label_more), main_app.admin_order_cycles_path(params: { show_more: true }) = form_for @order_cycle_set, url: main_app.bulk_update_admin_order_cycles_path, html: {"ng-app" => "admin.orderCycles"} do |f| %table.index#listing_order_cycles @@ -28,14 +28,21 @@ %thead %tr - %th Name - %th Open - %th Close + %th + =t :name + %th + =t :open + %th + =t :close - unless order_cycles_simple_index - %th Supplier - %th Coordinator - %th Distributors - %th Products + %th + =t :supplier + %th + =t :coordinator + %th + =t :distributors + %th + =t :products %th.actions %th.actions %th.actions @@ -44,4 +51,4 @@ = f.fields_for :collection do |order_cycle_form| = render 'admin/order_cycles/row', order_cycle_form: order_cycle_form - = f.submit 'Update' + = f.submit t :update diff --git a/app/views/admin/order_cycles/new.html.haml b/app/views/admin/order_cycles/new.html.haml index 460f2e08ca..a257bf3c0b 100644 --- a/app/views/admin/order_cycles/new.html.haml +++ b/app/views/admin/order_cycles/new.html.haml @@ -1,4 +1,5 @@ -%h1 New Order Cycle +%h1 + =t'new_order_cycle' - ng_controller = order_cycles_simple_form ? 'AdminSimpleCreateOrderCycleCtrl' : 'AdminCreateOrderCycleCtrl' = admin_inject_order_cycle_instance diff --git a/app/views/admin/order_cycles/set_coordinator.html.haml b/app/views/admin/order_cycles/set_coordinator.html.haml index f2663cbfd2..db9bbb926c 100644 --- a/app/views/admin/order_cycles/set_coordinator.html.haml +++ b/app/views/admin/order_cycles/set_coordinator.html.haml @@ -1,4 +1,5 @@ -%h4.text-center Select a coordinator for your order cycle +%h4.text-center + =t'select_a_coordinator_for_your_order_cycle' %br @@ -9,7 +10,7 @@ .ten.columns = select_tag :coordinator_id, options_for_select(permitted_coordinating_enterprise_options_for(@order_cycle)), { 'required' => true, class: 'select2 fullwidth'} .two.columns.alpha - = f.submit "Continue >" + = f.submit "#{t(:continue)} >" .two.columns.omega   diff --git a/app/views/admin/producer_properties/index.html.haml b/app/views/admin/producer_properties/index.html.haml index d8eac9e816..d898860cb1 100644 --- a/app/views/admin/producer_properties/index.html.haml +++ b/app/views/admin/producer_properties/index.html.haml @@ -6,7 +6,7 @@ - content_for :page_actions do %ul.tollbar.inline-menu %li - = link_to_add_fields 'Add Producer Property', 'tbody#producer_properties', class: 'icon-plus button' + = link_to_add_fields t(:add_producer_property), 'tbody#producer_properties', class: 'icon-plus button' = render 'spree/shared/error_messages', target: @enterprise diff --git a/app/views/producers/_skinny.html.haml b/app/views/producers/_skinny.html.haml index 11860d35d6..cf066be05a 100644 --- a/app/views/producers/_skinny.html.haml +++ b/app/views/producers/_skinny.html.haml @@ -1,20 +1,20 @@ .row.active_table_row{"ng-click" => "toggle($event)", "ng-class" => "{'closed' : !open(), 'is_distributor' : producer.is_distributor}"} .columns.small-12.medium-4.large-4.skinny-head %span{"bo-if" => "producer.is_distributor" } - %a.is_distributor{"bo-href" => "producer.path" } + %a.is_distributor{"bo-href" => "producer.path" } %i{bo: {class: "producer.producer_icon_font"}} - %span.margin-top + %span.margin-top %strong{"bo-text" => "producer.name"} %span.producer-name{"bo-if" => "!producer.is_distributor" } %i{bo: {class: "producer.producer_icon_font"}} - %span.margin-top + %span.margin-top %strong{"bo-text" => "producer.name"} - + .columns.small-6.medium-3.large-3 %span.margin-top{"bo-text" => "producer.address.city"} .columns.small-4.medium-3.large-4 %span.margin-top{"bo-bind" => "producer.address.state_name | uppercase"} .columns.small-2.medium-2.large-1.text-right - %span.margin-top + %span.margin-top %i{"ng-class" => "{'ofn-i_005-caret-down' : !open(), 'ofn-i_006-caret-up' : open()}"} diff --git a/app/views/spree/admin/orders/bulk_management.html.haml b/app/views/spree/admin/orders/bulk_management.html.haml index 003c1ab5f8..43983e87ea 100644 --- a/app/views/spree/admin/orders/bulk_management.html.haml +++ b/app/views/spree/admin/orders/bulk_management.html.haml @@ -2,8 +2,10 @@ = "ng-app='admin.lineItems'" - content_for :page_title do - %h1.page-title Bulk Order Management - %a{ 'ofn-with-tip' => "Use this page to alter product quantities across multiple orders. Products may also be removed from orders entirely, if required." } What's this? + %h1.page-title + = t "bom_page_title" + %a{ 'ofn-with-tip' => t("bom_tip") } + = t "admin.whats_this" = render :partial => 'spree/admin/shared/order_sub_menu' @@ -11,24 +13,29 @@ %save-bar{ save: "submit()", form: "bulk_order_form" } .filters{ :class => "sixteen columns alpha" } .date_filter{ :class => "two columns alpha" } - %label{ :for => 'start_date_filter' }Start Date + %label{ :for => 'start_date_filter' } + = t "start_date" %br %input{ :class => "two columns alpha", :type => "text", :id => 'start_date_filter', 'ng-model' => 'startDate', 'datepicker' => "startDate", 'confirm-change' => "confirmRefresh()", 'ng-change' => 'refreshData()' } .date_filter{ :class => "two columns" } - %label{ :for => 'end_date_filter' }End Date + %label{ :for => 'end_date_filter' } + = t "end_date" %br %input{ :class => "two columns alpha", :type => "text", :id => 'end_date_filter', 'ng-model' => 'endDate', 'datepicker' => "endDate", 'confirm-change' => "confirmRefresh()", 'ng-change' => 'refreshData()' } .one.column   .filter_select{ :class => "three columns" } - %label{ :for => 'supplier_filter' }Producer + %label{ :for => 'supplier_filter' } + = t "producer" %br %select{ :class => "three columns alpha", :id => 'supplier_filter', 'select2-min-search' => 5, 'ng-model' => 'supplierFilter', 'ng-options' => 's.id as s.name for s in suppliers' } .filter_select{ :class => "three columns" } - %label{ :for => 'distributor_filter' }Hub + %label{ :for => 'distributor_filter' } + = t "bom_hub" %br %select{ :class => "three columns alpha", :id => 'distributor_filter', 'select2-min-search' => 5, 'ng-model' => 'distributorFilter', 'ng-options' => 'd.id as d.name for d in distributors'} .filter_select{ :class => "three columns" } - %label{ :for => 'order_cycle_filter' }Order Cycle + %label{ :for => 'order_cycle_filter' } + = t "order_cycle" %br %select{ :class => "three columns alpha", :id => 'order_cycle_filter', 'select2-min-search' => 5, 'ng-model' => 'orderCycleFilter', 'ng-options' => 'oc.id as oc.name for oc in orderCycles', 'confirm-change' => "confirmRefresh()", 'ng-change' => 'refreshData()'} .filter_clear{ :class => "two columns omega" } @@ -42,7 +49,7 @@ %div.shared_resource{ :class => "four columns alpha" } %span{ :class => 'three columns alpha' } %input{ type: 'checkbox', :id => 'shared_resource', 'ng-model' => 'sharedResource'} - Shared Resource? + = t "bom_shared" %div{ :class => "eight columns" } %h6{ :class => "eight columns alpha", 'ng-show' => 'sharedResource', style: 'text-align: center;' } {{ selectedUnitsProduct.name + ": ALL" }} %h6{ :class => "eight columns alpha", 'ng-hide' => 'sharedResource', style: 'text-align: center;' } {{ selectedUnitsVariant.full_name }} @@ -53,28 +60,33 @@ .row .one.column.alpha   .two.columns - %span.two.columns Group Buy Unit Size + %span.two.columns + = t "group_buy_unit_size" %span.two.columns {{ formattedValueWithUnitName( selectedUnitsProduct.group_buy_unit_size, selectedUnitsProduct, selectedUnitsVariant ) }} .one.column   .two.columns - %span.two.columns Total Quantity Ordered + %span.two.columns + = t "total_qtt_ordered" %span.two.columns {{ formattedValueWithUnitName( sumUnitValues(), selectedUnitsProduct, selectedUnitsVariant ) }} .one.column   .two.columns - %span.two.columns Max Quantity Ordered + %span.two.columns + = t "max_qtt_ordered" %span.two.columns {{ formattedValueWithUnitName( sumMaxUnitValues(), selectedUnitsProduct, selectedUnitsVariant ) }} .one.column   .two.columns - %span.two.columns Current Fulfilled Units + %span.two.columns + = t "current_fulfilled_units" %span.two.columns {{ fulfilled(sumUnitValues()) }} .one.column   .two.columns - %span.two.columns Max Fulfilled Units + %span.two.columns + = t "max_fulfilled_units" %span.two.columns {{ fulfilled(sumMaxUnitValues()) }} .one.column.omega   %div{ :class => "eight columns alpha", 'ng-hide' => 'allFinalWeightVolumesPresent()' } %span{ :class => "eight columns alpha", style: 'color:red' } - WARNING: Some variants do not have a unit value + = t "bulk_management_warning" %hr.divider.sixteen.columns.alpha.omega @@ -87,10 +99,12 @@ %div.sixteen.columns.alpha#loading{ 'ng-if' => 'RequestMonitor.loading' } %img.spinner{ src: "/assets/spinning-circles.svg" } - %h1 LOADING ORDERS + %h1 + =t "bom_loading" %div{ :class => "sixteen columns alpha", 'ng-show' => '!RequestMonitor.loading && filteredLineItems.length == 0'} - %h1#no_results No orders found. + %h1#no_results + = t "bom_no_results" .margin-bottom-50{ 'ng-hide' => 'RequestMonitor.loading || filteredLineItems.length == 0' } %form{ name: 'bulk_order_form' } @@ -100,30 +114,43 @@ %th.bulk %input{ :type => "checkbox", :name => 'toggle_bulk', 'ng-click' => 'toggleAllCheckboxes()', 'ng-checked' => "allBoxesChecked()" } %th.order_no{ 'ng-show' => 'columns.order_no.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'order.number'; reverse = !reverse" } Order No. + %a{ :href => '', 'ng-click' => "predicate = 'order.number'; reverse = !reverse" } + = t "order_no" %th.full_name{ 'ng-show' => 'columns.full_name.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'order.full_name'; reverse = !reverse" } Name + %a{ :href => '', 'ng-click' => "predicate = 'order.full_name'; reverse = !reverse" } + = t "name" %th.email{ 'ng-show' => 'columns.email.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'order.email'; reverse = !reverse" } Email + %a{ :href => '', 'ng-click' => "predicate = 'order.email'; reverse = !reverse" } + = t "email" %th.phone{ 'ng-show' => 'columns.phone.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'order.phone'; reverse = !reverse" } Phone + %a{ :href => '', 'ng-click' => "predicate = 'order.phone'; reverse = !reverse" } + = t "phone" %th.date{ 'ng-show' => 'columns.order_date.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'order.completed_at'; reverse = !reverse" } Order Date + %a{ :href => '', 'ng-click' => "predicate = 'order.completed_at'; reverse = !reverse" } + =t "bom_date" %th.producer{ 'ng-show' => 'columns.producer.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'supplier.name'; reverse = !reverse" } Producer + %a{ :href => '', 'ng-click' => "predicate = 'supplier.name'; reverse = !reverse" } + = t "producer" %th.order_cycle{ 'ng-show' => 'columns.order_cycle.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'order.order_cycle.name'; reverse = !reverse" } Order Cycle + %a{ :href => '', 'ng-click' => "predicate = 'order.order_cycle.name'; reverse = !reverse" } + = t "bom_cycle" %th.hub{ 'ng-show' => 'columns.hub.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'order.distributor.name'; reverse = !reverse" } Hub + %a{ :href => '', 'ng-click' => "predicate = 'order.distributor.name'; reverse = !reverse" } + = t "bom_hub" %th.variant{ 'ng-show' => 'columns.variant.visible' } - %a{ :href => '', 'ng-click' => "predicate = 'units_variant.full_name'; reverse = !reverse" } Product: Unit - %th.quantity{ 'ng-show' => 'columns.quantity.visible' } Quantity - %th.max{ 'ng-show' => 'columns.max.visible' } Max - %th.final_weight_volume{ 'ng-show' => 'columns.final_weight_volume.visible' } Weight/Volume - %th.price{ 'ng-show' => 'columns.price.visible' } Price + %a{ :href => '', 'ng-click' => "predicate = 'units_variant.full_name'; reverse = !reverse" } + = t "bom_variant" + %th.quantity{ 'ng-show' => 'columns.quantity.visible' } + = t "products_quantity" + %th.max{ 'ng-show' => 'columns.max.visible' } + = t "shop_variant_quantity_max" + %th.final_weight_volume{ 'ng-show' => 'columns.final_weight_volume.visible' } + = t "weight_volume" + %th.price{ 'ng-show' => 'columns.price.visible' } + = t "products_price" %th.actions %th.actions - Ask?  + = t "ask" %input{ :type => 'checkbox', 'ng-model' => "confirmDelete" } %tr.line_item{ 'ng-repeat' => "line_item in filteredLineItems = ( lineItems | filter:quickSearch | selectFilter:supplierFilter:distributorFilter:orderCycleFilter | variantFilter:selectedUnitsProduct:selectedUnitsVariant:sharedResource | orderBy:predicate:reverse )", 'ng-class-even' => "'even'", 'ng-class-odd' => "'odd'", :id => "li_{{line_item.id}}" } diff --git a/app/views/spree/admin/overview/_enterprises_footer.html.haml b/app/views/spree/admin/overview/_enterprises_footer.html.haml index c61add38f5..c704dfef64 100644 --- a/app/views/spree/admin/overview/_enterprises_footer.html.haml +++ b/app/views/spree/admin/overview/_enterprises_footer.html.haml @@ -1,3 +1,3 @@ %a.sixteen.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_enterprises_path}" } - MANAGE MY ENTERPRISES + = t "spree_admin_overview_enterprises_footer" %span.icon-arrow-right diff --git a/app/views/spree/admin/overview/_enterprises_header.html.haml b/app/views/spree/admin/overview/_enterprises_header.html.haml index d198e8b549..5b1979c4ce 100644 --- a/app/views/spree/admin/overview/_enterprises_header.html.haml +++ b/app/views/spree/admin/overview/_enterprises_header.html.haml @@ -1,8 +1,10 @@ %div.header.sixteen.columns.alpha{ :class => "#{@enterprises.count > 0 ? "" : "red"}"} - %h3.thirteen.columns.alpha My Enterprises + %h3.thirteen.columns.alpha + = t "spree_admin_overview_enterprises_header" - if @enterprises.any? - if spree_current_user.can_own_more_enterprises? %a.three.columns.omega.icon-plus.button.blue.white-bottom{ href: "#{main_app.new_admin_enterprise_path}" } - CREATE NEW + = t "spree_admin_enterprises_create_new" - else - %a{ "ofn-with-tip" => "Enterprises are Producers and/or Hubs and are the basic unit of organisation within the Open Food Network." } What's this? + %a{ "ofn-with-tip" => "Enterprises are Producers and/or Hubs and are the basic unit of organisation within the Open Food Network." } + = t "admin_enterprise_groups_what_s_this" diff --git a/app/views/spree/admin/overview/_enterprises_hubs_tab.html.haml b/app/views/spree/admin/overview/_enterprises_hubs_tab.html.haml index 78c0e2427b..3073ec78a3 100644 --- a/app/views/spree/admin/overview/_enterprises_hubs_tab.html.haml +++ b/app/views/spree/admin/overview/_enterprises_hubs_tab.html.haml @@ -1,12 +1,15 @@ %div.hubs_tab{ ng: { show: "activeTab == 'hubs'"} } %div.sixteen.columns.alpha.list-title - %span.five.columns.alpha Name + %span.five.columns.alpha + = t "spree_admin_enterprises_hubs_name" - if can? :admin, Spree::PaymentMethod %span.centered.three.columns Payment Methods - if can? :admin, Spree::ShippingMethod - %span.centered.three.columns Shipping Methods + %span.centered.three.columns + = t "spree_admin_enterprises_shipping_methods" - if can? :admin, EnterpriseFee - %span.centered.three.columns Enterprise Fees + %span.centered.three.columns + = t "spree_admin_enterprises_fees" %div.sixteen.columns.alpha.list - @enterprises.is_distributor.each do |enterprise| %a.sixteen.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.edit_admin_enterprise_path(enterprise)}" } diff --git a/app/views/spree/admin/overview/_enterprises_none.html.haml b/app/views/spree/admin/overview/_enterprises_none.html.haml index c1428a6863..72cd90df1a 100644 --- a/app/views/spree/admin/overview/_enterprises_none.html.haml +++ b/app/views/spree/admin/overview/_enterprises_none.html.haml @@ -1,7 +1,8 @@ %div.sixteen.columns.alpha.list-item.red - %span.text.fifteen.columns.alpha You don't have any enterprises yet. + %span.text.fifteen.columns.alpha + = t "spree_admin_enterprises_none_text" %span.one.columns.omega %span.icon-remove-sign %a.sixteen.columns.alpha.button.bottom.red{ href: "#{main_app.new_admin_enterprise_path}" } - CREATE A NEW ENTERPRISE + = t "spree_admin_enterprises_none_create_a_new_enterprise" %span.icon-arrow-right diff --git a/app/views/spree/admin/overview/_enterprises_producers_tab.html.haml b/app/views/spree/admin/overview/_enterprises_producers_tab.html.haml index d5cad103b7..19cae1e6f8 100644 --- a/app/views/spree/admin/overview/_enterprises_producers_tab.html.haml +++ b/app/views/spree/admin/overview/_enterprises_producers_tab.html.haml @@ -1,11 +1,15 @@ %div.producers_tab{ ng: { show: "activeTab == 'producers'"} } %div.list-title.sixteen.columns.alpha - %span.five.columns.alpha Name + %span.five.columns.alpha + = t "spree_admin_enterprises_producers_name" - if can? :admin, Spree::Product - %span.centered.three.columns Total Products - %span.centered.three.columns Active Products + %span.centered.three.columns + = t "spree_admin_enterprises_producers_total_products" + %span.centered.three.columns + = t "spree_admin_enterprises_producers_active_products" - if can? :admin, OrderCycle - %span.centered.three.columns Products in OCs + %span.centered.three.columns + = t "spree_admin_enterprises_producers_order_cycles" %div.sixteen.columns.alpha.list - @enterprises.is_primary_producer.each do |enterprise| %a.sixteen.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.edit_admin_enterprise_path(enterprise)}" } diff --git a/app/views/spree/admin/overview/_enterprises_tabs.html.haml b/app/views/spree/admin/overview/_enterprises_tabs.html.haml index f6e5413786..5f8eb9e3c2 100644 --- a/app/views/spree/admin/overview/_enterprises_tabs.html.haml +++ b/app/views/spree/admin/overview/_enterprises_tabs.html.haml @@ -1,3 +1,5 @@ %div.sixteen.columns.alpha.tabs - %div.dashboard_tab.eight.columns.alpha.blue{ ng: { class: "{selected: activeTab == 'hubs'}", click: "activeTab = 'hubs'" } } HUBS - %div.dashboard_tab.eight.columns.omega.blue{ ng: { class: "{selected: activeTab == 'producers'}", click: "activeTab = 'producers'" } } PRODUCERS + %div.dashboard_tab.eight.columns.alpha.blue{ ng: { class: "{selected: activeTab == 'hubs'}", click: "activeTab = 'hubs'" } } + = t "spree_admin_enterprises_tabs_hubs" + %div.dashboard_tab.eight.columns.omega.blue{ ng: { class: "{selected: activeTab == 'producers'}", click: "activeTab = 'producers'" } } + = t "spree_admin_enterprises_tabs_producers" diff --git a/app/views/spree/admin/overview/_order_cycles.html.haml b/app/views/spree/admin/overview/_order_cycles.html.haml index 34b82c1f87..8628837a47 100644 --- a/app/views/spree/admin/overview/_order_cycles.html.haml +++ b/app/views/spree/admin/overview/_order_cycles.html.haml @@ -1,10 +1,13 @@ %div.dashboard_item.seven.columns.omega#order_cycles %div.header.seven.columns.alpha{ :class => "#{@order_cycle_count > 0 ? "" : "orange"}"} - %h3.four.columns.alpha Order Cycles + %h3.four.columns.alpha + = t "spree_admin_order_cycles" - if @order_cycle_count > 0 %a.three.columns.omega.icon-plus.button.blue{ href: "#{main_app.new_admin_order_cycle_path}" } - CREATE NEW + = t "spree_admin_enterprises_create_new" - else + %a.with-tip{ title: t(:spree_admin_order_cycles_tip) } + = t "admin.whats_this" %a{ "ofn-with-tip" => "Order cycles determine when and where your products are available to customers." } What's this? %div.seven.columns.alpha.list - if @order_cycle_count > 0 @@ -14,13 +17,16 @@ %span.one.column.omega %span.icon-ok-sign %a.seven.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_order_cycles_path}" } - MANAGE ORDER CYCLES + = t "spree_admin_enterprises_producers_manage_order_cycles" %span.icon-arrow-right - else %div.seven.columns.alpha.list-item.orange - %span.six.columns.alpha You don't have any active order cycles. + %span.six.columns.alpha + = t "spree_admin_enterprises_producers_orders_cycle_text" %span.one.column.omega %span.icon-warning-sign %a.seven.columns.alpha.button.bottom.orange{ href: "#{main_app.admin_order_cycles_path}" } + = t "spree_admin_enterprises_producers_manage_order_cycles" + %span.icon-arrow-right MANAGE ORDER CYCLES %span.icon-arrow-right diff --git a/app/views/spree/admin/overview/_products.html.haml b/app/views/spree/admin/overview/_products.html.haml index 24b60250c3..c017cd11f9 100644 --- a/app/views/spree/admin/overview/_products.html.haml +++ b/app/views/spree/admin/overview/_products.html.haml @@ -1,11 +1,13 @@ %div.dashboard_item.seven.columns.alpha#products %div.header.seven.columns.alpha{ :class => "#{@product_count > 0 ? "" : "red"}"} - %h3.four.columns.alpha Products + %h3.four.columns.alpha + = t "products" - if @product_count > 0 %a.three.columns.omega.icon-plus.button.blue{ href: "#{new_admin_product_path}" } - CREATE NEW + = t "spree_admin_enterprises_create_new" - else - %a{ "ofn-with-tip" => "The products that you sell through the Open Food Network." } What's this? + %a{ "ofn-with-tip" => "The products that you sell through the Open Food Network." } + = t "admin.whats_this" %div.seven.columns.alpha.list - if @product_count > 0 %div.seven.columns.alpha.list-item @@ -14,13 +16,14 @@ %span.one.column.omega %span.icon-ok-sign %a.seven.columns.alpha.button.bottom.blue{ href: "#{bulk_edit_admin_products_path}" } - MANAGE PRODUCTS + = t "spree_admin_enterprises_producers_manage_products" %span.icon-arrow-right - else %div.seven.columns.alpha.list-item.red - %span.six.columns.alpha You don't have any active products. + %span.six.columns.alpha + = t "spree_admin_enterprises_any_active_products_text" %span.one.column.omega %span.icon-remove-sign %a.seven.columns.alpha.button.bottom.red{ href: "#{new_admin_product_path}" } - CREATE A NEW PRODUCT + = t "spree_admin_enterprises_create_new_product" %span.icon-arrow-right diff --git a/app/views/spree/admin/overview/_unconfirmed.html.haml b/app/views/spree/admin/overview/_unconfirmed.html.haml index 05c4df2a0d..5ff0e17a84 100644 --- a/app/views/spree/admin/overview/_unconfirmed.html.haml +++ b/app/views/spree/admin/overview/_unconfirmed.html.haml @@ -1,4 +1,4 @@ - @enterprises.unconfirmed.each do |enterprise| .alert - %h6= "Action Required: Please confirm the email address for #{enterprise.name}." - %span.message= "We've sent a confirmation email to #{enterprise.email}, so please check there for further instructions. Thanks!" \ No newline at end of file + %h6= "#{t :spree_admin_overview_action_required}: #{t :spree_admin_single_enterprise_alert_mail_confirmation} #{enterprise.name}." + %span.message= "#{t :spree_admin_single_enterprise_alert_mail_sent} #{enterprise.email}. #{t :spree_admin_overview_check_your_inbox}" diff --git a/app/views/spree/admin/overview/multi_enterprise_dashboard.html.haml b/app/views/spree/admin/overview/multi_enterprise_dashboard.html.haml index 511718d3f4..0647304e05 100644 --- a/app/views/spree/admin/overview/multi_enterprise_dashboard.html.haml +++ b/app/views/spree/admin/overview/multi_enterprise_dashboard.html.haml @@ -3,7 +3,8 @@ %div{ 'ng-app' => 'ofn.admin' } - %h1{ :style => 'margin-bottom: 30px' } Dashboard + %h1{ :style => 'margin-bottom: 30px' } + = t "dashbord" - if @enterprises.unconfirmed.any? diff --git a/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml b/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml index 3998f736de..91c0934e21 100644 --- a/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml +++ b/app/views/spree/admin/overview/single_enterprise_dashboard.html.haml @@ -19,7 +19,7 @@ } #package_button %button#toggle_type{ onClick: 'toggleType()' } - Change Package + = t "change_package" %i.icon-chevron-down @@ -29,17 +29,17 @@ - if @enterprise.confirmed_at.nil? .alert-box - Please confirm the email address for + = t "spree_admin_single_enterprise_alert_mail_confirmation" %strong= "#{@enterprise.name}." - We've sent an email to + = t "spree_admin_single_enterprise_alert_mail_sent" %strong= "#{@enterprise.email}." - = link_to('Resend', main_app.enterprise_confirmation_path(enterprise: { id: @enterprise.id, email: @enterprise.email } ), method: :post) + = link_to(t('resend'), main_app.enterprise_confirmation_path(enterprise: { id: @enterprise.id, email: @enterprise.email } ), method: :post) %a.close{ href: "#" } × - if !@enterprise.visible .alert-box - %strong Hint: - To allow people to find you, turn on your visibility under - %strong= "Manage #{@enterprise.name}." + %strong + = t "spree_admin_single_enterprise_hint" + %strong= "#{t 'manage'} #{@enterprise.name}." %a.close{ href: "#" } × .row @@ -47,14 +47,15 @@ .header %h3 %span.icon-map-marker - Your profile live - %p on the Open Food Network map + = t "your_profil_live" + %p + = t "on_ofn_map" .list /-# Can we pass an anchor here to zoom to our enterprise? %a.button.bottom{href: main_app.map_path, target: '_blank'} - See + = t "see" = @enterprise.name - live + = t "live" %span.icon-arrow-right .two.columns   @@ -63,11 +64,12 @@ .header %h3 %span.icon-edit - Edit profile details - %p Change your profile description, images, etc. + = t "edit_profile_details" + %p + = t "edit_profile_details_etc" .list %a.button.bottom{href: main_app.edit_admin_enterprise_path(@enterprise)} - Manage + = t "manage" = @enterprise.name %span.icon-arrow-right @@ -77,10 +79,10 @@ .header %h3 %span.icon-th-large - Add & manage products + = t "add_and_manage_products" .list %a.button.bottom{href: bulk_edit_admin_products_path} - Manage products + = t "manage_products" %span.icon-arrow-right .two.columns @@ -91,8 +93,8 @@ .header %h3 %span.icon-shopping-cart - Add & manage order cycles + = t "add_and_manage_order_cycles" .list %a.button.bottom{href: main_app.admin_order_cycles_path} - Manage order cycles + = t "manage_order_cycles" %span.icon-arrow-right diff --git a/app/views/spree/admin/products/bulk_edit/_filters.html.haml b/app/views/spree/admin/products/bulk_edit/_filters.html.haml index 3e676ede6d..4ce0c7c053 100644 --- a/app/views/spree/admin/products/bulk_edit/_filters.html.haml +++ b/app/views/spree/admin/products/bulk_edit/_filters.html.haml @@ -4,11 +4,11 @@ %br %input.quick-search.fullwidth{ 'ng-model' => 'query', :name => "quick_filter", :type => 'text', 'placeholder' => 'Quick Search' } .filter_select.four.columns - %label{ :for => 'producer_filter' }Producer + %label{ :for => 'producer_filter' }= t 'producer' %br %select.fullwidth{ :id => 'producer_filter', 'ofn-select2-min-search' => 5, 'ng-model' => 'producerFilter', 'ng-options' => 'producer.id as producer.name for producer in filterProducers' } .filter_select.four.columns - %label{ :for => 'category_filter' }Category + %label{ :for => 'category_filter' }= t 'category' %br %select.fullwidth{ :id => 'category_filter', 'ofn-select2-min-search' => 5, 'ng-model' => 'categoryFilter', 'ng-options' => 'taxon.id as taxon.name for taxon in filterTaxons'} %div{ :class => "one column" }   diff --git a/app/views/spree/admin/reports/customers.html.haml b/app/views/spree/admin/reports/customers.html.haml index aef51702a6..70045662f9 100644 --- a/app/views/spree/admin/reports/customers.html.haml +++ b/app/views/spree/admin/reports/customers.html.haml @@ -2,30 +2,30 @@ %br .row .four.columns.alpha - = label_tag nil, "Distributor: " + = label_tag nil, t(:report_customers_distributor) = select_tag(:distributor_id, options_from_collection_for_select(@distributors, :id, :name, params[:distributor_id]), {:include_blank => true, :class => "select2 fullwidth"}) .four.columns - = label_tag nil, "Supplier: " + = label_tag nil, t(:report_customers_supplier) = select_tag(:supplier_id, options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id]), {:include_blank => true, :class => "select2 fullwidth"}) .six.columns - = label_tag nil, "Order Cycle: " + = label_tag nil, t(:report_customers_cycle) = select_tag(:order_cycle_id, options_for_select(report_order_cycle_options(@order_cycles), params[:order_cycle_id]), {:include_blank => true, :class => "select2 fullwidth"}) - = label_tag nil, "Report Type: " + = label_tag nil, t(:report_customers_type) = select_tag(:report_type, options_for_select(@report_types, @report_type)) %br %br = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) %br = button t(:search) @@ -33,7 +33,7 @@ %br %table#listing_customers.index %thead - %tr{'data-hook' => "orders_header"} + %tr{'data-hook' => "orders_header" } - @report.header.each do |heading| %th=heading %tbody @@ -44,4 +44,3 @@ - if @report.table.empty? %tr %td{:colspan => "2"}= t(:none) - diff --git a/app/views/spree/admin/reports/order_cycle_management.html.haml b/app/views/spree/admin/reports/order_cycle_management.html.haml index 5ab379a669..0b32eabe78 100644 --- a/app/views/spree/admin/reports/order_cycle_management.html.haml +++ b/app/views/spree/admin/reports/order_cycle_management.html.haml @@ -2,16 +2,16 @@ = render 'date_range_form', f: f .row - .alpha.two.columns= label_tag nil, "Hubs: " + .alpha.two.columns= label_tag nil, t(:report_hubs) .omega.fourteen.columns= f.collection_select(:distributor_id_in, @distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Order Cycles: " + .alpha.two.columns= label_tag nil, t(:report_customers_cycle) .omega.fourteen.columns = f.select(:order_cycle_id_in, report_order_cycle_options(@order_cycles), {selected: params[:q][:order_cycle_id_in]}, {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Payment Methods: " + .alpha.two.columns= label_tag nil, t(:report_payment) .omega.fourteen.columns= select_tag(:payment_method_in, options_for_select(report_payment_method_options(@report.orders), params[:payment_method_in]), {class: "select2 fullwidth", multiple: true}) .row @@ -24,7 +24,7 @@ .row = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) .row = button t(:search) @@ -33,7 +33,7 @@ %br %table#listing_ocm_orders.index %thead - %tr{'data-hook' => "orders_header"} + %tr{'data-hook' => "orders_header" } - @report.header.each do |heading| %th=heading %tbody diff --git a/app/views/spree/admin/reports/orders_and_distributors.html.haml b/app/views/spree/admin/reports/orders_and_distributors.html.haml index 23baad395e..9d733cc995 100644 --- a/app/views/spree/admin/reports/orders_and_distributors.html.haml +++ b/app/views/spree/admin/reports/orders_and_distributors.html.haml @@ -2,7 +2,7 @@ = render 'date_range_form', f: f = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) %br = button t(:search) @@ -10,7 +10,7 @@ %br %table#listing_orders.index %thead - %tr{'data-hook' => "orders_header"} + %tr{'data-hook' => t(:report_customers_header)} - @report.header.each do |heading| %th=heading %tbody diff --git a/app/views/spree/admin/reports/orders_and_fulfillment.html.haml b/app/views/spree/admin/reports/orders_and_fulfillment.html.haml index 2465fe0ff2..5bda882108 100644 --- a/app/views/spree/admin/reports/orders_and_fulfillment.html.haml +++ b/app/views/spree/admin/reports/orders_and_fulfillment.html.haml @@ -2,25 +2,25 @@ = render 'date_range_form', f: f .row - .alpha.two.columns= label_tag nil, "Hubs: " + .alpha.two.columns= label_tag nil, t(:report_hubs) .omega.fourteen.columns= f.collection_select(:distributor_id_in, @distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Producers: " + .alpha.two.columns= label_tag nil, t(:report_producers) .omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Order Cycles: " + .alpha.two.columns= label_tag nil, t(:report_customers_cycle) .omega.fourteen.columns = f.select(:order_cycle_id_in, report_order_cycle_options(@order_cycles), {selected: params[:q][:order_cycle_id_in]}, {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Report Type: " + .alpha.two.columns= label_tag nil, t(:report_type) .omega.fourteen.columns= select_tag(:report_type, options_for_select(@report_types, @report_type)) .row = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) .row = button t(:search) diff --git a/app/views/spree/admin/reports/packing.html.haml b/app/views/spree/admin/reports/packing.html.haml index 2aa8d8c8b9..fa9d22eb70 100644 --- a/app/views/spree/admin/reports/packing.html.haml +++ b/app/views/spree/admin/reports/packing.html.haml @@ -2,25 +2,25 @@ = render 'date_range_form', f: f .row - .alpha.two.columns= label_tag nil, "Hubs: " + .alpha.two.columns= label_tag nil, t(:report_hubs) .omega.fourteen.columns= f.collection_select(:distributor_id_in, @distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Producers: " + .alpha.two.columns= label_tag nil, t(:report_producers) .omega.fourteen.columns= select_tag(:supplier_id_in, options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id_in]), {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Order Cycles: " + .alpha.two.columns= label_tag nil, t(:report_customers_cycle) .omega.fourteen.columns = f.select(:order_cycle_id_in, report_order_cycle_options(@order_cycles), {selected: params[:q][:order_cycle_id_in]}, {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Report Type: " + .alpha.two.columns= label_tag nil, t(:report_type) .omega.fourteen.columns= select_tag(:report_type, options_for_select(@report_types, @report_type)) .row = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) .row = button t(:search) diff --git a/app/views/spree/admin/reports/payments.html.haml b/app/views/spree/admin/reports/payments.html.haml index 909846f47f..b69708fbd1 100644 --- a/app/views/spree/admin/reports/payments.html.haml +++ b/app/views/spree/admin/reports/payments.html.haml @@ -3,15 +3,15 @@ .row .four.columns.alpha - = label_tag nil, "Distributor: " - = f.collection_select(:distributor_id_eq, @distributors, :id, :name, {:include_blank => 'All'}, {:class => "select2 fullwidth"}) - = label_tag nil, "Report Type: " + = label_tag nil, t(:report_distributor) + = f.collection_select(:distributor_id_eq, @distributors, :id, :name, {:include_blank => t(:report_all)}, {:class => "select2 fullwidth"}) + = label_tag nil, t(:report_customers_type) %br - = select_tag(:report_type, options_for_select([['Payments By Type',:payments_by_payment_type],['Itemised Payment Totals',:itemised_payment_totals],['Payment Totals',:payment_totals]], @report_type)) + = select_tag(:report_type, options_for_select([[t(:report_payment_by),:payments_by_payment_type],[t(:report_itemised_payment),:itemised_payment_totals],[t(:report_payment_totals),:payment_totals]], @report_type)) %br %br = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) %br %br = button t(:search) diff --git a/app/views/spree/admin/reports/products_and_inventory.html.haml b/app/views/spree/admin/reports/products_and_inventory.html.haml index c3470e6047..40c4fbfccf 100644 --- a/app/views/spree/admin/reports/products_and_inventory.html.haml +++ b/app/views/spree/admin/reports/products_and_inventory.html.haml @@ -2,33 +2,33 @@ %br .row .four.columns.alpha - = label_tag nil, "Distributor: " + = label_tag nil, t(:report_distributor) = select_tag(:distributor_id, options_from_collection_for_select(@distributors, :id, :name, params[:distributor_id]), {:include_blank => true, :class => "select2 fullwidth"}) - + .four.columns - = label_tag nil, "Supplier: " + = label_tag nil, t(:report_customers_supplier) = select_tag(:supplier_id, options_from_collection_for_select(@suppliers, :id, :name, params[:supplier_id]), {:include_blank => true, :class => "select2 fullwidth"}) - + .six.columns - = label_tag nil, "Order Cycle: " + = label_tag nil, t(:report_order_cycle) = select_tag(:order_cycle_id, options_for_select(report_order_cycle_options(@order_cycles), params[:order_cycle_id]), {:include_blank => true, :class => "select2 fullwidth"}) - = label_tag nil, "Report Type: " + = label_tag nil, t(:report_type) %br = select_tag(:report_type, options_for_select(@report_types, params[:report_type])) %br %br = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) %br = button t(:search) %br diff --git a/app/views/spree/admin/reports/sales_tax.html.haml b/app/views/spree/admin/reports/sales_tax.html.haml index b0a115a74b..9a5cb9e533 100644 --- a/app/views/spree/admin/reports/sales_tax.html.haml +++ b/app/views/spree/admin/reports/sales_tax.html.haml @@ -3,10 +3,10 @@ .row .four.columns.alpha - = label_tag nil, "Distributor:" + = label_tag nil, t(:report_distributor) = f.collection_select(:distributor_id_eq, @distributors, :id, :name, {:include_blank => 'All'}, {:class => "select2 fullwidth"}) = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) %br = button t(:search) diff --git a/app/views/spree/admin/reports/users_and_enterprises.html.haml b/app/views/spree/admin/reports/users_and_enterprises.html.haml index 6820ee04b1..1b57373c38 100644 --- a/app/views/spree/admin/reports/users_and_enterprises.html.haml +++ b/app/views/spree/admin/reports/users_and_enterprises.html.haml @@ -1,10 +1,10 @@ = form_tag spree.users_and_enterprises_admin_reports_url do |f| .row - .alpha.two.columns= label_tag nil, "Enterprises: " + .alpha.two.columns= label_tag nil, t(:report_entreprises) .omega.fourteen.columns= select_tag(:enterprise_id_in, options_from_collection_for_select(Enterprise.all, :id, :name, params[:enterprise_id_in].andand.split(",")), {class: "select2 fullwidth", multiple: true}) .row - .alpha.two.columns= label_tag nil, "Users: " + .alpha.two.columns= label_tag nil, t(:report_users) .omega.fourteen.columns= select_tag(:user_id_in, options_from_collection_for_select(Spree::User.all, :id, :email, params[:user_id_in].andand.split(",")), {class: "select2 fullwidth", multiple: true}) -# Might need this later if we add different kinds of reports @@ -14,7 +14,7 @@ .row = check_box_tag :csv - = label_tag :csv, "Download as csv" + = label_tag :csv, t(:report_customers_csv) .row = button t(:search) %br diff --git a/app/views/spree/admin/reports/xero_invoices.html.haml b/app/views/spree/admin/reports/xero_invoices.html.haml index eca51fed4f..8669089f81 100644 --- a/app/views/spree/admin/reports/xero_invoices.html.haml +++ b/app/views/spree/admin/reports/xero_invoices.html.haml @@ -2,31 +2,31 @@ = render 'date_range_form', f: f .row - .four.columns.alpha= label_tag :report_type, "Report Type: " + .four.columns.alpha= label_tag :report_type, t(:report_type) .four.columns.omega= select_tag :report_type, options_for_select(xero_report_types, params[:report_type]), {include_blank: false, class: "select2 fullwidth"} .row - .four.columns.alpha= label_tag nil, "Hub: " + .four.columns.alpha= label_tag nil, t(:report_hubs) .four.columns.omega= f.collection_select(:distributor_id_eq, @distributors, :id, :name, {:include_blank => 'All'}, {:class => "select2 fullwidth"}) .row - .four.columns.alpha= label_tag nil, "Order Cycle: " + .four.columns.alpha= label_tag nil, t(:report_order_cycle) .four.columns.omega= f.select(:order_cycle_id_eq, options_for_select(report_order_cycle_options(@order_cycles), params[:q][:order_cycle_id_eq]), {:include_blank => true}, {:class => "select2 fullwidth"}) .row - .four.columns.alpha= label_tag :initial_invoice_number, "Initial invoice number:" + .four.columns.alpha= label_tag :initial_invoice_number, t(:initial_invoice_number) .twelve.columns.omega= text_field_tag :initial_invoice_number, params[:initial_invoice_number] .row - .four.columns.alpha= label_tag :invoice_date, "Invoice date:" + .four.columns.alpha= label_tag :invoice_date, t(:invoice_date) .twelve.columns.omega= text_field_tag :invoice_date, params[:invoice_date], class: 'datetimepicker' .row - .four.columns.alpha= label_tag :due_date, "Due date:" + .four.columns.alpha= label_tag :due_date, t(:due_date) .twelve.columns.omega= text_field_tag :due_date, params[:due_date], class: 'datetimepicker' .row - .four.columns.alpha= label_tag :account_code, "Account code:" + .four.columns.alpha= label_tag :account_code, t(:account_code) .twelve.columns.omega= text_field_tag :account_code, params[:account_code] .row - .four.columns.alpha= label_tag :csv, "Download as CSV:" + .four.columns.alpha= label_tag :csv, t(:report_customers_csv) .twelve.columns.omega= check_box_tag :csv .row .four.columns.alpha= button t(:search) diff --git a/app/views/spree/admin/shared/_address_form_simple.html.haml b/app/views/spree/admin/shared/_address_form_simple.html.haml index 3b8f756d88..36f49bf384 100644 --- a/app/views/spree/admin/shared/_address_form_simple.html.haml +++ b/app/views/spree/admin/shared/_address_form_simple.html.haml @@ -1,18 +1,24 @@ %tr{"data-hook" => "address1"} - %td Address: + %td + = t(:admin_shared_address_1): %td= f.text_field :address1 -%tr{"data-hook" => "address2"} - %td Address (cont.): +%tr{"data-hook" => "address2" } + %td + = t(:admin_shared_address_2): %td= f.text_field :address2 -%tr{"data-hook" => "city"} - %td City: +%tr{"data-hook" => "city" } + %td + = t(:admin_share_city): %td= f.text_field :city -%tr{"data-hook" => "zipcode"} - %td Postcode: +%tr{"data-hook" => "zipcode" } + %td + = t(:admin_share_zipcode): %td= f.text_field :zipcode -%tr{"data-hook" => "country"} - %td Country: +%tr{"data-hook" => "country" } + %td + = t(:admin_share_country): %td= f.collection_select(:country_id, available_countries, :id, :name) -%tr{"data-hook" => "state"} - %td State: +%tr{"data-hook" => "state" } + %td + = t(:admin_share_state): %td= f.collection_select(:state_id, f.object.country.states, :id, :name) diff --git a/app/views/spree/admin/shared/_hubs_sidebar.html.haml b/app/views/spree/admin/shared/_hubs_sidebar.html.haml index 23c536402b..75ef9bb32f 100644 --- a/app/views/spree/admin/shared/_hubs_sidebar.html.haml +++ b/app/views/spree/admin/shared/_hubs_sidebar.html.haml @@ -1,8 +1,9 @@ - hubs_color = @hubs.count > 0 ? "blue" : "red" -- hubs_color = 'red' if (controller.action_name == 'create' || controller.action_name == 'update') && @object.errors.full_messages.include?("At least one hub must be selected") +- hubs_color = 'red' if (controller.action_name == 'create' || controller.action_name == 'update') && @object.errors.full_messages.include?(t(:hub_sidebar_at_least)) .sidebar_item.omega.four.columns#hubs .four.columns.alpha.header{ class: "#{hubs_color}" } - %span.four.columns.alpha.centered Hubs + %span.four.columns.alpha.centered + = t(:hub_sidebar_hubs) .four.columns.alpha.list{ class: "#{hubs_color}" } - if @hubs.count > 0 = hidden_field klass, :distributor_ids, :multiple => true, value: nil @@ -17,9 +18,10 @@ %span.icon-arrow-right - else .four.columns.alpha.list-item - %span.three.columns.alpha None Available + %span.three.columns.alpha + = t(:hub_sidebar_none_available) %span.one.column.omega %span.icon-remove-sign %a.four.columns.alpha.button{ href: "#{main_app.admin_enterprises_path}", class: "#{hubs_color}" } - MANAGE + = t(:hub_sidebar_manage) %span.icon-arrow-right diff --git a/app/views/spree/admin/shared/_trial_progress_bar.html.haml b/app/views/spree/admin/shared/_trial_progress_bar.html.haml index abffdbd6ad..999dd9a13f 100644 --- a/app/views/spree/admin/shared/_trial_progress_bar.html.haml +++ b/app/views/spree/admin/shared/_trial_progress_bar.html.haml @@ -1,7 +1,7 @@ - if enterprise -if shop_trial_in_progress?(enterprise) #trial_progress_bar - = "Your shopfront trial expires in #{remaining_trial_days(enterprise)}." + = t(:shop_trial_in_progress) -elsif shop_trial_expired?(enterprise) #trial_progress_bar - = "Good news! We have decided to extend shopfront trials until further notice (probably around March 2015)." \ No newline at end of file + = t(:shop_trial_expired) \ No newline at end of file diff --git a/app/views/spree/admin/variants/_autocomplete.js.erb b/app/views/spree/admin/variants/_autocomplete.js.erb index 7b52c0a716..41b0e84550 100644 --- a/app/views/spree/admin/variants/_autocomplete.js.erb +++ b/app/views/spree/admin/variants/_autocomplete.js.erb @@ -17,7 +17,7 @@ {{#if variant.option_values}} diff --git a/app/views/spree/users/_fat.html.haml b/app/views/spree/users/_fat.html.haml new file mode 100644 index 0000000000..c10cf8254a --- /dev/null +++ b/app/views/spree/users/_fat.html.haml @@ -0,0 +1,29 @@ +.row{"ng-if" => "open()"} + .columns.small-12.fat + %table + %tr + %th.order1= t :transaction + %th.order2= t :transaction_date + %th.order3.show-for-large-up= t :payment_state + %th.order4.show-for-large-up= t :shipping_state + %th.order5.text-right= t :value + %th.order6.text-right.show-for-large-up= t :outstanding_balance + %th.order7.text-right= t :running_balance + %tbody.transaction-group{"ng-repeat" => "order in distributor.distributed_orders", "ng-class-odd"=>"'odd'", "ng-class-even"=>"'even'"} + %tr.order-row + %td.order1 + %a{"bo-href" => "order.path", "bo-text" => "('order' | t )+ ' ' + order.number"} + %td.order2{"bo-text" => "order.completed_at"} + %td.order3.show-for-large-up{"bo-text" => "'spree.payment_states.' + order.payment_state | t | capitalize"} + %td.order4.show-for-large-up{"bo-text" => "'spree.shipment_states.' + order.shipment_state | t | capitalize"} + %td.order5.text-right{"ng-class" => "{'credit' : order.total < 0, 'debit' : order.total > 0, 'paid' : order.total == 0}","bo-text" => "order.total | localizeCurrency"} + %td.order6.text-right.show-for-large-up{"ng-class" => "{'credit' : order.outstanding_balance < 0, 'debit' : order.outstanding_balance > 0, 'paid' : order.outstanding_balance == 0}", "bo-text" => "order.outstanding_balance | localizeCurrency"} + %td.order7.text-right{"ng-class" => "{'credit' : order.running_balance < 0, 'debit' : order.running_balance > 0, 'paid' : order.running_balance == 0}", "bo-text" => "order.running_balance | localizeCurrency"} + %tr.payment-row{"ng-repeat" => "payment in order.payments"} + %td.order1= t :payment + %td.order2{"bo-text" => "payment.updated_at"} + %td.order3.show-for-large-up{"bo-text" => "payment.payment_method"} + %td.order4.show-for-large-up + %td.order5.text-right{"ng-class" => "{'credit' : payment.amount > 0, 'debit' : payment.amount < 0, 'paid' : payment.amount == 0}","bo-text" => "payment.amount | localizeCurrency"} + %td.order6.show-for-large-up + %td.order7 diff --git a/app/views/spree/users/_skinny.html.haml b/app/views/spree/users/_skinny.html.haml new file mode 100644 index 0000000000..14c04f024a --- /dev/null +++ b/app/views/spree/users/_skinny.html.haml @@ -0,0 +1,12 @@ +.row.active_table_row.skinny-head.margin-top{"ng-click" => "toggle($event)", "ng-class" => "{'closed' : !open()}"} + .columns.small-2 + %span.margin-top + %img.account-logo{"logo-fallback" => true, "ng-src" => "{{distributor.logo}}"} + .columns.small-10.medium-5 + %span.margin-top + %strong{"bo-text" => "distributor.name"} + .columns.small-8.small-offset-2.medium-3.text-right + %span.margin-top.distributor-balance{"bo-text" => "distributor.balance | formatBalance", "ng-class" => "{'credit' : distributor.balance < 0, 'debit' : distributor.balance > 0, 'paid' : distributor.balance == 0}" } + .columns.small-2.medium-2.text-right + %span.margin-top + %i{"ng-class" => "{'ofn-i_005-caret-down' : !open(), 'ofn-i_006-caret-up' : open()}"} diff --git a/app/views/spree/users/show.html.haml b/app/views/spree/users/show.html.haml index 878d271e42..83171daf0d 100644 --- a/app/views/spree/users/show.html.haml +++ b/app/views/spree/users/show.html.haml @@ -1,34 +1,24 @@ .darkswarm + = inject_orders_by_distributor + .row.pad-top .small-12.columns.pad-top - %h1= accurate_title + %h2= accurate_title .account-summary{"data-hook" => "account_summary"} - %dl#user-info - %dt= t(:email) - %dd - = @user.email - (#{link_to t(:edit), spree.edit_account_path}) - .account-my-orders{"data-hook" => "account_my_orders"} - %h3= t(:my_orders) - - if @orders.present? - %table.order-summary - %thead - %tr - %th.order-number= t(:order_number) - %th.order-date= t(:order_date) - %th.order-status= t(:status) - %th.order-payment-state= t(:payment_state) - %th.order-shipment-state= t(:shipment_state) - %th.order-total= t(:total) - %tbody - - @orders.each do |order| - %tr{class: cycle('even', 'odd')} - %td.order-number= link_to order.number, order_url(order) - %td.order-date= l order.completed_at.to_date - %td.order-status= t(order.state).titleize - %td.order-payment-state= t("payment_states.#{order.payment_state}") if order.payment_state - %td.order-shipment-state= t("shipment_states.#{order.shipment_state}") if order.shipment_state - %td.order-total= money order.total - - else - %p= t(:you_have_no_orders_yet) - %br/ + = @user.email + (#{link_to t(:edit), spree.edit_account_path}) + %h3= t(:my_orders) + .orders{"ng-controller" => "OrdersCtrl", "ng-cloak" => true} + .row{bindonce: true} + .small-12.columns + .active_table + %distributor.active_table_node.row.animate-repeat{"ng-if" => "Orders.orders_by_distributor.length > 0", "ng-repeat" => "(key, distributor) in Orders.orders_by_distributor", + "ng-controller" => "DistributorNodeCtrl", + "ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !distributor.active}", + id: "{{distributor.hash}}"} + .small-12.columns + = render partial: "spree/users/skinny" + = render partial: "spree/users/fat" + .message{"ng-if" => "Orders.orders_by_distributor.length == 0", "bo-text" => "'you_have_no_orders_yet' | t"} + + = render partial: "shared/footer" diff --git a/config/locales/en.yml b/config/locales/en.yml index 95c4e0b92a..6b67eb4091 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -31,8 +31,8 @@ en: welcome_to: 'Welcome to ' site_meta_description: "We begin from the ground up. With farmers and growers ready to tell their stories proudly and truly. With distributors ready to connect people with products fairly and honestly. With buyers who believe that better weekly shopping decisions can…" search_by_name: Search by name or suburb... - producers: Aussie Producers - producers_join: Australian producers are now welcome to join the Open Food Network. + producers: 'Australian Producers' + producers_join: Australian producers are now welcome to join the Open Food Network. #FIXME charges_sales_tax: Charges GST? print_invoice: "Print Invoice" send_invoice: "Send Invoice" @@ -128,12 +128,12 @@ en: invoice_column_tax: "GST" invoice_column_price: "Price" - logo: "Logo (640x130)" - logo_mobile: "Mobile logo (75x26)" - logo_mobile_svg: "Mobile logo (SVG)" + logo: "Logo (640x130)" #FIXME + logo_mobile: "Mobile logo (75x26)" #FIXME + logo_mobile_svg: "Mobile logo (SVG)" #FIXME home_hero: "Hero image" home_show_stats: "Show statistics" - footer_logo: "Logo (220x76)" + footer_logo: "Logo (220x76)" #FIXME footer_facebook_url: "Facebook URL" footer_twitter_url: "Twitter URL" footer_instagram_url: "Instagram URL" @@ -176,7 +176,7 @@ en: label_administration: "Administration" label_admin: "Admin" label_account: "Account" - label_more: "More" + label_more: "Show more" label_less: "Show less" label_notices: "Notices" @@ -303,6 +303,25 @@ en: order_payment_paypal_successful: Your payment via PayPal has been processed successfully. order_hub_info: Hub Info + bom_tip: "Use this page to alter product quantities across multiple orders. Products may also be removed from orders entirely, if required." + bom_shared: "Shared Resource?" + bom_page_title: "Bulk Order Management" + bom_no: "Order no." + bom_date: "Order date" + bom_cycle: "Order cycle" + bom_max: "Max" + bom_hub: "Hub" + bom_variant: "Product: Unit" + bom_final_weigth_volume: "Weight/Volume" + bom_quantity: "Quantity" + bom_actions_delete: "Delete Selected" + bom_loading: "Loading orders" + bom_no_results: "No orders found." + bom_order_error: "Some errors must be resolved before you can update orders.\nAny fields with red borders contain errors." + + unsaved_changes_warning: "Unsaved changes exist and will be lost if you continue." + unsaved_changes_error: "Fields with red borders contain errors." + products: "Products" products_in: "in %{oc}" products_at: "at %{distributor}" @@ -406,6 +425,11 @@ See the %{link} to find out more about %{sitename}'s features and to start using products_cart_empty: "Cart empty" products_edit_cart: "Edit your cart" products_from: from + products_change: "No changes to save." + products_update_error: "Saving failed with the following error(s):" + products_update_error_msg: "Saving failed." + products_update_error_data: "Save failed due to invalid data:" + products_changes_saved: "Changes saved." search_no_results_html: "Sorry, no results found for %{query}. Try another search?" @@ -420,6 +444,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using groups_search: "Search name or keyword" groups_no_groups: "No groups found" groups_about: "About Us" + groups_producers: "Our producers" groups_hubs: "Our hubs" groups_contact_web: Contact @@ -507,13 +532,26 @@ See the %{link} to find out more about %{sitename}'s features and to start using producers_signup_cta_headline: Join now! producers_signup_cta_action: Join now producers_signup_detail: Here's the detail. + producer: Producer products_item: Item products_description: Description products_variant: Variant products_quantity: Quantity products_availabel: Available? - products_price: Price + products_producer: "Producer" + products_price: "Price" + products_sku: "SKU" + products_name: "name" + products_unit: "unit" + products_on_hand: "on hand" + products_on_demand: "On demand?" + products_category: "Category" + products_tax_category: "tax category" + products_available_on: "Available On" + products_inherit: "Inherit?" + products_inherits_properties: "Inherits Properties?" + products_stock_level_reset: "Enable Stock Level Reset?" register_title: Register @@ -559,7 +597,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using products_oc_is: "Your order cycle for this order is %{name}." products_oc_error: "Please complete your order from %{link} before shopping in a different order cycle." products_oc_current: "your current order cycle" - products_quantity: Quantity products_max_quantity: Max quantity products_distributor: Distributor products_distributor_info: When you select a distributor for your order, their address and pickup times will be displayed here. @@ -728,7 +765,7 @@ Please follow the instructions there to make your enterprise visible on the Open shop_variant_quantity_max: "max" contact: "Contact" follow: "Follow" - shop_for_products_html: "Shop for %{enterprise} products at:" + shop_for_products_html: "Shop for %{enterprise} products at:" #FIXME change_shop: "Change shop to:" shop_at: "Shop now at:" price_breakdown: "Full price breakdown" @@ -740,3 +777,252 @@ Please follow the instructions there to make your enterprise visible on the Open price_graph: "Price graph" included_tax: "Included tax" remove_tax: "Remove tax" + balance: "Balance" + transaction: "Transaction" + transaction_date: "Date" #Transaction is only in key to avoid conflict with :date + payment_state: "Payment status" + shipping_state: "Shipping status" + value: "Value" + balance_due: "Balance due" + credit: "Credit" + Paid: "Paid" + Ready: "Ready" + you_have_no_orders_yet: "You have no orders yet" + running_balance: "Running balance" + outstanding_balance: "Outstanding balance" + admin_entreprise_relationships: "Enterprise Relationships" + admin_entreprise_relationships_everything: "Everything" + admin_entreprise_relationships_permits: "permits" + admin_entreprise_relationships_seach_placeholder: "Search" + admin_entreprise_relationships_button_create: "Create" + admin_entreprise_groups: "Enterprise Groups" + admin_entreprise_groups_name: "Name" + admin_entreprise_groups_owner: "Owner" + admin_entreprise_groups_on_front_page: "On front page ?" + admin_entreprise_groups_entreprise: "Enterprises" + admin_entreprise_groups_primary_details: "Primary Details" + admin_entreprise_groups_data_powertip: "The primary user responsible for this group." + admin_entreprise_groups_data_powertip_logo: "This is the logo for the group" + admin_entreprise_groups_data_powertip_promo_image: "This image is displayed at the top of the Group profile" + admin_entreprise_groups_about: "About" + admin_entreprise_groups_images: "Images" + admin_entreprise_groups_contact: "Contact" + admin_entreprise_groups_contact_phone_placeholder: "eg. 98 7654 3210" + admin_entreprise_groups_contact_address1_placeholder: "eg. 123 High Street" + admin_entreprise_groups_contact_city: "Suburb" + admin_entreprise_groups_contact_city_placeholder: "eg. Northcote" + admin_entreprise_groups_contact_zipcode: "Postcode" + admin_entreprise_groups_contact_zipcode_placeholder: "eg. 3070" + admin_entreprise_groups_contact_state_id: "State" + admin_entreprise_groups_contact_country_id: "Country" + admin_entreprise_groups_web: "Web Resources" + admin_entreprise_groups_web_twitter: "eg. @the_prof" + admin_entreprise_groups_web_website_placeholder: "eg. www.truffles.com" + admin_order_cycles: "Admin Order Cycles" + open: "Open" + close: "Close" + supplier: "Supplier" + coordinator: "Coordinator" + distributor: "Distributor" + product: "Products" + enterprise_fees: "Enterprise Fees" + fee_type: "Fee Type" + tax_category: "Tax Category" + calculator: "Calculator" + calculator_values: "Calculator values" + new_order_cycles: "New Order Cycles" + select_a_coordinator_for_your_order_cycle: "select a coordinator for your order cycle" + edit_order_cycle: "Edit Order Cycle" + roles: "Roles" + update: "Update" + add_producer_property: "Add producer property" + admin_settings: "Settings" + update_invoice: "Update Invoices" + finalise_invoice: "Finalise Invoices" + finalise_user_invoices: "Finalise User Invoices" + finalise_user_invoice_explained: "Use this button to finalize all invoices in the system for the previous calendar month. This task can be set up to run automatically once a month." + manually_run_task: "Manually Run Task " + update_user_invoices: "Update User Invoices" + update_user_invoice_explained: "Use this button to immediately update invoices for the month to date for each enterprise user in the system. This task can be set up to run automatically every night." + auto_finalise_invoices: "Auto-finalise invoices monthly on the 2nd at 1:30am" + auto_update_invoices: "Auto-update invoices nightly at 1:00am" + in_progress: "In Progress" + started_at: "Started at" + queued: "Queued" + scheduled_for: "Scheduled for" + customers: "Customers" + please_select_hub: "Please select a Hub" + loading_customers: "Loading Customers" + no_customers_found: "No customers found" + go: "Go" + hub: "Hub" + accounts_administration_distributor: "accounts administration distributor" + admin_accounts_and_billing: "admin.accounts_and_billing_settings" #FIXME + producer: "Producer" + product: "Product" + price: "Price" + on_hand: "On hand" + save_changes: "Save Changes" + update_action: "update()" #FIXME + spree_admin_overview_enterprises_header: "My Enterprises" + spree_admin_overview_enterprises_footer: "MANAGE MY ENTERPRISES" + spree_admin_enterprises_hubs_name: "Name" + spree_admin_enterprises_create_new: "CREATE NEW" + spree_admin_enterprises_shipping_methods: "Shipping Methods" + spree_admin_enterprises_fees: "Enterprise Fees" + spree_admin_enterprises_none_create_a_new_enterprise: "CREATE A NEW ENTERPRISE" + spree_admin_enterprises_none_text: "You don't have any enterprises yet" + spree_admin_enterprises_producers_name: "Name" + spree_admin_enterprises_producers_total_products: "Total Products" + spree_admin_enterprises_producers_active_products: "Active Products" + spree_admin_enterprises_producers_order_cycles: "Products in OCs" + spree_admin_enterprises_producers_order_cycles_title: "" + spree_admin_enterprises_tabs_hubs: "HUBS" + spree_admin_enterprises_tabs_producers: "PRODUCERS" + spree_admin_enterprises_producers_manage_order_cycles: "MANAGE ORDER CYCLES" + spree_admin_enterprises_producers_manage_products: "MANAGE PRODUCTS" + spree_admin_enterprises_producers_orders_cycle_text: "You don't have any active order cycles." + spree_admin_enterprises_any_active_products_text: "You don't have any active products." + spree_admin_enterprises_create_new_product: "CREATE A NEW PRODUCT" + spree_admin_order_cycles: "Order Cycles" + spree_admin_order_cycles_tip: "Order cycles determine when and where your products are available to customers." + dashbord: "Dashboard" + spree_admin_single_enterprise_alert_mail_confirmation: "Please confirm the email address for" + spree_admin_single_enterprise_alert_mail_sent: "We've sent an email to" + spree_admin_overview_action_required: "Action Required" + spree_admin_overview_check_your_inbox: "Please check you inbox for furher instructions. Thanks!" + change_package: "Change Package" + spree_admin_single_enterprise_hint: "Hint: To allow people to find you, turn on your visibility under" + your_profil_live: "Your profile live" + on_ofn_map: "on the Open Food Network map" + see: "See" + live: "live" + manage: "Manage" + resend: "Resend" + add_and_manage_products: "Add & manage products" + add_and_manage_order_cycles: "Add & manage order cycles" + manage_order_cycles: "Manage order cycles" + manage_products: "Manage products" + edit_profile_details: "Edit profile details" + edit_profile_details_etc: "Change your profile description, images, etc." + start_date: "Start Date" + end_date: "End Date" + order_cycle: "Order Cycle" + group_buy_unit_size: "Group Buy Unit Size" + total_qtt_ordered: "Total Quantity Ordered" + max_qtt_ordered: "Max Quantity Ordered" + current_fulfilled_units: "Current Fulfilled Units" + max_fulfilled_units: "Max Fulfilled Units" + bulk_management_warning: "WARNING: Some variants do not have a unit value" + ask: "Ask?" + no_orders_found: "No orders found." + order_no: "Order No." + weight_volume: "Weight/Volume" + remove_tax: "Remove tax" + tax_settings: "Tax Settings" + products_require_tax_category: "products require tax category" + admin_shared_address_1: "Address" + admin_shared_address_2: "Address (cont.)" + admin_share_city: "City" + admin_share_zipcode: "Postcode" + admin_share_country: "Country" + admin_share_state: "State" + hub_sidebar_hubs: "Hubs" + hub_sidebar_none_available: "None Available" + hub_sidebar_manage: "Manage" + hub_sidebar_at_least: "At least one hub must be selected" + hub_sidebar_blue: "blue" + hub_sidebar_red: "red" + shop_trial_in_progress: "Your shopfront trial expires in #{remaining_trial_days(enterprise)}." #FIXME + shop_trial_expired: "Good news! We have decided to extend shopfront trials until further notice (probably around March 2015)." #FIXME + report_customers_distributor: "Distributor" + report_customers_supplier: "Supplier" + report_customers_cycle: "Order Cycle" + report_customers_type: "Report Type" + report_customers_csv: "Download as csv" + report_customers_header: "orders header" + report_producers: "Producers: " + report_type: "Report Type: " + report_hubs: "Hubs: " + report_payment: "Payment Methods: " + report_distributor: "Distributor: " + report_payment_by: 'Payments By Type' + report_itemised_payment: 'Itemised Payment Totals' + report_payment_totals: 'Payment Totals' + report_all: 'all' + report_order_cycle: "Order Cycle: " + report_product_header: "products_header" + report_order_header: "orders_header" + report_entreprises: "Enterprises: " + report_users: "Users: " + initial_invoice_number: "Initial invoice number:" + invoice_date: "Invoice date:" + due_date: "Due date:" + account_code: "Account code:" + equals: "Equals" + contains: "contains" + filter_products: "Filter Products" + delete_product_variant: "The last variant cannot be deleted!" + progress: "progress" + saving: "Saving.." + success: "success" + failure: "failure" + unsaved_changes_confirmation: "Unsaved changes will be lost. Continue anyway?" + one_product_unsaved: "Changes to one product remain unsaved." + products_unsaved: "Changes to %{n} products remain unsaved." + add_manager: "Add a manager" + is_already_manager: "is already a manager!" + no_change_to_save: " No change to save" + add_manager: "Add a manager" + users: "Users" + about: "About" + images: "Images" + contact: "Contact" + web: "Web" + primary_details: "Primary Details" + adrdress: "Address" + contact: "Contact" + social: "Social" + business_details: "Business Details" + properties: "Properties" + shipping_methods: "Shipping Methods" + payment_methods: "Payment Methods" + enterprise_fees: "Enterprise Fees" + inventory_settings: "Inventory Settings" + shop_preferences: "Shop Preferences" + validation_msg_relationship_already_established: "^That relationship is already established." + validation_msg_at_least_one_hub: "^At least one hub must be selected" + validation_msg_product_category_cant_be_blank: "^Product Category cant be blank" + validation_msg_tax_category_cant_be_blank: "^Tax Category can't be blank" + validation_msg_is_associated_with_an_exising_customer: "is associated with an existing customer" + + spree: + shipment_states: + backorder: backorder + partial: partial + pending: pending + ready: ready + shipped: shipped + payment_states: + balance_due: balance due + completed: completed + checkout: checkout + credit_owed: credit owed + failed: failed + paid: paid + pending: pending + processing: processing + void: void + order_state: + address: address + adjustments: adjustments + awaiting_return: awaiting return + canceled: canceled + cart: cart + complete: complete + confirm: confirm + delivery: delivery + payment: payment + resumed: resumed + returned: returned + skrill: skrill diff --git a/spec/factories.rb b/spec/factories.rb index 2e479696b4..8b06b67cad 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -217,6 +217,26 @@ FactoryGirl.define do distributor { create(:distributor_enterprise) } end + factory :order_with_credit_payment, parent: :completed_order_with_totals do + distributor { create(:distributor_enterprise)} + order_cycle { create(:simple_order_cycle) } + + after(:create) do |order| + create(:payment, amount: order.total + 10000, order: order, state: "completed") + order.reload + end + end + + factory :order_without_full_payment, parent: :completed_order_with_totals do + distributor { create(:distributor_enterprise)} + order_cycle { create(:simple_order_cycle) } + + after(:create) do |order| + create(:payment, amount: order.total - 1, order: order, state: "completed") + order.reload + end + end + factory :zone_with_member, :parent => :zone do default_tax true diff --git a/spec/features/admin/bulk_order_management_spec.rb b/spec/features/admin/bulk_order_management_spec.rb index 767274b274..0b23e77f6c 100644 --- a/spec/features/admin/bulk_order_management_spec.rb +++ b/spec/features/admin/bulk_order_management_spec.rb @@ -159,6 +159,7 @@ feature %q{ first("div#columns-dropdown", :text => "COLUMNS").click first("div#columns-dropdown div.menu div.menu_item", text: "Weight/Volume").click first("div#columns-dropdown div.menu div.menu_item", text: "Price").click + # hide dropdown first("div#columns-dropdown", :text => "COLUMNS").click within "tr#li_#{li1.id}" do expect(page).to have_field "price", with: "$50.00" diff --git a/spec/features/consumer/account_spec.rb b/spec/features/consumer/account_spec.rb new file mode 100644 index 0000000000..b072a24357 --- /dev/null +++ b/spec/features/consumer/account_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +feature %q{ + As a consumer + I want to view my order history with each hub + and view any outstanding balance. +}, js: true do + include UIComponentHelper + include AuthenticationWorkflow + let!(:user) { create(:user)} + let!(:user2) {create(:user)} + let!(:distributor1) { create(:distributor_enterprise) } + let!(:distributor2) { create(:distributor_enterprise) } + let!(:distributor_credit) { create(:distributor_enterprise) } + let!(:distributor_without_orders) { create(:distributor_enterprise) } + let!(:d1o1) { create(:completed_order_with_totals, distributor_id: distributor1.id, user_id: user.id, total: 10000)} + let!(:d1o2) { create(:order_without_full_payment, distributor_id: distributor1.id, user_id: user.id, total: 5000)} + let!(:d2o1) { create(:completed_order_with_totals, distributor_id: distributor2.id, user_id: user.id)} + let!(:credit_order) { create(:order_with_credit_payment, distributor_id: distributor_credit.id, user_id: user.id)} +# let!(:credit_payment) { create(:payment, amount: 12000.00, order_id: credit_order.id)} + + + before do + credit_order.update! + login_as user + visit "/account" + end + + it "shows all hubs that have been ordered from with balance or credit" do + expect(page).to have_content distributor1.name + expect(page).to have_content distributor2.name + expect(page).not_to have_content distributor_without_orders.name + expect(page).to have_content distributor1.name + " " + "Balance due" + expect(page).to have_content distributor_credit.name + " Credit" + end + + it "reveals table of orders for distributors when clicked" do + expand_active_table_node distributor1.name + expect(page).to have_link "Order " + d1o1.number, href:"/orders/#{d1o1.number}" + + expand_active_table_node distributor2.name + expect(page).not_to have_content "Order " + d1o1.number.to_s + end + + context "for a user without orders" do + before do + login_as user2 + visit "/account" + end + + it "displays an appropriate message" do + expect(page).to have_content {t :you_have_no_orders_yet} + end + end + +end diff --git a/spec/helpers/injection_helper_spec.rb b/spec/helpers/injection_helper_spec.rb index 362ca6479b..0eecdeeaf9 100644 --- a/spec/helpers/injection_helper_spec.rb +++ b/spec/helpers/injection_helper_spec.rb @@ -3,6 +3,13 @@ require 'spec_helper' describe InjectionHelper do let!(:enterprise) { create(:distributor_enterprise, facebook: "roger") } + let!(:distributor1) { create(:distributor_enterprise) } + let!(:distributor2) { create(:distributor_enterprise) } + let!(:user) { create(:user)} + let!(:d1o1) { create(:completed_order_with_totals, distributor: distributor1, user_id: user.id, total: 10000)} + let!(:d1o2) { create(:completed_order_with_totals, distributor: distributor1, user_id: user.id, total: 5000)} + let!(:d2o1) { create(:completed_order_with_totals, distributor: distributor2, user_id: user.id)} + it "will inject via AMS" do helper.inject_json_ams("test", [enterprise], Api::IdSerializer).should match /#{enterprise.id}/ end @@ -42,8 +49,4 @@ describe InjectionHelper do helper.inject_taxons.should match taxon.name end - it "injects taxons" do - taxon = create(:taxon) - helper.inject_taxons.should match taxon.name - end end diff --git a/spec/models/spree/user_spec.rb b/spec/models/spree/user_spec.rb index 7fefd56afb..ee01326316 100644 --- a/spec/models/spree/user_spec.rb +++ b/spec/models/spree/user_spec.rb @@ -79,4 +79,43 @@ describe Spree.user_class do end end end + + describe "retrieving orders for /account page" do + let!(:u1) { create(:user) } + let!(:u2) { create(:user) } + let!(:distributor1) { create(:distributor_enterprise) } + let!(:distributor2) { create(:distributor_enterprise) } + let!(:d1o1) { create(:completed_order_with_totals, distributor: distributor1, user_id: u1.id)} + let!(:d1o2) { create(:completed_order_with_totals, distributor: distributor1, user_id: u1.id)} + let!(:d1_order_for_u2) { create(:completed_order_with_totals, distributor: distributor1, user_id: u2.id)} + let!(:d1o3) { create(:order, state: 'cart', distributor: distributor1, user_id: u1.id)} + let!(:d2o1) { create(:completed_order_with_totals, distributor: distributor2, user_id: u2.id)} + + let!(:completed_payment) { create(:payment, order: d1o1, state: 'completed')} + let!(:payment) { create(:payment, order: d1o2, state: 'invalid')} + + it "returns enterprises that the user has ordered from" do + expect(u1.enterprises_ordered_from).to eq [distributor1.id] + end + + it "returns orders and payments for the user, organised by distributor" do + expect(u1.orders_by_distributor).to include distributor1 + expect(u1.orders_by_distributor.first.distributed_orders).to include d1o1 + end + + it "doesn't return irrelevant distributors" do + expect(u1.orders_by_distributor).not_to include distributor2 + end + it "doesn't return other users' orders" do + expect(u1.orders_by_distributor.first.distributed_orders).not_to include d1_order_for_u2 + end + + it "doesn't return uncompleted orders" do + expect(u1.orders_by_distributor.first.distributed_orders).not_to include d1o3 + end + + it "doesn't return uncompleted payments" do + expect(u1.orders_by_distributor.first.distributed_orders.map{|o| o.payments}.flatten).not_to include payment + end + end end diff --git a/spec/serializers/enterprise_serializer_spec.rb b/spec/serializers/enterprise_serializer_spec.rb index f70852d973..f5eff4f771 100644 --- a/spec/serializers/enterprise_serializer_spec.rb +++ b/spec/serializers/enterprise_serializer_spec.rb @@ -1,4 +1,4 @@ -#require 'spec_helper' +require 'spec_helper' describe Api::EnterpriseSerializer do let(:serializer) { Api::EnterpriseSerializer.new enterprise, data: data } diff --git a/spec/serializers/order_serializer_spec.rb b/spec/serializers/order_serializer_spec.rb new file mode 100644 index 0000000000..2c327537eb --- /dev/null +++ b/spec/serializers/order_serializer_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe Api::OrderSerializer do + let(:serializer) { Api::OrderSerializer.new order } + let(:order) { create(:completed_order_with_totals) } + + + it "serializes an order" do + expect(serializer.to_json).to match order.number.to_s + end + + it "convert the state attributes to translatable keys" do + expect(serializer.to_json).to match "complete" + expect(serializer.to_json).to match "balance_due" + end + +end diff --git a/spec/serializers/orders_by_distributor_serializer_spec.rb b/spec/serializers/orders_by_distributor_serializer_spec.rb new file mode 100644 index 0000000000..5976e9ad48 --- /dev/null +++ b/spec/serializers/orders_by_distributor_serializer_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +describe Api::OrdersByDistributorSerializer do + + # Banged lets ensure entered into test database + let!(:distributor1) { create(:distributor_enterprise) } + let!(:distributor2) { create(:distributor_enterprise) } + let!(:user) { create(:user)} + let!(:d1o1) { create(:completed_order_with_totals, distributor: distributor1, user_id: user.id, total: 10000)} + let!(:d1o2) { create(:completed_order_with_totals, distributor: distributor1, user_id: user.id, total: 5000)} + let!(:d2o1) { create(:completed_order_with_totals, distributor: distributor2, user_id: user.id)} + + before do + @data = Enterprise.includes(:distributed_orders).where(enterprises: {id: user.enterprises_ordered_from }, spree_orders: {state: :complete, user_id: user.id}).to_a + @serializer = ActiveModel::ArraySerializer.new(@data, {each_serializer: Api::OrdersByDistributorSerializer}) + end + + it "serializes orders" do + expect(@serializer.to_json).to match "distributed_orders" + end + + it "serializes the balance for each distributor" do + expect(@serializer.serializable_array[0].keys).to include :balance + # Would be good to test adding up balance properly but can't get a non-zero total from the factories... + expect(@serializer.serializable_array[0][:balance]).to eq "0.00" + end + +end