flash-messenger 0.2.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60ca4b88c9412aa2a5bb8bc310b7ed0b79bc4820
4
- data.tar.gz: 4d6fa4ffe1aa49d39b7f8b62698e25c4601dc913
3
+ metadata.gz: 3322aa3844977effb648a83b8d05757580efe8d3
4
+ data.tar.gz: c7628d4fcbff0884934fc16056a74cd04e420957
5
5
  SHA512:
6
- metadata.gz: 26e6eb07e55cf17ef5a8b74042754c6a456df790aa2a6cf99f85338c1d6845c65f15037f7e17edb37b893f2698ed685ee93bb4a28429998250cf4ce7ceeddad9
7
- data.tar.gz: d205d4c07174c8337d6a602231c411e4ce4bf8860903db71d88a12eb5bdbd1535609cd22b7396568350f34f6f56c5623c63f0f9108ea1c694b23c58e73430b11
6
+ metadata.gz: db99bdafc581f45428098ec2e1bb782bbaa985662bd748f9d4d221fd0e3bb82a5c8d45044d78d693c43ce78b0f3a29a0195471c1b53c68d7052d6d3964a03967
7
+ data.tar.gz: a0fc2f4cf57d123f12466b9fa6dda19ab910cfe7c66dd442cad62d7fff5838bfb8382e2157c77637f94fc62aff0ab4009bb4803275c007e0521e278bd54eb5da
@@ -2,17 +2,28 @@
2
2
  (function ($) {
3
3
  'use strict';
4
4
 
5
+ function showErrors(errors) {
6
+ errors.forEach(function (error) {
7
+ flash.error(error);
8
+ });
9
+ }
10
+
5
11
  $(document).on('turboboost:error', function (e, errors) {
12
+ var json;
6
13
  try {
7
- errors = JSON.parse(errors);
8
- if ($.isArray(errors)) {
9
- errors.forEach(function (error) {
10
- flash.error(error);
11
- });
12
- } else if (typeof errors == 'object') {
13
- flash.modelError(errors);
14
+ json = JSON.parse(errors);
15
+ } catch (e2) {
16
+ }
17
+ if ($.isArray(json)) {
18
+ showErrors(json);
19
+ } else if (typeof json == 'object') {
20
+ if ($.isArray(json.error)) {
21
+ showErrors(json.error);
22
+ } else {
23
+ flash.error(errors);
14
24
  }
15
- } catch (e) {
25
+ } else if (typeof json === 'string') {
26
+ flash.error(errors);
16
27
  }
17
28
  });
18
29
  })(jQuery);
@@ -1,3 +1,3 @@
1
1
  module FlashMessenger
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash-messenger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chen, Yi-Cyuan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: request_store
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.6.12
202
+ rubygems_version: 2.6.14
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Integrate with flash-messenger to provide a simple flash messages.