lato_core 2.1.2 → 2.1.3
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 +4 -4
- data/app/assets/javascripts/lato_core/application.js +18 -9
- data/app/assets/javascripts/lato_core/modules/CoreButton.js +38 -0
- data/app/assets/javascripts/lato_core/{initializers/Charts.js → modules/CoreChart.js} +12 -12
- data/app/assets/javascripts/lato_core/modules/CoreDatepicker.js +42 -0
- data/app/assets/javascripts/lato_core/modules/CoreEditor.js +27 -0
- data/app/assets/javascripts/lato_core/modules/CoreFlash.js +27 -0
- data/app/assets/javascripts/lato_core/modules/CoreFormValidator.js +110 -0
- data/app/assets/javascripts/lato_core/{initializers/Layout.js → modules/CoreLayout.js} +6 -5
- data/app/assets/javascripts/lato_core/modules/CoreMediapicker.js +140 -0
- data/app/assets/javascripts/lato_core/{interfaces/Modal.js → modules/CoreModal.js} +27 -2
- data/app/assets/javascripts/lato_core/modules/CoreSelect.js +110 -0
- data/app/assets/javascripts/lato_core/{initializers/inputs/SortableManager.js → modules/CoreSortableManager.js} +7 -6
- data/app/assets/javascripts/lato_core/modules/CoreTable.js +28 -0
- data/app/assets/stylesheets/lato_core/cells/inputs/_inputs.scss +1 -0
- data/app/assets/stylesheets/lato_core/cells/inputs/_multipleselect.scss +6 -0
- data/app/assets/stylesheets/lato_core/cells/widgets/_index.scss +9 -0
- data/app/cells/lato_core/inputs/dropzone/views/show.html.erb +24 -20
- data/app/cells/lato_core/inputs/multipleselect/cell.rb +52 -0
- data/app/cells/lato_core/inputs/multipleselect/views/show.html.erb +16 -0
- data/app/cells/lato_core/inputs/select/cell.rb +19 -1
- data/app/cells/lato_core/inputs/select/views/show.html.erb +10 -2
- data/app/cells/lato_core/widgets/index/cell.rb +1 -0
- data/app/cells/lato_core/widgets/index/views/partials/counter.html.erb +3 -0
- data/app/cells/lato_core/widgets/index/views/show.html.erb +2 -0
- data/app/controllers/lato_core/back/superusers_controller.rb +9 -9
- data/app/controllers/lato_core/doc/cells_inputs_controller.rb +28 -0
- data/app/views/lato_core/doc/cells_elements/button.html.erb +0 -4
- data/app/views/lato_core/doc/cells_elements/modal.html.erb +4 -4
- data/app/views/lato_core/doc/cells_inputs/multipleselect.html.erb +110 -0
- data/app/views/lato_core/doc/cells_inputs/select.html.erb +48 -2
- data/app/views/lato_core/doc/doc/index.html.erb +1 -0
- data/app/views/lato_core/doc/general/generators.html.erb +40 -0
- data/app/views/layouts/lato_core/partials/_logo.html.erb +7 -5
- data/config/languages/default.yml +2 -1
- data/config/languages/it.yml +2 -1
- data/config/routes/doc.rb +5 -0
- data/lib/generators/lato_core/crud_controller_generator.rb +35 -0
- data/lib/generators/lato_core/crud_generator.rb +31 -12
- data/lib/generators/lato_core/crud_views_generator.rb +52 -0
- data/lib/generators/lato_core/initializer_generator.rb +38 -28
- data/lib/generators/lato_core/scaffold_generator.rb +30 -0
- data/lib/generators/lato_core/templates/crud_controller/app/controllers/lato/crud_controller.rb +94 -0
- data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/edit.html.erb +24 -0
- data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/index.html.erb +35 -0
- data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/new.html.erb +24 -0
- data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/shared/_form.html.erb +42 -0
- data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/show.html.erb +22 -0
- data/lib/generators/lato_core/templates/{assets → initializer/assets}/images/logo.svg +0 -0
- data/lib/generators/lato_core/templates/{assets → initializer/assets}/javascripts/application.js +0 -0
- data/lib/generators/lato_core/templates/{assets → initializer/assets}/stylesheets/application.scss +0 -0
- data/lib/generators/lato_core/templates/{assets → initializer/assets}/stylesheets/theme.scss.erb +0 -0
- data/lib/generators/lato_core/templates/initializer/controllers/application_controller.rb +25 -0
- data/lib/generators/lato_core/templates/initializer/views/application/index.html.erb +20 -0
- data/lib/lato_core/interfaces/token.rb +4 -3
- data/lib/lato_core/version.rb +1 -1
- metadata +33 -16
- data/app/assets/javascripts/lato_core/initializers/Elements.js +0 -67
- data/app/assets/javascripts/lato_core/initializers/Inputs.js +0 -249
- data/app/assets/javascripts/lato_core/initializers/inputs/MultipleSelect.js +0 -0
- data/lib/generators/lato_core/templates/controllers/application_controller.rb +0 -13
- data/lib/generators/lato_core/templates/views/application/index.html.erb +0 -16
@@ -8,18 +8,37 @@ module LatoCore
|
|
8
8
|
|
9
9
|
source_root File.expand_path('../templates', __FILE__)
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
argument :model_name, type: :string, default: 'Crud'
|
12
|
+
|
13
|
+
desc 'This function create a complete crud with Lato.'
|
14
|
+
def create_crud
|
15
|
+
set_utils_names
|
16
|
+
|
17
|
+
run_lato_crud_controller_generator
|
18
|
+
run_lato_crud_views_generator
|
19
|
+
|
20
|
+
update_route
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def set_utils_names
|
26
|
+
@model_name = model_name
|
27
|
+
@singular_name = @model_name.underscore
|
28
|
+
@plural_name = @singular_name.pluralize
|
29
|
+
@controller_name = @plural_name.camelize
|
30
|
+
end
|
31
|
+
|
32
|
+
def run_lato_crud_controller_generator
|
33
|
+
generate 'lato_core:crud_controller', model_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def run_lato_crud_views_generator
|
37
|
+
generate 'lato_core:crud_views', model_name
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_route
|
41
|
+
route "namespace :lato { resources :#{@plural_name} }"
|
23
42
|
end
|
24
43
|
|
25
44
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/base'
|
4
|
+
|
5
|
+
module LatoCore
|
6
|
+
# CrudViewsGenerator.
|
7
|
+
class CrudViewsGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates/crud_views', __FILE__)
|
10
|
+
|
11
|
+
argument :model_name, type: :string, default: 'Crud'
|
12
|
+
|
13
|
+
desc 'This function create a complete crud controller with Lato.'
|
14
|
+
def create_crud
|
15
|
+
set_utils_names
|
16
|
+
|
17
|
+
manage_views
|
18
|
+
manage_shared_views
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def set_utils_names
|
24
|
+
@model_name = model_name
|
25
|
+
@singular_name = @model_name.underscore
|
26
|
+
@plural_name = @singular_name.pluralize
|
27
|
+
@controller_name = @plural_name.camelize
|
28
|
+
end
|
29
|
+
|
30
|
+
def manage_views
|
31
|
+
# copy index
|
32
|
+
template('app/views/lato/crud/index.html.erb',
|
33
|
+
"app/views/lato/#{@plural_name}/index.html.erb")
|
34
|
+
# copy show
|
35
|
+
template('app/views/lato/crud/show.html.erb',
|
36
|
+
"app/views/lato/#{@plural_name}/show.html.erb")
|
37
|
+
# copy new
|
38
|
+
template('app/views/lato/crud/new.html.erb',
|
39
|
+
"app/views/lato/#{@plural_name}/new.html.erb")
|
40
|
+
# copy edit
|
41
|
+
template('app/views/lato/crud/edit.html.erb',
|
42
|
+
"app/views/lato/#{@plural_name}/edit.html.erb")
|
43
|
+
end
|
44
|
+
|
45
|
+
def manage_shared_views
|
46
|
+
# copy form
|
47
|
+
template('app/views/lato/crud/shared/_form.html.erb',
|
48
|
+
"app/views/lato/#{@plural_name}/shared/_form.html.erb")
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -6,40 +6,50 @@ module LatoCore
|
|
6
6
|
# InitializerGenerator.
|
7
7
|
class InitializerGenerator < Rails::Generators::Base
|
8
8
|
|
9
|
-
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
source_root File.expand_path('../templates/initializer', __FILE__)
|
10
10
|
|
11
11
|
desc 'This function initialize your Rails project to support Lato.'
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
def create_initializer
|
13
|
+
manage_controllers
|
14
|
+
manage_views
|
15
|
+
manage_assets_stylesheets
|
16
|
+
manage_assets_javascripts
|
17
|
+
manage_assets_images
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def manage_controllers
|
23
|
+
# copy controllers
|
24
|
+
copy_file('controllers/application_controller.rb',
|
25
|
+
'app/controllers/lato/application_controller.rb')
|
26
|
+
end
|
27
|
+
|
28
|
+
def manage_views
|
29
|
+
# copy views
|
30
|
+
copy_file('views/application/index.html.erb',
|
31
|
+
'app/views/lato/application/index.html.erb')
|
32
|
+
end
|
33
|
+
|
34
|
+
def manage_assets_stylesheets
|
23
35
|
# copy stylesheets theme file
|
24
|
-
copy_file(
|
25
|
-
|
26
|
-
'app/assets/stylesheets/lato/theme.scss.erb'
|
27
|
-
)
|
36
|
+
copy_file('assets/stylesheets/theme.scss.erb',
|
37
|
+
'app/assets/stylesheets/lato/theme.scss.erb')
|
28
38
|
# copy stylesheets application file
|
29
|
-
copy_file(
|
30
|
-
|
31
|
-
|
32
|
-
|
39
|
+
copy_file('assets/stylesheets/application.scss',
|
40
|
+
'app/assets/stylesheets/lato/application.scss')
|
41
|
+
end
|
42
|
+
|
43
|
+
def manage_assets_javascripts
|
33
44
|
# copy javascripts application file
|
34
|
-
copy_file(
|
35
|
-
|
36
|
-
|
37
|
-
|
45
|
+
copy_file('assets/javascripts/application.js',
|
46
|
+
'app/assets/javascripts/lato/application.js')
|
47
|
+
end
|
48
|
+
|
49
|
+
def manage_assets_images
|
38
50
|
# copy images logo file
|
39
|
-
copy_file(
|
40
|
-
|
41
|
-
'app/assets/images/lato/logo.svg'
|
42
|
-
)
|
51
|
+
copy_file('assets/images/logo.svg',
|
52
|
+
'app/assets/images/lato/logo.svg')
|
43
53
|
end
|
44
54
|
|
45
55
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators/base'
|
4
|
+
|
5
|
+
module LatoCore
|
6
|
+
# ScaffoldGenerator.
|
7
|
+
class ScaffoldGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
10
|
+
|
11
|
+
argument :model_name, type: :string, default: 'Scaffold'
|
12
|
+
|
13
|
+
desc 'This function create a complete scaffold with Lato.'
|
14
|
+
def create_crud
|
15
|
+
run_model_generator
|
16
|
+
run_lato_crud_generator
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def run_model_generator
|
22
|
+
generate 'model', model_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_lato_crud_generator
|
26
|
+
generate 'lato_core:crud', model_name
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/generators/lato_core/templates/crud_controller/app/controllers/lato/crud_controller.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lato
|
4
|
+
|
5
|
+
# <%= @controller_name %>Controller.
|
6
|
+
class <%= @controller_name %>Controller < Lato::ApplicationController
|
7
|
+
|
8
|
+
before_action do
|
9
|
+
core__set_menu_active_item('<%= @singular_name %>')
|
10
|
+
end
|
11
|
+
|
12
|
+
def index
|
13
|
+
core__set_header_active_page_title('<%= @plural_name.humanize %>')
|
14
|
+
@<%= @plural_name %> = <%= @model_name %>.all
|
15
|
+
@widget_index_<%= @plural_name %> = core__widgets_index(
|
16
|
+
@<%= @plural_name %>,
|
17
|
+
search: 'name',
|
18
|
+
pagination: 10
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def show
|
23
|
+
core__set_header_active_page_title('<%= @singular_name.humanize %>')
|
24
|
+
@<%= @singular_name %> = <%= @model_name %>.find_by(id: params[:id])
|
25
|
+
return unless check_<%= @singular_name %>_presence
|
26
|
+
end
|
27
|
+
|
28
|
+
def new
|
29
|
+
core__set_header_active_page_title('New <%= @singular_name.humanize %>')
|
30
|
+
@<%= @singular_name %> = <%= @model_name %>.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def create
|
34
|
+
@<%= @singular_name %> = <%= @model_name %>.new(<%= @singular_name %>_params)
|
35
|
+
|
36
|
+
unless @<%= @singular_name %>.save
|
37
|
+
flash[:danger] = @<%= @singular_name %>.errors.full_messages.to_sentence
|
38
|
+
redirect_to new_lato_<%= @singular_name %>_path
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
42
|
+
flash[:success] = '<%= @singular_name.humanize %> created succesfully'
|
43
|
+
redirect_to lato_<%= @singular_name %>_path(@<%= @singular_name %>.id)
|
44
|
+
end
|
45
|
+
|
46
|
+
def edit
|
47
|
+
core__set_header_active_page_title('Edit <%= @singular_name.humanize %>')
|
48
|
+
@<%= @singular_name %> = <%= @model_name %>.find_by(id: params[:id])
|
49
|
+
return unless check_<%= @singular_name %>_presence
|
50
|
+
end
|
51
|
+
|
52
|
+
def update
|
53
|
+
@<%= @singular_name %> = <%= @model_name %>.find_by(id: params[:id])
|
54
|
+
return unless check_<%= @singular_name %>_presence
|
55
|
+
|
56
|
+
unless @<%= @singular_name %>.update(<%= @singular_name %>_params)
|
57
|
+
flash[:danger] = @<%= @singular_name %>.errors.full_messages.to_sentence
|
58
|
+
redirect_to edit_lato_<%= @singular_name %>_path(@<%= @singular_name %>.id)
|
59
|
+
return
|
60
|
+
end
|
61
|
+
|
62
|
+
flash[:success] = '<%= @singular_name.humanize %> updated succesfully'
|
63
|
+
redirect_to lato_<%= @singular_name %>_path(@<%= @singular_name %>.id)
|
64
|
+
end
|
65
|
+
|
66
|
+
def destroy
|
67
|
+
@<%= @singular_name %> = <%= @model_name %>.find_by(id: params[:id])
|
68
|
+
return unless check_<%= @singular_name %>_presence
|
69
|
+
|
70
|
+
unless @<%= @singular_name %>.destroy
|
71
|
+
flash[:danger] = @<%= @singular_name %>.errors.full_messages.to_sentence
|
72
|
+
redirect_to lato_<%= @singular_name %>_path(@<%= @singular_name %>.id)
|
73
|
+
return
|
74
|
+
end
|
75
|
+
|
76
|
+
flash[:success] = '<%= @singular_name.humanize %> destroyed succesfully'
|
77
|
+
redirect_to lato_<%= @singular_name %>s_path
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def <%= @singular_name %>_params
|
83
|
+
params.require(:<%= @singular_name %>).permit(:name)
|
84
|
+
end
|
85
|
+
|
86
|
+
def check_<%= @singular_name %>_presence
|
87
|
+
return true if @<%= @singular_name %>
|
88
|
+
redirect_to lato_<%= @singular_name %>s_path
|
89
|
+
false
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%%
|
2
|
+
# initialize row
|
3
|
+
row = cell(:elements, :row).new
|
4
|
+
|
5
|
+
# initialize block
|
6
|
+
block = cell(:elements, :block).new(class: 'xs-12 sm-12 md-12')
|
7
|
+
|
8
|
+
# initialize title
|
9
|
+
title = cell(:elements, :title).new(label: 'Edit <%= @singular_name.humanize %>', size: 2)
|
10
|
+
%>
|
11
|
+
|
12
|
+
<!-- MAIN CONTAINER -->
|
13
|
+
<%%=raw row.open %>
|
14
|
+
|
15
|
+
<%%=raw block.open %>
|
16
|
+
|
17
|
+
<%%=raw title %>
|
18
|
+
|
19
|
+
<%%= render 'lato/<%= @plural_name %>/shared/form', url: lato_<%= @singular_name %>_path(@<%= @singular_name %>.id), method: :put %>
|
20
|
+
|
21
|
+
<%%=raw block.close %>
|
22
|
+
|
23
|
+
<%%=raw row.close %>
|
24
|
+
<!-- / MAIN CONTAINER -->
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<%%
|
2
|
+
# initialize row
|
3
|
+
row = cell(:elements, :row).new
|
4
|
+
|
5
|
+
# initialize block
|
6
|
+
block = cell(:elements, :block).new(class: 'xs-12 sm-12 md-12')
|
7
|
+
|
8
|
+
# initialize index
|
9
|
+
index = cell(:widgets, :index).new(
|
10
|
+
records: @widget_index_<%= @plural_name %>,
|
11
|
+
index_url: lato_<%= @plural_name %>_path,
|
12
|
+
head: ['Id', 'Name'],
|
13
|
+
columns: [:id, :name],
|
14
|
+
search: true,
|
15
|
+
pagination: true,
|
16
|
+
actions: {
|
17
|
+
edit: true,
|
18
|
+
new: true,
|
19
|
+
delete: true,
|
20
|
+
show: true,
|
21
|
+
}
|
22
|
+
)
|
23
|
+
%>
|
24
|
+
|
25
|
+
<!-- MAIN CONTAINER -->
|
26
|
+
<%%=raw row.open %>
|
27
|
+
|
28
|
+
<%%=raw block.open %>
|
29
|
+
|
30
|
+
<%%=raw index %>
|
31
|
+
|
32
|
+
<%%=raw block.close %>
|
33
|
+
|
34
|
+
<%%=raw row.close %>
|
35
|
+
<!-- / MAIN CONTAINER -->
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%%
|
2
|
+
# initialize row
|
3
|
+
row = cell(:elements, :row).new
|
4
|
+
|
5
|
+
# initialize block
|
6
|
+
block = cell(:elements, :block).new(class: 'xs-12 sm-12 md-12')
|
7
|
+
|
8
|
+
# initialize title
|
9
|
+
title = cell(:elements, :title).new(label: 'New <%= @singular_name.humanize %>', size: 2)
|
10
|
+
%>
|
11
|
+
|
12
|
+
<!-- MAIN CONTAINER -->
|
13
|
+
<%%=raw row.open %>
|
14
|
+
|
15
|
+
<%%=raw block.open %>
|
16
|
+
|
17
|
+
<%%=raw title %>
|
18
|
+
|
19
|
+
<%%= render 'lato/<%= @plural_name %>/shared/form', url: lato_<%= @plural_name %>_path, method: :post %>
|
20
|
+
|
21
|
+
<%%=raw block.close %>
|
22
|
+
|
23
|
+
<%%=raw row.close %>
|
24
|
+
<!-- / MAIN CONTAINER -->
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%%
|
2
|
+
# initialize row
|
3
|
+
row = cell(:elements, :row).new
|
4
|
+
|
5
|
+
# initialize form
|
6
|
+
form = cell(:inputs, :form).new(url: url, method: method)
|
7
|
+
|
8
|
+
# initialize input name
|
9
|
+
input_name = cell(:inputs, :text).new(
|
10
|
+
name: '<%= @singular_name %>[name]',
|
11
|
+
label: 'Name',
|
12
|
+
required: true,
|
13
|
+
class: 'md-12',
|
14
|
+
value: @<%= @singular_name %>.name
|
15
|
+
)
|
16
|
+
|
17
|
+
# initialize button save
|
18
|
+
button_save = cell(:elements, :button).new(
|
19
|
+
type: 'submit',
|
20
|
+
label: 'Save',
|
21
|
+
style: 'success',
|
22
|
+
icon: 'check'
|
23
|
+
)
|
24
|
+
%>
|
25
|
+
|
26
|
+
<!-- FORM CONTAINER -->
|
27
|
+
<%%=raw form.open %>
|
28
|
+
|
29
|
+
<%%=raw row.open %>
|
30
|
+
|
31
|
+
<%%=raw input_name %>
|
32
|
+
|
33
|
+
<%%=raw row.close %>
|
34
|
+
|
35
|
+
<div class="text-right">
|
36
|
+
|
37
|
+
<%%=raw button_save %>
|
38
|
+
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<%%=raw form.close %>
|
42
|
+
<!-- / FORM CONTAINER -->
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%%
|
2
|
+
# initialize row
|
3
|
+
row = cell(:elements, :row).new
|
4
|
+
|
5
|
+
# initialize block
|
6
|
+
block = cell(:elements, :block).new(class: 'xs-12 sm-12 md-12')
|
7
|
+
|
8
|
+
# initialize title
|
9
|
+
title = cell(:elements, :title).new(label: @<%= @singular_name %>.name, size: 2)
|
10
|
+
%>
|
11
|
+
|
12
|
+
<!-- MAIN CONTAINER -->
|
13
|
+
<%%=raw row.open %>
|
14
|
+
|
15
|
+
<%%=raw block.open %>
|
16
|
+
|
17
|
+
<%%=raw title %>
|
18
|
+
|
19
|
+
<%%=raw block.close %>
|
20
|
+
|
21
|
+
<%%=raw row.close %>
|
22
|
+
<!-- / MAIN CONTAINER -->
|