diff --git a/client/src/modules/donor/donor.ctrl.js b/client/src/modules/donor/donor.ctrl.js index 5c05a9a9dc..2ea1620498 100644 --- a/client/src/modules/donor/donor.ctrl.js +++ b/client/src/modules/donor/donor.ctrl.js @@ -50,7 +50,23 @@ function DonorController($uibModal, Donor, Modal, Notify, uiGridConstants) { field : 'display_name', displayName : 'FORM.LABELS.NAME', headerCellFilter : 'translate', - }, { + }, + { + field : 'phone', + displayName : 'FORM.LABELS.PHONE', + headerCellFilter : 'translate', + }, + { + field : 'email', + displayName : 'FORM.LABELS.EMAIL', + headerCellFilter : 'translate', + }, + { + field : 'address', + displayName : 'FORM.LABELS.ADDRESS', + headerCellFilter : 'translate', + }, + { field : 'actions', enableFiltering : false, width : 100, diff --git a/client/src/modules/donor/donor.html b/client/src/modules/donor/donor.html index 41ec3d3496..0e24423a6b 100644 --- a/client/src/modules/donor/donor.html +++ b/client/src/modules/donor/donor.html @@ -22,7 +22,7 @@
+ +
+ + +
+
+
+
+ + +
+ + +
+
+
+
+ + +
+ + +
+
+
+
diff --git a/client/src/modules/reports/generate/stock_entry/stock_entry.html b/client/src/modules/reports/generate/stock_entry/stock_entry.html index 7b92a85eac..9464185371 100644 --- a/client/src/modules/reports/generate/stock_entry/stock_entry.html +++ b/client/src/modules/reports/generate/stock_entry/stock_entry.html @@ -43,28 +43,36 @@

REPORT.STOCK.ENTRY_REPORT

diff --git a/server/controllers/admin/donor.js b/server/controllers/admin/donor.js index a591d63aa4..fb22b6e37a 100644 --- a/server/controllers/admin/donor.js +++ b/server/controllers/admin/donor.js @@ -24,14 +24,14 @@ function update(req, res, next) { } function read(req, res, next) { - db.exec(`SELECT id, display_name FROM donor`).then(donors => { + db.exec(`SELECT id, display_name, email, phone, address FROM donor`).then(donors => { res.status(200).json(donors); }).catch(next); } function detail(req, res, next) { const { id } = req.params; - db.one(`SELECT id, display_name FROM donor WHERE id=?`, id).then(donor => { + db.one(`SELECT id, display_name, email, phone, address FROM donor WHERE id=?`, id).then(donor => { res.status(200).json(donor); }).catch(next); } diff --git a/server/models/migrations/next/migrate.sql b/server/models/migrations/next/migrate.sql index 2c3772c7f9..a5d9902f01 100644 --- a/server/models/migrations/next/migrate.sql +++ b/server/models/migrations/next/migrate.sql @@ -715,3 +715,8 @@ CREATE TABLE `lot_tag` ( */ INSERT INTO unit VALUES (290,'Donors','TREE.DONOR','Donors management',1,'/donors'); + +ALTER TABLE `donor` + ADD COLUMN `email` VARCHAR(50) DEFAULT NULL, + ADD COLUMN `phone` VARCHAR(50) DEFAULT NULL, + ADD COLUMN `address` VARCHAR(150) DEFAULT NULL; \ No newline at end of file diff --git a/server/models/schema.sql b/server/models/schema.sql index 3e7cdd2da6..9bc7cbc806 100644 --- a/server/models/schema.sql +++ b/server/models/schema.sql @@ -1989,6 +1989,9 @@ DROP TABLE IF EXISTS `donor`; CREATE TABLE `donor` ( `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, `display_name` VARCHAR(191) NOT NULL, + `phone` VARCHAR(50) NULL, + `email` VARCHAR(50) NULL, + `address` VARCHAR(150) NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = utf8mb4_unicode_ci; diff --git a/test/end-to-end/donor/donor.page.js b/test/end-to-end/donor/donor.page.js new file mode 100644 index 0000000000..098f57ea5e --- /dev/null +++ b/test/end-to-end/donor/donor.page.js @@ -0,0 +1,63 @@ +/* global element, by, browser */ +const EC = require('protractor').ExpectedConditions; +const FU = require('../shared/FormUtils'); +const GridRow = require('../shared/GridRow'); + +const { bhCheckboxTree } = require('../shared/components'); + +class DonorPage { + constructor() { + this.gridId = 'donor-grid'; + this.donorName = element(by.model('DonorAddCtrl.donor.display_name')); + this.donorPhone = element(by.model('DonorAddCtrl.donor.phone')); + this.donorEmail = element(by.model('DonorAddCtrl.donor.email')); + this.donorAddress = element(by.model('DonorAddCtrl.donor.address')); + } + + submit() { + return FU.modal.submit(); + } + + setName(txt) { + return this.donorName.clear().sendKeys(txt); + } + + setPhone(txt) { + return this.donorPhone.clear().sendKeys(txt); + } + + setEmail(txt) { + return this.donorEmail.clear().sendKeys(txt); + } + + setAddress(txt) { + return this.donorAddress.clear().sendKeys(txt); + } + + async openDropdownMenu(label) { + const row = new GridRow(label); + await row.dropdown().click(); + return row; + } + + async editDonor(displayName) { + const row = await this.openDropdownMenu(displayName); + await row.edit().click(); + } + + async deleteDonor(displayName) { + const row = await this.openDropdownMenu(displayName); + await row.remove().click(); + } + + async checkAllPermissions() { + await browser.wait(EC.presenceOf($(bhCheckboxTree.selector)), 1500); + await bhCheckboxTree.toggleAllCheckboxes(); + } + + openCreateModal() { + return FU.buttons.create(); + } +} + +module.exports = DonorPage; diff --git a/test/end-to-end/donor/donor.spec.js b/test/end-to-end/donor/donor.spec.js new file mode 100644 index 0000000000..cf0f0d1b1f --- /dev/null +++ b/test/end-to-end/donor/donor.spec.js @@ -0,0 +1,47 @@ +const helpers = require('../shared/helpers'); +const DonorsPage = require('./donor.page'); +const components = require('../shared/components'); + +// the page object +const page = new DonorsPage(); + +function donorsManagementTests() { + + // navigate to the page + before(() => helpers.navigate('#/donors')); + + it('should add a new donor', async () => { + await page.openCreateModal(); + await page.setName('DFD'); + await page.setEmail('dfid@imaworld.com'); + await page.setPhone('+100000202'); + await page.setAddress('232 USA ..'); + await page.submit(); + await components.notification.hasSuccess(); + }); + + it('should add a edit donor', async () => { + await page.editDonor('DFD'); + await page.setName('DFID'); + await page.submit(); + await components.notification.hasSuccess(); + }); + + it('should add a test donor', async () => { + await page.openCreateModal(); + await page.setName('Test donor'); + await page.submit(); + await components.notification.hasSuccess(); + }); + + it('should delete the test donor', async () => { + await page.deleteDonor('Test donor'); + await page.submit(); + await components.notification.hasSuccess(); + }); + +} + +describe('donor Management Tests', () => { + describe('donor Management', donorsManagementTests); +}); diff --git a/test/integration/donor.js b/test/integration/donor.js index f13dcb9c28..5401bbc33c 100644 --- a/test/integration/donor.js +++ b/test/integration/donor.js @@ -14,6 +14,9 @@ describe('(/donors) The donros API endpoint', () => { const newDonor = { id : 2, display_name : 'IMA', + email : 'ima@gmail.com', + phone : '+243810000001', + address : '289 Kinshasa, RDC', }; const updatedDonor = {