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

Commit a293f44

Browse files
authored
Merge pull request #1785 from OpenBazaar/orderAddressOnDrag
Makes Addresses in Settings Ordered by Dragging
2 parents 719848f + 3b24b0f commit a293f44

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

css/obBase.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4818,6 +4818,24 @@ input[type="checkbox"].fieldItem:checked + label .togLabelOff {
48184818
position: relative;
48194819
}
48204820

4821+
.addressBoxDragging .addressBox{
4822+
border-width: 2px;
4823+
border-style: solid;
4824+
}
4825+
4826+
.addressBoxGhost .addressBox{
4827+
border-width: 2px;
4828+
border-style: dashed;
4829+
}
4830+
4831+
.addressesWrapper .addressBox .defaultLabel {
4832+
display: none;
4833+
}
4834+
4835+
.addressesWrapper:first-child .addressBox .defaultLabel {
4836+
display: block;
4837+
}
4838+
48214839
.buyAddressWrapper {
48224840
padding: 15px;
48234841
word-wrap: break-word;

js/languages/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"Files": "Files",
128128
"NewAddress": "New Address",
129129
"CurrentAddress": "Current Addresses",
130+
"DefaultAddress": "Default Address",
130131
"ReturnsPolicy": "Returns Policy",
131132
"Tags": "Tags",
132133
"Keywords": "Keywords",

js/templates/settings.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,10 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('Content') %></h3>
833833
<div class="flexRow">
834834
<h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('CurrentAddress') %></h3>
835835
</div>
836-
<div class="flexRow pad5 rowTop15">
836+
<div class="flexRow pad5 rowTop15 js-sortableAddresses">
837837
<% _.each(ob.user.shipping_addresses, function(address, i){ %>
838-
<% console.log(address) %>
839-
<div class="flexCol-4 pad10 row15">
840-
<div class="addressBox custCol-secondary js-address">
838+
<div class="flexCol-4 pad10 row15 addressesWrapper">
839+
<div class="addressBox custCol-secondary custCol-border-background js-address">
841840
<div class="textOpacity1 row40">
842841
<div><%= address.name %></div>
843842
<div><%= address.street %></div>
@@ -860,6 +859,9 @@ <h3 class="padding15 margin0 fontWeight500"><%= polyglot.t('CurrentAddress') %><
860859
<span class="fontSize12 clickable togLabelOn js-settingsAddressUnDelete"><%= polyglot.t('DontDelete') %></span>
861860
</label>
862861
</div>
862+
<div class="positionBottomRight defaultLabel padding10 note">
863+
<%= polyglot.t('DefaultAddress') %>
864+
</div>
863865
</div>
864866
</div>
865867
<% }); %>

js/views/settingsVw.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ var __ = require('underscore'),
2020
SMTPConnection = require('smtp-connection'),
2121
MediumEditor = require('medium-editor'),
2222
validateMediumEditor = require('../utils/validateMediumEditor'),
23-
getBTPrice = require('../utils/getBitcoinPrice');
23+
getBTPrice = require('../utils/getBitcoinPrice'),
24+
Sortable = require('sortablejs');
2425

2526
module.exports = pageVw.extend({
2627

@@ -233,6 +234,7 @@ module.exports = pageVw.extend({
233234
placeholder_text_single: window.polyglot.t('chosenJS.placeHolderTextSingle'),
234235
placeholder_text_multiple: window.polyglot.t('chosenJS.placeHolderTextMultiple')
235236
});
237+
236238
$('#settings-image-cropper').cropit({
237239
$preview: self.$('.js-settingsAvatarPreview'),
238240
$fileInput: self.$('#settingsAvatarInput'),
@@ -255,6 +257,7 @@ module.exports = pageVw.extend({
255257
console.log(errorMessage);
256258
}
257259
});
260+
258261
//cache elements used more than once
259262
self.$moderatorFeeInput = self.$('#moderatorFeeInput');
260263
self.$moderatorFeeHolder = self.$('.js-settingsModeratorFee');
@@ -286,6 +289,7 @@ module.exports = pageVw.extend({
286289
console.log(errorMessage);
287290
}
288291
});
292+
289293
if (self.model.get('page').profile.header_hash){
290294
$('#settings-image-cropperBanner').cropit('imageSrc', self.serverUrl +'get_image?hash='+self.model.get('page').profile.header_hash);
291295
self.newBanner = false;
@@ -304,6 +308,12 @@ module.exports = pageVw.extend({
304308
}
305309
});
306310
editor.subscribe('blur', self.validateDescription);
311+
312+
self.sortableAddresses && self.sortableAddresses.destroy();
313+
self.sortableAddresses = Sortable.create(self.$('.js-sortableAddresses')[0], {
314+
chosenClass: "addressBoxDragging",
315+
ghostClass: "addressBoxGhost"
316+
});
307317
});
308318
return this;
309319
},

0 commit comments

Comments
 (0)