-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Shipping panel normalization #1740
Merged
Merged
Changes from 28 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
f95abc7
Migrate flat rates to shipping-rates plugin
0280620
Update from release-0.19
a2124d0
Initial shipping grid refactor
f615503
Merge branch 'release-0.19.0' into 1404-shipping-dashboard-panels
ab0936e
Catch invalid product grid filters
5b3910c
Add transform
4220cfc
Flat rate editing
50aa1a7
Remove old shipping ui
f5320ba
remove Loading template
2c77c6b
Rename shippoMethod -> settings
a463c2a
consolidated checkout shipping template
4a35660
Default groups
8a55415
fallback to shop email for guest orders
07c9b97
Resolve variables.less conflict
bebc96b
make transform optional
7962bf2
Silence of the logs
ec91188
Catch case where items is undefined
0f59d0d
Updated SMS label
a481bda
Update imports, add roles
2d56952
bs form defaults
3f46cb2
Refactor notes
097c48f
Add shippo carrier UI
6e45652
Implement onGetShippingRates hook
3a41db5
Updated configuration alert
5ac92d9
Deprecate core shipping methods
1b753f8
Shippo Carrier editing
21ffb70
Add flatten-obj dependency
b780a6b
Remove iconButton from carriers
e049a09
Update shipping configuration check
7259774
Updated provider enable/disable handling
dc161df
Updated payment package toggle handling
37663f0
Merge branch 'release-0.19.0' into 1404-shipping-dashboard-panels
18e6e5a
Lint / review cleanup
4e4ab49
Updated dependencies
5cc5120
[better] pattern implementation for roles.
46fd621
Add loader, revised loading state check
f25f61d
Removed default enabled
f50bccb
Remove carrier label editing
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
imports/plugins/core/layout/client/templates/layout/loading/loading.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,45 @@ | ||
import _ from "lodash"; | ||
import { Cart, Shipping } from "/lib/collections"; | ||
import { Meteor } from "meteor/meteor"; | ||
import { Template } from "meteor/templating"; | ||
import { Reaction } from "/client/api"; | ||
import { Cart, Shipping } from "/lib/collections"; | ||
|
||
// | ||
// These helpers can be used in general shipping packages | ||
// cartShippingMethods to get current shipment methods | ||
// until we handle multiple methods, we just use the first | ||
function cartShippingMethods(currentCart) { | ||
// cartShippingQuotes | ||
// returns multiple methods | ||
function cartShippingQuotes(currentCart) { | ||
const cart = currentCart || Cart.findOne(); | ||
const shipmentQuotes = []; | ||
|
||
if (cart) { | ||
if (cart.shipping) { | ||
if (cart.shipping[0].shipmentQuotes) { | ||
return cart.shipping[0].shipmentQuotes; | ||
for (shipping of cart.shipping) { | ||
if (shipping.shipmentQuotes) { | ||
for (quote of shipping.shipmentQuotes) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here as well? |
||
shipmentQuotes.push(quote); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return undefined; | ||
return shipmentQuotes; | ||
} | ||
// getShipmentMethod to get current shipment method | ||
// until we handle multiple methods, we just use the first | ||
function getShipmentMethod(currentCart) { | ||
// cartShipmentMethods to get current shipment method | ||
// this returns multiple methods, if more than one carrier | ||
// has been chosen | ||
function cartShipmentMethods(currentCart) { | ||
const cart = currentCart || Cart.findOne(); | ||
const shipmentMethods = []; | ||
|
||
if (cart) { | ||
if (cart.shipping) { | ||
if (cart.shipping[0].shipmentMethod) { | ||
return cart.shipping[0].shipmentMethod; | ||
for (shipping of cart.shipping) { | ||
if (shipping.shipmentMethod) { | ||
shipmentMethods.push(shipping.shipmentMethod); | ||
} | ||
} | ||
} | ||
} | ||
return undefined; | ||
return shipmentMethods; | ||
} | ||
|
||
Template.coreCheckoutShipping.onCreated(function () { | ||
|
@@ -42,8 +52,11 @@ Template.coreCheckoutShipping.helpers({ | |
// retrieves current rates and updates shipping rates | ||
// in the users cart collection (historical, and prevents repeated rate lookup) | ||
shipmentQuotes: function () { | ||
const cart = Cart.findOne(); | ||
return cartShippingMethods(cart); | ||
const instance = Template.instance(); | ||
if (instance.subscriptionsReady()) { | ||
const cart = Cart.findOne(); | ||
return cartShippingQuotes(cart); | ||
} | ||
}, | ||
|
||
// helper to make sure there are some shipping providers | ||
|
@@ -59,10 +72,13 @@ Template.coreCheckoutShipping.helpers({ | |
// helper to display currently selected shipmentMethod | ||
isSelected: function () { | ||
const self = this; | ||
const shipmentMethod = getShipmentMethod(); | ||
// if there is already a selected method, set active | ||
if (_.isEqual(self.method, shipmentMethod)) { | ||
return "active"; | ||
const shipmentMethods = cartShipmentMethods(); | ||
|
||
for (method of shipmentMethods) { | ||
// if there is already a selected method, set active | ||
if (_.isEqual(self.method, method)) { | ||
return "active"; | ||
} | ||
} | ||
return null; | ||
}, | ||
|
@@ -71,8 +87,10 @@ Template.coreCheckoutShipping.helpers({ | |
const instance = Template.instance(); | ||
const isReady = instance.subscriptionsReady(); | ||
|
||
if (isReady) { | ||
return true; | ||
if (Reaction.Subscriptions.Cart.ready()) { | ||
if (isReady) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
|
23 changes: 0 additions & 23 deletions
23
imports/plugins/core/shipping/client/templates/flatRates/shipping.html
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
imports/plugins/core/shipping/client/templates/flatRates/shipping.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
import "./checkout/shipping.html"; | ||
import "./checkout/shipping.js"; | ||
|
||
import "./flatRates/shipping.html"; | ||
import "./flatRates/shipping.js"; | ||
|
||
import "./shipping.html"; | ||
import "./shipping.js"; | ||
import "./shipping.less"; | ||
import "./settings/shipping.html"; | ||
import "./settings/shipping.js"; |
21 changes: 21 additions & 0 deletions
21
imports/plugins/core/shipping/client/templates/settings/shipping.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<template name="shippingSettings"> | ||
{{#each reactionApps provides='shippingSettings'}} | ||
|
||
<div class="panel panel-default"> | ||
<div class="panel-heading panel-heading-flex"> | ||
<div class="panel-title"> | ||
<i class="fa fa-{{name}}"></i> | ||
<span data-i18n="{{i18nKeyLabel}}">{{label}}</span> | ||
|
||
</div> | ||
<div class="panel-controls"> | ||
<input class="checkbox-switch shipping-settings" type="checkbox" name="enabled" data-id={{packageId}} data-key="{{settingsKey}}" {{checked enabled}}> | ||
</div> | ||
</div> | ||
<div class="panel-body {{shown enabled}}"> | ||
{{> Template.dynamic template=template data=.}} | ||
</div> | ||
</div> | ||
{{/each}} | ||
|
||
</template> |
46 changes: 46 additions & 0 deletions
46
imports/plugins/core/shipping/client/templates/settings/shipping.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Template } from "meteor/templating"; | ||
/* | ||
* Template shippinges Helpers | ||
*/ | ||
Template.shippingSettings.onCreated(function () { | ||
this.autorun(() => { | ||
this.subscribe("Shipping"); | ||
}); | ||
}); | ||
|
||
Template.shippingSettings.helpers({ | ||
checked(enabled) { | ||
if (enabled === true) { | ||
return "checked"; | ||
} | ||
return ""; | ||
}, | ||
shown(enabled) { | ||
if (enabled !== true) { | ||
return "hidden"; | ||
} | ||
return ""; | ||
} | ||
}); | ||
|
||
Template.shippingSettings.events({ | ||
/** | ||
* shippingSettings settings update enabled status for shipping service on change | ||
* @param {event} event jQuery Event | ||
* @return {void} | ||
*/ | ||
"change input.checkbox-switch.shipping-settings[name=enabled]": (event) => { | ||
event.preventDefault(); | ||
const settingsKey = event.target.getAttribute("data-key"); | ||
const packageId = event.target.getAttribute("data-id"); | ||
const fields = [{ | ||
property: "enabled", | ||
value: event.target.checked | ||
}]; | ||
// save shipping registry updates | ||
if (packageId) { | ||
// TODO also disable providers | ||
Meteor.call("registry/update", packageId, settingsKey, fields); | ||
} | ||
} | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
const shipping
?