diff --git a/.github/ISSUE_TEMPLATE/story-template.md b/.github/ISSUE_TEMPLATE/story-template.md index 48a1c33493..f3bfa62f54 100644 --- a/.github/ISSUE_TEMPLATE/story-template.md +++ b/.github/ISSUE_TEMPLATE/story-template.md @@ -7,12 +7,12 @@ assignees: '' --- -**## Description** +## Description -**## Acceptance Criteria** +## Acceptance Criteria diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 71812eb60a..fecfd46adc 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -22,9 +22,7 @@ Metrics/LineLength: Max: 100 Exclude: - - app/controllers/admin/accounts_and_billing_settings_controller.rb - app/controllers/admin/bulk_line_items_controller.rb - - app/controllers/admin/business_model_configuration_controller.rb - app/controllers/admin/cache_settings_controller.rb - app/controllers/admin/contents_controller.rb - app/controllers/admin/customers_controller.rb @@ -63,7 +61,6 @@ Metrics/LineLength: - app/controllers/stripe/callbacks_controller.rb - app/controllers/user_confirmations_controller.rb - app/helpers/admin/account_helper.rb - - app/helpers/admin/business_model_configuration_helper.rb - app/helpers/admin/injection_helper.rb - app/helpers/angular_form_builder.rb - app/helpers/angular_form_helper.rb @@ -79,16 +76,12 @@ Metrics/LineLength: - app/helpers/spree/admin/navigation_helper_decorator.rb - app/helpers/spree/admin/orders_helper_decorator.rb - app/helpers/spree/orders_helper.rb - - app/jobs/finalize_account_invoices.rb - app/jobs/products_cache_integrity_checker_job.rb - app/jobs/subscription_confirm_job.rb - app/jobs/subscription_placement_job.rb - - app/jobs/update_account_invoices.rb - - app/jobs/update_billable_periods.rb - app/mailers/producer_mailer.rb - app/mailers/spree/order_mailer_decorator.rb - app/mailers/subscription_mailer.rb - - app/models/billable_period.rb - app/models/column_preference.rb - app/models/content_configuration.rb - app/models/customer.rb @@ -160,11 +153,8 @@ Metrics/LineLength: - engines/web/app/helpers/web/cookies_policy_helper.rb - Gemfile - lib/discourse/single_sign_on.rb - - lib/open_food_network/accounts_and_billing_settings_validator.rb - lib/open_food_network/available_payment_method_filter.rb - - lib/open_food_network/bill_calculator.rb - lib/open_food_network/bulk_coop_report.rb - - lib/open_food_network/business_model_configuration_validator.rb - lib/open_food_network/customers_report.rb - lib/open_food_network/distribution_change_validator.rb - lib/open_food_network/enterprise_fee_applicator.rb @@ -201,7 +191,6 @@ Metrics/LineLength: - lib/tasks/dev.rake - lib/tasks/enterprises.rake - spec/archive/features/consumer/checkout_spec.rb - - spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb - spec/controllers/admin/bulk_line_items_controller_spec.rb - spec/controllers/admin/column_preferences_controller_spec.rb - spec/controllers/admin/customers_controller_spec.rb @@ -245,7 +234,6 @@ Metrics/LineLength: - spec/controllers/stripe/webhooks_controller_spec.rb - spec/controllers/user_confirmations_controller_spec.rb - spec/controllers/user_registrations_controller_spec.rb - - spec/features/admin/accounts_and_billing_settings_spec.rb - spec/features/admin/adjustments_spec.rb - spec/features/admin/bulk_order_management_spec.rb - spec/features/admin/bulk_product_update_spec.rb @@ -289,7 +277,6 @@ Metrics/LineLength: - spec/features/consumer/shopping/shopping_spec.rb - spec/features/consumer/shopping/variant_overrides_spec.rb - spec/features/consumer/shops_spec.rb - - spec/helpers/admin/business_model_configuration_helper_spec.rb - spec/helpers/admin/subscriptions_helper_spec.rb - spec/helpers/checkout_helper_spec.rb - spec/helpers/enterprises_helper_spec.rb @@ -298,12 +285,9 @@ Metrics/LineLength: - spec/helpers/order_cycles_helper_spec.rb - spec/helpers/spree/admin/base_helper_spec.rb - spec/jobs/confirm_order_job_spec.rb - - spec/jobs/finalize_account_invoices_spec.rb - spec/jobs/refresh_products_cache_job_spec.rb - spec/jobs/subscription_confirm_job_spec.rb - spec/jobs/subscription_placement_job_spec.rb - - spec/jobs/update_account_invoices_spec.rb - - spec/jobs/update_billable_periods_spec.rb - spec/lib/open_food_network/address_finder_spec.rb - spec/lib/open_food_network/bulk_coop_report_spec.rb - spec/lib/open_food_network/cached_products_renderer_spec.rb @@ -337,7 +321,6 @@ Metrics/LineLength: - spec/mailers/order_mailer_spec.rb - spec/mailers/producer_mailer_spec.rb - spec/mailers/subscription_mailer_spec.rb - - spec/models/billable_period_spec.rb - spec/models/column_preference_spec.rb - spec/models/customer_spec.rb - spec/models/enterprise_caching_spec.rb @@ -452,18 +435,13 @@ Metrics/AbcSize: - app/controllers/user_confirmations_controller.rb - app/controllers/user_passwords_controller.rb - app/controllers/user_registrations_controller.rb - - app/helpers/admin/business_model_configuration_helper.rb - app/helpers/checkout_helper.rb - app/helpers/i18n_helper.rb - app/helpers/order_cycles_helper.rb - app/helpers/spree/admin/orders_helper_decorator.rb - app/helpers/spree/orders_helper.rb - - app/jobs/finalize_account_invoices.rb - app/jobs/subscription_placement_job.rb - - app/jobs/update_account_invoices.rb - - app/jobs/update_billable_periods.rb - app/mailers/producer_mailer.rb - - app/models/billable_period.rb - app/models/calculator/flat_percent_per_item.rb - app/models/column_preference.rb - app/models/enterprise_group.rb @@ -492,7 +470,6 @@ Metrics/AbcSize: - app/services/order_syncer.rb - app/services/subscription_validator.rb - lib/discourse/single_sign_on.rb - - lib/open_food_network/bill_calculator.rb - lib/open_food_network/bulk_coop_report.rb - lib/open_food_network/customers_report.rb - lib/open_food_network/enterprise_issue_validator.rb @@ -534,13 +511,10 @@ Metrics/CyclomaticComplexity: - app/controllers/checkout_controller.rb - app/controllers/spree/admin/orders_controller_decorator.rb - app/controllers/spree/orders_controller_decorator.rb - - app/helpers/admin/business_model_configuration_helper.rb - app/helpers/checkout_helper.rb - app/helpers/i18n_helper.rb - app/helpers/order_cycles_helper.rb - app/helpers/spree/admin/orders_helper_decorator.rb - - app/jobs/update_account_invoices.rb - - app/jobs/update_billable_periods.rb - app/models/enterprise.rb - app/models/enterprise_relationship.rb - app/models/product_import/entry_processor.rb @@ -553,7 +527,6 @@ Metrics/CyclomaticComplexity: - app/models/variant_override_set.rb - app/services/cart_service.rb - lib/discourse/single_sign_on.rb - - lib/open_food_network/bill_calculator.rb - lib/open_food_network/bulk_coop_report.rb - lib/open_food_network/enterprise_issue_validator.rb - lib/open_food_network/orders_and_fulfillments_report.rb @@ -569,12 +542,10 @@ Metrics/PerceivedComplexity: - app/controllers/checkout_controller.rb - app/controllers/spree/admin/orders_controller_decorator.rb - app/controllers/spree/orders_controller_decorator.rb - - app/helpers/admin/business_model_configuration_helper.rb - app/helpers/checkout_helper.rb - app/helpers/i18n_helper.rb - app/helpers/order_cycles_helper.rb - app/helpers/spree/admin/orders_helper_decorator.rb - - app/jobs/update_account_invoices.rb - app/models/enterprise_relationship.rb - app/models/product_import/entry_processor.rb - app/models/product_import/entry_validator.rb @@ -624,12 +595,8 @@ Metrics/MethodLength: - app/helpers/checkout_helper.rb - app/helpers/order_cycles_helper.rb - app/helpers/spree/admin/orders_helper_decorator.rb - - app/jobs/finalize_account_invoices.rb - app/jobs/subscription_placement_job.rb - - app/jobs/update_account_invoices.rb - - app/jobs/update_billable_periods.rb - app/mailers/producer_mailer.rb - - app/models/billable_period.rb - app/models/column_preference.rb - app/models/enterprise.rb - app/models/enterprise_relationship.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f0d9000e11..d8a109f6e3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -143,7 +143,6 @@ Layout/EmptyLines: - 'app/helpers/angular_form_helper.rb' - 'app/helpers/injection_helper.rb' - 'app/helpers/spree/admin/base_helper_decorator.rb' - - 'app/jobs/finalize_account_invoices.rb' - 'app/jobs/products_cache_integrity_checker_job.rb' - 'app/jobs/refresh_products_cache_job.rb' - 'app/models/coordinator_fee.rb' @@ -218,7 +217,6 @@ Layout/EmptyLines: - 'spec/features/consumer/shopping/variant_overrides_spec.rb' - 'spec/features/consumer/shops_spec.rb' - 'spec/helpers/checkout_helper_spec.rb' - - 'spec/jobs/finalize_account_invoices_spec.rb' - 'spec/jobs/heartbeat_job_spec.rb' - 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb' - 'spec/lib/open_food_network/option_value_namer_spec.rb' @@ -278,17 +276,14 @@ Layout/EmptyLinesAroundBlockBody: - 'spec/features/consumer/shopping/embedded_groups_spec.rb' - 'spec/features/consumer/shopping/embedded_shopfronts_spec.rb' - 'spec/features/consumer/shopping/shopping_spec.rb' - - 'spec/helpers/admin/business_model_configuration_helper_spec.rb' - 'spec/helpers/shared_helper_spec.rb' - 'spec/helpers/shop_helper_spec.rb' - 'spec/helpers/spree/orders_helper_spec.rb' - - 'spec/jobs/update_billable_periods_spec.rb' - 'spec/lib/open_food_network/group_buy_report_spec.rb' - 'spec/lib/open_food_network/lettuce_share_report_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' - 'spec/lib/open_food_network/referer_parser_spec.rb' - 'spec/lib/open_food_network/user_balance_calculator_spec.rb' - - 'spec/models/billable_period_spec.rb' - 'spec/models/product_distribution_spec.rb' - 'spec/models/spree/ability_spec.rb' - 'spec/models/spree/product_spec.rb' @@ -307,7 +302,6 @@ Layout/EmptyLinesAroundBlockBody: # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only Layout/EmptyLinesAroundClassBody: Exclude: - - 'app/controllers/admin/account_controller.rb' - 'app/controllers/admin/cache_settings_controller.rb' - 'app/controllers/admin/enterprise_fees_controller.rb' - 'app/controllers/admin/inventory_items_controller.rb' @@ -358,7 +352,6 @@ Layout/ExtraSpacing: - 'lib/open_food_network/variant_and_line_item_naming.rb' - 'lib/spree/product_filters.rb' - 'lib/tasks/karma.rake' - - 'spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb' - 'spec/features/admin/bulk_order_management_spec.rb' - 'spec/features/admin/bulk_product_update_spec.rb' - 'spec/features/admin/orders_spec.rb' @@ -409,7 +402,6 @@ Layout/IndentationConsistency: - 'lib/open_food_network/permissions.rb' - 'spec/controllers/admin/tag_rules_controller_spec.rb' - 'spec/features/consumer/shopping/checkout_spec.rb' - - 'spec/helpers/admin/business_model_configuration_helper_spec.rb' - 'spec/models/spree/line_item_spec.rb' - 'spec/models/spree/product_spec.rb' @@ -425,7 +417,6 @@ Layout/IndentationWidth: - 'app/serializers/api/admin/for_order_cycle/supplied_product_serializer.rb' - 'app/serializers/api/admin/order_cycle_serializer.rb' - 'spec/features/consumer/shopping/variant_overrides_spec.rb' - - 'spec/helpers/admin/business_model_configuration_helper_spec.rb' - 'spec/helpers/groups_helper_spec.rb' - 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' @@ -439,7 +430,6 @@ Layout/IndentationWidth: Layout/LeadingCommentSpace: Exclude: - 'Gemfile' - - 'app/models/billable_period.rb' - 'app/models/content_configuration.rb' - 'app/models/spree/inventory_unit_decorator.rb' - 'app/models/spree/taxon_decorator.rb' @@ -449,7 +439,6 @@ Layout/LeadingCommentSpace: - 'spec/controllers/spree/api/line_items_controller_spec.rb' - 'spec/features/admin/products_spec.rb' - 'spec/features/admin/reports_spec.rb' - - 'spec/jobs/finalize_account_invoices_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' - 'spec/lib/open_food_network/user_balance_calculator_spec.rb' - 'spec/models/enterprise_spec.rb' @@ -471,7 +460,6 @@ Layout/MultilineBlockLayout: - 'spec/features/admin/variant_overrides_spec.rb' - 'spec/features/consumer/shopping/cart_spec.rb' - 'spec/helpers/enterprises_helper_spec.rb' - - 'spec/jobs/update_billable_periods_spec.rb' - 'spec/lib/open_food_network/enterprise_fee_calculator_spec.rb' - 'spec/lib/open_food_network/permissions_spec.rb' - 'spec/lib/open_food_network/user_balance_calculator_spec.rb' @@ -489,7 +477,6 @@ Layout/MultilineBlockLayout: Layout/MultilineHashBraceLayout: Exclude: - 'app/controllers/spree/admin/products_controller_decorator.rb' - - 'app/models/billable_period.rb' - 'lib/spree/product_filters.rb' - 'spec/support/request/authentication_workflow.rb' @@ -528,7 +515,6 @@ Layout/MultilineOperationIndentation: - 'app/models/producer_property.rb' - 'app/models/spree/ability_decorator.rb' - 'app/models/variant_override_set.rb' - - 'lib/open_food_network/accounts_and_billing_settings_validator.rb' - 'lib/open_food_network/order_cycle_permissions.rb' - 'lib/open_food_network/sales_tax_report.rb' - 'lib/open_food_network/users_and_enterprises_report.rb' @@ -551,8 +537,6 @@ Layout/SpaceAfterComma: - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/models/column_preference.rb' - 'lib/discourse/single_sign_on.rb' - - 'lib/open_food_network/accounts_and_billing_settings_validator.rb' - - 'lib/open_food_network/business_model_configuration_validator.rb' - 'lib/open_food_network/order_cycle_form_applicator.rb' - 'lib/open_food_network/users_and_enterprises_report.rb' - 'spec/controllers/admin/enterprises_controller_spec.rb' @@ -561,7 +545,6 @@ Layout/SpaceAfterComma: - 'spec/features/admin/bulk_product_update_spec.rb' - 'spec/features/admin/customers_spec.rb' - 'spec/features/admin/variant_overrides_spec.rb' - - 'spec/jobs/update_account_invoices_spec.rb' - 'spec/lib/open_food_network/group_buy_report_spec.rb' - 'spec/lib/open_food_network/subscription_summary_spec.rb' - 'spec/models/content_configuration_spec.rb' @@ -608,9 +591,6 @@ Layout/SpaceAroundEqualsInParameterDefault: - 'app/models/spree/taxon_decorator.rb' - 'app/models/variant_override_set.rb' - 'lib/discourse/single_sign_on.rb' - - 'lib/open_food_network/accounts_and_billing_settings_validator.rb' - - 'lib/open_food_network/bill_calculator.rb' - - 'lib/open_food_network/business_model_configuration_validator.rb' - 'lib/open_food_network/enterprise_fee_calculator.rb' - 'lib/open_food_network/enterprise_issue_validator.rb' - 'lib/open_food_network/order_cycle_form_applicator.rb' @@ -631,8 +611,6 @@ Layout/SpaceAroundEqualsInParameterDefault: Layout/SpaceAroundOperators: Exclude: - 'app/controllers/checkout_controller.rb' - - 'app/helpers/admin/business_model_configuration_helper.rb' - - 'app/jobs/update_billable_periods.rb' - 'app/overrides/remove_search_bar.rb' - 'app/overrides/remove_side_bar.rb' - 'app/overrides/replace_shipping_address_form_with_distributor_details.rb' @@ -644,7 +622,6 @@ Layout/SpaceAroundOperators: - 'spec/features/consumer/shopping/checkout_spec.rb' - 'spec/helpers/checkout_helper_spec.rb' - 'spec/helpers/order_cycles_helper_spec.rb' - - 'spec/jobs/update_billable_periods_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' - 'spec/lib/stripe/account_connector_spec.rb' - 'spec/spec_helper.rb' @@ -694,7 +671,6 @@ Layout/SpaceInsideArrayLiteralBrackets: - 'lib/open_food_network/users_and_enterprises_report.rb' - 'spec/controllers/admin/variant_overrides_controller_spec.rb' - 'spec/features/admin/reports_spec.rb' - - 'spec/jobs/update_billable_periods_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' - 'spec/lib/open_food_network/users_and_enterprises_report_spec.rb' - 'spec/models/spree/order_spec.rb' @@ -715,8 +691,6 @@ Layout/SpaceInsideBlockBraces: - 'lib/spree/product_filters.rb' - 'lib/tasks/karma.rake' - 'spec/archive/features/consumer/checkout_spec.rb' - - 'spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb' - - 'spec/controllers/admin/business_model_configuration_controller_spec.rb' - 'spec/controllers/admin/inventory_items_controller_spec.rb' - 'spec/controllers/admin/tag_rules_controller_spec.rb' - 'spec/controllers/admin/variant_overrides_controller_spec.rb' @@ -732,9 +706,6 @@ Layout/SpaceInsideBlockBraces: - 'spec/helpers/enterprises_helper_spec.rb' - 'spec/helpers/injection_helper_spec.rb' - 'spec/helpers/spree/orders_helper_spec.rb' - - 'spec/jobs/finalize_account_invoices_spec.rb' - - 'spec/jobs/update_account_invoices_spec.rb' - - 'spec/jobs/update_billable_periods_spec.rb' - 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb' - 'spec/lib/open_food_network/order_grouper_spec.rb' - 'spec/lib/open_food_network/orders_and_fulfillments_report_spec.rb' @@ -767,7 +738,6 @@ Layout/SpaceInsideHashLiteralBraces: - 'app/controllers/spree/admin/line_items_controller_decorator.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' - 'app/controllers/spree/admin/search_controller_decorator.rb' - - 'app/helpers/admin/business_model_configuration_helper.rb' - 'app/helpers/admin/injection_helper.rb' - 'app/helpers/angular_form_builder.rb' - 'app/helpers/injection_helper.rb' @@ -775,9 +745,7 @@ Layout/SpaceInsideHashLiteralBraces: - 'app/helpers/serializer_helper.rb' - 'app/helpers/spree/admin/base_helper_decorator.rb' - 'app/helpers/spree/admin/navigation_helper_decorator.rb' - - 'app/jobs/update_billable_periods.rb' - 'app/mailers/spree/base_mailer_decorator.rb' - - 'app/models/billable_period.rb' - 'app/models/enterprise.rb' - 'app/models/enterprise_group.rb' - 'app/models/enterprise_relationship.rb' @@ -796,8 +764,6 @@ Layout/SpaceInsideHashLiteralBraces: - 'lib/open_food_network/sales_tax_report.rb' - 'lib/open_food_network/variant_and_line_item_naming.rb' - 'lib/open_food_network/xero_invoices_report.rb' - - 'spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb' - - 'spec/controllers/admin/business_model_configuration_controller_spec.rb' - 'spec/controllers/admin/enterprises_controller_spec.rb' - 'spec/controllers/admin/manager_invitations_controller_spec.rb' - 'spec/controllers/admin/order_cycles_controller_spec.rb' @@ -816,7 +782,6 @@ Layout/SpaceInsideHashLiteralBraces: - 'spec/controllers/spree/user_sessions_controller_spec.rb' - 'spec/controllers/user_passwords_controller_spec.rb' - 'spec/controllers/user_registrations_controller_spec.rb' - - 'spec/features/admin/accounts_and_billing_settings_spec.rb' - 'spec/features/admin/image_settings_spec.rb' - 'spec/features/admin/products_spec.rb' - 'spec/features/admin/reports_spec.rb' @@ -972,7 +937,6 @@ Lint/ShadowingOuterLocalVariable: # Cop supports --auto-correct. Lint/StringConversionInInterpolation: Exclude: - - 'app/controllers/admin/accounts_and_billing_settings_controller.rb' - 'app/controllers/enterprises_controller.rb' - 'app/helpers/admin/injection_helper.rb' - 'app/helpers/injection_helper.rb' @@ -1025,8 +989,6 @@ Lint/UnusedMethodArgument: - 'app/helpers/angular_form_helper.rb' - 'app/helpers/order_cycles_helper.rb' - 'app/helpers/spree/base_helper_decorator.rb' - - 'app/jobs/finalize_account_invoices.rb' - - 'app/jobs/update_account_invoices.rb' - 'app/models/spree/ability_decorator.rb' - 'app/models/spree/product_decorator.rb' - 'lib/open_food_network/enterprise_fee_applicator.rb' @@ -1337,8 +1299,6 @@ Rails/HasAndBelongsToMany: # Include: app/models/**/*.rb Rails/HasManyOrHasOneDependent: Exclude: - - 'app/models/account_invoice.rb' - - 'app/models/billable_period.rb' - 'app/models/customer.rb' - 'app/models/enterprise.rb' - 'app/models/order_cycle.rb' @@ -1394,8 +1354,6 @@ Rails/OutputSafety: Rails/PluralizationGrammar: Exclude: - 'spec/features/admin/order_cycles_spec.rb' - - 'spec/jobs/update_account_invoices_spec.rb' - - 'spec/jobs/update_billable_periods_spec.rb' - 'spec/models/order_cycle_spec.rb' - 'spec/models/spree/product_spec.rb' @@ -1515,15 +1473,9 @@ Style/BracesAroundHashParameters: - 'app/controllers/checkout_controller.rb' - 'app/controllers/spree/admin/products_controller_decorator.rb' - 'app/controllers/spree/admin/search_controller_decorator.rb' - - 'app/helpers/admin/account_helper.rb' - - 'app/helpers/admin/business_model_configuration_helper.rb' - 'app/helpers/angular_form_builder.rb' - 'app/helpers/checkout_helper.rb' - 'app/helpers/spree/admin/orders_helper_decorator.rb' - - 'app/jobs/finalize_account_invoices.rb' - - 'app/jobs/update_account_invoices.rb' - - 'app/jobs/update_billable_periods.rb' - - 'app/models/billable_period.rb' - 'app/models/exchange.rb' - 'app/models/spree/adjustment_decorator.rb' - 'app/models/spree/line_item_decorator.rb' @@ -1533,8 +1485,6 @@ Style/BracesAroundHashParameters: - 'lib/open_food_network/reports/rule.rb' - 'lib/open_food_network/variant_and_line_item_naming.rb' - 'lib/open_food_network/xero_invoices_report.rb' - - 'spec/controllers/admin/accounts_and_billing_settings_controller_spec.rb' - - 'spec/controllers/admin/business_model_configuration_controller_spec.rb' - 'spec/controllers/admin/enterprises_controller_spec.rb' - 'spec/controllers/admin/manager_invitations_controller_spec.rb' - 'spec/controllers/admin/order_cycles_controller_spec.rb' @@ -1552,19 +1502,14 @@ Style/BracesAroundHashParameters: - 'spec/controllers/spree/orders_controller_spec.rb' - 'spec/controllers/user_confirmations_controller_spec.rb' - 'spec/controllers/user_registrations_controller_spec.rb' - - 'spec/features/admin/accounts_and_billing_settings_spec.rb' - - 'spec/features/admin/business_model_configuration_spec.rb' - 'spec/features/admin/order_cycles_spec.rb' - 'spec/features/admin/products_spec.rb' - 'spec/features/admin/reports_spec.rb' - 'spec/features/admin/tax_settings_spec.rb' - 'spec/helpers/order_cycles_helper_spec.rb' - - 'spec/jobs/finalize_account_invoices_spec.rb' - - 'spec/jobs/update_account_invoices_spec.rb' - 'spec/lib/open_food_network/feature_toggle_spec.rb' - 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb' - 'spec/lib/open_food_network/subscription_summarizer_spec.rb' - - 'spec/models/billable_period_spec.rb' - 'spec/models/product_distribution_spec.rb' - 'spec/models/spree/ability_spec.rb' - 'spec/models/spree/order_spec.rb' @@ -1588,9 +1533,6 @@ Style/CaseEquality: # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Exclude: - - 'app/controllers/admin/account_controller.rb' - - 'app/controllers/admin/accounts_and_billing_settings_controller.rb' - - 'app/controllers/admin/business_model_configuration_controller.rb' - 'app/controllers/admin/cache_settings_controller.rb' - 'app/controllers/spree/store_controller_decorator.rb' - 'app/helpers/angular_form_helper.rb' @@ -1758,7 +1700,6 @@ Style/FormatStringToken: # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: - - 'app/controllers/admin/accounts_and_billing_settings_controller.rb' - 'app/controllers/admin/enterprises_controller.rb' - 'app/controllers/admin/order_cycles_controller.rb' - 'app/controllers/admin/product_import_controller.rb' @@ -1775,8 +1716,6 @@ Style/GuardClause: - 'app/controllers/spree/orders_controller_decorator.rb' - 'app/controllers/spree/paypal_controller_decorator.rb' - 'app/jobs/products_cache_integrity_checker_job.rb' - - 'app/jobs/update_account_invoices.rb' - - 'app/jobs/update_billable_periods.rb' - 'app/models/enterprise.rb' - 'app/models/enterprise_group.rb' - 'app/models/producer_property.rb' @@ -1786,7 +1725,6 @@ Style/GuardClause: - 'app/models/spree/product_decorator.rb' - 'app/models/spree/user_decorator.rb' - 'lib/discourse/single_sign_on.rb' - - 'lib/open_food_network/accounts_and_billing_settings_validator.rb' - 'lib/open_food_network/order_cycle_form_applicator.rb' - 'lib/open_food_network/products_cache.rb' - 'lib/open_food_network/products_renderer.rb' @@ -1805,7 +1743,6 @@ Style/GuardClause: # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys Style/HashSyntax: Exclude: - - 'app/controllers/admin/accounts_and_billing_settings_controller.rb' - 'app/controllers/admin/contents_controller.rb' - 'app/controllers/admin/enterprise_fees_controller.rb' - 'app/controllers/admin/enterprises_controller.rb' @@ -1823,7 +1760,6 @@ Style/HashSyntax: - 'app/controllers/spree/paypal_controller_decorator.rb' - 'app/controllers/spree/store_controller_decorator.rb' - 'app/controllers/user_passwords_controller.rb' - - 'app/helpers/admin/account_helper.rb' - 'app/helpers/angular_form_builder.rb' - 'app/helpers/application_helper.rb' - 'app/helpers/checkout_helper.rb' @@ -1832,7 +1768,6 @@ Style/HashSyntax: - 'app/helpers/spree/admin/orders_helper_decorator.rb' - 'app/mailers/enterprise_mailer.rb' - 'app/mailers/spree/user_mailer_decorator.rb' - - 'app/models/billable_period.rb' - 'app/models/calculator/flat_percent_per_item.rb' - 'app/models/enterprise.rb' - 'app/models/enterprise_fee.rb' @@ -2090,9 +2025,7 @@ Style/NumericLiterals: Style/NumericPredicate: Exclude: - 'spec/**/*' - - 'app/helpers/admin/business_model_configuration_helper.rb' - 'app/helpers/checkout_helper.rb' - - 'app/jobs/update_account_invoices.rb' - 'app/models/spree/calculator/flexi_rate_decorator.rb' - 'app/models/spree/line_item_decorator.rb' - 'app/models/spree/order_decorator.rb' @@ -2181,7 +2114,6 @@ Style/RedundantReturn: # Cop supports --auto-correct. Style/RedundantSelf: Exclude: - - 'app/models/billable_period.rb' - 'app/models/calculator/flat_percent_per_item.rb' - 'app/models/enterprise.rb' - 'app/models/exchange.rb' @@ -2295,7 +2227,6 @@ Style/StabbyLambdaParentheses: Style/StringLiteralsInInterpolation: Exclude: - 'app/controllers/application_controller.rb' - - 'app/jobs/update_billable_periods.rb' - 'lib/discourse/single_sign_on.rb' - 'lib/open_food_network/users_and_enterprises_report.rb' - 'spec/features/admin/bulk_order_management_spec.rb' @@ -2373,12 +2304,9 @@ Style/UnneededCondition: # Cop supports --auto-correct. Style/UnneededInterpolation: Exclude: - - 'app/controllers/admin/accounts_and_billing_settings_controller.rb' - 'app/controllers/admin/resource_controller.rb' - - 'app/helpers/admin/business_model_configuration_helper.rb' - 'app/helpers/angular_form_builder.rb' - 'app/helpers/injection_helper.rb' - - 'app/jobs/update_billable_periods.rb' - 'lib/discourse/single_sign_on.rb' - 'spec/features/admin/bulk_order_management_spec.rb' - 'spec/features/admin/bulk_product_update_spec.rb' diff --git a/Gemfile b/Gemfile index 6eb959a3fb..58d4a86827 100644 --- a/Gemfile +++ b/Gemfile @@ -27,7 +27,8 @@ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable' # - Pass customer email and phone number to PayPal (merged to upstream master) # - Change type of password from string to password to hide it in the form gem 'spree_paypal_express', github: "openfoodfoundation/better_spree_paypal_express", branch: "2-0-stable" -gem 'stripe', '~> 4.5.0' +gem 'stripe', '~> 4.9.0' + # We need at least this version to have Digicert's root certificate # which is needed for Pin Payments (and possibly others). gem 'activemerchant', '~> 1.78' diff --git a/Gemfile.lock b/Gemfile.lock index f602edc9ed..4fb8a999b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -227,7 +227,7 @@ GEM execjs coffee-script-source (1.10.0) colorize (0.8.1) - combine_pdf (1.0.15) + combine_pdf (1.0.16) ruby-rc4 (>= 0.1.5) compass (1.0.3) chunky_png (~> 1.2) @@ -551,7 +551,7 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - oj (3.7.8) + oj (3.7.9) orm_adapter (0.5.0) paper_trail (5.2.3) activerecord (>= 3.0, < 6.0) @@ -719,7 +719,7 @@ GEM tilt (~> 1.1, != 1.3.0) state_machine (1.2.0) stringex (1.5.1) - stripe (4.5.0) + stripe (4.9.0) faraday (~> 0.13) net-http-persistent (~> 3.0) therubyracer (0.12.0) @@ -858,7 +858,7 @@ DEPENDENCIES spree_paypal_express! spring (= 1.7.2) spring-commands-rspec - stripe (~> 4.5.0) + stripe (~> 4.9.0) therubyracer (= 0.12.0) timecop truncate_html diff --git a/app/assets/javascripts/admin/accounts_and_billing_settings/accounts_and_billing_settings.js.coffee b/app/assets/javascripts/admin/accounts_and_billing_settings/accounts_and_billing_settings.js.coffee deleted file mode 100644 index 06ee4fa4ef..0000000000 --- a/app/assets/javascripts/admin/accounts_and_billing_settings/accounts_and_billing_settings.js.coffee +++ /dev/null @@ -1 +0,0 @@ -angular.module("admin.accounts_and_billing_settings", ["admin.utils"]) diff --git a/app/assets/javascripts/admin/accounts_and_billing_settings/directives/method_settings.js.coffee b/app/assets/javascripts/admin/accounts_and_billing_settings/directives/method_settings.js.coffee deleted file mode 100644 index 32ef50bb64..0000000000 --- a/app/assets/javascripts/admin/accounts_and_billing_settings/directives/method_settings.js.coffee +++ /dev/null @@ -1,14 +0,0 @@ -angular.module("admin.accounts_and_billing_settings").directive "methodSettingsFor", -> - template: "
" - restrict: 'A' - scope: { - enterprise_id: '=methodSettingsFor' - } - link: (scope, element, attrs) -> - scope.include_html = "" - - scope.$watch "enterprise_id", (newVal, oldVal)-> - if !newVal? || newVal == "" - scope.include_html = "" - else - scope.include_html = "/admin/accounts_and_billing_settings/show_methods?enterprise_id=#{newVal};" diff --git a/app/assets/javascripts/admin/all.js b/app/assets/javascripts/admin/all.js index 61f809ed25..80625cfa55 100644 --- a/app/assets/javascripts/admin/all.js +++ b/app/assets/javascripts/admin/all.js @@ -9,7 +9,7 @@ //= require jquery-migrate-min //= require jquery_ujs //= require jquery.ui.all -//= require shared/jquery-ui-timepicker-addon +//= require jquery-ui-timepicker-addon //= require angular //= require angular-resource //= require angular-animate @@ -23,8 +23,6 @@ //= require angular-rails-templates //= require_tree ../templates/admin //= require ./admin_ofn -//= require ./accounts_and_billing_settings/accounts_and_billing_settings -//= require ./business_model_configuration/business_model_configuration //= require ./customers/customers //= require ./dropdown/dropdown //= require ./enterprises/enterprises diff --git a/app/assets/javascripts/admin/business_model_configuration/business_model_configuration.js.coffee b/app/assets/javascripts/admin/business_model_configuration/business_model_configuration.js.coffee deleted file mode 100644 index cecb7c397e..0000000000 --- a/app/assets/javascripts/admin/business_model_configuration/business_model_configuration.js.coffee +++ /dev/null @@ -1 +0,0 @@ -angular.module("admin.businessModelConfiguration", ["admin.utils"]) diff --git a/app/assets/javascripts/admin/business_model_configuration/controllers/business_model_configuration_controller.js.coffee b/app/assets/javascripts/admin/business_model_configuration/controllers/business_model_configuration_controller.js.coffee deleted file mode 100644 index d5b7fa4b63..0000000000 --- a/app/assets/javascripts/admin/business_model_configuration/controllers/business_model_configuration_controller.js.coffee +++ /dev/null @@ -1,25 +0,0 @@ -angular.module("admin.businessModelConfiguration").controller "BusinessModelConfigCtrl", ($scope, $filter) -> - $scope.turnover = 1000 - - $scope.bill = -> - return $filter('currency')(0) unless $scope.fixed || $scope.rate - Number($scope.fixed) + Number($scope.turnover) * Number($scope.rate) - - $scope.cappedBill = -> - return $scope.bill() if !$scope.cap? || Number($scope.cap) == 0 - Math.min($scope.bill(), Number($scope.cap)) - - $scope.finalBill = -> - return 0 if Number($scope.turnover) < Number($scope.minBillableTurnover) - $scope.cappedBill() - - $scope.capReached = -> - return t('no') if !$scope.cap? || Number($scope.cap) == 0 - if $scope.bill() >= Number($scope.cap) then t('yes') else t('no') - - $scope.includedTax = -> - return 0 if !$scope.taxRate? || Number($scope.taxRate) == 0 - ($scope.cappedBill() * Number($scope.taxRate)) - - $scope.total = -> - $scope.finalBill() + $scope.includedTax() diff --git a/app/assets/javascripts/admin/order_cycles/order_cycles.js.erb.coffee b/app/assets/javascripts/admin/order_cycles/order_cycles.js.erb.coffee index d6f2d23679..91ef3c0436 100644 --- a/app/assets/javascripts/admin/order_cycles/order_cycles.js.erb.coffee +++ b/app/assets/javascripts/admin/order_cycles/order_cycles.js.erb.coffee @@ -10,17 +10,19 @@ angular.module('admin.orderCycles', ['ngTagsInput', 'admin.indexUtils', 'admin.e # using $parse instead of scope[attrs.datetimepicker] for cases # where attrs.datetimepicker is 'foo.bar.lol' $(element).datetimepicker - dateFormat: 'yy-mm-dd' - timeFormat: 'HH:mm:ss' - showOn: "button" - buttonImage: "<%= asset_path 'datepicker/cal.gif' %>" - buttonImageOnly: true - stepMinute: 15 - onSelect: (dateText, inst) -> - scope.$apply(-> + dateFormat: 'yy-mm-dd' + timeFormat: 'HH:mm' + showOn: 'button' + controlType: 'select' + oneLine: true + buttonImage: "<%= asset_path 'datepicker/cal.gif' %>" + buttonImageOnly: true + stepMinute: 15 + onSelect: (dateText, inst) -> + scope.$apply(-> element.val(dateText) - parsed = $parse(attrs.datetimepicker) - parsed.assign(scope, dateText) + parsed = $parse(attrs.datetimepicker) + parsed.assign(scope, dateText) ) diff --git a/app/assets/javascripts/admin/util.js.erb b/app/assets/javascripts/admin/util.js.erb index b894ca1837..37ff1cb9ca 100644 --- a/app/assets/javascripts/admin/util.js.erb +++ b/app/assets/javascripts/admin/util.js.erb @@ -1,12 +1,15 @@ $(document).ready(function() { $('.datetimepicker').datetimepicker({ dateFormat: 'yy-mm-dd', + timeFormat: 'HH:mm', dayNames: Spree.translations.abbr_day_names, dayNamesMin: Spree.translations.abbr_day_names, monthNames: Spree.translations.month_names, prevText: Spree.translations.previous, nextText: Spree.translations.next, - showOn: "button", + showOn: 'button', + controlType: 'select', + oneLine: true, buttonImage: "<%= asset_path 'datepicker/cal.gif' %>", buttonImageOnly: true, stepMinute: 15 diff --git a/app/assets/javascripts/darkswarm/services/cart.js.coffee b/app/assets/javascripts/darkswarm/services/cart.js.coffee index 849af562b8..bdd0aa3676 100644 --- a/app/assets/javascripts/darkswarm/services/cart.js.coffee +++ b/app/assets/javascripts/darkswarm/services/cart.js.coffee @@ -57,18 +57,20 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $modal, $roo scope = $rootScope.$new(true) scope.variants = [] - # TODO: These changes to quantity/max_quantity trigger another cart update, which - # is unnecessary. - + # TODO: These changes to quantity/max_quantity trigger another cart update, which is unnecessary. for li in @line_items when li.quantity > 0 - if stockLevels[li.variant.id]? - li.variant.count_on_hand = stockLevels[li.variant.id].on_hand - if li.quantity > li.variant.count_on_hand - li.quantity = li.variant.count_on_hand - scope.variants.push li.variant - if li.variant.count_on_hand == 0 && li.max_quantity > li.variant.count_on_hand - li.max_quantity = li.variant.count_on_hand - scope.variants.push(li.variant) unless li.variant in scope.variants + continue unless stockLevels[li.variant.id]? + + li.variant.on_hand = stockLevels[li.variant.id].on_hand + li.variant.on_demand = stockLevels[li.variant.id].on_demand + continue if li.variant.on_demand + + if li.quantity > li.variant.on_hand + li.quantity = li.variant.on_hand + scope.variants.push li.variant + if li.variant.on_hand == 0 && li.max_quantity > li.variant.on_hand + li.max_quantity = li.variant.on_hand + scope.variants.push(li.variant) unless li.variant in scope.variants if scope.variants.length > 0 $modal.open(templateUrl: "out_of_stock.html", scope: scope, windowClass: 'out-of-stock-modal') diff --git a/app/assets/javascripts/shared/jquery-ui-timepicker-addon.js b/app/assets/javascripts/shared/jquery-ui-timepicker-addon.js deleted file mode 100644 index b8616da378..0000000000 --- a/app/assets/javascripts/shared/jquery-ui-timepicker-addon.js +++ /dev/null @@ -1,1882 +0,0 @@ -/* - * jQuery timepicker addon - * By: Trent Richardson [http://trentrichardson.com] - * Version 1.1.1 - * Last Modified: 11/07/2012 - * - * Copyright 2012 Trent Richardson - * You may use this project under MIT or GPL licenses. - * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt - * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt - */ - -/*jslint evil: true, white: false, undef: false, nomen: false */ - -(function($) { - - /* - * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded" - */ - $.ui.timepicker = $.ui.timepicker || {}; - if ($.ui.timepicker.version) { - return; - } - - /* - * Extend jQueryUI, get it started with our version number - */ - $.extend($.ui, { - timepicker: { - version: "1.1.1" - } - }); - - /* - * Timepicker manager. - * Use the singleton instance of this class, $.timepicker, to interact with the time picker. - * Settings for (groups of) time pickers are maintained in an instance object, - * allowing multiple different settings on the same page. - */ - function Timepicker() { - this.regional = []; // Available regional settings, indexed by language code - this.regional[''] = { // Default regional settings - currentText: 'Now', - closeText: 'Done', - amNames: ['AM', 'A'], - pmNames: ['PM', 'P'], - timeFormat: 'HH:mm', - timeSuffix: '', - timeOnlyTitle: 'Choose Time', - timeText: 'Time', - hourText: 'Hour', - minuteText: 'Minute', - secondText: 'Second', - millisecText: 'Millisecond', - timezoneText: 'Time Zone', - isRTL: false - }; - this._defaults = { // Global defaults for all the datetime picker instances - showButtonPanel: true, - timeOnly: false, - showHour: true, - showMinute: true, - showSecond: false, - showMillisec: false, - showTimezone: false, - showTime: true, - stepHour: 1, - stepMinute: 1, - stepSecond: 1, - stepMillisec: 1, - hour: 0, - minute: 0, - second: 0, - millisec: 0, - timezone: null, - useLocalTimezone: false, - defaultTimezone: "+0000", - hourMin: 0, - minuteMin: 0, - secondMin: 0, - millisecMin: 0, - hourMax: 23, - minuteMax: 59, - secondMax: 59, - millisecMax: 999, - minDateTime: null, - maxDateTime: null, - onSelect: null, - hourGrid: 0, - minuteGrid: 0, - secondGrid: 0, - millisecGrid: 0, - alwaysSetTime: true, - separator: ' ', - altFieldTimeOnly: true, - altTimeFormat: null, - altSeparator: null, - altTimeSuffix: null, - pickerTimeFormat: null, - pickerTimeSuffix: null, - showTimepicker: true, - timezoneIso8601: false, - timezoneList: null, - addSliderAccess: false, - sliderAccessArgs: null, - controlType: 'slider', - defaultValue: null, - parse: 'strict' - }; - $.extend(this._defaults, this.regional['']); - } - - $.extend(Timepicker.prototype, { - $input: null, - $altInput: null, - $timeObj: null, - inst: null, - hour_slider: null, - minute_slider: null, - second_slider: null, - millisec_slider: null, - timezone_select: null, - hour: 0, - minute: 0, - second: 0, - millisec: 0, - timezone: null, - defaultTimezone: "+0000", - hourMinOriginal: null, - minuteMinOriginal: null, - secondMinOriginal: null, - millisecMinOriginal: null, - hourMaxOriginal: null, - minuteMaxOriginal: null, - secondMaxOriginal: null, - millisecMaxOriginal: null, - ampm: '', - formattedDate: '', - formattedTime: '', - formattedDateTime: '', - timezoneList: null, - units: ['hour','minute','second','millisec'], - control: null, - - /* - * Override the default settings for all instances of the time picker. - * @param settings object - the new settings to use as defaults (anonymous object) - * @return the manager object - */ - setDefaults: function(settings) { - extendRemove(this._defaults, settings || {}); - return this; - }, - - /* - * Create a new Timepicker instance - */ - _newInst: function($input, o) { - var tp_inst = new Timepicker(), - inlineSettings = {}, - fns = {}, - overrides, i; - - for (var attrName in this._defaults) { - if(this._defaults.hasOwnProperty(attrName)){ - var attrValue = $input.attr('time:' + attrName); - if (attrValue) { - try { - inlineSettings[attrName] = eval(attrValue); - } catch (err) { - inlineSettings[attrName] = attrValue; - } - } - } - } - overrides = { - beforeShow: function (input, dp_inst) { - if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) { - return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst); - } - }, - onChangeMonthYear: function (year, month, dp_inst) { - // Update the time as well : this prevents the time from disappearing from the $input field. - tp_inst._updateDateTime(dp_inst); - if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) { - tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst); - } - }, - onClose: function (dateText, dp_inst) { - if (tp_inst.timeDefined === true && $input.val() !== '') { - tp_inst._updateDateTime(dp_inst); - } - if ($.isFunction(tp_inst._defaults.evnts.onClose)) { - tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst); - } - } - }; - for (i in overrides) { - if (overrides.hasOwnProperty(i)) { - fns[i] = o[i] || null; - } - } - tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, overrides, { - evnts:fns, - timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker'); - }); - tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { - return val.toUpperCase(); - }); - tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { - return val.toUpperCase(); - }); - - // controlType is string - key to our this._controls - if(typeof(tp_inst._defaults.controlType) === 'string'){ - if($.fn[tp_inst._defaults.controlType] === undefined){ - tp_inst._defaults.controlType = 'select'; - } - tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType]; - } - // controlType is an object and must implement create, options, value methods - else{ - tp_inst.control = tp_inst._defaults.controlType; - } - - if (tp_inst._defaults.timezoneList === null) { - var timezoneList = ['-1200', '-1100', '-1000', '-0930', '-0900', '-0800', '-0700', '-0600', '-0500', '-0430', '-0400', '-0330', '-0300', '-0200', '-0100', '+0000', - '+0100', '+0200', '+0300', '+0330', '+0400', '+0430', '+0500', '+0530', '+0545', '+0600', '+0630', '+0700', '+0800', '+0845', '+0900', '+0930', - '+1000', '+1030', '+1100', '+1130', '+1200', '+1245', '+1300', '+1400']; - - if (tp_inst._defaults.timezoneIso8601) { - timezoneList = $.map(timezoneList, function(val) { - return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3)); - }); - } - tp_inst._defaults.timezoneList = timezoneList; - } - - tp_inst.timezone = tp_inst._defaults.timezone; - tp_inst.hour = tp_inst._defaults.hour; - tp_inst.minute = tp_inst._defaults.minute; - tp_inst.second = tp_inst._defaults.second; - tp_inst.millisec = tp_inst._defaults.millisec; - tp_inst.ampm = ''; - tp_inst.$input = $input; - - if (o.altField) { - tp_inst.$altInput = $(o.altField).css({ - cursor: 'pointer' - }).focus(function() { - $input.trigger("focus"); - }); - } - - if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) { - tp_inst._defaults.minDate = new Date(); - } - if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) { - tp_inst._defaults.maxDate = new Date(); - } - - // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime.. - if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) { - tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime()); - } - if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) { - tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime()); - } - if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) { - tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime()); - } - if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) { - tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime()); - } - tp_inst.$input.bind('focus', function() { - tp_inst._onFocus(); - }); - - return tp_inst; - }, - - /* - * add our sliders to the calendar - */ - _addTimePicker: function(dp_inst) { - var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val(); - - this.timeDefined = this._parseTime(currDT); - this._limitMinMaxDateTime(dp_inst, false); - this._injectTimePicker(); - }, - - /* - * parse the time string from input value or _setTime - */ - _parseTime: function(timeString, withDate) { - if (!this.inst) { - this.inst = $.datepicker._getInst(this.$input[0]); - } - - if (withDate || !this._defaults.timeOnly) { - var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); - try { - var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults); - if (!parseRes.timeObj) { - return false; - } - $.extend(this, parseRes.timeObj); - } catch (err) { - $.datepicker.log("Error parsing the date/time string: " + err + - "\ndate/time string = " + timeString + - "\ntimeFormat = " + this._defaults.timeFormat + - "\ndateFormat = " + dp_dateFormat); - return false; - } - return true; - } else { - var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults); - if (!timeObj) { - return false; - } - $.extend(this, timeObj); - return true; - } - }, - - /* - * generate and inject html for timepicker into ui datepicker - */ - _injectTimePicker: function() { - var $dp = this.inst.dpDiv, - o = this.inst.settings, - tp_inst = this, - litem = '', - uitem = '', - max = {}, - gridSize = {}, - size = null; - - // Prevent displaying twice - if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { - var noDisplay = ' style="display:none;"', - html = '
' + '
' + o.timeText + '
' + - '
'; - - // Create the markup - for(var i=0,l=this.units.length; i' + o[litem +'Text'] + '' + - '
'; - - if (o['show'+uitem] && o[litem+'Grid'] > 0) { - html += '
'; - - if(litem == 'hour'){ - for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) { - gridSize[litem]++; - var tmph = $.datepicker.formatTime(useAmpm(o.pickerTimeFormat || o.timeFormat)? 'hht':'HH', {hour:h}, o); - html += ''; - } - } - else{ - for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) { - gridSize[litem]++; - html += ''; - } - } - - html += '
' + tmph + '' + ((m < 10) ? '0' : '') + m + '
'; - } - html += '
'; - } - - // Timezone - html += '
' + o.timezoneText + '
'; - html += '
'; - - // Create the elements from string - html += '
'; - var $tp = $(html); - - // if we only want time picker... - if (o.timeOnly === true) { - $tp.prepend('
' + '
' + o.timeOnlyTitle + '
' + '
'); - $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide(); - } - - // add sliders, adjust grids, add events - for(var i=0,l=tp_inst.units.length; i 0) { - size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']); - $tp.find('.ui_tpicker_'+litem+' table').css({ - width: size + "%", - marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"), - marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0', - borderCollapse: 'collapse' - }).find("td").click(function(e){ - var $t = $(this), - h = $t.html(), - n = parseInt(h.replace(/[^0-9]/g),10), - ap = h.replace(/[^apm]/ig), - f = $t.data('for'); // loses scope, so we use data-for - - if(f == 'hour'){ - if(ap.indexOf('p') !== -1 && n < 12){ - n += 12; - } - else{ - if(ap.indexOf('a') !== -1 && n === 12){ - n = 0; - } - } - } - - tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n); - - tp_inst._onTimeChange(); - tp_inst._onSelectHandler(); - }) - .css({ - cursor: 'pointer', - width: (100 / gridSize[litem]) + '%', - textAlign: 'center', - overflow: 'hidden' - }); - } // end if grid > 0 - } // end for loop - - // Add timezone options - this.timezone_select = $tp.find('.ui_tpicker_timezone').append('').find("select"); - $.fn.append.apply(this.timezone_select, - $.map(o.timezoneList, function(val, idx) { - return $("