lato_core 2.2.0 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +44 -4
- data/app/assets/stylesheets/lato_core/base/_table.scss +24 -0
- data/app/assets/stylesheets/lato_core/cells/elements/_button.scss +11 -0
- data/app/assets/stylesheets/lato_core/cells/widgets/_index.scss +17 -1
- data/app/cells/lato_core/elements/button/cell.rb +3 -0
- data/app/cells/lato_core/elements/button/views/button.html.erb +6 -2
- data/app/cells/lato_core/elements/button/views/link.html.erb +5 -2
- data/app/cells/lato_core/widgets/index/cell.rb +51 -9
- data/app/views/lato_core/doc/cells_elements/button.html.erb +32 -0
- data/app/views/lato_core/doc/cells_widgets/index.html.erb +48 -1
- data/lib/lato_core/interfaces/cells.rb +19 -1
- data/lib/lato_core/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 10d0d90847799a6bf6da6765a2b6bf85994cd47afb79dd60fc12a8cad41db9c4
|
4
|
+
data.tar.gz: 03ed9310de285a4245c1b1a110d8f95484dc5763cf16e241b0d93cd97ebe9875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89af3d72a186ade8517edf0c88a7d11ea579dcd14eb5c5e37e830ab5de6f9779046b376c29f1afb9d6529dbf3f4fb249e5627069e2322c88555324b915d5ac32
|
7
|
+
data.tar.gz: 1742ef179d9b7d4d472e1ad2cb49305d5ad342bb2957e3b1eb5746ec42340d77e8fa6f844d6cf1dc19ed41309b9ac6571e51ed8847ae3ad9a1b2f7e2a1185d1e
|
data/README.md
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
# Lato Core
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/lato_core.svg)](https://badge.fury.io/rb/lato_core)
|
4
|
+
|
3
5
|
Lato is a Rails engine used to develop modular admin panels. This is the module used to initialize the admin panel.
|
4
6
|
The complete documentation is inside the application panel, so you must [install](#installation) it before.
|
5
7
|
|
6
|
-
You can always try a demo here: https://lato-
|
8
|
+
You can always try a demo here: https://lato-gem.herokuapp.com
|
7
9
|
|
8
|
-
![
|
10
|
+
![Lato dashboard screenshot](lib/screen.png)
|
9
11
|
|
10
12
|
## Ecosystem
|
11
13
|
|
12
14
|
- [Lato core](https://github.com/ideonetwork/lato-core): The core module used to initialize the panel.
|
13
15
|
- [Lato media](https://github.com/ideonetwork/lato-media): A module used to manage attachments and media files.
|
14
|
-
- [Lato blog](https://github.com/ideonetwork/lato-blog): A module
|
16
|
+
- [Lato blog](https://github.com/ideonetwork/lato-blog): A module to manage blog contents.
|
15
17
|
|
16
18
|
## Installation
|
17
19
|
|
@@ -39,4 +41,42 @@ Exec migrations
|
|
39
41
|
bundle exec rake db:migrate
|
40
42
|
```
|
41
43
|
|
42
|
-
Now you can start the server and go to the relative url */lato/core*
|
44
|
+
Now you can start the server and go to the relative url */lato/core*
|
45
|
+
|
46
|
+
## Command line interface
|
47
|
+
|
48
|
+
Lato has some commands that can be used to generate files and configurations.
|
49
|
+
|
50
|
+
Inside the Lato admin panel there is a specific list of all command line commands that can be used to work with a lato project.
|
51
|
+
|
52
|
+
### Configuration
|
53
|
+
|
54
|
+
```console
|
55
|
+
rails lato:load_configs
|
56
|
+
```
|
57
|
+
|
58
|
+
This command should create a list of **lato_*.yml** files inside **config/lato** containing settings and configuration of every module.
|
59
|
+
|
60
|
+
### Languages
|
61
|
+
|
62
|
+
```console
|
63
|
+
rails lato:load_languages
|
64
|
+
```
|
65
|
+
|
66
|
+
This command should create a list of **lato_*_lang.yml** files inside **config/lato** containing strings that can be replaced for every lato module.
|
67
|
+
|
68
|
+
### Generators
|
69
|
+
|
70
|
+
#### Initializer
|
71
|
+
|
72
|
+
```console
|
73
|
+
rails generate lato_core:initializer
|
74
|
+
```
|
75
|
+
|
76
|
+
This command should create some files that helps you to start to develop with lato.
|
77
|
+
|
78
|
+
#### Scaffold
|
79
|
+
|
80
|
+
```console
|
81
|
+
rails generate lato_core:scaffold ModelName
|
82
|
+
```
|
@@ -6,6 +6,30 @@
|
|
6
6
|
|
7
7
|
thead {
|
8
8
|
border-bottom: solid 1px darken($color_white, 3);
|
9
|
+
|
10
|
+
.attr-active {
|
11
|
+
color: $color_active;
|
12
|
+
}
|
13
|
+
|
14
|
+
.attr-sort-ASC {
|
15
|
+
position: relative;
|
16
|
+
|
17
|
+
&:after {
|
18
|
+
content: '\2193';
|
19
|
+
position: absolute;
|
20
|
+
right: -1em;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
.attr-sort-DESC {
|
25
|
+
position: relative;
|
26
|
+
|
27
|
+
&:after {
|
28
|
+
content: '\2191';
|
29
|
+
position: absolute;
|
30
|
+
right: -1em;
|
31
|
+
}
|
32
|
+
}
|
9
33
|
}
|
10
34
|
|
11
35
|
tbody:before {
|
@@ -27,6 +27,17 @@
|
|
27
27
|
}
|
28
28
|
}
|
29
29
|
|
30
|
+
.elements-button--block {
|
31
|
+
display: block;
|
32
|
+
width: 100%;
|
33
|
+
|
34
|
+
> .elements-button__element {
|
35
|
+
display: block;
|
36
|
+
width: 100%;
|
37
|
+
text-align: left;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
30
41
|
.elements-button__element--info {
|
31
42
|
background-color: $button_info_background;
|
32
43
|
color: $button_info_color_text;
|
@@ -4,9 +4,25 @@
|
|
4
4
|
padding-bottom: 30px;
|
5
5
|
clear: both;
|
6
6
|
}
|
7
|
+
|
8
|
+
}
|
9
|
+
|
10
|
+
.widgets-index--actions-start {
|
11
|
+
.elements-table__table thead th:first-child {
|
12
|
+
text-align: center;
|
13
|
+
}
|
14
|
+
|
15
|
+
.elements-table__row td:first-child {
|
16
|
+
text-align: center;
|
17
|
+
min-width: 250px;
|
18
|
+
|
19
|
+
.elements-button__element {
|
20
|
+
font-size: 0.8em;
|
21
|
+
}
|
22
|
+
}
|
7
23
|
}
|
8
24
|
|
9
|
-
.widgets-index--actions {
|
25
|
+
.widgets-index--actions-end {
|
10
26
|
.elements-table__table thead th:last-child {
|
11
27
|
text-align: center;
|
12
28
|
}
|
@@ -12,6 +12,7 @@ module LatoCore
|
|
12
12
|
icon: nil,
|
13
13
|
icon_align: 'left',
|
14
14
|
method: 'get',
|
15
|
+
block: false,
|
15
16
|
remote: false,
|
16
17
|
confirmation: {
|
17
18
|
message: nil,
|
@@ -52,6 +53,8 @@ module LatoCore
|
|
52
53
|
@args[:confirmation][:negative_response])
|
53
54
|
@icon_left = (@args[:icon_align] === 'left')
|
54
55
|
@icon_right = (@args[:icon_align] === 'right')
|
56
|
+
|
57
|
+
@block_class = @args[:block] ? ' elements-button--block ' : ' '
|
55
58
|
end
|
56
59
|
|
57
60
|
end
|
@@ -1,7 +1,11 @@
|
|
1
|
-
<div class="elements-button">
|
1
|
+
<div class="elements-button <%= @block_class %>">
|
2
2
|
|
3
3
|
<button
|
4
|
-
class="
|
4
|
+
class="
|
5
|
+
button
|
6
|
+
elements-button__element
|
7
|
+
elements-button__element--<%= @args[:style] %>
|
8
|
+
elements-button__button"
|
5
9
|
title="<%= @args[:label] %>"
|
6
10
|
id="<%= @args[:id] %>"
|
7
11
|
<% if @show_submit %>
|
@@ -1,7 +1,10 @@
|
|
1
|
-
<div class="elements-button">
|
1
|
+
<div class="elements-button <%= @block_class %>">
|
2
2
|
|
3
3
|
<a
|
4
|
-
class="
|
4
|
+
class="
|
5
|
+
button elements-button__element
|
6
|
+
elements-button__element--<%= @args[:style] %>
|
7
|
+
elements-button__link"
|
5
8
|
title="<%= @args[:label] %>"
|
6
9
|
id="<%= @args[:id] %>"
|
7
10
|
<% if !@show_confirmation %>
|
@@ -24,7 +24,8 @@ module LatoCore
|
|
24
24
|
},
|
25
25
|
table_body: {
|
26
26
|
hover: false
|
27
|
-
}
|
27
|
+
},
|
28
|
+
actions_on_start: false
|
28
29
|
}
|
29
30
|
|
30
31
|
def initialize(args = {})
|
@@ -48,7 +49,8 @@ module LatoCore
|
|
48
49
|
@total = @args[:records].is_a?(Hash) ? @args[:records][:total] : @args[:records].length
|
49
50
|
# conditions for show
|
50
51
|
@show_row_actions = @args[:index_url] && @args[:actions] && (@args[:actions][:show] || @args[:actions][:edit] || @args[:actions][:delete])
|
51
|
-
@show_row_actions_class = @show_row_actions ? 'widgets-index--actions' : ''
|
52
|
+
@show_row_actions_class = @args[:actions_on_start] && @show_row_actions ? 'widgets-index--actions-start' : ''
|
53
|
+
@show_row_actions_class = !@args[:actions_on_start] && @show_row_actions ? 'widgets-index--actions-end' : @show_row_actions_class
|
52
54
|
@show_search = @args[:index_url] && @args[:search]
|
53
55
|
@show_pagiantion = @args[:index_url] && @args[:pagination]
|
54
56
|
@show_new_action = @args[:index_url] && @args[:actions] && @args[:actions][:new]
|
@@ -84,13 +86,41 @@ module LatoCore
|
|
84
86
|
|
85
87
|
if @args[:head] && @args[:head].length > 0
|
86
88
|
# manage case with custom head
|
87
|
-
labels =
|
88
|
-
|
89
|
-
|
89
|
+
labels = []
|
90
|
+
if @args[:actions_on_start] && @show_row_actions
|
91
|
+
labels.push(LANGUAGES[:lato_core][:mixed][:actions])
|
92
|
+
end
|
93
|
+
@args[:head].each do |head|
|
94
|
+
if head.is_a?(Hash)
|
95
|
+
sort_value = @args[:records].is_a?(Hash) ? @args[:records][:sort] : ''
|
96
|
+
sort_dir_value = @args[:records].is_a?(Hash) ? @args[:records][:sort_dir] : 'ASC'
|
97
|
+
active_class = sort_value == head[:sort] ? "attr-active attr-sort-#{sort_dir_value}" : ''
|
98
|
+
active_sort = sort_value == head[:sort] ? (sort_dir_value == 'ASC' ? 'DESC' : 'ASC') : sort_dir_value
|
99
|
+
search_value = @args[:records].is_a?(Hash) ? @args[:records][:search] : ''
|
100
|
+
|
101
|
+
url = core__add_param_to_url(@args[:index_url], 'widget_index[search]', search_value)
|
102
|
+
url = core__add_param_to_url(url, 'widget_index[sort]', head[:sort])
|
103
|
+
url = core__add_param_to_url(url, 'widget_index[sort_dir]', active_sort)
|
104
|
+
string = "<a href='#{url}' class='#{active_class}'>#{head[:label]}</a>"
|
105
|
+
labels.push(string)
|
106
|
+
else
|
107
|
+
labels.push(head)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
if !@args[:actions_on_start] && @show_row_actions
|
111
|
+
labels.push(LANGUAGES[:lato_core][:mixed][:actions])
|
112
|
+
end
|
113
|
+
elsif @records&.length > 0
|
90
114
|
# manage case without custom head
|
91
|
-
labels =
|
115
|
+
labels = []
|
116
|
+
if @args[:actions_on_start] && @show_row_actions
|
117
|
+
labels.push(LANGUAGES[:lato_core][:mixed][:actions])
|
118
|
+
end
|
119
|
+
labels = labels + @records.first.attributes.keys.map {|s| s.gsub('_', ' ')}
|
92
120
|
labels = labels.map(&:capitalize)
|
93
|
-
|
121
|
+
if !@args[:actions_on_start] && @show_row_actions
|
122
|
+
labels.push(LANGUAGES[:lato_core][:mixed][:actions])
|
123
|
+
end
|
94
124
|
end
|
95
125
|
|
96
126
|
return LatoCore::Elements::Table::Head::Cell.new(labels: labels)
|
@@ -124,12 +154,16 @@ module LatoCore
|
|
124
154
|
|
125
155
|
@records.each do |record|
|
126
156
|
labels = []
|
157
|
+
# add actions to row columns
|
158
|
+
if @args[:actions_on_start] && @show_row_actions
|
159
|
+
labels.push(generate_actions_bottongroup_for_record(record))
|
160
|
+
end
|
127
161
|
# add function result to row columns
|
128
162
|
columns_functions.each do |column_function|
|
129
163
|
labels.push(record.send(column_function))
|
130
164
|
end
|
131
165
|
# add actions to row columns
|
132
|
-
if @show_row_actions
|
166
|
+
if !@args[:actions_on_start] && @show_row_actions
|
133
167
|
labels.push(generate_actions_bottongroup_for_record(record))
|
134
168
|
end
|
135
169
|
# puts rows on table rows
|
@@ -194,7 +228,10 @@ module LatoCore
|
|
194
228
|
|
195
229
|
# This function generate and return the search input.
|
196
230
|
def generate_search_input
|
197
|
-
search_placeholder =
|
231
|
+
search_placeholder = ''
|
232
|
+
if @args[:records].is_a?(Hash)
|
233
|
+
search_placeholder = @args[:records][:search_key].is_a?(Array) ? @args[:records][:search_key].to_sentence : @args[:records][:search_key].humanize
|
234
|
+
end
|
198
235
|
search_value = @args[:records].is_a?(Hash) ? @args[:records][:search] : ''
|
199
236
|
return LatoCore::Inputs::Text::Cell.new(name: 'widget_index[search]', value: search_value, placeholder: search_placeholder)
|
200
237
|
end
|
@@ -216,9 +253,14 @@ module LatoCore
|
|
216
253
|
total_records_per_page = @args[:records].is_a?(Hash) ? @args[:records][:per_page] : @args[:records].length
|
217
254
|
total_pages = (total_records.to_f / total_records_per_page.to_f).ceil
|
218
255
|
current_page = @args[:records].is_a?(Hash) ? @args[:records][:pagination] : 1
|
256
|
+
|
219
257
|
search_value = @args[:records].is_a?(Hash) ? @args[:records][:search] : ''
|
258
|
+
sort_value = @args[:records].is_a?(Hash) ? @args[:records][:sort] : ''
|
259
|
+
sort_dir_value = @args[:records].is_a?(Hash) ? @args[:records][:sort_dir] : ''
|
220
260
|
|
221
261
|
url = core__add_param_to_url(@args[:index_url], 'widget_index[search]', search_value)
|
262
|
+
url = core__add_param_to_url(url, 'widget_index[sort]', sort_value)
|
263
|
+
url = core__add_param_to_url(url, 'widget_index[sort_dir]', sort_dir_value)
|
222
264
|
return LatoCore::Elements::Pagination::Cell.new(total: total_pages, current: current_page, url: url,
|
223
265
|
param: 'widget_index[pagination]')
|
224
266
|
end
|
@@ -367,5 +367,37 @@
|
|
367
367
|
|
368
368
|
<%=raw block.close %>
|
369
369
|
|
370
|
+
<%=raw row.close %>
|
371
|
+
<!-- / CODE SECTION -->
|
372
|
+
|
373
|
+
<hr>
|
374
|
+
<%=raw cell(:elements, :title).new(label: 'Button with block style', size: 3) %>
|
375
|
+
|
376
|
+
<%=raw row.open %>
|
377
|
+
|
378
|
+
<%=raw block.open %>
|
379
|
+
|
380
|
+
<%=raw cell(:elements, :button).new(label: 'Block link button', block: true, url: '#', remote: true) %>
|
381
|
+
<%=raw cell(:elements, :button).new(label: 'Block button', type: 'button', block: true, url: '#', remote: true) %>
|
382
|
+
|
383
|
+
<%=raw block.close %>
|
384
|
+
|
385
|
+
<%=raw row.close %>
|
386
|
+
|
387
|
+
<!-- CODE SECTION -->
|
388
|
+
<%=raw row.open %>
|
389
|
+
|
390
|
+
<%=raw block.open %>
|
391
|
+
|
392
|
+
<%=raw cell(:elements, :title).new(label: 'Code', size: 6) %>
|
393
|
+
|
394
|
+
<%=raw code.open %>
|
395
|
+
|
396
|
+
<%= erb_open_tag %>=raw cell(:elements, :button).new(label: 'Block button', block: true, url: '#', remote: true) <%= erb_close_tag %>
|
397
|
+
|
398
|
+
<%=raw code.close %>
|
399
|
+
|
400
|
+
<%=raw block.close %>
|
401
|
+
|
370
402
|
<%=raw row.close %>
|
371
403
|
<!-- / CODE SECTION -->
|
@@ -202,4 +202,51 @@ options</p>
|
|
202
202
|
<%=raw block.close %>
|
203
203
|
|
204
204
|
<%=raw row.close %>
|
205
|
-
<!-- / CODE SECTION -->
|
205
|
+
<!-- / CODE SECTION -->
|
206
|
+
|
207
|
+
<hr>
|
208
|
+
<%=raw cell(:elements, :title).new(label: 'Index with sortable attributes', size: 3) %>
|
209
|
+
|
210
|
+
<%=raw row.open %>
|
211
|
+
|
212
|
+
<%=raw block.open %>
|
213
|
+
|
214
|
+
<%=raw cell(:widgets, :index).new(records: @widget_index_superusers,
|
215
|
+
head: [
|
216
|
+
{label: 'Name', sort: 'name'},
|
217
|
+
{label: 'Surname', sort: 'surname'},
|
218
|
+
'Email', 'Username'
|
219
|
+
],
|
220
|
+
columns: ['name', 'surname', 'email', 'username'], index_url: lato_core.doc_cells_widgets_index_path,
|
221
|
+
actions: {show: false, edit: false, delete: false, new: false}, search: true, pagination: true,
|
222
|
+
table: { fixed: true, height: 150 }, table_body: { hover: true }) %>
|
223
|
+
|
224
|
+
<%=raw block.close %>
|
225
|
+
|
226
|
+
<%=raw row.close %>
|
227
|
+
|
228
|
+
<!-- CODE SECTION -->
|
229
|
+
<%=raw row.open %>
|
230
|
+
|
231
|
+
<%=raw block.open %>
|
232
|
+
|
233
|
+
<%=raw cell(:elements, :title).new(label: 'Code', size: 6) %>
|
234
|
+
|
235
|
+
<%=raw code.open %>
|
236
|
+
|
237
|
+
<%= erb_open_tag %>raw cell(:widgets, :index).new(records: @widget_index_superusers,
|
238
|
+
head: [
|
239
|
+
{label: 'Name', sort: 'name'},
|
240
|
+
{label: 'Surname', sort: 'surname'},
|
241
|
+
'Email', 'Username'
|
242
|
+
],
|
243
|
+
columns: ['name', 'surname', 'email', 'username'], index_url: lato_core.doc_cells_widgets_index_path,
|
244
|
+
actions: {show: false, edit: false, delete: false, new: false}, search: true, pagination: true,
|
245
|
+
table: { fixed: true, height: 150 }, table_body: { hover: true })<%= erb_close_tag %>
|
246
|
+
|
247
|
+
<%=raw code.close %>
|
248
|
+
|
249
|
+
<%=raw block.close %>
|
250
|
+
|
251
|
+
<%=raw row.close %>
|
252
|
+
<!-- / CODE SECTION -->
|
@@ -18,14 +18,32 @@ module LatoCore
|
|
18
18
|
per_page: pagination,
|
19
19
|
search: '',
|
20
20
|
search_key: search,
|
21
|
+
sort: '',
|
22
|
+
sort_dir: 'ASC',
|
21
23
|
pagination: 1,
|
22
24
|
}
|
25
|
+
|
23
26
|
# manage search
|
24
27
|
if search && params[:widget_index] && params[:widget_index][:search] && !params[:widget_index][:search].blank?
|
25
|
-
|
28
|
+
search_array = search.is_a?(Array) ? search : [search]
|
29
|
+
query1 = ''
|
30
|
+
query2 = []
|
31
|
+
search_array.each do |s|
|
32
|
+
query1 += "#{s} like ? OR "
|
33
|
+
query2.push("%#{params[:widget_index][:search]}%")
|
34
|
+
end
|
35
|
+
query1 = query1[0...-4]
|
36
|
+
query = [query1] + query2
|
37
|
+
response[:records] = response[:records].where(query)
|
26
38
|
response[:total] = response[:records].length
|
27
39
|
response[:search] = params[:widget_index][:search]
|
28
40
|
end
|
41
|
+
# manage sort
|
42
|
+
if params[:widget_index] && !params[:widget_index][:sort].blank? && !params[:widget_index][:sort_dir].blank?
|
43
|
+
response[:sort] = params[:widget_index][:sort]
|
44
|
+
response[:sort_dir] = params[:widget_index][:sort_dir]
|
45
|
+
response[:records] = response[:records].order("#{params[:widget_index][:sort]} #{params[:widget_index][:sort_dir]}")
|
46
|
+
end
|
29
47
|
# manage pagination
|
30
48
|
if pagination
|
31
49
|
if params[:widget_index] && params[:widget_index][:pagination]
|
data/lib/lato_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lato_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ideonetwork
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -471,7 +471,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
471
471
|
version: '0'
|
472
472
|
requirements: []
|
473
473
|
rubyforge_project:
|
474
|
-
rubygems_version: 2.
|
474
|
+
rubygems_version: 2.7.3
|
475
475
|
signing_key:
|
476
476
|
specification_version: 4
|
477
477
|
summary: Lato core module
|