@openmrs/esm-stock-management-app 1.0.1-pre.352 → 1.0.1-pre.359
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/304.js +2 -0
- package/dist/304.js.map +1 -0
- package/dist/969.js +1 -0
- package/dist/969.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js +1 -1
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +41 -41
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/stock-items/types.ts +79 -0
- package/src/stock-locations/add-locations-form.component.tsx +74 -0
- package/src/stock-locations/location-admin-form.component.tsx +164 -0
- package/src/stock-locations/stock-locations-table.component.tsx +33 -10
- package/src/stock-locations/stock-locations-table.resource.tsx +67 -12
- package/src/stock-locations/stock-locations-table.scss +3 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +10 -5
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +28 -10
- package/dist/500.js +0 -2
- package/dist/500.js.map +0 -1
- package/dist/842.js +0 -1
- package/dist/842.js.map +0 -1
- /package/dist/{500.js.LICENSE.txt → 304.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
|
|
1
|
-
var _openmrs_esm_stock_management_app;(()=>{"use strict";var e,r,t,n,o,a,i,l,s,u,f,p,c,d,h,m,v,g={1371:(e,r,t)=>{var n={"./start":()=>Promise.all([t.e(935),t.e(
|
1
|
+
var _openmrs_esm_stock_management_app;(()=>{"use strict";var e,r,t,n,o,a,i,l,s,u,f,p,c,d,h,m,v,g={1371:(e,r,t)=>{var n={"./start":()=>Promise.all([t.e(935),t.e(304),t.e(672),t.e(969)]).then((()=>()=>t(2313)))},o=(e,r)=>(t.R=r,r=t.o(n,e)?n[e]():Promise.resolve().then((()=>{throw new Error('Module "'+e+'" does not exist in container.')})),t.R=void 0,r),a=(e,r)=>{if(t.S){var n="default",o=t.S[n];if(o&&o!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return t.S[n]=e,t.I(n,r)}};t.d(r,{get:()=>o,init:()=>a})}},b={};function y(e){var r=b[e];if(void 0!==r)return r.exports;var t=b[e]={id:e,loaded:!1,exports:{}};return g[e].call(t.exports,t,t.exports,y),t.loaded=!0,t.exports}y.m=g,y.c=b,y.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return y.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,y.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var o=Object.create(null);y.r(o);var a={};e=e||[null,r({}),r([]),r(r)];for(var i=2&n&&t;"object"==typeof i&&!~e.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,y.d(o,a),o},y.d=(e,r)=>{for(var t in r)y.o(r,t)&&!y.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},y.f={},y.e=e=>Promise.all(Object.keys(y.f).reduce(((r,t)=>(y.f[t](e,r),r)),[])),y.u=e=>e+".js",y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@openmrs/esm-stock-management-app:",y.l=(e,r,o,a)=>{if(t[e])t[e].push(r);else{var i,l;if(void 0!==o)for(var s=document.getElementsByTagName("script"),u=0;u<s.length;u++){var f=s[u];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+o){i=f;break}}i||(l=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,y.nc&&i.setAttribute("nonce",y.nc),i.setAttribute("data-webpack",n+o),i.src=e),t[e]=[r];var p=(r,n)=>{i.onerror=i.onload=null,clearTimeout(c);var o=t[e];if(delete t[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach((e=>e(n))),r)return r(n)},c=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),l&&document.head.appendChild(i)}},y.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{y.S={};var e={},r={};y.I=(t,n)=>{n||(n=[]);var o=r[t];if(o||(o=r[t]={}),!(n.indexOf(o)>=0)){if(n.push(o),e[t])return e[t];y.o(y.S,t)||(y.S[t]={});var a=y.S[t],i="@openmrs/esm-stock-management-app",l=(e,r,t,n)=>{var o=a[e]=a[e]||{},l=o[r];(!l||!l.loaded&&(!n!=!l.eager?n:i>l.from))&&(o[r]={get:t,from:i,eager:!!n})},s=[];return"default"===t&&(l("@openmrs/esm-framework","5.4.1-pre.1561",(()=>Promise.all([y.e(800),y.e(672)]).then((()=>()=>y(4800))))),l("dayjs","1.11.10",(()=>y.e(484).then((()=>()=>y(7484))))),l("react-i18next","11.18.6",(()=>Promise.all([y.e(672),y.e(629)]).then((()=>()=>y(707))))),l("react-router-dom","6.21.1",(()=>Promise.all([y.e(26),y.e(935),y.e(672)]).then((()=>()=>y(8026))))),l("react","18.2.0",(()=>y.e(294).then((()=>()=>y(7294))))),l("swr/_internal","2.2.5",(()=>Promise.all([y.e(46),y.e(672)]).then((()=>()=>y(46)))))),e[t]=s.length?Promise.all(s).then((()=>e[t]=1)):1}}})(),(()=>{var e;y.g.importScripts&&(e=y.g.location+"");var r=y.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&!e;)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),y.p=e})(),o=e=>{var r=e=>e.split(".").map((e=>+e==e?+e:e)),t=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),n=t[1]?r(t[1]):[];return t[2]&&(n.length++,n.push.apply(n,r(t[2]))),t[3]&&(n.push([]),n.push.apply(n,r(t[3]))),n},a=(e,r)=>{e=o(e),r=o(r);for(var t=0;;){if(t>=e.length)return t<r.length&&"u"!=(typeof r[t])[0];var n=e[t],a=(typeof n)[0];if(t>=r.length)return"u"==a;var i=r[t],l=(typeof i)[0];if(a!=l)return"o"==a&&"n"==l||"s"==l||"u"==a;if("o"!=a&&"u"!=a&&n!=i)return n<i;t++}},i=e=>{var r=e[0],t="";if(1===e.length)return"*";if(r+.5){t+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var n=1,o=1;o<e.length;o++)n--,t+="u"==(typeof(l=e[o]))[0]?"-":(n>0?".":"")+(n=2,l);return t}var a=[];for(o=1;o<e.length;o++){var l=e[o];a.push(0===l?"not("+s()+")":1===l?"("+s()+" || "+s()+")":2===l?a.pop()+" "+a.pop():i(l))}return s();function s(){return a.pop().replace(/^\((.+)\)$/,"$1")}},l=(e,r)=>{if(0 in e){r=o(r);var t=e[0],n=t<0;n&&(t=-t-1);for(var a=0,i=1,s=!0;;i++,a++){var u,f,p=i<e.length?(typeof e[i])[0]:"";if(a>=r.length||"o"==(f=(typeof(u=r[a]))[0]))return!s||("u"==p?i>t&&!n:""==p!=n);if("u"==f){if(!s||"u"!=p)return!1}else if(s)if(p==f)if(i<=t){if(u!=e[i])return!1}else{if(n?u>e[i]:u<e[i])return!1;u!=e[i]&&(s=!1)}else if("s"!=p&&"n"!=p){if(n||i<=t)return!1;s=!1,i--}else{if(i<=t||f<p!=n)return!1;s=!1}else"s"!=p&&"n"!=p&&(s=!1,i--)}}var c=[],d=c.pop.bind(c);for(a=1;a<e.length;a++){var h=e[a];c.push(1==h?d()|d():2==h?d()&d():h?l(h,r):!d())}return!!d()},s=(e,r)=>{var t=e[r];return Object.keys(t).reduce(((e,r)=>!e||!t[e].loaded&&a(e,r)?r:e),0)},u=(e,r,t,n)=>"Unsatisfied version "+t+" from "+(t&&e[r][t].from)+" of shared singleton module "+r+" (required "+i(n)+")",f=(e,r,t,n)=>{var o=s(e,t);return l(n,o)||p(u(e,t,o,n)),c(e[t][o])},p=e=>{"undefined"!=typeof console&&console.warn&&console.warn(e)},c=e=>(e.loaded=1,e.get()),d=(e=>function(r,t,n,o){var a=y.I(r);return a&&a.then?a.then(e.bind(e,r,y.S[r],t,n,o)):e(0,y.S[r],t,n,o)})(((e,r,t,n,o)=>r&&y.o(r,t)?f(r,0,t,n):o())),h={},m={1672:()=>d("default","react",[1,18],(()=>y.e(294).then((()=>()=>y(7294))))),1914:()=>d("default","react-router-dom",[1,6],(()=>y.e(26).then((()=>()=>y(8026))))),2653:()=>d("default","dayjs",[1,1],(()=>y.e(484).then((()=>()=>y(7484))))),3397:()=>d("default","react-i18next",[1,11],(()=>y.e(707).then((()=>()=>y(707))))),5512:()=>d("default","swr/_internal",[1,2],(()=>y.e(46).then((()=>()=>y(46))))),7248:()=>d("default","@openmrs/esm-framework",[1,5],(()=>y.e(800).then((()=>()=>y(4800)))))},v={672:[1672],969:[1914,2653,3397,5512,7248]},y.f.consumes=(e,r)=>{y.o(v,e)&&v[e].forEach((e=>{if(y.o(h,e))return r.push(h[e]);var t=r=>{h[e]=0,y.m[e]=t=>{delete y.c[e],t.exports=r()}},n=r=>{delete h[e],y.m[e]=t=>{throw delete y.c[e],r}};try{var o=m[e]();o.then?r.push(h[e]=o.then(t).catch(n)):t(o)}catch(e){n(e)}}))},(()=>{var e={122:0};y.f.j=(r,t)=>{var n=y.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(672!=r){var o=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=o);var a=y.p+y.u(r),i=new Error;y.l(a,(t=>{if(y.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var o=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;i.message="Loading chunk "+r+" failed.\n("+o+": "+a+")",i.name="ChunkLoadError",i.type=o,i.request=a,n[1](i)}}),"chunk-"+r,r)}else e[r]=0};var r=(r,t)=>{var n,o,[a,i,l]=t,s=0;if(a.some((r=>0!==e[r]))){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);l&&l(y)}for(r&&r(t);s<a.length;s++)o=a[s],y.o(e,o)&&e[o]&&e[o][0](),e[o]=0},t=globalThis.webpackChunk_openmrs_esm_stock_management_app=globalThis.webpackChunk_openmrs_esm_stock_management_app||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),y.nc=void 0;var _=y(1371);_openmrs_esm_stock_management_app=_})();
|
@@ -78,7 +78,7 @@
|
|
78
78
|
"auxiliaryFiles": [
|
79
79
|
"openmrs-esm-stock-management-app.js.map"
|
80
80
|
],
|
81
|
-
"hash": "
|
81
|
+
"hash": "2b9571af3f64de96",
|
82
82
|
"childrenByOrder": {}
|
83
83
|
},
|
84
84
|
{
|
@@ -86,10 +86,10 @@
|
|
86
86
|
"initial": true,
|
87
87
|
"entry": true,
|
88
88
|
"recorded": false,
|
89
|
-
"size":
|
89
|
+
"size": 4733569,
|
90
90
|
"sizes": {
|
91
91
|
"consume-shared": 252,
|
92
|
-
"javascript":
|
92
|
+
"javascript": 4711620,
|
93
93
|
"share-init": 252,
|
94
94
|
"runtime": 21445
|
95
95
|
},
|
@@ -106,7 +106,7 @@
|
|
106
106
|
"auxiliaryFiles": [
|
107
107
|
"main.js.map"
|
108
108
|
],
|
109
|
-
"hash": "
|
109
|
+
"hash": "757fd54a4b6b8756",
|
110
110
|
"childrenByOrder": {}
|
111
111
|
},
|
112
112
|
{
|
@@ -138,23 +138,25 @@
|
|
138
138
|
"initial": false,
|
139
139
|
"entry": false,
|
140
140
|
"recorded": false,
|
141
|
-
"
|
141
|
+
"reason": "split chunk (cache group: defaultVendors)",
|
142
|
+
"size": 3598866,
|
142
143
|
"sizes": {
|
143
|
-
"javascript":
|
144
|
+
"javascript": 3598866
|
144
145
|
},
|
145
146
|
"names": [],
|
146
|
-
"idHints": [
|
147
|
+
"idHints": [
|
148
|
+
"vendors"
|
149
|
+
],
|
147
150
|
"runtime": [
|
148
|
-
"@openmrs/esm-stock-management-app"
|
149
|
-
"main"
|
151
|
+
"@openmrs/esm-stock-management-app"
|
150
152
|
],
|
151
153
|
"files": [
|
152
|
-
"
|
154
|
+
"304.js"
|
153
155
|
],
|
154
156
|
"auxiliaryFiles": [
|
155
|
-
"
|
157
|
+
"304.js.map"
|
156
158
|
],
|
157
|
-
"hash": "
|
159
|
+
"hash": "8bcf539de0b31b14",
|
158
160
|
"childrenByOrder": {}
|
159
161
|
},
|
160
162
|
{
|
@@ -162,25 +164,23 @@
|
|
162
164
|
"initial": false,
|
163
165
|
"entry": false,
|
164
166
|
"recorded": false,
|
165
|
-
"
|
166
|
-
"size": 3552100,
|
167
|
+
"size": 7160,
|
167
168
|
"sizes": {
|
168
|
-
"javascript":
|
169
|
+
"javascript": 7160
|
169
170
|
},
|
170
171
|
"names": [],
|
171
|
-
"idHints": [
|
172
|
-
"vendors"
|
173
|
-
],
|
172
|
+
"idHints": [],
|
174
173
|
"runtime": [
|
175
|
-
"@openmrs/esm-stock-management-app"
|
174
|
+
"@openmrs/esm-stock-management-app",
|
175
|
+
"main"
|
176
176
|
],
|
177
177
|
"files": [
|
178
|
-
"
|
178
|
+
"484.js"
|
179
179
|
],
|
180
180
|
"auxiliaryFiles": [
|
181
|
-
"
|
181
|
+
"484.js.map"
|
182
182
|
],
|
183
|
-
"hash": "
|
183
|
+
"hash": "0eb218fc21d670bb",
|
184
184
|
"childrenByOrder": {}
|
185
185
|
},
|
186
186
|
{
|
@@ -306,23 +306,26 @@
|
|
306
306
|
"initial": false,
|
307
307
|
"entry": false,
|
308
308
|
"recorded": false,
|
309
|
-
"
|
309
|
+
"reason": "split chunk (cache group: defaultVendors)",
|
310
|
+
"size": 137533,
|
310
311
|
"sizes": {
|
311
|
-
"javascript":
|
312
|
-
"consume-shared": 210
|
312
|
+
"javascript": 137533
|
313
313
|
},
|
314
314
|
"names": [],
|
315
|
-
"idHints": [
|
315
|
+
"idHints": [
|
316
|
+
"vendors"
|
317
|
+
],
|
316
318
|
"runtime": [
|
317
|
-
"@openmrs/esm-stock-management-app"
|
319
|
+
"@openmrs/esm-stock-management-app",
|
320
|
+
"main"
|
318
321
|
],
|
319
322
|
"files": [
|
320
|
-
"
|
323
|
+
"935.js"
|
321
324
|
],
|
322
325
|
"auxiliaryFiles": [
|
323
|
-
"
|
326
|
+
"935.js.map"
|
324
327
|
],
|
325
|
-
"hash": "
|
328
|
+
"hash": "ec5f549cbfd789c7",
|
326
329
|
"childrenByOrder": {}
|
327
330
|
},
|
328
331
|
{
|
@@ -330,26 +333,23 @@
|
|
330
333
|
"initial": false,
|
331
334
|
"entry": false,
|
332
335
|
"recorded": false,
|
333
|
-
"
|
334
|
-
"size": 137533,
|
336
|
+
"size": 975431,
|
335
337
|
"sizes": {
|
336
|
-
"javascript":
|
338
|
+
"javascript": 975221,
|
339
|
+
"consume-shared": 210
|
337
340
|
},
|
338
341
|
"names": [],
|
339
|
-
"idHints": [
|
340
|
-
"vendors"
|
341
|
-
],
|
342
|
+
"idHints": [],
|
342
343
|
"runtime": [
|
343
|
-
"@openmrs/esm-stock-management-app"
|
344
|
-
"main"
|
344
|
+
"@openmrs/esm-stock-management-app"
|
345
345
|
],
|
346
346
|
"files": [
|
347
|
-
"
|
347
|
+
"969.js"
|
348
348
|
],
|
349
349
|
"auxiliaryFiles": [
|
350
|
-
"
|
350
|
+
"969.js.map"
|
351
351
|
],
|
352
|
-
"hash": "
|
352
|
+
"hash": "795b76659474cf05",
|
353
353
|
"childrenByOrder": {}
|
354
354
|
}
|
355
355
|
]
|
package/dist/routes.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.359"}
|
package/package.json
CHANGED
package/src/stock-items/types.ts
CHANGED
@@ -1,8 +1,87 @@
|
|
1
1
|
import { StockItemDTO } from "../core/api/types/stockItem/StockItem";
|
2
2
|
import { StockOperationDTO } from "../core/api/types/stockOperation/StockOperationDTO";
|
3
|
+
import { KeyedMutator } from "swr";
|
3
4
|
|
4
5
|
export type SaveStockItem = (item: StockItemDTO) => Promise<void>;
|
5
6
|
export type SaveStockOperation = (item: StockOperationDTO) => Promise<void>;
|
6
7
|
export type SaveStockOperationAction = (
|
7
8
|
item: StockOperationDTO
|
8
9
|
) => Promise<void>;
|
10
|
+
|
11
|
+
export type LocationMutator = KeyedMutator<{
|
12
|
+
data: {
|
13
|
+
results: Array<Location>;
|
14
|
+
};
|
15
|
+
}>;
|
16
|
+
|
17
|
+
export type Location = {
|
18
|
+
uuid: string;
|
19
|
+
display: string;
|
20
|
+
name: string;
|
21
|
+
description: string | null;
|
22
|
+
address1: string | null;
|
23
|
+
address2: string | null;
|
24
|
+
cityVillage: string | null;
|
25
|
+
stateProvince: string | null;
|
26
|
+
country: string | null;
|
27
|
+
postalCode: string | null;
|
28
|
+
latitude: string | null;
|
29
|
+
longitude: string | null;
|
30
|
+
countyDistrict: string | null;
|
31
|
+
address3: string | null;
|
32
|
+
address4: string | null;
|
33
|
+
address5: string | null;
|
34
|
+
address6: string | null;
|
35
|
+
tags: Tag[];
|
36
|
+
parentLocation: Location;
|
37
|
+
childLocations: Location[];
|
38
|
+
retired: boolean;
|
39
|
+
auditInfo: {
|
40
|
+
creator: {
|
41
|
+
uuid: string;
|
42
|
+
display: string;
|
43
|
+
links: Array<{
|
44
|
+
rel: string;
|
45
|
+
uri: string;
|
46
|
+
resourceAlias: string;
|
47
|
+
}>;
|
48
|
+
};
|
49
|
+
dateCreated: string;
|
50
|
+
changedBy: null;
|
51
|
+
dateChanged: null;
|
52
|
+
};
|
53
|
+
address7: string | null;
|
54
|
+
address8: string | null;
|
55
|
+
address9: string | null;
|
56
|
+
address10: string | null;
|
57
|
+
address11: string | null;
|
58
|
+
address12: string | null;
|
59
|
+
address13: string | null;
|
60
|
+
address14: string | null;
|
61
|
+
address15: string | null;
|
62
|
+
links: Array<{
|
63
|
+
rel: string;
|
64
|
+
uri: string;
|
65
|
+
resourceAlias: string;
|
66
|
+
}>;
|
67
|
+
resourceVersion: string;
|
68
|
+
};
|
69
|
+
|
70
|
+
export type Tag = {
|
71
|
+
uuid: string;
|
72
|
+
display: string;
|
73
|
+
name: string;
|
74
|
+
description?: string;
|
75
|
+
retired: boolean;
|
76
|
+
links: Array<{
|
77
|
+
rel: string;
|
78
|
+
uri: string;
|
79
|
+
resourceAlias: string;
|
80
|
+
}>;
|
81
|
+
resourceVersion: string;
|
82
|
+
};
|
83
|
+
export interface locationData {
|
84
|
+
uuid?: string;
|
85
|
+
name: string;
|
86
|
+
tags: [];
|
87
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import React, { useCallback } from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { showToast, showNotification, useConfig } from "@openmrs/esm-framework";
|
4
|
+
import { saveLocation } from "./stock-locations-table.resource";
|
5
|
+
import { locationData, LocationMutator } from "../stock-items/types";
|
6
|
+
import LocationAdministrationForm from "./location-admin-form.component";
|
7
|
+
|
8
|
+
interface LocationFormProps {
|
9
|
+
showModal: boolean;
|
10
|
+
onModalChange: (showModal: boolean) => void;
|
11
|
+
mutate: LocationMutator;
|
12
|
+
}
|
13
|
+
|
14
|
+
const NewLocationForm: React.FC<LocationFormProps> = ({
|
15
|
+
showModal,
|
16
|
+
onModalChange,
|
17
|
+
mutate,
|
18
|
+
}) => {
|
19
|
+
const { t } = useTranslation();
|
20
|
+
const headerTitle = t("addLocation", "Create new Location");
|
21
|
+
|
22
|
+
const initialData: locationData = {
|
23
|
+
uuid: "",
|
24
|
+
name: "",
|
25
|
+
tags: [],
|
26
|
+
};
|
27
|
+
|
28
|
+
const handleCreateQuestion = useCallback(
|
29
|
+
(formData: locationData) => {
|
30
|
+
const { name, tags } = formData;
|
31
|
+
|
32
|
+
const locationbject = {
|
33
|
+
name,
|
34
|
+
tags,
|
35
|
+
};
|
36
|
+
saveLocation({ locationPayload: locationbject })
|
37
|
+
.then(() => {
|
38
|
+
showToast({
|
39
|
+
title: t("formCreated", "Add Location"),
|
40
|
+
kind: "success",
|
41
|
+
critical: true,
|
42
|
+
description: t(`Location ${name} was created successfully.`),
|
43
|
+
});
|
44
|
+
|
45
|
+
mutate();
|
46
|
+
onModalChange(false);
|
47
|
+
})
|
48
|
+
.catch((error) => {
|
49
|
+
showNotification({
|
50
|
+
title: t("errorCreatingForm", "Error creating location"),
|
51
|
+
kind: "error",
|
52
|
+
critical: true,
|
53
|
+
description: error?.message,
|
54
|
+
});
|
55
|
+
onModalChange(false);
|
56
|
+
});
|
57
|
+
onModalChange(false);
|
58
|
+
},
|
59
|
+
[onModalChange, mutate, t]
|
60
|
+
);
|
61
|
+
|
62
|
+
return (
|
63
|
+
<>
|
64
|
+
<LocationAdministrationForm
|
65
|
+
onModalChange={onModalChange}
|
66
|
+
showModal={showModal}
|
67
|
+
handleCreateQuestion={handleCreateQuestion}
|
68
|
+
headerTitle={headerTitle}
|
69
|
+
initialData={initialData}
|
70
|
+
/>
|
71
|
+
</>
|
72
|
+
);
|
73
|
+
};
|
74
|
+
export default NewLocationForm;
|
@@ -0,0 +1,164 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { z } from "zod";
|
3
|
+
import { useForm, Controller } from "react-hook-form";
|
4
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
5
|
+
import {
|
6
|
+
Button,
|
7
|
+
ComposedModal,
|
8
|
+
FormGroup,
|
9
|
+
ModalBody,
|
10
|
+
ModalFooter,
|
11
|
+
ModalHeader,
|
12
|
+
Stack,
|
13
|
+
TextInput,
|
14
|
+
InlineNotification,
|
15
|
+
FilterableMultiSelect,
|
16
|
+
InlineLoading,
|
17
|
+
} from "@carbon/react";
|
18
|
+
import { useTranslation } from "react-i18next";
|
19
|
+
import { locationData } from "../stock-items/types";
|
20
|
+
import styles from "./stock-locations-table.scss";
|
21
|
+
import { useLocationTags } from "./stock-locations-table.resource";
|
22
|
+
|
23
|
+
const LocationAdministrationSchema = z.object({
|
24
|
+
name: z.string().max(255),
|
25
|
+
});
|
26
|
+
|
27
|
+
interface LocationAdministrationFormProps {
|
28
|
+
showModal: boolean;
|
29
|
+
onModalChange: (showModal: boolean) => void;
|
30
|
+
handleCreateQuestion?: (formData: locationData) => void;
|
31
|
+
handleDeleteBedTag?: () => void;
|
32
|
+
headerTitle: string;
|
33
|
+
initialData: locationData;
|
34
|
+
}
|
35
|
+
|
36
|
+
interface ErrorType {
|
37
|
+
message: string;
|
38
|
+
}
|
39
|
+
|
40
|
+
const LocationAdministrationForm: React.FC<LocationAdministrationFormProps> = ({
|
41
|
+
showModal,
|
42
|
+
onModalChange,
|
43
|
+
handleCreateQuestion,
|
44
|
+
headerTitle,
|
45
|
+
initialData,
|
46
|
+
}) => {
|
47
|
+
const { t } = useTranslation();
|
48
|
+
|
49
|
+
const [showErrorNotification, setShowErrorNotification] = useState(false);
|
50
|
+
const [formStateError, setFormStateError] = useState("");
|
51
|
+
|
52
|
+
// Location tag types
|
53
|
+
const { locationTagList: Tags, loading: loadingRoles } = useLocationTags();
|
54
|
+
|
55
|
+
const {
|
56
|
+
handleSubmit,
|
57
|
+
control,
|
58
|
+
getValues,
|
59
|
+
formState: { isDirty },
|
60
|
+
} = useForm<locationData>({
|
61
|
+
mode: "all",
|
62
|
+
resolver: zodResolver(LocationAdministrationSchema),
|
63
|
+
defaultValues: {
|
64
|
+
name: initialData.name || "",
|
65
|
+
tags: initialData.tags || [],
|
66
|
+
},
|
67
|
+
});
|
68
|
+
|
69
|
+
const onSubmit = (formData: locationData) => {
|
70
|
+
const formDataFormSubmission = getValues();
|
71
|
+
const locationTagsUuid =
|
72
|
+
formDataFormSubmission?.tags?.["selectedItems"]?.map((tag) => tag.uuid) ??
|
73
|
+
[];
|
74
|
+
|
75
|
+
const payload = {
|
76
|
+
name: formDataFormSubmission.name,
|
77
|
+
tags: locationTagsUuid,
|
78
|
+
};
|
79
|
+
const result = LocationAdministrationSchema.safeParse(formData);
|
80
|
+
if (result.success) {
|
81
|
+
setShowErrorNotification(false);
|
82
|
+
handleCreateQuestion(payload);
|
83
|
+
}
|
84
|
+
};
|
85
|
+
|
86
|
+
const onError = (error: { [key: string]: ErrorType }) => {
|
87
|
+
setFormStateError(Object.entries(error)[0][1].message);
|
88
|
+
setShowErrorNotification(true);
|
89
|
+
};
|
90
|
+
|
91
|
+
return (
|
92
|
+
<ComposedModal
|
93
|
+
open={showModal}
|
94
|
+
onClose={() => onModalChange(false)}
|
95
|
+
preventCloseOnClickOutside
|
96
|
+
size={"md"}
|
97
|
+
>
|
98
|
+
<ModalHeader title={headerTitle} />
|
99
|
+
<form onSubmit={handleSubmit(onSubmit, onError)}>
|
100
|
+
<ModalBody hasScrollingContent>
|
101
|
+
<Stack gap={3}>
|
102
|
+
<FormGroup legendText={""}>
|
103
|
+
<Controller
|
104
|
+
name="name"
|
105
|
+
control={control}
|
106
|
+
rules={{ required: true }}
|
107
|
+
render={({ field, fieldState }) => (
|
108
|
+
<>
|
109
|
+
<TextInput
|
110
|
+
id="location"
|
111
|
+
labelText={t("location", "Location Name")}
|
112
|
+
placeholder={t("locationPlaceholder", "Add a location")}
|
113
|
+
invalidText={fieldState.error?.message}
|
114
|
+
{...field}
|
115
|
+
/>
|
116
|
+
</>
|
117
|
+
)}
|
118
|
+
/>
|
119
|
+
<div className={styles.loaderContainer}>
|
120
|
+
<Controller
|
121
|
+
name="tags"
|
122
|
+
control={control}
|
123
|
+
render={({ field, fieldState }) => (
|
124
|
+
<FilterableMultiSelect
|
125
|
+
id="tag"
|
126
|
+
titleText="Select tag(s)"
|
127
|
+
helperText="This is helper text"
|
128
|
+
items={Tags ?? []}
|
129
|
+
{...field}
|
130
|
+
itemToString={(item) => (item ? item.display : "")}
|
131
|
+
selectionFeedback="top-after-reopen"
|
132
|
+
/>
|
133
|
+
)}
|
134
|
+
/>
|
135
|
+
</div>
|
136
|
+
</FormGroup>
|
137
|
+
|
138
|
+
{showErrorNotification && (
|
139
|
+
<InlineNotification
|
140
|
+
lowContrast
|
141
|
+
title={t("error", "Error")}
|
142
|
+
style={{ minWidth: "100%", margin: "0rem", padding: "0rem" }}
|
143
|
+
role="alert"
|
144
|
+
kind="error"
|
145
|
+
subtitle={t("pleaseFillField", formStateError) + "."}
|
146
|
+
onClose={() => setShowErrorNotification(false)}
|
147
|
+
/>
|
148
|
+
)}
|
149
|
+
</Stack>
|
150
|
+
</ModalBody>
|
151
|
+
<ModalFooter>
|
152
|
+
<Button onClick={() => onModalChange(false)} kind="secondary">
|
153
|
+
{t("cancel", "Cancel")}
|
154
|
+
</Button>
|
155
|
+
<Button disabled={!isDirty} type="submit">
|
156
|
+
<span>{t("save", "Save")}</span>
|
157
|
+
</Button>
|
158
|
+
</ModalFooter>
|
159
|
+
</form>
|
160
|
+
</ComposedModal>
|
161
|
+
);
|
162
|
+
};
|
163
|
+
|
164
|
+
export default LocationAdministrationForm;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React from "react";
|
1
|
+
import React, { useMemo, useState } from "react";
|
2
2
|
import { useStockLocationPages } from "./stock-locations-table.resource";
|
3
3
|
import {
|
4
4
|
Button,
|
@@ -12,6 +12,9 @@ import styles from "../stock-items/stock-items-table.scss";
|
|
12
12
|
import { ResourceRepresentation } from "../core/api/api";
|
13
13
|
import DataList from "../core/components/table/table.component";
|
14
14
|
import { useTranslation } from "react-i18next";
|
15
|
+
import { mutate } from "swr";
|
16
|
+
import NewLocationForm from "./add-locations-form.component";
|
17
|
+
import { Add } from "@carbon/react/icons";
|
15
18
|
|
16
19
|
interface StockLocationsTableProps {
|
17
20
|
status?: string;
|
@@ -20,20 +23,29 @@ interface StockLocationsTableProps {
|
|
20
23
|
const StockLocationsItems: React.FC<StockLocationsTableProps> = () => {
|
21
24
|
const { t } = useTranslation();
|
22
25
|
|
23
|
-
const
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
const [showLocationModal, setAddLocationModal] = useState(false);
|
27
|
+
|
28
|
+
const { tableHeaders, tableRows, items, isLoading } = useStockLocationPages({
|
29
|
+
v: ResourceRepresentation.Full,
|
30
|
+
});
|
27
31
|
|
28
32
|
const handleRefresh = () => {
|
29
33
|
// search.refetch()
|
30
34
|
};
|
31
35
|
|
32
|
-
const
|
33
|
-
|
36
|
+
const createStockLocation = () => {
|
37
|
+
{
|
38
|
+
showLocationModal ? (
|
39
|
+
<NewLocationForm
|
40
|
+
onModalChange={setAddLocationModal}
|
41
|
+
showModal={showLocationModal}
|
42
|
+
mutate={mutate}
|
43
|
+
/>
|
44
|
+
) : null;
|
45
|
+
}
|
34
46
|
};
|
35
47
|
|
36
|
-
if (
|
48
|
+
if (isLoading) {
|
37
49
|
return <DataTableSkeleton role="progressbar" />;
|
38
50
|
}
|
39
51
|
|
@@ -48,8 +60,19 @@ const StockLocationsItems: React.FC<StockLocationsTableProps> = () => {
|
|
48
60
|
Refresh
|
49
61
|
</TableToolbarAction>
|
50
62
|
</TableToolbarMenu>
|
51
|
-
|
52
|
-
|
63
|
+
{showLocationModal ? (
|
64
|
+
<NewLocationForm
|
65
|
+
onModalChange={setAddLocationModal}
|
66
|
+
showModal={showLocationModal}
|
67
|
+
mutate={mutate}
|
68
|
+
/>
|
69
|
+
) : null}
|
70
|
+
<Button
|
71
|
+
kind="ghost"
|
72
|
+
renderIcon={(props) => <Add size={16} {...props} />}
|
73
|
+
onClick={() => setAddLocationModal(true)}
|
74
|
+
>
|
75
|
+
{t("createLocation", "Create Location")}
|
53
76
|
</Button>
|
54
77
|
</>
|
55
78
|
)}
|