-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for issue #972
- Loading branch information
aaronjudd
committed
Aug 3, 2016
1 parent
2f4a0a6
commit 9a0614f
Showing
37 changed files
with
1,216 additions
and
49 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,6 +133,7 @@ raix:[email protected] | |
raix:[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
|
@@ -148,6 +149,7 @@ [email protected] | |
[email protected] | ||
[email protected] | ||
[email protected] | ||
tmeasday:[email protected] | ||
tmeasday:[email protected] | ||
[email protected] | ||
[email protected] | ||
|
Empty file.
Empty file.
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,13 @@ | ||
import "./checkout/taxes.html"; | ||
import "./checkout/taxes.js"; | ||
import "./settings/griddle.jsx"; | ||
import "./settings/avalara.html"; | ||
import "./settings/avalara.js"; | ||
import "./settings/custom.html"; | ||
import "./settings/custom.js"; | ||
import "./settings/settings.html"; | ||
import "./settings/settings.js"; | ||
import "./settings/taxcloud.html"; | ||
import "./settings/taxcloud.js"; | ||
import "./settings/taxjar.html"; | ||
import "./settings/taxjar.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,8 @@ | ||
<template name="avalaraSettings"> | ||
{{#autoForm collection=Collections.Packages schema=packageConfigSchema doc=packageData type="update" id="avalara-update-form"}} | ||
<div class="panel-body"> | ||
{{>afQuickField name='settings.avalara.apiLoginId' class='form-control'}} | ||
</div> | ||
{{> shopSettingsSubmitButton}} | ||
{{/autoForm}} | ||
</template> |
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,31 @@ | ||
import { Template } from "meteor/templating"; | ||
import { AutoForm } from "meteor/aldeed:autoform"; | ||
import { i18next } from "/client/api"; | ||
import { Packages } from "/lib/collections"; | ||
import { TaxPackageConfig } from "../../lib/collections/schemas"; | ||
|
||
Template.avalaraSettings.helpers({ | ||
packageConfigSchema() { | ||
return TaxPackageConfig; | ||
}, | ||
packageData() { | ||
return Packages.findOne({ | ||
name: "reaction-taxes" | ||
}); | ||
} | ||
}); | ||
|
||
|
||
AutoForm.hooks({ | ||
"avalara-update-form": { | ||
onSuccess: function () { | ||
return Alerts.toast(i18next.t("shopSettings.shopTaxMethodsSaved"), | ||
"success"); | ||
}, | ||
onError: function (operation, error) { | ||
return Alerts.toast( | ||
`${i18next.t("shopSettings.shopTaxMethodsFailed")} ${error}`, "error" | ||
); | ||
} | ||
} | ||
}); |
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,52 @@ | ||
<template name="customTaxRates"> | ||
<div> | ||
{{> React component=griddleTable | ||
publication="Taxes" | ||
collection=Taxes | ||
matchingResultsCount="taxes-count" | ||
filteredFields=filteredFields | ||
columns=filteredFields | ||
noDataMessage=noDataMessage | ||
onRowClick=editRow | ||
useExternal=true | ||
}} | ||
</div> | ||
|
||
|
||
{{instance}} | ||
{{#if instance.state.get 'editing'}} | ||
<div> | ||
{{#autoForm | ||
collection=Collections.Taxes | ||
schema=Schemas.Taxes | ||
type="method" | ||
meteormethod="taxes/addRate" | ||
id="customTaxRates-update-form" | ||
}} | ||
{{> afQuickField name='taxCode' options=taxCodes class='form-control'}} | ||
{{> afQuickField name='cartMethod' options="allowed" class='form-control'}} | ||
{{> afQuickField name='taxLocale' options="allowed" class='form-control'}} | ||
{{> afQuickField name='taxShipping'}} | ||
{{> afQuickField name='taxIncluded'}} | ||
{{> afQuickField name='discountsIncluded'}} | ||
{{> afQuickField name='country' options=countryOptions value=country class='form-control'}} | ||
<div> | ||
<label class="control-label">{{afFieldLabelText name='region'}}</label> | ||
{{#if statesForCountry}} | ||
{{>afFieldInput name="region" value=region options=statesForCountry class='form-control'}} | ||
{{else}} | ||
{{>afFieldInput name="region" value=region class='form-control'}} | ||
{{/if}} | ||
{{#if afFieldIsInvalid name="region"}} | ||
<span class="help-block">{{afFieldMessage name="region"}}</span> | ||
{{/if}} | ||
</div> | ||
{{> afQuickField name='postal' class='form-control'}} | ||
{{> afQuickField name='rate' class='form-control'}} | ||
{{> shopSettingsSubmitButton}} | ||
{{/autoForm}} | ||
</div> | ||
{{else}} | ||
<div class="nav-group">...</div> | ||
{{/if}} | ||
</template> |
116 changes: 116 additions & 0 deletions
116
imports/plugins/core/tax-base/client/settings/custom.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,116 @@ | ||
// import { checkNpmVersions } from "meteor/tmeasday:check-npm-versions"; | ||
import { Template } from "meteor/templating"; | ||
import { MeteorGriddle } from "./griddle"; | ||
import { ReactiveDict } from "meteor/reactive-dict"; | ||
import { Shops, Countries } from "/lib/collections"; | ||
import { Taxes, TaxCodes } from "../../lib/collections"; | ||
import { i18next } from "/client/api"; | ||
import { TaxPackageConfig } from "../../lib/collections/schemas"; | ||
|
||
Template.customTaxRates.onCreated(function () { | ||
this.autorun(() => { | ||
this.subscribe("Taxes"); | ||
}); | ||
|
||
this.state = new ReactiveDict(); | ||
this.state.setDefault({ | ||
editing: false | ||
}); | ||
}); | ||
|
||
Template.customTaxRates.helpers({ | ||
packageConfigSchema() { | ||
return TaxPackageConfig; | ||
}, | ||
countryOptions: function () { | ||
return Countries.find().fetch(); | ||
}, | ||
country: function () { | ||
const shop = Shops.findOne(); | ||
if (shop && typeof shop.addressBook === "Array") { | ||
const country = shop.addressBook[0].country; | ||
return country; | ||
} | ||
return []; | ||
}, | ||
statesForCountry: function () { | ||
const shop = Shops.findOne(); | ||
const selectedCountry = AutoForm.getFieldValue("country"); | ||
if (!selectedCountry) { | ||
return false; | ||
} | ||
if ((shop !== null ? shop.locales.countries[selectedCountry].states : void 0) === null) { | ||
return false; | ||
} | ||
options = []; | ||
if (shop && typeof shop.locales.countries[selectedCountry].states === "object") { | ||
for (const state in shop.locales.countries[selectedCountry].states) { | ||
if ({}.hasOwnProperty.call(shop.locales.countries[selectedCountry].states, state)) { | ||
const locale = shop.locales.countries[selectedCountry].states[state]; | ||
options.push({ | ||
label: locale.name, | ||
value: state | ||
}); | ||
} | ||
} | ||
} | ||
return options; | ||
}, | ||
filteredFields() { | ||
return ["taxCode", "rate", "country", "region", "postal"]; | ||
}, | ||
Taxes() { | ||
return Taxes; | ||
}, | ||
packageData() { | ||
return Taxes.find(); | ||
}, | ||
taxCodes() { | ||
const instance = Template.instance(); | ||
if (instance.subscriptionsReady()) { | ||
const taxCodes = TaxCodes.find().fetch(); | ||
const options = [{ | ||
label: i18next.t("app.auto"), | ||
value: "none" | ||
}]; | ||
|
||
for (let taxCode of taxCodes) { | ||
options.push({ | ||
label: i18next.t(taxCode.label), | ||
value: taxCode.id | ||
}); | ||
} | ||
return options; | ||
} | ||
return []; | ||
}, | ||
griddleTable() { | ||
return MeteorGriddle; | ||
}, | ||
editRow(options) { | ||
return (options ) => { | ||
const instance = Template.instance(); | ||
console.log(instance.state.get("editing")); | ||
instance.state.set("editing", options.props.data); | ||
Session.set("editingTaxCode", options.props.data); | ||
console.log("here in edit row", options.props.data); | ||
}; | ||
}, | ||
noDataMessage() { | ||
return i18next.t("shopSettings.noCustomTaxRatesFound"); | ||
} | ||
}); | ||
|
||
AutoForm.hooks({ | ||
"customTaxRates-update-form": { | ||
onSuccess: function () { | ||
return Alerts.toast(i18next.t("shopSettings.shopCustomTaxRatesSaved"), | ||
"success"); | ||
}, | ||
onError: function (operation, error) { | ||
return Alerts.toast( | ||
`${i18next.t("shopSettings.shopCustomTaxRatesFailed")} ${error}`, "error" | ||
); | ||
} | ||
} | ||
}); |
Oops, something went wrong.