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

PDP Revisions and Revised #1356

Merged
merged 155 commits into from
Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from 131 commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
2b0a36c
Initial start for handling product revisions
mikemurray Jul 29, 2016
43ab02c
Merge branch 'development' into pdp-workflow-1178
mikemurray Jul 29, 2016
daddd17
Product visibility and draft reactivity restored
mikemurray Aug 2, 2016
a8c127b
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 2, 2016
4187176
Cleanups and added ability to mark products as deleted
mikemurray Aug 5, 2016
ee7db3c
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 5, 2016
731d5cc
Publishing and diffs
mikemurray Aug 9, 2016
c28d4bb
Added ability to publish multiple top level products
mikemurray Aug 10, 2016
d9abc63
Fix show diffs toggle
mikemurray Aug 10, 2016
ff81385
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 10, 2016
297b4e6
tag create / remove are now properly directed to a revision.
mikemurray Aug 10, 2016
f472b0d
Fixed bug preventing metadata from revision updating
mikemurray Aug 10, 2016
00cb43a
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 10, 2016
83f5c9c
Added some tests for product handle and revisions
mikemurray Aug 10, 2016
c80b149
updated from development
Aug 15, 2016
5dd0260
updated lodash dependencies
Aug 15, 2016
e4c5c84
updating tests for product revisions
mikemurray Aug 15, 2016
6cdcb07
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 15, 2016
27322f5
Updated more product tests.
mikemurray Aug 15, 2016
ac01343
Fixing more tests
mikemurray Aug 16, 2016
6ca3aa5
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 16, 2016
38cef56
Fixing even more product tests.
mikemurray Aug 16, 2016
eb9ae74
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 16, 2016
f59e379
Removing some test expects as they have no chance of every being true
mikemurray Aug 17, 2016
66924bb
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 17, 2016
4c8d9c6
PDP react
mikemurray Aug 19, 2016
9a4f5b2
Variant and edit component updates
mikemurray Aug 20, 2016
aac4b34
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 22, 2016
b3bb1ba
added child variants to variant list
mikemurray Aug 23, 2016
1296754
Added tooltips, cart button and revision object handling
mikemurray Aug 26, 2016
587b70d
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 26, 2016
7209989
React product detail page updates
mikemurray Aug 27, 2016
90ea600
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 27, 2016
a5a263b
Added tags component to PDP
mikemurray Aug 29, 2016
ea6a74b
Updated CSS classes for react PDP media gallery
mikemurray Aug 29, 2016
8d6a0f7
UI updates for varaints
mikemurray Aug 29, 2016
5312801
Merge branch 'development' into pdp-workflow-1178
mikemurray Aug 29, 2016
d4bf0d5
Cleanup of price formatting
mikemurray Aug 29, 2016
4810f92
Provide translation updated to product detail container
mikemurray Aug 29, 2016
479894c
React based social component
mikemurray Aug 31, 2016
e2670b8
Added pinterest button
mikemurray Sep 1, 2016
09d28b2
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 1, 2016
2e6a488
Edit buttons for everything
mikemurray Sep 6, 2016
78e257d
product detail editing improvements
mikemurray Sep 6, 2016
4b04c6b
removed template tag
mikemurray Sep 6, 2016
0d4b31f
product admin form react
mikemurray Sep 6, 2016
0611044
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 6, 2016
252e64e
metadata management and style updates
mikemurray Sep 7, 2016
998a4a4
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 7, 2016
90d5c10
Adding WIP react tag list editor
mikemurray Sep 7, 2016
8c8f49c
React product detail page is now primary
mikemurray Sep 8, 2016
540663b
Remove git ignored config file
mikemurray Sep 8, 2016
b45d128
Updated textfield className handling
mikemurray Sep 8, 2016
4b0b449
Add ability to define multiple fields on edit button for diffs
mikemurray Sep 8, 2016
332da6a
Product social container how handles change notifications properly
mikemurray Sep 8, 2016
b36e576
Selectable variant and child variant
mikemurray Sep 8, 2016
7c083b0
Cleanup product detail tags and metadata.
mikemurray Sep 8, 2016
fad233a
React based inline alert components and containers
mikemurray Sep 9, 2016
63a4fa5
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 9, 2016
779ce79
React based drag and drop.
mikemurray Sep 9, 2016
8a9eb2a
Create, update and remove tag functionality added.
mikemurray Sep 9, 2016
bd54658
Update style of customer facing metadata component
mikemurray Sep 9, 2016
ab20946
Move media gallery to core ui components
mikemurray Sep 10, 2016
4b478b8
removed unused component
mikemurray Sep 10, 2016
cb14d4f
Media gallery upload and remove
mikemurray Sep 10, 2016
6766496
Media gallery drag and drop sortable
mikemurray Sep 12, 2016
eea6e9b
Updated registry entries and media gallery
mikemurray Sep 12, 2016
75b0c94
Fixed erroneous display of edit buttons with permissions
mikemurray Sep 12, 2016
18738b0
Switch media gallery for ul to div
mikemurray Sep 12, 2016
bd63e23
Fixed exception caused by undefined data
mikemurray Sep 12, 2016
b65e603
Add publish controls to product admin
mikemurray Sep 12, 2016
e9c2f57
Updated publishing workflow.
mikemurray Sep 12, 2016
179ab72
Updated package.json with react-dnd and react-dropzone dependencies.
mikemurray Sep 14, 2016
3e67dc7
Tag updates
mikemurray Sep 14, 2016
dd2c225
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 14, 2016
041482d
Updated some references to lodash isArray to use built in Array.isArray
mikemurray Sep 14, 2016
7cb7908
Fixed broken multi-file uploads for media gallery.
mikemurray Sep 15, 2016
63d7da6
Added add button to add images using the file picker.
mikemurray Sep 15, 2016
4cc0ff8
Fixed missing card titled for product admin
mikemurray Sep 15, 2016
e863a56
Renamed classname to match file name.
mikemurray Sep 15, 2016
98b9ff6
Added card group component.
mikemurray Sep 15, 2016
fa9d97f
Updated product admin with card group component
mikemurray Sep 15, 2016
d88b985
Updated product admin fields to be multiline
mikemurray Sep 15, 2016
30df62e
Updated metadata component
mikemurray Sep 15, 2016
7abde9b
Fix broken tag test
mikemurray Sep 16, 2016
55aa780
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 16, 2016
5aa5bd4
Re-Enabled and updated product publication tests.
mikemurray Sep 16, 2016
c7a1e94
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 16, 2016
38be177
clean up product publication tests
mikemurray Sep 16, 2016
a798d89
Fixed slowdown caused by social buttons.
mikemurray Sep 17, 2016
2731051
Fix tag submit on enter key
mikemurray Sep 17, 2016
c5121d8
Updated tags
mikemurray Sep 18, 2016
61a085a
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 18, 2016
38b2a2b
Updated drag-n-drop for variants
mikemurray Sep 18, 2016
7a702a8
Updated media drag-n-drop
mikemurray Sep 18, 2016
bf6ce0d
Update meta field styles and RTL styles
mikemurray Sep 18, 2016
87b93fd
Add metadata (details) placeholders with translations
mikemurray Sep 18, 2016
6a96f6b
Load and display child variant media.
mikemurray Sep 18, 2016
8173836
Fixed issues causing suggestions to change on arrow key input
mikemurray Sep 18, 2016
c99713a
Add placeholder for tag input
mikemurray Sep 18, 2016
b8f9e5d
Updated media gallery uploader placeholder display
mikemurray Sep 18, 2016
f8db6ff
space-out social buttons
mikemurray Sep 19, 2016
d95f3fd
add link type button
mikemurray Sep 19, 2016
4319fff
Add basic ability to change product handle manually
mikemurray Sep 19, 2016
be7b11a
Added button toggle text, and fixed translation issues
mikemurray Sep 19, 2016
bf459b5
Product delete callback
mikemurray Sep 19, 2016
3fbf92a
ensure product handle is always slug-ified
mikemurray Sep 19, 2016
1c87ccc
Removed duplicated delete function
mikemurray Sep 19, 2016
6b96092
removed console.log
mikemurray Sep 19, 2016
244563a
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 19, 2016
395b2c9
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 20, 2016
5830931
Fix for incorrect product handle being applied to grid items
mikemurray Sep 20, 2016
b65ccb9
Props and PropType fixes
mikemurray Sep 20, 2016
c240ca0
Translation component updates.
mikemurray Sep 20, 2016
1bd3fcf
Add settings panel for revision control settings
mikemurray Sep 20, 2016
eeff53f
Allow disable of revision control system.
mikemurray Sep 20, 2016
6e6a622
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 20, 2016
6137370
Cleanup and removed unused props.
mikemurray Sep 21, 2016
0421838
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 21, 2016
b833e50
Tooltip plugin cleanup
mikemurray Sep 22, 2016
28741c0
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 22, 2016
4502117
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 22, 2016
f6a9edd
Added ability to disable new product detail page alongside revision c…
mikemurray Sep 22, 2016
c0ad9bb
More css selector specificity
mikemurray Sep 22, 2016
b3418d8
Enable / disable publish controls
mikemurray Sep 22, 2016
c2cef22
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 22, 2016
3d13acf
Publish revision control enabled status to users.
mikemurray Sep 23, 2016
e706795
Merge branch 'development' into pdp-workflow-1178
mikemurray Sep 23, 2016
1d5c8e0
Fix legacy PDP media gallery styles.
mikemurray Sep 23, 2016
d772240
Added media gallery hover
mikemurray Sep 23, 2016
a937c2c
Fix safari flex box bug with icon button.
mikemurray Sep 23, 2016
d94d76f
Add max width to PDP container.
mikemurray Sep 26, 2016
4522831
Force add icon index file
mikemurray Sep 26, 2016
54b4b9c
removed console log in sortableItem
mikemurray Sep 26, 2016
3f98b78
moved revision logging level to debug
mikemurray Sep 26, 2016
e991983
Fixed bug that caused any change to a variant to toggle visibility
mikemurray Sep 27, 2016
08e11f2
Load media for social buttons
mikemurray Sep 27, 2016
b8f55ce
Removed logging statement
mikemurray Sep 27, 2016
8b46e0c
Added badge for deleted variants
mikemurray Sep 27, 2016
fba5ee0
Fix weird variant selection behavior
mikemurray Sep 27, 2016
8ba2a4d
Fix for undefined FB reference and cleanup
mikemurray Sep 27, 2016
70b4050
Fix for broken tests due to revision control on / off state
mikemurray Sep 27, 2016
4732bab
Updated react-autosuggest to 6.0.4
mikemurray Sep 28, 2016
b5c2f2c
Fixed typo on visibility button tooltip
mikemurray Sep 28, 2016
49cb8b8
Clicking a variant while action view is open will now focus it for ed…
mikemurray Sep 28, 2016
f691b95
Fixed typo in CSS classname
mikemurray Sep 28, 2016
885a2bb
Fixed classname typo
mikemurray Sep 28, 2016
90209d4
Fix errors caused by change event attached to file upload input
mikemurray Sep 28, 2016
9c9cc5a
Added ability to restore product variants from trash
mikemurray Sep 28, 2016
ae81f10
Don't delete media when variant is deleted.
mikemurray Sep 28, 2016
830f650
Adds ability to restore a deleted product for current draft
mikemurray Sep 28, 2016
ca0d1cf
Updated alert confirm to SWAL
mikemurray Sep 28, 2016
8c9e289
Fixed issues causing incorrect revision to be displayed for top variant
mikemurray Sep 28, 2016
380b2c9
remove security group from pull approve
Sep 28, 2016
c5bd92e
Merge branch 'development' into pdp-workflow-1178
Sep 30, 2016
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
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
"jsx-quotes": [2, "prefer-double"], // http://eslint.org/docs/rules/jsx-quotes
"react/no-deprecated": 1,
"react/display-name": 1,
"react/forbid-prop-types": 1,
"react/forbid-prop-types": 0,
"react/jsx-boolean-value": 0,
"react/jsx-closing-bracket-location": [1, "after-props"],
"react/jsx-closing-bracket-location": 1,
"react/jsx-curly-spacing": 1,
"react/jsx-indent-props": [1, 2],
"react/jsx-max-props-per-line": [1, {
Expand Down
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ practicalmeteor:sinon


# Custom Packages
johanbrook:publication-collector@1.0.2
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ htmljs@1.0.11
http@1.2.9
id-map@1.0.8
jeremy:stripe@1.6.0
johanbrook:publication-collector@1.0.2
jparker:crypto-core@0.1.0
jparker:crypto-md5@0.1.1
jparker:gravatar@0.5.1
Expand Down
124 changes: 124 additions & 0 deletions client/modules/i18n/currency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import accounting from "accounting-js";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { localeDep, i18nextDep } from "./main";
import { Reaction, Logger, i18next } from "/client/api";

/**
* formatPriceString
* @summary return shop /locale specific formatted price
* also accepts a range formatted with " - "
* @param {String} currentPrice - currentPrice or "xx.xx - xx.xx" formatted String
* @return {String} returns locale formatted and exchange rate converted values
*/
export function formatPriceString(formatPrice) {
const locale = Reaction.Locale.get();

if (typeof locale !== "object" || typeof locale.currency !== "object") {
// locale not yet loaded, so we don"t need to return anything.
return false;
}

if (typeof formatPrice !== "string" && typeof formatPrice !== "number") {
return false;
}

// for the cases then we have only one price. It is a number.
const currentPrice = formatPrice.toString();
let price = 0;
const prices = ~currentPrice.indexOf(" - ") ?
currentPrice.split(" - ") : [currentPrice];

// basic "for" is faster then "for ...of" for arrays. We need more speed here
const len = prices.length;
for (let i = 0; i < len; i++) {
const originalPrice = prices[i];
try {
// we know the locale, but we don"t know exchange rate. In that case we
// should return to default shop currency
if (typeof locale.currency.rate !== "number") {
throw new Meteor.Error("exchangeRateUndefined");
}
prices[i] *= locale.currency.rate;

price = _formatPrice(price, originalPrice, prices[i],
currentPrice, locale.currency, i, len);
} catch (error) {
Logger.debug("currency error, fallback to shop currency");
price = _formatPrice(price, originalPrice, prices[i],
currentPrice, locale.shopCurrency, i, len);
}
}

return price;
}

export function formatNumber(currentPrice) {
const locale = Reaction.Locale.get();
let price = currentPrice;
const format = Object.assign({}, locale.currency, {
format: "%v"
});
const shopFormat = Object.assign({}, locale.shopCurrency, {
format: "%v"
});

if (typeof locale.currency === "object" && locale.currency.rate) {
price = currentPrice * locale.currency.rate;
return accounting.formatMoney(price, format);
}

Logger.debug("currency error, fallback to shop currency");
return accounting.formatMoney(currentPrice, shopFormat);
}

/**
* _formatPrice
* private function for formatting locale currency
* @private
* @param {Number} price price
* @param {Number} originalPrice originalPrice
* @param {Number} actualPrice actualPrice
* @param {Number} currentPrice currentPrice
* @param {Number} currency currency
* @param {Number} pos position
* @param {Number} len length
* @return {Number} formatted price
*/
function _formatPrice(price, originalPrice, actualPrice, currentPrice, currency,
pos, len) {
// this checking for locale.shopCurrency mostly
if (typeof currency !== "object") {
return false;
}

let adjustedPrice = actualPrice;
let formattedPrice;

// Precision is mis-used in accounting js. Scale is the propery term for number
// of decimal places. Let's adjust it here so accounting.js does not break.
if (currency.scale !== undefined) {
currency.precision = currency.scale;
}

// If there are no decimal places, in the case of the Japanese Yen, we adjust it here.
if (currency.scale === 0) {
adjustedPrice = actualPrice * 100;
}

// @param {string} currency.where: If it presents - in situation then two
// prices in string, currency sign will be placed just outside the right price.
// For now it should be manually added to fixtures shop data.
if (typeof currency.where === "string" && currency.where === "right" &&
len > 1 && pos === 0) {
const modifiedCurrency = Object.assign({}, currency, {
symbol: ""
});
formattedPrice = accounting.formatMoney(adjustedPrice, modifiedCurrency);
} else {
// accounting api: http://openexchangerates.github.io/accounting.js/
formattedPrice = accounting.formatMoney(adjustedPrice, currency);
}

return price === 0 ? currentPrice.replace(originalPrice, formattedPrice) : price.replace(originalPrice, formattedPrice);
}
116 changes: 2 additions & 114 deletions client/modules/i18n/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import accounting from "accounting-js";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { localeDep, i18nextDep } from "./main";
import { formatPriceString } from "./currency";
import { Reaction, Logger, i18next } from "/client/api";

/**
Expand Down Expand Up @@ -49,120 +48,9 @@ Template.registerHelper("currencySymbol", function () {
*/
Template.registerHelper("formatPrice", function (formatPrice) {
localeDep.depend();

const locale = Reaction.Locale.get();

if (typeof locale !== "object" || typeof locale.currency !== "object") {
// locale not yet loaded, so we don"t need to return anything.
return false;
}

if (typeof formatPrice !== "string" && typeof formatPrice !== "number") {
return false;
}

// for the cases then we have only one price. It is a number.
const currentPrice = formatPrice.toString();
let price = 0;
const prices = ~currentPrice.indexOf(" - ") ?
currentPrice.split(" - ") : [currentPrice];

// basic "for" is faster then "for ...of" for arrays. We need more speed here
const len = prices.length;
for (let i = 0; i < len; i++) {
const originalPrice = prices[i];
try {
// we know the locale, but we don"t know exchange rate. In that case we
// should return to default shop currency
if (typeof locale.currency.rate !== "number") {
throw new Meteor.Error("exchangeRateUndefined");
}
prices[i] *= locale.currency.rate;

price = _formatPrice(price, originalPrice, prices[i],
currentPrice, locale.currency, i, len);
} catch (error) {
Logger.debug("currency error, fallback to shop currency");
price = _formatPrice(price, originalPrice, prices[i],
currentPrice, locale.shopCurrency, i, len);
}
}

return price;
return formatPriceString(formatPrice);
});

Reaction.Currency = {};

Reaction.Currency.formatNumber = function (currentPrice) {
const locale = Reaction.Locale.get();
let price = currentPrice;
const format = Object.assign({}, locale.currency, {
format: "%v"
});
const shopFormat = Object.assign({}, locale.shopCurrency, {
format: "%v"
});

if (typeof locale.currency === "object" && locale.currency.rate) {
price = currentPrice * locale.currency.rate;
return accounting.formatMoney(price, format);
}

Logger.debug("currency error, fallback to shop currency");
return accounting.formatMoney(currentPrice, shopFormat);
};

/**
* _formatPrice
* private function for formatting locale currency
* @private
* @param {Number} price price
* @param {Number} originalPrice originalPrice
* @param {Number} actualPrice actualPrice
* @param {Number} currentPrice currentPrice
* @param {Number} currency currency
* @param {Number} pos position
* @param {Number} len length
* @return {Number} formatted price
*/
function _formatPrice(price, originalPrice, actualPrice, currentPrice, currency,
pos, len) {
// this checking for locale.shopCurrency mostly
if (typeof currency !== "object") {
return false;
}

let adjustedPrice = actualPrice;
let formattedPrice;

// Precision is mis-used in accounting js. Scale is the propery term for number
// of decimal places. Let's adjust it here so accounting.js does not break.
if (currency.scale !== undefined) {
currency.precision = currency.scale;
}

// If there are no decimal places, in the case of the Japanese Yen, we adjust it here.
if (currency.scale === 0) {
adjustedPrice = actualPrice * 100;
}

// @param {string} currency.where: If it presents - in situation then two
// prices in string, currency sign will be placed just outside the right price.
// For now it should be manually added to fixtures shop data.
if (typeof currency.where === "string" && currency.where === "right" &&
len > 1 && pos === 0) {
const modifiedCurrency = Object.assign({}, currency, {
symbol: ""
});
formattedPrice = accounting.formatMoney(adjustedPrice, modifiedCurrency);
} else {
// accounting api: http://openexchangerates.github.io/accounting.js/
formattedPrice = accounting.formatMoney(adjustedPrice, currency);
}

return price === 0 ? currentPrice.replace(originalPrice, formattedPrice) : price.replace(originalPrice, formattedPrice);
}

Object.assign(Reaction, {
/**
* translateRegistry
Expand Down
1 change: 1 addition & 0 deletions client/modules/i18n/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import i18next, { getBrowserLanguage, i18nextDep, localeDep } from "./main";
export * from "./currency";

export {
i18next,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ Alerts = {
},
collection_: new Mongo.Collection(null)
};

export default Alerts;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import accounting from "accounting-js";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { ReactiveVar } from "meteor/reactive-var";
import { Reaction, i18next, Logger } from "/client/api";
import { i18next, Logger, formatNumber } from "/client/api";
import { NumericInput } from "/imports/plugins/core/ui/client/components";
import { Media, Orders, Shops } from "/lib/collections";
import _ from "lodash";
Expand Down Expand Up @@ -248,7 +248,7 @@ Template.coreOrderShippingInvoice.helpers({
},

money(amount) {
return Reaction.Currency.formatNumber(amount);
return formatNumber(amount);
},

disabled() {
Expand Down
Loading