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

Commit 90f62be

Browse files
committed
Get display values from database
1 parent 4c9027f commit 90f62be

File tree

4 files changed

+57
-25
lines changed

4 files changed

+57
-25
lines changed

js/about/autofill.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ class CreditCardItem extends ImmutableComponent {
7979
</span>
8080
</td>
8181
<td className='creditCardName'>{creditCard.get('name')}</td>
82-
<td className='creditCardNumber'>{creditCard.get('card')}</td>
82+
<td className='creditCardNumber'>{
83+
creditCard.get('card') !== undefined ? '***' + creditCard.get('card').slice(-4) : null
84+
}</td>
8385
<td className='creditCardPExpirationDate'>
8486
{creditCard.get('month') + '/' + creditCard.get('year')}
8587
</td>

js/components/autofillCreditCardPanel.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,8 @@ class AutofillCreditCardPanel extends ImmutableComponent {
5858
onClick (e) {
5959
e.stopPropagation()
6060
}
61-
get displayNameOnCard () {
62-
return this.props.currentDetail.get('name')
63-
}
64-
get displayCreditCardNumber () {
65-
return this.props.currentDetail.get('card')
61+
get displayMonth () {
62+
return this.props.currentDetail.get('month').replace('0', '')
6663
}
6764
render () {
6865
var ExpMonth = []
@@ -87,11 +84,12 @@ class AutofillCreditCardPanel extends ImmutableComponent {
8784
</div>
8885
<div id='creditCardNumber' className='formRow'>
8986
<label data-l10n-id='creditCardNumber' htmlFor='creditCardNumber' />
90-
<input spellCheck='false' onKeyDown={this.onKeyDown} onChange={this.onCardChange} value={this.displayCreditCardNumber} />
87+
<input spellCheck='false' onKeyDown={this.onKeyDown} onChange={this.onCardChange}
88+
value={this.props.currentDetail.get('card')} />
9189
</div>
9290
<div id='expirationDate' className='formRow'>
9391
<label data-l10n-id='expirationDate' htmlFor='expirationDate' />
94-
<select value={this.props.currentDetail.get('month')}
92+
<select value={this.displayMonth}
9593
onChange={this.onExpMonthChange} className='formSelect' >
9694
{ExpMonth}
9795
</select>

js/components/frame.js

+39-3
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,44 @@ class Frame extends ImmutableComponent {
106106
} else if (location === 'about:flash') {
107107
this.webview.send(messages.BRAVERY_DEFAULTS_UPDATED, this.braveryDefaults)
108108
} else if (location === 'about:autofill') {
109-
this.webview.send(messages.AUTOFILL_ADDRESSES_UPDATED, this.props.autofillAddresses.toJS())
110-
this.webview.send(messages.AUTOFILL_CREDIT_CARDS_UPDATED, this.props.autofillCreditCards.toJS())
109+
const partition = FrameStateUtil.getPartition(this.frame)
110+
if (this.props.autofillAddresses) {
111+
const addresses = this.props.autofillAddresses.toJS()
112+
let list = []
113+
for (let index in addresses) {
114+
const address = currentWindow.webContents.session.autofill.getProfile(addresses[index][partition])
115+
let addressDetail = {
116+
name: address.full_name,
117+
organization: address.company_name,
118+
streetAddress: address.street_address,
119+
city: address.city,
120+
state: address.state,
121+
postalCode: address.postal_code,
122+
country: address.country_code,
123+
phone: address.phone,
124+
email: address.email,
125+
guid: addresses[index]
126+
}
127+
list.push(addressDetail)
128+
}
129+
this.webview.send(messages.AUTOFILL_ADDRESSES_UPDATED, list)
130+
}
131+
if (this.props.autofillCreditCards) {
132+
const creditCards = this.props.autofillCreditCards.toJS()
133+
let list = []
134+
for (let index in creditCards) {
135+
const creditCard = currentWindow.webContents.session.autofill.getCreditCard(creditCards[index][partition])
136+
let creditCardDetail = {
137+
name: creditCard.name,
138+
card: creditCard.card_number,
139+
month: creditCard.expiration_month,
140+
year: creditCard.expiration_year,
141+
guid: creditCards[index]
142+
}
143+
list.push(creditCardDetail)
144+
}
145+
this.webview.send(messages.AUTOFILL_CREDIT_CARDS_UPDATED, list)
146+
}
111147
}
112148

113149
// send state to about pages
@@ -671,7 +707,7 @@ class Frame extends ImmutableComponent {
671707
windowActions.setAutofillAddressDetail(e.args[0], e.args[0])
672708
break
673709
case messages.ADD_AUTOFILL_CREDIT_CARD:
674-
windowActions.setAutofillCreditCardDetail({month: '1', year: new Date().getFullYear()}, {})
710+
windowActions.setAutofillCreditCardDetail({month: '1', year: new Date().getFullYear().toString()}, {})
675711
break
676712
case messages.EDIT_AUTOFILL_CREDIT_CARD:
677713
windowActions.setAutofillCreditCardDetail(e.args[0], e.args[0])

js/stores/appStore.js

+10-14
Original file line numberDiff line numberDiff line change
@@ -548,25 +548,23 @@ const handleAppAction = (action) => {
548548
}
549549
appState = appState.setIn(['autofill', 'addresses'],
550550
appState.getIn(['autofill', 'addresses']).filterNot((address) => {
551-
return Immutable.is(address, action.originalDetail)
551+
return Immutable.is(address, action.originalDetail.get('guid'))
552552
}))
553-
if (action.originalDetail.toJS().guid !== undefined) {
554-
Filtering.removeAutofillAddress(action.originalDetail.toJS().guid)
553+
if (action.originalDetail.get('guid') !== undefined) {
554+
Filtering.removeAutofillAddress(action.originalDetail.get('guid'))
555555
}
556556

557557
let addresses = appState.getIn(['autofill', 'addresses'])
558558
const guid = Filtering.addAutofillAddress(action.detail.toJS())
559-
let detail = action.detail
560-
detail = detail.set('guid', Immutable.fromJS(guid))
561-
appState = appState.setIn(['autofill', 'addresses'], addresses.push(Immutable.fromJS(detail)))
559+
appState = appState.setIn(['autofill', 'addresses'], addresses.push(Immutable.fromJS(guid)))
562560
break
563561
}
564562
case AppConstants.APP_REMOVE_AUTOFILL_ADDRESS:
565563
{
566564
const Filtering = require('../../app/filtering')
567565
appState = appState.setIn(['autofill', 'addresses'],
568566
appState.getIn(['autofill', 'addresses']).filterNot((address) => {
569-
return Immutable.is(address, Immutable.fromJS(action.detail))
567+
return Immutable.is(address, Immutable.fromJS(action.detail.guid))
570568
}))
571569
Filtering.removeAutofillAddress(action.detail.guid)
572570
break
@@ -579,25 +577,23 @@ const handleAppAction = (action) => {
579577
}
580578
appState = appState.setIn(['autofill', 'creditCards'],
581579
appState.getIn(['autofill', 'creditCards']).filterNot((card) => {
582-
return Immutable.is(card, action.originalDetail)
580+
return Immutable.is(card, action.originalDetail.get('guid'))
583581
}))
584-
if (action.originalDetail.toJS().guid !== undefined) {
585-
Filtering.removeAutofillCreditCard(action.originalDetail.toJS().guid)
582+
if (action.originalDetail.get('guid') !== undefined) {
583+
Filtering.removeAutofillCreditCard(action.originalDetail.get('guid'))
586584
}
587585

588586
let creditCards = appState.getIn(['autofill', 'creditCards'])
589587
const guid = Filtering.addAutofillCreditCard(action.detail.toJS())
590-
let detail = action.detail
591-
detail = detail.set('guid', Immutable.fromJS(guid))
592-
appState = appState.setIn(['autofill', 'creditCards'], creditCards.push(Immutable.fromJS(detail)))
588+
appState = appState.setIn(['autofill', 'creditCards'], creditCards.push(Immutable.fromJS(guid)))
593589
break
594590
}
595591
case AppConstants.APP_REMOVE_AUTOFILL_CREDIT_CARD:
596592
{
597593
const Filtering = require('../../app/filtering')
598594
appState = appState.setIn(['autofill', 'creditCards'],
599595
appState.getIn(['autofill', 'creditCards']).filterNot((card) => {
600-
return Immutable.is(card, Immutable.fromJS(action.detail))
596+
return Immutable.is(card, Immutable.fromJS(action.detail.guid))
601597
}))
602598
Filtering.removeAutofillCreditCard(action.detail.guid)
603599
break

0 commit comments

Comments
 (0)