diff --git a/client/src/i18n/en/enterprise.json b/client/src/i18n/en/enterprise.json index 2ef74d828e..ada4dc3c27 100644 --- a/client/src/i18n/en/enterprise.json +++ b/client/src/i18n/en/enterprise.json @@ -1,8 +1,17 @@ -{"ENTERPRISE":{"ADD_ENTERPRISE":"Add Enterprise.", -"ALL_ENTERPRISES":"All Enterprises", -"CONFIGURATION_ENTERPRISE":"Configuration Enterprise", -"DESCRIPTION_1":"Manage the application Companies from here. For now clearing the enterprise is not taken into account.", -"DESCRIPTION_2":"Edit selected Enterprise", -"DESCRIPTION_3":"Add a new enterprise.", -"EDITING_ENTERPRISE":"Editing enterprise", -"TITLE":"Enterprise Management"}} \ No newline at end of file +{ + "ENTERPRISE": { + "ADD_ENTERPRISE" : "Add Enterprise.", + "ALL_ENTERPRISES" : "All Enterprises", + "CONFIGURATION_ENTERPRISE" : "Configuration Enterprise", + "DESCRIPTION_1" : "Manage the application Companies from here. For now clearing the enterprise is not taken into account.", + "DESCRIPTION_2" : "Edit selected enterprise", + "DESCRIPTION_3" : "Add a new enterprise.", + "EDITING_ENTERPRISE" : "Editing enterprise", + "TITLE" : "Enterprise Management", + "SETTINGS" : { + "TITLE" : "Enterprise Settings", + "ENABLE_PRICE_LOCK_LABEL" : "Lock Price Changes for Patient Invoicing", + "ENABLE_PRICE_LOCK_HELP_TEXT" : "Enabling this feature will disallow users from modifying the prices of inventory items in the Patient Invoice module." + } + } +} diff --git a/client/src/i18n/fr/enterprise.json b/client/src/i18n/fr/enterprise.json index eb60ecb21b..b65cda62b4 100644 --- a/client/src/i18n/fr/enterprise.json +++ b/client/src/i18n/fr/enterprise.json @@ -1,8 +1,17 @@ -{"ENTERPRISE":{"ADD_ENTERPRISE":"Ajouter entreprise", -"ALL_ENTERPRISES":"Tous les entriprises", -"CONFIGURATION_ENTERPRISE":"Configuration entreprise", -"DESCRIPTION_1":"Gerer les entreprises de l'application A partir d'ici. Pour l'instant effacement de l'entrerpise n'est pas prise en compte.", -"DESCRIPTION_2":"Modifier l'enterprise sélectionner", -"DESCRIPTION_3":"Ajouter une nouvelle entreprises", -"EDITING_ENTERPRISE":"Edition entreprise", -"TITLE":"Gestion des entreprises"}} \ No newline at end of file +{ + "ENTERPRISE" : { + "ADD_ENTERPRISE" : "Ajouter entreprise", + "ALL_ENTERPRISES" : "Tous les entriprises", + "CONFIGURATION_ENTERPRISE" : "Configuration entreprise", + "DESCRIPTION_1" : "Gerer les entreprises de l'application A partir d'ici. Pour l'instant effacement de l'entrerpise n'est pas prise en compte.", + "DESCRIPTION_2" : "Modifier l'enterprise sélectionner", + "DESCRIPTION_3" : "Ajouter une nouvelle entreprises", + "EDITING_ENTERPRISE" : "Edition entreprise", + "TITLE" : "Gestion des entreprises", + "SETTINGS" : { + "TITLE" : "Parametres de l'Enterprise", + "ENABLE_PRICE_LOCK_LABEL" : "Verrouiller les changements de prix pour la facturation des patients", + "ENABLE_PRICE_LOCK_HELP_TEXT" : "L'activation de cette fonctionnalité empêchera les utilisateurs de modifier les prix des articles en stock dans le module Facturation de Patients." + } + } +} diff --git a/client/src/js/components/bhYesNoRadios.js b/client/src/js/components/bhYesNoRadios.js index 9c21c80e5f..d32d472d06 100644 --- a/client/src/js/components/bhYesNoRadios.js +++ b/client/src/js/components/bhYesNoRadios.js @@ -1,24 +1,30 @@ angular.module('bhima.components') .component('bhYesNoRadios', { bindings : { - defaultValue : '@?', - value : '=', - label : '@?', + value : '<', + label : '@', helpText : '@?', onChangeCallback : '&', }, templateUrl : 'modules/templates/bhYesNoRadios.tmpl.html', - controller : YesNoRadio, + controller : YesNoRadioController, }); -function YesNoRadio() { +/** + * @function YesNoRadioController + * + * @description + * This component makes yes/no options a bit easier to navigate. + */ +function YesNoRadioController() { const $ctrl = this; - $ctrl.$onInit = function onInit() { - $ctrl.onChangeCallback = $ctrl.onChangeCallback; - $ctrl.defaultValue = $ctrl.defaultValue; - $ctrl.value = ($ctrl.defaultValue) ? 1 : 0; - $ctrl.label = $ctrl.label; - $ctrl.helpText = $ctrl.helpText; + + $ctrl.$onInit = () => { + $ctrl.value = Number.parseInt($ctrl.value, 10); + $ctrl.onChangeCallback = $ctrl.onChangeCallback || angular.noop; }; + $ctrl.onChange = (value) => { + $ctrl.onChangeCallback({ value }); + }; } diff --git a/client/src/js/services/ModalService.js b/client/src/js/services/ModalService.js index 3ed6a1ee15..ed60915ea1 100644 --- a/client/src/js/services/ModalService.js +++ b/client/src/js/services/ModalService.js @@ -24,9 +24,9 @@ ModalService.$inject = ['$uibModal']; * */ function ModalService(Modal) { - var service = this; + const service = this; - var modalParameters = { + const modalParameters = { size : 'md', backdrop : 'static', animation : false, @@ -89,9 +89,9 @@ function ModalService(Modal) { */ function confirm(prompt, options) { // default options for modal rendering - var opts = options || {}; + const opts = options || {}; - var instance = Modal.open({ + const instance = Modal.open({ animation : opts.animation || false, keyboard : opts.keyboard || true, size : opts.size || 'md', @@ -105,28 +105,30 @@ function ModalService(Modal) { function alert(prompt, options) { // default options for modal rendering - var opts = options || {}; + const opts = options || {}; - var instance = Modal.open({ + const instance = Modal.open({ animation : opts.animation || false, keyboard : opts.keyboard || true, size : opts.size || 'md', controller : 'AlertModalController as AlertModalCtrl', - resolve : { prompt : function provider() { return prompt;} }, - templateUrl : '/modules/templates/modals/alert.modal.html' + resolve : { prompt : () => prompt }, + templateUrl : '/modules/templates/modals/alert.modal.html', }); + + return instance.result; } /** * Select cashbox modal */ function openSelectCashbox(request) { - var params = angular.extend(modalParameters, { + const params = angular.extend(modalParameters, { templateUrl : 'modules/cash/modals/selectCashbox.modal.html', controller : 'SelectCashboxModalController as $ctrl', resolve : { - cashboxId : function cashboxIdProvider() { return request.cashboxId; } - } + cashboxId : function cashboxIdProvider() { return request.cashboxId; }, + }, }); return Modal.open(params).result; @@ -137,281 +139,223 @@ function ModalService(Modal) { */ function openUploadDocument(request) { - var params = angular.extend(modalParameters, { + const params = angular.extend(modalParameters, { templateUrl : 'modules/patients/documents/modals/documents.modal.html', controller : 'PatientDocumentsModalController', controllerAs : '$ctrl', - resolve : { - patientUuid : function patientProvider() { return request.patient_uuid; } - } + resolve : { patientUuid : () => request.patient_uuid }, }); - var instance = Modal.open(params); + const instance = Modal.open(params); return instance.result; } /** * Page for printing in Modal */ - function openReports(request) { - - var params = angular.extend(modalParameters, { - templateUrl : 'modules/templates/modals/reports.modal.html', - controller : 'ReportsModalController', - controllerAs : '$ctrl', - size : 'lg', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - } - - /** - * Inventory Group Actions - */ - function openInventoryGroupActions(request) { - - var params = angular.extend(modalParameters, { - templateUrl : 'modules/inventory/configuration/groups/modals/actions.tmpl.html', - controller : 'InventoryGroupsActionsModalController', - controllerAs : '$ctrl', - size : 'xs', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** Inventory Types Modal for actions */ - function openInventoryTypeActions(request) { - - var params = angular.extend(modalParameters, { - templateUrl : 'modules/inventory/configuration/types/modals/actions.tmpl.html', - controller : 'InventoryTypeActionsModalController', - controllerAs : '$ctrl', - size : 'xs', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** Inventory Units Modals for actions */ - function openInventoryUnitActions(data) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/inventory/configuration/units/modals/actions.tmpl.html', - controller : 'InventoryUnitActionsModalController', - controllerAs : '$ctrl', - resolve : { - data : function dataProvider() { return data; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** Inventory List Modals for actions */ - function openInventoryListActions(request) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/inventory/list/modals/actions.tmpl.html', - controller : 'InventoryListActionsModalController', - controllerAs : '$ctrl', - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** Find by Date interval modal */ - function openDateInterval(request) { - - var params = angular.extend(modalParameters, { - templateUrl : 'modules/templates/modals/dateInterval.tmpl.html', - controller : 'DateIntervalModalController', - controllerAs : '$ctrl', - size : 'xs', - backdrop : 'static', - animation : true, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** - * confirm deletion modal - * @param {object} request - * The request parameter take : - * pattern: the text to match, - * elementName: the name translated of the element to delete (document, transaction) - * @example - * request = { - * pattern: '#HBB17', - * elementName: $translate.instant('FORM.LABELS.TRANSACTION') - * } - */ - function openConfirmDialog(request) { - - var params = angular.extend(modalParameters, { - templateUrl : 'modules/templates/modals/confirmDialog.modal.html', - controller : 'ConfirmDialogModalController', - controllerAs : '$ctrl', - size : 'xs', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** project modal actions */ - function openProjectActions(request) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/templates/modals/project.modal.html', - controller : 'ProjectModalController', - controllerAs : '$ctrl', - size : 'xs', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** transaction type modal actions */ - function openTransactionTypeActions(request) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/templates/modals/transactionType.modal.html', - controller : 'TransactionTypeModalController', - controllerAs : '$ctrl', - size : 'xs', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** closing fiscal year modal */ - function openClosingFiscalYear(request) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/fiscal/templates/modals/fiscal.closing.modal.html', - controller : 'ClosingFiscalYearModalController', - controllerAs : '$ctrl', - size : 'lg', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** searchCashPayment */ - function openSearchCashPayment(filters) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/cash/payments/templates/search.modal.html', - controller : 'SearchCashPaymentModalController', - controllerAs : '$ctrl', - size : 'md', - backdrop : 'static', - animation : false, - resolve : { - filters : function filtersProvider() { return filters; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** purchase order status */ - function openPurchaseOrderStatus(request) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/purchases/modals/status.tmpl.html', - controller : 'PurchaseOrderStatusModalController', - controllerAs : '$ctrl', - size : 'md', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - /** search purchase order */ - function openSearchPurchaseOrder(request) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/purchases/modals/search.tmpl.html', - controller : 'SearchPurchaseOrderModalController', - controllerAs : '$ctrl', - size : 'md', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } - - function openSelectFiscalYear(request) { - var params = angular.extend(modalParameters, { - templateUrl : 'modules/general-ledger/modals/search.tmpl.html', - controller : 'SearchFiscalYearModalController', - controllerAs : '$ctrl', - size : 'md', - backdrop : 'static', - animation : false, - resolve : { - data : function dataProvider() { return request; } - } - }); - - var instance = Modal.open(params); - return instance.result; - } + function openReports(request) { + + const params = angular.extend(modalParameters, { + templateUrl : 'modules/templates/modals/reports.modal.html', + controller : 'ReportsModalController', + controllerAs : '$ctrl', + size : 'lg', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** + * Inventory Group Actions + */ + function openInventoryGroupActions(request) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/inventory/configuration/groups/modals/actions.tmpl.html', + controller : 'InventoryGroupsActionsModalController', + controllerAs : '$ctrl', + size : 'xs', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** Inventory Types Modal for actions */ + function openInventoryTypeActions(request) { + + const params = angular.extend(modalParameters, { + templateUrl : 'modules/inventory/configuration/types/modals/actions.tmpl.html', + controller : 'InventoryTypeActionsModalController', + controllerAs : '$ctrl', + size : 'xs', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** Inventory Units Modals for actions */ + function openInventoryUnitActions(data) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/inventory/configuration/units/modals/actions.tmpl.html', + controller : 'InventoryUnitActionsModalController', + controllerAs : '$ctrl', + resolve : { data : () => data }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** Inventory List Modals for actions */ + function openInventoryListActions(request) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/inventory/list/modals/actions.tmpl.html', + controller : 'InventoryListActionsModalController', + controllerAs : '$ctrl', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** Find by Date interval modal */ + function openDateInterval(request) { + + const params = angular.extend(modalParameters, { + templateUrl : 'modules/templates/modals/dateInterval.tmpl.html', + controller : 'DateIntervalModalController', + controllerAs : '$ctrl', + size : 'xs', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** + * confirm deletion modal + * @param {object} request + * The request parameter take : + * pattern: the text to match, + * elementName: the name translated of the element to delete (document, transaction) + * @example + * request = { + * pattern: '#HBB17', + * elementName: $translate.instant('FORM.LABELS.TRANSACTION') + * } + */ + function openConfirmDialog(request) { + + const params = angular.extend(modalParameters, { + templateUrl : 'modules/templates/modals/confirmDialog.modal.html', + controller : 'ConfirmDialogModalController', + controllerAs : '$ctrl', + size : 'xs', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** project modal actions */ + function openProjectActions(request) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/templates/modals/project.modal.html', + controller : 'ProjectModalController', + controllerAs : '$ctrl', + size : 'xs', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** transaction type modal actions */ + function openTransactionTypeActions(request) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/templates/modals/transactionType.modal.html', + controller : 'TransactionTypeModalController', + controllerAs : '$ctrl', + size : 'xs', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** closing fiscal year modal */ + function openClosingFiscalYear(request) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/fiscal/templates/modals/fiscal.closing.modal.html', + controller : 'ClosingFiscalYearModalController', + controllerAs : '$ctrl', + size : 'lg', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** searchCashPayment */ + function openSearchCashPayment(filters) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/cash/payments/templates/search.modal.html', + controller : 'SearchCashPaymentModalController', + controllerAs : '$ctrl', + resolve : { filters : () => filters }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** purchase order status */ + function openPurchaseOrderStatus(request) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/purchases/modals/status.tmpl.html', + controller : 'PurchaseOrderStatusModalController', + controllerAs : '$ctrl', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + /** search purchase order */ + function openSearchPurchaseOrder(request) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/purchases/modals/search.tmpl.html', + controller : 'SearchPurchaseOrderModalController', + controllerAs : '$ctrl', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } + + function openSelectFiscalYear(request) { + const params = angular.extend(modalParameters, { + templateUrl : 'modules/general-ledger/modals/search.tmpl.html', + controller : 'SearchFiscalYearModalController', + controllerAs : '$ctrl', + resolve : { data : () => request }, + }); + + const instance = Modal.open(params); + return instance.result; + } } diff --git a/client/src/modules/enterprises/enterprises.html b/client/src/modules/enterprises/enterprises.html index 8fe88b4a7e..21f0c67d23 100644 --- a/client/src/modules/enterprises/enterprises.html +++ b/client/src/modules/enterprises/enterprises.html @@ -50,7 +50,7 @@ - +
@@ -124,7 +124,7 @@ @@ -147,15 +147,20 @@ @@ -168,9 +173,24 @@ + +
+
+ ENTERPRISE.SETTINGS.TITLE +
+
+ + +
+
+
- + diff --git a/client/src/modules/enterprises/enterprises.js b/client/src/modules/enterprises/enterprises.js index 251a3d4d29..767011bdfa 100644 --- a/client/src/modules/enterprises/enterprises.js +++ b/client/src/modules/enterprises/enterprises.js @@ -2,52 +2,49 @@ angular.module('bhima.controllers') .controller('EnterpriseController', EnterpriseController); EnterpriseController.$inject = [ - 'EnterpriseService', 'CurrencyService', 'util', 'NotifyService', 'ProjectService', 'ModalService', - 'ScrollService', + 'EnterpriseService', 'util', 'NotifyService', 'ProjectService', 'ModalService', 'ScrollService', ]; /** - * Enterprise Controller + * @function EnterpriseController + * + * @description + * This controller binds the basic CRUD operations on the enterprise. */ -function EnterpriseController(Enterprises, Currencies, util, Notify, Projects, Modal, ScrollTo) { - var vm = this; +function EnterpriseController(Enterprises, util, Notify, Projects, Modal, ScrollTo) { + const vm = this; - vm.enterprises = []; vm.enterprise = {}; vm.maxLength = util.maxTextLength; vm.length50 = util.length50; vm.length100 = util.length100; vm.hasEnterprise = false; + let $touched = false; + // bind methods vm.submit = submit; vm.onSelectGainAccount = onSelectGainAccount; vm.onSelectLossAccount = onSelectLossAccount; + vm.enablePriceLockSetting = enablePriceLockSetting; // fired on startup function startup() { // load enterprises - Enterprises.read(null, { detailed: 1 }) - .then(function (enterprises) { + Enterprises.read(null, { detailed : 1 }) + .then(enterprises => { vm.hasEnterprise = (enterprises.length > 0); vm.enterprises = vm.hasEnterprise ? enterprises : []; /** - * @note: set the enterprise to the first one + * NOTE: set the enterprise to the first one * this choice need the team point of view for to setting the default enterprise */ vm.enterprise = vm.hasEnterprise ? vm.enterprises[0] : {}; return refreshProjects(); }) .catch(Notify.handleError); - - // load currencies - Currencies.read() - .then(function (currencies) { - vm.currencies = currencies; - }) - .catch(Notify.handleError); } function onSelectGainAccount(account) { @@ -66,25 +63,26 @@ function EnterpriseController(Enterprises, Currencies, util, Notify, Projects, M function submit(form) { if (form.$invalid) { Notify.danger('FORM.ERRORS.HAS_ERRORS'); - return; + return 0; } // make sure only fresh data is sent to the server. - if (form.$pristine) { + if (form.$pristine && !$touched) { Notify.warn('FORM.WARNINGS.NO_CHANGES'); - return; + return 0; } - var promise; - var creation = (vm.hasEnterprise === false); - var changes = util.filterFormElements(form, true); + const creation = (vm.hasEnterprise === false); + const changes = util.filterFormElements(form, true); - promise = (creation) ? + changes.settings = angular.copy(vm.enterprise.settings); + + const promise = (creation) ? Enterprises.create(changes) : Enterprises.update(vm.enterprise.id, changes); return promise - .then(function () { + .then(() => { Notify.success(creation ? 'FORM.INFO.SAVE_SUCCESS' : 'FORM.INFO.UPDATE_SUCCESS'); }) .catch(Notify.handleError); @@ -98,8 +96,8 @@ function EnterpriseController(Enterprises, Currencies, util, Notify, Projects, M // refresh the displayed projects function refreshProjects() { - return Projects.read(null, { complete: 1 }) - .then(function (projects) { + return Projects.read(null, { complete : 1 }) + .then(projects => { vm.projects = projects; }); } @@ -109,20 +107,20 @@ function EnterpriseController(Enterprises, Currencies, util, Notify, Projects, M * @desc launch project modal for editing */ function editProject(id) { - var params = { + const params = { action : 'edit', identifier : id, enterprise : vm.enterprise, }; Modal.openProjectActions(params) - .then(function (value) { - if (!value) { return; } + .then(value => { + if (!value) { return; } - refreshProjects(); - Notify.success('FORM.INFO.UPDATE_SUCCESS'); - }) - .catch(Notify.handleError); + refreshProjects(); + Notify.success('FORM.INFO.UPDATE_SUCCESS'); + }) + .catch(Notify.handleError); } /** @@ -134,13 +132,13 @@ function EnterpriseController(Enterprises, Currencies, util, Notify, Projects, M action : 'create', enterprise : vm.enterprise, }) - .then(function (value) { - if (!value) { return; } + .then(value => { + if (!value) { return; } - refreshProjects(); - Notify.success('FORM.INFO.CREATE_SUCCESS'); - }) - .catch(Notify.handleError); + refreshProjects(); + Notify.success('FORM.INFO.CREATE_SUCCESS'); + }) + .catch(Notify.handleError); } /** @@ -149,17 +147,17 @@ function EnterpriseController(Enterprises, Currencies, util, Notify, Projects, M * @param {number} id The project id */ function deleteProject(id, pattern) { - var params = { - pattern : pattern, + const params = { + pattern, patternName : 'FORM.PATTERNS.PROJECT_NAME', }; Modal.openConfirmDialog(params) - .then(function (bool) { + .then(bool => { if (!bool) { return; } Projects.delete(id) - .then(function () { + .then(() => { Notify.success('FORM.INFO.DELETE_SUCCESS'); return refreshProjects(); }) @@ -167,5 +165,10 @@ function EnterpriseController(Enterprises, Currencies, util, Notify, Projects, M }); } + function enablePriceLockSetting(enabled) { + vm.enterprise.settings.enable_price_lock = enabled; + $touched = true; + } + startup(); } diff --git a/client/src/modules/enterprises/projects.service.js b/client/src/modules/enterprises/projects.service.js index 7599ce2b9c..19faf34866 100644 --- a/client/src/modules/enterprises/projects.service.js +++ b/client/src/modules/enterprises/projects.service.js @@ -1,43 +1,16 @@ angular.module('bhima.services') -.service('ProjectService', ProjectService); + .service('ProjectService', ProjectService); -ProjectService.$inject = [ '$http', 'util' ]; +ProjectService.$inject = ['PrototypeApiService']; /** - * Project Service + * @function ProjectService * + * @description * This service implements basic CRUD functionality on the project table in the * backend database. - * - * @module services/ProjectService */ -function ProjectService($http, util) { - var service = this; - var baseUrl = '/projects/'; - - service.create = create; - service.read = read; - service.update = update; - service.delete = del; - - function create(project) { - return $http.post(baseUrl, project) - .then(util.unwrapHttpResponse); - } - - function read(id, params) { - var url = baseUrl.concat(id || ''); - return $http.get(url, { params : params }) - .then(util.unwrapHttpResponse); - } - - function update(id, project) { - return $http.put(baseUrl.concat(id), project) - .then(util.unwrapHttpResponse); - } - - function del(id) { - return $http.delete(baseUrl.concat(id)) - .then(util.unwrapHttpResponse); - } +function ProjectService(Api) { + const service = new Api('/projects/'); + return service; } diff --git a/client/src/modules/templates/bhYesNoRadios.tmpl.html b/client/src/modules/templates/bhYesNoRadios.tmpl.html index 427fd1d758..be8b4d834d 100644 --- a/client/src/modules/templates/bhYesNoRadios.tmpl.html +++ b/client/src/modules/templates/bhYesNoRadios.tmpl.html @@ -1,37 +1,36 @@ -
+ ng-class="{'has-error' : RadioForm.$error && RadioForm.$submitted }"> +
- {{$ctrl.helpText}} + {{$ctrl.helpText}}
-
\ No newline at end of file + diff --git a/client/src/modules/templates/modals/project.modal.html b/client/src/modules/templates/modals/project.modal.html index db2cfba918..9d747d2b46 100644 --- a/client/src/modules/templates/modals/project.modal.html +++ b/client/src/modules/templates/modals/project.modal.html @@ -4,15 +4,26 @@ novalidate>