@fiduswriter/frontend 0.1.27 → 0.1.29
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/dist/admin_console/index.d.ts +9 -2
- package/dist/admin_console/index.d.ts.map +1 -1
- package/dist/admin_console/index.js.map +1 -1
- package/dist/api/index.d.ts +62 -75
- package/dist/api/index.d.ts.map +1 -1
- package/dist/app/index.d.ts +11 -6
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +66 -23
- package/dist/app/index.js.map +1 -1
- package/dist/document_templates/actions.js +2 -4
- package/dist/document_templates/actions.js.map +1 -1
- package/dist/document_templates/editor.d.ts +2 -2
- package/dist/document_templates/editor.d.ts.map +1 -1
- package/dist/document_templates/editor.js +2 -2
- package/dist/document_templates/editor.js.map +1 -1
- package/dist/document_templates/overview.d.ts +7 -7
- package/dist/document_templates/overview.d.ts.map +1 -1
- package/dist/document_templates/overview.js.map +1 -1
- package/dist/documents/overview/actions.d.ts +3 -2
- package/dist/documents/overview/actions.d.ts.map +1 -1
- package/dist/documents/overview/actions.js +20 -17
- package/dist/documents/overview/actions.js.map +1 -1
- package/dist/documents/overview/index.d.ts +8 -17
- package/dist/documents/overview/index.d.ts.map +1 -1
- package/dist/documents/overview/index.js +2 -2
- package/dist/documents/overview/index.js.map +1 -1
- package/dist/documents/overview/menu.d.ts.map +1 -1
- package/dist/documents/overview/menu.js +2 -2
- package/dist/documents/overview/menu.js.map +1 -1
- package/dist/documents/tools.d.ts +2 -2
- package/dist/documents/tools.d.ts.map +1 -1
- package/dist/documents/tools.js.map +1 -1
- package/dist/e2ee/passphrase_urls.d.ts +10 -0
- package/dist/e2ee/passphrase_urls.d.ts.map +1 -0
- package/dist/e2ee/passphrase_urls.js +23 -0
- package/dist/e2ee/passphrase_urls.js.map +1 -0
- package/dist/error_hook/index.d.ts +8 -1
- package/dist/error_hook/index.d.ts.map +1 -1
- package/dist/error_hook/index.js +10 -12
- package/dist/error_hook/index.js.map +1 -1
- package/dist/feedback/index.d.ts +3 -2
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/feedback/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/maintenance/index.d.ts +3 -2
- package/dist/maintenance/index.d.ts.map +1 -1
- package/dist/maintenance/index.js.map +1 -1
- package/dist/menu/index.d.ts +3 -3
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +0 -1
- package/dist/menu/index.js.map +1 -1
- package/dist/pages/flatpage.js.map +1 -1
- package/dist/prelogin/index.d.ts +3 -7
- package/dist/prelogin/index.d.ts.map +1 -1
- package/dist/prelogin/index.js.map +1 -1
- package/dist/types.d.ts +63 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/user/auth/email_confirm.d.ts +2 -2
- package/dist/user/auth/email_confirm.d.ts.map +1 -1
- package/dist/user/auth/email_confirm.js +5 -6
- package/dist/user/auth/email_confirm.js.map +1 -1
- package/dist/user/auth/login.d.ts +3 -3
- package/dist/user/auth/login.d.ts.map +1 -1
- package/dist/user/auth/login.js +18 -19
- package/dist/user/auth/login.js.map +1 -1
- package/dist/user/auth/password_reset_change.d.ts +2 -2
- package/dist/user/auth/password_reset_change.d.ts.map +1 -1
- package/dist/user/auth/password_reset_change.js +0 -1
- package/dist/user/auth/password_reset_change.js.map +1 -1
- package/dist/user/auth/password_reset_request.d.ts +2 -2
- package/dist/user/auth/password_reset_request.d.ts.map +1 -1
- package/dist/user/auth/password_reset_request.js +0 -1
- package/dist/user/auth/password_reset_request.js.map +1 -1
- package/dist/user/auth/signup.d.ts +2 -2
- package/dist/user/auth/signup.d.ts.map +1 -1
- package/dist/user/auth/signup.js +2 -2
- package/dist/user/auth/signup.js.map +1 -1
- package/dist/user/auth/two_factor.d.ts +7 -5
- package/dist/user/auth/two_factor.d.ts.map +1 -1
- package/dist/user/auth/two_factor.js +3 -2
- package/dist/user/auth/two_factor.js.map +1 -1
- package/dist/user/contacts/add_dialog.d.ts +16 -2
- package/dist/user/contacts/add_dialog.d.ts.map +1 -1
- package/dist/user/contacts/add_dialog.js +4 -4
- package/dist/user/contacts/add_dialog.js.map +1 -1
- package/dist/user/contacts/delete_dialog.d.ts +3 -2
- package/dist/user/contacts/delete_dialog.d.ts.map +1 -1
- package/dist/user/contacts/delete_dialog.js.map +1 -1
- package/dist/user/contacts/index.d.ts +10 -2
- package/dist/user/contacts/index.d.ts.map +1 -1
- package/dist/user/contacts/index.js.map +1 -1
- package/dist/user/contacts/invite.d.ts +3 -2
- package/dist/user/contacts/invite.d.ts.map +1 -1
- package/dist/user/contacts/invite.js +3 -2
- package/dist/user/contacts/invite.js.map +1 -1
- package/dist/user/contacts/menu.d.ts.map +1 -1
- package/dist/user/contacts/menu.js +1 -1
- package/dist/user/contacts/menu.js.map +1 -1
- package/dist/user/contacts/respond_invite.d.ts +3 -2
- package/dist/user/contacts/respond_invite.d.ts.map +1 -1
- package/dist/user/contacts/respond_invite.js.map +1 -1
- package/dist/user/profile/delete_user.d.ts +3 -2
- package/dist/user/profile/delete_user.d.ts.map +1 -1
- package/dist/user/profile/delete_user.js.map +1 -1
- package/dist/user/profile/dialogs.d.ts +8 -7
- package/dist/user/profile/dialogs.d.ts.map +1 -1
- package/dist/user/profile/dialogs.js +3 -4
- package/dist/user/profile/dialogs.js.map +1 -1
- package/dist/user/profile/index.d.ts +9 -4
- package/dist/user/profile/index.d.ts.map +1 -1
- package/dist/user/profile/index.js.map +1 -1
- package/package.json +12 -9
- package/src/admin_console/index.ts +9 -2
- package/src/api/index.ts +78 -39
- package/src/app/index.ts +114 -50
- package/src/document_templates/actions.ts +6 -6
- package/src/document_templates/editor.ts +10 -8
- package/src/document_templates/overview.ts +10 -12
- package/src/documents/overview/actions.ts +52 -25
- package/src/documents/overview/index.ts +16 -27
- package/src/documents/overview/menu.ts +4 -2
- package/src/documents/tools.ts +2 -2
- package/src/error_hook/index.ts +20 -15
- package/src/feedback/index.ts +5 -3
- package/src/index.ts +3 -1
- package/src/maintenance/index.ts +16 -7
- package/src/menu/index.ts +4 -4
- package/src/pages/flatpage.ts +4 -4
- package/src/prelogin/index.ts +4 -8
- package/src/types.ts +53 -9
- package/src/user/auth/email_confirm.ts +19 -19
- package/src/user/auth/login.ts +23 -22
- package/src/user/auth/password_reset_change.ts +4 -4
- package/src/user/auth/password_reset_request.ts +3 -3
- package/src/user/auth/signup.ts +8 -8
- package/src/user/auth/two_factor.ts +31 -22
- package/src/user/contacts/add_dialog.ts +7 -4
- package/src/user/contacts/delete_dialog.ts +3 -2
- package/src/user/contacts/index.ts +14 -4
- package/src/user/contacts/invite.ts +9 -5
- package/src/user/contacts/menu.ts +4 -1
- package/src/user/contacts/respond_invite.ts +3 -2
- package/src/user/profile/delete_user.ts +3 -2
- package/src/user/profile/dialogs.ts +19 -18
- package/src/user/profile/index.ts +13 -10
package/src/app/index.ts
CHANGED
|
@@ -23,13 +23,15 @@ import {Page404} from "../pages/404.js"
|
|
|
23
23
|
import {FlatPage} from "../pages/flatpage.js"
|
|
24
24
|
import {OfflinePage} from "../pages/offline.js"
|
|
25
25
|
import {SetupPage} from "../pages/setup.js"
|
|
26
|
-
import {ContactsOverview} from "../user/contacts/index.js"
|
|
26
|
+
import {ContactsOverview, type ContactsApp} from "../user/contacts/index.js"
|
|
27
27
|
import {Profile} from "../user/profile/index.js"
|
|
28
28
|
import {baseBodyTemplate} from "../common/index.js"
|
|
29
29
|
import {SiteMenu} from "../menu/index.js"
|
|
30
30
|
import {FeedbackTab} from "../feedback/index.js"
|
|
31
31
|
|
|
32
32
|
import type {ApiConnectors} from "../api/index.js"
|
|
33
|
+
import type {PreloginApp} from "../prelogin/index.js"
|
|
34
|
+
import type {FrontendApp, Settings} from "../types.js"
|
|
33
35
|
|
|
34
36
|
// ---- Plugin types ----
|
|
35
37
|
|
|
@@ -77,9 +79,10 @@ interface Page {
|
|
|
77
79
|
// ---- App class ----
|
|
78
80
|
|
|
79
81
|
export class App {
|
|
82
|
+
app: PreloginApp
|
|
80
83
|
apiConnectors: ApiConnectors
|
|
81
|
-
settings:
|
|
82
|
-
config:
|
|
84
|
+
settings: Settings
|
|
85
|
+
config: FrontendApp
|
|
83
86
|
name: string
|
|
84
87
|
menuPlugins: PluginList
|
|
85
88
|
appPlugins: PluginList
|
|
@@ -94,30 +97,49 @@ export class App {
|
|
|
94
97
|
open404Page: () => Page
|
|
95
98
|
handleSWUpdate: () => void
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
ws?:
|
|
99
|
-
csl?:
|
|
100
|
+
private _page?: Page
|
|
101
|
+
ws?: FrontendApp["ws"]
|
|
102
|
+
csl?: FrontendApp["csl"]
|
|
100
103
|
bibDB?: any
|
|
101
104
|
imageDB?: any
|
|
102
105
|
indexedDB?: IndexedDB
|
|
103
106
|
plugins?: Record<string, any>
|
|
104
107
|
inviteKey?: string
|
|
105
108
|
|
|
109
|
+
get page(): Page | undefined {
|
|
110
|
+
return this._page
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
set page(page: Page | undefined) {
|
|
114
|
+
this._page = page
|
|
115
|
+
this.config.page = page
|
|
116
|
+
}
|
|
117
|
+
|
|
106
118
|
constructor(
|
|
107
119
|
apiConnectors: ApiConnectors,
|
|
108
|
-
settings:
|
|
120
|
+
settings: Settings = {
|
|
121
|
+
APPS: [],
|
|
122
|
+
apiUrl: (url: string) => url,
|
|
123
|
+
getCsrfToken: () => ""
|
|
124
|
+
},
|
|
109
125
|
pluginOpts: AppPluginOptions = {}
|
|
110
126
|
) {
|
|
111
127
|
this.apiConnectors = apiConnectors
|
|
112
128
|
|
|
113
|
-
settings.gettext = (window as any).gettext
|
|
114
|
-
settings.staticUrl = (window as any).staticUrl
|
|
115
|
-
settings.interpolate = (window as any).interpolate
|
|
116
|
-
initSettings(settings
|
|
117
|
-
this.settings = getSettings() as
|
|
118
|
-
this.config = {}
|
|
129
|
+
;(settings as Record<string, unknown>).gettext = (window as any).gettext
|
|
130
|
+
;(settings as Record<string, unknown>).staticUrl = (window as any).staticUrl
|
|
131
|
+
;(settings as Record<string, unknown>).interpolate = (window as any).interpolate
|
|
132
|
+
initSettings(settings)
|
|
133
|
+
this.settings = getSettings() as Settings
|
|
134
|
+
this.config = {} as FrontendApp
|
|
135
|
+
this.config.settings = this.settings
|
|
119
136
|
this.name = "Fidus Writer"
|
|
120
|
-
this.
|
|
137
|
+
this.app = this as unknown as PreloginApp
|
|
138
|
+
this.config.app = this.app
|
|
139
|
+
this.config.name = this.name
|
|
140
|
+
this.config.isOffline = this.isOffline.bind(this)
|
|
141
|
+
this.config.getConfiguration = this.getConfiguration.bind(this)
|
|
142
|
+
this.config.selectPage = this.selectPage.bind(this)
|
|
121
143
|
|
|
122
144
|
this.appPlugins = pluginOpts.appPlugins ?? []
|
|
123
145
|
this.menuPlugins = pluginOpts.menuPlugins ?? []
|
|
@@ -135,7 +157,10 @@ export class App {
|
|
|
135
157
|
app: "document",
|
|
136
158
|
requireLogin: true,
|
|
137
159
|
open: () => {
|
|
138
|
-
const overview = new DocumentOverview(
|
|
160
|
+
const overview = new DocumentOverview(
|
|
161
|
+
{app: this.config, user: this.config.user},
|
|
162
|
+
"/"
|
|
163
|
+
)
|
|
139
164
|
return Promise.resolve(overview)
|
|
140
165
|
}
|
|
141
166
|
},
|
|
@@ -147,22 +172,31 @@ export class App {
|
|
|
147
172
|
switch (pathnameParts[2]) {
|
|
148
173
|
case "confirm-email": {
|
|
149
174
|
const key = pathnameParts[3]
|
|
150
|
-
returnValue = new EmailConfirm(
|
|
175
|
+
returnValue = new EmailConfirm(
|
|
176
|
+
{app: this.config.app as PreloginApp, language: ""},
|
|
177
|
+
key
|
|
178
|
+
)
|
|
151
179
|
break
|
|
152
180
|
}
|
|
153
181
|
case "password-reset":
|
|
154
|
-
returnValue = new PasswordResetRequest(
|
|
182
|
+
returnValue = new PasswordResetRequest({
|
|
183
|
+
app: this.config.app as PreloginApp,
|
|
184
|
+
language: ""
|
|
185
|
+
})
|
|
155
186
|
break
|
|
156
187
|
case "change-password": {
|
|
157
188
|
const key = pathnameParts[3]
|
|
158
189
|
returnValue = new PasswordResetChangePassword(
|
|
159
|
-
this.config as
|
|
190
|
+
{app: this.config.app as PreloginApp, language: ""},
|
|
160
191
|
key
|
|
161
192
|
)
|
|
162
193
|
break
|
|
163
194
|
}
|
|
164
195
|
case "sign-up":
|
|
165
|
-
returnValue = new Signup(
|
|
196
|
+
returnValue = new Signup({
|
|
197
|
+
app: this.config.app as PreloginApp,
|
|
198
|
+
language: ""
|
|
199
|
+
})
|
|
166
200
|
break
|
|
167
201
|
default:
|
|
168
202
|
returnValue = false
|
|
@@ -179,12 +213,12 @@ export class App {
|
|
|
179
213
|
dom.classList.add("fw-scrollable")
|
|
180
214
|
dom.innerHTML = baseBodyTemplate({
|
|
181
215
|
contents: "",
|
|
182
|
-
user: this.config.user
|
|
216
|
+
user: this.config.user,
|
|
183
217
|
hasOverview: true,
|
|
184
|
-
app: this.config
|
|
218
|
+
app: this.config
|
|
185
219
|
})
|
|
186
|
-
new SiteMenu(this.
|
|
187
|
-
new FeedbackTab(this.config
|
|
220
|
+
new SiteMenu(this.app, "bibliography").init()
|
|
221
|
+
new FeedbackTab(this.config).init()
|
|
188
222
|
const container = dom.querySelector(
|
|
189
223
|
".fw-contents"
|
|
190
224
|
) as HTMLElement
|
|
@@ -196,8 +230,8 @@ export class App {
|
|
|
196
230
|
{
|
|
197
231
|
app: this.config.app,
|
|
198
232
|
container
|
|
199
|
-
}
|
|
200
|
-
this.bibliographyOverviewPlugins
|
|
233
|
+
},
|
|
234
|
+
this.bibliographyOverviewPlugins
|
|
201
235
|
)
|
|
202
236
|
)
|
|
203
237
|
}
|
|
@@ -218,11 +252,11 @@ export class App {
|
|
|
218
252
|
).then(
|
|
219
253
|
({Editor}: any) =>
|
|
220
254
|
new Editor(
|
|
221
|
-
this.config
|
|
255
|
+
this.config,
|
|
222
256
|
path,
|
|
223
257
|
id,
|
|
224
|
-
this.editorPlugins
|
|
225
|
-
this.citationDialogPlugins
|
|
258
|
+
this.editorPlugins,
|
|
259
|
+
this.citationDialogPlugins
|
|
226
260
|
)
|
|
227
261
|
)
|
|
228
262
|
},
|
|
@@ -247,11 +281,11 @@ export class App {
|
|
|
247
281
|
).then(
|
|
248
282
|
({Editor}: any) =>
|
|
249
283
|
new Editor(
|
|
250
|
-
this.config
|
|
284
|
+
this.config,
|
|
251
285
|
path,
|
|
252
286
|
token,
|
|
253
|
-
this.editorPlugins
|
|
254
|
-
this.citationDialogPlugins
|
|
287
|
+
this.editorPlugins,
|
|
288
|
+
this.citationDialogPlugins
|
|
255
289
|
)
|
|
256
290
|
)
|
|
257
291
|
}
|
|
@@ -263,7 +297,10 @@ export class App {
|
|
|
263
297
|
const path = (
|
|
264
298
|
"/" + pathnameParts.slice(2).join("/")
|
|
265
299
|
).replace(/\/?$/, "/")
|
|
266
|
-
const overview = new DocumentOverview(
|
|
300
|
+
const overview = new DocumentOverview(
|
|
301
|
+
{app: this.config, user: this.config.user},
|
|
302
|
+
path
|
|
303
|
+
)
|
|
267
304
|
return Promise.resolve(overview)
|
|
268
305
|
}
|
|
269
306
|
},
|
|
@@ -271,7 +308,10 @@ export class App {
|
|
|
271
308
|
app: "base",
|
|
272
309
|
open: (pathnameParts: string[]) => {
|
|
273
310
|
const url = `/${pathnameParts[2]}/`
|
|
274
|
-
return new FlatPage(
|
|
311
|
+
return new FlatPage(
|
|
312
|
+
{app: this.config.app as PreloginApp, language: ""},
|
|
313
|
+
url
|
|
314
|
+
)
|
|
275
315
|
}
|
|
276
316
|
},
|
|
277
317
|
user: {
|
|
@@ -281,10 +321,18 @@ export class App {
|
|
|
281
321
|
let returnValue: any
|
|
282
322
|
switch (pathnameParts[2]) {
|
|
283
323
|
case "profile":
|
|
284
|
-
returnValue = new Profile(
|
|
324
|
+
returnValue = new Profile({
|
|
325
|
+
app: this.config,
|
|
326
|
+
user: this.config.user,
|
|
327
|
+
socialaccount_providers:
|
|
328
|
+
this.config.socialaccount_providers ?? []
|
|
329
|
+
})
|
|
285
330
|
break
|
|
286
331
|
case "contacts":
|
|
287
|
-
returnValue = new ContactsOverview(
|
|
332
|
+
returnValue = new ContactsOverview({
|
|
333
|
+
app: this.config as ContactsApp,
|
|
334
|
+
user: this.config.user
|
|
335
|
+
})
|
|
288
336
|
break
|
|
289
337
|
default:
|
|
290
338
|
returnValue = false
|
|
@@ -301,7 +349,7 @@ export class App {
|
|
|
301
349
|
app: "user",
|
|
302
350
|
open: (pathnameParts: string[]) => {
|
|
303
351
|
const id = pathnameParts[2]
|
|
304
|
-
return new ContactInvite(this.config as
|
|
352
|
+
return new ContactInvite({app: this.config.app as PreloginApp}, id)
|
|
305
353
|
}
|
|
306
354
|
},
|
|
307
355
|
usermedia: {
|
|
@@ -313,18 +361,18 @@ export class App {
|
|
|
313
361
|
dom.classList.add("fw-scrollable")
|
|
314
362
|
dom.innerHTML = baseBodyTemplate({
|
|
315
363
|
contents: "",
|
|
316
|
-
user: this.config.user
|
|
364
|
+
user: this.config.user,
|
|
317
365
|
hasOverview: true,
|
|
318
|
-
app: this.config
|
|
366
|
+
app: this.config
|
|
319
367
|
})
|
|
320
|
-
new SiteMenu(this.
|
|
321
|
-
new FeedbackTab(this.config
|
|
368
|
+
new SiteMenu(this.app, "images").init()
|
|
369
|
+
new FeedbackTab(this.config).init()
|
|
322
370
|
const container = dom.querySelector(
|
|
323
371
|
".fw-contents"
|
|
324
372
|
) as HTMLElement
|
|
325
373
|
return Promise.resolve(
|
|
326
374
|
new ImageOverview({
|
|
327
|
-
app: this.
|
|
375
|
+
app: this.app,
|
|
328
376
|
container
|
|
329
377
|
} as any)
|
|
330
378
|
)
|
|
@@ -333,17 +381,26 @@ export class App {
|
|
|
333
381
|
|
|
334
382
|
}
|
|
335
383
|
this.config.routes = this.routes
|
|
336
|
-
this.openLoginPage = () =>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
384
|
+
this.openLoginPage = () =>
|
|
385
|
+
new LoginPage({
|
|
386
|
+
app: this.config.app as PreloginApp,
|
|
387
|
+
language: "",
|
|
388
|
+
socialaccount_providers: this.config.socialaccount_providers ?? []
|
|
389
|
+
})
|
|
390
|
+
this.openOfflinePage = () =>
|
|
391
|
+
new OfflinePage({app: this.config.app as PreloginApp, language: ""})
|
|
392
|
+
this.openSetupPage = () =>
|
|
393
|
+
new SetupPage({app: this.config.app as PreloginApp, language: ""})
|
|
394
|
+
this.open404Page = () =>
|
|
395
|
+
new Page404({app: this.config.app as PreloginApp, language: ""})
|
|
340
396
|
this.handleSWUpdate = () => window.location.reload()
|
|
341
397
|
}
|
|
342
398
|
|
|
343
399
|
isOffline(): boolean {
|
|
400
|
+
const ws = this.ws
|
|
344
401
|
return (
|
|
345
402
|
!navigator.onLine ||
|
|
346
|
-
(
|
|
403
|
+
(ws !== undefined && !!ws.connectionCount && !ws.connected)
|
|
347
404
|
)
|
|
348
405
|
}
|
|
349
406
|
|
|
@@ -431,12 +488,15 @@ export class App {
|
|
|
431
488
|
|
|
432
489
|
setup(): Promise<any> {
|
|
433
490
|
this.csl = new CSL()
|
|
491
|
+
this.config.csl = this.csl
|
|
434
492
|
if (!this.config.user.is_authenticated) {
|
|
435
493
|
this.activateFidusPlugins()
|
|
436
494
|
return this.selectPage().then(() => this.bind())
|
|
437
495
|
}
|
|
438
496
|
this.bibDB = new BibliographyDB(this as any)
|
|
497
|
+
this.config.bibDB = this.bibDB
|
|
439
498
|
this.imageDB = new ImageDB(this as any)
|
|
499
|
+
this.config.imageDB = this.imageDB
|
|
440
500
|
this.connectWs()
|
|
441
501
|
return Promise.all([this.bibDB.getDB(), this.imageDB.getDB()])
|
|
442
502
|
.then(() => {
|
|
@@ -444,11 +504,14 @@ export class App {
|
|
|
444
504
|
// Initialize the indexedDB after the plugins have loaded.
|
|
445
505
|
this.indexedDB = new IndexedDB(
|
|
446
506
|
this.config.user.username,
|
|
447
|
-
this.routes
|
|
507
|
+
this.routes
|
|
448
508
|
)
|
|
449
509
|
return this.indexedDB.init()
|
|
450
510
|
})
|
|
451
|
-
.then(() =>
|
|
511
|
+
.then(() => {
|
|
512
|
+
this.config.indexedDB = this.indexedDB
|
|
513
|
+
return this.selectPage()
|
|
514
|
+
})
|
|
452
515
|
.then(() => this.bind())
|
|
453
516
|
.then(() => this.showNews())
|
|
454
517
|
}
|
|
@@ -523,7 +586,7 @@ export class App {
|
|
|
523
586
|
return
|
|
524
587
|
}
|
|
525
588
|
this.ws = new (WebSocketConnector as any)({
|
|
526
|
-
base: this.config.ws_url_base
|
|
589
|
+
base: this.config.ws_url_base!,
|
|
527
590
|
path: "/base/",
|
|
528
591
|
appLoaded: () => true,
|
|
529
592
|
receiveData: (data: any) => {
|
|
@@ -536,7 +599,8 @@ export class App {
|
|
|
536
599
|
}
|
|
537
600
|
}
|
|
538
601
|
})
|
|
539
|
-
this.ws.
|
|
602
|
+
this.config.ws = this.ws
|
|
603
|
+
this.ws?.init()
|
|
540
604
|
}
|
|
541
605
|
|
|
542
606
|
activateFidusPlugins(): void {
|
|
@@ -23,7 +23,7 @@ export class DocTemplatesActions {
|
|
|
23
23
|
return
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
this.docTemplatesOverview.app.apiConnectors.documentTemplate.delete({id})
|
|
27
27
|
.catch((error: Error) => {
|
|
28
28
|
addAlert(
|
|
29
29
|
"error",
|
|
@@ -73,9 +73,9 @@ export class DocTemplatesActions {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
copyDocTemplate(oldDocTemplate: Record<string, unknown>): void {
|
|
76
|
-
|
|
77
|
-
id: oldDocTemplate.id,
|
|
78
|
-
title: `${gettext("Copy of")} ${oldDocTemplate.title}`
|
|
76
|
+
this.docTemplatesOverview.app.apiConnectors.documentTemplate.copy({
|
|
77
|
+
id: oldDocTemplate.id as number,
|
|
78
|
+
title: `${gettext("Copy of")} ${oldDocTemplate.title as string}`
|
|
79
79
|
})
|
|
80
80
|
.catch((error: Error) => {
|
|
81
81
|
addAlert("error", gettext("The document template could not be copied"))
|
|
@@ -94,7 +94,7 @@ export class DocTemplatesActions {
|
|
|
94
94
|
downloadDocTemplate(id: number): void {
|
|
95
95
|
const exporter = new DocumentTemplateExporter(
|
|
96
96
|
id,
|
|
97
|
-
|
|
97
|
+
this.docTemplatesOverview.app.apiConnectors.documentTemplate
|
|
98
98
|
)
|
|
99
99
|
exporter.init()
|
|
100
100
|
}
|
|
@@ -120,7 +120,7 @@ export class DocTemplatesActions {
|
|
|
120
120
|
|
|
121
121
|
const importer = new DocumentTemplateImporter(
|
|
122
122
|
file,
|
|
123
|
-
|
|
123
|
+
this.docTemplatesOverview.app.apiConnectors.documentTemplate
|
|
124
124
|
)
|
|
125
125
|
|
|
126
126
|
importer
|
|
@@ -11,10 +11,11 @@ import {
|
|
|
11
11
|
whenReady
|
|
12
12
|
} from "fwtoolkit"
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
import type {FrontendApp} from "../types.js"
|
|
15
|
+
|
|
16
|
+
interface AppLike extends FrontendApp {
|
|
15
17
|
csl: {getStyles: () => Promise<any>}
|
|
16
18
|
page: unknown
|
|
17
|
-
[key: string]: unknown
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export class DocTemplatesEditor {
|
|
@@ -46,7 +47,7 @@ export class DocTemplatesEditor {
|
|
|
46
47
|
.getStyles()
|
|
47
48
|
.then(styles => {
|
|
48
49
|
this.citationStyles = styles
|
|
49
|
-
return
|
|
50
|
+
return this.app.apiConnectors.documentTemplate.get({
|
|
50
51
|
id: this.id
|
|
51
52
|
})
|
|
52
53
|
})
|
|
@@ -68,7 +69,8 @@ export class DocTemplatesEditor {
|
|
|
68
69
|
this.template.document_styles,
|
|
69
70
|
this.citationStyles,
|
|
70
71
|
this.template.export_templates,
|
|
71
|
-
this.dom.querySelector("#template-editor")
|
|
72
|
+
this.dom.querySelector("#template-editor")!,
|
|
73
|
+
this.app.apiConnectors.documentTemplate
|
|
72
74
|
)
|
|
73
75
|
this.templateDesigner.init()
|
|
74
76
|
this.bind()
|
|
@@ -109,7 +111,7 @@ export class DocTemplatesEditor {
|
|
|
109
111
|
</div>
|
|
110
112
|
</div>`
|
|
111
113
|
document.body = this.dom
|
|
112
|
-
setDocTitle(gettext("Template Editor"), this.app
|
|
114
|
+
setDocTitle(gettext("Template Editor"), this.app)
|
|
113
115
|
const feedbackTab = new FeedbackTab(this.app)
|
|
114
116
|
feedbackTab.init()
|
|
115
117
|
}
|
|
@@ -132,7 +134,7 @@ export class DocTemplatesEditor {
|
|
|
132
134
|
this.showErrors(errors)
|
|
133
135
|
return Promise.reject()
|
|
134
136
|
} else {
|
|
135
|
-
return
|
|
137
|
+
return this.app.apiConnectors.documentTemplate.save({
|
|
136
138
|
id: this.id,
|
|
137
139
|
value,
|
|
138
140
|
import_id,
|
|
@@ -145,7 +147,7 @@ export class DocTemplatesEditor {
|
|
|
145
147
|
this.save().then(() => {
|
|
146
148
|
const exporter = new DocumentTemplateExporter(
|
|
147
149
|
this.id,
|
|
148
|
-
|
|
150
|
+
this.app.apiConnectors.documentTemplate
|
|
149
151
|
)
|
|
150
152
|
exporter.init()
|
|
151
153
|
})
|
|
@@ -165,7 +167,7 @@ export class DocTemplatesEditor {
|
|
|
165
167
|
break
|
|
166
168
|
case findTarget(event, "button.close, span.close", el):
|
|
167
169
|
event.preventDefault()
|
|
168
|
-
|
|
170
|
+
this.app.goTo("/templates/")
|
|
169
171
|
break
|
|
170
172
|
default:
|
|
171
173
|
break
|
|
@@ -12,25 +12,23 @@ import {
|
|
|
12
12
|
whenReady
|
|
13
13
|
} from "fwtoolkit"
|
|
14
14
|
|
|
15
|
+
import type {FrontendApp, User} from "../types.js"
|
|
15
16
|
import {DocTemplatesActions} from "./actions.js"
|
|
16
17
|
import {bulkMenuModel, menuModel} from "./menu.js"
|
|
17
18
|
|
|
18
|
-
interface AppLike {
|
|
19
|
-
|
|
20
|
-
goTo: (url: string) => void
|
|
19
|
+
interface AppLike extends FrontendApp {
|
|
20
|
+
csl: {getStyles: () => Promise<any>}
|
|
21
21
|
indexedDB: {
|
|
22
22
|
readAllData: (store: string) => Promise<Array<Record<string, unknown>>>
|
|
23
23
|
clearData: (store: string) => Promise<void>
|
|
24
24
|
insertData: (store: string, data: Array<Record<string, unknown>>) => Promise<void>
|
|
25
25
|
}
|
|
26
|
-
settings: Record<string, unknown>
|
|
27
26
|
page: unknown
|
|
28
|
-
[key: string]: unknown
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
export class DocTemplatesOverview {
|
|
32
30
|
app: AppLike
|
|
33
|
-
user:
|
|
31
|
+
user: User
|
|
34
32
|
mod: {actions?: DocTemplatesActions}
|
|
35
33
|
templateList: Array<Record<string, unknown>>
|
|
36
34
|
styles: any
|
|
@@ -41,7 +39,7 @@ export class DocTemplatesOverview {
|
|
|
41
39
|
dtBulk: any
|
|
42
40
|
menu: any
|
|
43
41
|
|
|
44
|
-
constructor({app, user}: {app: AppLike; user:
|
|
42
|
+
constructor({app, user}: {app: AppLike; user: User}) {
|
|
45
43
|
this.app = app
|
|
46
44
|
this.user = user
|
|
47
45
|
this.mod = {}
|
|
@@ -54,7 +52,7 @@ export class DocTemplatesOverview {
|
|
|
54
52
|
init(): Promise<void> {
|
|
55
53
|
return whenReady().then(() => {
|
|
56
54
|
this.render()
|
|
57
|
-
const smenu = new SiteMenu(this.app
|
|
55
|
+
const smenu = new SiteMenu(this.app, "templates")
|
|
58
56
|
smenu.init()
|
|
59
57
|
new DocTemplatesActions(this)
|
|
60
58
|
this.menu = new OverviewMenuView(this, menuModel as any)
|
|
@@ -68,16 +66,16 @@ export class DocTemplatesOverview {
|
|
|
68
66
|
this.dom = document.createElement("body")
|
|
69
67
|
this.dom.innerHTML = baseBodyTemplate({
|
|
70
68
|
contents: "",
|
|
71
|
-
user: this.user
|
|
69
|
+
user: this.user,
|
|
72
70
|
hasOverview: true,
|
|
73
|
-
app: this.app
|
|
71
|
+
app: this.app
|
|
74
72
|
})
|
|
75
73
|
document.body = this.dom
|
|
76
74
|
ensureCSS([
|
|
77
75
|
staticUrl("css/add_remove_dialog.css"),
|
|
78
76
|
staticUrl("css/access_rights_dialog.css")
|
|
79
77
|
])
|
|
80
|
-
setDocTitle(gettext("Document Templates Overview"), this.app
|
|
78
|
+
setDocTitle(gettext("Document Templates Overview"), this.app)
|
|
81
79
|
const feedbackTab = new FeedbackTab(this.app)
|
|
82
80
|
feedbackTab.init()
|
|
83
81
|
}
|
|
@@ -246,7 +244,7 @@ export class DocTemplatesOverview {
|
|
|
246
244
|
if (this.app.isOffline()) {
|
|
247
245
|
return this.showCached()
|
|
248
246
|
}
|
|
249
|
-
return
|
|
247
|
+
return this.app.apiConnectors.documentTemplate.list()
|
|
250
248
|
.then((json: any) => {
|
|
251
249
|
this.updateIndexedDB(json)
|
|
252
250
|
this.initializeView(json)
|