Skip to content

Commit

Permalink
Import Meteor pseudo-globals (reactioncommerce#1115)
Browse files Browse the repository at this point in the history
* Import Meteor pseudo-globals

Add Meteor pseudo-globals as recommended in
https://guide.meteor.com/v1.3/structure.html#importing-meteor-globals

* Import Meteor pseudo-globals
  • Loading branch information
Aaron Judd authored Jun 30, 2016
1 parent 553c0ff commit 5c92a43
Show file tree
Hide file tree
Showing 83 changed files with 194 additions and 23 deletions.
1 change: 1 addition & 0 deletions client/modules/accounts/helpers/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { _ } from "lodash";
import { ServiceConfigHelper } from "./util";
import { Template } from "meteor/templating";

export const LoginFormSharedHelpers = {

Expand Down
2 changes: 2 additions & 0 deletions client/modules/accounts/helpers/templates.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Reaction, i18next, i18nextDep } from "/client/api";
import * as Collections from "/lib/collections";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

Template.registerHelper("getGravatar", function (currentUser, size) {
const options = {
Expand Down
1 change: 1 addition & 0 deletions client/modules/accounts/helpers/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { _ } from "lodash";
import { Template } from "meteor/templating";

function capitalize(str) {
const finalString = str === null ? "" : String(str);
Expand Down
1 change: 1 addition & 0 deletions client/modules/accounts/helpers/validation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Meteor } from "meteor/meteor";

const validationMethods = {
/**
Expand Down
4 changes: 4 additions & 0 deletions client/modules/accounts/templates/addressBook/add/add.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { i18next } from "/client/api";
import * as Collections from "/lib/collections";
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

Template.addressBookAdd.helpers({
thisAddress: function () {
Expand All @@ -23,6 +26,7 @@ Template.addressBookAdd.helpers({
}
}
}

if (Session.get("address")) {
thisAddress.postal = Session.get("address").zipcode;
thisAddress.country = Session.get("address").countryCode;
Expand Down
3 changes: 3 additions & 0 deletions client/modules/accounts/templates/addressBook/addressBook.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Meteor } from "meteor/meteor";
import { ReactiveVar } from "meteor/reactive-var";
import { i18next } from "/client/api";
import * as Collections from "/lib/collections";
import { Template } from "meteor/templating";

/*
* Template.checkoutAddressBook
Expand Down
1 change: 1 addition & 0 deletions client/modules/accounts/templates/addressBook/edit/edit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { i18next } from "/client/api";
import { Meteor } from "meteor/meteor";

/*
* update address book (cart) form handling
Expand Down
25 changes: 14 additions & 11 deletions client/modules/accounts/templates/addressBook/form/form.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";
import { Countries } from "/client/collections";
import * as Collections from "/lib/collections";
import { Template } from "meteor/templating";

Template.addressBookForm.helpers({

Expand All @@ -9,23 +12,23 @@ Template.addressBookForm.helpers({
countryOptions: function () {
return Countries.find().fetch();
},
statesForCountry: function() {
var locale, options, ref, selectedCountry, shop, state;
shop = Collections.Shops.findOne();
selectedCountry = Session.get('addressBookCountry') || AutoForm.getFieldValue('country');
statesForCountry: function () {
let locale;
const shop = Collections.Shops.findOne();
const selectedCountry = Session.get("addressBookCountry") || AutoForm.getFieldValue("country");
if (!selectedCountry) {
return false;
}
if ((shop != null ? shop.locales.countries[selectedCountry].states : void 0) == null) {
if ((shop !== null ? shop.locales.countries[selectedCountry].states : void 0) === null) {
return false;
}
options = [];
ref = shop != null ? shop.locales.countries[selectedCountry].states : void 0;
for (state in ref) {
const ref = shop !== null ? shop.locales.countries[selectedCountry].states : void 0;
for (let state in ref) {
locale = ref[state];
options.push({
'label': locale.name,
'value': state
label: locale.name,
value: state
});
}
return options;
Expand Down Expand Up @@ -57,7 +60,7 @@ Template.addressBookForm.helpers({
});

Template.addressBookForm.events({
'change [name="country"]': function() {
return Session.set('addressBookCountry', AutoForm.getFieldValue('country'));
"change [name='country']": function () {
return Session.set("addressBookCountry", AutoForm.getFieldValue("country"));
}
});
2 changes: 2 additions & 0 deletions client/modules/accounts/templates/addressBook/grid/grid.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as Collections from "/lib/collections";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/*
* handles display of addressBook grid
Expand Down
2 changes: 2 additions & 0 deletions client/modules/accounts/templates/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Meteor } from "meteor/meteor";
import _ from "lodash";
import { Reaction, i18next } from "/client/api";
import { ServiceConfigHelper } from "../../helpers/util";
import { Template } from "meteor/templating";

/**
* Accounts helpers
Expand Down
3 changes: 3 additions & 0 deletions client/modules/accounts/templates/dropdown/dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Reaction, Logger } from "/client/api";
import { Tags } from "/lib/collections";
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

Template.loginDropdown.events({

Expand Down
1 change: 1 addition & 0 deletions client/modules/accounts/templates/forgot/forgot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { i18next } from "/client/api";
import { LoginFormSharedHelpers } from "/client/modules/accounts/helpers";
import { Template } from "meteor/templating";

Template.loginFormResetPasswordView.events({

Expand Down
3 changes: 3 additions & 0 deletions client/modules/accounts/templates/inline/inline.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/**
* Inline login form for instance where guest login is needed.
*/
Expand Down
3 changes: 3 additions & 0 deletions client/modules/accounts/templates/login/loginForm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

// ============================================================================
// Login form
//
Expand Down
2 changes: 2 additions & 0 deletions client/modules/accounts/templates/members/member.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Reaction } from "/client/api";
import { Packages, Shops } from "/lib/collections";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

const getPermissionMap = (permissions) => {
const permissionMap = {};
Expand Down
2 changes: 2 additions & 0 deletions client/modules/accounts/templates/members/memberForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Reaction, i18next } from "/client/api";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/**
* memberForm events
Expand Down
2 changes: 2 additions & 0 deletions client/modules/accounts/templates/profile/profile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as Collections from "/lib/collections";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/**
* onCreated: Account Profile View
Expand Down
2 changes: 2 additions & 0 deletions client/modules/accounts/templates/signIn/signIn.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { LoginFormSharedHelpers } from "/client/modules/accounts/helpers";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/**
* onCreated: Login form sign in view
Expand Down
1 change: 1 addition & 0 deletions client/modules/accounts/templates/signUp/signUp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LoginFormSharedHelpers } from "/client/modules/accounts/helpers";
import { Template } from "meteor/templating";

/**
* onCreated: Login form sign up view
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { i18next } from "/client/api";
import { LoginFormSharedHelpers } from "/client/modules/accounts/helpers";
import { Template } from "meteor/templating";

ModalHelper = {
closeModal: function (template) {
Expand Down
1 change: 1 addition & 0 deletions client/modules/core/accounts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Accounts } from "meteor/accounts-base";
import { Session } from "meteor/session";
// import { amplify } from "meteor/amplify";

/*
Expand Down
1 change: 1 addition & 0 deletions client/modules/core/helpers/apps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Reaction, Logger } from "/client/api";
import { Packages } from "/lib/collections";
import { Template } from "meteor/templating";

/**
*
Expand Down
4 changes: 4 additions & 0 deletions client/modules/core/helpers/globals.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";
// import { Roles } from "meteor/roles";

// Reaction Globals
//
// These should all be removed. PR's happily accepted.
Expand Down
2 changes: 2 additions & 0 deletions client/modules/core/helpers/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import Logger from "/client/modules/logger";
import { Reaction } from "../";
import * as Collections from "/lib/collections";
import { _ } from "lodash";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/**
* reactionTemplate helper
Expand Down
2 changes: 2 additions & 0 deletions client/modules/core/helpers/permissions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Reaction } from "../";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/*
* Methods for the reaction permissions
Expand Down
2 changes: 2 additions & 0 deletions client/modules/core/helpers/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { i18next } from "/client/modules/i18n";
import { Reaction } from "../";
import * as Collections from "/lib/collections";
import * as Schemas from "/lib/collections/schemas";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/*
*
Expand Down
2 changes: 2 additions & 0 deletions client/modules/core/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Meteor } from "meteor/meteor";
import { Session } from "meteor/session";
import { check } from "meteor/check";
import { Tracker } from "meteor/tracker";
import Logger from "/client/modules/logger";
import { Countries } from "/client/collections";
Expand Down
1 change: 1 addition & 0 deletions client/modules/core/startup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Tracker } from "meteor/tracker";
import Logger from "/client/modules/logger";
import Reaction from "./main";
import { Meteor } from "meteor/meteor";

// @see https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
let hidden;
Expand Down
2 changes: 2 additions & 0 deletions client/modules/i18n/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import accounting from "accounting-js";
import { i18next } from "/client/modules/i18n";
import { localeDep, i18nextDep } from "./main";
import { Reaction, Logger } from "/client/api";
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";

/**
* i18n
Expand Down
1 change: 1 addition & 0 deletions client/modules/i18n/templates/header/i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Reaction } from "/client/api";
import { Shops } from "/lib/collections";
import { Session } from "meteor/session";

/**
* i18nChooser helpers
Expand Down
2 changes: 2 additions & 0 deletions client/modules/i18n/templates/i18nSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import i18next from "i18next";
import { Countries } from "/client/collections";
import { Reaction } from "/client/api";
import { Shops } from "/lib/collections";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

Template.i18nSettings.helpers({
shop() {
Expand Down
3 changes: 3 additions & 0 deletions client/modules/router/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { Reaction } from "/client/api";
import { Logger } from "/client/modules/logger";
import { Packages, Shops } from "/lib/collections";
import { MetaData } from "/lib/api/router/metadata";
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";
import { Tracker } from "meteor/tracker";


// init flow-router
Expand Down
1 change: 1 addition & 0 deletions imports/plugins/core/checkout/client/helpers/cart.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Cart } from "/lib/collections";
import { Template } from "meteor/templating";

/*
* Template helpers for cart
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Reaction } from "/client/api";
import { Cart } from "/lib/collections";
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/**
* cartDrawer helpers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Swiper from "swiper";
import { Media, Products } from "/lib/collections";
import { _ } from "lodash";
import { Template } from "meteor/templating";

/**
* Add swiper to cartDrawerItems
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Cart } from "/lib/collections";
import { Template } from "meteor/templating";

/**
* cartSubTotals helpers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Reaction } from "/client/api";
import { Cart } from "/lib/collections";
import { Template } from "meteor/templating";

/**
* cartIcon helpers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Reaction } from "/client/api";
import { Session } from "meteor/session";

/**
* cartPanel events
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Reaction } from "/client/api";
import { Cart } from "/lib/collections";

import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import "./checkout.html";

//
Expand All @@ -13,6 +14,7 @@ Template.cartCheckout.helpers({
if (Reaction.Subscriptions.Cart.ready()) {
return Cart.findOne();
}
return {};
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Meteor } from "meteor/meteor";
import { Session } from "meteor/session";
import { Reaction, i18next } from "/client/api";
import { Orders } from "/lib/collections";
import { Template } from "meteor/templating";

/**
* cartCompleted helpers
Expand All @@ -18,6 +21,7 @@ Template.cartCompleted.helpers({
});
}
}
return {};
},
orderStatus: function () {
if (this.workflow.status === "new") {
Expand All @@ -32,6 +36,7 @@ Template.cartCompleted.helpers({
cartId: this._id
});
}
return {};
}
});

Expand All @@ -41,8 +46,9 @@ Template.cartCompleted.helpers({
* adds email to order
*/
Template.cartCompleted.events({
"click #update-order": function (event, template) {
const email = template.find("input[name=email]").value;
"click #update-order": function () {
let templateInstance = Template.instance();
const email = templateInstance.find("input[name=email]").value;
check(email, String);
const cartId = Reaction.Router.getQueryParam("_id");
return Meteor.call("orders/addOrderEmail", cartId, email);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Reaction } from "/client/api";
import { Cart } from "/lib/collections";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";

/**
* checkoutLoginCompleted
Expand Down
Loading

0 comments on commit 5c92a43

Please sign in to comment.