diff --git a/js/src/forum/components/ComposePollPage.tsx b/js/src/forum/components/ComposePollPage.tsx
index da765071..055c83f2 100644
--- a/js/src/forum/components/ComposePollPage.tsx
+++ b/js/src/forum/components/ComposePollPage.tsx
@@ -8,6 +8,7 @@ import Acl from '../../common/Acl';
import PollFormState from '../states/PollFormState';
import { slug } from '../../common';
import ComposePollHero from './ComposePollHero';
+import Button from 'flarum/common/components/Button';
const t = app.translator.trans.bind(app.translator);
const prfx = `${slug}.forum.compose`;
@@ -44,8 +45,8 @@ export default class ComposePollPage extends Page {
this.poll = PollFormState.createNewPoll();
}
- app.history.push('compose-goodie-collection');
- this.bodyClass = 'App--compose-goodie-collection';
+ app.history.push('compose-poll');
+ this.bodyClass = 'App--compose-poll';
app.setTitle(t(`${prfx}.${!!this.poll?.id() ? 'edit' : 'add'}_title`));
}
@@ -58,9 +59,46 @@ export default class ComposePollPage extends Page {
);
}
+
+ async onsubmit(data: Object, state: PollFormState) {
+ const isNew = state.poll.id() === undefined;
+ await state.save(data);
+
+ const alertAttrs = isNew
+ ? {
+ type: 'success',
+ controls: [
+ ,
+ ],
+ }
+ : {
+ type: 'success',
+ };
+
+ // Show success alert
+ const alertId = app.alerts.show(alertAttrs, t(`${prfx}.success`));
+
+ // Hide alert after 10 seconds
+ setTimeout(() => app.alerts.dismiss(alertId), 10000);
+
+ if (isNew) {
+ m.route.set(app.route('fof_polls_list'));
+ }
+ }
}
diff --git a/js/src/forum/components/CreatePollModal.js b/js/src/forum/components/CreatePollModal.js
index d0725cac..1a59f08d 100755
--- a/js/src/forum/components/CreatePollModal.js
+++ b/js/src/forum/components/CreatePollModal.js
@@ -12,16 +12,15 @@ export default class CreatePollModal extends Modal {
}
content() {
- //@todo check if bind is needed for onsubmit
return [
,
];
}
- onsubmit(poll) {
+ onsubmit(data) {
this.hide();
- this.attrs.onsubmit(poll);
+ this.attrs.onsubmit(data);
}
}
diff --git a/js/src/forum/components/EditPollModal.js b/js/src/forum/components/EditPollModal.js
index 304a6470..be113f49 100755
--- a/js/src/forum/components/EditPollModal.js
+++ b/js/src/forum/components/EditPollModal.js
@@ -5,4 +5,19 @@ export default class EditPollModal extends CreatePollModal {
title() {
return app.translator.trans('fof-polls.forum.modal.edit_title');
}
+
+ async onsubmit(data, state) {
+ await state.save(data);
+
+ // Show success alert
+ const alertId = app.alerts.show(
+ {
+ type: 'success',
+ },
+ app.translator.trans('fof-polls.forum.compose.success')
+ );
+
+ // Hide alert after 10 seconds
+ setTimeout(() => app.alerts.dismiss(alertId), 10000);
+ }
}
diff --git a/js/src/forum/components/Poll.tsx b/js/src/forum/components/Poll.tsx
index d51430af..b4950181 100644
--- a/js/src/forum/components/Poll.tsx
+++ b/js/src/forum/components/Poll.tsx
@@ -4,10 +4,9 @@ import app from 'flarum/forum/app';
import PollTitle from './Poll/PollTitle';
import PollOptions from './Poll/PollOptions';
import PollImage from './Poll/PollImage';
-import PollDescription from './Poll/PollDescription';
+import PollSubTitle from './Poll/PollSubTitle';
import PollModel from '../models/Poll';
import PollState from '../states/PollState';
-import Tooltip from 'flarum/common/components/Tooltip';
import Button from 'flarum/common/components/Button';
import ItemList from 'flarum/common/utils/ItemList';
import { slug } from '../../common';
@@ -49,7 +48,7 @@ export default class Poll extends Component {