@fiduswriter/frontend 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +66 -0
- package/dist/admin_console/index.d.ts +8 -0
- package/dist/admin_console/index.d.ts.map +1 -0
- package/dist/admin_console/index.js +54 -0
- package/dist/admin_console/index.js.map +1 -0
- package/dist/api/index.d.ts +193 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +6 -0
- package/dist/api/index.js.map +1 -0
- package/dist/app/index.d.ts +74 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/index.js +471 -0
- package/dist/app/index.js.map +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +3 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/templates.d.ts +3 -0
- package/dist/common/templates.d.ts.map +1 -0
- package/dist/common/templates.js +42 -0
- package/dist/common/templates.js.map +1 -0
- package/dist/common/user_util.d.ts +6 -0
- package/dist/common/user_util.d.ts.map +1 -0
- package/dist/common/user_util.js +16 -0
- package/dist/common/user_util.js.map +1 -0
- package/dist/document_templates/actions.d.ts +11 -0
- package/dist/document_templates/actions.d.ts.map +1 -0
- package/dist/document_templates/actions.js +141 -0
- package/dist/document_templates/actions.js.map +1 -0
- package/dist/document_templates/editor.d.ts +28 -0
- package/dist/document_templates/editor.d.ts.map +1 -0
- package/dist/document_templates/editor.js +139 -0
- package/dist/document_templates/editor.js.map +1 -0
- package/dist/document_templates/index.d.ts +3 -0
- package/dist/document_templates/index.d.ts.map +1 -0
- package/dist/document_templates/index.js +3 -0
- package/dist/document_templates/index.js.map +1 -0
- package/dist/document_templates/menu.d.ts +7 -0
- package/dist/document_templates/menu.d.ts.map +1 -0
- package/dist/document_templates/menu.js +62 -0
- package/dist/document_templates/menu.js.map +1 -0
- package/dist/document_templates/overview.d.ts +52 -0
- package/dist/document_templates/overview.d.ts.map +1 -0
- package/dist/document_templates/overview.js +274 -0
- package/dist/document_templates/overview.js.map +1 -0
- package/dist/document_templates/templates.d.ts +3 -0
- package/dist/document_templates/templates.d.ts.map +1 -0
- package/dist/document_templates/templates.js +9 -0
- package/dist/document_templates/templates.js.map +1 -0
- package/dist/documents/importer/docx/import.d.ts +5 -0
- package/dist/documents/importer/docx/import.d.ts.map +1 -0
- package/dist/documents/importer/docx/import.js +15 -0
- package/dist/documents/importer/docx/import.js.map +1 -0
- package/dist/documents/importer/docx/index.d.ts +2 -0
- package/dist/documents/importer/docx/index.d.ts.map +1 -0
- package/dist/documents/importer/docx/index.js +2 -0
- package/dist/documents/importer/docx/index.js.map +1 -0
- package/dist/documents/importer/native/file.d.ts +7 -0
- package/dist/documents/importer/native/file.d.ts.map +1 -0
- package/dist/documents/importer/native/file.js +60 -0
- package/dist/documents/importer/native/file.js.map +1 -0
- package/dist/documents/importer/native/import.d.ts +41 -0
- package/dist/documents/importer/native/import.d.ts.map +1 -0
- package/dist/documents/importer/native/import.js +126 -0
- package/dist/documents/importer/native/import.js.map +1 -0
- package/dist/documents/importer/native/index.d.ts +3 -0
- package/dist/documents/importer/native/index.d.ts.map +1 -0
- package/dist/documents/importer/native/index.js +3 -0
- package/dist/documents/importer/native/index.js.map +1 -0
- package/dist/documents/importer/odt/import.d.ts +5 -0
- package/dist/documents/importer/odt/import.d.ts.map +1 -0
- package/dist/documents/importer/odt/import.js +16 -0
- package/dist/documents/importer/odt/import.js.map +1 -0
- package/dist/documents/importer/odt/index.d.ts +2 -0
- package/dist/documents/importer/odt/index.d.ts.map +1 -0
- package/dist/documents/importer/odt/index.js +2 -0
- package/dist/documents/importer/odt/index.js.map +1 -0
- package/dist/documents/importer/pandoc/import.d.ts +5 -0
- package/dist/documents/importer/pandoc/import.d.ts.map +1 -0
- package/dist/documents/importer/pandoc/import.js +37 -0
- package/dist/documents/importer/pandoc/import.js.map +1 -0
- package/dist/documents/importer/pandoc/index.d.ts +2 -0
- package/dist/documents/importer/pandoc/index.d.ts.map +1 -0
- package/dist/documents/importer/pandoc/index.js +2 -0
- package/dist/documents/importer/pandoc/index.js.map +1 -0
- package/dist/documents/importer/register.d.ts +4 -0
- package/dist/documents/importer/register.d.ts.map +1 -0
- package/dist/documents/importer/register.js +4 -0
- package/dist/documents/importer/register.js.map +1 -0
- package/dist/documents/overview/actions.d.ts +32 -0
- package/dist/documents/overview/actions.d.ts.map +1 -0
- package/dist/documents/overview/actions.js +725 -0
- package/dist/documents/overview/actions.js.map +1 -0
- package/dist/documents/overview/index.d.ts +98 -0
- package/dist/documents/overview/index.d.ts.map +1 -0
- package/dist/documents/overview/index.js +814 -0
- package/dist/documents/overview/index.js.map +1 -0
- package/dist/documents/overview/menu.d.ts +28 -0
- package/dist/documents/overview/menu.d.ts.map +1 -0
- package/dist/documents/overview/menu.js +222 -0
- package/dist/documents/overview/menu.js.map +1 -0
- package/dist/documents/overview/templates.d.ts +31 -0
- package/dist/documents/overview/templates.d.ts.map +1 -0
- package/dist/documents/overview/templates.js +39 -0
- package/dist/documents/overview/templates.js.map +1 -0
- package/dist/documents/revisions/index.d.ts +14 -0
- package/dist/documents/revisions/index.d.ts.map +1 -0
- package/dist/documents/revisions/index.js +143 -0
- package/dist/documents/revisions/index.js.map +1 -0
- package/dist/documents/revisions/templates.d.ts +4 -0
- package/dist/documents/revisions/templates.d.ts.map +1 -0
- package/dist/documents/revisions/templates.js +36 -0
- package/dist/documents/revisions/templates.js.map +1 -0
- package/dist/documents/tools.d.ts +16 -0
- package/dist/documents/tools.d.ts.map +1 -0
- package/dist/documents/tools.js +69 -0
- package/dist/documents/tools.js.map +1 -0
- package/dist/error_hook/index.d.ts +19 -0
- package/dist/error_hook/index.d.ts.map +1 -0
- package/dist/error_hook/index.js +75 -0
- package/dist/error_hook/index.js.map +1 -0
- package/dist/feedback/index.d.ts +12 -0
- package/dist/feedback/index.d.ts.map +1 -0
- package/dist/feedback/index.js +125 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/indexed_db/index.d.ts +24 -0
- package/dist/indexed_db/index.d.ts.map +1 -0
- package/dist/indexed_db/index.js +175 -0
- package/dist/indexed_db/index.js.map +1 -0
- package/dist/maintenance/index.d.ts +19 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +223 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/menu/index.d.ts +25 -0
- package/dist/menu/index.d.ts.map +1 -0
- package/dist/menu/index.js +229 -0
- package/dist/menu/index.js.map +1 -0
- package/dist/menu/templates.d.ts +6 -0
- package/dist/menu/templates.d.ts.map +1 -0
- package/dist/menu/templates.js +10 -0
- package/dist/menu/templates.js.map +1 -0
- package/dist/pages/404.d.ts +9 -0
- package/dist/pages/404.d.ts.map +1 -0
- package/dist/pages/404.js +12 -0
- package/dist/pages/404.js.map +1 -0
- package/dist/pages/flatpage.d.ts +12 -0
- package/dist/pages/flatpage.d.ts.map +1 -0
- package/dist/pages/flatpage.js +39 -0
- package/dist/pages/flatpage.js.map +1 -0
- package/dist/pages/offline.d.ts +10 -0
- package/dist/pages/offline.d.ts.map +1 -0
- package/dist/pages/offline.js +27 -0
- package/dist/pages/offline.js.map +1 -0
- package/dist/pages/setup.d.ts +10 -0
- package/dist/pages/setup.d.ts.map +1 -0
- package/dist/pages/setup.js +22 -0
- package/dist/pages/setup.js.map +1 -0
- package/dist/plugins/menu/index.d.ts +3 -0
- package/dist/plugins/menu/index.d.ts.map +1 -0
- package/dist/plugins/menu/index.js +2 -0
- package/dist/plugins/menu/index.js.map +1 -0
- package/dist/prelogin/index.d.ts +51 -0
- package/dist/prelogin/index.d.ts.map +1 -0
- package/dist/prelogin/index.js +131 -0
- package/dist/prelogin/index.js.map +1 -0
- package/dist/prelogin/templates.d.ts +20 -0
- package/dist/prelogin/templates.d.ts.map +1 -0
- package/dist/prelogin/templates.js +50 -0
- package/dist/prelogin/templates.js.map +1 -0
- package/dist/state_plugins/contributor_input/add_button.d.ts +22 -0
- package/dist/state_plugins/contributor_input/add_button.d.ts.map +1 -0
- package/dist/state_plugins/contributor_input/add_button.js +106 -0
- package/dist/state_plugins/contributor_input/add_button.js.map +1 -0
- package/dist/state_plugins/contributor_input/helpers.d.ts +3 -0
- package/dist/state_plugins/contributor_input/helpers.d.ts.map +1 -0
- package/dist/state_plugins/contributor_input/helpers.js +23 -0
- package/dist/state_plugins/contributor_input/helpers.js.map +1 -0
- package/dist/state_plugins/contributor_input/index.d.ts +4 -0
- package/dist/state_plugins/contributor_input/index.d.ts.map +1 -0
- package/dist/state_plugins/contributor_input/index.js +4 -0
- package/dist/state_plugins/contributor_input/index.js.map +1 -0
- package/dist/state_plugins/contributor_input/node_view.d.ts +20 -0
- package/dist/state_plugins/contributor_input/node_view.d.ts.map +1 -0
- package/dist/state_plugins/contributor_input/node_view.js +85 -0
- package/dist/state_plugins/contributor_input/node_view.js.map +1 -0
- package/dist/state_plugins/index.d.ts +3 -0
- package/dist/state_plugins/index.d.ts.map +1 -0
- package/dist/state_plugins/index.js +3 -0
- package/dist/state_plugins/index.js.map +1 -0
- package/dist/state_plugins/tag_input/helpers.d.ts +5 -0
- package/dist/state_plugins/tag_input/helpers.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/helpers.js +55 -0
- package/dist/state_plugins/tag_input/helpers.js.map +1 -0
- package/dist/state_plugins/tag_input/index.d.ts +5 -0
- package/dist/state_plugins/tag_input/index.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/index.js +5 -0
- package/dist/state_plugins/tag_input/index.js.map +1 -0
- package/dist/state_plugins/tag_input/node_view.d.ts +19 -0
- package/dist/state_plugins/tag_input/node_view.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/node_view.js +85 -0
- package/dist/state_plugins/tag_input/node_view.js.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor.d.ts +4 -0
- package/dist/state_plugins/tag_input/tag_editor.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor.js +160 -0
- package/dist/state_plugins/tag_input/tag_editor.js.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.d.ts +5 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.d.ts.map +1 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.js +64 -0
- package/dist/state_plugins/tag_input/tag_editor_plugins.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/user/auth/email_confirm.d.ts +23 -0
- package/dist/user/auth/email_confirm.d.ts.map +1 -0
- package/dist/user/auth/email_confirm.js +123 -0
- package/dist/user/auth/email_confirm.js.map +1 -0
- package/dist/user/auth/email_confirm_templates.d.ts +12 -0
- package/dist/user/auth/email_confirm_templates.d.ts.map +1 -0
- package/dist/user/auth/email_confirm_templates.js +30 -0
- package/dist/user/auth/email_confirm_templates.js.map +1 -0
- package/dist/user/auth/login.d.ts +13 -0
- package/dist/user/auth/login.d.ts.map +1 -0
- package/dist/user/auth/login.js +186 -0
- package/dist/user/auth/login.js.map +1 -0
- package/dist/user/auth/password_reset_change.d.ts +11 -0
- package/dist/user/auth/password_reset_change.d.ts.map +1 -0
- package/dist/user/auth/password_reset_change.js +101 -0
- package/dist/user/auth/password_reset_change.js.map +1 -0
- package/dist/user/auth/password_reset_request.d.ts +10 -0
- package/dist/user/auth/password_reset_request.d.ts.map +1 -0
- package/dist/user/auth/password_reset_request.js +82 -0
- package/dist/user/auth/password_reset_request.js.map +1 -0
- package/dist/user/auth/signup.d.ts +9 -0
- package/dist/user/auth/signup.d.ts.map +1 -0
- package/dist/user/auth/signup.js +148 -0
- package/dist/user/auth/signup.js.map +1 -0
- package/dist/user/auth/two_factor.d.ts +10 -0
- package/dist/user/auth/two_factor.d.ts.map +1 -0
- package/dist/user/auth/two_factor.js +201 -0
- package/dist/user/auth/two_factor.js.map +1 -0
- package/dist/user/contacts/add_dialog.d.ts +7 -0
- package/dist/user/contacts/add_dialog.d.ts.map +1 -0
- package/dist/user/contacts/add_dialog.js +84 -0
- package/dist/user/contacts/add_dialog.js.map +1 -0
- package/dist/user/contacts/delete_dialog.d.ts +6 -0
- package/dist/user/contacts/delete_dialog.d.ts.map +1 -0
- package/dist/user/contacts/delete_dialog.js +38 -0
- package/dist/user/contacts/delete_dialog.js.map +1 -0
- package/dist/user/contacts/index.d.ts +35 -0
- package/dist/user/contacts/index.d.ts.map +1 -0
- package/dist/user/contacts/index.js +234 -0
- package/dist/user/contacts/index.js.map +1 -0
- package/dist/user/contacts/invite.d.ts +9 -0
- package/dist/user/contacts/invite.d.ts.map +1 -0
- package/dist/user/contacts/invite.js +21 -0
- package/dist/user/contacts/invite.js.map +1 -0
- package/dist/user/contacts/menu.d.ts +7 -0
- package/dist/user/contacts/menu.d.ts.map +1 -0
- package/dist/user/contacts/menu.js +62 -0
- package/dist/user/contacts/menu.js.map +1 -0
- package/dist/user/contacts/respond_invite.d.ts +9 -0
- package/dist/user/contacts/respond_invite.d.ts.map +1 -0
- package/dist/user/contacts/respond_invite.js +65 -0
- package/dist/user/contacts/respond_invite.js.map +1 -0
- package/dist/user/contacts/templates.d.ts +7 -0
- package/dist/user/contacts/templates.d.ts.map +1 -0
- package/dist/user/contacts/templates.js +24 -0
- package/dist/user/contacts/templates.js.map +1 -0
- package/dist/user/profile/delete_user.d.ts +8 -0
- package/dist/user/profile/delete_user.d.ts.map +1 -0
- package/dist/user/profile/delete_user.js +56 -0
- package/dist/user/profile/delete_user.js.map +1 -0
- package/dist/user/profile/dialogs.d.ts +10 -0
- package/dist/user/profile/dialogs.d.ts.map +1 -0
- package/dist/user/profile/dialogs.js +311 -0
- package/dist/user/profile/dialogs.js.map +1 -0
- package/dist/user/profile/index.d.ts +27 -0
- package/dist/user/profile/index.d.ts.map +1 -0
- package/dist/user/profile/index.js +254 -0
- package/dist/user/profile/index.js.map +1 -0
- package/dist/user/profile/templates.d.ts +22 -0
- package/dist/user/profile/templates.d.ts.map +1 -0
- package/dist/user/profile/templates.js +261 -0
- package/dist/user/profile/templates.js.map +1 -0
- package/dist/workers/adjust_doc_to_template.d.ts +11 -0
- package/dist/workers/adjust_doc_to_template.d.ts.map +1 -0
- package/dist/workers/adjust_doc_to_template.js +26 -0
- package/dist/workers/adjust_doc_to_template.js.map +1 -0
- package/package.json +225 -0
- package/src/admin_console/index.ts +84 -0
- package/src/api/index.ts +149 -0
- package/src/app/index.ts +605 -0
- package/src/common/index.ts +2 -0
- package/src/common/templates.ts +49 -0
- package/src/common/user_util.ts +16 -0
- package/src/document_templates/actions.ts +179 -0
- package/src/document_templates/editor.ts +177 -0
- package/src/document_templates/index.ts +2 -0
- package/src/document_templates/menu.ts +74 -0
- package/src/document_templates/overview.ts +335 -0
- package/src/document_templates/templates.ts +9 -0
- package/src/documents/importer/docx/import.ts +25 -0
- package/src/documents/importer/docx/index.ts +1 -0
- package/src/documents/importer/native/file.ts +112 -0
- package/src/documents/importer/native/import.ts +219 -0
- package/src/documents/importer/native/index.ts +2 -0
- package/src/documents/importer/odt/import.ts +26 -0
- package/src/documents/importer/odt/index.ts +1 -0
- package/src/documents/importer/pandoc/import.ts +57 -0
- package/src/documents/importer/pandoc/index.ts +1 -0
- package/src/documents/importer/register.ts +8 -0
- package/src/documents/overview/actions.ts +1031 -0
- package/src/documents/overview/index.ts +1006 -0
- package/src/documents/overview/menu.ts +311 -0
- package/src/documents/overview/templates.ts +64 -0
- package/src/documents/revisions/index.ts +183 -0
- package/src/documents/revisions/templates.ts +42 -0
- package/src/documents/tools.ts +107 -0
- package/src/error_hook/index.ts +129 -0
- package/src/feedback/index.ts +185 -0
- package/src/global.d.ts +22 -0
- package/src/index.ts +95 -0
- package/src/indexed_db/index.ts +217 -0
- package/src/maintenance/index.ts +258 -0
- package/src/menu/index.ts +267 -0
- package/src/menu/templates.ts +21 -0
- package/src/pages/404.ts +13 -0
- package/src/pages/flatpage.ts +43 -0
- package/src/pages/offline.ts +39 -0
- package/src/pages/setup.ts +34 -0
- package/src/plugins/menu/index.ts +3 -0
- package/src/prelogin/index.ts +175 -0
- package/src/prelogin/templates.ts +86 -0
- package/src/types.ts +63 -0
- package/src/user/auth/email_confirm.ts +153 -0
- package/src/user/auth/email_confirm_templates.ts +76 -0
- package/src/user/auth/login.ts +221 -0
- package/src/user/auth/password_reset_change.ts +120 -0
- package/src/user/auth/password_reset_request.ts +107 -0
- package/src/user/auth/signup.ts +182 -0
- package/src/user/auth/two_factor.ts +244 -0
- package/src/user/contacts/add_dialog.ts +104 -0
- package/src/user/contacts/delete_dialog.ts +40 -0
- package/src/user/contacts/index.ts +289 -0
- package/src/user/contacts/invite.ts +24 -0
- package/src/user/contacts/menu.ts +70 -0
- package/src/user/contacts/respond_invite.ts +76 -0
- package/src/user/contacts/templates.ts +29 -0
- package/src/user/profile/delete_user.ts +71 -0
- package/src/user/profile/dialogs.ts +363 -0
- package/src/user/profile/index.ts +359 -0
- package/src/user/profile/templates.ts +299 -0
- package/src/workers/adjust_doc_to_template.ts +41 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import deepEqual from "fast-deep-equal"
|
|
2
|
+
|
|
3
|
+
import {baseBodyTemplate} from "../../common/index.js"
|
|
4
|
+
import {FeedbackTab} from "../../feedback/index.js"
|
|
5
|
+
import {SiteMenu} from "../../menu/index.js"
|
|
6
|
+
import {
|
|
7
|
+
OverviewDataTable,
|
|
8
|
+
OverviewMenuView,
|
|
9
|
+
addAlert,
|
|
10
|
+
avatarTemplate,
|
|
11
|
+
escapeText,
|
|
12
|
+
findTarget,
|
|
13
|
+
postJson,
|
|
14
|
+
setDocTitle,
|
|
15
|
+
whenReady
|
|
16
|
+
} from "fwtoolkit"
|
|
17
|
+
import {DeleteContactDialog} from "./delete_dialog.js"
|
|
18
|
+
import {bulkMenuModel, menuModel} from "./menu.js"
|
|
19
|
+
import {RespondInviteDialog} from "./respond_invite.js"
|
|
20
|
+
import {
|
|
21
|
+
deleteContactCell,
|
|
22
|
+
displayContactType,
|
|
23
|
+
respondInviteCell
|
|
24
|
+
} from "./templates.js"
|
|
25
|
+
|
|
26
|
+
export class ContactsOverview {
|
|
27
|
+
app: any
|
|
28
|
+
user: Record<string, unknown>
|
|
29
|
+
contacts: Array<Record<string, unknown>>
|
|
30
|
+
lastSort: {column: number; dir: string}
|
|
31
|
+
dom!: HTMLElement
|
|
32
|
+
table: any
|
|
33
|
+
overviewTable: any
|
|
34
|
+
dtBulk: any
|
|
35
|
+
menu: any
|
|
36
|
+
|
|
37
|
+
constructor({app, user}: {app: any; user: Record<string, unknown>}) {
|
|
38
|
+
this.app = app
|
|
39
|
+
this.user = user
|
|
40
|
+
this.contacts = []
|
|
41
|
+
this.lastSort = {column: 0, dir: "asc"}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
init(): Promise<void> {
|
|
45
|
+
return whenReady().then(() => {
|
|
46
|
+
this.render()
|
|
47
|
+
const smenu = new SiteMenu(this.app, "")
|
|
48
|
+
smenu.init()
|
|
49
|
+
this.menu = new OverviewMenuView(this, menuModel as any)
|
|
50
|
+
this.menu.init()
|
|
51
|
+
this.bind()
|
|
52
|
+
this.getList()
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
render(): void {
|
|
57
|
+
this.dom = document.createElement("body")
|
|
58
|
+
this.dom.innerHTML = baseBodyTemplate({
|
|
59
|
+
contents: "",
|
|
60
|
+
user: this.user as any,
|
|
61
|
+
hasOverview: true,
|
|
62
|
+
app: this.app
|
|
63
|
+
})
|
|
64
|
+
document.body = this.dom
|
|
65
|
+
setDocTitle(gettext("Contacts"), this.app)
|
|
66
|
+
const feedbackTab = new FeedbackTab()
|
|
67
|
+
feedbackTab.init()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
initTable(searching = false): void {
|
|
71
|
+
if (this.overviewTable) {
|
|
72
|
+
this.overviewTable.destroy()
|
|
73
|
+
this.overviewTable = null
|
|
74
|
+
}
|
|
75
|
+
this.table = null
|
|
76
|
+
this.dtBulk = null
|
|
77
|
+
|
|
78
|
+
const contentsEl = document.querySelector(".fw-contents") as HTMLElement
|
|
79
|
+
contentsEl.innerHTML = ""
|
|
80
|
+
|
|
81
|
+
this.overviewTable = new OverviewDataTable({
|
|
82
|
+
dom: contentsEl,
|
|
83
|
+
classes: ["fw-data-table", "fw-large", "contacts-table"],
|
|
84
|
+
columns: [
|
|
85
|
+
{select: 0, hidden: true, type: "number"},
|
|
86
|
+
{select: 1, hidden: true, type: "string"},
|
|
87
|
+
{select: 2, type: "boolean"},
|
|
88
|
+
{select: [2, 6], sortable: false},
|
|
89
|
+
{select: [this.lastSort.column], sort: this.lastSort.dir}
|
|
90
|
+
],
|
|
91
|
+
data: this.contacts.map(contact => this.createTableRow(contact)),
|
|
92
|
+
idColumn: 0,
|
|
93
|
+
checkboxColumn: 2,
|
|
94
|
+
bulkMenu: bulkMenuModel(),
|
|
95
|
+
bulkMenuPage: this,
|
|
96
|
+
searchable: searching,
|
|
97
|
+
scrollY: `${Math.max(window.innerHeight - 360, 100)}px`,
|
|
98
|
+
tabIndex: 1,
|
|
99
|
+
labels: {
|
|
100
|
+
noRows: gettext("No contacts available"),
|
|
101
|
+
noResults: gettext("No contacts found")
|
|
102
|
+
},
|
|
103
|
+
headings: [
|
|
104
|
+
"", "", "",
|
|
105
|
+
gettext("Name"),
|
|
106
|
+
gettext("Type"),
|
|
107
|
+
gettext("Email address"),
|
|
108
|
+
""
|
|
109
|
+
],
|
|
110
|
+
template: (options: any, _dom: any) =>
|
|
111
|
+
`<div class='${options.classes.container}'style='height: ${options.scrollY}; overflow-Y: auto;'></div>`,
|
|
112
|
+
rowRender: (row: any, tr: any, _index: number) => {
|
|
113
|
+
const id = row.cells[0].data
|
|
114
|
+
const contactType = row.cells[1].data
|
|
115
|
+
const inputNode: any = {
|
|
116
|
+
nodeName: "input",
|
|
117
|
+
attributes: {
|
|
118
|
+
type: "checkbox",
|
|
119
|
+
class: `entry-select fw-check ${contactType}`,
|
|
120
|
+
"data-id": id,
|
|
121
|
+
"data-type": contactType,
|
|
122
|
+
id: `contact-${contactType}-${id}`
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (row.cells[2].data) {
|
|
126
|
+
inputNode.attributes.checked = true
|
|
127
|
+
}
|
|
128
|
+
tr.childNodes[0].childNodes = [
|
|
129
|
+
inputNode,
|
|
130
|
+
{
|
|
131
|
+
nodeName: "label",
|
|
132
|
+
attributes: {for: `contact-${contactType}-${id}`}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
onDelete: (row: any) => {
|
|
137
|
+
const id = row.cells[0].data
|
|
138
|
+
const type = row.cells[1].data
|
|
139
|
+
this.deleteContact(id, type)
|
|
140
|
+
}
|
|
141
|
+
} as any)
|
|
142
|
+
this.overviewTable.init()
|
|
143
|
+
this.table = this.overviewTable.table
|
|
144
|
+
this.dtBulk = this.overviewTable.dtBulk
|
|
145
|
+
|
|
146
|
+
this.table.on("datatable.sort", (column: number, dir: string) => {
|
|
147
|
+
this.lastSort = {column, dir}
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
this.table.dom.focus()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
createTableRow(contact: Record<string, unknown>): Array<any> {
|
|
154
|
+
return [
|
|
155
|
+
contact.id,
|
|
156
|
+
contact.type,
|
|
157
|
+
false,
|
|
158
|
+
`${avatarTemplate({user: contact})} ${escapeText((contact.name as string) || "")}`,
|
|
159
|
+
displayContactType({type: contact.type as string}),
|
|
160
|
+
contact.email,
|
|
161
|
+
contact.type === "to_userinvite"
|
|
162
|
+
? respondInviteCell(contact)
|
|
163
|
+
: deleteContactCell(contact)
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
getList(): Promise<void> {
|
|
168
|
+
const cachedPromise = this.showCached()
|
|
169
|
+
if (this.app.isOffline()) {
|
|
170
|
+
return cachedPromise.then(() => {})
|
|
171
|
+
}
|
|
172
|
+
return postJson("/api/user/contacts/list/")
|
|
173
|
+
.then(({json}: any) => {
|
|
174
|
+
return cachedPromise.then(oldJson => {
|
|
175
|
+
if (!deepEqual(json, oldJson)) {
|
|
176
|
+
this.updateIndexedDB(json)
|
|
177
|
+
this.loadData(json)
|
|
178
|
+
this.initializeView()
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
.catch((error: Error) => {
|
|
183
|
+
if (!this.app.isOffline()) {
|
|
184
|
+
addAlert("error", gettext("Could not obtain contacts list"))
|
|
185
|
+
throw error
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
loadData(json: Record<string, unknown>): void {
|
|
191
|
+
this.contacts = json.contacts as Array<Record<string, unknown>>
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
initializeView(): void {
|
|
195
|
+
if (this.app.page === this) {
|
|
196
|
+
this.initTable()
|
|
197
|
+
window.scrollTo(0, 0)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
showCached(): Promise<any> {
|
|
202
|
+
return this.loaddatafromIndexedDB().then(json => {
|
|
203
|
+
if (!json) {
|
|
204
|
+
return Promise.resolve(false)
|
|
205
|
+
}
|
|
206
|
+
this.loadData(json)
|
|
207
|
+
this.initializeView()
|
|
208
|
+
return json
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
loaddatafromIndexedDB(): Promise<any> {
|
|
213
|
+
return this.app.indexedDB.readAllData("user_data").then((response: any) => {
|
|
214
|
+
if (!response.length) {
|
|
215
|
+
return false
|
|
216
|
+
}
|
|
217
|
+
const data = response[0]
|
|
218
|
+
delete data.id
|
|
219
|
+
return data
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
updateIndexedDB(json: any): Promise<void> {
|
|
224
|
+
json.id = 1
|
|
225
|
+
return this.app.indexedDB
|
|
226
|
+
.clearData("user_data")
|
|
227
|
+
.then(() => this.app.indexedDB.insertData("user_data", [json]))
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
bind(): void {
|
|
231
|
+
this.dom.addEventListener("click", (event: Event) => {
|
|
232
|
+
const el: Record<string, any> = {}
|
|
233
|
+
switch (true) {
|
|
234
|
+
case findTarget(event, ".delete-single-contact", el): {
|
|
235
|
+
const id = Number.parseInt(el.target.dataset.id)
|
|
236
|
+
const type = el.target.dataset.type
|
|
237
|
+
|
|
238
|
+
this.deleteContact(id, type)
|
|
239
|
+
break
|
|
240
|
+
}
|
|
241
|
+
case findTarget(event, ".respond-invite", el): {
|
|
242
|
+
const id = Number.parseInt(el.target.dataset.id)
|
|
243
|
+
const invite = this.contacts.find(
|
|
244
|
+
contact =>
|
|
245
|
+
contact.id === id && contact.type === "to_userinvite"
|
|
246
|
+
)
|
|
247
|
+
const dialog = new RespondInviteDialog(
|
|
248
|
+
[invite!],
|
|
249
|
+
contacts =>
|
|
250
|
+
(this.contacts = this.contacts.concat(contacts)),
|
|
251
|
+
invites =>
|
|
252
|
+
(this.contacts = this.contacts.filter(
|
|
253
|
+
contact =>
|
|
254
|
+
!invites.find(
|
|
255
|
+
(invite: any) =>
|
|
256
|
+
invite.type === contact.type &&
|
|
257
|
+
invite.id === contact.id
|
|
258
|
+
)
|
|
259
|
+
)),
|
|
260
|
+
() => this.initializeView()
|
|
261
|
+
)
|
|
262
|
+
dialog.init()
|
|
263
|
+
break
|
|
264
|
+
}
|
|
265
|
+
default:
|
|
266
|
+
break
|
|
267
|
+
}
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
getSelected(): Array<{id: number; type: string}> {
|
|
272
|
+
return Array.from(
|
|
273
|
+
this.dom.querySelectorAll(".entry-select:checked:not(:disabled)")
|
|
274
|
+
).map(el => ({
|
|
275
|
+
id: Number.parseInt((el as HTMLElement).dataset.id!),
|
|
276
|
+
type: (el as HTMLElement).dataset.type!
|
|
277
|
+
}))
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
deleteContact(id: number, type: string): void {
|
|
281
|
+
const dialog = new DeleteContactDialog([{id, type}])
|
|
282
|
+
dialog.init().then(() => {
|
|
283
|
+
this.contacts = this.contacts.filter(
|
|
284
|
+
ocontact => ocontact.id !== id || ocontact.type !== type
|
|
285
|
+
)
|
|
286
|
+
this.initializeView()
|
|
287
|
+
})
|
|
288
|
+
}
|
|
289
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {postJson} from "fwtoolkit"
|
|
2
|
+
|
|
3
|
+
export class ContactInvite {
|
|
4
|
+
app: any
|
|
5
|
+
key: string
|
|
6
|
+
|
|
7
|
+
constructor({app}: {app: any}, key: string) {
|
|
8
|
+
this.app = app
|
|
9
|
+
this.key = key
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
init(): Promise<any> {
|
|
13
|
+
if (!this.app.config.user.is_authenticated) {
|
|
14
|
+
this.app.inviteKey = this.key
|
|
15
|
+
this.app.page = this.app.openLoginPage()
|
|
16
|
+
return this.app.page.init()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return postJson("/api/user/invite/", {key: this.key}).then(({json}: any) => {
|
|
20
|
+
window.history.replaceState({}, "", json.redirect)
|
|
21
|
+
return this.app.selectPage()
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {AddContactDialog} from "./add_dialog.js"
|
|
2
|
+
import {DeleteContactDialog} from "./delete_dialog.js"
|
|
3
|
+
|
|
4
|
+
export const bulkMenuModel = (): {content: Array<Record<string, unknown>>} => ({
|
|
5
|
+
content: [
|
|
6
|
+
{
|
|
7
|
+
title: gettext("Delete selected"),
|
|
8
|
+
tooltip: gettext("Delete selected contacts."),
|
|
9
|
+
action: (overview: any) => {
|
|
10
|
+
const selected = overview.getSelected()
|
|
11
|
+
if (selected.length) {
|
|
12
|
+
const dialog = new DeleteContactDialog(selected)
|
|
13
|
+
dialog.init().then(() => {
|
|
14
|
+
overview.contacts = overview.contacts.filter(
|
|
15
|
+
(ocontact: any) =>
|
|
16
|
+
!selected.some(
|
|
17
|
+
(scontact: any) =>
|
|
18
|
+
scontact.id == ocontact.id &&
|
|
19
|
+
scontact.type == ocontact.type
|
|
20
|
+
)
|
|
21
|
+
)
|
|
22
|
+
overview.initializeView()
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
disabled: (overview: any) => !overview.getSelected().length
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
let currentlySearching = false
|
|
32
|
+
|
|
33
|
+
export const menuModel = (): {content: Array<Record<string, unknown>>} => ({
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: "text",
|
|
37
|
+
title: gettext("Invite contact"),
|
|
38
|
+
keys: "Alt-i",
|
|
39
|
+
action: (overview: any) => {
|
|
40
|
+
const dialog = new AddContactDialog(overview.app.settings)
|
|
41
|
+
dialog.init().then((contacts: any) => {
|
|
42
|
+
contacts.forEach((contact: any) => overview.contacts.push(contact))
|
|
43
|
+
overview.initializeView()
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
order: 0
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: "search",
|
|
50
|
+
icon: "search",
|
|
51
|
+
title: gettext("Search contacts"),
|
|
52
|
+
keys: "Alt-s",
|
|
53
|
+
input: (overview: any, text: string) => {
|
|
54
|
+
if (text.length && !currentlySearching) {
|
|
55
|
+
overview.initTable(true)
|
|
56
|
+
currentlySearching = true
|
|
57
|
+
overview.table.on("datatable.init", () =>
|
|
58
|
+
overview.table.search(text)
|
|
59
|
+
)
|
|
60
|
+
} else if (!text.length && currentlySearching) {
|
|
61
|
+
overview.initTable(false)
|
|
62
|
+
currentlySearching = false
|
|
63
|
+
} else if (text.length) {
|
|
64
|
+
overview.table.search(text)
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
order: 1
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
})
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {Dialog, escapeText, postJson} from "fwtoolkit"
|
|
2
|
+
|
|
3
|
+
export class RespondInviteDialog {
|
|
4
|
+
invites: Array<Record<string, unknown>>
|
|
5
|
+
addCallback: (contacts: Array<Record<string, unknown>>) => void
|
|
6
|
+
deleteCallback: (invites: Array<Record<string, unknown>>) => void
|
|
7
|
+
doneCallback: () => void
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
invites: Array<Record<string, unknown>>,
|
|
11
|
+
addCallback: (contacts: Array<Record<string, unknown>>) => void = () => {},
|
|
12
|
+
deleteCallback: (invites: Array<Record<string, unknown>>) => void = () => {},
|
|
13
|
+
doneCallback: () => void = () => {}
|
|
14
|
+
) {
|
|
15
|
+
this.invites = invites
|
|
16
|
+
this.addCallback = addCallback
|
|
17
|
+
this.deleteCallback = deleteCallback
|
|
18
|
+
this.doneCallback = doneCallback
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
init(): void {
|
|
22
|
+
const buttons = [
|
|
23
|
+
{
|
|
24
|
+
text:
|
|
25
|
+
this.invites.length > 1
|
|
26
|
+
? gettext("Accept all invites")
|
|
27
|
+
: gettext("Accept invite"),
|
|
28
|
+
classes: "fw-dark",
|
|
29
|
+
click: () => {
|
|
30
|
+
postJson("/api/user/invites/accept/", {
|
|
31
|
+
invites: this.invites
|
|
32
|
+
}).then(({json, status}: any) => {
|
|
33
|
+
dialog.close()
|
|
34
|
+
if (status == 200) {
|
|
35
|
+
this.deleteCallback(this.invites)
|
|
36
|
+
this.addCallback(json.contacts)
|
|
37
|
+
this.doneCallback()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
text:
|
|
44
|
+
this.invites.length > 1
|
|
45
|
+
? gettext("Decline all invites")
|
|
46
|
+
: gettext("Decline invite"),
|
|
47
|
+
classes: "fw-dark",
|
|
48
|
+
click: () => {
|
|
49
|
+
postJson("/api/user/invites/decline/", {
|
|
50
|
+
invites: this.invites
|
|
51
|
+
}).then(({status}: any) => {
|
|
52
|
+
dialog.close()
|
|
53
|
+
if (status == 200) {
|
|
54
|
+
this.deleteCallback(this.invites)
|
|
55
|
+
this.doneCallback()
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{type: "cancel"}
|
|
61
|
+
]
|
|
62
|
+
const dialog = new Dialog({
|
|
63
|
+
title: gettext("Accept of invite"),
|
|
64
|
+
id: "confirmaccept",
|
|
65
|
+
body: `<p>${
|
|
66
|
+
this.invites.length > 1
|
|
67
|
+
? gettext("Do you want to accept the below invites?")
|
|
68
|
+
: gettext("Do you want to accept the below invite?")
|
|
69
|
+
}</p>
|
|
70
|
+
${this.invites.map(invite => `<p>${escapeText((invite.name as string) || "")} (${escapeText((invite.email as string) || "")})</p>`).join("")}`,
|
|
71
|
+
height: 60,
|
|
72
|
+
buttons
|
|
73
|
+
} as any)
|
|
74
|
+
dialog.open()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const deleteContactCell = (contact: Record<string, unknown>): string =>
|
|
2
|
+
`<span class="fw-link-text delete-single-contact"
|
|
3
|
+
data-type="${contact.type}" data-id="${contact.id}">
|
|
4
|
+
<i class="fa fa-trash-alt"></i>
|
|
5
|
+
</span>`
|
|
6
|
+
|
|
7
|
+
export const addContactTemplate = (): string =>
|
|
8
|
+
`<table class="ui-dialog-content-table"><tbody><tr><td>
|
|
9
|
+
<input type="text" name="user_string" id="new-contact-user-string"
|
|
10
|
+
placeholder="${gettext("E-mail address or username")}" />
|
|
11
|
+
</td></tr></tbody></table>`
|
|
12
|
+
|
|
13
|
+
export const displayContactType = ({type}: {type: string}): string => {
|
|
14
|
+
switch (type) {
|
|
15
|
+
case "user":
|
|
16
|
+
return gettext("User")
|
|
17
|
+
case "userinvite":
|
|
18
|
+
return gettext("Invite you sent")
|
|
19
|
+
case "to_userinvite":
|
|
20
|
+
return gettext("Invite you received")
|
|
21
|
+
default:
|
|
22
|
+
return type
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const respondInviteCell = (contact: Record<string, unknown>): string =>
|
|
27
|
+
`<button class="fw-button fw-small fw-dark respond-invite" data-id="${contact.id}">
|
|
28
|
+
${gettext("Respond")}
|
|
29
|
+
</button>`
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {Dialog, activateWait, addAlert, deactivateWait, postBare} from "fwtoolkit"
|
|
2
|
+
import {deleteUserDialogTemplate} from "./templates.js"
|
|
3
|
+
|
|
4
|
+
export class DeleteUserDialog {
|
|
5
|
+
username: string
|
|
6
|
+
dialog: any
|
|
7
|
+
|
|
8
|
+
constructor(username: string) {
|
|
9
|
+
this.username = username
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
init(): void {
|
|
13
|
+
const buttons = [
|
|
14
|
+
{
|
|
15
|
+
text: gettext("Delete"),
|
|
16
|
+
classes: "fw-dark",
|
|
17
|
+
click: () => {
|
|
18
|
+
const usernamefieldValue = (
|
|
19
|
+
document.getElementById("username-confirmation") as HTMLInputElement
|
|
20
|
+
).value
|
|
21
|
+
const passwordfieldValue = (
|
|
22
|
+
document.getElementById("password") as HTMLInputElement
|
|
23
|
+
).value
|
|
24
|
+
if (
|
|
25
|
+
usernamefieldValue === this.username &&
|
|
26
|
+
passwordfieldValue.length
|
|
27
|
+
) {
|
|
28
|
+
this.deleteCurrentUser(passwordfieldValue)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{type: "cancel"}
|
|
33
|
+
]
|
|
34
|
+
this.dialog = new Dialog({
|
|
35
|
+
id: "confirmaccountdeletion",
|
|
36
|
+
title: gettext("Confirm deletion"),
|
|
37
|
+
body: deleteUserDialogTemplate(),
|
|
38
|
+
icon: "exclamation-triangle",
|
|
39
|
+
buttons,
|
|
40
|
+
height: 250
|
|
41
|
+
} as any)
|
|
42
|
+
this.dialog.open()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
deleteCurrentUser(password: string): void {
|
|
46
|
+
activateWait()
|
|
47
|
+
|
|
48
|
+
postBare("/api/user/delete/", {password}).then((response: Response) => {
|
|
49
|
+
switch (response.status) {
|
|
50
|
+
case 200:
|
|
51
|
+
window.location.href = "/"
|
|
52
|
+
break
|
|
53
|
+
case 403:
|
|
54
|
+
addAlert(
|
|
55
|
+
"error",
|
|
56
|
+
gettext(
|
|
57
|
+
"Staff accounts have to be deleted through the admin interface."
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
break
|
|
61
|
+
case 401:
|
|
62
|
+
addAlert("error", gettext("Password incorrect."))
|
|
63
|
+
break
|
|
64
|
+
default:
|
|
65
|
+
addAlert("error", gettext("Could not delete user account."))
|
|
66
|
+
break
|
|
67
|
+
}
|
|
68
|
+
deactivateWait()
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
}
|