-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
323 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import app from 'flarum/forum/app'; | ||
import UploadPollImageButton, { UploadPollImageButtonAttrs } from './UploadPollImageButton'; | ||
import PollOption from '../models/PollOption'; | ||
|
||
export interface UploadPollOptionImageButtonAttrs extends UploadPollImageButtonAttrs { | ||
option: PollOption; | ||
} | ||
|
||
export default class UploadPollOptionImageButton extends UploadPollImageButton<UploadPollOptionImageButtonAttrs> { | ||
view(vnode: Mithril.Vnode<UploadPollOptionImageButtonAttrs>) { | ||
const poll = this.attrs.poll; | ||
if(poll?.exists) { | ||
|
||
return super.view(vnode); | ||
} | ||
|
||
return <p className="UploadPollOptionImageButton-info">{app.translator.trans('fof-polls.forum.modal.option_image.requires_saved_poll')}</p> | ||
} | ||
|
||
resourceUrl() { | ||
let url = app.forum.attribute('apiUrl') + '/fof/polls/pollOptionImage'; | ||
const poll = this.attrs.poll; | ||
const option = this.attrs.option; | ||
|
||
if (poll?.exists) url += '/' + poll?.id(); | ||
if (option?.exists) url += '/' + option?.id(); | ||
|
||
return url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
migrations/2024_03_07_000000_modify_poll_options_rename_image_url_to_image.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of fof/polls. | ||
* | ||
* Copyright (c) FriendsOfFlarum. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Flarum\Database\Migration; | ||
|
||
return Migration::renameColumn('poll_options', 'image_url', 'image'); |
26 changes: 26 additions & 0 deletions
26
migrations/2024_03_07_000001_create_poll_options_image_alt_column.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of fof/polls. | ||
* | ||
* Copyright (c) FriendsOfFlarum. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Schema\Builder; | ||
|
||
return [ | ||
'up' => function (Builder $schema) { | ||
$schema->table('poll_options', function (Blueprint $table) { | ||
$table->string('image_alt')->nullable()->after('image'); | ||
}); | ||
}, | ||
'down' => function (Builder $schema) { | ||
$schema->table('poll_options', function (Blueprint $table) { | ||
$table->dropColumn('image_alt'); | ||
}); | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.