Skip to content

Commit

Permalink
add notification.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeloc committed Feb 2, 2024
1 parent f89c9d7 commit 7230e23
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 70 deletions.
2 changes: 1 addition & 1 deletion js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/admin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/forum.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/forum.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ app.initializers.add('nodeloc/lottery', () => {
.registerPermission(
{
icon: 'fas fa-signal',
label: app.translator.trans('nodeloc-lottery.admin.permissions.view_results_without_Enter'),
permission: 'discussion.lottery.viewResultsWithoutEnter',
label: app.translator.trans('nodeloc-lottery.admin.permissions.seeParticipants'),
permission: 'lottery.seeParticipants',
allowGuest: true,
},
'view'
Expand Down
8 changes: 4 additions & 4 deletions js/src/forum/components/CreateLotteryModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default class CreateLotteryModal extends Modal {
oninit(vnode) {
super.oninit(vnode);

this.operator_type = [Stream('money')];
this.operator_type = [Stream('discussions_started')];
this.operator = [Stream('1')];
this.operator_value = [Stream('100')];
this.operator_value = [Stream('1')];

this.prizes = Stream('');
this.price = Stream('');
Expand Down Expand Up @@ -257,9 +257,9 @@ export default class CreateLotteryModal extends Modal {
const max = 5;

if (this.operator_value.length < max) {
this.operator_type.push(Stream(''));
this.operator_type.push(Stream('money'));
this.operator.push(Stream('1'));
this.operator_value.push(Stream(''));
this.operator_value.push(Stream('1'));
} else {
alert(extractText(app.translator.trans('nodeloc-lottery.forum.modal.max', {max})));
}
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/components/EditLotteryModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default class EditLotteryModal extends CreateLotteryModal {
}

displayOptions() {
console.log('options',this.options);
return this.options.map((options, i) => (
<div className="Form-group MinMaxSelector">
<fieldset className="MinMaxSelector--inputs">
Expand Down Expand Up @@ -81,6 +80,7 @@ export default class EditLotteryModal extends CreateLotteryModal {
this.operator_type.push(Stream(''));
this.operator.push(Stream(''));
this.operator_value.push(Stream(''));
this.displayOptions();
} else {
alert(extractText(app.translator.trans('nodeloc-lottery.forum.modal.max', {max})));
}
Expand Down
9 changes: 5 additions & 4 deletions js/src/forum/components/ListLotteryModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class ListLotteryModal extends Modal {
}

title() {
return app.translator.trans('nodeloc-lottery.forum.participants_modal.title');
return app.translator.trans('nodeloc-lottery.forum.participants_modal.title' + (this.attrs.lottery.hasEnded() ? '_winners':''));
}

content() {
Expand All @@ -33,10 +33,8 @@ export default class ListLotteryModal extends Modal {

optionContent() {
const participants = this.attrs.lottery.participants();

return (
<div className="VotesModal-option">
<h2>Participants:</h2>
{participants.length ? (
<div className="VotesModal-list">{participants.map(this.participantsContent.bind(this))}</div>
) : (
Expand All @@ -45,9 +43,12 @@ export default class ListLotteryModal extends Modal {
</div>
);
}

participantsContent(participants) {
const user = participants.user();
// 只在 hasEnded 为 true 时显示 status=1 的用户
if (this.attrs.lottery.hasEnded() && participants.status() !== 1) {
return null;
}
const attrs = user && { href: app.route.user(user) };

return (
Expand Down
Loading

0 comments on commit 7230e23

Please sign in to comment.