mirror of
https://github.com/flarum/core.git
synced 2025-08-04 15:37:51 +02:00
common: merge admin & forum Page components
Now both extend src/common/components/Page.tsx Admin component is the exact same as common Forum component extends common & adds one line
This commit is contained in:
@@ -1,34 +1,3 @@
|
|||||||
import Component from '../../common/Component';
|
import Page from '../../common/components/Page';
|
||||||
|
|
||||||
/**
|
export default Page;
|
||||||
* The `Page` component
|
|
||||||
*/
|
|
||||||
export default abstract class Page extends Component {
|
|
||||||
/**
|
|
||||||
* A class name to apply to the body while the route is active.
|
|
||||||
*/
|
|
||||||
bodyClass: string = '';
|
|
||||||
|
|
||||||
oninit(vnode) {
|
|
||||||
super.oninit(vnode);
|
|
||||||
|
|
||||||
if (this.bodyClass) {
|
|
||||||
$('#app').addClass(this.bodyClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
oncreate(vnode) {
|
|
||||||
super.oncreate(vnode);
|
|
||||||
|
|
||||||
app.previous = app.current;
|
|
||||||
app.current = this;
|
|
||||||
|
|
||||||
app.modal.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
onremove(vnode) {
|
|
||||||
super.onremove(vnode);
|
|
||||||
|
|
||||||
$('#app').removeClass(this.bodyClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -20,12 +20,13 @@ import Group from './models/Group';
|
|||||||
import Notification from './models/Notification';
|
import Notification from './models/Notification';
|
||||||
|
|
||||||
import Alert from './components/Alert';
|
import Alert from './components/Alert';
|
||||||
|
import AlertManager from './components/AlertManager';
|
||||||
import Button from './components/Button';
|
import Button from './components/Button';
|
||||||
import ModalManager from './components/ModalManager';
|
import ModalManager from './components/ModalManager';
|
||||||
|
import Page from './components/Page';
|
||||||
import RequestErrorModal from './components/RequestErrorModal';
|
import RequestErrorModal from './components/RequestErrorModal';
|
||||||
|
|
||||||
import flattenDeep from 'lodash/flattenDeep';
|
import flattenDeep from 'lodash/flattenDeep';
|
||||||
import AlertManager from './components/AlertManager';
|
|
||||||
|
|
||||||
export type ApplicationData = {
|
export type ApplicationData = {
|
||||||
apiDocument: any;
|
apiDocument: any;
|
||||||
@@ -107,6 +108,9 @@ export default abstract class Application {
|
|||||||
modal!: ModalManager;
|
modal!: ModalManager;
|
||||||
alerts!: AlertManager;
|
alerts!: AlertManager;
|
||||||
|
|
||||||
|
current?: Page;
|
||||||
|
previous?: Page;
|
||||||
|
|
||||||
load(payload) {
|
load(payload) {
|
||||||
this.data = payload;
|
this.data = payload;
|
||||||
this.translator.locale = payload.locale;
|
this.translator.locale = payload.locale;
|
||||||
|
34
js/src/common/components/Page.tsx
Normal file
34
js/src/common/components/Page.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import Component from '../../common/Component';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `Page` component
|
||||||
|
*/
|
||||||
|
export default abstract class Page extends Component {
|
||||||
|
/**
|
||||||
|
* A class name to apply to the body while the route is active.
|
||||||
|
*/
|
||||||
|
bodyClass: string = '';
|
||||||
|
|
||||||
|
oninit(vnode) {
|
||||||
|
super.oninit(vnode);
|
||||||
|
|
||||||
|
app.previous = app.current;
|
||||||
|
app.current = this;
|
||||||
|
|
||||||
|
if (this.bodyClass) {
|
||||||
|
$('#app').addClass(this.bodyClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oncreate(vnode) {
|
||||||
|
super.oncreate(vnode);
|
||||||
|
|
||||||
|
app.modal.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
onremove(vnode) {
|
||||||
|
super.onremove(vnode);
|
||||||
|
|
||||||
|
$('#app').removeClass(this.bodyClass);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,35 +1,9 @@
|
|||||||
import Component from '../../common/Component';
|
import CommonPage from '../../common/components/Page';
|
||||||
|
|
||||||
/**
|
|
||||||
* The `Page` component
|
|
||||||
*/
|
|
||||||
export default abstract class Page extends Component {
|
|
||||||
/**
|
|
||||||
* A class name to apply to the body while the route is active.
|
|
||||||
*/
|
|
||||||
bodyClass: string = '';
|
|
||||||
|
|
||||||
oninit(vnode) {
|
|
||||||
super.oninit(vnode);
|
|
||||||
|
|
||||||
if (this.bodyClass) {
|
|
||||||
$('#app').addClass(this.bodyClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
export default abstract class Page extends CommonPage {
|
||||||
oncreate(vnode) {
|
oncreate(vnode) {
|
||||||
super.oncreate(vnode);
|
super.oncreate(vnode);
|
||||||
|
|
||||||
app.previous = app.current;
|
|
||||||
app.current = this;
|
|
||||||
|
|
||||||
app.drawer.hide();
|
app.drawer.hide();
|
||||||
app.modal.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
onremove(vnode) {
|
|
||||||
super.onremove(vnode);
|
|
||||||
|
|
||||||
$('#app').removeClass(this.bodyClass);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user