Skip to content

Commit

Permalink
Merge branch 'development' into joykare-inventory-tracking-1928
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Judd authored Mar 29, 2017
2 parents d15edf5 + bc16da9 commit 634975e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 21 deletions.
4 changes: 3 additions & 1 deletion client/modules/router/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ export function ReactionLayout(options = {}) {
if (Reaction.Subscriptions.Shops.ready()) {
const shop = Shops.findOne(Reaction.getShopId());
if (shop) {
const newLayout = shop.layout.find((x) => selectLayout(x, layout, workflow));
const sortedLayout = shop.layout.sort((prev, next) => prev.priority - next.priority);
const newLayout = sortedLayout.find((x) => selectLayout(x, layout, workflow));

// oops this layout wasn't found. render notFound
if (!newLayout) {
BlazeLayout.render("notFound");
Expand Down
5 changes: 0 additions & 5 deletions imports/plugins/core/checkout/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,34 @@ Reaction.registerPackage({
workflow: "coreCartWorkflow",
container: "checkout-steps-main",
audience: ["guest", "anonymous"],
priority: 1,
position: "1"
}, {
template: "checkoutAddressBook",
label: "Shipping Billing",
workflow: "coreCartWorkflow",
container: "checkout-steps-main",
audience: ["guest", "anonymous"],
priority: 2,
position: "2"
}, {
template: "coreCheckoutShipping",
label: "Shipping Options",
workflow: "coreCartWorkflow",
container: "checkout-steps-main",
audience: ["guest", "anonymous"],
priority: 3,
position: "3"
}, {
template: "checkoutReview",
label: "Review Payment",
workflow: "coreCartWorkflow",
container: "checkout-steps-side",
audience: ["guest", "anonymous"],
priority: 4,
position: "4"
}, {
template: "checkoutPayment",
label: "Complete",
workflow: "coreCartWorkflow",
container: "checkout-steps-side",
audience: ["guest", "anonymous"],
priority: 5,
position: "5"
}]
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Migrations } from "/imports/plugins/core/versions";
import { Packages } from "/lib/collections";

const reactionPkgs = [ // reaction packages with layouts
"reaction-accounts",
"reaction-checkout",
"reaction-dashboard",
"reaction-email",
"reaction-orders",
"reaction-ui",
"reaction-inventory",
"reaction-product-variant"];

const query = {
name: { $in: reactionPkgs },
layout: { $type: 3 } // docs with layouts set
};

Migrations.add({
version: 4,
up() {
const packages = Packages.find(query).fetch();
packages.forEach(updateHandler(1, 999));
},
down() {
const packages = Packages.find(query).fetch();
packages.forEach(updateHandler(999, 1));
}
});

function updateHandler(oldValue, newValue) {
return function (pkg) {
let changed = false; // to track if updating is needed
pkg.layout.forEach((layout) => {
if (!layout.priority || layout.priority === oldValue) {
layout.priority = newValue;
changed = true;
}
});

if (changed) {
Packages.update(pkg._id, {
$set: { layout: pkg.layout }
});
}
};
}
1 change: 1 addition & 0 deletions imports/plugins/core/versions/server/migrations/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./1_rebuild_account_and_order_search_collections";
import "./2_add_key_to_search_ui";
import "./3_reset_package_registry";
import "./4_update_templates_priority";
17 changes: 2 additions & 15 deletions lib/collections/schemas/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ import { SimpleSchema } from "meteor/aldeed:simple-schema";
* "adminControlsFooter": "adminControlsFooter"
*/

/**
* Permissions Schema
*/

export const Audience = new SimpleSchema({
permission: {
type: String
},
label: {
type: String
}
});

export const LayoutStructure = new SimpleSchema({
template: {
type: String,
Expand Down Expand Up @@ -115,7 +102,7 @@ export const Layout = new SimpleSchema({
optional: true
},
audience: {
type: [Audience],
type: [String],
optional: true
},
structure: {
Expand All @@ -125,7 +112,7 @@ export const Layout = new SimpleSchema({
priority: {
type: Number,
optional: true,
defaultValue: 1
defaultValue: 999
},
position: {
type: Number,
Expand Down

0 comments on commit 634975e

Please sign in to comment.