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

Fix: Dashboard panel keeps re-opening during checkout #1956

Merged
merged 4 commits into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion imports/plugins/core/checkout/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import "./templates/cartPanel/cartPanel.html";
import "./templates/cartPanel/cartPanel.js";

import "./templates/checkout/addressBook/addressBook.html";
import "./templates/checkout/addressBook/addressBook.js";
import "./templates/checkout/completed/completed.html";
import "./templates/checkout/completed/completed.js";
import "./templates/checkout/header/header.html";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "./review.html";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { Reaction } from "/client/api";

/**
* review status
Expand All @@ -10,9 +9,4 @@ import { Reaction } from "/client/api";

Template.checkoutReview.onRendered(function () {
Meteor.call("workflow/pushCartWorkflow", "coreCartWorkflow", "checkoutReview");
Reaction.showActionView({
name: "payment/settings",
provides: "settings",
template: "paymentSettings"
});
});
50 changes: 32 additions & 18 deletions imports/plugins/core/payments/client/checkout/payment/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,43 @@ import { Reaction } from "/client/api";
import "./methods.html";

Template.corePaymentMethods.helpers({
enabledPayments() {
const enabledPayments = [];
const apps = Reaction.Apps({
provides: "paymentMethod",
enabled: true
});
for (app of apps) {
if (app.enabled === true) enabledPayments.push(app);
}
return enabledPayments;
enabledPayments
});

Template.corePaymentMethods.onCreated(function () {
const payments = enabledPayments();
const paymentsEnabled = payments.length;
// If no payments enabled, show payments settings dashboard
if (!paymentsEnabled) {
openActionView();
}
});

Template.corePaymentMethods.events({
"click [data-event-action=configure-payment-methods]"(event) {
event.preventDefault();

const dashboardRegistryEntry = Reaction.Apps({ name: "reaction-dashboard", provides: "shortcut" });
const paymentRegistryEntry = Reaction.Apps({ name: "reaction-payments", provides: "settings" });

Reaction.showActionView([
dashboardRegistryEntry[0],
paymentRegistryEntry[0]
]);
openActionView();
}
});

function enabledPayments() {
const enabledPaymentsArr = [];
const apps = Reaction.Apps({
provides: "paymentMethod",
enabled: true
});
for (app of apps) {
if (app.enabled === true) enabledPaymentsArr.push(app);
}
return enabledPaymentsArr;
}

function openActionView() {
const dashboardRegistryEntry = Reaction.Apps({ name: "reaction-dashboard", provides: "shortcut" });
const paymentRegistryEntry = Reaction.Apps({ name: "reaction-payments", provides: "settings" });

Reaction.showActionView([
dashboardRegistryEntry[0],
paymentRegistryEntry[0]
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ Template.coreCheckoutShipping.onCreated(function () {
this.autorun(() => {
this.subscribe("Shipping");
});

const shippingOpts = {
provides: "settings",
name: "settings/shipping",
template: "shippingSettings"
};

const cart = Cart.findOne();
const shipping = cartShippingQuotes(cart);
const shippingAval = shipping.length;
// If shipping not set, show shipping settings dashboard
if (!shippingAval) {
Reaction.showActionView(shippingOpts);
}
});

Template.coreCheckoutShipping.helpers({
Expand Down