@mapomodule/core 1.0.0-alpha.10 → 1.0.0-alpha.16

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/CHANGELOG.md CHANGED
@@ -3,6 +3,45 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.16](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.15...v1.0.0-alpha.16) (2022-04-03)
7
+
8
+
9
+ ### Features
10
+
11
+ * Added mapo integrations module! 🎉 ([76d2c80](https://github.com/lotrekagency/mapo/commit/76d2c805245b4cf49a33696339da52e4c17f4053))
12
+ * added mapo options to mapo helper ([38dcbf2](https://github.com/lotrekagency/mapo/commit/38dcbf28d286eb02c2a6785a883a14edaa0837b1))
13
+
14
+
15
+ ### BREAKING CHANGES
16
+
17
+ * This change removes all the camomilla cms references moving the compatibility layer in a detached package [mapo-integrations-camomilla](https://github.com/lotrekagency/mapo-integrations-camomilla). The guidelines to make mapo work with camomilla will be provided in the package readme.
18
+
19
+
20
+
21
+
22
+
23
+ # [1.0.0-alpha.15](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2022-03-11)
24
+
25
+
26
+ ### Features
27
+
28
+ * **ordering:** added sortablejs to drag and reorder list ([eb8bf21](https://github.com/lotrekagency/mapo/commit/eb8bf21c3178c3ad62db5aa7c06c0562e944dea6))
29
+
30
+
31
+
32
+
33
+
34
+ # [1.0.0-alpha.13](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2022-03-01)
35
+
36
+
37
+ ### Features
38
+
39
+ * added snack message in the requst interceptor ([acf9cd1](https://github.com/lotrekagency/mapo/commit/acf9cd1efbabc13eb99af7f4bfe0dcf096112ec0))
40
+
41
+
42
+
43
+
44
+
6
45
  # [1.0.0-alpha.10](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2022-02-11)
7
46
 
8
47
 
package/api/crud.js CHANGED
@@ -105,7 +105,22 @@ const createRepository = ($axios) => (endpoint, higherConf = {}) => ({
105
105
  delete(id, config) {
106
106
  const func = $axios.$delete(`/${trimslashes(endpoint)}/${id}/`, { ...higherConf, ...config })
107
107
  return endpoint !== null ? func : Promise.reject(endpointError)
108
- }
108
+ },
109
+ /**
110
+ * This makes a POST http call to the crud endpoint slash update_order. Returns as a promise the server response.
111
+ * Use this endpoint to change the order of the items in the list.
112
+ * @alias $api.crud.update_order
113
+ * @param {String} startId The id of the item we want to move in the list.
114
+ * @param {String} endId The id of the item in the position where we want to move.
115
+ * @param {external:AxiosRequestConfig} [config] This is a further axios configuration object that allows you to override the options previously setted.
116
+ * @returns {Promise<external:AxiosResponse>}
117
+ */
118
+ update_order(startId, endId, config) {
119
+ const func = $axios.$post(`/${trimslashes(endpoint)}/update_order/`, { startId, endId }, { ...higherConf, ...config })
120
+ return endpoint !== null ? func : Promise.reject(endpointError)
121
+ },
122
+
123
+
109
124
  })
110
125
  /**
111
126
  * @external AxiosResponse
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import createRepository from '@mapomodule/core/api/crud'
2
2
  import transformRequestInMultipart from '@mapomodule/core/api/multipart'
3
3
  import initInterceptors from '@mapomodule/core/interceptor'
4
+ import options from './options'
4
5
 
5
6
  function getRouteMiddlewares(route) {
6
7
  const meta = Array.isArray(route?.meta) ? route.meta[0] : route.meta
@@ -8,6 +9,7 @@ function getRouteMiddlewares(route) {
8
9
  return (typeof middleware === "string" ? [middleware] : middleware) || []
9
10
  }
10
11
 
12
+ const { axios, ...conf } = options;
11
13
 
12
14
  export default (ctx, inject) => {
13
15
 
@@ -19,8 +21,10 @@ export default (ctx, inject) => {
19
21
  */
20
22
  $api: {
21
23
  crud: createRepository(ctx.$axios),
22
- multipart: transformRequestInMultipart
24
+ multipart: transformRequestInMultipart,
25
+ conf: axios
23
26
  },
27
+ $options: conf,
24
28
  /**
25
29
  * From here you can reach some utilities that simplify the interaction with the user authentication flow.
26
30
  */
@@ -35,7 +39,7 @@ export default (ctx, inject) => {
35
39
  *
36
40
  * This simply commits a logout to the vuex store.
37
41
  */
38
- logout: () => ctx.store.dispatch("mapo/user/login"),
42
+ logout: () => ctx.store.dispatch("mapo/user/logout"),
39
43
  /**
40
44
  * This refresh user informations present in vuex store and returns them.
41
45
  * @returns {UserData}
@@ -12,14 +12,20 @@ module.exports = ({ $axios, store }) => {
12
12
  if (response.status === 401) {
13
13
  store.dispatch('mapo/user/logout');
14
14
  }
15
+ if (response.status == 403) {
16
+ store.dispatch("mapo/app/showSnackMessage", { message: "Permission denied..", color: "error" })
17
+ }
15
18
  return response
16
19
  })
17
-
20
+
18
21
  $axios.onError((error) => {
19
22
  const { status } = error.response || {}
20
23
  if (status === 401) {
21
24
  store.dispatch('mapo/user/logout');
22
25
  }
26
+ if (status == 403) {
27
+ store.dispatch("mapo/app/showSnackMessage", { message: "Permission denied..", color: "error" })
28
+ }
23
29
  return Promise.reject(error)
24
30
  })
25
31
  }
@@ -1,8 +1,8 @@
1
1
  import Middleware from '../../middleware' // little hack to inject middleware in root project :P
2
2
 
3
3
  Middleware.auth = Middleware.auth || function ({ route, redirect, query, store }) {
4
- const hasToken = store.getters['mapo/user/token']
5
- if (!hasToken) {
4
+ const isLoggedIn = store.getters['mapo/user/isLoggedIn']
5
+ if (!isLoggedIn) {
6
6
  query['redirect'] = route.path
7
7
  return redirect('/login', query)
8
8
  }
package/module.js CHANGED
@@ -23,6 +23,13 @@ export default async function (moduleOptions) {
23
23
  fileName: path.join(namespace, 'mapo.js')
24
24
  })
25
25
 
26
+ // INJECT MAPO OPTIONS
27
+ this.addTemplate({
28
+ src: path.resolve(__dirname, './options.js'),
29
+ fileName: path.join(namespace, 'options.js'),
30
+ options: { axios: (this.options && this.options.axios), ...moduleOptions }
31
+ })
32
+
26
33
  // INJECT ALL MIDDLEWARES
27
34
  const middlewares = (await resolver.resolveRelative(__dirname, 'middleware')).map(({ src }) => src)
28
35
 
package/options.js ADDED
@@ -0,0 +1 @@
1
+ export default <%= serializeFunction(options) %>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/core",
3
- "version": "1.0.0-alpha.10",
3
+ "version": "1.0.0-alpha.16",
4
4
  "description": "This is part of Mapo nuxt module. Injects the core mapo plugin helpers.",
5
5
  "author": "bnznamco <gabriele.baldi.01@gmail.com>",
6
6
  "keywords": [
@@ -13,10 +13,10 @@
13
13
  "repository": "https://github.com/lotrekagency/mapo",
14
14
  "main": "./module.js",
15
15
  "dependencies": {
16
- "@mapomodule/utils": "^1.0.0-alpha.10"
16
+ "@mapomodule/utils": "^1.0.0-alpha.15"
17
17
  },
18
18
  "publishConfig": {
19
19
  "access": "public"
20
20
  },
21
- "gitHead": "283cad977741523d3a0c300ce08edf1a6855e11c"
21
+ "gitHead": "2ef4275464cd8eb28cbbc61c980355b1379186b5"
22
22
  }