Remove global refernece to $msg

This commit is contained in:
Paulo Gustavo Veiga 2021-12-14 17:54:11 -08:00
parent 5b74b9cff3
commit f95e65f21b
12 changed files with 21 additions and 15 deletions

View File

@ -17,9 +17,9 @@
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import $ from 'jquery'; import $ from 'jquery';
import Messages, { $msg } from './Messages';
import Events from './Events'; import Events from './Events';
import Messages from './Messages';
import StandaloneActionDispatcher from './StandaloneActionDispatcher'; import StandaloneActionDispatcher from './StandaloneActionDispatcher';
import CommandContext from './CommandContext'; import CommandContext from './CommandContext';
@ -258,19 +258,15 @@ class Designer extends Events {
if (isConnected) { if (isConnected) {
// Improve this ... // Improve this ...
const targetTopicModel = model.getParent(); const targetTopicModel = model.getParent();
let targetTopic = null;
// Find target topic with the same model ...
const topics = this.getModel().getTopics(); const topics = this.getModel().getTopics();
for (let i = 0; i < topics.length; i++) { const targetTopic = topics.find((t) => t.getModel() === targetTopicModel);
const t = topics[i]; if (targetTopic) {
if (t.getModel() === targetTopicModel) { model.disconnect();
targetTopic = t; } else {
// Disconnect the node. It will be connected again later ... $assert(targetTopic, 'Could not find a topic to connect');
model.disconnect();
break;
}
} }
$assert(targetTopic, 'Could not find a topic to connect');
topic.connectTo(targetTopic, this._workspace); topic.connectTo(targetTopic, this._workspace);
} }

View File

@ -33,7 +33,7 @@ class Messages {
} }
// @Todo: fix global assignment. // @Todo: fix global assignment.
global.$msg = function $msg(key) { const $msg = function $msg(key) {
if (!Messages.__bundle) { if (!Messages.__bundle) {
Messages.init('en'); Messages.init('en');
} }
@ -43,3 +43,4 @@ global.$msg = function $msg(key) {
Messages.BUNDLES = {}; Messages.BUNDLES = {};
export default Messages; export default Messages;
export { $msg };

View File

@ -17,6 +17,7 @@
*/ */
import { $assert } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import $ from 'jquery'; import $ from 'jquery';
import { $msg } from './Messages';
import Icon from './Icon'; import Icon from './Icon';
import FloatingTip from './widget/FloatingTip'; import FloatingTip from './widget/FloatingTip';

View File

@ -16,6 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { $assert } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import { $msg } from './Messages';
import PersistenceManager from './PersistenceManager'; import PersistenceManager from './PersistenceManager';
class RESTPersistenceManager extends PersistenceManager{ class RESTPersistenceManager extends PersistenceManager{

View File

@ -16,6 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import { $msg } from './Messages';
import { TopicShape } from './model/INodeModel'; import { TopicShape } from './model/INodeModel';
class TopicStyle { class TopicStyle {

View File

@ -1,5 +1,5 @@
import Options from '../../Options'; import Options from '../../Options';
import { $msg } from '../../Messages';
import $ from 'jquery'; import $ from 'jquery';
class BootstrapDialog extends Options { class BootstrapDialog extends Options {
@ -36,7 +36,7 @@ class BootstrapDialog extends Options {
content.append(footer); content.append(footer);
} }
this._native.find('.modal-dialog').append(content); this._native.find('.modal-dialog').append(content);
this._native.on('hidden.bs.modal', function () { this._native.on('hidden.bs.modal', function remove() {
$(this).remove(); $(this).remove();
}); });
this._native.on('shown.bs.modal', this.onDialogShown); this._native.on('shown.bs.modal', this.onDialogShown);

View File

@ -16,6 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { $assert } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import { $msg } from '../Messages';
import PersistenceManager from '../PersistenceManager'; import PersistenceManager from '../PersistenceManager';
import { $notify } from './ToolbarNotifier'; import { $notify } from './ToolbarNotifier';
import $notifyModal from './ModalDialogNotifier'; import $notifyModal from './ModalDialogNotifier';

View File

@ -17,6 +17,7 @@
*/ */
import $ from 'jquery'; import $ from 'jquery';
import { $assert } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import { $msg } from '../Messages';
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog'; import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
class LinkEditor extends BootstrapDialog { class LinkEditor extends BootstrapDialog {

View File

@ -17,6 +17,7 @@
*/ */
import { $assert } from "@wisemapping/core-js"; import { $assert } from "@wisemapping/core-js";
import $ from 'jquery'; import $ from 'jquery';
import { $msg } from '../Messages';
import FloatingTip from './FloatingTip'; import FloatingTip from './FloatingTip';
class LinkIconTooltip extends FloatingTip { class LinkIconTooltip extends FloatingTip {

View File

@ -16,8 +16,8 @@
* limitations under the License. * limitations under the License.
*/ */
import $ from 'jquery'; import $ from 'jquery';
import { $defined } from '@wisemapping/core-js'; import { $defined } from '@wisemapping/core-js';
import { $msg } from '../Messages';
import BootstrapDialogRequest from "../libraries/bootstrap/BootstrapDialogRequest"; import BootstrapDialogRequest from "../libraries/bootstrap/BootstrapDialogRequest";
import IMenu from './IMenu'; import IMenu from './IMenu';
import FontFamilyPanel from './FontFamilyPanel'; import FontFamilyPanel from './FontFamilyPanel';

View File

@ -18,6 +18,7 @@
import { $assert } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog'; import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
import $ from 'jquery'; import $ from 'jquery';
import { $msg } from '../Messages';
class NoteEditor extends BootstrapDialog { class NoteEditor extends BootstrapDialog {
constructor(model) { constructor(model) {

View File

@ -18,6 +18,8 @@
import { $assert } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import { PersistenceManager, Designer, LocalStorageManager, Menu } from '../../../../src/'; import { PersistenceManager, Designer, LocalStorageManager, Menu } from '../../../../src/';
import * as mindplot from '../../../../src/'; import * as mindplot from '../../../../src/';
import { $msg } from '../../../../src/components/Messages';
import $notifyModal from '../../../../src/components/widget/ModalDialogNotifier'; import $notifyModal from '../../../../src/components/widget/ModalDialogNotifier';
import $ from 'jquery'; import $ from 'jquery';