@galadrim/galadmin 0.0.64 → 0.0.70

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.
Files changed (31) hide show
  1. package/dist/api.js +4 -1
  2. package/dist/api.js.map +1 -1
  3. package/dist/tsconfig.tsbuildinfo +1 -1
  4. package/dist/types/config.d.ts +11 -6
  5. package/package.json +1 -1
  6. package/src/api.ts +3 -1
  7. package/src/front/build/asset-manifest.json +7 -7
  8. package/src/front/build/index.html +1 -1
  9. package/src/front/build/static/js/{2.88bb9cea.chunk.js → 2.f2c3716e.chunk.js} +3 -3
  10. package/src/front/build/static/js/{2.88bb9cea.chunk.js.LICENSE.txt → 2.f2c3716e.chunk.js.LICENSE.txt} +0 -0
  11. package/src/front/build/static/js/2.f2c3716e.chunk.js.map +1 -0
  12. package/src/front/build/static/js/main.41c4b315.chunk.js +2 -0
  13. package/src/front/build/static/js/main.41c4b315.chunk.js.map +1 -0
  14. package/src/front/node_modules/.cache/.eslintcache +1 -1
  15. package/src/front/node_modules/.cache/babel-loader/1e8750017803ed2618bfa8e7876588f4.json +1 -0
  16. package/src/front/node_modules/.cache/babel-loader/3b3e3be2905c35944c0229efe73d25f1.json +1 -0
  17. package/src/front/node_modules/.cache/babel-loader/40f82d7c4495af82b6e682474a644bd6.json +1 -0
  18. package/src/front/node_modules/.cache/terser-webpack-plugin/content-v2/sha512/{02/1c/cd922a30b837866c304e653fd02dc10a713290b65b1a3f8ab96fac6e8d3d8153afdd05cd2f39ac5a2b666bbc7c16e0a5a909a50abc0640d631f50f2d5405 → 84/ad/d97cdd00bcf0d10c691fe8aac1fde475e7e4b03a6b11153f0090501f2088b1faa73632a5ae701f7875e0018fd2254c094716b41e38c1b9802af8526716e1} +1 -1
  19. package/src/front/node_modules/.cache/terser-webpack-plugin/content-v2/sha512/cc/ec/206cd365832240deed2445c531154c5f17b15817cdfbd1cb5ba5ea8cc5891224bd176901d43d994942f16373b916c124b30dd7dac62de05b1d7fc8799b8d +1 -0
  20. package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/{32/f1/8264252bcf7c4f98cde13450968b415f55003188f30504894efa85c8e42b → 93/40/1664ad7eaeaf568aa45393ab7f158f62d0407af4e89717f5a845397dd57f} +1 -1
  21. package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/{13/48/ea4fd5de6d7ce705b49b91192d276b4d6695b9224484d8b332cd236e2f2a → e2/ce/ec4d9ffbc3052b37905b14459364efd0e45053fc2a92259673778eddbcb1} +1 -1
  22. package/src/front/src/components/panels/GalleryPanel.js +37 -3
  23. package/src/front/src/components/panels/TablePanel.js +6 -5
  24. package/src/front/src/pages/CreateRecord.js +4 -2
  25. package/src/types/config.ts +13 -8
  26. package/src/front/build/static/js/2.88bb9cea.chunk.js.map +0 -1
  27. package/src/front/build/static/js/main.4a75d43f.chunk.js +0 -2
  28. package/src/front/build/static/js/main.4a75d43f.chunk.js.map +0 -1
  29. package/src/front/node_modules/.cache/babel-loader/cd53713ec61cb5f5e41e728d0d93a34d.json +0 -1
  30. package/src/front/node_modules/.cache/babel-loader/d35a56a324725da640fb076831eb6e91.json +0 -1
  31. package/src/front/node_modules/.cache/terser-webpack-plugin/content-v2/sha512/a3/b4/65b20bcb7256e4e5b06e4ceeaa58e4b96a15a4f1c3e446f097df9d6dab35028acedcd5d9551148d2e7289ccf2df41e2f7f43bafda0812f8eb19971cdee20 +0 -1
@@ -1,2 +1,2 @@
1
1
 
2
- d5c1b26c9ac4526842f7e3aa2cfda64559617136 {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002F2.88bb9cea.chunk.js\",\"contentHash\":\"01567565c347bca09e20\"}","integrity":"sha512-AhzNkiowuDeGbDBOZT/QLcEKcTKQtlsaP4q5b6xujT2BU6/dBc0vOaxaK2ZrvHwW4KWpCaUKvAZA1jH1Dy1UBQ==","time":1640166912665,"size":1866754}
2
+ 7c08067cd930aba5f76f76fd7359731ca286ed2e {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002F2.f2c3716e.chunk.js\",\"contentHash\":\"973b410a3095eb5207c3\"}","integrity":"sha512-hK3ZfN0AvPDRDGkf6KrB/eR15+SwOmsRFT8AkFAfIIix+qc2MqWucB94deABj9IlTAlHFrQeOMG5gCr4UmcW4Q==","time":1640183142529,"size":1866754}
@@ -1,2 +1,2 @@
1
1
 
2
- d06c51b80fcfb8c0aa5fedf5ae8fe20b673c3695 {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002Fmain.4a75d43f.chunk.js\",\"contentHash\":\"07f6aad002a88561f41c\"}","integrity":"sha512-o7RlsgvLclbk5bBuTO6qWOS5ahWk8cPkRvCX351tqzUCis7c1dlVEUjS5yiczy30Hi9/Q7r9oIEvjrGZcc3uIA==","time":1640166909427,"size":336367}
2
+ 91eb090106a0f1bc1ae526c2bb19c2455b954a1d {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002Fmain.41c4b315.chunk.js\",\"contentHash\":\"1ca69d5579b3df8462b0\"}","integrity":"sha512-zOwgbNNlgyJA3u0kRcUxFUxfF7FYF8370ctbpeqMxYkSJL0XaQHUPZlJQvFjc7kWwSSzDdfaxi3gWx1/yHmbjQ==","time":1640183138753,"size":342111}
@@ -1,10 +1,20 @@
1
1
  import { useState, useEffect } from "react"
2
+ import {
3
+ useHistory,
4
+ useParams
5
+ } from "react-router-dom";
2
6
  import axios from "axios";
3
7
 
4
8
  export default ({ panel, record, view }) => {
5
9
  const [results, setResults] = useState(null);
10
+ const history = useHistory();
11
+ const { viewIndex } = useParams();
6
12
 
7
13
  useEffect(() => {
14
+ refreshData()
15
+ }, [panel.query])
16
+
17
+ const refreshData = () => {
8
18
  axios.get("/customQuery", {
9
19
  params: {
10
20
  query: panel.query,
@@ -13,7 +23,31 @@ export default ({ panel, record, view }) => {
13
23
  }).then((response) => {
14
24
  setResults(response.data)
15
25
  })
16
- }, [panel.query])
26
+ }
27
+ const deleteRow = async (row) => {
28
+ const willDelete = await window.swal({
29
+ title: "Êtes-vous sûr ?",
30
+ text: "Une fois la suppression confirmée, il ne sera pas possible de revenir en arrière.",
31
+ buttons: ["Annuler", "Oui"],
32
+ dangerMode: true
33
+ })
34
+ if (willDelete) {
35
+ try {
36
+ await axios.post("/deleteRecordFromPanel", {
37
+ viewIndex,
38
+ panelId: panel.__id__,
39
+ primaryValue: row[panel.primaryId]
40
+ })
41
+ refreshData();
42
+ } catch (e) {
43
+ window.swal({
44
+ title: "Erreur",
45
+ text: "Suppression impossible",
46
+ dangerMode: true
47
+ })
48
+ }
49
+ }
50
+ }
17
51
 
18
52
  const pathField = panel.pathField || "Path"
19
53
 
@@ -23,11 +57,11 @@ export default ({ panel, record, view }) => {
23
57
  <div class="gallery">
24
58
  {results.map((result) => (
25
59
  <div class='galleryPicture' key={result[pathField]}>
26
- {panel.canDelete ? <div class='deleteIcon'><i class='fa fa-minus'></i></div> : null}
60
+ {panel.canDelete ? <div class='deleteIcon' onClick={() => deleteRow(result)}><i class='fa fa-minus'></i></div> : null}
27
61
  <a href={panel.baseUrl + result[pathField]} target='_blank'>
28
62
  <img
29
63
  src={panel.baseUrl + result[pathField]}
30
- style={{ width: 150, height: 150, objectFit: panel.objectFit || "cover" }}
64
+ style={{ width: "100%", height: 150, objectFit: panel.objectFit || "cover" }}
31
65
  onerror='this.style.height = 0'
32
66
  />
33
67
  </a>
@@ -78,11 +78,12 @@ export default ({ panel, record, view }) => {
78
78
  >
79
79
  {Object.keys(result).filter(key => key !== panel.primaryId).map((key) =>
80
80
  <td key={key}>
81
- <div
82
- dangerouslySetInnerHTML={{ __html:
83
- (panel.formattedValues && (key in panel.formattedValues)) ?
84
- evalExpression(panel.formattedValues[key], result) :
85
- result[key]
81
+ <div
82
+ dangerouslySetInnerHTML={{
83
+ __html:
84
+ (panel.formattedValues && (key in panel.formattedValues)) ?
85
+ evalExpression(panel.formattedValues[key], result) :
86
+ result[key]
86
87
  }}
87
88
  />
88
89
  </td>
@@ -42,15 +42,17 @@ export default () => {
42
42
  }
43
43
  setIsCreating(true)
44
44
  try {
45
- await axios.post("/createRecord", {
45
+ const response = await axios.post("/createRecord", {
46
46
  viewIndex,
47
47
  panelIndex,
48
48
  recordId,
49
49
  data: data.current
50
50
  })
51
51
  setIsCreating(false)
52
- if (recordId) {
52
+ if (recordId) { // Create from panel view
53
53
  history.push(`/record/${viewIndex}/${recordId}`)
54
+ } else if (view.createConfig.redirectToCreatedItems) {
55
+ history.push(`/record/${viewIndex}/${response.data.id}`)
54
56
  } else {
55
57
  history.push(`/records/${viewIndex}`)
56
58
  }
@@ -62,7 +62,8 @@ export type ForeignSelectColumn = {
62
62
  join?: string,
63
63
  filters?: Filter[],
64
64
  orderBy?: string,
65
- optional?: boolean
65
+ optional?: boolean,
66
+ formatForeignValue?: (record: any) => string,
66
67
  }
67
68
 
68
69
  export type ForeignDatalistColumn = {
@@ -76,7 +77,8 @@ export type ForeignDatalistColumn = {
76
77
  join?: string,
77
78
  filters?: Filter[],
78
79
  orderBy?: string,
79
- optional?: boolean
80
+ optional?: boolean,
81
+ formatForeignValue?: (record: any) => string,
80
82
  }
81
83
 
82
84
  export type RichTextColumn = {
@@ -159,8 +161,13 @@ export type Subview = {
159
161
  export type BaseTypePanel = {
160
162
  label: string,
161
163
  folded?: boolean,
162
- canCreate?: boolean,
164
+ }
163
165
 
166
+ export type CreateConfig = {
167
+ label: string,
168
+ recordIdKey: string,
169
+ columns: Column[],
170
+ redirectToCreatedItems?: boolean
164
171
  }
165
172
 
166
173
  export type TablePanel = {
@@ -171,11 +178,7 @@ export type TablePanel = {
171
178
  canShow?: boolean,
172
179
  canDelete?: boolean,
173
180
  canCreate?: boolean,
174
- createConfig?: {
175
- label: string,
176
- recordIdKey: string,
177
- columns: Column[]
178
- },
181
+ createConfig?: CreateConfig,
179
182
  tableName?: string,
180
183
  primaryId?: string,
181
184
  formattedValues?: { [key: string]: string },
@@ -196,6 +199,8 @@ export type MapPanel = {
196
199
  export type GalleryPanel = {
197
200
  type: "gallery",
198
201
  query: string,
202
+ canCreate?: boolean,
203
+ createConfig?: CreateConfig,
199
204
  canDelete?: boolean,
200
205
  baseUrl?: string,
201
206
  pathField?: string,