Skip to content

Commit

Permalink
Merge pull request #186 from reactioncommerce/pre-beta-refactor
Browse files Browse the repository at this point in the history
Beta 0.9.0
  • Loading branch information
Aaron Judd committed Oct 7, 2015
2 parents 20d038b + ed01421 commit 77f274f
Show file tree
Hide file tree
Showing 159 changed files with 7,047 additions and 11,802 deletions.
14 changes: 9 additions & 5 deletions packages/reaction-core/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.js]
max_line_length = 80
max_line_length = 160
indent_brace_style = 1TBS
spaces_around_operators = true
quote_type = auto
quote_type = double
insert_final_newline = true
184 changes: 184 additions & 0 deletions packages/reaction-core/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"meteor": true,
},
"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": false,
"modules": false,
"objectLiteralComputedProperties": true,
"objectLiteralDuplicateProperties": false,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"spread": true,
"superInFunctions": true,
"templateStrings": true,
"jsx": true
},
"rules": {
/**
* Strict mode
*/
// babel inserts "use strict"; for us
// http://eslint.org/docs/rules/strict
"strict": [2, "never"],

/**
* ES6
*/
"no-var": 2, // http://eslint.org/docs/rules/no-var

/**
* Variables
*/
"no-shadow": 2, // http://eslint.org/docs/rules/no-shadow
"no-shadow-restricted-names": 2, // http://eslint.org/docs/rules/no-shadow-restricted-names
"no-unused-vars": [2, { // http://eslint.org/docs/rules/no-unused-vars
"vars": "local",
"args": "after-used"
}],
"no-use-before-define": [2, "nofunc"], // http://eslint.org/docs/rules/no-use-before-define

/**
* Possible errors
*/
"comma-dangle": [2, "never"], // http://eslint.org/docs/rules/comma-dangle
"no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign
"no-console": 1, // http://eslint.org/docs/rules/no-console
"no-debugger": 1, // http://eslint.org/docs/rules/no-debugger
"no-alert": 1, // http://eslint.org/docs/rules/no-alert
"no-constant-condition": 1, // http://eslint.org/docs/rules/no-constant-condition
"no-dupe-keys": 2, // http://eslint.org/docs/rules/no-dupe-keys
"no-duplicate-case": 2, // http://eslint.org/docs/rules/no-duplicate-case
"no-empty": 2, // http://eslint.org/docs/rules/no-empty
"no-ex-assign": 2, // http://eslint.org/docs/rules/no-ex-assign
"no-extra-boolean-cast": 0, // http://eslint.org/docs/rules/no-extra-boolean-cast
"no-extra-semi": 2, // http://eslint.org/docs/rules/no-extra-semi
"no-func-assign": 2, // http://eslint.org/docs/rules/no-func-assign
"no-inner-declarations": 2, // http://eslint.org/docs/rules/no-inner-declarations
"no-invalid-regexp": 2, // http://eslint.org/docs/rules/no-invalid-regexp
"no-irregular-whitespace": 2, // http://eslint.org/docs/rules/no-irregular-whitespace
"no-obj-calls": 2, // http://eslint.org/docs/rules/no-obj-calls
"no-sparse-arrays": 2, // http://eslint.org/docs/rules/no-sparse-arrays
"no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable
"use-isnan": 2, // http://eslint.org/docs/rules/use-isnan
"block-scoped-var": 0, // http://eslint.org/docs/rules/block-scoped-var

/**
* Best practices
*/
"consistent-return": 2, // http://eslint.org/docs/rules/consistent-return
"curly": [2, "multi-line"], // http://eslint.org/docs/rules/curly
"default-case": 2, // http://eslint.org/docs/rules/default-case
"dot-notation": [2, { // http://eslint.org/docs/rules/dot-notation
"allowKeywords": true
}],
"eqeqeq": 2, // http://eslint.org/docs/rules/eqeqeq
"guard-for-in": 2, // http://eslint.org/docs/rules/guard-for-in
"no-caller": 2, // http://eslint.org/docs/rules/no-caller
"no-else-return": 2, // http://eslint.org/docs/rules/no-else-return
"no-eq-null": 2, // http://eslint.org/docs/rules/no-eq-null
"no-eval": 2, // http://eslint.org/docs/rules/no-eval
"no-extend-native": 2, // http://eslint.org/docs/rules/no-extend-native
"no-extra-bind": 2, // http://eslint.org/docs/rules/no-extra-bind
"no-fallthrough": 2, // http://eslint.org/docs/rules/no-fallthrough
"no-floating-decimal": 2, // http://eslint.org/docs/rules/no-floating-decimal
"no-implied-eval": 2, // http://eslint.org/docs/rules/no-implied-eval
"no-lone-blocks": 2, // http://eslint.org/docs/rules/no-lone-blocks
"no-loop-func": 2, // http://eslint.org/docs/rules/no-loop-func
"no-multi-str": 2, // http://eslint.org/docs/rules/no-multi-str
"no-native-reassign": 2, // http://eslint.org/docs/rules/no-native-reassign
"no-new": 2, // http://eslint.org/docs/rules/no-new
"no-new-func": 2, // http://eslint.org/docs/rules/no-new-func
"no-new-wrappers": 2, // http://eslint.org/docs/rules/no-new-wrappers
"no-octal": 2, // http://eslint.org/docs/rules/no-octal
"no-octal-escape": 2, // http://eslint.org/docs/rules/no-octal-escape
"no-param-reassign": 2, // http://eslint.org/docs/rules/no-param-reassign
"no-proto": 2, // http://eslint.org/docs/rules/no-proto
"no-redeclare": 2, // http://eslint.org/docs/rules/no-redeclare
"no-return-assign": 2, // http://eslint.org/docs/rules/no-return-assign
"no-script-url": 2, // http://eslint.org/docs/rules/no-script-url
"no-self-compare": 2, // http://eslint.org/docs/rules/no-self-compare
"no-sequences": 2, // http://eslint.org/docs/rules/no-sequences
"no-throw-literal": 2, // http://eslint.org/docs/rules/no-throw-literal
"no-with": 2, // http://eslint.org/docs/rules/no-with
"radix": 2, // http://eslint.org/docs/rules/radix
"vars-on-top": 2, // http://eslint.org/docs/rules/vars-on-top
"wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife
"yoda": 2, // http://eslint.org/docs/rules/yoda
"max-len": [2, 160, 2, {
"ignoreComments": true,
"ignoreUrls": true
}], // http://eslint.org/docs/rules/max-len
"valid-jsdoc": 2, // http://eslint.org/docs/rules/valid-jsdoc
"quote-props": [2, "consistent-as-needed"], // http://eslint.org/docs/rules/quote-props
"no-console": 2, // http://eslint.org/docs/rules/no-console

/**
* Style
*/
"indent": [2, 2], // http://eslint.org/docs/rules/indent
"brace-style": [2, // http://eslint.org/docs/rules/brace-style
"1tbs", {
"allowSingleLine": true
}
],
"quotes": [
2, "double", "avoid-escape" // http://eslint.org/docs/rules/quotes
],
"camelcase": [2, { // http://eslint.org/docs/rules/camelcase
"properties": "always"
}],
"comma-spacing": [2, { // http://eslint.org/docs/rules/comma-spacing
"before": false,
"after": true
}],
"comma-style": [2, "last"], // http://eslint.org/docs/rules/comma-style
"eol-last": 2, // http://eslint.org/docs/rules/eol-last
"func-names": 0, // http://eslint.org/docs/rules/func-names
"func-style": [2, "declaration"], // http://eslint.org/docs/rules/func-style
"key-spacing": [2, { // http://eslint.org/docs/rules/key-spacing
"beforeColon": false,
"afterColon": true
}],
"new-cap": [0, { // http://eslint.org/docs/rules/new-cap (turned off for now, as it complains on all Match)
"newIsCap": true,
"capIsNewExceptions": ["Match", "OneOf", "Optional"],
}],
"no-multiple-empty-lines": [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines
"max": 2
}],
"no-nested-ternary": 2, // http://eslint.org/docs/rules/no-nested-ternary
"no-new-object": 2, // http://eslint.org/docs/rules/no-new-object
"no-array-constructor": 2, // http://eslint.org/docs/rules/no-array-constructor
"no-spaced-func": 2, // http://eslint.org/docs/rules/no-spaced-func
"no-trailing-spaces": 2, // http://eslint.org/docs/rules/no-trailing-spaces
"no-extra-parens": 2, // http://eslint.org/docs/rules/no-extra-parens
"no-underscore-dangle": 0, // http://eslint.org/docs/rules/no-underscore-dangle
"one-var": [2, "never"], // http://eslint.org/docs/rules/one-var
"padded-blocks": [2, "never"], // http://eslint.org/docs/rules/padded-blocks
"semi": [2, "always"], // http://eslint.org/docs/rules/semi
"semi-spacing": [2, { // http://eslint.org/docs/rules/semi-spacing
"before": false,
"after": true
}],
"space-after-keywords": 2, // http://eslint.org/docs/rules/space-after-keywords
"space-before-blocks": 2, // http://eslint.org/docs/rules/space-before-blocks
"space-before-function-paren": [2, {
"anonymous": "always",
"named": "never"
}], // http://eslint.org/docs/rules/space-before-function-paren
"space-infix-ops": 2, // http://eslint.org/docs/rules/space-infix-ops
"space-return-throw-case": 2, // http://eslint.org/docs/rules/space-return-throw-case
"space-in-parens": [2, "never"], // http://eslint.org/docs/rules/space-in-parens
"spaced-comment": [2, "always"], // http://eslint.org/docs/rules/spaced-comment
}
}
20 changes: 20 additions & 0 deletions packages/reaction-core/.jsbeautifyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"break_chained_methods": false,
"e4x": false,
"eval_code": false,
"indent_char": " ",
"indent_level": 0,
"indent_size": 2,
"indent_with_tabs": false,
"jslint_happy": true,
"keep_array_indentation": false,
"keep_function_indentation": false,
"max_preserve_newlines": 2,
"preserve_newlines": true,
"space_before_conditional": true,
"space_in_paren": false,
"unescape_strings": false,
"wrap_line_length": 80,
"space_after_anon_function": true,
"end_with_newline": true
}
20 changes: 6 additions & 14 deletions packages/reaction-core/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#Reaction Core

[![Circle CI](https://circleci.com/gh/reactioncommerce/reaction-core.svg?style=svg)](https://circleci.com/gh/reactioncommerce/reaction-core)
[![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/reactioncommerce/reaction?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
# Reaction Core
[![Circle CI](https://circleci.com/gh/reactioncommerce/reaction-core.svg?style=svg)](https://circleci.com/gh/reactioncommerce/reaction-core) [![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/reactioncommerce/reaction?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Reaction Core provides a core set of methods and templates for creating, connecting, and managing user carts, sessions, products, checkout and orders for Reaction Commerce.

Expand All @@ -28,12 +26,9 @@ curl -o client/themes/bootstrap/custom.reaction.json https://raw.githubuserconte
```

## Packages

You can find a list of published packages on [Atmosphere](https://atmospherejs.com/?q=reactioncommerce
)
You can find a list of published packages on [Atmosphere](https://atmospherejs.com/?q=reactioncommerce)

## Developer Documentation

[Meteor Documentation](http://docs.meteor.com)

[Getting started guide](http://thoughts.reactioncommerce.com/how-to-get-involved-with-reaction-commerce/)
Expand All @@ -52,19 +47,16 @@ You can find a list of published packages on [Atmosphere](https://atmospherejs.c

[Template Development](https://github.com/ongoworks/reaction-core/blob/master/docs/templates.md)

[Cart Workflow](docs/workflow.md)
[Workflow](docs/workflow.md)

[Deploying](https://github.com/ongoworks/reaction-core/blob/master/docs/deploying.md)


## Roadmap
For a high level review our roadmap, take a look at the vision page [Reaction Vision](http://reactioncommerce.com/vision)
For a high level review our roadmap, take a look at the features page [Reaction Vision](http://reactioncommerce.com/features)

For grouping of development channels by feature see project milestones: https://github.com/reactioncommerce/reaction/milestones
For grouping of development channels by feature see project milestones: [https://github.com/reactioncommerce/reaction/milestones](https://github.com/reactioncommerce/reaction/milestones)

And finally for the kanban-esque, hardcore real time progress view, take a look our [waffle board](https://waffle.io/reactioncommerce/reaction)


## Issues
For development tasks/issues please use the [Reaction project issues](https://github.com/reactioncommerce/reaction/issues?state=open). We're keeping this as the central issue tracking for all [reactioncommerce:*](https://github.com/reactioncommerce/) packages. You can also view issues on our [waffle board](https://waffle.io/reactioncommerce/reaction).

92 changes: 61 additions & 31 deletions packages/reaction-core/client/helpers/cart.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,87 @@
/*
* Template helpers for cart
*
*/

/**
* Template helpers for cart
*
* methods to return cart calculated values
* cartCount, cartSubTotal, cartShipping, cartTaxes, cartTotal
* are calculated by a transformation on the collection
* and are available to use in template as cart.xxx
* in template: {{cart.cartCount}}
* in code: ReactionCore.Collections.Cart.findOne().cartTotal()
*/

Template.registerHelper("cart", function() {
return {
showCartIconWarning: function() {
* cart template helper
* @description
* methods to return cart calculated values
* cartCount, cartSubTotal, cartShipping, cartTaxes, cartTotal
* are calculated by a transformation on the collection
* and are available to use in template as cart.xxx
* in template: {{cart.cartCount}}
* in code: ReactionCore.Collections.Cart.findOne().cartTotal()
* @return {Object} returns inventory helpers
*/
Template.registerHelper("cart", function () {
let cartHelpers = {
/**
* showCartIconWarning
* @return {Boolean} return true if low inventory on any item in cart
*/
showCartIconWarning() {
if (this.showLowInventoryWarning()) {
return true;
}
return false;
},
showLowInventoryWarning: function() {
var item, storedCart, _i, _len, _ref, _ref1, _ref2, _ref3;
storedCart = Cart.findOne();
if (storedCart != null ? storedCart.items : void 0) {
_ref = storedCart != null ? storedCart.items : void 0;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
if (((_ref1 = item.variants) != null ? _ref1.inventoryPolicy : void 0) && ((_ref2 = item.variants) != null ? _ref2.lowInventoryWarningThreshold : void 0)) {
if (((_ref3 = item.variants) != null ? _ref3.inventoryQuantity : void 0) <= item.variants.lowInventoryWarningThreshold) {
/**
* showLowInventoryWarning
* @return {Boolean} return true if low inventory on any item in cart
*/
showLowInventoryWarning() {
let item;
let storedCart = ReactionCore.Collections.Cart.findOne();
// we're not being picky here - first thing in cart
// that is low will trigger a inventory warning
if (storedCart !== null ? storedCart.items : void 0) {
for (item of storedCart.items) {
if (item.variants !== null && item.variants.inventoryPolicy &&
item.variants.lowInventoryWarningThreshold) {
if (item.variants.inventoryQuantity <= item.variants.lowInventoryWarningThreshold) {
return true;
}
}
}
}
return false;
},
showItemLowInventoryWarning: function(variant) {
if ((variant != null ? variant.inventoryPolicy : void 0) && (variant != null ? variant.lowInventoryWarningThreshold : void 0)) {
if ((variant != null ? variant.inventoryQuantity : void 0) <= variant.lowInventoryWarningThreshold) {
/**
* showLowInventoryWarning
* @param {Object} variant - variant object to check inventory levels on
* @return {Boolean} return true if low inventory on variant
*/
showItemLowInventoryWarning(variant) {
if ((variant !== null ? variant.inventoryPolicy : void 0) && (
variant !== null ? variant.lowInventoryWarningThreshold :
void 0
)) {
if ((variant !== null ? variant.inventoryQuantity : void 0) <=
variant.lowInventoryWarningThreshold) {
return true;
}
}
return false;
}
};
return cartHelpers;
});


/**
* cartPayerName
* gets current cart billing address / payment name
* @summary gets current cart billing address / payment name
* @return {String} returns cart.billing[0].fullName
*/

Template.registerHelper("cartPayerName", function() {
var _ref, _ref1, _ref2;
return (_ref = Cart.findOne()) != null ? (_ref1 = _ref.payment) != null ? (_ref2 = _ref1.address) != null ? _ref2.fullName : void 0 : void 0 : void 0;
Template.registerHelper("cartPayerName", function () {
let cart = ReactionCore.Collections.Cart.findOne();
if (cart) {
if (cart.billing) {
if (cart.billing[0].address) {
if (cart.billing[0].address.fullName) {
return cart.billing[0].address.fullName;
}
}
}
}
});
Loading

0 comments on commit 77f274f

Please sign in to comment.