Skip to content

Commit

Permalink
refactor(registry and test): update the registry by intergrating sugg…
Browse files Browse the repository at this point in the history
…estion of #1964 and update the
  • Loading branch information
DedrickEnc committed Aug 15, 2017
1 parent 6a8bb48 commit 6d6cd7f
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 141 deletions.
11 changes: 6 additions & 5 deletions client/src/i18n/fr/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@
"ON_DELIVERY": "Lors de la delivarance",
"ON_PURCHASE": "Lors de l'achat",
"OTHER": "Autre",
"OPENING_BALANCE" : "Balance Ouverture",
"FINAL_BALANCE" : "Balance Finale",
"INTERMEDIATE_BALANCE" : "Balance Intermediare",
"OPENING_BALANCE": "Balance Ouverture",
"FINAL_BALANCE": "Balance Finale",
"INTERMEDIATE_BALANCE": "Balance Intermediare",
"OPTIONAL_INFO": "Informations Optionnelles",
"ORIGIN_LOCATION": "Localisation d'Origine",
"ORIGIN_VILLAGE": "Village d'Origine",
Expand Down Expand Up @@ -417,7 +417,7 @@
"SERVICE": "Service",
"SET_DATE": "Changer la Date",
"SEX": "Sexe",
"SHOW_SIMPLE_PREVIEW" : "Afficher Apercue Simple",
"SHOW_SIMPLE_PREVIEW": "Afficher Apercue Simple",
"SIGNATURE": "Signature",
"SIZE_BYTES": "Octets",
"SIZE_KB": "Ko",
Expand Down Expand Up @@ -585,6 +585,7 @@
"SERVICE": "Sélectionner un Service",
"SEX": "Sélectionner le sexe",
"SOURCE": "Sélectionner la source",
"SUPPLIER" : "Selectionner Fournisseur",
"TRANSACTION_TYPE": "Selectionner transaction type",
"TRANSFER_TYPE": "Sélectionner le type de transfert",
"TYPE": "Sélectionner un type",
Expand Down Expand Up @@ -623,4 +624,4 @@
"NO_CHANGES" : "Vous n'avez pas changé les données dans le formulaire. Rien a été submis au server."
}
}
}
}
8 changes: 4 additions & 4 deletions client/src/modules/purchases/list/list.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="flex-header static">
<div class="flex-header">
<div class="bhima-title">
<ol class="headercrumb">
<li class="static" translate>TREE.PURCHASE</li>
Expand Down Expand Up @@ -55,15 +55,16 @@
ng-click="PurchaseListCtrl.search()"
data-method="search"
class="btn btn-default">
<span class="hidden-xs"></span> <span translate>FORM.BUTTONS.SEARCH</span>
<span class="fa fa-search"></span> <span class="hidden-xs" translate>FORM.BUTTONS.SEARCH</span>
</button>
</div>
</div>
</div>
</div>

<div class="flex-util bh-filter-bar">
<div class="flex-util" style="min-height : 35px; padding-top : 7px; max-height: initial">
<bh-filters
style="max-width:90%"
filters="PurchaseListCtrl.latestViewFilters"
on-remove-filter="PurchaseListCtrl.onRemoveFilter(filter)">
</bh-filters>
Expand All @@ -74,7 +75,6 @@
<div
id="purchase-registry"
class="grid-full-height-with-filters"
ng-style="PurchaseListCtrl.filterBarHeight"
ui-grid="PurchaseListCtrl.uiGridOptions"
ui-grid-auto-resize
ui-grid-resize-columns
Expand Down
108 changes: 45 additions & 63 deletions client/src/modules/purchases/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,67 +33,62 @@ function PurchaseListController($state, PurchaseOrder, Notify, Receipts, uiGridC
vm.loading = false;

columnDefs = [{
field : 'reference',
displayName : 'FORM.LABELS.REFERENCE',
headerCellFilter : 'translate',
aggregationType : uiGridConstants.aggregationTypes.count,
aggregationHideLabel : true,
field: 'reference',
displayName: 'FORM.LABELS.REFERENCE',
headerCellFilter: 'translate',
cellTemplate: 'modules/purchases/templates/uuid.tmpl.html',
aggregationType: uiGridConstants.aggregationTypes.count,
aggregationHideLabel: true,
}, {
field : 'date',
displayName : 'FORM.LABELS.DATE',
headerCellFilter : 'translate',
cellFilter : 'date',
field: 'date',
displayName: 'FORM.LABELS.DATE',
headerCellFilter: 'translate',
cellFilter: 'date',
}, {
field : 'supplier',
displayName : 'FORM.LABELS.SUPPLIER',
headerCellFilter : 'translate',
field: 'supplier',
displayName: 'FORM.LABELS.SUPPLIER',
headerCellFilter: 'translate',
}, {
field : 'note',
displayName : 'FORM.LABELS.DESCRIPTION',
headerCellFilter : 'translate',
field: 'note',
displayName: 'FORM.LABELS.DESCRIPTION',
headerCellFilter: 'translate',
}, {
cellTemplate : '/modules/purchases/templates/cellCost.tmpl.html',
field : 'cost',
displayName : 'FORM.LABELS.COST',
headerCellFilter : 'translate',
footerCellFilter : 'currency:'.concat(Session.enterprise.currency_id),
aggregationType : uiGridConstants.aggregationTypes.sum,
aggregationHideLabel : true,
cellTemplate: '/modules/purchases/templates/cellCost.tmpl.html',
field: 'cost',
displayName: 'FORM.LABELS.COST',
headerCellFilter: 'translate',
footerCellFilter: 'currency:'.concat(Session.enterprise.currency_id),
aggregationType: uiGridConstants.aggregationTypes.sum,
aggregationHideLabel: true,
}, {
field : 'author',
displayName : 'FORM.LABELS.AUTHOR',
headerCellFilter : 'translate',
field: 'author',
displayName: 'FORM.LABELS.AUTHOR',
headerCellFilter: 'translate',
}, {
cellTemplate : '/modules/purchases/templates/cellStatus.tmpl.html',
field : 'status',
displayName : 'FORM.LABELS.STATUS',
headerCellFilter : 'translate',
enableFiltering : false,
enableSorting : false,
cellTemplate: '/modules/purchases/templates/cellStatus.tmpl.html',
field: 'status',
displayName: 'FORM.LABELS.STATUS',
headerCellFilter: 'translate',
enableFiltering: false,
enableSorting: false,
}, {
field : 'action',
displayName : '',
cellTemplate : '/modules/purchases/templates/cellEdit.tmpl.html',
enableFiltering : false,
enableSorting : false,
}, {
field : 'uuid',
cellTemplate : '/modules/purchases/templates/cellDocument.tmpl.html',
displayName : 'FORM.LABELS.DOCUMENT',
headerCellFilter : 'translate',
enableFiltering : false,
enableSorting : false,
field: 'action',
displayName: '...',
enableFiltering: false,
enableColumnMenu: false,
enableSorting: false,
cellTemplate: 'modules/purchases/templates/action.cell.html',
}];

/** TODO manage column : last_transaction */
vm.uiGridOptions = {
appScopeProvider : vm,
showColumnFooter : true,
enableSorting : true,
enableColumnMenus : false,
flatEntityAccess : true,
fastWatch : true,
columnDefs : columnDefs,
appScopeProvider: vm,
showColumnFooter: true,
enableSorting: true,
enableColumnMenus: false,
flatEntityAccess: true,
fastWatch: true,
columnDefs: columnDefs,
};

var columnConfig = new Columns(vm.uiGridOptions, cacheKey);
Expand Down Expand Up @@ -172,19 +167,6 @@ function PurchaseListController($state, PurchaseOrder, Notify, Receipts, uiGridC
function startup() {
load(PurchaseOrder.filters.formatHTTP(true));
vm.latestViewFilters = PurchaseOrder.filters.formatView();



// if ($state.params.filters) {
// // Fix me, generate change dynamically
// var change = [{ key : $state.params.filters.key, value : $state.params.filters.value }];

// PurchaseOrder.filters.replaceFilters(change);
// PurchaseOrder.cacheFilters();
// }

// load(PurchaseOrder.filters.formatHTTP(true));
// vm.latestViewFilters = PurchaseOrder.filters.formatView();
}

// fire up the module
Expand Down
29 changes: 29 additions & 0 deletions client/src/modules/purchases/templates/action.cell.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="ui-grid-cell-contents text-action" uib-dropdown dropdown-append-to-body>
<a href uib-dropdown-toggle>
<span data-method="action" translate>FORM.BUTTONS.ACTIONS</span>
<span class="caret"></span>
</a>

<ul data-action="{{ rowRenderIndex}}" class="dropdown-menu-right" uib-dropdown-menu>
<li>
<a
href
data-method="document"
ng-click="grid.appScope.getDocument(row.entity.uuid)"
data-edit-metadata="{{ row.entity.uuid }}">
<i class="fa fa-file-pdf-o"></i> <span translate>FORM.LABELS.DOCUMENT</span>
</a>
</li>

<li>
<a
href
class="text-action"
ng-click="grid.appScope.editStatus(row.entity)"
data-edit-metadata="{{ row.entity.uuid }}"
data-method="edit">
<i class="fa fa-edit"></i><span translate>FORM.LABELS.EDIT_STATUS</span>
</a>
</li>
</ul>
</div>
11 changes: 0 additions & 11 deletions client/src/modules/purchases/templates/cellDocument.tmpl.html

This file was deleted.

13 changes: 0 additions & 13 deletions client/src/modules/purchases/templates/cellEdit.tmpl.html

This file was deleted.

5 changes: 5 additions & 0 deletions client/src/modules/purchases/templates/uuid.tmpl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="ui-grid-cell-contents">
<a href ng-click="grid.appScope.getDocument(row.entity.uuid)">
{{ row.entity.reference }}
</a>
</div>
35 changes: 0 additions & 35 deletions server/controllers/finance/purchases.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,41 +198,6 @@ function list(req, res, next) {
.then(rows => res.status(200).json(rows))
.catch(next)
.done();




// let sql;

// sql = `
// SELECT BUID(p.uuid) AS uuid,
// CONCAT_WS('.', '${identifiers.PURCHASE_ORDER.key}', pr.abbr, p.reference) AS reference,
// p.cost, p.date, BUID(p.supplier_uuid) as supplier_uuid
// FROM purchase AS p
// JOIN supplier AS s ON s.uuid = p.supplier_uuid
// JOIN project AS pr ON p.project_id = pr.id;
// `;

// if (req.query.detailed === '1') {
// sql = `
// SELECT BUID(p.uuid) AS uuid,
// CONCAT_WS('.', '${identifiers.PURCHASE_ORDER.key}', pr.abbr, p.reference) AS reference,
// p.cost, p.date, s.display_name AS supplier, p.user_id, p.note,
// BUID(p.supplier_uuid) as supplier_uuid, u.display_name AS author,
// p.is_confirmed, p.is_received, p.is_cancelled, p.is_partially_received
// FROM purchase AS p
// JOIN supplier AS s ON s.uuid = p.supplier_uuid
// JOIN project AS pr ON p.project_id = pr.id
// JOIN user AS u ON u.id = p.user_id;
// `;
// }

// db.exec(sql)
// .then((rows) => {
// res.status(200).json(rows);
// })
// .catch(next)
// .done();
}

/**
Expand Down
29 changes: 19 additions & 10 deletions test/end-to-end/purchases/registry.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function PurchaseOrderSearch() {
reference: 'PO.TPA.2',
name1: 'Patient',
author: 'Super User',
status: 'Confirmed'
status: 'Confirmed',
supplier : 'Test Supplier',
};

const grid = element(by.id('purchase-registry'));
Expand All @@ -40,42 +41,50 @@ function PurchaseOrderSearch() {
}

it('grid should have 0 visible rows', () => {
const DEFAULT_PATIENTS_FOR_TODAY = 0;
const DEFAULT_PURCHASES_FOR_TODAY = 0;
modal.switchToDefaultFilterTab();
modal.setPeriod('today');
modal.submit();

expectNumberOfGridRows(DEFAULT_PATIENTS_FOR_TODAY);
expectNumberOfGridRows(DEFAULT_PURCHASES_FOR_TODAY);
});

// demonstrates that filtering works
it(`should find one Purchase Order with Reference "${parameters.reference}"`, () => {
it(`should find one Purchase Order with Reference "${parameters.reference}" for the current year`, () => {
const NUM_MATCHING = 1;
FU.input('ModalCtrl.params.reference', parameters.reference);
modal.setReference(parameters.reference);

modal.switchToDefaultFilterTab();
modal.setPeriod('year');
FU.modal.submit();

expectNumberOfGridRows(NUM_MATCHING);
});

it(`should find two Purchases Orders authored By "${parameters.author}"`, () => {
it(`should find four Purchases Orders authored By "${parameters.author}" for all time`, () => {
const NUM_MATCHING = 4;
modal.setUser('Super User');
modal.setUser(parameters.author);

modal.switchToDefaultFilterTab();
modal.setPeriod('allTime');
FU.modal.submit();

element.all(by.css('[data-method="edit"]')).get(0).click();
element.all(by.name('status')).get(0).click();
expectNumberOfGridRows(NUM_MATCHING);
});

it(`should list all purchase orders ordered to "${parameters.supplier}" for all time`, () => {
const NUM_MATCHING = 4;
modal.setSupplier(parameters.supplier);

modal.switchToDefaultFilterTab();
modal.setPeriod('allTime');
FU.modal.submit();

expectNumberOfGridRows(NUM_MATCHING);
});


it(`Change the status of a purchase order and should find two Purchases Orders status By "${parameters.status}"`, function () {
it(`Choose the status confirmed and should find two Purchases Orders status By "${parameters.status}" for all time`, function () {
const NUM_MATCHING = 1;
element(by.id('is_confirmed')).click();
modal.switchToDefaultFilterTab();
Expand Down
5 changes: 5 additions & 0 deletions test/end-to-end/shared/search.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const bhDepotSelect = require('../shared/components/bhDepotSelect');
const bhInventorySelect = require('../shared/components/bhInventorySelect');
const bhDateInterval = require('../shared/components/bhDateInterval');
const bhTransactionTypeSelect = require('../shared/components/bhTransactionTypeSelect');
const bhSupplierSelect = require('../shared/components/bhSupplierSelect');

const CUSTOM_FILTER_TAB = '[data-custom-filter-tab]';
const DEFAULT_FILTER_TAB = '[data-default-filter-tab]';
Expand Down Expand Up @@ -109,6 +110,10 @@ class SearchModal {
bhUserSelect.set(user);
}

setSupplier(supplier) {
bhSupplierSelect.set(supplier);
}

setDepot (depot){
bhDepotSelect.set(depot);
}
Expand Down

0 comments on commit 6d6cd7f

Please sign in to comment.