nodebb-plugin-poll 4.0.9 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/sockets.js +1 -1
- package/library.js +1 -1
- package/package.json +2 -2
- package/public/js/poll/creator.js +11 -10
- package/templates/poll/creator.tpl +1 -1
- package/templates/poll/manage.tpl +1 -1
- package/templates/poll/option-input.tpl +1 -1
- package/templates/poll/view/results.tpl +1 -1
- package/templates/poll/view/voting.tpl +16 -16
- package/templates/poll/view.tpl +2 -2
package/lib/sockets.js
CHANGED
|
@@ -15,7 +15,7 @@ const Sockets = exports;
|
|
|
15
15
|
|
|
16
16
|
Sockets.get = async function (socket, data) {
|
|
17
17
|
const settings = await Config.getSettings();
|
|
18
|
-
const allowAnon =
|
|
18
|
+
const allowAnon = settings.allowGuestsToViewResults === 'on';
|
|
19
19
|
|
|
20
20
|
if (!data) {
|
|
21
21
|
throw new Error('Invalid request, request data is not defined');
|
package/library.js
CHANGED
|
@@ -92,7 +92,7 @@ Plugin.renderPollWidget = async function (widget) {
|
|
|
92
92
|
const Poll = require('./lib/poll');
|
|
93
93
|
|
|
94
94
|
const settings = await Config.getSettings();
|
|
95
|
-
const allowAnon =
|
|
95
|
+
const allowAnon = settings.allowGuestsToViewResults === 'on';
|
|
96
96
|
|
|
97
97
|
if (!widget.uid && !allowAnon) {
|
|
98
98
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-poll",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11",
|
|
4
4
|
"description": "NodeBB Poll Plugin",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"cron": "^1.8.2"
|
|
27
27
|
},
|
|
28
28
|
"nbbpm": {
|
|
29
|
-
"compatibility": "^4.
|
|
29
|
+
"compatibility": "^4.14.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"eslint": "10.0.3",
|
|
@@ -41,21 +41,22 @@
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
async function openManageModal(payload) {
|
|
44
|
-
const
|
|
44
|
+
const [modals, Benchpress] = await app.require(['modals', 'benchpressjs']);
|
|
45
45
|
const { postData, modal, uuid } = payload;
|
|
46
|
-
const html = await
|
|
46
|
+
const html = await Benchpress.render('poll/manage', { post: postData });
|
|
47
47
|
|
|
48
48
|
if (modal) {
|
|
49
|
-
modal.find('.bootbox-body').html(html[0].outerHTML);
|
|
49
|
+
// modal.find('.bootbox-body').html(html[0].outerHTML);
|
|
50
|
+
modal.find('.bootbox-body').html(html);
|
|
50
51
|
handleSort({ modal, polls: postData.polls });
|
|
51
52
|
} else {
|
|
52
|
-
const modal =
|
|
53
|
+
const modal = await modals.dialog({
|
|
53
54
|
title: '[[poll:manage-polls]]',
|
|
54
55
|
message: html,
|
|
55
56
|
className: 'poll-manage',
|
|
56
57
|
buttons: {
|
|
57
58
|
add: {
|
|
58
|
-
label: '
|
|
59
|
+
label: '[[poll:add-poll]]',
|
|
59
60
|
className: 'btn-success',
|
|
60
61
|
callback: () => {
|
|
61
62
|
Creator.show('[[poll:creator_title]]', {
|
|
@@ -88,11 +89,11 @@
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
async function handleDelete(payload) {
|
|
91
|
-
const
|
|
92
|
+
const modals = await app.require('modals');
|
|
92
93
|
const { uuid, modal, postData } = payload;
|
|
93
94
|
modal.on('click', 'button[data-action="remove"]', function () {
|
|
94
95
|
const clickedPollId = $(this).attr('data-poll-id');
|
|
95
|
-
|
|
96
|
+
modals.confirm('[[poll:confirm-remove]]', (ok) => {
|
|
96
97
|
if (!ok) {
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
@@ -155,9 +156,9 @@
|
|
|
155
156
|
|
|
156
157
|
Creator.show = function (modalTitle, poll, config) {
|
|
157
158
|
return new Promise((resolve) => {
|
|
158
|
-
require(['
|
|
159
|
-
|
|
160
|
-
const modal =
|
|
159
|
+
app.require(['benchpressjs', 'modals']).then(([Benchpress, modals]) => {
|
|
160
|
+
Benchpress.render('poll/creator', { poll, config }).then(async function (html) {
|
|
161
|
+
const modal = await modals.dialog({
|
|
161
162
|
title: modalTitle,
|
|
162
163
|
message: html,
|
|
163
164
|
className: 'poll-creator',
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
<div class="mb-3">
|
|
7
7
|
<label class="form-label" for="pollInputTitle">[[poll:poll_title]]</label>
|
|
8
|
-
<input type="text" name="title" id="pollInputTitle" value="{
|
|
8
|
+
<input type="text" name="title" id="pollInputTitle" value="{poll.title}" placeholder="[[poll:poll_title_placeholder]]" class="form-control">
|
|
9
9
|
</div>
|
|
10
10
|
|
|
11
11
|
<div class="mb-3 d-flex flex-column gap-1">
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<div component="post/poll/item" data-poll-id="{./pollId}" class="bg-body d-flex align-items-center justify-content-between mb-3 p-1 border rounded-1">
|
|
7
7
|
<div class="d-flex align-items-center gap-1">
|
|
8
8
|
<a href="#" component="sort/handle" class="btn btn-ghost btn-sm align-self-start" style="cursor:grab;"><i class="fa fa-arrows-up-down text-muted"></i></a>
|
|
9
|
-
<div class="text-nowrap flex-grow-1">{
|
|
9
|
+
<div class="text-nowrap flex-grow-1">{./title}</div>
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
12
|
<div class="d-flex align-items-center gap-1">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div component="post/poll/option/item" data-option-id="{./id}" class="bg-body d-flex align-items-center justify-content-between gap-2 p-1 rounded-1">
|
|
2
2
|
<a href="#" component="sort/handle" class="btn btn-ghost btn-sm" style="cursor:grab;"><i class="fa fa-arrows-up-down text-muted"></i></a>
|
|
3
|
-
<input type="text" name="options" id="pollInputOptions" value="{
|
|
3
|
+
<input type="text" name="options" id="pollInputOptions" value="{./title}" class="form-control"/>
|
|
4
4
|
<input type="hidden" name="id" value="{./id}"/>
|
|
5
5
|
<button class="btn btn-ghost btn-sm" data-action="remove-option" data-option-id="{./id}"><i class="fa fa-trash text-danger"></i></button>
|
|
6
6
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- BEGIN poll.options -->
|
|
2
2
|
<div class="poll-result" data-poll-option-id="{poll.options.id}">
|
|
3
3
|
<div class="d-flex justify-content-between mb-1">
|
|
4
|
-
<strong>{
|
|
4
|
+
<strong>{poll.options.title}</strong>
|
|
5
5
|
<a class="poll-result-votecount small" href="#">
|
|
6
6
|
<span>[[poll:x-votes, {poll.options.voteCount}]]</span>
|
|
7
7
|
</a>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
<form role="form" class="poll-voting-form mb-3 d-flex flex-column gap-3">
|
|
2
|
-
<!-- BEGIN poll.options -->
|
|
3
|
-
<div class="poll-view-option {poll.optionType}" data-poll-option-id="{poll.options.id}">
|
|
4
|
-
<div class="form-check">
|
|
5
|
-
<input class="form-check-input" type="{poll.optionType}" name="pollVoteSelection" value="{poll.options.id}" id="poll-{poll.info.pollId}-option-id-{poll.options.id}">
|
|
6
|
-
<label class="form-check-label" for="poll-{poll.info.pollId}-option-id-{poll.options.id}">{
|
|
7
|
-
</div>
|
|
8
|
-
</div>
|
|
9
|
-
<!-- END poll.options -->
|
|
10
|
-
</form>
|
|
11
|
-
|
|
12
|
-
<!-- IF poll.settings.disallowVoteUpdate -->
|
|
13
|
-
<div class="alert alert-warning" role="alert">
|
|
14
|
-
[[poll:vote_is_final]]
|
|
15
|
-
</div>
|
|
16
|
-
<!-- ENDIF poll.settings.disallowVoteUpdate -->
|
|
1
|
+
<form role="form" class="poll-voting-form mb-3 d-flex flex-column gap-3">
|
|
2
|
+
<!-- BEGIN poll.options -->
|
|
3
|
+
<div class="poll-view-option {poll.optionType}" data-poll-option-id="{poll.options.id}">
|
|
4
|
+
<div class="form-check">
|
|
5
|
+
<input class="form-check-input" type="{poll.optionType}" name="pollVoteSelection" value="{poll.options.id}" id="poll-{poll.info.pollId}-option-id-{poll.options.id}">
|
|
6
|
+
<label class="form-check-label" for="poll-{poll.info.pollId}-option-id-{poll.options.id}">{poll.options.title}</label>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
<!-- END poll.options -->
|
|
10
|
+
</form>
|
|
11
|
+
|
|
12
|
+
<!-- IF poll.settings.disallowVoteUpdate -->
|
|
13
|
+
<div class="alert alert-warning" role="alert">
|
|
14
|
+
[[poll:vote_is_final]]
|
|
15
|
+
</div>
|
|
16
|
+
<!-- ENDIF poll.settings.disallowVoteUpdate -->
|
package/templates/poll/view.tpl
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
<div class="card-header border-0 d-flex justify-content-between align-items-center flex-wrap">
|
|
4
4
|
<h5 class="card-title mb-0 {{{ if poll.isWidget }}}fs-6{{{ end }}}">
|
|
5
5
|
{{{ if poll.isWidget }}}
|
|
6
|
-
<a class="text-reset text-break" href="{config.relative_path}/post/{poll.info.pid}">{
|
|
6
|
+
<a class="text-reset text-break" href="{config.relative_path}/post/{poll.info.pid}">{poll.info.title}</a>
|
|
7
7
|
{{{ else }}}
|
|
8
|
-
{
|
|
8
|
+
{poll.info.title}
|
|
9
9
|
{{{ end }}}
|
|
10
10
|
</h5>
|
|
11
11
|
{{{ if (isAdmin && !poll.isWidget) }}}
|