mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
use lodash instead of json in RevertButton
This commit is contained in:
parent
a1ce048ed5
commit
56800737e6
5 changed files with 25 additions and 3 deletions
|
@ -127,6 +127,7 @@ svelte_check(
|
|||
"*.svelte",
|
||||
]) + [
|
||||
"@npm//@types/bootstrap",
|
||||
"@npm//@types/lodash-es",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
<script lang="ts">
|
||||
import { revertIcon } from "./icons";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { isEqual, cloneDeep } from "lodash-es";
|
||||
|
||||
export let value: any;
|
||||
export let defaultValue: any;
|
||||
|
@ -12,12 +13,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
const dispatch = createEventDispatcher();
|
||||
|
||||
let modified: boolean;
|
||||
$: modified = JSON.stringify(value) !== JSON.stringify(defaultValue);
|
||||
$: modified = !isEqual(value, defaultValue);
|
||||
|
||||
/// This component can be used either with bind:value, or by listening
|
||||
/// to the revert event.
|
||||
function revert(): void {
|
||||
value = JSON.parse(JSON.stringify(defaultValue));
|
||||
value = cloneDeep(defaultValue);
|
||||
dispatch("revert", { value });
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -102,6 +102,18 @@
|
|||
"path": "node_modules/@protobufjs/utf8",
|
||||
"licenseFile": "node_modules/@protobufjs/utf8/LICENSE"
|
||||
},
|
||||
"@types/lodash-es@4.17.4": {
|
||||
"licenses": "MIT",
|
||||
"repository": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
||||
"path": "node_modules/@types/lodash-es",
|
||||
"licenseFile": "node_modules/@types/lodash-es/LICENSE"
|
||||
},
|
||||
"@types/lodash@4.14.168": {
|
||||
"licenses": "MIT",
|
||||
"repository": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
||||
"path": "node_modules/@types/lodash",
|
||||
"licenseFile": "node_modules/@types/lodash/LICENSE"
|
||||
},
|
||||
"@types/long@4.0.1": {
|
||||
"licenses": "MIT",
|
||||
"repository": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
"@fluent/bundle": "^0.15.1",
|
||||
"@mdi/svg": "^5.9.55",
|
||||
"@popperjs/core": "^2.9.2",
|
||||
"@types/lodash-es": "^4.17.4",
|
||||
"bootstrap": "^5.0.0-beta2",
|
||||
"bootstrap-icons": "^1.4.0",
|
||||
"css-browser-selector": "^0.6.5",
|
||||
|
|
|
@ -973,7 +973,14 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
|
||||
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
|
||||
|
||||
"@types/lodash@^4.14.162":
|
||||
"@types/lodash-es@^4.17.4":
|
||||
version "4.17.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.4.tgz#b2e440d2bf8a93584a9fd798452ec497986c9b97"
|
||||
integrity sha512-BBz79DCJbD2CVYZH67MBeHZRX++HF+5p8Mo5MzjZi64Wac39S3diedJYHZtScbRVf4DjZyN6LzA0SB0zy+HSSQ==
|
||||
dependencies:
|
||||
"@types/lodash" "*"
|
||||
|
||||
"@types/lodash@*", "@types/lodash@^4.14.162":
|
||||
version "4.14.168"
|
||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008"
|
||||
integrity sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q==
|
||||
|
|
Loading…
Reference in a new issue