62 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-07-16 11:41:58 -03:00
/*
2021-12-25 14:39:34 -08:00
* Copyright [2021] [wisemapping]
2021-07-16 11:41:58 -03:00
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2021-12-03 16:11:17 -08:00
import { $assert } from '@wisemapping/core-js';
import Icon from './Icon';
2021-12-27 23:10:56 -08:00
import NotesImage from '../../assets/icons/notes.svg';
2022-02-22 19:12:04 -08:00
import Topic from './Topic';
import NoteModel from './model/NoteModel';
import FeatureModel from './model/FeatureModel';
import WidgetManager from './WidgetManager';
2021-07-16 11:41:58 -03:00
2021-12-04 15:39:20 -08:00
class NoteIcon extends Icon {
2022-02-22 19:12:04 -08:00
private _linksModel: NoteModel;
2022-02-22 19:12:04 -08:00
private _topic: Topic;
2022-02-22 19:12:04 -08:00
private _readOnly: boolean;
2022-02-22 19:12:04 -08:00
constructor(topic: Topic, noteModel: NoteModel, readOnly: boolean) {
2021-10-04 17:05:34 -07:00
$assert(topic, 'topic can not be null');
2021-07-16 11:41:58 -03:00
2021-12-04 15:39:20 -08:00
super(NoteIcon.IMAGE_URL);
2021-10-04 17:05:34 -07:00
this._linksModel = noteModel;
this._topic = topic;
this._readOnly = readOnly;
2021-07-16 11:41:58 -03:00
2021-10-04 17:05:34 -07:00
this._registerEvents();
2021-12-04 15:39:20 -08:00
}
2021-07-16 11:41:58 -03:00
2022-02-22 19:12:04 -08:00
private _registerEvents(): void {
2021-10-04 17:05:34 -07:00
this._image.setCursor('pointer');
2021-07-16 11:41:58 -03:00
const manager = WidgetManager.getInstance();
manager.createTooltipForNote(this._topic, this._linksModel as NoteModel, this);
2021-10-04 17:05:34 -07:00
if (!this._readOnly) {
manager.configureEditorForNote(this._topic, this._linksModel as NoteModel, this);
2021-07-16 11:41:58 -03:00
}
2021-12-04 15:39:20 -08:00
}
2021-10-04 17:05:34 -07:00
2022-02-22 19:12:04 -08:00
getModel(): FeatureModel {
2021-10-04 17:05:34 -07:00
return this._linksModel;
2021-12-04 15:39:20 -08:00
}
2021-07-16 11:41:58 -03:00
2022-02-22 19:12:04 -08:00
static IMAGE_URL = NotesImage;
}
2021-07-16 11:41:58 -03:00
2021-10-04 17:05:34 -07:00
export default NoteIcon;