New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispute portal #1456

Merged
merged 13 commits into from Sep 9, 2014
@@ -1,4 +1,5 @@
Balanced.ModalsContainerController = Ember.Controller.extend({
needs: ['notification_center', 'modal_notification_center'],
registerContainer: function(modalsContainer) {
this.set("modalsContainer", modalsContainer);
},
View
@@ -7,11 +7,18 @@ Balanced.Debit = Balanced.Transaction.extend({
route_name: "debits",
source: Balanced.Model.belongsTo('source', 'Balanced.FundingInstrument'),
hold: Balanced.Model.belongsTo('hold', 'Balanced.Hold'),
hold: Balanced.Model.belongsTo('card_hold', 'Balanced.Hold'),
refunds: Balanced.Model.hasMany('refunds', 'Balanced.Refund'),
dispute: Balanced.Model.belongsTo('dispute', 'Balanced.Dispute'),
order: Balanced.Model.belongsTo('order', 'Balanced.Order'),
getDisputesLoader: function(attributes) {
attributes = _.extend({
path: this.get("dispute_uri")
}, attributes);
return Balanced.DisputesResultsLoader.create(attributes);
},
funding_instrument_description: Ember.computed.alias('source.description'),
last_four: Ember.computed.alias('source.last_four'),
funding_instrument_name: Ember.computed.alias('source.brand'),
View
@@ -2,10 +2,21 @@ Balanced.Dispute = Balanced.Model.extend(Ember.Validations, {
transaction: Balanced.Model.belongsTo('transaction', 'Balanced.Transaction'),
events: Balanced.Model.hasMany('events', 'Balanced.Event'),
documents: Balanced.Model.hasMany('dispute_documents', 'Balanced.DisputeDocument'),
dispute_note: function() {
var note = this.get('note');
return note ? note : 'none';
}.property('note'),
note: null,
tracking_number: null,
validations: {
note: {
presence: true,
}
},
justitia_dispute: function() {
return Balanced.JustitiaDispute.find(this.get('dispute_uri'));
}.property('dispute_uri'),
isEvidenceProvided: function() {
return !!this.get('justitia_dispute.created_at');
}.property('justitia_dispute.created_at'),
type_name: 'Dispute',
route_name: 'dispute',
@@ -52,18 +63,8 @@ Balanced.Dispute = Balanced.Model.extend(Ember.Validations, {
}.property('respond_by'),
canUploadDocuments: function() {
if (this.get('hasExpired') || this.get('status') !== 'pending') {
return false;
}
// no document
if (!this.get('documents.isLoaded') && this.get('documents.isError')) {
return true;
}
return !(this.get('documents.isLoaded') && this.get('documents.length') > 0);
}.property('status', 'documents.isLoaded', 'hasExpired', 'documents.length')
return !this.get('isEvidenceProvided') && !this.get('hasExpired') && (this.get('status') === 'pending');
}.property('isEvidenceProvided', 'hasExpired', 'status')
});
Balanced.TypeMappings.addTypeMapping('dispute', 'Balanced.Dispute');
@@ -19,3 +19,15 @@ Balanced.DisputeDocument.reopenClass({
Balanced.Adapter.registerHostForType(Balanced.DisputeDocument, ENV.BALANCED.JUSTITIA);
Balanced.TypeMappings.addTypeMapping('dispute_documents', 'Balanced.DisputeDocument');
Balanced.JustitiaDispute = Balanced.Model.extend({});
Balanced.JustitiaDispute.reopenClass({
loadFromUri: function(uri) {
return Balanced.ModelArray.newArrayLoadedFromUri(uri, Balanced.JustitiaDispute, "disputes");
}
});
Balanced.Adapter.registerHostForType(Balanced.JustitiaDispute, ENV.BALANCED.JUSTITIA);
View
@@ -1,5 +1,11 @@
Balanced.DebitsRoute = Balanced.ModelRoute.extend({
title: 'Debit',
modelObject: Balanced.Debit,
marketplaceUri: 'debits_uri'
marketplaceUri: 'debits_uri',
setupController: function(controller, model) {
this._super(controller, model);
controller.setProperties({
disputesResultsLoader: model.getDisputesLoader()
});
}
});
View
@@ -14,6 +14,13 @@
{{/view}}
{{#view Balanced.MainPanelView}}
{{#if model.dispute}}
<h3>Associated dispute<i class="icon-disputes"></i></h3>
<div class="results">
{{view Balanced.EmbeddedDisputesResultsView loader=disputesResultsLoader}}
</div>
{{/if}}
<h3>Logs</h3>
<div class="results">
{{view Balanced.ResourceLogsView content=model}}
@@ -13,10 +13,10 @@
<div class="row-fluid notification-center warning">
<div class="notification-center-message">
<span class="message">
Provide documentation by <span class="sl-sb">{{humanReadableDateLong respond_by}}</span> to avoid a loss.
Provide evidence by <span class="sl-sb">{{humanReadableDateLong respond_by}}</span> to avoid a loss.
</span>
<div class="pull-right">
<a class="btn" {{action "openModal" Balanced.EvidencePortalModalView model}}>Attach docs</a>
<a class="btn" {{action "openModal" Balanced.EvidencePortalModalView model}}>Provide evidence</a>
</div>
</div>
</div>
@@ -28,7 +28,7 @@
{{view Balanced.EmbeddedTransactionsResultsView loader=transactionsResultsLoader hasNoFilter=true}}
</div>
<h3>Documents</h3>
<h3>Evidence</h3>
<div class="results documents">
{{view Balanced.ResourceDocumentsView content=model}}
</div>
@@ -0,0 +1,7 @@
<div {{bind-attr class=":file-drop :droppable view.isDragging:dragging"}}>
<i class="icon-upload non-interactive"></i>
<p>{{view.dropMessage}}</p>
<a class="fileinput-button btn secondary">Select files
<input id="fileupload" type="file" name="files[]" multiple {{action 'fileSelectionChanged' on="change" target="view.parentView"}}>
</a>
</div>
@@ -1,6 +1,6 @@
<h3>{{view.sectionTitle}}</h3>
{{#if view.sectionDescription}}
<p class="span6">{{view.sectionDescription}}</p>
<div class="description span5">{{view.sectionDescription}}</div>
{{/if}}
<div class="pull-right">
{{yield}}
@@ -0,0 +1 @@
{{textarea viewName="textAreaElement" name=view.inputName value=view.value class=view.inputClassNames maxlength=view.maxlength}}
@@ -1,81 +1,52 @@
<form {{action "save" on="submit" target="view"}}>
<div class="modal-body modal-with-headers">
{{#if view.model.displayErrorDescription}}
<div class="alert alert-error">
<p>{{view.model.errorDescription}}</p>
</div>
{{/if}}
<div class="modal-content">
<p>{{view.modalMessage}}</p>
<ul>
{{#each requirement in view.documentRequirements}}
<li>{{requirement}}</li>
{{/each}}
</ul>
<hr class="separation-line" />
<div {{bind-attr class=":clearfix :control-group view.model.validationErrors.note:error"}}>
<label class="control-label clearfix">
Documents
<a class="fileinput-button pull-right">Attach docs
<input id="fileupload" type="file" name="files[]" multiple {{action 'fileSelectionChanged' on="change" target="view"}}>
</a>
</label>
<div class="controls results">
<table class="items">
<thead>
<tr>
<th class="span8"><span>File (PDF or JPEG)</span></th>
<th class="span3"><span>Size (Max: 1 MB)</span></th>
<th class="span1"><span>&nbsp;</span></th>
</tr>
</thead>
<tbody>
{{#each doc in view.documentsToUpload}}
<tr {{bind-attr class=":table-row doc.isError:error"}}>
<td class="name">
<span {{bind-attr class="doc.isError:error"}}>
{{doc.file_name}}
</span>
</td>
<td class="size"><span>{{formatFileSize doc.file_size}}</span></td>
<td>
{{#if doc.isUploading}}
<div class="loader-container">
<span class="loader loading"></span>
</div>
{{else}}
<a href="#" {{action "remove" doc target="view"}}>
<i class="icon-x"></i>
</a>
{{/if}}
</td>
</tr>
{{#view Balanced.FormSectionView model=view.model sectionTitle="File upload" sectionDescription=view.fileUploadText}}
<div class="form-group">
{{view Balanced.FileDropFieldView}}
</div>
<div class="clearfix form-group">
<label class="control-label clearfix">Documents</label>
<table class="items">
<thead>
<tr>
<th class="span4"><span>File (PDF or JPEG)</span></th>
<th class="span3"><span>Size (Max: 1 MB)</span></th>
<th class="span1"><span>&nbsp;</span></th>
</tr>
</thead>
<tbody>
{{#each doc in view.parentView.documentsToUpload}}
<tr {{bind-attr class=":table-row doc.isError:error"}}>
<td class="name">
<span {{bind-attr class="doc.isError:error"}}>
{{doc.file_name}}
</span>
</td>
<td class="size"><span>{{formatFileSize doc.file_size}}</span></td>
<td>
{{#if doc.isUploading}}
<div class="loader-container">
<span class="loader loading"></span>
</div>
{{else}}
<tr>
<td colspan="3" class="no-results">None</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
<div {{bind-attr class=":control-group view.model.validationErrors.note:error"}}>
<label class="control-label clearfix">Note</label>
<div class="controls row-fluid">
{{view Ember.TextArea valueBinding="view.model.note" name="note" class="span" placeholder="Describe the documents you've attached."}}
</div>
</div>
<div class="control-group">
<p>You can only submit this information once. You will not be able to add to or modify your files once you click "Submit."</p>
</div>
</div>
<a href="#" {{action "remove" doc target="view.parentView"}}>
<i class="icon-table-x"></i>
</a>
{{/if}}
</td>
</tr>
{{else}}
<tr>
<td colspan="3" class="no-results">None</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
{{/view}}
<div class="modal-footer">
<button class="btn secondary" type="button" name="modal-cancel" data-dismiss="modal" aria-hidden="true" {{bind-attr disabled="view.isSubmitting"}}>Cancel</button>
<button {{bind-attr class=":btn view.isDisabled:disabled"}} type="submit" name="modal-submit" {{bind-attr disabled="view.isDisabled"}}>Submit</button>
</div>
</form>
{{#view Balanced.FormSectionView model=view.model sectionTitle="Tracking information" sectionDescription=view.trackingCodeText}}
{{view Balanced.TextFormFieldView model=view.model inputClassNames="full" inputName="tracking_number" field="tracking_number" labelText="Tracking number" explanationText="FedEx or USPS tracking number only"}}
{{/view}}
{{#view Balanced.FormSectionView model=view.model sectionTitle="Evidence description" sectionDescription=view.noteText}}
{{view Balanced.TextAreaFormFieldView model=view.model inputClassNames="full" inputName="note" field="note" labelText="Note" maxlength=434}}
{{/view}}
@@ -16,5 +16,5 @@
<div class="modal-body clearfix">
{{yield}}
</div>
{{view Balanced.Modals.ModalBaseFooter isSaving=view.isSaving cancelButtonText=view.cancelButtonText submitButtonText=view.submitButtonText}}
{{view Balanced.Modals.ModalBaseFooter isSaving=view.isSaving beforeSubmitText=view.beforeSubmitText cancelButtonText=view.cancelButtonText submitButtonText=view.submitButtonText}}
</form>
@@ -1,3 +1,4 @@
<div class="before-submit-text">{{view.beforeSubmitText}}</div>
{{#if view.cancelButtonText}}
<button class="btn secondary" type="button" name="modal-cancel" data-dismiss="modal" aria-hidden="true" {{bind-attr disabled="view.isSaving"}}>{{view.cancelButtonText}}</button>
{{/if}}
@@ -4,23 +4,25 @@
<th class="span3 date">
<span>Date</span>
</th>
<th class="span6">
<span>Name</span>
<th class="span9">
<span>File</span>
</th>
<th class="span3"><span>Size</span></th>
<th class="span3 num"><span>Size</span></th>
</tr>
</thead>
<tbody>
{{#each doc in view.content.documents}}
<tr>
<td>
<a {{bind-attr href="doc.file_url"}}><time {{bind-attr datetime="doc.created_at"}} {{bind-attr title="doc.created_at"}}>
{{humanReadableDateShort doc.created_at}}</time></a>
</td>
{{view Balanced.LinkedDateCellView
item=doc
classNames="span3"
href=doc.file_url
date=doc.created_at
}}
<td>
<a {{bind-attr href="doc.file_url"}}><span>{{doc.file_name}}</span></a>
</td>
<td>
<td class="num">
<a {{bind-attr href="doc.file_url"}}><span>{{formatFileSize doc.size}}</span></a>
</td>
</tr>
@@ -37,9 +39,15 @@
{{/each}}
</tbody>
</table>
{{#if view.content.documents}}
<div class="dispute-note">
<span class="sl-sm">Note:</span>
<span class="sl-note">{{view.content.dispute_note}}</span>
</div>
{{#if view.content.isEvidenceProvided}}
<dl class="dispute-note">
{{#if view.content.justitia_dispute.tracking_number}}
<dt>Tracking number</dt>
<dd>{{view.content.justitia_dispute.tracking_number}}</dd>
{{/if}}
<dt>Note</dt>
<dd>{{view.content.justitia_dispute.note}}</dd>
</dl>
{{/if}}
@@ -7,7 +7,7 @@
<th class="span3 status">
<span>Status</span>
</th>
<th class="span6 event"><span>Event name</span></th>
<th class="span9 event"><span>Event name</span></th>
</tr>
</thead>
<tbody>
@@ -15,8 +15,8 @@
</th>
{{#unless view.isSmallTable}}
<th class="span4 label6a account"><span>Customer</span></th>
<th class="span4 label6a funding-instrument"><span>Payment method</span></th>
{{/unless}}
<th class="span3 label6a funding-instrument"><span>Payment method</span></th>
<th class="span2 label6a amount num has-filter">
{{#view Balanced.ResultsLoaderSortColumnHeaderView resultsLoader=view.loader field="amount" actionName="changeDisputesSort"}}
<span>Amount</span>
@@ -70,15 +70,14 @@
{{/if}}
{{/link-to}}
</td>
<td class="span3 funding-instrument">
{{#link-to dispute.route_name dispute}}
<span {{bind-attr class="dispute.transaction.dasherized_funding_instrument_type"}}>
<span class="primary">{{dispute.last_four}} {{dispute.funding_instrument_name}}</span>
<span class="secondary">{{dispute.funding_instrument_type}}</span>
</span>{{/link-to}}
</td>
{{/unless}}
<td class="span3 funding-instrument">
{{#link-to dispute.route_name dispute}}
<span {{bind-attr class="dispute.transaction.dasherized_funding_instrument_type"}}>
<span class="primary">{{dispute.last_four}} {{dispute.funding_instrument_name}}</span>
<span class="secondary">{{dispute.funding_instrument_type}}</span>
</span>{{/link-to}}
</td>
<td class="span2 amount num">
{{#link-to dispute.route_name dispute}}
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.