diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index 6fce4e1e1a..8bb30231e8 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -39,6 +39,7 @@ "RESET_DEFAULTS":"Reset Defaults", "RETURN":"Return", "SAVE":"Save", +"SAVE_GRID_CONFIGURATION" : "Save grid configuration", "SEARCH":"Search", "SELECT_INVOICES":"Select Invoices", "SUBMIT":"Submit", @@ -101,6 +102,7 @@ "ITEMS_FULL":"There are no additional inventory items that be assigned to this invoice.", "INVOICES":"Invoices", "IMPORT_SUCCESS":"Successfully Imported", +"GRID_STATE_SUCCESS":"Grid settings saved", "LOADING":"Loading", "MANY_TRYS":"Many tries", "NOT_CONFIGURED":"The accounts for this currency have not been configured yet.", @@ -139,7 +141,7 @@ "ACCOUNT_NUMBER":"Account Number", "ACCOUNT_TITLE":"Account Text", "ACCOUNT_TYPE":"Account Type", -"ACTIVATE":"Activate", +"ACTIVATE":"Activate", "ACTIVE":"Active", "ADD":"Add", "ADDRESS":"Address", @@ -207,7 +209,7 @@ "DATE_FROM":"Start", "DATE_REGISTRATION":"Registration Date", "DATE_TO":"End", -"DEACTIVATE":"Deactivate", +"DEACTIVATE":"Deactivate", "DEBIT":"Debit", "DEBTOR_GROUP":"Debtor Group", "DEBTOR_GROUP_FORM":"Form debtor group record", diff --git a/client/src/i18n/fr/form.json b/client/src/i18n/fr/form.json index 28e66af8fa..ee38fcff55 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -39,6 +39,7 @@ "RESET_DEFAULTS":"Réinitialiser par défaut", "RETURN":"Retourne", "SAVE":"Sauver", +"SAVE_GRID_CONFIGURATION" : "Enregister la configuration", "SEARCH":"Rechercher", "SELECT_INVOICES":"Sélectionner la(les) Facture(s)", "SUBMIT":"Soumettre", @@ -99,6 +100,7 @@ "GROUPS_DEBTOR":"Attribuez un nouveau groupe de débiteur parmi les options ci-dessous. Appuyez sur 'confirmer' pour une mise à jour permanente du groupe de débiteur du patient", "GROUPS_PATIENT":"Attribuer le patient à des groupes parmi les options ci-dessous. Appuyez sur 'confirmer' pour une mise à jour permanente des groupes souscrites du patient.", "IMPORT_SUCCESS":"Importation avec succes", +"GRID_STATE_SUCCESS":"Enregistrement avec succès", "INVOICES":"Factures", "ITEMS_FULL":"Il n'y a pas d'articles supplémentaires qui seront affectés à cette facture.", "LOADING":"Chargement en cours", @@ -139,7 +141,7 @@ "ACCOUNT_NUMBER":"Numéro de Compte", "ACCOUNT_TITLE":"Libelle de Compte", "ACCOUNT_TYPE":"Type de Compte", -"ACTIVATE":"Activer", +"ACTIVATE":"Activer", "ACTIVE":"Actif", "ADD":"Ajouter", "ADDRESS":"Adresse", diff --git a/client/src/js/app.js b/client/src/js/app.js index dba8227f72..75c1f04d18 100644 --- a/client/src/js/app.js +++ b/client/src/js/app.js @@ -2,7 +2,7 @@ var bhima = angular.module('bhima', [ 'bhima.controllers', 'bhima.services', 'bhima.directives', 'bhima.filters', 'bhima.components', 'bhima.routes', 'ui.bootstrap', 'pascalprecht.translate', 'ngStorage', 'chart.js', - 'tmh.dynamicLocale', 'ngFileUpload', 'ui.grid', + 'tmh.dynamicLocale', 'ngFileUpload', 'ui.grid', 'ui.grid.saveState', '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', 'ui.grid.exporter', diff --git a/client/src/js/services/grid/GridState.js b/client/src/js/services/grid/GridState.js new file mode 100644 index 0000000000..db0448edcd --- /dev/null +++ b/client/src/js/services/grid/GridState.js @@ -0,0 +1,45 @@ +angular.module('bhima.services') +.service('GridStateService', GridStateService); + +GridStateService.$inject = [ + 'util', 'appcache', 'NotifyService' +]; + +// responsible for - +// - caching grid state seperately for each grid +// - hooking into the grid api to apply the default size only when the grid is ready +// - exposing the methods to save and restore grid state +function GridStateService(util, AppCache, Notify) { + /* @const */ + var stateCacheKey = 'gridState'; + + function StateInstance(gridOptions, moduleCacheKey) { + this._cacheKey = moduleCacheKey.concat(stateCacheKey); + this._cache = new AppCache(this._cacheKey); + + util.after(gridOptions, 'onRegisterApi', function onRegisterApi(api) { + this._gridApi = api; + + this._gridApi.core.on.rowsRendered(null, util.once(function () { + this.restoreGridState(); + }.bind(this))); + }.bind(this)); + + this.saveGridState = saveGridState.bind(this); + this.restoreGridState = restoreGridState.bind(this); + } + + function saveGridState() { + if (this._gridApi) { + this._cache.gridState = this._gridApi.saveState.save(); + Notify.success('FORM.INFO.GRID_STATE_SUCCESS'); + } + }; + + function restoreGridState() { + if (this._gridApi && this._cache.gridState) { + this._gridApi.saveState.restore(null, this._cache.gridState); + } + }; + return StateInstance; +} diff --git a/client/src/modules/journal/journal.html b/client/src/modules/journal/journal.html index 0a893c2859..ce59da5603 100644 --- a/client/src/modules/journal/journal.html +++ b/client/src/modules/journal/journal.html @@ -22,9 +22,16 @@