Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Apps, payment packages #1592

Merged
merged 26 commits into from
Nov 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bc83c9e
move discount rates to catalog/codes to payments
Nov 11, 2016
b7db046
restore default method data
Nov 11, 2016
02cfdd2
Merge branch 'release-0.18.0' into discount-code-payments
Nov 12, 2016
6aa638e
Merge branch 'release-0.18.0' into discount-code-payments
Nov 13, 2016
17585fb
Merge branch 'release-0.18.0' into discount-code-payments
Nov 15, 2016
94c3c99
Merge branch 'release-0.18.0' into discount-code-payments
Nov 15, 2016
3a780d5
[WIP] Updates to package registry
Nov 20, 2016
bfbc451
Merge remote-tracking branch 'origin/release-0.18.0' into package-set…
Nov 20, 2016
7ab967c
updated reaction Apps
Nov 22, 2016
ac48108
Merge remote-tracking branch 'origin/release-0.18.0' into package-set…
Nov 22, 2016
2e25174
Add localhost WS browser-policy
Nov 23, 2016
81893a7
Payment package updates, removes name
Nov 23, 2016
a4704d6
Move mergeDeep into /lib/api/helpers
Nov 24, 2016
b9865ed
Update settings handling
Nov 24, 2016
2869e66
Cleanup panels in payments, taxes
Nov 24, 2016
3d56c34
Updated package
Nov 25, 2016
5825750
PayPal as split payment methods
Nov 25, 2016
1588b3e
Add Month Translations to monthOptions helper
Nov 27, 2016
73561ed
updated payments styling, missing i18n
Nov 27, 2016
86d2199
object-curly-spacing lint rules applied
Nov 27, 2016
46ec4e6
Avoid localLocale.defineLocale warning
Nov 28, 2016
66a8f00
Clarify Auth.net credentials messaging
Nov 28, 2016
100bafe
Only display enabled payment methods to admin in checkout
Nov 28, 2016
ea74c21
Updated import/requires for moment
Nov 28, 2016
41aa37b
Updated translation
Nov 28, 2016
35cf759
Update styling for payment settings
Nov 28, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
/**
* ES6
*/
"object-curly-spacing": ["error", "always", { "objectsInObjects": true }],
"no-var": 2, // http://eslint.org/docs/rules/no-var

/**
* Variables
*/
Expand Down
1 change: 0 additions & 1 deletion .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ kadira:flow-router-ssr
matb33:collection-hooks
meteorhacks:ssr
meteorhacks:subs-manager
momentjs:moment
ongoworks:security
raix:ui-dropped-event
risul:moment-timezone
Expand Down
2 changes: 1 addition & 1 deletion .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ [email protected]
[email protected]
[email protected]
[email protected]
momentjs:moment@2.16.0
momentjs:moment@2.17.0
[email protected]
[email protected]
[email protected]
Expand Down
6 changes: 3 additions & 3 deletions client/modules/accounts/helpers/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Template.registerHelper("displayName", function (displayUser) {
// new check covers previous check?
if (Roles.userIsInRole(user._id || user.userId, "account/profile",
Reaction.getShopId())) {
return i18next.t("accountsUI.guest", {defaultValue: "Guest"});
return i18next.t("accountsUI.guest", { defaultValue: "Guest" });
}
}
});
Expand Down Expand Up @@ -70,10 +70,10 @@ Template.registerHelper("fName", function (displayUser) {
case !user.services.pinterest:
return user.services.pinterest.first_name;
default:
return i18next.t("accountsUI.guest", {defaultValue: "Guest"});
return i18next.t("accountsUI.guest", { defaultValue: "Guest" });
}
})();
return username;
}
return i18next.t("accountsUI.signIn", {defaultValue: "Sign in"});
return i18next.t("accountsUI.signIn", { defaultValue: "Sign in" });
});
2 changes: 1 addition & 1 deletion client/modules/accounts/helpers/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class ServiceConfigHelper {
const configurations = ServiceConfiguration.configurations.find().fetch();

return _.map(availableServices, (name) => {
const matchingConfigurations = _.filter(configurations, {service: name});
const matchingConfigurations = _.filter(configurations, { service: name });
let service = {
name,
label: this.capitalizedServiceName(name),
Expand Down
5 changes: 3 additions & 2 deletions client/modules/accounts/templates/members/member.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@


{{#each groupsForUser}}
{{#if permissionGroups}}
<div class="panel-body">
<h3><i class="fa fa-shopping-cart"></i> {{shopLabel}}</h3>
</div>
Expand Down Expand Up @@ -88,6 +89,6 @@ <h3><i class="fa fa-shopping-cart"></i> {{shopLabel}}</h3>
</div>
{{/each}}
</div>
{{/each}}

{{/if}}
{{/each}}
</template>
2 changes: 1 addition & 1 deletion client/modules/accounts/templates/members/member.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Template.memberSettings.helpers({
_id: shopId
});
if (shop && shop.name) {
return shop.name;
return shop.name || "Default Shop";
}
},
permissionGroups: function (thisShopId) {
Expand Down
2 changes: 1 addition & 1 deletion client/modules/accounts/templates/signIn/signIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Template.loginFormSignInView.events({
const password = passwordInput.val().trim();

const validatedEmail = LoginFormValidation.email(username);
const validatedPassword = LoginFormValidation.password(password, {validationLevel: "exists"});
const validatedPassword = LoginFormValidation.password(password, { validationLevel: "exists" });

const templateInstance = Template.instance();
const errors = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Template.loginFormChangePassword.events({

// We only check if it exists, just incase we"ve change the password strength and want the
// user to have an oppurtinity to update to a stronger password
const validatedOldPassword = LoginFormValidation.password(password, {validationLevel: "exists"});
const validatedOldPassword = LoginFormValidation.password(password, { validationLevel: "exists" });
const validatedPassword = LoginFormValidation.password(password);

const templateInstance = Template.instance();
Expand Down
142 changes: 23 additions & 119 deletions client/modules/core/helpers/apps.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import { Reaction, Logger } from "/client/api";
import _ from "lodash";
import { Reaction } from "/client/api";
import { Packages } from "/lib/collections";
import { Template } from "meteor/templating";

/**
*
* reactionApps
*
* provides="<where matching registry provides is this >"
* enabled=true <false for disabled packages>
* context= true filter templates to current route
*
* returns matching package registry objects
* @todo:
* - reintroduce a dependency context
* - introduce position,zones #148
* - is it better to get all packages once and filter in code
* and possibly have some cache benefits down the road,
* or to retrieve what is requested and gain the advantage of priviledged,
* unnecessary data not retrieved with the cost of additional requests.
* - context filter should be considered experimental
*
* returns matching package registry objects
* @example {{#each reactionApps provides="settings" name=packageName container=container}}
* @example {{#each reactionApps provides="userAccountDropdown" enabled=true}}
* @example
Expand Down Expand Up @@ -54,9 +44,7 @@ export function Apps(optionHash) {
const filter = {};
const registryFilter = {};
let key;
let match;
let packages;
let reactionApps = [];
const reactionApps = [];
let options = {};

// allow for object or option.hash
Expand All @@ -79,115 +67,31 @@ export function Apps(optionHash) {
for (key in options) {
if ({}.hasOwnProperty.call(options, key)) {
const value = options[key];
if (!(key === "enabled" || key === "name" || key === "shopId")) {
filter["registry." + key] = value;
registryFilter[key] = value;
} else {
filter[key] = value;
}
}
}

// return these fields
const fields = {
enabled: 1,
registry: 1,
name: 1,
provides: 1,
icon: 1
};

// fetch the packages
const reactionPackages = Packages.find(filter, fields).fetch();

// apply filters to registry items
if (reactionPackages.length) {
// filter by package and enabled true/false
if (filter.name && filter.enabled) {
packages = (function () {
const results = [];
for (const pkg of reactionPackages) {
if (pkg.name === filter.name && pkg.enabled === filter.enabled) {
results.push(pkg);
}
}
return results;
})();
// we want all entries by package name
} else if (filter.name) {
packages = (function () {
const results = [];
for (const pkg of reactionPackages) {
if (pkg.name === filter.name) {
results.push(pkg);
}
}
return results;
})();
// just all enabled packages
} else if (filter.enabled) {
packages = (function () {
const results = [];
for (const pkg of reactionPackages) {
if (pkg.enabled === filter.enabled) {
results.push(pkg);
}
}
return results;
})();
// no filter
} else {
packages = (function () {
const results = [];
for (const pkg of reactionPackages) {
results.push(pkg);
}
return results;
})();
}

// we have all the package app registry entries
for (const app of packages) {
// go through the registry entries and push enabled entries
if (app.registry) {
for (let registry of app.registry) {
match = 0;
for (key in registryFilter) {
// make sure we're dealing with valid keys
if ({}.hasOwnProperty.call(registryFilter, key)) {
const value = registryFilter[key];
if (registry[key] === value) {
match += 1;
}
if (match === Object.keys(registryFilter).length) {
if (!registry.packageName) registry.packageName = app.name;
if (registry.enabled !== false) {
registry = Reaction.translateRegistry(registry, app);
registry.enabled = registry.enabled || app.enabled;
registry.packageId = app._id;
// check permissions before pushing so that templates aren't required.
if (Reaction.hasPermission([registry.name, registry.route])) {
reactionApps.push(registry);
}
}
}
if (value) {
if (!(key === "enabled" || key === "name" || key === "shopId")) {
filter["registry." + key] = value;
registryFilter[key] = value;
} else {
// perhaps not the best way to check but lets admin see all packages
if (!Reaction.hasAdminAccess()) {
if (key !== "shopId") {
registryFilter[key] = value;
}
}
filter[key] = value;
}
}
}
// we only need any given package once, let's be sure.
reactionApps = _.uniq(reactionApps);

// sort cycle to ensure order
reactionApps = reactionApps.sort((a, b) => a.priority - b.priority).slice();
} // end reactionPackages check

// enable debug to find missing reaction apps
if (reactionApps.length === 0) {
Logger.info("Failed to return matching reaction apps for", optionHash);
}
// we're done.

// fetch the packages
Packages.find(filter).forEach((app) => {
const matchingRegistry = _.filter(app.registry, registryFilter);
for (registry of matchingRegistry) {
reactionApps.push(registry);
}
});
// sort cycle to ensure order aka. is registry.priority working? .sort((a, b) => a.priority - b.priority).slice();
return reactionApps;
}

Expand Down
19 changes: 1 addition & 18 deletions client/modules/core/helpers/globals.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";
// import { Roles } from "meteor/roles";
import { Roles } from "meteor/alanning:roles";

// Reaction Globals
//
Expand All @@ -9,23 +9,6 @@ import { Meteor } from "meteor/meteor";
/* eslint "no-extend-native": [2, {"exceptions": ["String"]}] */
/* eslint "no-alert": 0 */

/**
* String.prototype.toCamelCase
* @summary special toCamelCase for converting a string to camelCase for use with i18n keys
* @return {String} camelCased string
*/
String.prototype.toCamelCase = function () {
let s;
s = this.replace(/([^a-zA-Z0-9_\- ])|^[_0-9]+/g, "").trim().toLowerCase();
s = s.replace(/([ -]+)([a-zA-Z0-9])/g, function (a, b, c) {
return c.toUpperCase();
});
s = s.replace(/([0-9]+)([a-zA-Z])/g, function (a, b, c) {
return b + c.toUpperCase();
});
return s;
};

/**
* toggleSession
* quick and easy snippet for toggling sessions
Expand Down
Loading