ywana-core8 0.0.299 → 0.0.302

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.299",
3
+ "version": "0.0.302",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -47,7 +47,7 @@ export const TablePage = (props) => {
47
47
  }, [form])
48
48
 
49
49
  useEffect(async () => {
50
- const context = TableContext(url, field, host)
50
+ const context = TableContext(url, field, host, urlQuery)
51
51
  await context.load()
52
52
  if (canQuery) await context.loadQueries()
53
53
  setPageContext(context)
@@ -211,19 +211,15 @@ const TableSelector = (props) => {
211
211
  const TableQueries = (props) => {
212
212
 
213
213
  const [pageContext, setPageContext] = useContext(PageContext)
214
+ const { url } = props
214
215
  const { queries= [
215
216
  { name: "Query 1", filters: {}},
216
217
  { name: "Query 2", filters: {}},
217
218
  { name: "Query 3", filters: {}},
218
219
  ] } = pageContext
219
220
 
220
- useEffect(() => {
221
- pageContext.loadQueries()
222
- }, [])
223
-
224
-
225
221
  async function remove(id) {
226
- await pageContext.removeQuery(id)
222
+ await pageContext.removeQuery(id, url)
227
223
  setPageContext(Object.assign({}, pageContext))
228
224
  }
229
225
 
@@ -447,7 +443,7 @@ export const TableEditor = (props) => {
447
443
  /**
448
444
  * Table Context
449
445
  */
450
- const TableContext = (url, field, host) => {
446
+ const TableContext = (url, field, host, urlQuery) => {
451
447
 
452
448
  const API = TableAPI(url, host)
453
449
 
@@ -527,7 +523,7 @@ const TableContext = (url, field, host) => {
527
523
 
528
524
  async loadQueries() {
529
525
  try {
530
- this.queries = await API.queries()
526
+ this.queries = await API.queries(urlQuery)
531
527
  } catch (error) {
532
528
  console.log(error)
533
529
  }
@@ -603,17 +599,20 @@ const TableAPI = (url, host) => {
603
599
  return http.DELETE(`${url}/${id}`)
604
600
  },
605
601
 
606
- queries() {
607
- return http.GET(`${url}/queries`)
602
+ queries(url2) {
603
+ const url3 = url2 ? url2 : url
604
+ return http.GET(`${url3}queries`)
608
605
  },
609
606
 
610
- createQuery(form) {
607
+ createQuery(form, url2) {
608
+ const url3 = url2 ? url2 : url
611
609
  const body = JSON.stringify(form)
612
- return http.POST(`${url}/queries`, body)
610
+ return http.POST(`${url3}queries`, body)
613
611
  },
614
612
 
615
- removeQuery(id) {
616
- return http.DELETE(`${url}/queries/${id}`)
613
+ removeQuery(id, url2) {
614
+ const url3 = url2 ? url2 : url
615
+ return http.DELETE(`${url3}queries/${id}`)
617
616
  },
618
617
  }
619
618
  }