nodebb-plugin-poll 4.0.10 → 4.0.12
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/config.js +1 -1
- package/lib/hooks.js +4 -4
- package/lib/nodebb.js +12 -12
- package/lib/poll.js +2 -2
- package/lib/sockets.js +6 -6
- package/lib/vote.js +2 -2
- package/library.js +5 -5
- package/package.json +4 -4
- package/public/js/poll/creator.js +11 -10
- package/upgrades/convert_poll_id_voters_and_options_votes_to_sorted_sets.js +1 -1
- package/upgrades/fix_incorrect_poll_privilege.js +2 -2
- package/upgrades/give_categories_poll_create_privs_to_reg_users.js +1 -1
- package/upgrades/poll-4.0-upgrade.js +2 -2
package/lib/config.js
CHANGED
package/lib/hooks.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const db =
|
|
4
|
-
const topics =
|
|
5
|
-
const posts =
|
|
6
|
-
const privileges =
|
|
3
|
+
const db = nodebb.require('./src/database');
|
|
4
|
+
const topics = nodebb.require('./src/topics');
|
|
5
|
+
const posts = nodebb.require('./src/posts');
|
|
6
|
+
const privileges = nodebb.require('./src/privileges');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const Config = require('./config');
|
package/lib/nodebb.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
db:
|
|
5
|
-
Settings:
|
|
6
|
-
Meta:
|
|
7
|
-
User:
|
|
8
|
-
Posts:
|
|
9
|
-
Topics:
|
|
10
|
-
Privileges:
|
|
11
|
-
Plugins:
|
|
12
|
-
PluginSockets:
|
|
13
|
-
SocketIndex:
|
|
14
|
-
Translator:
|
|
15
|
-
winston:
|
|
4
|
+
db: nodebb.require('./src/database'),
|
|
5
|
+
Settings: nodebb.require('./src/settings'),
|
|
6
|
+
Meta: nodebb.require('./src/meta'),
|
|
7
|
+
User: nodebb.require('./src/user'),
|
|
8
|
+
Posts: nodebb.require('./src/posts'),
|
|
9
|
+
Topics: nodebb.require('./src/topics'),
|
|
10
|
+
Privileges: nodebb.require('./src/privileges'),
|
|
11
|
+
Plugins: nodebb.require('./src/plugins'),
|
|
12
|
+
PluginSockets: nodebb.require('./src/socket.io/plugins'),
|
|
13
|
+
SocketIndex: nodebb.require('./src/socket.io/index'),
|
|
14
|
+
Translator: nodebb.require('./src/translator'),
|
|
15
|
+
winston: nodebb.require('winston'),
|
|
16
16
|
app: null,
|
|
17
17
|
};
|
package/lib/poll.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const db =
|
|
4
|
-
const privileges =
|
|
3
|
+
const db = nodebb.require('./src/database');
|
|
4
|
+
const privileges = nodebb.require('./src/privileges');
|
|
5
5
|
|
|
6
6
|
const Vote = require('./vote');
|
|
7
7
|
|
package/lib/sockets.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const _ =
|
|
4
|
-
const db =
|
|
5
|
-
const posts =
|
|
6
|
-
const topics =
|
|
7
|
-
const privileges =
|
|
3
|
+
const _ = nodebb.require('lodash');
|
|
4
|
+
const db = nodebb.require('./src/database');
|
|
5
|
+
const posts = nodebb.require('./src/posts');
|
|
6
|
+
const topics = nodebb.require('./src/topics');
|
|
7
|
+
const privileges = nodebb.require('./src/privileges');
|
|
8
8
|
|
|
9
9
|
const NodeBB = require('./nodebb');
|
|
10
10
|
const Config = require('./config');
|
|
@@ -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/lib/vote.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const db =
|
|
4
|
-
const privileges =
|
|
3
|
+
const db = nodebb.require('./src/database');
|
|
4
|
+
const privileges = nodebb.require('./src/privileges');
|
|
5
5
|
|
|
6
6
|
const Poll = require('./poll');
|
|
7
7
|
|
package/library.js
CHANGED
|
@@ -5,16 +5,16 @@ const Config = require('./lib/config');
|
|
|
5
5
|
const Sockets = require('./lib/sockets');
|
|
6
6
|
const Hooks = require('./lib/hooks');
|
|
7
7
|
const Poll = require('./lib/poll');
|
|
8
|
-
const db =
|
|
9
|
-
const pagination =
|
|
10
|
-
const utils =
|
|
8
|
+
const db = nodebb.require('./src/database');
|
|
9
|
+
const pagination = nodebb.require('./src/pagination');
|
|
10
|
+
const utils = nodebb.require('./src/utils');
|
|
11
11
|
|
|
12
12
|
const Plugin = module.exports;
|
|
13
13
|
|
|
14
14
|
Plugin.hooks = Hooks;
|
|
15
15
|
|
|
16
16
|
Plugin.load = async function (params) {
|
|
17
|
-
const routeHelpers =
|
|
17
|
+
const routeHelpers = nodebb.require('./src/routes/helpers');
|
|
18
18
|
const { router } = params;
|
|
19
19
|
|
|
20
20
|
routeHelpers.setupAdminPageRoute(router, `/admin/plugins/${Config.plugin.id}`, async (req, res) => {
|
|
@@ -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.12",
|
|
4
4
|
"description": "NodeBB Poll Plugin",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,10 +26,10 @@
|
|
|
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
|
-
"eslint": "10.0
|
|
33
|
-
"eslint-config-nodebb": "^2.0.
|
|
32
|
+
"eslint": "10.6.0",
|
|
33
|
+
"eslint-config-nodebb": "^2.0.3"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -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',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const db =
|
|
4
|
-
const privileges =
|
|
3
|
+
const db = nodebb.require('./src/database');
|
|
4
|
+
const privileges = nodebb.require('./src/privileges');
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
name: 'Fix incorrectly given poll privilege',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const db =
|
|
4
|
-
const batch =
|
|
3
|
+
const db = nodebb.require('./src/database');
|
|
4
|
+
const batch = nodebb.require('./src/batch');
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
name: 'Convert data structures for v4.0',
|