diff --git a/framework/core/js/src/admin/components/AdminPage.tsx b/framework/core/js/src/admin/components/AdminPage.tsx index 71517bd461..658fd53f39 100644 --- a/framework/core/js/src/admin/components/AdminPage.tsx +++ b/framework/core/js/src/admin/components/AdminPage.tsx @@ -134,8 +134,11 @@ export type SettingsComponentOptions = */ export type AdminHeaderAttrs = AdminHeaderOptions & Partial>; +export type SettingValue = string; +export type MutableSettings = Record>; + export default abstract class AdminPage extends Page { - settings: Record> = {}; + settings: MutableSettings = {}; loading: boolean = false; view(vnode: Mithril.Vnode): Mithril.Children { diff --git a/framework/core/js/src/admin/components/EditCustomCssModal.js b/framework/core/js/src/admin/components/EditCustomCssModal.tsx similarity index 100% rename from framework/core/js/src/admin/components/EditCustomCssModal.js rename to framework/core/js/src/admin/components/EditCustomCssModal.tsx diff --git a/framework/core/js/src/admin/components/EditCustomFooterModal.js b/framework/core/js/src/admin/components/EditCustomFooterModal.tsx similarity index 100% rename from framework/core/js/src/admin/components/EditCustomFooterModal.js rename to framework/core/js/src/admin/components/EditCustomFooterModal.tsx diff --git a/framework/core/js/src/admin/components/EditCustomHeaderModal.js b/framework/core/js/src/admin/components/EditCustomHeaderModal.tsx similarity index 100% rename from framework/core/js/src/admin/components/EditCustomHeaderModal.js rename to framework/core/js/src/admin/components/EditCustomHeaderModal.tsx diff --git a/framework/core/js/src/admin/components/EditGroupModal.js b/framework/core/js/src/admin/components/EditGroupModal.tsx similarity index 85% rename from framework/core/js/src/admin/components/EditGroupModal.js rename to framework/core/js/src/admin/components/EditGroupModal.tsx index d89182f9f9..d1b6293834 100644 --- a/framework/core/js/src/admin/components/EditGroupModal.js +++ b/framework/core/js/src/admin/components/EditGroupModal.tsx @@ -1,18 +1,31 @@ import app from '../../admin/app'; -import Modal from '../../common/components/Modal'; +import Modal, { IInternalModalAttrs } from '../../common/components/Modal'; import Button from '../../common/components/Button'; import Badge from '../../common/components/Badge'; import Group from '../../common/models/Group'; import ItemList from '../../common/utils/ItemList'; import Switch from '../../common/components/Switch'; import Stream from '../../common/utils/Stream'; +import Mithril from 'mithril'; +import extractText from '../../common/utils/extractText'; + +export interface IEditGroupModalAttrs extends IInternalModalAttrs { + group?: Group; +} /** * The `EditGroupModal` component shows a modal dialog which allows the user * to create or edit a group. */ -export default class EditGroupModal extends Modal { - oninit(vnode) { +export default class EditGroupModal extends Modal { + group!: Group; + nameSingular!: Stream; + namePlural!: Stream; + icon!: Stream; + color!: Stream; + isHidden!: Stream; + + oninit(vnode: Mithril.Vnode) { super.oninit(vnode); this.group = this.attrs.group || app.store.createRecord('groups'); @@ -134,7 +147,7 @@ export default class EditGroupModal extends Modal { }; } - onsubmit(e) { + onsubmit(e: SubmitEvent) { e.preventDefault(); this.loading = true; @@ -149,7 +162,7 @@ export default class EditGroupModal extends Modal { } deleteGroup() { - if (confirm(app.translator.trans('core.admin.edit_group.delete_confirmation'))) { + if (confirm(extractText(app.translator.trans('core.admin.edit_group.delete_confirmation')))) { this.group.delete().then(() => m.redraw()); this.hide(); } diff --git a/framework/core/js/src/admin/components/SettingsModal.js b/framework/core/js/src/admin/components/SettingsModal.tsx similarity index 65% rename from framework/core/js/src/admin/components/SettingsModal.js rename to framework/core/js/src/admin/components/SettingsModal.tsx index e108c78ae8..bc167fed5c 100644 --- a/framework/core/js/src/admin/components/SettingsModal.js +++ b/framework/core/js/src/admin/components/SettingsModal.tsx @@ -1,18 +1,18 @@ import app from '../../admin/app'; -import Modal from '../../common/components/Modal'; +import Modal, { IInternalModalAttrs } from '../../common/components/Modal'; import Button from '../../common/components/Button'; import Stream from '../../common/utils/Stream'; import saveSettings from '../utils/saveSettings'; +import Mithril from 'mithril'; +import { MutableSettings, SettingValue } from './AdminPage'; -export default class SettingsModal extends Modal { - oninit(vnode) { - super.oninit(vnode); +export interface ISettingsModalAttrs extends IInternalModalAttrs {} - this.settings = {}; - this.loading = false; - } +export default abstract class SettingsModal extends Modal { + settings: MutableSettings = {}; + loading: boolean = false; - form() { + form(): Mithril.Children { return ''; } @@ -28,7 +28,7 @@ export default class SettingsModal extends Modal { ); } - submitButton() { + submitButton(): Mithril.Children { return (