mirror of
https://github.com/flarum/core.git
synced 2025-08-05 16:07:34 +02:00
chore: extract FormModal
from Modal
(#3922)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import app from 'flarum/forum/app';
|
||||
import Modal from 'flarum/common/components/Modal';
|
||||
import FormModal from 'flarum/common/components/FormModal';
|
||||
import Form from 'flarum/common/components/Form';
|
||||
import Button from 'flarum/common/components/Button';
|
||||
|
||||
@@ -7,7 +7,7 @@ import Stream from 'flarum/common/utils/Stream';
|
||||
import withAttr from 'flarum/common/utils/withAttr';
|
||||
import ItemList from 'flarum/common/utils/ItemList';
|
||||
|
||||
export default class FlagPostModal extends Modal {
|
||||
export default class FlagPostModal extends FormModal {
|
||||
oninit(vnode) {
|
||||
super.oninit(vnode);
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import app from 'flarum/forum/app';
|
||||
import Modal from 'flarum/common/components/Modal';
|
||||
import FormModal from 'flarum/common/components/FormModal';
|
||||
import Button from 'flarum/common/components/Button';
|
||||
import Stream from 'flarum/common/utils/Stream';
|
||||
import Form from '@flarum/core/src/common/components/Form';
|
||||
|
||||
export default class NicknameModal extends Modal {
|
||||
export default class NicknameModal extends FormModal {
|
||||
oninit(vnode) {
|
||||
super.oninit(vnode);
|
||||
this.nickname = Stream(app.session.user.displayName());
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import app from 'flarum/admin/app';
|
||||
import ItemList from 'flarum/common/utils/ItemList';
|
||||
import generateElementId from 'flarum/admin/utils/generateElementId';
|
||||
import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal';
|
||||
import FormModal, { IFormModalAttrs } from 'flarum/common/components/FormModal';
|
||||
|
||||
import Mithril from 'mithril';
|
||||
import Button from 'flarum/common/components/Button';
|
||||
@@ -22,7 +22,7 @@ export interface IDateSelection {
|
||||
end: number;
|
||||
}
|
||||
|
||||
export interface IStatisticsWidgetDateSelectionModalAttrs extends IInternalModalAttrs {
|
||||
export interface IStatisticsWidgetDateSelectionModalAttrs extends IFormModalAttrs {
|
||||
onModalSubmit: (dates: IDateSelection) => void;
|
||||
value?: IDateSelection;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ interface IStatisticsWidgetDateSelectionModalState {
|
||||
};
|
||||
}
|
||||
|
||||
export default class StatisticsWidgetDateSelectionModal extends Modal<IStatisticsWidgetDateSelectionModalAttrs> {
|
||||
export default class StatisticsWidgetDateSelectionModal extends FormModal<IStatisticsWidgetDateSelectionModalAttrs> {
|
||||
/* @ts-expect-error core typings don't allow us to set the type of the state attr :( */
|
||||
state: IStatisticsWidgetDateSelectionModalState = {
|
||||
inputs: {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import app from 'flarum/forum/app';
|
||||
import Modal from 'flarum/common/components/Modal';
|
||||
import FormModal from 'flarum/common/components/FormModal';
|
||||
import Button from 'flarum/common/components/Button';
|
||||
import Stream from 'flarum/common/utils/Stream';
|
||||
import withAttr from 'flarum/common/utils/withAttr';
|
||||
@@ -9,7 +9,7 @@ import { getPermanentSuspensionDate } from '../helpers/suspensionHelper';
|
||||
import Form from '@flarum/core/src/common/components/Form';
|
||||
import FieldSet from '@flarum/core/src/common/components/FieldSet';
|
||||
|
||||
export default class SuspendUserModal extends Modal {
|
||||
export default class SuspendUserModal extends FormModal {
|
||||
oninit(vnode) {
|
||||
super.oninit(vnode);
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import app from 'flarum/admin/app';
|
||||
import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal';
|
||||
import FormModal, { IFormModalAttrs } from 'flarum/common/components/FormModal';
|
||||
import Button from 'flarum/common/components/Button';
|
||||
import ColorPreviewInput from 'flarum/common/components/ColorPreviewInput';
|
||||
import ItemList from 'flarum/common/utils/ItemList';
|
||||
@@ -12,7 +12,7 @@ import type Mithril from 'mithril';
|
||||
import tagLabel from '../../common/helpers/tagLabel';
|
||||
import type Tag from '../../common/models/Tag';
|
||||
|
||||
export interface EditTagModalAttrs extends IInternalModalAttrs {
|
||||
export interface EditTagModalAttrs extends IFormModalAttrs {
|
||||
primary?: boolean;
|
||||
model?: Tag;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ export interface EditTagModalAttrs extends IInternalModalAttrs {
|
||||
* The `EditTagModal` component shows a modal dialog which allows the user
|
||||
* to create or edit a tag.
|
||||
*/
|
||||
export default class EditTagModal extends Modal<EditTagModalAttrs> {
|
||||
export default class EditTagModal extends FormModal<EditTagModalAttrs> {
|
||||
tag!: Tag;
|
||||
|
||||
name!: Stream<string>;
|
||||
|
@@ -5,7 +5,7 @@ import extractText from 'flarum/common/utils/extractText';
|
||||
import highlight from 'flarum/common/helpers/highlight';
|
||||
import KeyboardNavigatable from 'flarum/common/utils/KeyboardNavigatable';
|
||||
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
|
||||
import Modal from 'flarum/common/components/Modal';
|
||||
import FormModal from 'flarum/common/components/FormModal';
|
||||
import Stream from 'flarum/common/utils/Stream';
|
||||
|
||||
import sortTags from '../utils/sortTags';
|
||||
@@ -14,7 +14,7 @@ import tagIcon from '../helpers/tagIcon';
|
||||
import ToggleButton from '../../forum/components/ToggleButton';
|
||||
|
||||
import type Tag from '../models/Tag';
|
||||
import type { IInternalModalAttrs } from 'flarum/common/components/Modal';
|
||||
import type { IFormModalAttrs } from 'flarum/common/components/FormModal';
|
||||
import type Mithril from 'mithril';
|
||||
|
||||
export interface ITagSelectionModalLimits {
|
||||
@@ -34,7 +34,7 @@ export interface ITagSelectionModalLimits {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ITagSelectionModalAttrs extends IInternalModalAttrs {
|
||||
export interface ITagSelectionModalAttrs extends IFormModalAttrs {
|
||||
/** Custom modal className to use. */
|
||||
className?: string;
|
||||
/** Modal title, defaults to 'Choose Tags'. */
|
||||
@@ -64,7 +64,7 @@ export type ITagSelectionModalState = undefined;
|
||||
export default class TagSelectionModal<
|
||||
CustomAttrs extends ITagSelectionModalAttrs = ITagSelectionModalAttrs,
|
||||
CustomState extends ITagSelectionModalState = ITagSelectionModalState
|
||||
> extends Modal<CustomAttrs, CustomState> {
|
||||
> extends FormModal<CustomAttrs, CustomState> {
|
||||
protected loading = true;
|
||||
protected tags!: Tag[];
|
||||
protected selected: Tag[] = [];
|
||||
@@ -108,7 +108,7 @@ export default class TagSelectionModal<
|
||||
.onSelect(this.select.bind(this))
|
||||
.onRemove(() => this.selected.splice(this.selected.length - 1, 1));
|
||||
|
||||
app.tagList.load(['parent']).then((tags) => {
|
||||
app.tagList.load(['parent']).then((tags: Tag[]) => {
|
||||
this.loading = false;
|
||||
|
||||
if (this.attrs.selectableTags) {
|
||||
|
@@ -21,7 +21,7 @@ export default class TagListState {
|
||||
async query(includes: string[] = []): Promise<Tag[]> {
|
||||
this.loadedIncludes ??= new Set();
|
||||
|
||||
return app.store.find<Tag[]>('tags', { include: includes.join(',') }).then((val) => {
|
||||
return app.store.find<Tag[]>('tags', { include: includes.join(',') }).then((val: Tag) => {
|
||||
includes.forEach((include) => this.loadedIncludes!.add(include));
|
||||
return val;
|
||||
});
|
||||
|
Reference in New Issue
Block a user