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

Commit b9157b9

Browse files
committed
Merge pull request #1553 from OpenBazaar/transactionNotifications
Transaction notifications
2 parents 19c9461 + 6500397 commit b9157b9

File tree

14 files changed

+172
-74
lines changed

14 files changed

+172
-74
lines changed

css/obBase.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3442,7 +3442,7 @@ input[type="checkbox"].fieldItem:checked + label .togLabelOff {
34423442
opacity: 1;
34433443
}
34443444

3445-
.notificationUnreadIndicator {
3445+
.highlightRow {
34463446
position: absolute;
34473447
left: 0;
34483448
top: 0;
@@ -4478,6 +4478,18 @@ input[type="checkbox"].fieldItem:checked + label .togLabelOff {
44784478
background: red;
44794479
}
44804480

4481+
.pill.tabPill {
4482+
position: relative;
4483+
display: inline-block;
4484+
min-width: 0;
4485+
line-height: normal;
4486+
}
4487+
4488+
.pill.tabPill .badge:after {
4489+
right: -12px;
4490+
top: -8px;
4491+
}
4492+
44814493
.selectPill {
44824494
opacity: .75;
44834495
transition: opacity .2s cubic-bezier(0, 0, 0.2, 1);

js/languages/en-US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"GoToOneName": "Go to Onename.com",
3636
"GoToOneNameTooltip": "Create an ID at Onename.com, and under App Accounts enter openbazaar as the app name and your guid as the account identifier (your guid is on your page, in the About tab). Verification can take up to several days.",
3737
"ChangeCurrency": "Change currency",
38+
"ChangeCurrencyHelp": "Clicking this will take you to the settings view and will lose any changes you have made.",
3839
"SKU": "SKU",
3940
"Refurbished": "Refurbished",
4041
"Physical": "Physical",
@@ -240,6 +241,7 @@
240241
"NotificationRefund": "%{name} has refunded your order.",
241242
"NoticationOrderStatus": "Order status updated, buyer notified.",
242243
"NotificationNewOrder": "%{name} has made a purchase.",
244+
"NotificationNewTransactionMessage": "%{name} has sent you a new message about a transaction.",
243245
"NotificationTitle": "Title: %{title}",
244246
"NotificationFrom": "From: %{name}",
245247
"NotificationType": "Type: %{type}",

js/models/orderMd.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ module.exports = window.Backbone.Model.extend({
104104
response.dispute_resolution.resolution.vendor_payout = response.dispute_resolution.resolution.vendor_payout || 0;
105105
}
106106

107-
response.serverUrl = this.serverUrl;
108-
response.bitcoinValidationRegex = config.bitcoinValidationRegex;
109-
response.transactionType = this.transactionType;
110-
response.userGuid = this.userGuid;
107+
//response.serverUrl = this.serverUrl;
108+
//response.bitcoinValidationRegex = config.bitcoinValidationRegex;
109+
//response.transactionType = this.transactionType;
110+
//response.userGuid = this.userGuid;
111111

112112
response.vendorAvatarURL = localStorage.getItem('userAvatar-'+response.vendor_offer.listing.id.guid);
113113
response.buyerAvatarURL = localStorage.getItem('userAvatar-'+response.buyer_order.order.id.guid);
@@ -203,12 +203,12 @@ module.exports = window.Backbone.Model.extend({
203203
initialize: function(options){
204204
this.userCurrencyCode = options.cCode;
205205
this.userBTCAve = options.btAve;
206-
this.serverUrl = options.serverUrl;
207-
this.transactionType = options.transactionType;
206+
//this.serverUrl = options.serverUrl;
207+
//this.transactionType = options.transactionType;
208208
//this.countries = new countriesMd();
209209
//this.countryArray = this.countries.get('countries');
210-
this.avatarURL = options.avatarURL;
211-
this.userGuid = options.userGuid;
210+
//this.avatarURL = options.avatarURL;
211+
//this.userGuid = options.userGuid;
212212
}
213213

214214
});

js/models/orderShortMd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module.exports = window.Backbone.Model.extend({
2727
currency: response.cCode
2828
}).format(response.btc_total*response.btAve);
2929
}
30+
31+
response.unread = response.unread || 0;
3032
return response;
3133
}
3234
});

js/router.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = Backbone.Router.extend({
2929
[/^@([^\/]+)(.*)$/, "userPageViaHandle"],
3030
["userPageViaHandle", "userPageViaHandle"],
3131
["transactions", "transactions"],
32-
["transactions/:state(/:orderID)", "transactions"],
32+
["transactions/:state(/:orderID)(/:tabState)", "transactions"],
3333
["settings", "settings"],
3434
["settings/:state", "settings"]
3535
];
@@ -317,14 +317,15 @@ module.exports = Backbone.Router.extend({
317317
});
318318
},
319319

320-
transactions: function(state, orderID){
320+
transactions: function(state, orderID, tabState){
321321
"use strict";
322322
this.newView(new transactionsView({
323323
userModel: this.userModel,
324324
userProfile: this.userProfile,
325325
socketView: this.socketView,
326326
state: state,
327-
orderID: orderID
327+
orderID: orderID,
328+
tabState: tabState //opens a tab in the order modal
328329
}),"userPage");
329330
app.appBar.setTitle(polyglot.t('Transactions'));
330331
},

js/templates/itemEdit.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ <h5><%= polyglot.t('Listing') %></h5>
9595
<%= polyglot.t('Price') %> (<%= ob.userCurrencyCode %>)
9696
</label>
9797
<div class="underline note rowTop5">
98-
<a href="#settings"><%= polyglot.t('ChangeCurrency') %></a>
98+
<a href="#settings" class="tooltip tooltip-box" data-tooltip="<%= polyglot.t('ChangeCurrencyHelp') %>"><%= polyglot.t('ChangeCurrency') %></a>
9999
</div>
100100
</div>
101101
</div>

js/templates/notification.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="rowItem js-notification padding10 clickable positionRelative">
22
<% if (!ob.read) { %>
3-
<div class="notificationUnreadIndicator"></div>
3+
<div class="highlightRow"></div>
44
<% } %>
55
<div class="table">
66
<div>
@@ -35,6 +35,17 @@
3535
<% } %>
3636
</div>
3737
<div class="textSize11px floatLeft txt-fade"><%= ob.moment(new Date(ob.timestamp*1000)).format('MMM D, h:mm A') %></div>
38+
<% } else if(ob.type == "ORDER") { %>
39+
<div class="textSize12px row5">
40+
<% if(ob.handle) { %>
41+
<%= polyglot.t('NotificationNewTransactionMessage',{name:ob.handle}) %>
42+
<% }else{ %>
43+
<span class="inlineBlock top3">
44+
<%= polyglot.t('NotificationNewTransactionMessage',{name:ob.guid}) %>
45+
</span>
46+
<% } %>
47+
</div>
48+
<div class="textSize11px floatLeft txt-fade"><%= ob.moment(new Date(ob.timestamp*1000)).format('MMM D, h:mm A') %></div>
3849
<% } else if(ob.type == "payment received") { %>
3950
<div class="textSize12px row5">
4051
<% if(ob.handle) { %>

js/templates/orderShort.html

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<div class="width100 cursorDefault">
1+
<div class="width100 cursorDefault positionWrapper">
2+
<% if (ob.unread) { %>
3+
<div class="highlightRow"></div>
4+
<% } %>
25
<div class="rowItem padding20">
36
<div class="flexRow">
47
<div class="width100">
@@ -56,26 +59,32 @@
5659
</tr>
5760
</table>
5861
<div class="floatRight width200">
59-
<div class="btn btn-txt height36 custCol-secondary js-orderShort marginBottom5 width100">
60-
<%= polyglot.t('transactions.OrderDetails') %>
62+
<% if(ob.transactionType == "purchases" && ob.status == 0){ %>
63+
<div class="btn btn-txt height36 custCol-secondary marginBottom5 width100 js-orderShort">
64+
<%= polyglot.t('transactions.PayPurchase') %>
6165
</div>
62-
<% if(ob.transactionType == "purchase" && ob.status == 0){ %>
63-
<div class="btn btn-txt height36 custCol-secondary marginBottom5 width100 js-orderShort">
64-
<%= polyglot.t('transactions.PayPurchase') %>
65-
</div>
66-
<% } else if(ob.transactionType == "sale" && ob.status == 1){ %>
67-
<div class="btn btn-txt height36 custCol-secondary js-orderShortConfirm marginBottom5 width100">
66+
<% } else if(ob.transactionType == "sales" && ob.status == 1){ %>
67+
<div class="btn btn-txt height36 custCol-secondary js-orderShortConfirm marginBottom5 width100">
6868
<% if (ob.contract_type == "digital good" || ob.contract_type == "service") { %>
69-
<%= polyglot.t('transactions.ConfirmOrder') %>
69+
<%= polyglot.t('transactions.ConfirmOrder') %>
7070
<% } else { %>
71-
<%= polyglot.t('transactions.MarkAsShipped') %>
72-
<% } %>
73-
</div>
74-
<% } else if(ob.transactionType == "purchase" && ob.status == 2){ %>
75-
<div class="btn btn-txt height36 custCol-secondary js-orderShortComplete marginBottom5 width100">
76-
<%= polyglot.t('transactions.CompleteOrder') %>
71+
<%= polyglot.t('transactions.MarkAsShipped') %>
72+
<% } %>
73+
</div>
74+
<% } else if(ob.transactionType == "purchases" && ob.status == 2){ %>
75+
<div class="btn btn-txt height36 custCol-secondary js-orderShortComplete marginBottom5 width100">
76+
<%= polyglot.t('transactions.CompleteOrder') %>
77+
</div>
78+
<% } else { %>
79+
<div class="btn btn-txt height36 custCol-secondary js-orderShort marginBottom5 width100">
80+
<%= polyglot.t('transactions.OrderDetails') %>
7781
</div>
7882
<% } %>
83+
<div class="btn btn-txt height36 custCol-secondary marginBottom5 width100 positionWrapper js-orderShortDiscusson <% if(!ob.unread){ %> hide <% } %>"
84+
data-order="<%= ob.order_id %>">
85+
<i class="ion-chatbubbles"></i> <%= polyglot.t('Discussion') %>
86+
<div class="badge js-unreadBadge" data-count="<%= ob.unread || 0 %>"></div>
87+
</div>
7988
</div>
8089
</div>
8190
</div>

js/templates/transactionModal.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ <h3 class="txt-bright"><%= polyglot.t('CheckExchanges') %> </h3>
5353
<input type="checkbox" class="textSize11px fieldItem thin" id="BuyWizardQRDetailsInput">
5454
<label for="BuyWizardQRDetailsInput" class="textSize11px"> <%= polyglot.t('AdditionalPaymentDataInfo') %></label>
5555
</div>
56-
<a class="btn btn-txt btn-wide row10 js-transactionPayCopy"><i class="ion-clipboard"></i> <%= polyglot.t('buyFlow.CopyAddress') %></a>
56+
<a class="btn btn-txt btn-wide row10 js-transactionPayCopy" data-url="<%= ob.buyer_order.order.payment.address %>">
57+
<i class="ion-clipboard"></i> <%= polyglot.t('buyFlow.CopyAddress') %>
58+
</a>
5759
<a class="btn btn-txt btn-wide row10 js-externalLink"
5860
href="bitcoin:<%= ob.buyer_order.order.payment.address %>?amount=<%= ob.buyer_order.order.payment.amount %>&message=<%= ob.vendor_offer.listing.item.title %>">
5961
<i class="ion-link"></i> <%= polyglot.t('buyFlow.OpenAddress') %>
@@ -569,10 +571,13 @@ <h3 class="txt-bright"><%= polyglot.t('CheckExchanges') %> </h3>
569571
<span class="ion-social-bitcoin fontSize12 marginRight2 textOpacity1"></span>
570572
<%= polyglot.t('Funds') %>
571573
</a>
572-
<a class="btn btn-bar btn-tab custCol-secondary fontSize13 js-tab js-discussionTab paddingRight18" data-tab="discussion">
574+
<a class="btn btn-bar btn-tab custCol-secondary fontSize13 js-tab js-discussionTab paddingRight18 positionWrapper" data-tab="discussion">
573575
<span class="ion-chatbubbles fontSize11 marginRight2 textOpacity1"></span>
574576
<%= polyglot.t('Discussion') %>
575-
<span class="pill fontSize12 textOpacity75 marginLeft2 js-discussionCount">0</span>
577+
<div class="pill fontSize12 textOpacity75 marginLeft2 tabPill">
578+
<div class="badge js-unreadBadge <% if(!ob.unread){%>hide<%}%>" data-count="<%= ob.unread || 0 %>"></div>
579+
<span class="js-discussionCount">0</span>
580+
</div>
576581
</a>
577582
</div>
578583

js/views/notificationVw.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ module.exports = baseVw.extend({
4545
case "rating received":
4646
Backbone.history.navigate('#transactions/sales/' + this.model.get('order_id'), {trigger: true});
4747
break;
48+
case "ORDER":
49+
Backbone.history.navigate('#transactions/sales/' + this.model.get('subject') +'/discussion', {trigger: true});
50+
break;
4851
}
4952

5053
this.trigger('notification-click', { view: this });

0 commit comments

Comments
 (0)