diff --git a/app/controllers/abstract-paged-controller.js b/app/controllers/abstract-paged-controller.js index e349dedeaf..ddcceae30b 100644 --- a/app/controllers/abstract-paged-controller.js +++ b/app/controllers/abstract-paged-controller.js @@ -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'), diff --git a/app/routes/abstract-index-route.js b/app/routes/abstract-index-route.js index 0790164719..5c489b4442 100644 --- a/app/routes/abstract-index-route.js +++ b/app/routes/abstract-index-route.js @@ -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') }; diff --git a/tests/acceptance/imaging-test.js b/tests/acceptance/imaging-test.js index af85dc1929..86f9224b28 100644 --- a/tests/acceptance/imaging-test.js +++ b/tests/acceptance/imaging-test.js @@ -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?)'); }); }); }); diff --git a/tests/acceptance/inventory-test.js b/tests/acceptance/inventory-test.js index 7050f6aabf..4f7e854621 100644 --- a/tests/acceptance/inventory-test.js +++ b/tests/acceptance/inventory-test.js @@ -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();