Skip to content

Commit

Permalink
collapse list of errors when error open
Browse files Browse the repository at this point in the history
  • Loading branch information
agnessa committed Sep 7, 2016
1 parent 006c51a commit c52f848
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Trade.SandboxShipmentsController = Ember.ArrayController.extend Trade.ShipmentPa
@get('controllers.annualReportUpload.id')
)
@set('controllers.annualReportUpload.currentError', null)
@set('controllers.annualReportUpload.allErrorsCollapsed', null)

unsavedChanges: (->
@get('changedRowsCount') > 0
Expand All @@ -56,6 +57,8 @@ Trade.SandboxShipmentsController = Ember.ArrayController.extend Trade.ShipmentPa
).property('content.@each._modified', 'currentShipment')

actions:
closeError: ->
@transitionToParentController()

toggleUpdatesVisible: ->
@toggleProperty 'updatesVisible'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Trade.AnnualReportUploadRoute = Trade.BeforeRoute.extend
setupController: (controller, model) ->
controller.set('model', model)
controller.set('currentError', null)
controller.set('allErrorsCollapsed', null)
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Trade.SandboxShipmentsRoute = Trade.BeforeRoute.extend
setupController: (controller, model) ->
controller.set('model', model)
@controllerFor('annualReportUpload').set('currentError', @validationError)
@controllerFor('annualReportUpload').set('allErrorsCollapsed', true)
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<p>
Selected error: {{controllers.annualReportUpload.currentError.errorMessage}} ({{controllers.annualReportUpload.currentError.errorCount}})
{{#link-to "annual_report_upload" controllers.annualReportUpload}}
(close this error)
{{/link-to}}
<a {{action 'closeError'}}>(close this error)</a>
</p>

<div class="clearfix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{{/if}}
</div>
<div class="span9">
<a {{action transitionToSandboxShipments this}}>
<a {{action openError this target="view"}}>
{{errorMessage}} ({{errorCount}})
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@ Trade.ValidationErrorsView = Ember.View.extend
classNames: ['accordion-group']

didInsertElement: ->
@set('defaultCollapsed', @get('collapsed'))
if @get('controller.allErrorsCollapsed')
@set('collapsed', true)
$(@get('collapsibleElement')).on('hidden', =>
@set('collapsed', true)
)
$(@get('collapsibleElement')).on('shown', =>
@set('collapsed', false)
)

allErrorsCollapsedDidChange: ( ->
# reset default collapse setting
if @get('controller.allErrorsCollapsed') == null
@set('collapsed', @get('defaultCollapsed'))
).observes('controller.allErrorsCollapsed')

toggleHint: ( ->
if @get('collapsed')
'>>'
else
'<<'
).property('collapsed')

collapsibleId: ( ->
@get('errorType') + '-validation-errors'
).property('errorType')

collapsibleElement: ( ->
'#' + @get('collapsibleId')
).property('collapsibleId')
Expand All @@ -29,3 +40,9 @@ Trade.ValidationErrorsView = Ember.View.extend
else
'No errors detected'
).property('errorType')

actions:

openError: (validationError) ->
@set('collapsed', true)
@get('controller').send('transitionToSandboxShipments', validationError)

0 comments on commit c52f848

Please sign in to comment.