removed lodash
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
export function debounce(callback, wait) {
|
||||
let timeoutId = null;
|
||||
|
||||
return (...args) => {
|
||||
window.clearTimeout(timeoutId);
|
||||
|
||||
timeoutId = window.setTimeout(() => {
|
||||
callback.apply(null, args);
|
||||
}, wait);
|
||||
};
|
||||
}
|
||||
+19
-3
@@ -1,18 +1,18 @@
|
||||
import {formatDistanceToNow, parseJSON, format, parse} from "date-fns";
|
||||
import {format, formatDistanceToNow, parseJSON} from "date-fns";
|
||||
|
||||
export function friendlyDate(date) {
|
||||
return formatDistanceToNow(parseJSON(date), {addSuffix: true});
|
||||
}
|
||||
|
||||
export function readableDate(date) {
|
||||
if(!date){
|
||||
if (!date) {
|
||||
return "";
|
||||
}
|
||||
return format(parseJSON(date), "dd MMM yyyy");
|
||||
}
|
||||
|
||||
export function readableDatetime(date) {
|
||||
if(!date){
|
||||
if (!date) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -50,3 +50,19 @@ export function clickOutside(node) {
|
||||
}
|
||||
}
|
||||
|
||||
export function uniqueBy(list, callback) {
|
||||
const itemMap = list.reduce((c, item) => {
|
||||
c[callback(item)] = item;
|
||||
return c;
|
||||
}, {});
|
||||
|
||||
return Object.values(itemMap);
|
||||
}
|
||||
|
||||
export function range(start, end) {
|
||||
var ans = [];
|
||||
for (let i = start; i <= end; i++) {
|
||||
ans.push(i);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { createEventDispatcher } from "svelte";
|
||||
const dispatch = createEventDispatcher();
|
||||
import { range } from "lodash";
|
||||
import { range } from "../../../helpers.js";
|
||||
import NavItem from "./NavItem.svelte";
|
||||
export let inModal;
|
||||
export let modalUrl;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script>
|
||||
import {createEventDispatcher, getContext} from "svelte";
|
||||
import {debounce} from "lodash";
|
||||
import {debounce} from "../../../debounce.js";
|
||||
import {previewTitle} from "../../records/Preview";
|
||||
|
||||
import axios from "axios";
|
||||
|
||||
const channel = getContext("channel");
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script>
|
||||
import {afterUpdate, getContext, onMount} from "svelte";
|
||||
import {isEqual} from "lodash";
|
||||
import axios from "axios";
|
||||
import EditHeader from "./header/EditHeader.svelte"
|
||||
import FilePreview from "./FilePreview.svelte"
|
||||
@@ -10,6 +9,7 @@
|
||||
import Info from "./Info.svelte"
|
||||
import ErrorAlert from "../common/ErrorAlert.svelte"
|
||||
import Title from "./header/Title.svelte";
|
||||
import {hasDataChanged} from "./editor.js";
|
||||
|
||||
const channel = getContext("channel");
|
||||
|
||||
@@ -74,10 +74,7 @@
|
||||
}
|
||||
|
||||
function checkUnsavedData() {
|
||||
if (isCreateMode) {
|
||||
return false;
|
||||
}
|
||||
return !isEqual(originalContent, {
|
||||
return hasDataChanged(isCreateMode,originalContent,{
|
||||
data: record.data,
|
||||
schema: record.schema,
|
||||
status: record.status,
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
import {friendlyDate} from "../../helpers";
|
||||
import Avatar from "../account/Avatar.svelte";
|
||||
import {usernameById} from "../account/users";
|
||||
import {isEqual} from "lodash";
|
||||
import Icon from "../common/Icon.svelte";
|
||||
import RevisionCell from "./revisions/RevisionCell.svelte";
|
||||
import {getContext} from "svelte";
|
||||
import RevisionEdgeRow from "./revisions/RevisionEdgeRow.svelte";
|
||||
import axios from "axios";
|
||||
import {hasDataChanged} from "./editor.js";
|
||||
|
||||
const channel = getContext("channel");
|
||||
export let record;
|
||||
@@ -60,7 +61,7 @@
|
||||
selectedRevision = revision;
|
||||
|
||||
fieldsWithDiff = schema.fields.filter((f) => {
|
||||
return !isEqual(selectedRevision.data[f.name], record.data[f.name]);
|
||||
return hasDataChanged(false,selectedRevision.data[f.name], record.data[f.name]);
|
||||
});
|
||||
getEdgesByField(fieldsWithDiff, revision)
|
||||
revisionSection.scrollIntoView();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script>
|
||||
import {afterUpdate, createEventDispatcher, getContext, onMount} from "svelte";
|
||||
|
||||
import {isEqual} from "lodash";
|
||||
import {hasDataChanged} from "./editor.js";
|
||||
import FormField from "./FormField.svelte";
|
||||
import FilePreview from "./FilePreview.svelte";
|
||||
import ContentTabs from "./header/ContentTabs.svelte";
|
||||
@@ -80,10 +79,7 @@
|
||||
}
|
||||
|
||||
function checkUnsavedData() {
|
||||
if (isCreateMode) {
|
||||
return false;
|
||||
}
|
||||
return !isEqual(originalContent, {
|
||||
return hasDataChanged(isCreateMode, originalContent, {
|
||||
data: record.data,
|
||||
schema: record.schema,
|
||||
status: record.status,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export function hasDataChanged(isCreateMode, originalContent, newContent){
|
||||
if (isCreateMode) {
|
||||
return false;
|
||||
}
|
||||
return JSON.stringify(originalContent) !== JSON.stringify(newContent);
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
<script>
|
||||
import {getContext} from "svelte";
|
||||
import {debounce} from "lodash";
|
||||
import {debounce} from "../../../debounce.js";
|
||||
import {previewTitle} from "../Preview";
|
||||
import {getErrorMessage} from "./errorMessage";
|
||||
import {insertEdges} from "./reference.js";
|
||||
import Icon from "../../common/Icon.svelte";
|
||||
import axios from "axios";
|
||||
|
||||
const channel = getContext("channel");
|
||||
export let field;
|
||||
@@ -18,7 +19,7 @@
|
||||
$: references = graph.edges
|
||||
.filter((edge) => edge.field === field.name)
|
||||
.map((edge) => {
|
||||
return graph.records.find((increc) => increc.id == edge.target && record.id == edge.source);
|
||||
return graph.records.find((increc) => increc.id === edge.target && record.id === edge.source);
|
||||
}).filter((rec) => (rec?.id ? true : false)) ?? [];
|
||||
|
||||
let search = ""
|
||||
@@ -48,11 +49,9 @@
|
||||
.then((response) => {
|
||||
searchOptions = [];
|
||||
insert(e, response.data.records[0]);
|
||||
console.log(response)
|
||||
})
|
||||
.catch((error) => {
|
||||
searchOptions = [];
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,7 +78,6 @@
|
||||
})
|
||||
.catch((error) => {
|
||||
searchOptions = [];
|
||||
console.log(error);
|
||||
});
|
||||
}, 500);
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { uniqueId } from "lodash";
|
||||
import { getContext } from "svelte";
|
||||
const channelurl = getContext("channelurl");
|
||||
export let field;
|
||||
export let value;
|
||||
export let schema;
|
||||
let id = uniqueId();
|
||||
export let id;
|
||||
</script>
|
||||
|
||||
<div class="mb-0">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {uniqBy} from "lodash";
|
||||
import {uniqueBy} from "../../../helpers.js";
|
||||
import axios from "axios";
|
||||
|
||||
export function insertEdges(graph, sourceRecord, targetRecords, fieldName, action = "") {
|
||||
@@ -17,8 +17,8 @@ export function insertEdges(graph, sourceRecord, targetRecords, fieldName, actio
|
||||
replacedEdges = replacedEdges.filter((edge) => edge.field !== field.name);
|
||||
}
|
||||
|
||||
graph.records = uniqBy([...graph.records, ...targetRecords], (r) => r.id);
|
||||
graph.edges = uniqBy([...replacedEdges, ...newEdges], (edge) => edge.source + edge.target + edge.field + edge.depth);
|
||||
graph.records = uniqueBy([...graph.records, ...targetRecords], (r) => r.id);
|
||||
graph.edges = uniqueBy([...replacedEdges, ...newEdges], (edge) => edge.source + edge.target + edge.field + edge.depth);
|
||||
return graph;
|
||||
}
|
||||
|
||||
|
||||
Generated
+1111
-684
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,6 @@
|
||||
"htmx.org": "^2.0.1",
|
||||
"install": "^0.13.0",
|
||||
"laravel-vite-plugin": "^1.0.5",
|
||||
"lodash": "^4.17.21",
|
||||
"mustache": "^4.2.0",
|
||||
"npm": "^10.8.2",
|
||||
"postcss": "8.4.31",
|
||||
|
||||
Reference in New Issue
Block a user