@data-fair/lib-vue 1.25.3 → 1.25.4

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 (2) hide show
  1. package/edit-fetch.js +4 -3
  2. package/package.json +1 -1
package/edit-fetch.js CHANGED
@@ -3,14 +3,15 @@ import { ofetch } from 'ofetch';
3
3
  import { useFetch } from './fetch.js';
4
4
  import useAsyncAction from './async-action.js';
5
5
  import equal from 'fast-deep-equal';
6
+ import clone from '@data-fair/lib-utils/clone.js';
6
7
  export function useEditFetch(url, options = {}) {
7
8
  const fetch = useFetch(url, options);
8
9
  const serverData = ref(null);
9
10
  const data = ref(null);
10
11
  watch(fetch.data, () => {
11
12
  // TODO: check for local changes before overwriting ?
12
- serverData.value = fetch.data.value;
13
- data.value = fetch.data.value;
13
+ serverData.value = clone(fetch.data.value);
14
+ data.value = clone(fetch.data.value);
14
15
  });
15
16
  const hasDiff = computed(() => !equal(data.value, serverData.value));
16
17
  const getPatch = () => {
@@ -40,7 +41,7 @@ export function useEditFetch(url, options = {}) {
40
41
  // TODO: add if-unmodified-since header ?
41
42
  serverData.value = await ofetch(fetch.fullUrl.value, { method: 'PUT', body: data.value });
42
43
  }
43
- serverData.value = data.value;
44
+ serverData.value = clone(data.value);
44
45
  }, options.saveOptions);
45
46
  return {
46
47
  fetch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vue",
3
- "version": "1.25.3",
3
+ "version": "1.25.4",
4
4
  "description": "Composables and other utilities for Vue applications in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [