Add missing types in Mention.ts
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com> Change-Id: Ia3909dd8a1e55a4872e38d5b3d0e8493401d475bpull/9012/head
parent
368c2218ec
commit
81722df0ab
|
@ -14,53 +14,49 @@
|
||||||
|
|
||||||
/* global app */
|
/* global app */
|
||||||
|
|
||||||
|
// TODO: duplicate from MessageRouter
|
||||||
|
interface WidgetJSON {
|
||||||
|
id: string; // unique id of a widget
|
||||||
|
type: string; // type of widget
|
||||||
|
enabled: boolean | undefined; // enabled state
|
||||||
|
visible: boolean | undefined; // visibility state
|
||||||
|
children: Array<WidgetJSON> | undefined; // child nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
interface JSDialogJSON extends WidgetJSON {
|
||||||
|
id: string; // unique windowId
|
||||||
|
jsontype: string; // specifies target componenet, on root level only
|
||||||
|
action: string | undefined; // optional name of an action
|
||||||
|
control?: WidgetJSON;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PopupData extends JSDialogJSON {
|
||||||
|
isMention?: boolean;
|
||||||
|
cancellable?: boolean;
|
||||||
|
popupParent?: string;
|
||||||
|
clickToClose?: string;
|
||||||
|
posx: number;
|
||||||
|
posy: number;
|
||||||
|
}
|
||||||
|
|
||||||
interface Entry {
|
interface Entry {
|
||||||
text: string;
|
text: string;
|
||||||
columns: { text: any }[];
|
columns: { text: any }[];
|
||||||
row: string;
|
row: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Control {
|
interface MentionWidget extends WidgetJSON {
|
||||||
id: string;
|
|
||||||
type: string;
|
|
||||||
text: string;
|
text: string;
|
||||||
enabled: boolean;
|
|
||||||
singleclickactivate: boolean;
|
singleclickactivate: boolean;
|
||||||
fireKeyEvents: boolean;
|
fireKeyEvents: boolean;
|
||||||
entries: Array<Entry>;
|
entries: Array<Entry>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Children {
|
interface FireEvent {
|
||||||
id: string;
|
data?: any
|
||||||
type: string;
|
|
||||||
text: string;
|
|
||||||
enabled: boolean;
|
|
||||||
children: Array<Control>;
|
|
||||||
vertical: boolean;
|
|
||||||
}
|
}
|
||||||
|
interface CloseMessageEvent extends FireEvent {
|
||||||
interface Data {
|
typingMention?: boolean;
|
||||||
jsontype: string;
|
|
||||||
id: string;
|
|
||||||
control: Control;
|
|
||||||
posx: number;
|
|
||||||
posy: number;
|
|
||||||
children: Array<Children>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PopupData {
|
|
||||||
children: Children;
|
|
||||||
jsontype: string;
|
|
||||||
type: string;
|
|
||||||
isMention: boolean;
|
|
||||||
cancellable: boolean;
|
|
||||||
popupParent: string;
|
|
||||||
clickToClose: string;
|
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MessageEvent2 extends MessageEvent {
|
|
||||||
typingMention: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Mention {
|
class Mention {
|
||||||
|
@ -77,14 +73,15 @@ class Mention {
|
||||||
this.map.on('closementionpopup', this.closeMentionPopup, this);
|
this.map.on('closementionpopup', this.closeMentionPopup, this);
|
||||||
this.map.on('sendmentiontext', this.sendMentionText, this);
|
this.map.on('sendmentiontext', this.sendMentionText, this);
|
||||||
this.newPopupData = {
|
this.newPopupData = {
|
||||||
children: {
|
children: [
|
||||||
id: 'container',
|
{
|
||||||
type: 'container',
|
id: 'container',
|
||||||
text: '',
|
type: 'container',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
children: [],
|
children: new Array<WidgetJSON>(),
|
||||||
vertical: true,
|
vertical: true,
|
||||||
},
|
} as any as WidgetJSON
|
||||||
|
] as Array<WidgetJSON>,
|
||||||
jsontype: 'dialog',
|
jsontype: 'dialog',
|
||||||
type: 'modalpopup',
|
type: 'modalpopup',
|
||||||
isMention: true,
|
isMention: true,
|
||||||
|
@ -92,13 +89,13 @@ class Mention {
|
||||||
popupParent: '_POPOVER_',
|
popupParent: '_POPOVER_',
|
||||||
clickToClose: '_POPOVER_',
|
clickToClose: '_POPOVER_',
|
||||||
id: 'mentionPopup',
|
id: 'mentionPopup',
|
||||||
};
|
} as PopupData;
|
||||||
this.firstChar = null;
|
this.firstChar = null;
|
||||||
this.users = null;
|
this.users = null;
|
||||||
this.itemList = null;
|
this.itemList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMentionText(ev: MessageEvent) {
|
sendMentionText(ev: FireEvent) {
|
||||||
var text = ev.data.join('').substring(1);
|
var text = ev.data.join('').substring(1);
|
||||||
if (text.length === 1 && this.firstChar !== text[0]) {
|
if (text.length === 1 && this.firstChar !== text[0]) {
|
||||||
this.map.fire('postMessage', {
|
this.map.fire('postMessage', {
|
||||||
|
@ -124,7 +121,7 @@ class Mention {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
openMentionPopup(ev: MessageEvent) {
|
openMentionPopup(ev: FireEvent) {
|
||||||
var framePos = this.getCurrentCursorPosition();
|
var framePos = this.getCurrentCursorPosition();
|
||||||
this.users = ev.data;
|
this.users = ev.data;
|
||||||
if (this.users === null) return;
|
if (this.users === null) return;
|
||||||
|
@ -155,27 +152,27 @@ class Mention {
|
||||||
entries.push(entry);
|
entries.push(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
var data: Data;
|
var data: PopupData;
|
||||||
var control: Control = {
|
const control = {
|
||||||
id: 'mentionList',
|
id: 'mentionList',
|
||||||
type: 'treelistbox',
|
type: 'treelistbox',
|
||||||
text: '',
|
text: '',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
singleclickactivate: false,
|
singleclickactivate: false,
|
||||||
fireKeyEvents: true,
|
fireKeyEvents: true,
|
||||||
entries: [],
|
entries: [] as Array<Entry>,
|
||||||
};
|
} as MentionWidget;
|
||||||
// update the popup with list if mentionList already exist
|
// update the popup with list if mentionList already exist
|
||||||
if (L.DomUtil.get('mentionList')) {
|
if (L.DomUtil.get('mentionList')) {
|
||||||
data = {
|
data = {
|
||||||
jsontype: 'dialog',
|
jsontype: 'dialog',
|
||||||
id: 'mentionPopup',
|
id: 'mentionPopup',
|
||||||
|
action: 'update',
|
||||||
control: control,
|
control: control,
|
||||||
posx: framePos.x,
|
posx: framePos.x,
|
||||||
posy: framePos.y,
|
posy: framePos.y,
|
||||||
children: undefined,
|
} as any as PopupData;
|
||||||
};
|
(data.control as MentionWidget).entries = entries;
|
||||||
data.control.entries = entries;
|
|
||||||
this.map.fire('jsdialogupdate', {
|
this.map.fire('jsdialogupdate', {
|
||||||
data: data,
|
data: data,
|
||||||
callback: this.callback.bind(this),
|
callback: this.callback.bind(this),
|
||||||
|
@ -183,29 +180,29 @@ class Mention {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (L.DomUtil.get('mentionPopup'))
|
if (L.DomUtil.get('mentionPopup'))
|
||||||
this.closeMentionPopup({ typingMention: true });
|
this.closeMentionPopup({ typingMention: true } as CloseMessageEvent);
|
||||||
data = this.newPopupData;
|
data = this.newPopupData;
|
||||||
data.children[0].children[0] = control;
|
data.children[0].children[0] = control;
|
||||||
data.children[0].children[0].entries = entries;
|
(data.children[0].children[0] as MentionWidget).entries = entries;
|
||||||
} else {
|
} else {
|
||||||
var control: Control = {
|
const control = {
|
||||||
id: 'fixedtext',
|
id: 'fixedtext',
|
||||||
type: 'fixedtext',
|
type: 'fixedtext',
|
||||||
text: 'no search results found!',
|
text: 'no search results found!',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
singleclickactivate: undefined,
|
singleclickactivate: undefined,
|
||||||
fireKeyEvents: undefined,
|
fireKeyEvents: undefined,
|
||||||
entries: undefined,
|
} as MentionWidget;
|
||||||
};
|
|
||||||
if (L.DomUtil.get('fixedtext')) {
|
if (L.DomUtil.get('fixedtext')) {
|
||||||
data = {
|
data = {
|
||||||
jsontype: 'dialog',
|
jsontype: 'dialog',
|
||||||
id: 'mentionPopup',
|
id: 'mentionPopup',
|
||||||
|
action: 'update',
|
||||||
control: control,
|
control: control,
|
||||||
posx: framePos.x,
|
posx: framePos.x,
|
||||||
posy: framePos.y,
|
posy: framePos.y,
|
||||||
children: undefined,
|
children: undefined,
|
||||||
};
|
} as any as PopupData;
|
||||||
this.map.fire('jsdialogupdate', {
|
this.map.fire('jsdialogupdate', {
|
||||||
data: data,
|
data: data,
|
||||||
callback: this.callback.bind(this),
|
callback: this.callback.bind(this),
|
||||||
|
@ -213,7 +210,7 @@ class Mention {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (L.DomUtil.get('mentionPopup'))
|
if (L.DomUtil.get('mentionPopup'))
|
||||||
this.closeMentionPopup({ typingMention: true });
|
this.closeMentionPopup({ typingMention: true } as CloseMessageEvent);
|
||||||
data = this.newPopupData;
|
data = this.newPopupData;
|
||||||
data.children[0].children[0] = control;
|
data.children[0].children[0] = control;
|
||||||
}
|
}
|
||||||
|
@ -226,13 +223,13 @@ class Mention {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
closeMentionPopup(ev: MessageEvent) {
|
closeMentionPopup(ev: CloseMessageEvent) {
|
||||||
var closePopupData = {
|
var closePopupData = {
|
||||||
jsontype: 'dialog',
|
jsontype: 'dialog',
|
||||||
type: 'modalpopup',
|
type: 'modalpopup',
|
||||||
action: 'close',
|
action: 'close',
|
||||||
id: 'mentionPopup',
|
id: 'mentionPopup',
|
||||||
};
|
} as PopupData;
|
||||||
this.map.fire('jsdialog', { data: closePopupData, callback: undefined });
|
this.map.fire('jsdialog', { data: closePopupData, callback: undefined });
|
||||||
if (!ev.typingMention) {
|
if (!ev.typingMention) {
|
||||||
this.map._docLayer._typingMention = false;
|
this.map._docLayer._typingMention = false;
|
||||||
|
@ -242,7 +239,7 @@ class Mention {
|
||||||
|
|
||||||
callback(objectType: any, eventType: any, object: any, index: number) {
|
callback(objectType: any, eventType: any, object: any, index: number) {
|
||||||
if (eventType === 'close') {
|
if (eventType === 'close') {
|
||||||
this.closeMentionPopup({ typingMention: false });
|
this.closeMentionPopup({ typingMention: false } as CloseMessageEvent);
|
||||||
} else if (eventType === 'select' || eventType === 'activate') {
|
} else if (eventType === 'select' || eventType === 'activate') {
|
||||||
var command = {
|
var command = {
|
||||||
'Hyperlink.Text': {
|
'Hyperlink.Text': {
|
||||||
|
@ -263,7 +260,7 @@ class Mention {
|
||||||
msgId: 'UI_Mention',
|
msgId: 'UI_Mention',
|
||||||
args: { type: 'selected', username: this.itemList[index].username },
|
args: { type: 'selected', username: this.itemList[index].username },
|
||||||
});
|
});
|
||||||
this.closeMentionPopup({ typingMention: false });
|
this.closeMentionPopup({ typingMention: false } as CloseMessageEvent);
|
||||||
} else if (eventType === 'keydown') {
|
} else if (eventType === 'keydown') {
|
||||||
if (object.key !== 'Tab' && object.key !== 'Shift') {
|
if (object.key !== 'Tab' && object.key !== 'Shift') {
|
||||||
this.map.focus();
|
this.map.focus();
|
||||||
|
|
|
@ -20,7 +20,7 @@ interface WidgetJSON {
|
||||||
type: string; // type of widget
|
type: string; // type of widget
|
||||||
enabled: boolean | undefined; // enabled state
|
enabled: boolean | undefined; // enabled state
|
||||||
visible: boolean | undefined; // visibility state
|
visible: boolean | undefined; // visibility state
|
||||||
children: Array<JSDialogJSON> | undefined; // child nodes
|
children: Array<WidgetJSON> | undefined; // child nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
interface JSDialogJSON extends WidgetJSON {
|
interface JSDialogJSON extends WidgetJSON {
|
||||||
|
@ -39,7 +39,7 @@ type JSDialogCallback = (
|
||||||
|
|
||||||
class JSDialogMessageRouter {
|
class JSDialogMessageRouter {
|
||||||
// show labels instead of editable fields in message boxes
|
// show labels instead of editable fields in message boxes
|
||||||
private _preProcessMessageDialog(msgData: JSDialogJSON) {
|
private _preProcessMessageDialog(msgData: WidgetJSON) {
|
||||||
for (var i in msgData.children) {
|
for (var i in msgData.children) {
|
||||||
var child = msgData.children[i];
|
var child = msgData.children[i];
|
||||||
if (child.type === 'multilineedit') child.type = 'fixedtext';
|
if (child.type === 'multilineedit') child.type = 'fixedtext';
|
||||||
|
|
Loading…
Reference in New Issue