nodebb-plugin-poll 3.1.8 → 3.2.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/lib/config.js +42 -39
- package/lib/hooks.js +93 -111
- package/lib/poll.js +218 -304
- package/lib/scheduler.js +45 -56
- package/lib/sockets.js +160 -249
- package/lib/vote.js +65 -120
- package/library.js +8 -11
- package/package.json +1 -1
- package/plugin.json +0 -7
- package/public/js/poll/creator.js +1 -1
- package/public/js/poll/serializer.js +1 -1
- package/public/scss/style.scss +0 -25
- package/templates/poll/view.tpl +5 -6
package/library.js
CHANGED
|
@@ -8,10 +8,9 @@ const Scheduler = require('./lib/scheduler');
|
|
|
8
8
|
|
|
9
9
|
const Plugin = module.exports;
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
Plugin.hooks = Hooks;
|
|
13
12
|
|
|
14
|
-
Plugin.load = function (params
|
|
13
|
+
Plugin.load = async function (params) {
|
|
15
14
|
const routeHelpers = require.main.require('./src/routes/helpers');
|
|
16
15
|
const { router } = params;
|
|
17
16
|
|
|
@@ -27,27 +26,25 @@ Plugin.load = function (params, callback) {
|
|
|
27
26
|
NodeBB.app = params.app;
|
|
28
27
|
Scheduler.start();
|
|
29
28
|
|
|
30
|
-
Config.init(
|
|
29
|
+
await Config.init();
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
Plugin.addAdminNavigation = function (adminHeader
|
|
32
|
+
Plugin.addAdminNavigation = function (adminHeader) {
|
|
34
33
|
adminHeader.plugins.push({
|
|
35
34
|
route: `/plugins/${Config.plugin.id}`,
|
|
36
35
|
icon: Config.plugin.icon,
|
|
37
36
|
name: Config.plugin.name,
|
|
38
37
|
});
|
|
39
|
-
|
|
40
|
-
callback(null, adminHeader);
|
|
38
|
+
return adminHeader;
|
|
41
39
|
};
|
|
42
40
|
|
|
43
|
-
Plugin.registerFormatting = function (payload
|
|
41
|
+
Plugin.registerFormatting = function (payload) {
|
|
44
42
|
payload.options.push({
|
|
45
43
|
name: 'poll',
|
|
46
44
|
className: `fa ${Config.plugin.icon}`,
|
|
47
45
|
title: '[[poll:creator_title]]',
|
|
48
46
|
});
|
|
49
|
-
|
|
50
|
-
callback(null, payload);
|
|
47
|
+
return payload;
|
|
51
48
|
};
|
|
52
49
|
|
|
53
50
|
Plugin.addPrivilege = function (hookData) {
|
|
@@ -56,7 +53,7 @@ Plugin.addPrivilege = function (hookData) {
|
|
|
56
53
|
);
|
|
57
54
|
};
|
|
58
55
|
|
|
59
|
-
Plugin.copyPrivilegesFrom = function (data
|
|
56
|
+
Plugin.copyPrivilegesFrom = function (data) {
|
|
60
57
|
if (data.privileges.indexOf('poll:create') === -1) {
|
|
61
58
|
data.privileges.push('poll:create');
|
|
62
59
|
}
|
|
@@ -64,5 +61,5 @@ Plugin.copyPrivilegesFrom = function (data, callback) {
|
|
|
64
61
|
if (data.privileges.indexOf('groups:poll:create') === -1) {
|
|
65
62
|
data.privileges.push('groups:poll:create');
|
|
66
63
|
}
|
|
67
|
-
|
|
64
|
+
return data;
|
|
68
65
|
};
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -20,10 +20,6 @@
|
|
|
20
20
|
{ "hook": "action:topic.delete", "method": "hooks.action.topicDelete" },
|
|
21
21
|
{ "hook": "action:topic.restore", "method": "hooks.action.topicRestore" }
|
|
22
22
|
],
|
|
23
|
-
"staticDirs": {
|
|
24
|
-
"public": "public",
|
|
25
|
-
"vendor": "vendor"
|
|
26
|
-
},
|
|
27
23
|
"scss": [
|
|
28
24
|
"public/scss/style.scss"
|
|
29
25
|
],
|
|
@@ -37,9 +33,6 @@
|
|
|
37
33
|
"../admin/plugins/poll.js": "public/js/admin.js",
|
|
38
34
|
"poll/serializer.js": "public/js/poll/serializer.js"
|
|
39
35
|
},
|
|
40
|
-
"css": [
|
|
41
|
-
"vendor/flatpickr.min.css"
|
|
42
|
-
],
|
|
43
36
|
"templates": "templates",
|
|
44
37
|
"languages": "languages",
|
|
45
38
|
"upgrades": [
|
|
@@ -85,7 +85,7 @@ module.exports = function (utils) {
|
|
|
85
85
|
|
|
86
86
|
rawOptions.forEach(function (option) {
|
|
87
87
|
if (option.length) {
|
|
88
|
-
option = option.split('-').slice(1).join('-').trim()
|
|
88
|
+
option = option.split('-').slice(1).join('-').trim();
|
|
89
89
|
|
|
90
90
|
if (option.length) {
|
|
91
91
|
pollOptions.push(option);
|
package/public/scss/style.scss
CHANGED
|
@@ -2,28 +2,3 @@
|
|
|
2
2
|
.composer.reply .poll, .composer.reply .ql-poll {
|
|
3
3
|
display: none;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
.poll-view {
|
|
7
|
-
h2, h3 {
|
|
8
|
-
margin-top: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.card-title {
|
|
12
|
-
display: inline-block;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.btn-group {
|
|
16
|
-
display: block;
|
|
17
|
-
a {
|
|
18
|
-
color: inherit;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.poll-result-details:hover {
|
|
24
|
-
text-decoration: none;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.poll-creator {
|
|
28
|
-
z-index: 11000 !important;
|
|
29
|
-
}
|
package/templates/poll/view.tpl
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
<div class="poll-view mb-3" data-poll-id="{poll.info.pollId}">
|
|
2
2
|
<div class="card">
|
|
3
|
-
<div class="card-header">
|
|
3
|
+
<div class="card-header d-flex justify-content-between align-items-center">
|
|
4
4
|
<h5 class="card-title mb-0">{poll.settings.title}</h5>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
</div>
|
|
5
|
+
|
|
6
|
+
<a href="#" class="btn btn-sm btn-light border poll-button-edit hidden">
|
|
7
|
+
<span class="fa fa-pencil"></span>
|
|
8
|
+
</a>
|
|
10
9
|
</div>
|
|
11
10
|
<div class="card-body">
|
|
12
11
|
<div class="poll-view-messages hidden"></div>
|