Skip to content

Commit

Permalink
- Documentation and minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Royedc4 committed Mar 10, 2017
1 parent 0c5824c commit 002df19
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 32 deletions.
93 changes: 70 additions & 23 deletions stitch-order-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
}
</style>

<stitch-order-request id="request" product-url="[[url]]" product-details="{{details}}"></stitch-order-request>
<stitch-order-form id="form" product-url="{{url}}" product-details="[[details]]"></stitch-order-form>
<stitch-order-request id="request"
product-url="[[productUrl]]"
product-details="{{details}}">
</stitch-order-request>

<stitch-order-form id="form" product-url="{{productUrl}}" product-details="[[details]]"></stitch-order-form>
<!--
Development guidelines:
- Stick to paper elements if possible for UI widgets
Expand All @@ -46,12 +49,69 @@
Polymer({
is: 'stitch-order-element',

properties: {},
properties: {
/**
* The current product URL.
*/
productUrl: {
type: Object,
notify: true
},
/**
* The current product details retrieved from amazon.
*
* Note that this object will not have the shipping information.
*/
productDetails: {
type: Object,
readOnly: true,
computed: '_detailsChanged(details)',
notify: true
},

/**
* The last product submitted (address, product, options are the 3 objects inside this one).
*
* Note that this object will have the data from the last product submitted
* to access the current product data use `productDetails` instead.
*/
lastProduct: {
type: Object,
readOnly: true,
notify: true
},
/**
* The last product submitted URL.
*
* Note that this URL will be the last product submitted URL
* to access the current product URL use `productUrl` instead.
*/
lastUrl: {
type: String,
readOnly: true,
notify: true
}
},

listeners: {
'request.order-details-request': '_loadingProduct',
'request.order-response': '_orderDataRetrieved',
'request.error': '_errorThrown'
'request.error': '_errorThrown',
'order-submit': '_save'
},

/**
* Resets the current form data.
*
* This will wipe `productUrl` and `productDetails`.
* `lastProduct` and `lastUrl` will remain unchanged.
*/
reset: function(){
this.$.form.reset();
},

_detailsChanged: function(details){
return details;
},

_loadingProduct: function(e){
Expand All @@ -70,26 +130,13 @@
_errorThrown: function(e){
this.$.form.error(e.detail.request.response[0].Error[0]);
},
/*
* Resets the form.
*/
reset: function(){
this.$.form.reset();
},
/*
* When the Set Up Order button is clicked.
*/
onSave: function(){

},

/*
* When the Cancel button is clicked.
*/
onCancel: function(){

/**
* Capture the `order-submit` event and set the data into the `lastProduct` Object
*/
_save: function(e){
this._setlastUrl(this.productUrl);
this._setLastProduct(e.detail);
}

});
</script>
</dom-module>
17 changes: 8 additions & 9 deletions stitch-order-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ <h3>Total Cost</h3>
<div id="buttons" class="section">
<paper-button id="submitButton" raised on-tap="_submit">Set up Order</paper-button>
<div spacer></div>
<paper-button id="cancelButton" on-tap="reset">Cancel</paper-button>
<paper-button id="cancelButton" on-tap="_reset">Cancel</paper-button>
</div>
</form>
</template>
Expand Down Expand Up @@ -268,17 +268,12 @@ <h3>Total Cost</h3>
/**
* The product details and options requests from amazon are on the fly.
*/
loading: {
type: Boolean,
value: false
},
loading: Boolean,
/**
* The product details where retrieved from amazon.
*/
loaded: {
type: Boolean,
value: false
},
loaded: Boolean,

/**
* The product could not be retrieved through the amazon API or another error gets captured.
*/
Expand Down Expand Up @@ -333,6 +328,7 @@ <h3>Total Cost</h3>
this.$.form.reset();
this.productUrl = URL || '';
this.address = address || {};
this.loading = this.loaded = false;
this._setFail(false);
this._setFailMessage('');
},
Expand Down Expand Up @@ -373,6 +369,9 @@ <h3>Total Cost</h3>
this.$.form.submit();
}
},
_reset: function(){
this.reset();
},
_validate: function(){
return true;
}
Expand Down

0 comments on commit 002df19

Please sign in to comment.