From 7b4efb1bfe1567977011b1e37bd8c6f42aa1fbc0 Mon Sep 17 00:00:00 2001 From: Ciaran Welch Date: Wed, 26 Jun 2024 10:35:30 +1000 Subject: [PATCH] refactor(lodash): Tweak utils class --- client/helpers/confirmationDialog.js | 2 +- client/templates/topic/topicEdit.js | 2 +- imports/attachment.js | 2 +- imports/helpers/utils.js | 13 +++++-------- imports/infoitem.js | 6 +++--- imports/meetingseries.js | 2 +- imports/minutes.js | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/client/helpers/confirmationDialog.js b/client/helpers/confirmationDialog.js index 9ff21201c..fc04630eb 100644 --- a/client/helpers/confirmationDialog.js +++ b/client/helpers/confirmationDialog.js @@ -1,4 +1,4 @@ -import { _ } from "./utils"; +import { Util as _ } from "./utils"; import { Blaze } from "meteor/blaze"; import { Template } from "meteor/templating"; import { i18n } from "meteor/universe:i18n"; diff --git a/client/templates/topic/topicEdit.js b/client/templates/topic/topicEdit.js index 71ca921d1..515ca9cc5 100644 --- a/client/templates/topic/topicEdit.js +++ b/client/templates/topic/topicEdit.js @@ -4,7 +4,7 @@ import { configureSelect2Responsibles } from "/imports/client/ResponsibleSearch" import { MeetingSeries } from "/imports/meetingseries"; import { Minutes } from "/imports/minutes"; import { Topic } from "/imports/topic"; -import { _ } from "../../../imports/helpers/utils"; +import { Util as _ } from "../../../imports/helpers/utils"; import { $ } from "meteor/jquery"; import { Meteor } from "meteor/meteor"; import { Session } from "meteor/session"; diff --git a/imports/attachment.js b/imports/attachment.js index 356c00c26..af83a0446 100644 --- a/imports/attachment.js +++ b/imports/attachment.js @@ -1,4 +1,4 @@ -import { _ } from "./helpers/utils"; +import { Util _ } from "./helpers/utils"; import { AttachmentsCollection } from "./collections/attachments_private"; import { Minutes } from "./minutes"; diff --git a/imports/helpers/utils.js b/imports/helpers/utils.js index ff0eea48d..b6fcea88f 100644 --- a/imports/helpers/utils.js +++ b/imports/helpers/utils.js @@ -1,17 +1,14 @@ -class _ { - assignIn = (target, ...sources) => { +export class Util { + assignIn(target, ...sources) { const length = sources.length; if (length < 1 || target == null) return target; - for (let i = 0; i < length; i++) { - const source = sources[i]; + for (const source of sources) { for (const key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; + this.target[key] = source[key]; } } } return target; - }; + } } - -export { _ }; diff --git a/imports/infoitem.js b/imports/infoitem.js index cf1693cd7..5e8660b35 100644 --- a/imports/infoitem.js +++ b/imports/infoitem.js @@ -5,7 +5,6 @@ * and a list of associated tags. */ import { User } from "/imports/user"; -import { _ } from "lodash"; import { Meteor } from "meteor/meteor"; import { Random } from "meteor/random"; @@ -49,12 +48,13 @@ export class InfoItem { if (!Object.prototype.hasOwnProperty.call(source, "createdInMinute")) { throw new Meteor.Error("Property createdInMinute of topicDoc required"); } - _.defaults(source, { + const defaultValues = { itemType: "infoItem", isNew: true, isSticky: false, labels: [], - }); + }; + this._infoItemDoc = Object.assign({}, defaultValues, source); this._infoItemDoc = source; } diff --git a/imports/meetingseries.js b/imports/meetingseries.js index fb8bddcbd..01e9eb012 100644 --- a/imports/meetingseries.js +++ b/imports/meetingseries.js @@ -13,7 +13,7 @@ import "./collections/meetingseries_private"; import { formatDateISO8601 } from "/imports/helpers/date"; import { subElementsHelper } from "/imports/helpers/subElements"; import { MinutesFinder } from "/imports/services/minutesFinder"; -import { _ } from "./helpers/utils"; +import { Util as _ } from "./helpers/utils"; import { Meteor } from "meteor/meteor"; import { Random } from "meteor/random"; import moment from "moment/moment"; diff --git a/imports/minutes.js b/imports/minutes.js index b94e79991..981528fac 100644 --- a/imports/minutes.js +++ b/imports/minutes.js @@ -4,7 +4,7 @@ import "./collections/workflow_private"; import { emailAddressRegExpMatch } from "/imports/helpers/email"; import { subElementsHelper } from "/imports/helpers/subElements"; import { User } from "/imports/user"; -import { _ } from "./helpers/utils"; +import { Util as _ } from "./helpers/utils"; import { Meteor } from "meteor/meteor"; import { Random } from "meteor/random"; import { i18n } from "meteor/universe:i18n";