inline_editor 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/inline_editor.js +30 -23
- data/lib/inline_editor/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 964af5b7bbee12fa4477afd5183b52785a323fd11f8d888399c457847613c012
|
4
|
+
data.tar.gz: 8de677e0c699e4b7a53310fe572107d77d714aa7f011cf1a36e191dd59278a99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11805fff7f98a872f30e4dd78a1ab684bceffeaa09e6a1198024c839c0ade648421006ebd93de00f73bf84ec0881e3dbc9d166dd290dece83975a40b6fa63d5a
|
7
|
+
data.tar.gz: f064437169a4ed114b0bdce9c1f7129ad92a3d6ba2450de4fe4d187cdab7da50f21d611954ad005312f138f3132dd4a36d9bb6200b7d5c83982cb5a47d3d9a00
|
@@ -4,42 +4,49 @@ document.addEventListener('DOMContentLoaded', function(){
|
|
4
4
|
let data = {};
|
5
5
|
let target = e.currentTarget;
|
6
6
|
const url = target.dataset.url;
|
7
|
+
let url_type = url.split('.').pop();
|
7
8
|
data[target.dataset.param] = target.querySelector('option:checked').text;
|
8
9
|
|
9
10
|
fetch(url, {
|
10
11
|
method: 'PUT',
|
11
|
-
body: JSON.stringify(data),
|
12
|
+
body: JSON.stringify({post: data}),
|
12
13
|
headers: { 'Content-Type': 'application/json' }
|
13
14
|
})
|
14
15
|
.then(response => {
|
15
|
-
return response.json();
|
16
|
+
return url_type == 'js' ? response.text() : response.json();
|
16
17
|
})
|
17
|
-
.then(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
.then(result => {
|
19
|
+
if(url_type == 'js') {
|
20
|
+
eval(result);
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
const form = target.parentNode;
|
24
|
+
const hint = form.querySelector('span.inline-form-hint');
|
25
|
+
if (hint) {
|
26
|
+
hint.remove();
|
27
|
+
};
|
23
28
|
|
24
|
-
|
25
|
-
|
29
|
+
if (result.status === 'error') {
|
30
|
+
form.dispatchEvent(createEvent('inlineEditError', result));
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
form.classList.add('invalid-value');
|
33
|
+
if (result.message) {
|
34
|
+
form.insertAdjacentHTML('beforeend',
|
35
|
+
"<span class='inline-form-hint'>" + result.message + "</span>"
|
36
|
+
);
|
37
|
+
}
|
32
38
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
else {
|
40
|
+
const container = form.parentNode;
|
41
|
+
let clicableItem = container.querySelector('.clickable-item');
|
36
42
|
|
37
|
-
|
43
|
+
form.dispatchEvent(createEvent('inlineEditSuccess', result))
|
38
44
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
form.classList.remove('invalid-value');
|
46
|
+
clicableItem.innerHTML = '';
|
47
|
+
clicableItem.insertAdjacentHTML('beforeend', result.html);
|
48
|
+
toggleVisibility(container);
|
49
|
+
}
|
43
50
|
}
|
44
51
|
})
|
45
52
|
.catch(function(error) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inline_editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ShevchukTania
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -80,7 +80,7 @@ homepage: https://github.com/ShevchukTania/inline_editor
|
|
80
80
|
licenses:
|
81
81
|
- MIT
|
82
82
|
metadata: {}
|
83
|
-
post_install_message:
|
83
|
+
post_install_message:
|
84
84
|
rdoc_options: []
|
85
85
|
require_paths:
|
86
86
|
- lib
|
@@ -95,8 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubygems_version: 3.0.
|
99
|
-
signing_key:
|
98
|
+
rubygems_version: 3.0.8
|
99
|
+
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Inline editor for Rails applications
|
102
102
|
test_files: []
|