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 CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const meta = require.main.require('./src/meta');
3
+ const meta = nodebb.require('./src/meta');
4
4
 
5
5
  const packageInfo = require('../package.json');
6
6
  const pluginInfo = require('../plugin.json');
package/lib/hooks.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const db = require.main.require('./src/database');
4
- const topics = require.main.require('./src/topics');
5
- const posts = require.main.require('./src/posts');
6
- const privileges = require.main.require('./src/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: require.main.require('./src/database'),
5
- Settings: require.main.require('./src/settings'),
6
- Meta: require.main.require('./src/meta'),
7
- User: require.main.require('./src/user'),
8
- Posts: require.main.require('./src/posts'),
9
- Topics: require.main.require('./src/topics'),
10
- Privileges: require.main.require('./src/privileges'),
11
- Plugins: require.main.require('./src/plugins'),
12
- PluginSockets: require.main.require('./src/socket.io/plugins'),
13
- SocketIndex: require.main.require('./src/socket.io/index'),
14
- Translator: require.main.require('./src/translator'),
15
- winston: require.main.require('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 = require.main.require('./src/database');
4
- const privileges = require.main.require('./src/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 _ = require.main.require('lodash');
4
- const db = require.main.require('./src/database');
5
- const posts = require.main.require('./src/posts');
6
- const topics = require.main.require('./src/topics');
7
- const privileges = require.main.require('./src/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 = parseInt(settings.allowGuestsToViewResults, 10) === 1;
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 = require.main.require('./src/database');
4
- const privileges = require.main.require('./src/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 = require.main.require('./src/database');
9
- const pagination = require.main.require('./src/pagination');
10
- const utils = require.main.require('./src/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 = require.main.require('./src/routes/helpers');
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 = parseInt(settings.allowGuestsToViewResults, 10) === 1;
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.10",
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.12.0"
29
+ "compatibility": "^4.14.0"
30
30
  },
31
31
  "devDependencies": {
32
- "eslint": "10.0.3",
33
- "eslint-config-nodebb": "^2.0.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 bootbox = await app.require('bootbox');
44
+ const [modals, Benchpress] = await app.require(['modals', 'benchpressjs']);
45
45
  const { postData, modal, uuid } = payload;
46
- const html = await app.parseAndTranslate('poll/manage', { post: postData });
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 = bootbox.dialog({
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: '<i class="fa fa-plus"></i> [[poll:add-poll]]',
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 bootbox = await app.require('bootbox');
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
- bootbox.confirm('[[poll:confirm-remove]]', (ok) => {
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(['bootbox'], function (bootbox) {
159
- app.parseAndTranslate('poll/creator', { poll, config }, function (html) {
160
- const modal = bootbox.dialog({
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,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const async = require.main.require('async');
3
+ const async = nodebb.require('async');
4
4
  const NodeBB = require('../lib/nodebb');
5
5
 
6
6
  const timestamp = Date.UTC(2019, 3, 1);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const db = require.main.require('./src/database');
4
- const privileges = require.main.require('./src/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,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const async = require.main.require('async');
3
+ const async = nodebb.require('async');
4
4
  const NodeBB = require('../lib/nodebb');
5
5
 
6
6
  module.exports = {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const db = require.main.require('./src/database');
4
- const batch = require.main.require('./src/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',