Skip to content

Commit

Permalink
Merge tag '8.27.9' into feature/pimp-fonts
Browse files Browse the repository at this point in the history
8.27.0

Conflicts:
	sprd/model/AbstractShop.js
  • Loading branch information
it-ony committed Oct 2, 2014
2 parents e823ac5 + 6981357 commit c73177b
Show file tree
Hide file tree
Showing 34 changed files with 543 additions and 108 deletions.
4 changes: 4 additions & 0 deletions bin/jsonMerge.js 100644 → 100755
Expand Up @@ -16,6 +16,7 @@
*
*/
var fs = require('fs'),
path = require('path'),
nodeCommand = process.title,
filename1, filename2,
outputFilename,
Expand All @@ -28,6 +29,9 @@ var fs = require('fs'),
filename1 = args.shift();
filename2 = args.shift();

filename1= path.resolve(filename1.replace(/^~\//, process.env.HOME + '/'));
filename2 = path.resolve(filename2.replace(/^~\//, process.env.HOME + '/'));

if (!(filename1 && filename2)) {
console.error('not enough arguments');
console.log('usage: ' + [nodeCommand, __filename.match(/[^/]+$/), 'inputFile1', 'inputFile2', '[outputFilename]'].join(' '));
Expand Down
5 changes: 5 additions & 0 deletions sprd/data/SprdApiDataSource.xml
Expand Up @@ -83,6 +83,11 @@
signatureRequired="true"/>
<conf:ResourceConfiguration path="objectTypes" modelClassName="sprd.model.ObjectType"/>

<conf:ResourceConfiguration path="orders" modelClassName="sprd.model.Order"
apiKeyRequired="true" sessionRequired="true" signatureRequired="true">
<conf:ResourceConfiguration path="items" modelClassName="sprd.model.OrderItem"
processor="OrderItemProcessor"/>
</conf:ResourceConfiguration>

</conf:DataSourceConfiguration>
</data:SprdApiDataSourceClass>
3 changes: 2 additions & 1 deletion sprd/data/SprdApiDataSourceClass.js
Expand Up @@ -14,7 +14,8 @@ define(["sprd/data/SprdDataSource", "js/data/RestDataSource", "underscore", "spr

$processors: {
BasketProcessor: BasketProcessor,
BasketItemProcessor: BasketItemProcessor
BasketItemProcessor: BasketItemProcessor,
OrderItemProcessor: BasketItemProcessor
},

getQueryParameters: function (method, resource) {
Expand Down
36 changes: 25 additions & 11 deletions sprd/entity/Address.js
@@ -1,4 +1,4 @@
define(["js/data/Entity", "sprd/entity/ShippingState", "sprd/entity/Country", "sprd/entity/Person", "sprd/data/validator/LengthValidator", "js/data/validator/RegExValidator"], function (Entity, ShippingState, Country, Person, LengthValidator, RegExValidator) {
define(["js/data/Entity", "sprd/entity/ShippingState", "sprd/entity/Country", "sprd/entity/Person", "sprd/data/validator/LengthValidator", "js/data/validator/RegExValidator", "js/data/transformer/TrimTransformer"], function (Entity, ShippingState, Country, Person, LengthValidator, RegExValidator, TrimTransformer) {

var ADDRESS_TYPES = {
PACKSTATION: "PACKSTATION",
Expand Down Expand Up @@ -46,7 +46,9 @@ define(["js/data/Entity", "sprd/entity/ShippingState", "sprd/entity/Country", "s
},
company: {
type: String,
required: false
required: function () {
return this.isCompany();
}
},

person: Person,
Expand All @@ -65,6 +67,7 @@ define(["js/data/Entity", "sprd/entity/ShippingState", "sprd/entity/Country", "s
city: String,
houseNumber: String,
state: {
isReference: true,
type: ShippingState,
required: function () {
return this.isStateRequired();
Expand Down Expand Up @@ -105,6 +108,10 @@ define(["js/data/Entity", "sprd/entity/ShippingState", "sprd/entity/Country", "s
}
},

transformers: [
new TrimTransformer()
],

validators: [
new LengthValidator({
field: "zipCode",
Expand Down Expand Up @@ -160,15 +167,19 @@ define(["js/data/Entity", "sprd/entity/ShippingState", "sprd/entity/Country", "s
compose: function () {
var data = this.callBase();

if (this.get("country.code") !== "US") {
if (!this.isStateRequired()) {
delete data.state;
}

if (!this.needsZipCode() && !data.zipCode) {
data.zipCode = "-";
}

if (this.get('type') === ADDRESS_TYPES.PACKSTATION) {
data.street = PACKSTATION + data.packStationNr;
data.street = PACKSTATION + (data.packStationNr || "").replace(/packstation/i, " ").replace(/^\s*|\s*$/, "");
data.streetAnnex = POSTNUMMER + data.postNr;
} else {
delete data.packstationNr;
delete data.packStationNr;
delete data.postNr;
}

Expand All @@ -179,19 +190,22 @@ define(["js/data/Entity", "sprd/entity/ShippingState", "sprd/entity/Country", "s
return this.$.type == ADDRESS_TYPES.PACKSTATION;
}.onChange('type'),

supportsCounty: function () {
var code = this.get('country.code');
return code === "GB" || code === "IE";
needsCounty: function () {
return this.get('country.code') === "IE";
}.onChange('country'),

isStateRequired: function () {
var code = this.get("country.code");
return code === "US" || code === "IE";
return this.get("country.code") === "US";
}.onChange('country'),

needsZipCode: function () {
// not required for ireland
return this.get("country.code") !== "IE";
}.onChange('country')
}.onChange('country'),

isCompany: function () {
return this.get('person.salutation') == "4"
}.onChange('person.salutation')
});

Address.ADDRESS_TYPES = ADDRESS_TYPES;
Expand Down
4 changes: 2 additions & 2 deletions sprd/entity/Configuration.js
Expand Up @@ -166,7 +166,7 @@ define(['js/data/Entity', 'sprd/entity/Offset', 'sprd/entity/Size', 'sprd/entity
for (var i = 0; i < printTypes.length; i++) {
newPrintType = printTypes[i];
val = this._validatePrintTypeSize(newPrintType, width, height, scale);
if (!(val.printTypeScaling || val.maxBound || val.minBound)) {
if (!(val.printTypeScaling || val.maxBound || val.minBound || val.dpiBound)) {
// if the previous print type is valid, use it
if (printTypeWasScaled && this.$.originalPrintType === newPrintType) {
preferredPrintType = newPrintType;
Expand Down Expand Up @@ -222,7 +222,7 @@ define(['js/data/Entity', 'sprd/entity/Offset', 'sprd/entity/Size', 'sprd/entity

var ret = this._validatePrintTypeSize(printType, this.get('size.width'), this.get('size.height'), this.$.scale);

return !ret.maxBound && !ret.minBound && !ret.printTypeScaling;
return !ret.maxBound && !ret.minBound && !ret.printTypeScaling && !ret.dpiBound;
}.onChange('_size.width', '_size.height', 'scale'),

_hasHardBoundaryError: function (offset, width, height, rotation, scale) {
Expand Down
2 changes: 1 addition & 1 deletion sprd/entity/DesignConfiguration.js
Expand Up @@ -142,7 +142,7 @@ define(['sprd/entity/Configuration', 'sprd/entity/Size', 'sprd/util/UnitUtil', '
}

ret.minBound = !printType.isShrinkable() && Math.min(Math.abs(scale.x), Math.abs(scale.y)) * 100 < (this.get("design.restrictions.minimumScale"));
ret.maxBound = ret.maxBound || printType.isShrinkable() && !design.isVectorDesign() && Math.max(Math.abs(scale.x), Math.abs(scale.y)) > 1;
ret.dpiBound = printType.isShrinkable() && !design.isVectorDesign() && Math.max(Math.abs(scale.x), Math.abs(scale.y)) > 1;

return ret;

Expand Down
12 changes: 12 additions & 0 deletions sprd/entity/Payment.js
Expand Up @@ -11,6 +11,18 @@ define(["js/data/Entity"], function(Entity) {
return this.type;
},

clearData: function() {
var $ = this.$,
data = {};
for (var key in $) {
if ($.hasOwnProperty(key) && key !== "root" && key !== "paymentTypeGroup") {
data[key] = null;
}
}

this.set(data);
},

/***
* determinate the real payment method. This is a hook so the credit card
* payment type group can select the payment method
Expand Down
17 changes: 4 additions & 13 deletions sprd/entity/Person.js
@@ -1,4 +1,4 @@
define(["js/data/Entity", "js/data/validator/RegExValidator"], function (Entity, RegExValidator) {
define(["js/data/Entity", "js/data/transformer/TrimTransformer"], function (Entity, TrimTransformer) {

var SalutationMap = {
"1": "mr",
Expand All @@ -21,17 +21,8 @@ define(["js/data/Entity", "js/data/validator/RegExValidator"], function (Entity,
lastName: String
},

validators: [
new RegExValidator({
field: "lastName",
regEx: /^[0-9a-zA-Z]{0,30}$/,
errorCode: 'lastNameError'
}),
new RegExValidator({
field: "firstName",
regEx: /^[0-9a-zA-Z]{0,30}$/,
errorCode: 'firstNameError'
})
transformers: [
new TrimTransformer()
],

fullName: function () {
Expand All @@ -58,6 +49,6 @@ define(["js/data/Entity", "js/data/validator/RegExValidator"], function (Entity,

contraction: function () {
return SalutationMap[this.$.salutation];
}.onChange("id")
}.onChange("salutation")
});
});
16 changes: 15 additions & 1 deletion sprd/entity/ShippingState.js
Expand Up @@ -4,19 +4,33 @@ define(["js/data/Entity", "sprd/entity/ShippingRegion"], function (Entity, Shipp

defaults: {
name: "",
isoCode: "",
code: "",
shippingRegion: null,
shippingSupported: true,
externalFulfillmentSupported: true
},

idField: "code",

schema: {
name: String,
isoCode: String,
shippingRegion: ShippingRegion,
shippingSupported: Boolean,
externalFulfillmentSupported: Boolean
},

parse: function (data) {

if (data.isoCode) {
data.code = data.isoCode;
delete data.isoCode;
}

return this.callBase(data);

}


});
});
6 changes: 5 additions & 1 deletion sprd/helper/DomainHelper.js
Expand Up @@ -3,17 +3,21 @@ define(["underscore"], function(_) {
var domainMap = {
EU: {
de_DE: "de",
de_CH: "ch",
de_AT: "at",
fr_CH: "ch/fr",
fr_FR: "fr",
se_SE: "se",
dk_DK: "dk",
fi_FI: "fi",
nl_BE: "be/nl",
nl_NL: "nl",
pl_PL: "pl",
es_ES: "es",
it_CH: "ch/it",
it_IT: "it",
no_NO: "no",
be_BE: "be",
fr_BE: "be",
en_EU: "net",
en_IE: "ie",
en_GB: "co.uk"
Expand Down
4 changes: 3 additions & 1 deletion sprd/lib/ScrollIntoView.js
Expand Up @@ -69,10 +69,12 @@ define([], function() {
return;
}


var body = document.body || document.getElementsByTagName("body")[0];
var scrollTop = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;

if (to === undefined) {
to = element.getBoundingClientRect().top + body.parentNode.scrollTop;
to = element.getBoundingClientRect().top + scrollTop;
}

scrollTo(to + offset);
Expand Down
35 changes: 33 additions & 2 deletions sprd/manager/ApiBasketManager.js
Expand Up @@ -91,6 +91,16 @@ define(["sprd/manager/IBasketManager", "flow", "sprd/model/Basket", "xaml!sprd/d

},

_commitBasket: function(basket) {

if (basket) {
basket = basket.clone();
}

// remember a clone
this.$originalBasket = basket;
},

/**
* Adds an element to the basket without saving it
* @param element
Expand Down Expand Up @@ -244,7 +254,13 @@ define(["sprd/manager/IBasketManager", "flow", "sprd/model/Basket", "xaml!sprd/d
cb();
});
})
.exec(callback);
.exec(function(err) {
if (!err) {
self.$originalBasket = basket.clone();
}

callback && callback(err, basket);
});
}
});
}
Expand Down Expand Up @@ -291,9 +307,24 @@ define(["sprd/manager/IBasketManager", "flow", "sprd/model/Basket", "xaml!sprd/d
},

saveBasketDebounced: function () {

var self = this;

this._triggerBasketUpdating();
this._debounceFunctionCall(function () {
this.saveBasket();

this.saveBasket(function(err) {
if (err) {
// couldn't save basket, restore clone
if (self.$originalBasket) {
self.$originalBasket.sync();
}
} else {
// success create a new copy of it
self.$originalBasket = self.$.basket.clone();
}
});

}, "saveBasketCall", 700, this);
},

Expand Down
4 changes: 1 addition & 3 deletions sprd/manager/AuthenticationManager.js
Expand Up @@ -92,11 +92,9 @@ define(["js/core/Component", "xaml!sprd/data/SprdApiDataSource", "flow", "sprd/m
self = this;

if (!session) {
callback && callback();
return;
session = this.$.api.createEntity(Session, "current");
}


session.remove(null, function(err) {
if (self.$.session === session) {
self.set("session", null);
Expand Down
2 changes: 1 addition & 1 deletion sprd/manager/ProductManager.js
Expand Up @@ -251,7 +251,7 @@ define(["sprd/manager/IProductManager", "underscore", "flow", "sprd/util/Product
};

var result = configuration._validatePrintTypeSize(printType, currentConfigurationWidth, currentConfigurationHeight, preferredScale);
if (result.minBound || result.maxBound) {
if (result.minBound || result.maxBound || result.dpiBound) {
continue;
}

Expand Down
9 changes: 8 additions & 1 deletion sprd/manager/TextConfigurationManager.js
@@ -1,4 +1,4 @@
define(["sprd/manager/ITextConfigurationManager", "flow", 'sprd/entity/Size', "text/entity/TextFlow", "text/entity/ParagraphElement", "text/entity/SpanElement", "sprd/type/Style", "text/entity/TextRange"], function (Base, flow, Size, TextFlow, ParagraphElement, SpanElement, Style, TextRange) {
define(["sprd/manager/ITextConfigurationManager", "flow", 'sprd/entity/Size', "text/entity/TextFlow", "text/entity/ParagraphElement", "text/entity/SpanElement", "sprd/type/Style", "text/entity/TextRange", "underscore"], function (Base, flow, Size, TextFlow, ParagraphElement, SpanElement, Style, TextRange, _) {
return Base.inherit("sprd.manager.TextConfigurationManager", {
initializeConfiguration: function (configuration, callback) {

Expand Down Expand Up @@ -55,6 +55,13 @@ define(["sprd/manager/ITextConfigurationManager", "flow", 'sprd/entity/Size', "t
for (var i = 0; i < content.length; i++) {
var tspan = content[i];

if (_.isString(tspan)) {
// text tag without tspans
tspan = {
content: [tspan]
}
}

if (!lastTSpan || tspan.hasOwnProperty("y")) {
if (paragraph) {
paragraph.mergeElements();
Expand Down
9 changes: 8 additions & 1 deletion sprd/model/AbstractShop.js
Expand Up @@ -32,7 +32,14 @@ define(['sprd/data/SprdModel', 'js/data/Collection', 'sprd/model/Currency', 'spr
var platform = this.$.platform,
id = this.$.id;
return (platform === "EU" && id == MarketPlace.EU) || (platform === "NA" && id == MarketPlace.NA);
}.onChange("platform", "id")
}.onChange("platform", "id"),

isOwnedBySpreadshirt: function() {
var platform = this.$.platform,
userId = this.get("user.id");

return (platform === "EU" && userId == 40000) || (platform === "NA" && userId == 1000);
}.onChange("platform", "user.id")

}, {

Expand Down

0 comments on commit c73177b

Please sign in to comment.