summaryrefslogtreecommitdiff
path: root/animism-align/frontend/api/crud.types.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-06-23 23:18:07 +0200
committerJules Laplace <julescarbon@gmail.com>2020-06-23 23:18:07 +0200
commit3cf70771cb45cc16ec33ffe44e7a1a4799d8f395 (patch)
tree55f0edb53141d5f043b486d722f507bfd94abdea /animism-align/frontend/api/crud.types.js
parent014816dc724c1be60b7dd28d4e608c89b4ed451c (diff)
adding web app base
Diffstat (limited to 'animism-align/frontend/api/crud.types.js')
-rw-r--r--animism-align/frontend/api/crud.types.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/animism-align/frontend/api/crud.types.js b/animism-align/frontend/api/crud.types.js
new file mode 100644
index 0000000..7a64f5c
--- /dev/null
+++ b/animism-align/frontend/api/crud.types.js
@@ -0,0 +1,36 @@
+
+export const as_type = (a, b) => [a, b].join('_').toUpperCase()
+
+export const with_type = (type, actions) =>
+ actions.reduce((a, b) => (a[b] = as_type(type, b)) && a, {})
+
+export const crud_type = (type, actions=[]) =>
+ with_type(type, actions.concat([
+ 'index_loading',
+ 'index',
+ 'index_error',
+ 'index_sort',
+ 'show_loading',
+ 'show',
+ 'show_error',
+ 'create_loading',
+ 'create',
+ 'create_error',
+ 'update_loading',
+ 'update',
+ 'update_error',
+ 'destroy_loading',
+ 'destroy',
+ 'destroy_error',
+ 'upload_loading',
+ 'upload_progress',
+ 'upload_waiting',
+ 'upload_complete',
+ 'upload_error',
+ 'sort',
+ 'update_option',
+ 'update_options',
+ 'loading',
+ 'loaded',
+ 'error',
+ ]))