This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,005 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<!-- This Source Code Form is subject to the terms of the Mozilla Public | ||
- License, v. 2.0. If a copy of the MPL was not distributed with this | ||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="availableLanguages" content=""> | ||
<meta name="defaultLanguage" content="en-US"> | ||
<meta name='theme-color' content='#ff5000'> | ||
<title data-l10n-id="autofillTitle"></title> | ||
<script src='js/about.js'></script> | ||
<script src="ext/l20n.min.js" async></script> | ||
<link rel="localization" href="locales/{locale}/autofill.properties"> | ||
</head> | ||
<body> | ||
<div id="appContainer"/> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
autofillTitle=Autofill Settings | ||
addresses=Addresses | ||
creditCards=Credit Cards | ||
addAddress=Add Address | ||
addCreditCard=Add Credit Card | ||
nameOnCard=Name on card | ||
creditCardNumber=Credit card number | ||
expirationDate=Expiration date | ||
noCreditCardsSaved=No saved credit cards | ||
nameOnAddress=Name | ||
organization=Organization | ||
streetAddress=Street Address | ||
city=City | ||
state=State | ||
postalCode=Postal Code | ||
country=Country | ||
phone=Phone | ||
email=Email | ||
noAddressesSaved=No saved addresses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const React = require('react') | ||
const messages = require('../constants/messages') | ||
const Immutable = require('immutable') | ||
const ImmutableComponent = require('../components/immutableComponent') | ||
const aboutActions = require('./aboutActions') | ||
const Button = require('../components/button') | ||
|
||
const ipc = window.chrome.ipc | ||
|
||
require('../../less/about/autofill.less') | ||
require('../../node_modules/font-awesome/css/font-awesome.css') | ||
|
||
class AddressItem extends ImmutableComponent { | ||
constructor () { | ||
super() | ||
this.onDelete = this.onDelete.bind(this) | ||
this.onEdit = this.onEdit.bind(this) | ||
} | ||
|
||
onDelete () { | ||
aboutActions.removeAutofillAddress(this.props.address.toJS()) | ||
} | ||
|
||
onEdit () { | ||
aboutActions.editAutofillAddress(this.props.address.toJS()) | ||
} | ||
|
||
render () { | ||
const address = this.props.address | ||
return <tr className='autofillItem'> | ||
<td className='autofillActions'> | ||
<span className='autofillAction fa fa-times' title='Delete address' | ||
onClick={this.onDelete}> | ||
</span> | ||
</td> | ||
<td className='addressName'>{address.get('name')}</td> | ||
<td className='organization'>{address.get('organization')}</td> | ||
<td className='streetAddress'>{address.get('streetAddress')}</td> | ||
<td className='city'>{address.get('city')}</td> | ||
<td className='state'>{address.get('state')}</td> | ||
<td className='postalCode'>{address.get('postalCode')}</td> | ||
<td className='country'>{address.get('country')}</td> | ||
<td className='phone'>{address.get('phone')}</td> | ||
<td className='email'>{address.get('email')}</td> | ||
<td className='autofillActions'> | ||
<span className='autofillAction fa fa-pencil-square-o' title='Edit address' | ||
onClick={this.onEdit}> | ||
</span> | ||
</td> | ||
</tr> | ||
} | ||
} | ||
|
||
class CreditCardItem extends ImmutableComponent { | ||
constructor () { | ||
super() | ||
this.onDelete = this.onDelete.bind(this) | ||
this.onEdit = this.onEdit.bind(this) | ||
} | ||
|
||
onDelete () { | ||
aboutActions.removeAutofillCreditCard(this.props.creditCard.toJS()) | ||
} | ||
|
||
onEdit () { | ||
aboutActions.editAutofillCreditCard(this.props.creditCard.toJS()) | ||
} | ||
|
||
render () { | ||
const creditCard = this.props.creditCard | ||
return <tr className='autofillItem'> | ||
<td className='autofillActions'> | ||
<span className='autofillAction fa fa-times' title='Delete creditCard' | ||
onClick={this.onDelete}> | ||
</span> | ||
</td> | ||
<td className='creditCardName'>{creditCard.get('name')}</td> | ||
<td className='creditCardNumber'>{creditCard.get('card')}</td> | ||
<td className='creditCardPExpirationDate'> | ||
{creditCard.get('month') + '/' + creditCard.get('year')} | ||
</td> | ||
<td className='autofillActions'> | ||
<span className='autofillAction fa fa-pencil-square-o' title='Edit creditCard' | ||
onClick={this.onEdit}> | ||
</span> | ||
</td> | ||
</tr> | ||
} | ||
} | ||
|
||
class AboutAutofill extends React.Component { | ||
constructor () { | ||
super() | ||
this.state = { | ||
addressesDetails: new Immutable.List(), | ||
creditCardsDetails: new Immutable.List() | ||
} | ||
ipc.on(messages.AUTOFILL_ADDRESSES_UPDATED, (e, detail) => { | ||
if (detail) { | ||
this.setState({ | ||
addressesDetails: Immutable.fromJS(detail) | ||
}) | ||
} | ||
}) | ||
ipc.on(messages.AUTOFILL_CREDIT_CARDS_UPDATED, (e, detail) => { | ||
if (detail) { | ||
this.setState({ | ||
creditCardsDetails: Immutable.fromJS(detail) | ||
}) | ||
} | ||
}) | ||
this.onAddAddress = this.onAddAddress.bind(this) | ||
this.onAddCreditCard = this.onAddCreditCard.bind(this) | ||
} | ||
|
||
onAddAddress () { | ||
aboutActions.addAutofillAddress() | ||
} | ||
|
||
onAddCreditCard () { | ||
aboutActions.addAutofillCreditCard() | ||
} | ||
|
||
get isAddresssEmpty () { | ||
return !this.state.addressesDetails || !this.state.addressesDetails.size | ||
} | ||
|
||
get isCreditCardsEmpty () { | ||
return !this.state.creditCardsDetails || !this.state.creditCardsDetails.size | ||
} | ||
|
||
render () { | ||
var savedAddresssPage = this.isAddresssEmpty | ||
? <div><span data-l10n-id='noAddressesSaved' /></div> | ||
: <div> | ||
<h2 data-l10n-id='addresses' /> | ||
<div className='autofillPageContent'> | ||
<table className='autofillList'> | ||
<thead> | ||
<tr> | ||
<th></th> | ||
<th data-l10n-id='nameOnAddress'></th> | ||
<th data-l10n-id='organization'></th> | ||
<th data-l10n-id='streetAddress'></th> | ||
<th data-l10n-id='city'></th> | ||
<th data-l10n-id='state'></th> | ||
<th data-l10n-id='postalCode'></th> | ||
<th data-l10n-id='country'></th> | ||
<th data-l10n-id='phone'></th> | ||
<th data-l10n-id='email'></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{ | ||
this.state.addressesDetails.sort((a, b) => { | ||
return a.get('name') > b.get('name') ? 1 : -1 | ||
}).map((item) => | ||
<AddressItem address={item} />) | ||
} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
|
||
var savedCreditCardsPage = this.isCreditCardsEmpty | ||
? <div><span data-l10n-id='noCreditCardsSaved' /></div> | ||
: <div> | ||
<h2 data-l10n-id='creditCards' /> | ||
<div className='autofillPageContent'> | ||
<table className='autofillList'> | ||
<thead> | ||
<tr> | ||
<th></th> | ||
<th data-l10n-id='nameOnCard'></th> | ||
<th data-l10n-id='creditCardNumber'></th> | ||
<th data-l10n-id='expirationDate'></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{ | ||
this.state.creditCardsDetails.sort((a, b) => { | ||
return a.get('name') > b.get('name') ? 1 : -1 | ||
}).map((item) => | ||
<CreditCardItem creditCard={item} />) | ||
} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
return <div className='autofillPage'> | ||
<h1 data-l10n-id='autofillTitle' /> | ||
{savedAddresssPage} | ||
<Button l10nId='addAddress' className='primaryButton' onClick={this.onAddAddress} /> | ||
{savedCreditCardsPage} | ||
<Button l10nId='addCreditCard' className='primaryButton' onClick={this.onAddCreditCard} /> | ||
</div> | ||
} | ||
} | ||
|
||
module.exports = <AboutAutofill /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.