Skip to content

Commit

Permalink
fix: rename image attribute to reflect backend changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Mar 15, 2024
1 parent 7ab5b79 commit 1338db5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/src/forum/components/PollForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class PollForm extends Component<PollFormAttrs, PollFormState> {
protected optionImageUrls: Stream<string>[] = [];
protected question: Stream<string>;
protected subtitle: Stream<string>;
protected pollImage: Stream<string | null>;
protected image: Stream<string | null>;
protected imageAlt: Stream<string | null>;
protected endDate: Stream<string | null>;
protected publicPoll: Stream<boolean>;
Expand All @@ -49,7 +49,7 @@ export default class PollForm extends Component<PollFormAttrs, PollFormState> {

this.question = Stream(poll.question());
this.subtitle = Stream(poll.subtitle());
this.pollImage = Stream(poll.imageUrl());
this.image = Stream(poll.image());
this.imageAlt = Stream(poll.imageAlt());
this.endDate = Stream(this.formatDate(poll.endDate()));
this.publicPoll = Stream(poll.publicPoll());
Expand Down Expand Up @@ -105,12 +105,12 @@ export default class PollForm extends Component<PollFormAttrs, PollFormState> {
<label className="label">{app.translator.trans('fof-polls.forum.modal.poll_image.label')}</label>
<p className="helpText">{app.translator.trans('fof-polls.forum.modal.poll_image.help')}</p>
<UploadPollImageButton name="pollImage" poll={this.state.poll} onUpload={this.pollImageUploadSuccess.bind(this)} />
<input type="hidden" name="pollImage" value={this.pollImage()} />
<input type="hidden" name="pollImage" value={this.image()} />
</div>,
90
);

if (this.pollImage()) {
if (this.image()) {
items.add(
'poll_image_alt',
<div className="Form-group">
Expand Down Expand Up @@ -332,7 +332,7 @@ export default class PollForm extends Component<PollFormAttrs, PollFormState> {
return {
question: this.question(),
subtitle: this.subtitle(),
pollImage: this.pollImage(),
pollImage: this.image(),
imageAlt: this.imageAlt(),
endDate: this.dateToTimestamp(this.endDate()) ?? false,
publicPoll: this.publicPoll(),
Expand Down Expand Up @@ -388,6 +388,6 @@ export default class PollForm extends Component<PollFormAttrs, PollFormState> {
}

pollImageUploadSuccess(fileName: string | null | undefined): void {
this.pollImage(fileName);
this.image(fileName);
}
}
4 changes: 4 additions & 0 deletions js/src/forum/models/Poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default class Poll extends Model {
return Model.attribute<string | null>('subtitle').call(this);
}

image() {
return Model.attribute<string | null>('image').call(this);
}

imageUrl() {
return Model.attribute<string | null>('imageUrl').call(this);
}
Expand Down

0 comments on commit 1338db5

Please sign in to comment.