nodebb-plugin-poll 2.0.6 → 3.0.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/languages/en_GB/poll.json +2 -1
- package/library.js +5 -14
- package/package.json +2 -2
- package/plugin.json +3 -8
- package/public/js/poll/view.js +1 -1
- package/public/{less/style.less → scss/style.scss} +1 -9
- package/templates/admin/plugins/poll.tpl +22 -23
- package/templates/poll/creator.tpl +19 -20
- package/templates/poll/view/details.tpl +1 -5
- package/templates/poll/view/results.tpl +1 -1
- package/templates/poll/view.tpl +5 -5
package/library.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const NodeBB = require('./lib/nodebb');
|
|
4
4
|
const Config = require('./lib/config');
|
|
5
5
|
const Sockets = require('./lib/sockets');
|
|
6
6
|
const Hooks = require('./lib/hooks');
|
|
@@ -46,19 +46,10 @@ const Scheduler = require('./lib/scheduler');
|
|
|
46
46
|
callback(null, payload);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
Plugin.
|
|
50
|
-
privileges.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Plugin.addPrivilegeLabels = function (labels, callback) {
|
|
55
|
-
labels.push({ name: 'Create Poll' });
|
|
56
|
-
callback(null, labels);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
Plugin.addGroupPrivilege = function (privileges, callback) {
|
|
60
|
-
privileges.push('groups:poll:create');
|
|
61
|
-
callback(null, privileges);
|
|
49
|
+
Plugin.addPrivilege = function (hookData) {
|
|
50
|
+
hookData.privileges.set(
|
|
51
|
+
'poll:create', { label: '[[poll:admin.create-poll]]' },
|
|
52
|
+
);
|
|
62
53
|
};
|
|
63
54
|
|
|
64
55
|
Plugin.copyPrivilegesFrom = function (data, callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-poll",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.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": "^
|
|
29
|
+
"compatibility": "^3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"eslint": "^7.31.0",
|
package/plugin.json
CHANGED
|
@@ -8,13 +8,8 @@
|
|
|
8
8
|
{ "hook": "static:app.load", "method": "load" },
|
|
9
9
|
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
|
|
10
10
|
{ "hook": "filter:composer.formatting", "method": "registerFormatting" },
|
|
11
|
-
|
|
12
|
-
{ "hook": "filter:privileges.list", "method": "addUserPrivilege" },
|
|
13
|
-
{ "hook": "filter:privileges.groups.list", "method": "addGroupPrivilege" },
|
|
14
|
-
{ "hook": "filter:privileges.list_human", "method": "addPrivilegeLabels" },
|
|
15
|
-
{ "hook": "filter:privileges.groups.list_human", "method": "addPrivilegeLabels" },
|
|
11
|
+
{ "hook": "static:privileges.categories.init", "method": "addPrivilege" },
|
|
16
12
|
{ "hook": "filter:categories.copyPrivilegesFrom", "method": "copyPrivilegesFrom" },
|
|
17
|
-
|
|
18
13
|
{ "hook": "filter:topic.post", "method": "hooks.filter.topicPost" },
|
|
19
14
|
{ "hook": "filter:parse.raw", "method": "hooks.filter.parseRaw", "priority": 1 },
|
|
20
15
|
{ "hook": "filter:post.create", "method": "hooks.filter.postCreate" },
|
|
@@ -29,8 +24,8 @@
|
|
|
29
24
|
"public": "public",
|
|
30
25
|
"vendor": "vendor"
|
|
31
26
|
},
|
|
32
|
-
"
|
|
33
|
-
"public/
|
|
27
|
+
"scss": [
|
|
28
|
+
"public/scss/style.scss"
|
|
34
29
|
],
|
|
35
30
|
"scripts": [
|
|
36
31
|
"public/js/poll/main.js",
|
package/public/js/poll/view.js
CHANGED
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
var el = this.dom.resultsPanel.find('[data-poll-option-id=' + option.id + ']');
|
|
230
230
|
el.find('.poll-result-votecount span').text(option.voteCount);
|
|
231
231
|
el.find('.poll-result-progressbar').css('width', option.percentage + '%')
|
|
232
|
-
.find('span').text(option.percentage);
|
|
232
|
+
.find('span.percent').text(option.percentage);
|
|
233
233
|
}, this);
|
|
234
234
|
};
|
|
235
235
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
margin-top: 0;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.
|
|
11
|
+
.card-title {
|
|
12
12
|
display: inline-block;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -24,14 +24,6 @@
|
|
|
24
24
|
min-width: 2em;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
.poll-result-avatar {
|
|
28
|
-
width: 50px;
|
|
29
|
-
height: 50px;
|
|
30
|
-
font-size: 3rem;
|
|
31
|
-
vertical-align: middle;
|
|
32
|
-
margin-bottom: 3px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
27
|
.poll-result-details:hover {
|
|
36
28
|
text-decoration: none;
|
|
37
29
|
}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
<div class="row">
|
|
2
2
|
<div class="col-lg-9">
|
|
3
3
|
<form class="form poll-settings">
|
|
4
|
-
<div class="
|
|
5
|
-
<div class="
|
|
6
|
-
<div class="
|
|
4
|
+
<div class="card">
|
|
5
|
+
<div class="card-header">[[poll:poll]]</div>
|
|
6
|
+
<div class="card-body">
|
|
7
7
|
<div class="row">
|
|
8
8
|
<div class="col-lg-6">
|
|
9
|
-
<
|
|
10
|
-
<div class="
|
|
11
|
-
<div class="
|
|
12
|
-
<label>
|
|
13
|
-
|
|
14
|
-
</label>
|
|
9
|
+
<h6>[[poll:toggles]]</h6>
|
|
10
|
+
<div class="mb-3">
|
|
11
|
+
<div class="form-check">
|
|
12
|
+
<label class="form-check-label">[[poll:allow_guests]]</label>
|
|
13
|
+
<input class="form-check-input" type="checkbox" data-key="toggles.allowAnon" data-trim="false">
|
|
15
14
|
</div>
|
|
16
15
|
</div>
|
|
17
16
|
</div>
|
|
18
17
|
<div class="col-lg-6">
|
|
19
|
-
<
|
|
20
|
-
<div
|
|
21
|
-
<label for="maxPollOptions">[[poll:max_options]]</label>
|
|
18
|
+
<h6>[[poll:limits]]</h6>
|
|
19
|
+
<div>
|
|
20
|
+
<label class="form-label" for="maxPollOptions">[[poll:max_options]]</label>
|
|
22
21
|
<input type="number" class="form-control" id="maxPollOptions" placeholder="10" min="1" max="100" data-key="limits.maxOptions">
|
|
23
22
|
</div>
|
|
24
23
|
</div>
|
|
@@ -26,19 +25,19 @@
|
|
|
26
25
|
</div>
|
|
27
26
|
</div>
|
|
28
27
|
|
|
29
|
-
<div class="
|
|
30
|
-
<div class="
|
|
31
|
-
<div class="
|
|
28
|
+
<div class="card">
|
|
29
|
+
<div class="card-header">[[poll:defaults]]</div>
|
|
30
|
+
<div class="card-body">
|
|
32
31
|
<div class="row">
|
|
33
32
|
<div class="col-lg-6">
|
|
34
|
-
<div class="
|
|
35
|
-
<label for="defaultsTitle">[[poll:default_title]]</label>
|
|
33
|
+
<div class="mb-3">
|
|
34
|
+
<label class="form-label" for="defaultsTitle">[[poll:default_title]]</label>
|
|
36
35
|
<input type="text" class="form-control" id="defaultsTitle" placeholder="Poll" data-key="defaults.title">
|
|
37
36
|
</div>
|
|
38
|
-
<div
|
|
39
|
-
<label for="defaultsMaxVotes">[[poll:max_votes]]</label>
|
|
37
|
+
<div>
|
|
38
|
+
<label class="form-label" for="defaultsMaxVotes">[[poll:max_votes]]</label>
|
|
40
39
|
<input type="number" class="form-control" id="defaultsMaxVotes" placeholder="1" min="1" max="100" data-key="defaults.maxvotes">
|
|
41
|
-
<p class="
|
|
40
|
+
<p class="form-text">[[poll:info_choices]]</p>
|
|
42
41
|
</div>
|
|
43
42
|
</div>
|
|
44
43
|
</div>
|
|
@@ -48,9 +47,9 @@
|
|
|
48
47
|
</div>
|
|
49
48
|
|
|
50
49
|
<div class="col-lg-3">
|
|
51
|
-
<div class="
|
|
52
|
-
<div class="
|
|
53
|
-
<div class="
|
|
50
|
+
<div class="card">
|
|
51
|
+
<div class="card-header">[[poll:settings]]</div>
|
|
52
|
+
<div class="card-body">
|
|
54
53
|
<button id="save" class="btn btn-primary btn-block">[[poll:save]]</button>
|
|
55
54
|
<button id="reset" class="btn btn-warning btn-block">[[poll:reset]]</button>
|
|
56
55
|
</div>
|
|
@@ -1,51 +1,50 @@
|
|
|
1
1
|
<form class="form" id="pollCreator">
|
|
2
2
|
<div id="pollErrorBox" class="alert alert-danger hidden"></div>
|
|
3
3
|
|
|
4
|
-
<div class="
|
|
5
|
-
<label for="pollInputTitle">[[poll:poll_title]]</label>
|
|
4
|
+
<div class="mb-3">
|
|
5
|
+
<label class="form-label" for="pollInputTitle">[[poll:poll_title]]</label>
|
|
6
6
|
<input type="text" name="settings.title" id="pollInputTitle" value="{poll.settings.title}" placeholder="[[poll:poll_title_placeholder]]" class="form-control">
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
<div class="
|
|
10
|
-
<label for="pollInputOptions">[[poll:options_title]]</label>
|
|
9
|
+
<div class="mb-3">
|
|
10
|
+
<label class="form-label" for="pollInputOptions">[[poll:options_title]]</label>
|
|
11
11
|
<!-- IF poll.options.length -->
|
|
12
12
|
<!-- BEGIN poll.options -->
|
|
13
|
-
<input type="text" name="options" id="pollInputOptions" value="{@value}" class="form-control"/>
|
|
13
|
+
<input type="text" name="options" id="pollInputOptions" value="{@value}" class="form-control mb-2"/>
|
|
14
14
|
<!-- END poll.options -->
|
|
15
15
|
<!-- ELSE -->
|
|
16
|
-
<input type="text" name="options" id="pollInputOptions" class="form-control"/>
|
|
16
|
+
<input type="text" name="options" id="pollInputOptions" class="form-control mb-2"/>
|
|
17
17
|
<!-- ENDIF poll.options.length -->
|
|
18
18
|
<button type="button" id="pollAddOption" class="btn btn-primary btn-sm btn-block">[[poll:options_add]]</button>
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
21
|
<hr>
|
|
22
22
|
|
|
23
|
-
<div class="
|
|
24
|
-
<label for="pollInputAmount">[[poll:max_votes]]</label>
|
|
23
|
+
<div class="mb-3">
|
|
24
|
+
<label class="form-label" for="pollInputAmount">[[poll:max_votes]]</label>
|
|
25
25
|
<input type="number" name="settings.maxvotes" id="pollInputAmount" value="{poll.settings.maxvotes}"
|
|
26
26
|
min="1" max="10" step="1" placeholder="[[poll:max_votes_placeholder]]" class="form-control">
|
|
27
27
|
</div>
|
|
28
28
|
|
|
29
|
-
<div class="
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
</
|
|
29
|
+
<div class="mb-3">
|
|
30
|
+
<div class="form-check">
|
|
31
|
+
<label class="form-check-label" for="pollDisallowVoteUpdate">[[poll:disallow_vote_update]]</label>
|
|
32
|
+
<input class="form-check-input" type="checkbox" name="settings.disallowVoteUpdate" id="pollDisallowVoteUpdate" {{{if poll.settings.disallowVoteUpdate}}}checked{{{end}}}>
|
|
33
|
+
</div>
|
|
34
34
|
</div>
|
|
35
35
|
|
|
36
|
-
<div class="
|
|
37
|
-
<label for="pollInputEnd">[[poll:auto_end_title]]</label>
|
|
38
|
-
|
|
36
|
+
<div class="mb-3">
|
|
37
|
+
<label class="form-label" for="pollInputEnd">[[poll:auto_end_title]]</label>
|
|
39
38
|
<div class="input-group date flatpickr">
|
|
40
39
|
<input id="pollInputEnd" placeholder="[[poll:auto_end_placeholder]]" name="settings.end" class="form-control" value="{poll.settings.end}" data-input>
|
|
41
|
-
<a class="input-group-
|
|
40
|
+
<a class="input-group-text" data-toggle><i class="fa fa-calendar"></i></a>
|
|
42
41
|
</div>
|
|
43
|
-
<p class="
|
|
42
|
+
<p class="form-text">[[poll:auto_end_help]]</p>
|
|
44
43
|
</div>
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
{{{ if isRedactor }}}
|
|
47
46
|
<div class="alert alert-warning" role="alert">
|
|
48
47
|
[[poll:warning.redactor]]
|
|
49
48
|
</div>
|
|
50
|
-
|
|
49
|
+
{{{ end }}}
|
|
51
50
|
</form>
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
<h2>{voteCount} [[poll:vote_count]]</h2>
|
|
2
2
|
<!-- BEGIN votes -->
|
|
3
3
|
<a href="{config.relative_path}/user/{votes.userslug}" class="poll-result-details">
|
|
4
|
-
|
|
5
|
-
<img class="poll-result-avatar" title="{votes.username}" src="{votes.picture}">
|
|
6
|
-
<!-- ELSE -->
|
|
7
|
-
<div class="poll-result-avatar user-icon" title="{votes.username}" style="background-color: {votes.icon:bgColor};">{votes.icon:text}</div>
|
|
8
|
-
<!-- ENDIF votes.picture -->
|
|
4
|
+
{buildAvatar(votes, "24px", true)}
|
|
9
5
|
</a>
|
|
10
6
|
<!-- END votes -->
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</small>
|
|
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
|
-
<span>{poll.options.percentage}</span
|
|
11
|
+
<span><span class="percent">{poll.options.percentage}</span>%</span>
|
|
12
12
|
</div>
|
|
13
13
|
</div>
|
|
14
14
|
</div>
|
package/templates/poll/view.tpl
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<div class="poll-view" data-poll-id="{poll.info.pollId}">
|
|
2
|
-
<div class="
|
|
3
|
-
<div class="
|
|
4
|
-
<h3 class="
|
|
5
|
-
<div class="btn-group
|
|
2
|
+
<div class="card">
|
|
3
|
+
<div class="card-header">
|
|
4
|
+
<h3 class="card-title">{poll.settings.title}</h3>
|
|
5
|
+
<div class="btn-group float-end hidden">
|
|
6
6
|
<a href="#" class="poll-button-edit">
|
|
7
7
|
<span class="fa fa-pencil"></span>
|
|
8
8
|
</a>
|
|
9
9
|
</div>
|
|
10
10
|
</div>
|
|
11
|
-
<div class="
|
|
11
|
+
<div class="card-body">
|
|
12
12
|
<div class="poll-view-messages hidden"></div>
|
|
13
13
|
<div class="poll-view-voting <!-- IF poll.hasVoted -->hidden<!-- ENDIF poll.hasVoted -->">
|
|
14
14
|
<!-- IMPORT poll/view/voting.tpl -->
|