Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 79760fc

Browse files
authored
Merge pull request #1780 from OpenBazaar/flexibleAddresses
Flexible addresses
2 parents 7edca3a + d71b7f8 commit 79760fc

File tree

14 files changed

+187
-56
lines changed

14 files changed

+187
-56
lines changed

css/obBase.css

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,10 @@ label.fieldItem {
11891189
margin-bottom: 30px;
11901190
}
11911191

1192+
.row40 {
1193+
margin-bottom: 40px;
1194+
}
1195+
11921196
.row60 {
11931197
margin-bottom: 60px;
11941198
}
@@ -4806,6 +4810,24 @@ input[type="checkbox"].fieldItem:checked + label .togLabelOff {
48064810
right: 303px;
48074811
}
48084812

4813+
.addressBox {
4814+
padding: 10px;
4815+
font-size: 15px;
4816+
border-radius: 3px;
4817+
min-height: 120px;
4818+
position: relative;
4819+
}
4820+
4821+
.buyAddressWrapper {
4822+
padding: 15px;
4823+
overflow: hidden;
4824+
}
4825+
4826+
.buyAddressWrapper > div {
4827+
overflow: hidden;
4828+
text-overflow: ellipsis;
4829+
}
4830+
48094831
/*========== utility classes ==========*/
48104832

48114833
/* the #ov1 id is on the HTML tag. It is used to force specificity
@@ -4888,7 +4910,6 @@ input[type="checkbox"].fieldItem:checked + label .togLabelOff {
48884910
#ov1 .positionBottom {
48894911
position: absolute;
48904912
bottom: 0;
4891-
right: 0;
48924913
}
48934914

48944915
#ov1 .positionTop {

js/languages/en-US.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"CountryOfOrigin": "Country of Origin:",
123123
"CanBeShippedTo": "Can Ship to You In:",
124124
"NoShippableAddress": "None of your saved addresses are in a country this listing can be shipped to.",
125+
"NoSavedAddresses": "You don't have any saved addresses yet.",
125126
"Addresses": "Addresses",
126127
"Files": "Files",
127128
"NewAddress": "New Address",
@@ -161,7 +162,11 @@
161162
"ShipToCity": "City",
162163
"ShipToState": "State/Province/Region",
163164
"ShipToPostalCode": "Postal code",
165+
"ShipToOther": "Contact Information",
166+
"ShipToOtherPlaceholder": "Alternate method(s) the seller can use to contact you, like email",
167+
"ShipToOtherPlaceholderShort": "Alternate contact method",
164168
"ShipToCountry": "Country",
169+
"Required": "Required",
165170
"EnableNotifications": "Enable Notifications",
166171
"SSLOn": "SSL on",
167172
"SSLOff": "SSL off",
@@ -505,6 +510,7 @@
505510
"saveError": "Data could not be saved.",
506511
"getError": "Data could not be retrieved.",
507512
"missingError": "Some fields are missing or incorrect.",
513+
"missingErrorList": "Some fields are missing or incorrect. \n\n%{errorList}",
508514
"serverError": "An incorrect reply was received from the server.",
509515
"userError": "Information for this ID could not be found",
510516
"userNotFoundError": "This person's information is not available. They may have gone offline.",

js/models/itemMd.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ module.exports = window.Backbone.Model.extend({
183183
//listen for fetched. This is set by the view after fetch is successful, to prevent multiple fires of changed.
184184
this.on('change:fetched', this.updateAttributes, this);
185185
this.countries = new countriesMd();
186-
this.countryArray = this.countries.get('countries');
187186
},
188187

189188
updateAttributes: function(callback){
@@ -256,4 +255,4 @@ module.exports = window.Backbone.Model.extend({
256255
this.set({displayPrice: "Price Unavailable"});
257256
}
258257
}
259-
});
258+
});

js/models/userMd.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ module.exports = Backbone.Model.extend({
99

1010
initialize: function(){
1111
this.countries = new countriesMd();
12-
this.countryArray = this.countries.get('countries');
1312
},
1413

1514
defaults: {
@@ -59,7 +58,7 @@ module.exports = Backbone.Model.extend({
5958
__.each(response.shipping_addresses, function (address) {
6059
if (address){
6160
address = JSON.parse(address);
62-
if (address.name && address.street && address.city && address.state && address.postal_code && address.country && address.displayCountry){
61+
if (address.name && address.displayCountry){
6362
tempAddresses.push(address);
6463
}
6564
}
@@ -82,8 +81,7 @@ module.exports = Backbone.Model.extend({
8281
response.moderators = response.moderators || [];
8382

8483
response.moderator_guids = response.moderators.map(function(moderatorObject){
85-
var modGuid = moderatorObject.guid;
86-
return modGuid;
84+
return moderatorObject.guid;
8785
});
8886

8987
response.blocked_guids = response.blocked_guids || [];

js/templates/buyAddresses.html

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</div>
77
<% } %>
88
<% _.each(ob.user.shipping_addresses, function(address, i){ %>
9-
<% if(address.city && address.country && address.displayCountry && address.name && address.postal_code && address.state && address.street) { %>
9+
<% if(address.country && address.displayCountry && address.name) { %>
1010
<% if(ob.worldwide || ob.vendor_offer.listing.shipping.shipping_regions.indexOf(address.country) > -1){ %>
1111
<div class="flexRow custCol-primary custCol-border js-buyWizardAddress pad10">
1212
<input type="radio"
@@ -15,9 +15,21 @@
1515
value="<%= i %>" <% if(ob.selected == i){ %>checked<% } %> />
1616
<label for="buyWizardAddress<%= i %>" class="width100 textOpacity1 textSize13px paddingRight5">
1717
<div class="flexRow">
18-
<div class="flexCol-8 padding15">
19-
<div class="row10 txt-unleaded"><strong><%= address.name %></strong></div>
20-
<div class=""><%= address.street %><br/><%= address.city %>, <%= address.state %> <%= address.postal_code %><br/><%= address.displayCountry %></div>
18+
<div class="flexCol-8 buyAddressWrapper">
19+
<div class="row5 txt-unleaded"><strong><%= address.name %></strong></div>
20+
<div>
21+
<%= address.street %>
22+
</div>
23+
<div>
24+
<%= address.city %><% if(address.city && address.state || address.city && address.postal_code) print(",") %>
25+
<%= address.state %> <%= address.postal_code %>
26+
</div>
27+
<div>
28+
<%= address.other %>
29+
</div>
30+
<div>
31+
<%= address.displayCountry %>
32+
</div>
2133
</div>
2234
<div class="flexCol-4">
2335
<div class="fontWeight500 textOpacity1 textSize14px marginTop25 minWidth120 js-buyWizardAddressSelected ">
@@ -50,15 +62,27 @@
5062
<% });%>
5163

5264
<% _.each(ob.user.shipping_addresses, function(address, i){ %>
53-
<% if(address.city && address.country && address.displayCountry && address.name && address.postal_code && address.state && address.street) { %>
65+
<% if(address.country && address.displayCountry && address.name) { %>
5466
<% if(!ob.worldwide && ob.vendor_offer.listing.shipping.shipping_regions.indexOf(address.country) < 0){ %>
5567
<div class="flexRow custCol-primary custCol-border js-buyWizardAddress disabled2 pad10">
5668
<input type="radio" class="fieldItem" name="address" id="buyWizardAddressDisabled<%= i %>" value="<%= i %>" disabled/>
5769
<label for="buyWizardAddress<%= i %>" class="width100 textOpacity1 textSize13px paddingRight5">
5870
<div class="flexRow">
59-
<div class="flexCol-8 padding15">
60-
<div class="row10 txt-unleaded"><strong><%= address.name %></strong></div>
61-
<div class="txt-unleaded"><%= address.street %><br/><%= address.city %>, <%= address.state %> <%= address.postal_code %><br/><%= address.displayCountry %></div>
71+
<div class="flexCol-8 buyAddressWrapper">
72+
<div class="row5 txt-unleaded"><strong><%= address.name %></strong></div>
73+
<div>
74+
<%= address.street %>
75+
</div>
76+
<div>
77+
<%= address.city %><% if(address.city && address.state || address.city && address.postal_code) print(",") %>
78+
<%= address.state %> <%= address.postal_code %>
79+
</div>
80+
<div>
81+
<%= address.other %>
82+
</div>
83+
<div>
84+
<%= address.displayCountry %>
85+
</div>
6286
</div>
6387
<div class="flexCol-4">
6488
<div class="fontWeight500 textOpacity1 textSize14px marginTop25 minWidth120">

js/templates/buyDetails.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<div class="marginBottom2"><%= ob.selectedAddress.name %></div>
6969
<div class="marginBottom2"><%= ob.selectedAddress.street %></div>
7070
<div class="marginBottom2"><%= ob.selectedAddress.city %>, <%= ob.selectedAddress.state %> <%= ob.selectedAddress.postal_code %></div>
71+
<div class="marginBottom2"><%= ob.selectedAddress.other %></div>
7172
<div><%= ob.selectedAddress.displayCountry %></div>
7273
<% } %>
7374
</div>

js/templates/buyWizard.html

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h3 class="custCol-text padding30"><%= polyglot.t('CheckExchanges') %> </h3>
3434
<%= polyglot.t('buyFlow.paymentNote') %>
3535
</div>
3636
</div>
37-
<div class="positionBottom width100 padding20 custCol-background borderTop custCol-border txt-center js-partialPaymentMsg opacity0">
37+
<div class="positionBottomRight width100 padding20 custCol-background borderTop custCol-border txt-center js-partialPaymentMsg opacity0">
3838
<div class="h4 width100">
3939
<i class="ion-alert-circled"></i>
4040
<span class="js-partialPaymentTxt"></span>
@@ -414,11 +414,15 @@ <h2 class="margin0 marginTop80"><%= polyglot.t('buyFlow.HaveWallet') %></h2>
414414
<div class="flexRow custCol-border borderTop">
415415
<div class="flexCol-5 custCol-border">
416416
<div class="fieldItem">
417-
<label for="buyWizardNameInput"><%= polyglot.t('ShipToName') %></label>
417+
<label for="buyWizardNameInput"><%= polyglot.t('ShipToName') %> *</label>
418418
</div>
419419
</div>
420420
<div class="flexCol-7 custCol-border">
421-
<input type="text" name="new_ship_to_name" class="fieldItem custCol-text" id="buyWizardNameInput" required/>
421+
<input type="text"
422+
name="new_ship_to_name"
423+
class="fieldItem custCol-text"
424+
placeholder="<%= polyglot.t('ShipToName') %>"
425+
id="buyWizardNameInput" required/>
422426
</div>
423427
</div>
424428
<div class="flexRow">
@@ -428,7 +432,11 @@ <h2 class="margin0 marginTop80"><%= polyglot.t('buyFlow.HaveWallet') %></h2>
428432
</div>
429433
</div>
430434
<div class="flexCol-7 custCol-border">
431-
<input type="text" name="new_ship_to_street" class="fieldItem custCol-text" id="buyWizardStreetInput" required/>
435+
<input type="text"
436+
name="new_ship_to_street"
437+
class="fieldItem custCol-text"
438+
placeholder="<%= polyglot.t('ShipToStreet') %>"
439+
id="buyWizardStreetInput"/>
432440
</div>
433441
</div>
434442
<div class="flexRow">
@@ -438,7 +446,11 @@ <h2 class="margin0 marginTop80"><%= polyglot.t('buyFlow.HaveWallet') %></h2>
438446
</div>
439447
</div>
440448
<div class="flexCol-7 custCol-border">
441-
<input type="text" name="new_ship_to_city" class="fieldItem custCol-text" id="buyWizardCityInput" required/>
449+
<input type="text"
450+
name="new_ship_to_city"
451+
class="fieldItem custCol-text"
452+
placeholder="<%= polyglot.t('ShipToCity') %>"
453+
id="buyWizardCityInput"/>
442454
</div>
443455
</div>
444456
<div class="flexRow">
@@ -448,7 +460,11 @@ <h2 class="margin0 marginTop80"><%= polyglot.t('buyFlow.HaveWallet') %></h2>
448460
</div>
449461
</div>
450462
<div class="flexCol-7 custCol-border">
451-
<input type="text" name="new_ship_to_state" class="fieldItem custCol-text js-buyWizardStateInput" id="buyWizardStateInput" required/>
463+
<input type="text"
464+
name="new_ship_to_state"
465+
class="fieldItem custCol-text js-buyWizardStateInput"
466+
placeholder="<%= polyglot.t('ShipToState') %>"
467+
id="buyWizardStateInput"/>
452468
</div>
453469
</div>
454470
<div class="flexRow">
@@ -458,13 +474,31 @@ <h2 class="margin0 marginTop80"><%= polyglot.t('buyFlow.HaveWallet') %></h2>
458474
</div>
459475
</div>
460476
<div class="flexCol-7 custCol-border">
461-
<input type="text" name="new_ship_to_street" class="fieldItem custCol-text js-buyWizardPostalInput" id="buyWizardPostalInput" required/>
477+
<input type="text"
478+
name="new_ship_to_street"
479+
class="fieldItem custCol-text js-buyWizardPostalInput"
480+
placeholder="<%= polyglot.t('ShipToPostalCode') %>"
481+
id="buyWizardPostalInput"/>
462482
</div>
463483
</div>
464484
<div class="flexRow">
465485
<div class="flexCol-5 custCol-border">
466486
<div class="fieldItem">
467-
<label for="buyWizardStreetInput"><%= polyglot.t('ShipToCountry') %></label>
487+
<label for="buyWizardOther"><%= polyglot.t('ShipToOther') %></label>
488+
</div>
489+
</div>
490+
<div class="flexCol-7 custCol-border">
491+
<input type="text"
492+
name="new_ship_to_other"
493+
class="fieldItem custCol-text"
494+
placeholder="<%= polyglot.t('ShipToOtherPlaceholderShort') %>"
495+
id="buyWizardOther"/>
496+
</div>
497+
</div>
498+
<div class="flexRow">
499+
<div class="flexCol-5 custCol-border">
500+
<div class="fieldItem">
501+
<label for="buyWizardStreetInput"><%= polyglot.t('ShipToCountry') %> *</label>
468502
</div>
469503
</div>
470504
<div class="flexCol-7 custCol-border">
@@ -473,6 +507,9 @@ <h2 class="margin0 marginTop80"><%= polyglot.t('buyFlow.HaveWallet') %></h2>
473507
</div>
474508
</div>
475509
</div>
510+
<div class="padding15">
511+
<span class="note">* <%= polyglot.t('Required') %></span>
512+
</div>
476513
</form>
477514
</div>
478515
</div>

js/templates/item.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,20 @@ <h4><%= polyglot.t('CanBeShippedTo') %></h4>
127127
</div>
128128
<div class="marginBottom20 marginLeft7 row10">
129129
<% var matchedItemShippableCountries = _.uniq(_.intersection(_.pluck(ob.userAddresses, 'country'), ob.vendor_offer.listing.shipping.shipping_regions));
130-
if(matchedItemShippableCountries.length > 0){
131-
_.each(matchedItemShippableCountries, function(data){
132-
print("<p>" + polyglot.t(`countries.${data}`) + "</p>");
133-
});
134-
} else if(!ob.worldwide){
135-
print(polyglot.t('NoShippableAddress'));
130+
if(ob.userAddresses.length > 0) {
131+
if(matchedItemShippableCountries.length > 0){
132+
_.each(matchedItemShippableCountries, function(data){
133+
print("<p>" + polyglot.t(`countries.${data}`) + "</p>");
134+
});
135+
} else if(!ob.worldwide){
136+
print(polyglot.t('NoShippableAddress'));
137+
} else {
138+
_.each(_.uniq(_.pluck(ob.userAddresses, 'country')), function(data){
139+
print("<p>" + polyglot.t(`countries.${data}`) + "</p>");
140+
});
141+
}
136142
} else {
137-
_.each(_.uniq(_.pluck(ob.userAddresses, 'country')), function(data){
138-
print("<p>" + polyglot.t(`countries.${data}`) + "</p>");
139-
});
143+
print(polyglot.t('NoSavedAddresses'));
140144
}
141145
%>
142146
</div>

0 commit comments

Comments
 (0)