rails_admin_live_edit 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/app/views/live_edit/_ra_live_editor.html.haml +76 -13
- data/lib/rails_admin_live_edit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0edb6a9d579a56400807ee4943cff28c60ce28af
|
4
|
+
data.tar.gz: 16c77573069b89fac7d59465d12353392b3aaa26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 584f45b1e7877700cc06895109c5756e9859f86da37dde64fd59db07eb5e48b552c8a6fa0136255569bafe24347a74fecb8541b6a1c793a525400ac9e733e5df
|
7
|
+
data.tar.gz: 78fd9689464faa8de90d54e29914404cad0a1a2601d5475bde907ffed63804bd0b83e478cf09050a7bba0bdf606180299643c68e6ac02b9ec01c00b914e46cc6
|
data/README.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
A [rails_admin](https://github.com/sferik/rails_admin) plugin to edit site contents from the frontend.
|
4
4
|
|
5
|
-
If the user is logged in
|
5
|
+
If the user is logged in rails_admin a fixed bar on bottom is shown. It allows to edit the current record (if in a *show* page) or to create a new one (if in an *index* page).
|
6
|
+
|
7
|
+
Demo: [heroku app](http://rails-admin-material.herokuapp.com/posts/)
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -10,14 +12,16 @@ If the user is logged in in rails_admin and is viewing an editable page an edit
|
|
10
12
|
|
11
13
|
- Add to application layout (in body) (erb example): `<%= render 'live_edit/ra_live_editor' %>`
|
12
14
|
|
13
|
-
- Add to *app/assets/javascripts/application.js*: `//= require rmodal.js/dist/rmodal`
|
14
|
-
|
15
15
|
- Edit or create *app/assets/javascripts/rails_admin/custom/ui.js* and add: `//= require rails_admin/plugins/live_edit/ui.js`
|
16
16
|
|
17
|
+
## Notes
|
18
|
+
|
19
|
+
- This plugin use `current_user` method to check if the user is logged in; to bypass this check it is possible to define a `current_user` helper method.
|
20
|
+
|
17
21
|
## Preview
|
18
22
|
|
19
23
|
![preview](preview.jpg)
|
20
24
|
|
21
25
|
## Contributors
|
22
26
|
|
23
|
-
- [Mattia Roccoberton](http://blocknot.es) - creator, maintainer
|
27
|
+
- [Mattia Roccoberton](http://blocknot.es) - creator, maintainer
|
@@ -1,11 +1,28 @@
|
|
1
1
|
:ruby
|
2
|
+
ra_logged = false
|
2
3
|
ra_le_model = false
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
p '1'
|
5
|
+
p current_user
|
6
|
+
if defined?( current_user ) && current_user
|
7
|
+
p '2'
|
8
|
+
ra_logged = true
|
9
|
+
model = controller_name.singularize
|
10
|
+
if RailsAdmin.config && RailsAdmin.config.models.map{ |mod| mod.abstract_model.model_name.underscore }.include?( model )
|
11
|
+
p '3'
|
12
|
+
ra_le_model = model
|
13
|
+
ra_le_id = params[:id]
|
14
|
+
end
|
15
|
+
if RailsAdmin.config.main_app_name
|
16
|
+
if RailsAdmin.config.main_app_name.is_a? Proc
|
17
|
+
name = RailsAdmin.config.main_app_name.call
|
18
|
+
else
|
19
|
+
name = RailsAdmin.config.main_app_name
|
20
|
+
end
|
21
|
+
admin_title = name[1] ? name[1] : '' if name.is_a? Array
|
22
|
+
end
|
6
23
|
end
|
7
24
|
|
8
|
-
- if
|
25
|
+
- if ra_logged
|
9
26
|
:css
|
10
27
|
.ra-le-button {
|
11
28
|
background: #ddd;
|
@@ -22,11 +39,15 @@
|
|
22
39
|
.ra-le-button.btn2 {
|
23
40
|
border-top: 1px solid #aaa;
|
24
41
|
border-left: 1px solid #aaa;
|
42
|
+
}
|
43
|
+
.ra-le-button.btn3 {
|
44
|
+
border-top: 1px solid #aaa;
|
45
|
+
border-left: 1px solid #aaa;
|
25
46
|
border-right: 1px solid #aaa;
|
26
47
|
border-radius: 0 5px 0 0;
|
27
48
|
}
|
28
49
|
.ra-le-controls {
|
29
|
-
background: rgba(0, 0, 0, .
|
50
|
+
background: rgba(0, 0, 0, .3);
|
30
51
|
bottom: 0;
|
31
52
|
left: 0;
|
32
53
|
padding-top: 5px;
|
@@ -34,6 +55,15 @@
|
|
34
55
|
text-align: right;
|
35
56
|
width: 100%;
|
36
57
|
}
|
58
|
+
.ra-le-controls > .admin-title {
|
59
|
+
color: #fff;
|
60
|
+
float: left;
|
61
|
+
padding: 4px 0 0 8px;
|
62
|
+
}
|
63
|
+
.ra-le-controls > .close {
|
64
|
+
border-left: 1px solid #aaa;
|
65
|
+
padding: 5px 0;
|
66
|
+
}
|
37
67
|
.ra-le-controls > a:last-child {
|
38
68
|
margin-right: 5px;
|
39
69
|
}
|
@@ -51,8 +81,13 @@
|
|
51
81
|
left: 0;
|
52
82
|
right: 0;
|
53
83
|
bottom: 0;
|
84
|
+
opacity: 0;
|
54
85
|
overflow-x: hidden;
|
55
86
|
overflow-y: auto;
|
87
|
+
transition: opacity 0.3s;
|
88
|
+
}
|
89
|
+
#ra-le-modal.opened {
|
90
|
+
opacity: 1;
|
56
91
|
}
|
57
92
|
#ra-le-modal > .modal-dialog {
|
58
93
|
position: relative;
|
@@ -60,8 +95,12 @@
|
|
60
95
|
width: 940px;
|
61
96
|
-webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
|
62
97
|
box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
|
63
|
-
background: #fff;
|
64
98
|
margin: 0 auto;
|
99
|
+
opacity: 1;
|
100
|
+
transition: opacity 0.3s;
|
101
|
+
}
|
102
|
+
#ra-le-modal > .modal-dialog.closed {
|
103
|
+
opacity: 0;
|
65
104
|
}
|
66
105
|
#ra-le-modal .dlg-buttons {
|
67
106
|
background: #ccc;
|
@@ -101,8 +140,15 @@
|
|
101
140
|
%a.btn-close.ra-le-button{ href: '#', onclick: 'event.preventDefault();modal.close();' }= t 'live_edit.button.close'
|
102
141
|
|
103
142
|
.ra-le-controls
|
104
|
-
|
105
|
-
= link_to
|
143
|
+
.admin-title= admin_title
|
144
|
+
= link_to rails_admin_path, class: 'btn1 ra-le-button' do
|
145
|
+
= t('live_edit.button.admin')
|
146
|
+
- if ra_le_model
|
147
|
+
- if ra_le_id
|
148
|
+
%a.btn2.ra-le-button#ra-le-open-modal1{ href: '#', 'data-op': 'edit' }>= t 'live_edit.button.edit_page'
|
149
|
+
%a.btn3.ra-le-button#ra-le-open-modal2{ href: '#', 'data-op': 'new' }>= t 'live_edit.button.new_page'
|
150
|
+
- else
|
151
|
+
%span.close==
|
106
152
|
|
107
153
|
:javascript
|
108
154
|
// >>> rmodal.js >>>
|
@@ -265,13 +311,15 @@
|
|
265
311
|
})));
|
266
312
|
// <<< rmodal.js <<<
|
267
313
|
|
314
|
+
var iframe = '';
|
268
315
|
window.onload = function() {
|
269
316
|
var modal = new RModal(document.getElementById('ra-le-modal'), {
|
270
317
|
beforeOpen: function(next) {
|
271
|
-
document.getElementById('ra-le-content').innerHTML =
|
318
|
+
document.getElementById('ra-le-content').innerHTML = iframe;
|
272
319
|
next();
|
273
320
|
},
|
274
321
|
afterOpen: function() {
|
322
|
+
document.getElementById('ra-le-modal').className = 'opened';
|
275
323
|
},
|
276
324
|
beforeClose: function(next) {
|
277
325
|
next();
|
@@ -281,8 +329,10 @@
|
|
281
329
|
}
|
282
330
|
// , bodyClass: 'modal-open'
|
283
331
|
// , dialogClass: 'modal-dialog modal-dialog-lg'
|
332
|
+
// , dialogOpenClass: 'opened'
|
284
333
|
// , dialogOpenClass: 'animated fadeIn'
|
285
334
|
// , dialogCloseClass: 'animated fadeOut'
|
335
|
+
, dialogCloseClass: 'closed'
|
286
336
|
|
287
337
|
// , focus: true
|
288
338
|
// , focusElements: ['input.form-control', 'textarea', 'button.btn-primary']
|
@@ -292,9 +342,22 @@
|
|
292
342
|
document.addEventListener('keydown', function(ev) {
|
293
343
|
modal.keydown(ev);
|
294
344
|
}, false);
|
295
|
-
document.getElementById('ra-le-open-modal').addEventListener("click", function(ev) {
|
296
|
-
ev.preventDefault();
|
297
|
-
modal.open();
|
298
|
-
}, false);
|
299
345
|
window.modal = modal;
|
300
346
|
}
|
347
|
+
|
348
|
+
- if ra_le_model
|
349
|
+
:javascript
|
350
|
+
if( document.getElementById('ra-le-open-modal1') ) {
|
351
|
+
document.getElementById('ra-le-open-modal1').addEventListener("click", function(ev) {
|
352
|
+
ev.preventDefault();
|
353
|
+
iframe = '<iframe src="#{rails_admin.edit_path( ra_le_model, ra_le_id ? ra_le_id : 0 )}" width="930px" height="470px"></iframe>';
|
354
|
+
modal.open();
|
355
|
+
}, false);
|
356
|
+
}
|
357
|
+
if( document.getElementById('ra-le-open-modal2') ) {
|
358
|
+
document.getElementById('ra-le-open-modal2').addEventListener("click", function(ev) {
|
359
|
+
ev.preventDefault();
|
360
|
+
iframe = '<iframe src="#{rails_admin.new_path( ra_le_model )}" width="930px" height="470px"></iframe>';
|
361
|
+
modal.open();
|
362
|
+
}, false);
|
363
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_live_edit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A rails_admin plugin to edit site contents from the frontend
|
14
14
|
email:
|