Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Journal export csv with custom options #1554

Merged
merged 30 commits into from
May 15, 2017

Conversation

mbayopanda
Copy link
Contributor

@mbayopanda mbayopanda commented Apr 24, 2017

This PR allows to:

  • Export to csv the trial balance
  • Customize the name of the csv file
  • Use the exportation tool with grids

Closes #1543

@mbayopanda mbayopanda requested a review from jniles April 24, 2017 15:24
@mbayopanda mbayopanda requested review from sfount and removed request for jniles April 26, 2017 09:03
@ghost
Copy link

ghost commented Apr 27, 2017

☔ The latest upstream changes (presumably 033d9cd) made this pull request unmergeable. Please resolve the merge conflicts.

@ghost
Copy link

ghost commented Apr 28, 2017

☔ The latest upstream changes (presumably ac06db3) made this pull request unmergeable. Please resolve the merge conflicts.

@ghost
Copy link

ghost commented May 2, 2017

☔ The latest upstream changes (presumably 9f17d54) made this pull request unmergeable. Please resolve the merge conflicts.

@mbayopanda
Copy link
Contributor Author

@jniles could you review this PR

@jniles
Copy link
Collaborator

jniles commented May 4, 2017

Working on it!

@ghost
Copy link

ghost commented May 8, 2017

☔ The latest upstream changes (presumably 4df53c2) made this pull request unmergeable. Please resolve the merge conflicts.

@ghost
Copy link

ghost commented May 8, 2017

☔ The latest upstream changes (presumably 7cf8682) made this pull request unmergeable. Please resolve the merge conflicts.

@ghost
Copy link

ghost commented May 9, 2017

☔ The latest upstream changes (presumably 6bc89ba) made this pull request unmergeable. Please resolve the merge conflicts.

@mbayopanda
Copy link
Contributor Author

@jniles could you review this PR please

@@ -60,7 +60,7 @@
"MISSING_DATES":"Date(s) manquante(s)",
"MISSING_DOCUMENT_ID":"Ligne(s) sans ID Document",
"MISSING_ENTITY":"Ligne(s) sans ID entite",
"MISSING_FISCAL_OR_PERIOD":"Annee fiscale ou periode omise",
"MISSING_FISCAL_OR_PERIOD":"Année fiscale ou periode omise",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -5,7 +5,8 @@ var bhima = angular.module('bhima', [
'tmh.dynamicLocale', 'ngFileUpload', 'ui.grid',
'ui.grid.selection', 'ui.grid.autoResize', 'ui.grid.resizeColumns',
'ui.grid.edit', 'ui.grid.grouping', 'ui.grid.treeView', 'ui.grid.cellNav',
'ui.grid.pagination', 'ui.grid.moveColumns', 'angularMoment', 'ngMessages',
'ui.grid.pagination', 'ui.grid.moveColumns', 'ui.grid.exporter',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... is this possible to do without the exporter service? I don't see where it is used and I hate to introduce another dependency for something we can almost already do...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but with a lot of supplementary request to the server, also if we don't use the exporter service we cannot share the client service for exporting with custom name to other modules.

The first reason of using exporter service was because the trial balance request is so complex, and using this request again and again is not useful when we don't have a lot of data at client and data are already at the client we have just to export them.

Also exporter service give us more options for exportation which are flexible and we can use them in other modules with less effort

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your analysis is correct - for the trial balance, it is more work to export a CSV from the server side.

My biggest worry with this change is that, as a developer, I do not know when to use the server-side CSV rather than the client-side CSV. It creates another question to ask during development and something else to test....

function GridExport(gridOptions, defaultRows, defaultCols) {

this.gridOptions = gridOptions;
this.ROWS = defaultRows;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a little while to realize that these aren't actually rows .. it's a string. Could you name it something like defaultRowKey or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -50,6 +50,9 @@ function JournalController(Journal, Sorting, Grouping,
// top level cache
var cache = AppCache(cacheKey + '-module');
var vm = this;

var gridApi;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you use gridApi here.

headerCellFilter : 'translate',
headerCellClass : cssClass,
}, {
field : 'trans_id',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good catch.

var gridOptions = Data.options || {};
var gridApi = Data.api || {};
var filename = Data.filename || 'Export ' + moment().format('YYYY-MM-DD');
var ROWS = Data.rows || 'visible';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity, I propose we always render all rows in the grid. That's how our PDFs work and it makes sense that the filters chosen will be the ones applied to the dataset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current state of the exporter is just for csv, so we render what is visible to the client with the possibility of choosing other options (selected or all). This flexibility is useful because we have some grid which has grouped data and other not, for grid which has grouped data with the option visible the service export what is visible (ex. only grouping rows in the case of posting journal with grouped rows) and the user can select other options if he want, and developers can set the default option for grid according needs.

@mbayopanda
Copy link
Contributor Author

@jniles could you review this PR

Copy link
Collaborator

@jniles jniles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbayopanda, I need a second opinion on this.

I'm concerned about having two ways of doing things - one on the client and one on the server. It feels like unnecessary code bloat and technical debt... kind of against both DRY and KISS principles.

@sfount, could you provide your perspective?

@@ -5,7 +5,8 @@ var bhima = angular.module('bhima', [
'tmh.dynamicLocale', 'ngFileUpload', 'ui.grid',
'ui.grid.selection', 'ui.grid.autoResize', 'ui.grid.resizeColumns',
'ui.grid.edit', 'ui.grid.grouping', 'ui.grid.treeView', 'ui.grid.cellNav',
'ui.grid.pagination', 'ui.grid.moveColumns', 'angularMoment', 'ngMessages',
'ui.grid.pagination', 'ui.grid.moveColumns', 'ui.grid.exporter',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your analysis is correct - for the trial balance, it is more work to export a CSV from the server side.

My biggest worry with this change is that, as a developer, I do not know when to use the server-side CSV rather than the client-side CSV. It creates another question to ask during development and something else to test....

@ghost
Copy link

ghost commented May 11, 2017

☔ The latest upstream changes (presumably 89a3272) made this pull request unmergeable. Please resolve the merge conflicts.

@jniles
Copy link
Collaborator

jniles commented May 15, 2017

Since the work has already been done for this, we'll merge it and see how it works in production. If necessary, we can revert changes or implement something different/more.

@jniles jniles merged commit 869599d into IMA-WorldHealth:master May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants