Skip to content

Commit

Permalink
Merge pull request #32 from OpenLMIS/OLMIS-7838
Browse files Browse the repository at this point in the history
OLMIS-7838: Move functionalities done in tanzania to core
  • Loading branch information
dszafranek authored Feb 7, 2024
2 parents 0888d90 + 6ee7357 commit 8294139
Show file tree
Hide file tree
Showing 97 changed files with 6,942 additions and 18 deletions.
68 changes: 68 additions & 0 deletions src/admin-buq/Routing.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

import React, { useEffect, useState } from 'react';
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
import Breadcrumbs from '../react-components/Breadcrumbs';
import useServerService from '../react-hooks/useServerService';
import AdminBuqPage from './components/AdminBuqPage/AdminBuqPage';

const Routing = ({
loadingModalService
}) => {
const [remarks, setRemarks] = useState([]);
const [sourcesOfFunds, setSourcesOfFunds] = useState([]);
const serverService = useServerService('adminBuq');

const fetchRemarks = () => {
loadingModalService.open();
serverService.getRemarks()
.then((fetchedRemarks) => {
setRemarks(fetchedRemarks);
}).finally(() => loadingModalService.close());
};

const fetchSourcesOfFunds = () => {
loadingModalService.open();
serverService.getSourcesOfFunds()
.then((fetchedSourcesOfFunds) => {
setSourcesOfFunds(fetchedSourcesOfFunds.content);
}).finally(() => loadingModalService.close());
};

useEffect(() => {
fetchRemarks()
fetchSourcesOfFunds();
}, []);

return !!remarks.length && !!sourcesOfFunds.length ? (
<div className='page-responsive'>
<Router basename='/' hashType='hashbang'>
<Breadcrumbs routes={[{ path: '/administration/manage-buq', breadcrumb: 'Manage BUQ' }]} />
<Switch>

<Route exact path='/administration/manage-buq'>
<AdminBuqPage
remarks={remarks}
sourcesOfFunds={sourcesOfFunds}
loadingModalService={loadingModalService}
/>
</Route>
</Switch>
</Router>
</div>) : null;
};

export default Routing;
1 change: 1 addition & 0 deletions src/admin-buq/admin-buq.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<admin-buq></admin-buq>
23 changes: 23 additions & 0 deletions src/admin-buq/admin-buq.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

(function() {
'use strict';

angular.module('admin-buq', [
'react-components'
]);

})();
40 changes: 40 additions & 0 deletions src/admin-buq/admin-buq.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

(function() {
'use strict';

angular
.module('admin-buq')
.config(routes);

routes.$inject = ['$stateProvider', 'ADMINISTRATION_RIGHTS'];

function routes($stateProvider, ADMINISTRATION_RIGHTS) {
$stateProvider.state('openlmis.administration.buq', {
url: '/manage-buq',
label: 'admin.buq.label',
isOffline: false,
priority: 11,
showInNavigation: true,
accessRights: [ADMINISTRATION_RIGHTS.MANAGE_BUQ],
views: {
'@': {
templateUrl: 'admin-buq/admin-buq.html'
}
}
});
}
})();
120 changes: 120 additions & 0 deletions src/admin-buq/admin-buq.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

(function() {

'use strict';

/**
* @ngdoc service
* @name admin-buq.adminBuq
*
* @description
* Communicates with the /api/serverConfiguration endpoint of the OpenLMIS server.
*/
angular
.module('admin-buq')
.service('adminBuq', service);

service.$inject = ['$resource', 'openlmisUrlFactory'];

function service($resource, openlmisUrlFactory) {

var resource = $resource(openlmisUrlFactory('/api'), {}, {
getRemarks: {
url: openlmisUrlFactory('/api/remark'),
method: 'GET',
isArray: true
},
addRemark: {
url: openlmisUrlFactory('/api/remark'),
method: 'Post'
},
updateRemark: {
url: openlmisUrlFactory('/api/remark/:id'),
method: 'PUT'
},
removeRemark: {
url: openlmisUrlFactory('/api/remark/:id'),
method: 'DELETE'
},
getSourcesOfFunds: {
url: openlmisUrlFactory('/api/sourcesOfFunds'),
method: 'GET'
},
addSourcesOfFunds: {
url: openlmisUrlFactory('/api/sourcesOfFunds'),
method: 'POST'
},
removeSourceOfFund: {
url: openlmisUrlFactory('/api/sourcesOfFunds/:id'),
method: 'DELETE'
},
updateSourceOfFund: {
url: openlmisUrlFactory('/api/sourcesOfFunds/:id'),
method: 'PUT'
}
});

this.getRemarks = getRemarks;
this.addRemark = addRemark;
this.updateRemark = updateRemark;
this.removeRemark = removeRemark;

this.getSourcesOfFunds = getSourcesOfFunds;
this.addSourcesOfFunds = addSourcesOfFunds;
this.removeSourceOfFund = removeSourceOfFund;
this.updateSourceOfFund = updateSourceOfFund;

function getRemarks() {
return resource.getRemarks().$promise;
}
function addRemark(remark) {
return resource.addRemark(remark).$promise;
}

function updateRemark(remark) {
return resource.updateRemark({
id: remark.id
}, remark).$promise;
}

function removeRemark(remark) {
return resource.removeRemark({
id: remark.id
}).$promise;
}

function getSourcesOfFunds() {
return resource.getSourcesOfFunds().$promise;
}

function addSourcesOfFunds(sourcesOfFunds) {
return resource.addSourcesOfFunds(sourcesOfFunds).$promise;
}

function removeSourceOfFund(sourceOfFund) {
return resource.removeSourceOfFund({
id: sourceOfFund.id
}).$promise;
}

function updateSourceOfFund(sourceOfFund) {
return resource.updateSourceOfFund({
id: sourceOfFund.id
}, sourceOfFund).$promise;
}
}
})();
51 changes: 51 additions & 0 deletions src/admin-buq/admin-buq.wrapper.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

import React from 'react';
import ReactDOM from 'react-dom';
import Routing from './Routing';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import 'tippy.js/dist/tippy.css';

(function () {
'use strict';

angular
.module('admin-buq')
.directive('adminBuq', adminBuq);

adminBuq.$inject = ['loadingModalService'];

function adminBuq(loadingModalService) {
return {
template: '<div id="adminBuq" class="admin-buq"></div>',
replace: true,
link: function () {
const app = document.getElementById('adminBuq');

ReactDOM.render(
<>
<Routing
loadingModalService={loadingModalService}
/>
<ToastContainer theme='colored'/>
</>,
app
);
}
};
}
})();
35 changes: 35 additions & 0 deletions src/admin-buq/components/AdminBuqForm/AdminBuqDeleteForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';

const AdminBuqDeleteForm = ({ submitDelete, confirmMessage, onCancel }) => (
<div className='page-container'>
<div className='page-content element-create-form'>
<div className='section'>
{confirmMessage}
</div>
</div>
<div className='bottom-bar'>
<div>
<button
type='button'
className='secondary'
onClick={() => {
onCancel();
}}
>
<span>Cancel</span>
</button>
</div>
<div>
<button
className='danger'
type='button'
onClick={() => submitDelete()}
>
Delete
</button>
</div>
</div>
</div>
);

export default AdminBuqDeleteForm;
Loading

0 comments on commit 8294139

Please sign in to comment.