|
1 | 1 | import app from 'flarum/admin/app'; |
2 | | -import Button from 'flarum/common/components/Button'; |
3 | 2 | import registerWidget from '../common/registerWidget'; |
4 | | -import Alert from 'flarum/common/components/Alert'; |
5 | | -import type ExtensionPage from 'flarum/admin/components/ExtensionPage'; |
| 3 | + |
| 4 | +export { default as extend } from './extend'; |
6 | 5 |
|
7 | 6 | app.initializers.add('fof/news-widget', () => { |
8 | 7 | registerWidget(); |
9 | | - |
10 | | - const settingKey = 'fof-news-widget.lines'; |
11 | | - |
12 | | - app.extensionData |
13 | | - .for('fof-news-widget') |
14 | | - .registerSetting(function (this: ExtensionPage) { |
15 | | - return ( |
16 | | - <div className="Form-group FoF-NewsWidget-htmlWarning"> |
17 | | - <Button |
18 | | - className="Button" |
19 | | - onclick={() => { |
20 | | - const value = JSON.parse(this.setting(settingKey)() || '[]'); |
21 | | - |
22 | | - this.setting(settingKey)(JSON.stringify([...value, ''])); |
23 | | - }} |
24 | | - > |
25 | | - {app.translator.trans('fof-news-widget.admin.settings.add_line')} |
26 | | - </Button> |
27 | | - <Alert dismissible={false}>{app.translator.trans('fof-news-widget.admin.settings.html_warning')}</Alert> |
28 | | - </div> |
29 | | - ); |
30 | | - }) |
31 | | - .registerSetting(function (this: ExtensionPage) { |
32 | | - const value = JSON.parse(this.setting(settingKey)() || '[]'); |
33 | | - |
34 | | - if (!value.length) return; |
35 | | - |
36 | | - return ( |
37 | | - <div className="Form-group"> |
38 | | - <label>{app.translator.trans('fof-news-widget.admin.settings.lines')}</label> |
39 | | - {value.map((line: string, index: number) => ( |
40 | | - <div className="FoF-NewsWidget-lineSetting"> |
41 | | - <textarea |
42 | | - className="FormControl" |
43 | | - oninput={(e: any) => { |
44 | | - value[index] = e.target.value; |
45 | | - this.setting(settingKey)(JSON.stringify([...value])); |
46 | | - }} |
47 | | - > |
48 | | - {line} |
49 | | - </textarea> |
50 | | - <Button |
51 | | - className="Button Button--icon" |
52 | | - icon="fas fa-trash" |
53 | | - onclick={() => { |
54 | | - this.setting(settingKey)(JSON.stringify([...value.filter((l: string, i: number) => i !== index)])); |
55 | | - }} |
56 | | - /> |
57 | | - </div> |
58 | | - ))} |
59 | | - </div> |
60 | | - ); |
61 | | - }); |
62 | 8 | }); |
0 commit comments