Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Fix #395 #396 #397 (#431)
Browse files Browse the repository at this point in the history
Fixes #395 
Fixes #396 
Fixes #397
  • Loading branch information
esbanarango authored and jkleinsc committed Apr 25, 2016
1 parent 5c3e843 commit bf59ede
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
11 changes: 11 additions & 0 deletions app/controllers/abstract-paged-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ export default Ember.Controller.extend(PaginationProps, ProgressDialog, UserSess
return (!Ember.isEmpty(this.get('previousStartKey')) || !Ember.isEmpty(this.get('nextStartKey')));
}.property('nextStartKey', 'previousStartKey'),

hasRecords: Ember.computed('model.length', {
get() {
let model = this.get('model');
if (!Ember.isEmpty(model)) {
return (model.get('length') > 0);
} else {
return false;
}
}
}),

actions: {
nextPage: function() {
var key = this.get('nextStartKey'),
Expand Down
3 changes: 0 additions & 3 deletions app/routes/abstract-index-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ export default Ember.Route.extend(PouchDbMixin, ProgressDialog, AuthenticatedRou
setupController: function(controller, model) {
var props = this.getProperties('firstKey', 'nextStartKey');
controller.setProperties(props);
if (!Ember.isEmpty(model)) {
controller.set('hasRecords', (model.get('length') > 0));
}
var sectionDetails = {
currentScreenTitle: this.get('pageTitle')
};
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/imaging-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ test('mark an imaging request as completed', (assert) => {
click('button:contains(Return)');
andThen(() => {
assert.equal(currentURL(), '/imaging');
assert.equal(find('tr').length, 1, 'No requests are left to complete');
findWithAssert('a:contains(Create a new record?)');
});
});
});
22 changes: 22 additions & 0 deletions tests/acceptance/inventory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ test('Adding a new inventory item', (assert) => {
});
});

test('Deleting the last inventory item', (assert) => {
runWithPouchDump('inventory', function() {
authenticateUser();
visit('/inventory/listing');

andThen(function() {
assert.equal(currentURL(), '/inventory/listing');
click('button:contains(Delete)');
waitToAppear('.modal-dialog');
andThen(() => {
assert.equal(find('.modal-title').text(), 'Delete Item', 'Deleting confirmation.');
});
click('.modal-content button:contains(Delete)');
waitToAppear('.panel-body .alert-info');
andThen(function() {
assert.equal(currentURL(), '/inventory/listing');
findWithAssert('a:contains(Create a new record?)');
});
});
});
});

test('Creating a new inventory request', function(assert) {
runWithPouchDump('inventory', function() {
authenticateUser();
Expand Down

0 comments on commit bf59ede

Please sign in to comment.