nodebb-plugin-poll 3.0.5 → 3.1.1

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/library.js CHANGED
@@ -6,60 +6,63 @@ const Sockets = require('./lib/sockets');
6
6
  const Hooks = require('./lib/hooks');
7
7
  const Scheduler = require('./lib/scheduler');
8
8
 
9
- (function (Plugin) {
10
- Plugin.hooks = Hooks;
9
+ const Plugin = module.exports;
11
10
 
12
- Plugin.load = function (params, callback) {
13
- function renderAdmin(req, res) {
14
- res.render(`admin/plugins/${Config.plugin.id}`, {});
15
- }
16
11
 
17
- params.router.get(`/admin/plugins/${Config.plugin.id}`, params.middleware.admin.buildHeader, renderAdmin);
18
- params.router.get(`/api/admin/plugins/${Config.plugin.id}`, renderAdmin);
12
+ Plugin.hooks = Hooks;
19
13
 
20
- NodeBB.PluginSockets[Config.plugin.id] = Sockets;
21
- NodeBB.AdminSockets[Config.plugin.id] = Config.adminSockets;
14
+ Plugin.load = function (params, callback) {
15
+ const routeHelpers = require.main.require('./src/routes/helpers');
16
+ const { router } = params;
22
17
 
23
- NodeBB.app = params.app;
24
- Scheduler.start();
18
+ routeHelpers.setupAdminPageRoute(router, `/admin/plugins/${Config.plugin.id}`, (req, res) => {
19
+ res.render(`admin/plugins/${Config.plugin.id}`, {
20
+ title: 'Poll',
21
+ });
22
+ });
25
23
 
26
- Config.init(callback);
27
- };
24
+ NodeBB.PluginSockets[Config.plugin.id] = Sockets;
25
+ NodeBB.AdminSockets[Config.plugin.id] = Config.adminSockets;
28
26
 
29
- Plugin.addAdminNavigation = function (adminHeader, callback) {
30
- adminHeader.plugins.push({
31
- route: `/plugins/${Config.plugin.id}`,
32
- icon: Config.plugin.icon,
33
- name: Config.plugin.name,
34
- });
27
+ NodeBB.app = params.app;
28
+ Scheduler.start();
35
29
 
36
- callback(null, adminHeader);
37
- };
30
+ Config.init(callback);
31
+ };
38
32
 
39
- Plugin.registerFormatting = function (payload, callback) {
40
- payload.options.push({
41
- name: 'poll',
42
- className: `fa ${Config.plugin.icon}`,
43
- title: '[[poll:creator_title]]',
44
- });
33
+ Plugin.addAdminNavigation = function (adminHeader, callback) {
34
+ adminHeader.plugins.push({
35
+ route: `/plugins/${Config.plugin.id}`,
36
+ icon: Config.plugin.icon,
37
+ name: Config.plugin.name,
38
+ });
39
+
40
+ callback(null, adminHeader);
41
+ };
42
+
43
+ Plugin.registerFormatting = function (payload, callback) {
44
+ payload.options.push({
45
+ name: 'poll',
46
+ className: `fa ${Config.plugin.icon}`,
47
+ title: '[[poll:creator_title]]',
48
+ });
49
+
50
+ callback(null, payload);
51
+ };
52
+
53
+ Plugin.addPrivilege = function (hookData) {
54
+ hookData.privileges.set(
55
+ 'poll:create', { label: '[[poll:admin.create-poll]]' },
56
+ );
57
+ };
58
+
59
+ Plugin.copyPrivilegesFrom = function (data, callback) {
60
+ if (data.privileges.indexOf('poll:create') === -1) {
61
+ data.privileges.push('poll:create');
62
+ }
45
63
 
46
- callback(null, payload);
47
- };
48
-
49
- Plugin.addPrivilege = function (hookData) {
50
- hookData.privileges.set(
51
- 'poll:create', { label: '[[poll:admin.create-poll]]' },
52
- );
53
- };
54
-
55
- Plugin.copyPrivilegesFrom = function (data, callback) {
56
- if (data.privileges.indexOf('poll:create') === -1) {
57
- data.privileges.push('poll:create');
58
- }
59
-
60
- if (data.privileges.indexOf('groups:poll:create') === -1) {
61
- data.privileges.push('groups:poll:create');
62
- }
63
- callback(null, data);
64
- };
65
- }(exports));
64
+ if (data.privileges.indexOf('groups:poll:create') === -1) {
65
+ data.privileges.push('groups:poll:create');
66
+ }
67
+ callback(null, data);
68
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-poll",
3
- "version": "3.0.5",
3
+ "version": "3.1.1",
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": "^3.0.0"
29
+ "compatibility": "^3.2.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "eslint": "^7.31.0",
@@ -1,11 +1,21 @@
1
- <div class="row">
2
- <div class="col-lg-9">
3
- <form class="form poll-settings">
4
- <div class="card">
5
- <div class="card-header">[[poll:poll]]</div>
6
- <div class="card-body">
7
- <div class="row">
8
- <div class="col-lg-6">
1
+ <div class="acp-page-container">
2
+ <div component="settings/main/header" class="row border-bottom py-2 m-0 sticky-top acp-page-main-header align-items-center">
3
+ <div class="col-12 col-md-8 px-0 mb-1 mb-md-0">
4
+ <h4 class="fw-bold tracking-tight mb-0">{title}</h4>
5
+ </div>
6
+ <div class="col-12 col-md-4 px-0 px-md-3 text-end">
7
+ <button id="reset" class="btn btn-warning btn-sm fw-semibold ff-secondary text-center text-nowrap">[[poll:reset]]</button>
8
+ <button id="save" class="btn btn-primary btn-sm fw-semibold ff-secondary text-center text-nowrap">[[admin/admin:save-changes]]</button>
9
+ </div>
10
+ </div>
11
+
12
+ <div class="row m-0">
13
+ <div id="spy-container" class="col-12 px-0 mb-4" tabindex="0">
14
+ <form class="form poll-settings">
15
+ <div class="card">
16
+ <div class="card-header">[[poll:poll]]</div>
17
+ <div class="card-body">
18
+ <div class="mb-3">
9
19
  <h6>[[poll:toggles]]</h6>
10
20
  <div class="mb-3">
11
21
  <div class="form-check">
@@ -14,7 +24,7 @@
14
24
  </div>
15
25
  </div>
16
26
  </div>
17
- <div class="col-lg-6">
27
+ <div class="mb-3">
18
28
  <h6>[[poll:limits]]</h6>
19
29
  <div>
20
30
  <label class="form-label" for="maxPollOptions">[[poll:max_options]]</label>
@@ -23,36 +33,26 @@
23
33
  </div>
24
34
  </div>
25
35
  </div>
26
- </div>
27
36
 
28
- <div class="card">
29
- <div class="card-header">[[poll:defaults]]</div>
30
- <div class="card-body">
31
- <div class="row">
32
- <div class="col-lg-6">
33
- <div class="mb-3">
34
- <label class="form-label" for="defaultsTitle">[[poll:default_title]]</label>
35
- <input type="text" class="form-control" id="defaultsTitle" placeholder="Poll" data-key="defaults.title">
36
- </div>
37
- <div>
38
- <label class="form-label" for="defaultsMaxVotes">[[poll:max_votes]]</label>
39
- <input type="number" class="form-control" id="defaultsMaxVotes" placeholder="1" min="1" max="100" data-key="defaults.maxvotes">
40
- <p class="form-text">[[poll:info_choices]]</p>
41
- </div>
37
+ <div class="card">
38
+ <div class="card-header">[[poll:defaults]]</div>
39
+ <div class="card-body">
40
+ <div class="mb-3">
41
+ <label class="form-label" for="defaultsTitle">[[poll:default_title]]</label>
42
+ <input type="text" class="form-control" id="defaultsTitle" placeholder="Poll" data-key="defaults.title">
43
+ </div>
44
+ <div>
45
+ <label class="form-label" for="defaultsMaxVotes">[[poll:max_votes]]</label>
46
+ <input type="number" class="form-control" id="defaultsMaxVotes" placeholder="1" min="1" max="100" data-key="defaults.maxvotes">
47
+ <p class="form-text">[[poll:info_choices]]</p>
42
48
  </div>
43
49
  </div>
44
50
  </div>
45
- </div>
46
- </form>
47
- </div>
51
+ </form>
52
+ </div>
53
+
54
+ <!-- IMPORT admin/partials/settings/toc.tpl -->
55
+ </div>
56
+ </div>
57
+
48
58
 
49
- <div class="col-lg-3">
50
- <div class="card">
51
- <div class="card-header">[[poll:settings]]</div>
52
- <div class="card-body">
53
- <button id="save" class="btn btn-primary btn-block">[[poll:save]]</button>
54
- <button id="reset" class="btn btn-warning btn-block">[[poll:reset]]</button>
55
- </div>
56
- </div>
57
- </div>
58
- </div>
@@ -1,11 +1,11 @@
1
1
  <!-- BEGIN poll.options -->
2
2
  <div class="poll-result" data-poll-option-id="{poll.options.id}">
3
- <strong>{poll.options.title}</strong>
4
- <small class="pull-right">
5
- <a class="poll-result-votecount" href="#">
3
+ <div class="d-flex justify-content-between mb-1">
4
+ <strong>{poll.options.title}</strong>
5
+ <a class="poll-result-votecount small" href="#">
6
6
  <span>{poll.options.voteCount}</span> [[poll:votes]]
7
7
  </a>
8
- </small>
8
+ </div>
9
9
  <div class="progress">
10
10
  <div class="progress-bar poll-result-progressbar" role="progressbar" aria-valuenow="{poll.options.percentage}" aria-valuemin="0" aria-valuemax="100" style="width: {poll.options.percentage}%;">
11
11
  <span><span class="percent">{poll.options.percentage}</span>%</span>
@@ -1,4 +1,4 @@
1
- <form role="form" class="poll-voting-form">
1
+ <form role="form" class="poll-voting-form mb-3 d-flex flex-column gap-3">
2
2
  <!-- BEGIN poll.options -->
3
3
  <div class="poll-view-option {poll.optionType}" data-poll-option-id="{poll.options.id}">
4
4
  <label>
@@ -1,7 +1,7 @@
1
1
  <div class="poll-view" data-poll-id="{poll.info.pollId}">
2
2
  <div class="card">
3
3
  <div class="card-header">
4
- <h3 class="card-title">{poll.settings.title}</h3>
4
+ <h5 class="card-title mb-0">{poll.settings.title}</h5>
5
5
  <div class="btn-group float-end hidden">
6
6
  <a href="#" class="poll-button-edit">
7
7
  <span class="fa fa-pencil"></span>
@@ -13,7 +13,7 @@
13
13
  <div class="poll-view-voting <!-- IF poll.hasVoted -->hidden<!-- ENDIF poll.hasVoted -->">
14
14
  <!-- IMPORT poll/view/voting.tpl -->
15
15
  </div>
16
- <div class="poll-view-results <!-- IF !poll.hasVoted -->hidden<!-- ENDIF !poll.hasVoted -->">
16
+ <div class="poll-view-results d-flex flex-column gap-3 mb-3 <!-- IF !poll.hasVoted -->hidden<!-- ENDIF !poll.hasVoted -->">
17
17
  <!-- IMPORT poll/view/results.tpl -->
18
18
  </div>
19
19