decidim-notify 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -1
- data/Rakefile +8 -0
- data/app/cells/decidim/notify/note/show.erb +1 -1
- data/app/cells/decidim/notify/participant_cell.rb +2 -1
- data/app/controllers/decidim/notify/conversations_controller.rb +1 -1
- data/app/models/decidim/notify/author.rb +1 -1
- data/app/packs/entrypoints/decidim_notify_component.js +9 -0
- data/app/packs/entrypoints/decidim_notify_component.scss +1 -0
- data/app/packs/entrypoints/decidim_notify_selects.js +1 -0
- data/app/{assets → packs}/images/decidim/notify/icon.svg +0 -0
- data/app/packs/src/decidim/notify/consumer.js +7 -0
- data/app/{assets/javascripts/decidim/notify/conversations.js.es6 → packs/src/decidim/notify/notify.js} +20 -21
- data/app/packs/src/decidim/notify/notify_channel.js +100 -0
- data/app/{assets/javascripts/decidim/notify/select2.js.es6 → packs/src/decidim/notify/notify_selects.js} +15 -12
- data/app/{assets → packs}/stylesheets/decidim/notify/admin.scss +0 -0
- data/app/{assets/stylesheets/decidim/notify/_hexagon.scss → packs/stylesheets/decidim/notify/hexagon.scss} +0 -0
- data/app/{assets → packs}/stylesheets/decidim/notify/notify.scss +6 -3
- data/{vendor/assets/stylesheets → app/packs/stylesheets/decidim/notify}/select2-foundation-theme.css +0 -0
- data/app/views/decidim/notify/admin/conversations/index.html.erb +2 -1
- data/app/views/decidim/notify/conversations/_script.js.erb +4 -2
- data/app/views/decidim/notify/conversations/index.html.erb +6 -6
- data/config/assets.rb +42 -0
- data/config/i18n-tasks.yml +1 -0
- data/config/locales/ca.yml +5 -0
- data/config/locales/cs.yml +5 -0
- data/config/locales/en.yml +5 -0
- data/config/locales/es.yml +5 -0
- data/lib/decidim/notify/component.rb +4 -4
- data/lib/decidim/notify/engine.rb +2 -2
- data/lib/decidim/notify/version.rb +2 -2
- data/lib/decidim/notify.rb +14 -17
- data/lib/tasks/decidim_notify_webpacker_tasks.rake +62 -0
- data/package.json +200 -0
- metadata +24 -22
- data/app/assets/config/decidim_notify_manifest.css +0 -2
- data/app/assets/config/decidim_notify_manifest.js +0 -3
- data/app/assets/javascripts/cable.js +0 -13
- data/app/assets/javascripts/channels/decidim/notify/conversations.js +0 -90
- data/vendor/assets/javascripts/select2.js +0 -6147
- data/vendor/assets/stylesheets/select2.css +0 -515
data/lib/decidim/notify.rb
CHANGED
@@ -13,30 +13,27 @@ module Decidim
|
|
13
13
|
|
14
14
|
class << self
|
15
15
|
def cable
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
@cable || begin
|
17
|
+
@cable = ActionCable::Server::Configuration.new
|
18
|
+
@cable.mount_path = config.cable_mount_path
|
19
|
+
@cable.connection_class = -> { Decidim::Notify::Connection }
|
20
|
+
@cable.url = config.cable_url
|
21
|
+
@cable.cable = {
|
22
|
+
"adapter" => config.cable_adapter,
|
23
|
+
"channel_prefix" => config.cable_channel_prefix
|
24
|
+
}
|
25
|
+
@cable
|
26
|
+
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def server
|
30
|
-
|
31
|
-
|
32
|
-
@server = ActionCable::Server::Base.new
|
33
|
-
@server.config = cable
|
34
|
-
@server
|
30
|
+
@server ||= ActionCable::Server::Base.new(config: cable)
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
34
|
+
# Notify uses its custom ActionCable server, better not to use the default /cable route as it causes conflicts
|
38
35
|
config_accessor :cable_mount_path do
|
39
|
-
"/
|
36
|
+
"/notify_cable"
|
40
37
|
end
|
41
38
|
|
42
39
|
# Not recommended to use "async", event for development
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "decidim/gem_manager"
|
4
|
+
|
5
|
+
namespace :decidim_notify do
|
6
|
+
namespace :webpacker do
|
7
|
+
desc "Installs Decidim Awesome webpacker files in Rails instance application"
|
8
|
+
task install: :environment do
|
9
|
+
raise "Decidim gem is not installed" if decidim_path.nil?
|
10
|
+
|
11
|
+
install_notify_npm
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Adds Decidim Awesome dependencies in package.json"
|
15
|
+
task upgrade: :environment do
|
16
|
+
raise "Decidim gem is not installed" if decidim_path.nil?
|
17
|
+
|
18
|
+
install_notify_npm
|
19
|
+
end
|
20
|
+
|
21
|
+
def install_notify_npm
|
22
|
+
notify_npm_dependencies.each do |type, packages|
|
23
|
+
system! "npm i --save-#{type} #{packages.join(" ")}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def notify_npm_dependencies
|
28
|
+
@notify_npm_dependencies ||= begin
|
29
|
+
package_json = JSON.parse(File.read(notify_path.join("package.json")))
|
30
|
+
|
31
|
+
{
|
32
|
+
prod: package_json["dependencies"].map { |package, version| "#{package}@#{version}" },
|
33
|
+
dev: package_json["devDependencies"].map { |package, version| "#{package}@#{version}" }
|
34
|
+
}.freeze
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def notify_path
|
39
|
+
@notify_path ||= Pathname.new(notify_gemspec.full_gem_path) if Gem.loaded_specs.has_key?(gem_name)
|
40
|
+
end
|
41
|
+
|
42
|
+
def notify_gemspec
|
43
|
+
@notify_gemspec ||= Gem.loaded_specs[gem_name]
|
44
|
+
end
|
45
|
+
|
46
|
+
def rails_app_path
|
47
|
+
@rails_app_path ||= Rails.root
|
48
|
+
end
|
49
|
+
|
50
|
+
def copy_awesome_file_to_application(origin_path, destination_path = origin_path)
|
51
|
+
FileUtils.cp(notify_path.join(origin_path), rails_app_path.join(destination_path))
|
52
|
+
end
|
53
|
+
|
54
|
+
def system!(command)
|
55
|
+
system("cd #{rails_app_path} && #{command}") || abort("\n== Command #{command} failed ==")
|
56
|
+
end
|
57
|
+
|
58
|
+
def gem_name
|
59
|
+
"decidim-notify"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/package.json
ADDED
@@ -0,0 +1,200 @@
|
|
1
|
+
{
|
2
|
+
"name": "decidim-module-notify",
|
3
|
+
"version": "1.1.0",
|
4
|
+
"description": "A conversation tracker for Decidim",
|
5
|
+
"scripts": {
|
6
|
+
"lint": "eslint -c .eslintrc.json --ext .js"
|
7
|
+
},
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "git+https://github.com/Platoniq/decidim-module-notify.git"
|
11
|
+
},
|
12
|
+
"scripts": {
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
14
|
+
"lint": "eslint -c .eslintrc.json --ext .js app/packs/",
|
15
|
+
"lint-fix": "eslint -c .eslintrc.json --ext .js app/packs/ --fix",
|
16
|
+
"stylelint": "stylelint **/*.scss",
|
17
|
+
"stylelint-fix": "stylelint **/*.scss --fix"
|
18
|
+
},
|
19
|
+
"keywords": [
|
20
|
+
"decidim"
|
21
|
+
],
|
22
|
+
"author": "ivan@platoniq.net",
|
23
|
+
"license": "AGPL-3.0-or-later",
|
24
|
+
"bugs": {
|
25
|
+
"url": "https://github.com/Platoniq/decidim-module-notify/issues"
|
26
|
+
},
|
27
|
+
"homepage": "https://github.com/Platoniq/decidim-module-notify#readme",
|
28
|
+
"stylelint": {
|
29
|
+
"rules": {
|
30
|
+
"at-rule-empty-line-before": [
|
31
|
+
"always",
|
32
|
+
{
|
33
|
+
"except": [
|
34
|
+
"blockless-after-same-name-blockless",
|
35
|
+
"first-nested"
|
36
|
+
],
|
37
|
+
"ignore": [
|
38
|
+
"after-comment"
|
39
|
+
],
|
40
|
+
"ignoreAtRules": [
|
41
|
+
"else"
|
42
|
+
]
|
43
|
+
}
|
44
|
+
],
|
45
|
+
"at-rule-name-case": "lower",
|
46
|
+
"at-rule-semicolon-newline-after": "always",
|
47
|
+
"block-closing-brace-empty-line-before": "never",
|
48
|
+
"block-closing-brace-newline-after": "always",
|
49
|
+
"block-closing-brace-newline-before": "always-multi-line",
|
50
|
+
"block-closing-brace-space-before": "always-single-line",
|
51
|
+
"block-no-empty": true,
|
52
|
+
"block-opening-brace-newline-after": "always-multi-line",
|
53
|
+
"block-opening-brace-space-after": "always-single-line",
|
54
|
+
"block-opening-brace-space-before": "always",
|
55
|
+
"color-hex-case": "lower",
|
56
|
+
"color-hex-length": "short",
|
57
|
+
"color-no-invalid-hex": true,
|
58
|
+
"comment-empty-line-before": [
|
59
|
+
"always",
|
60
|
+
{
|
61
|
+
"except": [
|
62
|
+
"first-nested"
|
63
|
+
],
|
64
|
+
"ignore": [
|
65
|
+
"stylelint-commands"
|
66
|
+
]
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"comment-no-empty": true,
|
70
|
+
"comment-whitespace-inside": "always",
|
71
|
+
"custom-property-empty-line-before": [
|
72
|
+
"always",
|
73
|
+
{
|
74
|
+
"except": [
|
75
|
+
"after-custom-property",
|
76
|
+
"first-nested"
|
77
|
+
],
|
78
|
+
"ignore": [
|
79
|
+
"after-comment",
|
80
|
+
"inside-single-line-block"
|
81
|
+
]
|
82
|
+
}
|
83
|
+
],
|
84
|
+
"declaration-bang-space-after": "never",
|
85
|
+
"declaration-bang-space-before": "always",
|
86
|
+
"declaration-block-no-duplicate-properties": [
|
87
|
+
true,
|
88
|
+
{
|
89
|
+
"ignore": [
|
90
|
+
"consecutive-duplicates-with-different-values"
|
91
|
+
]
|
92
|
+
}
|
93
|
+
],
|
94
|
+
"declaration-block-no-redundant-longhand-properties": true,
|
95
|
+
"declaration-block-no-shorthand-property-overrides": true,
|
96
|
+
"declaration-block-semicolon-newline-after": "always-multi-line",
|
97
|
+
"declaration-block-semicolon-space-after": "always-single-line",
|
98
|
+
"declaration-block-semicolon-space-before": "never",
|
99
|
+
"declaration-block-single-line-max-declarations": 1,
|
100
|
+
"declaration-block-trailing-semicolon": "always",
|
101
|
+
"declaration-colon-newline-after": "always-multi-line",
|
102
|
+
"declaration-colon-space-after": "always-single-line",
|
103
|
+
"declaration-colon-space-before": "never",
|
104
|
+
"declaration-empty-line-before": [
|
105
|
+
"always",
|
106
|
+
{
|
107
|
+
"except": [
|
108
|
+
"after-declaration",
|
109
|
+
"first-nested"
|
110
|
+
],
|
111
|
+
"ignore": [
|
112
|
+
"after-comment",
|
113
|
+
"inside-single-line-block"
|
114
|
+
]
|
115
|
+
}
|
116
|
+
],
|
117
|
+
"function-calc-no-unspaced-operator": true,
|
118
|
+
"function-comma-newline-after": "always-multi-line",
|
119
|
+
"function-comma-space-after": "always-single-line",
|
120
|
+
"function-comma-space-before": "never",
|
121
|
+
"function-linear-gradient-no-nonstandard-direction": true,
|
122
|
+
"function-max-empty-lines": 0,
|
123
|
+
"function-name-case": "lower",
|
124
|
+
"function-parentheses-newline-inside": "always-multi-line",
|
125
|
+
"function-parentheses-space-inside": "never-single-line",
|
126
|
+
"function-whitespace-after": "always",
|
127
|
+
"indentation": 2,
|
128
|
+
"keyframe-declaration-no-important": true,
|
129
|
+
"length-zero-no-unit": true,
|
130
|
+
"max-empty-lines": 1,
|
131
|
+
"media-feature-colon-space-after": "always",
|
132
|
+
"media-feature-colon-space-before": "never",
|
133
|
+
"media-feature-name-case": "lower",
|
134
|
+
"media-feature-name-no-unknown": true,
|
135
|
+
"media-feature-parentheses-space-inside": "never",
|
136
|
+
"media-feature-range-operator-space-after": "always",
|
137
|
+
"media-feature-range-operator-space-before": "always",
|
138
|
+
"media-query-list-comma-newline-after": "always-multi-line",
|
139
|
+
"media-query-list-comma-space-after": "always-single-line",
|
140
|
+
"media-query-list-comma-space-before": "never",
|
141
|
+
"no-empty-source": true,
|
142
|
+
"no-eol-whitespace": true,
|
143
|
+
"no-extra-semicolons": true,
|
144
|
+
"no-invalid-double-slash-comments": true,
|
145
|
+
"no-missing-end-of-source-newline": true,
|
146
|
+
"number-leading-zero": "never",
|
147
|
+
"number-no-trailing-zeros": true,
|
148
|
+
"property-case": "lower",
|
149
|
+
"property-no-unknown": true,
|
150
|
+
"rule-empty-line-before": [
|
151
|
+
"always-multi-line",
|
152
|
+
{
|
153
|
+
"except": [
|
154
|
+
"first-nested"
|
155
|
+
],
|
156
|
+
"ignore": [
|
157
|
+
"after-comment"
|
158
|
+
]
|
159
|
+
}
|
160
|
+
],
|
161
|
+
"selector-attribute-brackets-space-inside": "never",
|
162
|
+
"selector-attribute-operator-space-after": "never",
|
163
|
+
"selector-attribute-operator-space-before": "never",
|
164
|
+
"selector-combinator-space-after": "always",
|
165
|
+
"selector-combinator-space-before": "always",
|
166
|
+
"selector-descendant-combinator-no-non-space": true,
|
167
|
+
"selector-list-comma-newline-after": "always",
|
168
|
+
"selector-list-comma-space-before": "never",
|
169
|
+
"selector-max-empty-lines": 0,
|
170
|
+
"selector-pseudo-class-case": "lower",
|
171
|
+
"selector-pseudo-class-no-unknown": true,
|
172
|
+
"selector-pseudo-class-parentheses-space-inside": "never",
|
173
|
+
"selector-pseudo-element-case": "lower",
|
174
|
+
"selector-pseudo-element-colon-notation": "double",
|
175
|
+
"selector-pseudo-element-no-unknown": true,
|
176
|
+
"selector-type-case": "lower",
|
177
|
+
"selector-type-no-unknown": true,
|
178
|
+
"shorthand-property-no-redundant-values": true,
|
179
|
+
"string-no-newline": true,
|
180
|
+
"unit-case": "lower",
|
181
|
+
"unit-no-unknown": true,
|
182
|
+
"value-list-comma-newline-after": "always-multi-line",
|
183
|
+
"value-list-comma-space-after": "always-single-line",
|
184
|
+
"value-list-comma-space-before": "never",
|
185
|
+
"value-list-max-empty-lines": 0
|
186
|
+
}
|
187
|
+
},
|
188
|
+
"devDependencies": {
|
189
|
+
"eslint": "^7.32.0",
|
190
|
+
"eslint": "^7.25.0",
|
191
|
+
"eslint-config-prettier": "^8.2.0",
|
192
|
+
"eslint-config-standard": "^11.0.0",
|
193
|
+
"eslint-plugin-import": "^2.22.0",
|
194
|
+
"stylelint": "13.11.0"
|
195
|
+
},
|
196
|
+
"dependencies": {
|
197
|
+
"@rails/actioncable": "6.0.4",
|
198
|
+
"select2": "^4.1.0-rc.0"
|
199
|
+
}
|
200
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Vergés
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim-admin
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.25'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.25'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: decidim-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.25'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.25'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: decidim-dev
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.25'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
54
|
+
version: '0.25'
|
55
55
|
description: A note-taker feature focused on conversations.
|
56
56
|
email:
|
57
57
|
- ivan@platoniq.net
|
@@ -62,16 +62,6 @@ files:
|
|
62
62
|
- LICENSE-AGPLv3.txt
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
|
-
- app/assets/config/decidim_notify_manifest.css
|
66
|
-
- app/assets/config/decidim_notify_manifest.js
|
67
|
-
- app/assets/images/decidim/notify/icon.svg
|
68
|
-
- app/assets/javascripts/cable.js
|
69
|
-
- app/assets/javascripts/channels/decidim/notify/conversations.js
|
70
|
-
- app/assets/javascripts/decidim/notify/conversations.js.es6
|
71
|
-
- app/assets/javascripts/decidim/notify/select2.js.es6
|
72
|
-
- app/assets/stylesheets/decidim/notify/_hexagon.scss
|
73
|
-
- app/assets/stylesheets/decidim/notify/admin.scss
|
74
|
-
- app/assets/stylesheets/decidim/notify/notify.scss
|
75
65
|
- app/cells/decidim/notify/chapter/show.erb
|
76
66
|
- app/cells/decidim/notify/chapter_cell.rb
|
77
67
|
- app/cells/decidim/notify/note/show.erb
|
@@ -109,6 +99,18 @@ files:
|
|
109
99
|
- app/models/decidim/notify/author.rb
|
110
100
|
- app/models/decidim/notify/chapter.rb
|
111
101
|
- app/models/decidim/notify/note.rb
|
102
|
+
- app/packs/entrypoints/decidim_notify_component.js
|
103
|
+
- app/packs/entrypoints/decidim_notify_component.scss
|
104
|
+
- app/packs/entrypoints/decidim_notify_selects.js
|
105
|
+
- app/packs/images/decidim/notify/icon.svg
|
106
|
+
- app/packs/src/decidim/notify/consumer.js
|
107
|
+
- app/packs/src/decidim/notify/notify.js
|
108
|
+
- app/packs/src/decidim/notify/notify_channel.js
|
109
|
+
- app/packs/src/decidim/notify/notify_selects.js
|
110
|
+
- app/packs/stylesheets/decidim/notify/admin.scss
|
111
|
+
- app/packs/stylesheets/decidim/notify/hexagon.scss
|
112
|
+
- app/packs/stylesheets/decidim/notify/notify.scss
|
113
|
+
- app/packs/stylesheets/decidim/notify/select2-foundation-theme.css
|
112
114
|
- app/permissions/decidim/notify/admin/permissions.rb
|
113
115
|
- app/permissions/decidim/notify/permissions.rb
|
114
116
|
- app/views/decidim/notify/admin/chapters/_form.html.erb
|
@@ -124,6 +126,7 @@ files:
|
|
124
126
|
- app/views/decidim/notify/conversations/_script.js.erb
|
125
127
|
- app/views/decidim/notify/conversations/index.html.erb
|
126
128
|
- app/views/decidim/notify/conversations/private.html.erb
|
129
|
+
- config/assets.rb
|
127
130
|
- config/i18n-tasks.yml
|
128
131
|
- config/locales/ca.yml
|
129
132
|
- config/locales/cs.yml
|
@@ -148,9 +151,8 @@ files:
|
|
148
151
|
- lib/decidim/notify/test/factories.rb
|
149
152
|
- lib/decidim/notify/test/shared_examples/component_examples.rb
|
150
153
|
- lib/decidim/notify/version.rb
|
151
|
-
-
|
152
|
-
-
|
153
|
-
- vendor/assets/stylesheets/select2.css
|
154
|
+
- lib/tasks/decidim_notify_webpacker_tasks.rake
|
155
|
+
- package.json
|
154
156
|
homepage: https://github.com/decidim/decidim-module-notify
|
155
157
|
licenses:
|
156
158
|
- AGPL-3.0
|
@@ -170,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
172
|
- !ruby/object:Gem::Version
|
171
173
|
version: '0'
|
172
174
|
requirements: []
|
173
|
-
rubygems_version: 3.1.
|
175
|
+
rubygems_version: 3.1.6
|
174
176
|
signing_key:
|
175
177
|
specification_version: 4
|
176
178
|
summary: A conversation tracker module for Decidim
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
-
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
-
//
|
4
|
-
//= require action_cable
|
5
|
-
//= require_self
|
6
|
-
//= require_tree ./channels
|
7
|
-
|
8
|
-
(function() {
|
9
|
-
this.App || (this.App = {});
|
10
|
-
|
11
|
-
App.cable = ActionCable.createConsumer();
|
12
|
-
|
13
|
-
}).call(this);
|
@@ -1,90 +0,0 @@
|
|
1
|
-
// = require cable
|
2
|
-
|
3
|
-
jQuery.fn.reverse = [].reverse;
|
4
|
-
|
5
|
-
var updateEmptyStatus = function(selector) {
|
6
|
-
$(selector).each(function(){
|
7
|
-
if($(this).children().length == 0){
|
8
|
-
$(this).addClass("empty");
|
9
|
-
} else {
|
10
|
-
$(this).removeClass("empty");
|
11
|
-
}
|
12
|
-
});
|
13
|
-
};
|
14
|
-
|
15
|
-
App.notifyNotesChannel = App.cable.subscriptions.create({ channel: "Decidim::Notify::NotesChannel", id: window.Notify && window.Notify.id }, {
|
16
|
-
received: function(data) {
|
17
|
-
// console.log("note received",data);
|
18
|
-
|
19
|
-
if(data.create) $(`#notify-chapter-notes-${data.chapterId||"unclassified"}`).prepend(data.create);
|
20
|
-
if(data.update) {
|
21
|
-
var $note = $(`#notify-note-${data.id}`);
|
22
|
-
var $old = $note.closest(".notify-chapter-notes");
|
23
|
-
var $new = $(`#notify-chapter-notes-${data.chapterId||"unclassified"}`);
|
24
|
-
if($old[0] != $new[0]) {
|
25
|
-
// TODO: put it in the right place by time of creation
|
26
|
-
$note.detach().prependTo($new);
|
27
|
-
}
|
28
|
-
$note.replaceWith(data.update);
|
29
|
-
}
|
30
|
-
if(data.destroy) $(`#notify-note-${data.destroy}`).remove();
|
31
|
-
|
32
|
-
updateEmptyStatus(".notify-chapter-notes");
|
33
|
-
}
|
34
|
-
});
|
35
|
-
|
36
|
-
|
37
|
-
App.notifyParticipantsChannel = App.cable.subscriptions.create({ channel: "Decidim::Notify::ParticipantsChannel", id: window.Notify && window.Notify.id }, {
|
38
|
-
received: function(data) {
|
39
|
-
// console.log("participants received",data);
|
40
|
-
|
41
|
-
$("#notify-note_takers").html(data.noteTakers);
|
42
|
-
$("#notify-participants").html(data.participants);
|
43
|
-
}
|
44
|
-
});
|
45
|
-
|
46
|
-
App.notifyChaptersChannel = App.cable.subscriptions.create({ channel: "Decidim::Notify::ChaptersChannel", id: window.Notify && window.Notify.id }, {
|
47
|
-
received: function(data) {
|
48
|
-
// console.log("chapter received",data);
|
49
|
-
var newOption;
|
50
|
-
if(data.create) {
|
51
|
-
$("#notify-chapters").prepend(data.create);
|
52
|
-
$(document).foundation();
|
53
|
-
if (!$(`#note_chapter [value="${data.title}"]`).length) {
|
54
|
-
newOption = new Option(data.title, data.title, true, true);
|
55
|
-
$("#note_chapter").append(newOption).trigger("change");
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
if(data.update) {
|
60
|
-
var $chapter = $(`#notify-chapter-${data.id} .chapter-title`);
|
61
|
-
if($chapter.length) {
|
62
|
-
var old = $chapter.text();
|
63
|
-
$chapter.text(data.update);
|
64
|
-
if(data.active) {
|
65
|
-
$(".notify-chapter h3").removeClass("active");
|
66
|
-
$(`.toggle-chapter-active .switch-input:not(#chapter_active-${data.id})`).prop("checked", false);
|
67
|
-
$chapter.closest("h3").addClass("active");
|
68
|
-
}
|
69
|
-
var activate = $('#note_body').val()=="" && data.active;
|
70
|
-
newOption = new Option(data.update, data.update, activate, activate);
|
71
|
-
$(`#note_chapter [value="${old}"]`).remove();
|
72
|
-
$('#note_chapter').append(newOption).trigger('change');
|
73
|
-
} else {
|
74
|
-
console.error("Chapter not found", data);
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
if(data.destroy) {
|
79
|
-
// Move notes to the unclassified
|
80
|
-
var $unclassified = $("#notify-chapter-notes-unclassified");
|
81
|
-
$(`#notify-chapter-notes-${data.destroy} .notify-note`).reverse().each(function() {
|
82
|
-
$(this).detach().prependTo($unclassified);
|
83
|
-
});
|
84
|
-
|
85
|
-
$(`#notify-chapter-${data.destroy}`).remove();
|
86
|
-
}
|
87
|
-
|
88
|
-
updateEmptyStatus(".notify-chapter-notes");
|
89
|
-
}
|
90
|
-
});
|