fdbq-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9195b6626e0cf218de00b495a3617f1cb460f8a50fbee7add7c93b5e44ebccc
4
- data.tar.gz: 2d8c3c1606629fa1ed0e934168edd8fba4a699fcc7dfd3a4cd5af0f203014784
3
+ metadata.gz: df314fdffb6053f9ca40c0dcac86002851f1f4fe8ab88991902b6a950f247df1
4
+ data.tar.gz: 5762c0e77c2d988c6e5b48952238c6850955b1a740246f20dfb744f95cc96e78
5
5
  SHA512:
6
- metadata.gz: 5c98ef23951c9f362f4da0c4a8eb0922615bae697f1b2cc6281277da879dc33ca016c2f1258ab3ae68f1d2c40805810ef881769f74cdc7bf96ef3466d73e0770
7
- data.tar.gz: 69cc776c15caaa9acc52b9286be0706870c36fe4711f19e2c2acdc0cf443773c60dd7f00c7e81d7299673e215b59b2d842b5c5e397c25aeeb9379a571a62fa89
6
+ metadata.gz: cda69e3b03688976fa0a82acbbf0af8af3541cf9206778fffcc7ef4b06ea26d45278e645bf6548522d2c97bb910bc2f68eb6f9bde53edbdc331395e10016940c
7
+ data.tar.gz: bf1e5394c62c63ba91c3a7dcd798519d6158083fa862ddea1d2c82b2865f10e9cf70d89c613d28182b8a1b74ccd097f2c71cd81d57dfc81a46e714b9796207d7
@@ -2,12 +2,17 @@ module Fdbq
2
2
  class FeedbackController < Fdbq::Rails.controller_parent.constantize
3
3
  skip_before_action :verify_authenticity_token, only: :create
4
4
 
5
+ self.instance_eval(&Fdbq::Plugin.instance.controller_extensions) if Fdbq::Plugin.instance.controller_extensions
6
+
5
7
  def create
6
8
  @feedback = Fdbq::Feedback.new(fields: permitted_params.to_h)
7
- @feedback.save
9
+
10
+ if @feedback.save
11
+ flash.now[:notice] = I18n.t('fdbq.events.created')
12
+ end
8
13
 
9
14
  respond_to do |format|
10
- format.json { render(status: @feedback.persisted? ? 201 : 422) }
15
+ format.json { head(@feedback.persisted? ? 201 : 422) }
11
16
  end
12
17
  end
13
18
 
@@ -7,6 +7,8 @@ module Fdbq
7
7
 
8
8
  validate :required_fields
9
9
 
10
+ self.instance_eval(&Fdbq::Plugin.instance.model_extensions) if Fdbq::Plugin.instance.model_extensions
11
+
10
12
  private
11
13
 
12
14
  def required_fields
data/lib/fdbq/plugin.rb CHANGED
@@ -9,6 +9,8 @@ module Fdbq
9
9
 
10
10
  attr_accessor :config_file_path
11
11
  attr_accessor :param_key
12
+ attr_accessor :controller_extensions
13
+ attr_accessor :model_extensions
12
14
 
13
15
  include ::Singleton
14
16
 
@@ -5,13 +5,15 @@ module Fdbq
5
5
  engine_name 'fdbq'
6
6
 
7
7
  initializer "fdbq.assets.precompile" do |app|
8
- app.config.assets.precompile += %w( fdbq.* )
8
+ app.config.assets.precompile += %w( *fdbq.* )
9
9
  end
10
10
 
11
11
  initializer "fdbq.engine" do |app|
12
12
  ActionController::Base.send :include, Fdbq::Rails::Helpers
13
13
  ActionView::Base.send :include, Fdbq::Rails::Helpers
14
14
  end
15
+
16
+ config.assets.paths << File.expand_path("../../../../vendor/node_modules", __FILE__)
15
17
  end
16
18
  end
17
19
  end
@@ -1,5 +1,5 @@
1
1
  module Fdbq
2
2
  module Rails
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
@@ -31,6 +31,10 @@ module Fdbq
31
31
  def copy_initializer
32
32
  template "fdbq.rb", "config/initializers/fdbq.rb"
33
33
  end
34
+
35
+ def copy_locales
36
+ template "fdbq.en.yml", "config/locales/fdbq.en.yml"
37
+ end
34
38
  end
35
39
  end
36
40
  end
@@ -0,0 +1,4 @@
1
+ en:
2
+ fdbq:
3
+ events:
4
+ created: Feedback created!
@@ -2,4 +2,12 @@ Fdbq.configure do |config|
2
2
  config.config_file_path = Rails.root.join('config', 'fdbq.yml').to_s
3
3
 
4
4
  config.param_key = :feedback
5
+
6
+ # config.controller_extensions do
7
+ # # extend controller
8
+ # end
9
+
10
+ # config.model_extensions do
11
+ # # extend model
12
+ # end
5
13
  end
@@ -1,4 +1,5 @@
1
1
  placement: bottom right
2
+ appearance: fade
2
3
  modal:
3
4
  title:
4
5
  subHeader:
@@ -66,6 +66,7 @@
66
66
  | ------------------------ | -------- | ------------------- | -------------------------------- | --------- | ----------------------------- |
67
67
  | `mountNode` | No | String | |`"body" ` | Root node to mount lugin into |
68
68
  | `placement` | Yes | String | `bottom`, `top`, `left`, `right` | | Button placement on a screen |
69
+ | `appearance` | No | String | `fade`, `slide-up`, `slide-down` | `fade` | Modal appearance animation |
69
70
  | `modal` | No | Object | | | Modal settings |
70
71
  | `submit` | Yes | Object | | `func` | Modal submit handler. Default handler submit on `url` |
71
72
  | `subHeader` | No | String | | | Modal body sub-header |
@@ -292,7 +292,7 @@
292
292
  function FdbqModal(instance) {
293
293
  var overlay = document.createElement("div");
294
294
  var node = document.createElement("div");
295
- node.className = "fdbq-modal";
295
+ node.className = "fdbq-modal fdbq-"+(instance.config.appearance || "fade");
296
296
  node.id = instance.modalContainerSelector;
297
297
 
298
298
  renderModalBody(node, instance);
@@ -325,10 +325,21 @@
325
325
  var closeButton = document.getElementById(this.modalCloseSelector);
326
326
  var submitButton = document.getElementById(this.modalSubmitSelector);
327
327
 
328
- if(button) button.addEventListener("click", this.onActionClick.bind(this));
329
- if(closeButton) closeButton.addEventListener("click", this.onCloseClick.bind(this));
330
- if(submitButton) submitButton.addEventListener("click", this.onSubmitClick.bind(this));
328
+ if(button) {
329
+ button.removeEventListener("click", this.onActionClick);
330
+ button.addEventListener("click", this.onActionClick.bind(this));
331
+ }
332
+ if(closeButton) {
333
+ closeButton.removeEventListener("click", this.onCloseClick);
334
+ closeButton.addEventListener("click", this.onCloseClick.bind(this));
335
+ }
336
+ if(submitButton) {
337
+ submitButton.removeEventListener("click", this.onSubmitClick);
338
+ submitButton.addEventListener("click", this.onSubmitClick.bind(this));
339
+ }
331
340
 
341
+ document.removeEventListener("keydown", this.handleModalKeyboardNavigation);
342
+ document.addEventListener("keydown", this.handleModalKeyboardNavigation.bind(this));
332
343
  };
333
344
 
334
345
  this.mountNode = function() { return document.querySelector(this.config.mountNode) || document.body; };
@@ -378,6 +389,11 @@
378
389
 
379
390
  return true;
380
391
  };
392
+ this.handleModalKeyboardNavigation = function(event) {
393
+ if(event.keyCode === 27 || event.key === "Escape") {
394
+ this.onCloseClick();
395
+ }
396
+ };
381
397
 
382
398
  // props;
383
399
  this.config = config || {};
@@ -0,0 +1,62 @@
1
+ {
2
+ "_from": "@softserveopensource/fdbq@0.1.1",
3
+ "_id": "@softserveopensource/fdbq@0.1.1",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-LkSCEEVJVL9J7bKy/8yxe4b093qvLi6US+/koferhO/HHcOxpcortbtxyRIr5BPybOQvaPdpCBD1CZVNla0O+g==",
6
+ "_location": "/@softserveopensource/fdbq",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "version",
10
+ "registry": true,
11
+ "raw": "@softserveopensource/fdbq@0.1.1",
12
+ "name": "@softserveopensource/fdbq",
13
+ "escapedName": "@softserveopensource%2ffdbq",
14
+ "scope": "@softserveopensource",
15
+ "rawSpec": "0.1.1",
16
+ "saveSpec": null,
17
+ "fetchSpec": "0.1.1"
18
+ },
19
+ "_requiredBy": [
20
+ "#USER",
21
+ "/"
22
+ ],
23
+ "_resolved": "https://registry.npmjs.org/@softserveopensource/fdbq/-/fdbq-0.1.1.tgz",
24
+ "_shasum": "4a50eb16c812055ed2eeb3fc6f588189dd44e026",
25
+ "_spec": "@softserveopensource/fdbq@0.1.1",
26
+ "_where": "/Users/rsolomud/dev/rails/fdbq-rails/vendor",
27
+ "author": {
28
+ "name": "SoftServe OpenSource"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/SoftServeInc/fdbq/issues"
32
+ },
33
+ "bundleDependencies": false,
34
+ "deprecated": false,
35
+ "description": "A simple lightweight survey for your website",
36
+ "devDependencies": {
37
+ "jest": "^24.9.0",
38
+ "serve": "^11.3.0"
39
+ },
40
+ "directories": {
41
+ "example": "examples"
42
+ },
43
+ "files": [
44
+ "index.js",
45
+ "theme.css"
46
+ ],
47
+ "homepage": "https://github.com/SoftServeInc/fdbq#readme",
48
+ "keywords": [
49
+ "Feedback"
50
+ ],
51
+ "license": "MIT",
52
+ "main": "index.js",
53
+ "name": "@softserveopensource/fdbq",
54
+ "repository": {
55
+ "url": "git+https://github.com/SoftServeInc/fdbq.git",
56
+ "type": "git"
57
+ },
58
+ "scripts": {
59
+ "test": "jest"
60
+ },
61
+ "version": "0.1.1"
62
+ }
@@ -1,3 +1,38 @@
1
+ @keyframes fdbq-fadeIn {
2
+ from {
3
+ opacity: 0;
4
+ }
5
+
6
+ to {
7
+ opacity: 1;
8
+ }
9
+ }
10
+
11
+ @keyframes fdbq-slide-up {
12
+ from {
13
+ margin-top: 100%;
14
+ }
15
+
16
+ to {
17
+ margin-top: 40px;
18
+ }
19
+ }
20
+
21
+ @keyframes fdbq-slide-down {
22
+ from {
23
+ margin-top: -100%;
24
+ }
25
+
26
+ to {
27
+ margin-top: 40px;
28
+ }
29
+ }
30
+
31
+ @keyframes fdbq-action-hover {
32
+ 0% { transform: scale(1); }
33
+ 50% { transform: scale(.7); }
34
+ 100% { transform: scale(1); }
35
+ }
1
36
 
2
37
  .fdbq-modal-overlay {
3
38
  position: fixed;
@@ -21,6 +56,18 @@
21
56
  background-color: #ffffff;
22
57
  }
23
58
 
59
+ .fdbq-modal.fdbq-fade {
60
+ animation: fdbq-fadeIn .4s;
61
+ }
62
+
63
+ .fdbq-modal.fdbq-slide-up {
64
+ animation: fdbq-slide-up .4s;
65
+ }
66
+
67
+ .fdbq-modal.fdbq-slide-down {
68
+ animation: fdbq-slide-down .4s;
69
+ }
70
+
24
71
  .fdbq-modal .fdbq-modal-head {
25
72
  display: flex;
26
73
  margin: 0;
@@ -173,6 +220,10 @@
173
220
  transition: background-color .5s;
174
221
  }
175
222
 
223
+ .fdbq-toggle:hover .fdbq-icon-action, .fdbq-toggle:focus .fdbq-icon-action {
224
+ animation: fdbq-action-hover 2s infinite;
225
+ }
226
+
176
227
  .fdbq-toggle .fdbq-icon-action {
177
228
  display: inline-block;
178
229
  width: 45px;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fdbq-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SoftServe OpenSource
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-07 00:00:00.000000000 Z
11
+ date: 2020-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -73,7 +73,6 @@ files:
73
73
  - app/assets/stylesheets/fdbq.css
74
74
  - app/controllers/fdbq/feedback_controller.rb
75
75
  - app/models/fdbq/feedback.rb
76
- - app/views/fdbq/feedback/create.json.jbuilder
77
76
  - config/routes.rb
78
77
  - lib/fdbq-rails.rb
79
78
  - lib/fdbq/fdbq.rb
@@ -87,12 +86,13 @@ files:
87
86
  - lib/fdbq/version.rb
88
87
  - lib/generators/fdbq/rails/install_generator.rb
89
88
  - lib/generators/templates/create_fdbq_feedback.rb
89
+ - lib/generators/templates/fdbq.en.yml
90
90
  - lib/generators/templates/fdbq.rb
91
91
  - lib/generators/templates/fdbq.yml
92
- - vendor/assets/javascripts/@softserveopensource/fdbq/README.md
93
- - vendor/assets/javascripts/@softserveopensource/fdbq/index.js
94
- - vendor/assets/javascripts/@softserveopensource/fdbq/package.json
95
- - vendor/assets/javascripts/@softserveopensource/fdbq/theme.css
92
+ - vendor/node_modules/@softserveopensource/fdbq/README.md
93
+ - vendor/node_modules/@softserveopensource/fdbq/index.js
94
+ - vendor/node_modules/@softserveopensource/fdbq/package.json
95
+ - vendor/node_modules/@softserveopensource/fdbq/theme.css
96
96
  homepage: https://github.com/SoftServeInc/fdbq-rails
97
97
  licenses:
98
98
  - MIT
@@ -1,7 +0,0 @@
1
- json.call(@feedback, :id, :fields)
2
- json.created_at @feedback.created_at&.iso8601
3
- json.updated_at @feedback.updated_at&.iso8601
4
-
5
- if @feedback.errors.present?
6
- json.errors @feedback.errors.messages
7
- end
@@ -1,33 +0,0 @@
1
- {
2
- "name": "@softserveopensource/fdbq",
3
- "version": "0.1.0",
4
- "description": "A simple lightweight survey for your website",
5
- "main": "index.js",
6
- "author": "SoftServe OpenSource",
7
- "license": "MIT",
8
- "homepage": "https://github.com/SoftServeInc/fdbq#readme",
9
- "scripts": {
10
- "test": "jest"
11
- },
12
- "devDependencies": {
13
- "jest": "^24.9.0",
14
- "serve": "^11.3.0"
15
- },
16
- "files": [
17
- "index.js",
18
- "theme.css"
19
- ],
20
- "repository": {
21
- "url": "git+https://github.com/SoftServeInc/fdbq.git",
22
- "type": "git"
23
- },
24
- "bugs": {
25
- "url": "https://github.com/SoftServeInc/fdbq/issues"
26
- },
27
- "directories": {
28
- "example": "examples"
29
- },
30
- "keywords": [
31
- "Feedback"
32
- ]
33
- }