diff --git a/src/requisition-order-create/order-create-form.jsx b/src/requisition-order-create/order-create-form.jsx index 07bef4e3..d8dfa48f 100644 --- a/src/requisition-order-create/order-create-form.jsx +++ b/src/requisition-order-create/order-create-form.jsx @@ -36,9 +36,9 @@ const OrderCreateForm = () => { const ADMINISTRATION_RIGHTS = useMemo(() => getService('ADMINISTRATION_RIGHTS'), []); const programService = useMemo(() => getService('programService'), []); + const { formatMessage } = useMemo(() => getService('messageService'), []); const facilityService = useMemo(() => getService('facilityService'), []); const orderService = useMemo(() => getService('orderCreateService'), []); - const { formatMessage } = useMemo(() => getService('messageService'), []); const columns = useMemo(() => orderCreateFormTableColumns(formatMessage), []); const userId = useMemo( @@ -100,7 +100,7 @@ const OrderCreateForm = () => { useEffect( () => { - facilityService.getUserFacilitiesForRight(userId, ADMINISTRATION_RIGHTS.ORDER_CREATE) + facilityService.getUserFacilitiesForRight(userId, ADMINISTRATION_RIGHTS.ORDER_CREATE, true) .then((facilities) => { setRequestingFacilityOptions(_.map(facilities, facility => ({ name: facility.name, value: facility.id }))); }); @@ -140,36 +140,54 @@ const OrderCreateForm = () => { return (
-

{ formatMessage('requisition.orderCreate.create') }

+

{formatMessage('requisition.orderCreate.create')}

-
{ formatMessage('requisition.orderCreate.program') }
+
+ + {formatMessage('requisition.orderCreate.program')} + +
setSelectedProgram(value)} - placeholder={ formatMessage('requisition.orderCreate.program.placeholder')} + placeholder={formatMessage('requisition.orderCreate.program.placeholder')} />
-
{ formatMessage('requisition.orderCreate.reqFacility') }
+
+ + {formatMessage('requisition.orderCreate.reqFacility')} + +
setSelectedRequestingFacilities(prevState => [...prevState, value])} - placeholder={ formatMessage('requisition.orderCreate.reqFacility.placeholder')} + onChange={(value) => { + setSelectedRequestingFacilities((prevState) => { + if (!prevState.includes(value) && value) { + return [...prevState, value]; + } + return prevState; + }); + }} + placeholder={formatMessage('requisition.orderCreate.reqFacility.placeholder')} />
-
{ formatMessage('requisition.orderCreate.supFacility') }
+
+ + {formatMessage('requisition.orderCreate.supFacility')} + +
{ disabled={!selectedProgram || !selectedRequestingFacilities || !selectedSupplyingFacility} onClick={createOrders} > - { formatMessage('requisition.orderCreate.create') } + {formatMessage('requisition.orderCreate.create')}
diff --git a/src/requisition-order-create/order-create.service.js b/src/requisition-order-create/order-create.service.js index 77f510e5..774413e9 100644 --- a/src/requisition-order-create/order-create.service.js +++ b/src/requisition-order-create/order-create.service.js @@ -28,9 +28,9 @@ .module('requisition-order-create') .service('orderCreateService', service); - service.$inject = ['$resource', 'openlmisUrlFactory']; + service.$inject = ['$resource', '$http', 'openlmisUrlFactory']; - function service($resource, openlmisUrlFactory) { + function service($resource, $http, openlmisUrlFactory) { var resource = $resource(openlmisUrlFactory('/api/orders/:id'), {}, { update: { @@ -50,6 +50,7 @@ this.create = create; this.update = update; this.send = send; + this.delete = deleteOrders; function get(orderId) { return resource.get({ @@ -72,5 +73,18 @@ id: order.id }, order).$promise; } + + function deleteOrders(orderIds) { + return $http({ + method: 'DELETE', + url: openlmisUrlFactory('/api/orders'), + data: { + ids: orderIds + }, + headers: { + 'Content-Type': 'application/json;charset=utf-8' + } + }); + } } })();