tybo 0.2.6 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/components/index_header_export_component.html.erb +5 -1
- data/lib/generators/bo/bo_generator.rb +1 -1
- data/lib/generators/bo/templates/_search_bar.html.erb +9 -9
- data/lib/generators/bo/templates/controller.rb +32 -0
- data/lib/generators/bo/templates/index.html.erb +1 -0
- data/lib/generators/bo/utils/files/fr.json +1 -1
- data/lib/generators/bo/utils/translations.rb +0 -1
- data/lib/generators/bo_namespace/bo_namespace_generator.rb +1 -1
- data/lib/generators/bo_namespace/templates/admin_controller.rb +1 -0
- data/lib/generators/tybo_install/tybo_install_generator.rb +2 -2
- data/lib/generators/tybo_install/utils/files/en.json +2 -1
- data/lib/generators/tybo_install/utils/files/fr.json +2 -1
- data/lib/generators/tybo_install/utils/translations.rb +1 -0
- data/lib/tybo/version.rb +1 -1
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b3aa98d8a47b14d56d3af8b3fb8471d463d996761bd0aec1b3c246b6357810
|
4
|
+
data.tar.gz: 17d6114cd4efa0dedd2d99a37cf93434ead97cc036f6cbb1039f48b8b0e0fc88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecf0a24c19fdb662c60710ec92b6095e4b48ae8c160ea1363fd35d479d0c7d03b769c6bfd1d3a67e5b9468ac1f5ffab17228d098c295d95b3c69f22963809496
|
7
|
+
data.tar.gz: 649ee5595fdbab032c98f60fd7937586cfdbf05abf12befb47f057b64b24afe3661d320c96a8fb73ff2708a0d955bc7fc4b29b5819bb87bc8ae9e8346673b6b1
|
data/README.md
CHANGED
@@ -57,7 +57,8 @@ add your policy logic in ApplicationController eg:
|
|
57
57
|
|
58
58
|
**Customize colors**: Change the `tybo` colors class in `tailwind.config.js`,
|
59
59
|
you can use https://uicolors.app/create to generate complete palette
|
60
|
-
|
60
|
+
## Customize trix editor
|
61
|
+
https://gist.github.com/dhairyagabha/034f5baefb054b7b960438aaf3d88341
|
61
62
|
## Contributing
|
62
63
|
|
63
64
|
Contribution directions go here.
|
@@ -1,3 +1,7 @@
|
|
1
1
|
<div class="mt-4 mr-2 sm:flex-none">
|
2
|
-
<%= link_to I18n.t('bo.
|
2
|
+
<%= link_to I18n.t('bo.export_btn'),
|
3
|
+
@path,
|
4
|
+
id: 'exportBtn',
|
5
|
+
class: "inline-flex items-center justify-center rounded-md border border-transparent bg-tybo px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-tybo-700 focus:outline-none focus:ring-2 focus:ring-tybo-500 focus:ring-offset-2 sm:w-auto"
|
6
|
+
%>
|
3
7
|
</div>
|
@@ -38,7 +38,7 @@ class BoGenerator < Rails::Generators::NamedBase
|
|
38
38
|
return if rails_routes.any?("#{options[:namespace]}_#{plural_name}")
|
39
39
|
|
40
40
|
inject_into_file 'config/routes.rb', after: " namespace :#{options[:namespace]} do\n" do
|
41
|
-
" resources :#{plural_name}\n"
|
41
|
+
" resources :#{plural_name} do\n get 'export_csv', on: :collection\n end\n"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<div class="relative mt-3
|
1
|
+
<div class="relative inline-block mt-3 text-left" data-controller="dropdown">
|
2
2
|
<div>
|
3
|
-
<button data-action="click->dropdown#toggle click@window->dropdown#hide" type="button" class="inline-flex
|
3
|
+
<button data-action="click->dropdown#toggle click@window->dropdown#hide" type="button" class="inline-flex justify-center w-full px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md shadow-sm hover:bg-gray-50 focus:outline-none " id="menu-button" aria-expanded="true" aria-haspopup="true">
|
4
4
|
<%%= I18n.t('bo.filters') %>
|
5
|
-
<svg class="-
|
5
|
+
<svg class="w-5 h-5 ml-2 -mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
6
6
|
<path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd" />
|
7
7
|
</svg>
|
8
8
|
</button>
|
@@ -22,29 +22,29 @@
|
|
22
22
|
<%%= f.number_field :<%= col.name %>_eq, placeholder: I18n.t('bo.<%= class_name.underscore %>.attributes.<%= col.name %>'), data: { action: "input->search-form#search" }, class: "block w-full max-w-lg rounded-md border-gray-300 shadow-sm focus:border-tybo-500 focus:ring-tybo-500 sm:max-w-xs sm:text-sm" %>
|
23
23
|
<%% end %>
|
24
24
|
<%- elsif col.type == :boolean -%>
|
25
|
-
<div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4
|
25
|
+
<div class="pt-5 sm:grid sm:grid-cols-3 sm:items-start sm:gap-4">
|
26
26
|
<label class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">
|
27
27
|
<%%= I18n.t('bo.<%= class_name.underscore %>.attributes.<%= col.name %>') %>
|
28
28
|
</label>
|
29
29
|
<div class="mt-1 sm:col-span-2 sm:mt-0">
|
30
|
-
<span class="
|
30
|
+
<span class="inline-flex rounded-md shadow-sm isolate">
|
31
31
|
<button type="button"
|
32
32
|
data-target-id='q_<%= col.name %>_eq'
|
33
33
|
data-action="click->search-form#setBooleanField"
|
34
|
-
class="relative inline-flex items-center
|
34
|
+
class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-l-md hover:bg-gray-50 focus:z-10 focus:border-tybo-500 focus:outline-none focus:ring-1 focus:ring-tybo-500">
|
35
35
|
-
|
36
36
|
</button>
|
37
37
|
<button type="button"
|
38
38
|
data-action="click->search-form#setBooleanField"
|
39
39
|
data-value='true'
|
40
40
|
data-target-id='q_<%= col.name %>_eq'
|
41
|
-
class="relative inline-flex items-center
|
41
|
+
class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-l-md hover:bg-gray-50 focus:z-10 focus:border-tybo-500 focus:outline-none focus:ring-1 focus:ring-tybo-500">ON
|
42
42
|
</button>
|
43
43
|
<button type="button"
|
44
44
|
data-action="click->search-form#setBooleanField"
|
45
45
|
data-value='false'
|
46
46
|
data-target-id='q_<%= col.name %>_eq'
|
47
|
-
class="relative inline-flex items-center
|
47
|
+
class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-l-md hover:bg-gray-50 focus:z-10 focus:border-tybo-500 focus:outline-none focus:ring-1 focus:ring-tybo-500">OFF</button>
|
48
48
|
</span>
|
49
49
|
<%%= f.hidden_field :<%= col.name %>_eq, value: nil, data: { action: "change->search-form#search"}%>
|
50
50
|
</div>
|
@@ -60,7 +60,7 @@
|
|
60
60
|
<%- end -%>
|
61
61
|
<!-- belongs_to Associations -->
|
62
62
|
<%- belongs_to_assoc.each do |association| -%>
|
63
|
-
<div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4
|
63
|
+
<div class="pt-5 sm:grid sm:grid-cols-3 sm:items-start sm:gap-4">
|
64
64
|
<label for="<%=association.name%>" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">
|
65
65
|
<%%= I18n.t('bo.<%=association.klass.name.underscore%>.one') %>
|
66
66
|
</label>
|
@@ -63,8 +63,40 @@ module <%= options[:namespace].camelize %>
|
|
63
63
|
redirect_to <%="#{options[:namespace]}_#{class_name.underscore.pluralize}_path"%>, status: :see_other
|
64
64
|
end
|
65
65
|
|
66
|
+
def export_csv
|
67
|
+
@<%= class_name.pluralize.underscore %> = fetch_authorized_<%= class_name.pluralize.underscore %>
|
68
|
+
csv_data = generate_csv_data
|
69
|
+
|
70
|
+
send_data csv_data,
|
71
|
+
type: 'text/csv; charset=utf-8; header=present',
|
72
|
+
disposition: "attachment; filename=#{I18n.t("bo.<%= class_name.underscore %>.other")}_#{Time.zone.now}.csv"
|
73
|
+
end
|
74
|
+
|
66
75
|
private
|
67
76
|
|
77
|
+
def fetch_authorized_<%= class_name.pluralize.underscore %>
|
78
|
+
authorized_scope(
|
79
|
+
<%=class_name%>.all,
|
80
|
+
with: Bo::Administrators::<%=class_name%>Policy
|
81
|
+
).ransack(params[:q]).result(distinct: true)
|
82
|
+
end
|
83
|
+
|
84
|
+
def generate_csv_data
|
85
|
+
CSV.generate(headers: true) do |csv|
|
86
|
+
csv << translated_headers
|
87
|
+
|
88
|
+
@<%= class_name.pluralize.underscore %>.each do |instance|
|
89
|
+
csv << <%=class_name%>.column_names.map { |col| instance.send(col) }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def translated_headers
|
95
|
+
<%=class_name%>.column_names.map do |col|
|
96
|
+
I18n.t("bo.<%=class_name.downcase%>.attributes.#{col}")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
68
100
|
def set_<%= class_name.underscore %>
|
69
101
|
@<%= class_name.underscore %> = authorized_scope(
|
70
102
|
<%= class_name %>.all,
|
@@ -5,6 +5,7 @@
|
|
5
5
|
subtitle: I18n.t('bo.<%= class_name.underscore %>.subtitle').capitalize,
|
6
6
|
) do |header| %>
|
7
7
|
<%%= header.with_add_button(path: <%="new_#{options[:namespace]}_#{class_name.underscore}_path" %>) %>
|
8
|
+
<%%= header.with_export_button(path: <%= "export_csv_#{options[:namespace]}_#{class_name.pluralize.underscore}_path(format: :csv)"%>)%>
|
8
9
|
<%% end %>
|
9
10
|
|
10
11
|
<!-- Search Bar -->
|
@@ -11,7 +11,6 @@ def create_translations
|
|
11
11
|
'new' => find_existing_translation(nil, locale),
|
12
12
|
'subtitle' => find_existing_translation("list of #{bo_model.to_s.pluralize.downcase}", locale),
|
13
13
|
'attributes' => model_attributes(data, locale)
|
14
|
-
|
15
14
|
}
|
16
15
|
output = YAML.dump data
|
17
16
|
File.write(locale_file, output)
|
@@ -43,7 +43,7 @@ class BoNamespaceGenerator < Rails::Generators::NamedBase
|
|
43
43
|
# devise_route = "devise_for :#{singular_name},\n path: '#{plural_name}',\n controllers: {\n sessions: 'custom_devise/sessions',\n passwords: 'custom_devise/passwords',\n registrations: 'custom_devise/registrations'\n }"
|
44
44
|
gsub_file('config/routes.rb', /devise_for :#{plural_name}/, "devise_for :#{plural_name}, path: '#{plural_name}'")
|
45
45
|
# route devise_route
|
46
|
-
route "# #{plural_name.capitalize}\nnamespace :#{plural_name} do\n root to: '#{plural_name}#index'\n resources :#{plural_name}\nend"
|
46
|
+
route "# #{plural_name.capitalize}\nnamespace :#{plural_name} do\n root to: '#{plural_name}#index'\n resources :#{plural_name} do\n get 'export_csv', on: :collection\n end\n\nend"
|
47
47
|
end
|
48
48
|
|
49
49
|
def remove_devise_registration
|
@@ -23,7 +23,7 @@ class TyboInstallGenerator < Rails::Generators::Base
|
|
23
23
|
|
24
24
|
def pin_js_dependencies
|
25
25
|
run "./bin/importmap pin tom-select --download"
|
26
|
-
run "./bin/importmap pin @tymate/
|
26
|
+
run "./bin/importmap pin @tymate/tybo_js"
|
27
27
|
end
|
28
28
|
|
29
29
|
def create_routes
|
@@ -39,7 +39,7 @@ class TyboInstallGenerator < Rails::Generators::Base
|
|
39
39
|
|
40
40
|
def add_javascript_controllers
|
41
41
|
inject_into_file 'app/javascript/controllers/application.js', after: "const application = Application.start()\n" do
|
42
|
-
"import { Dropdown, Flash, SearchForm, TsSearch, TsSelect } from \"@tymate/
|
42
|
+
"import { Dropdown, Flash, SearchForm, TsSearch, TsSelect } from \"@tymate/tybo_js\"\n"
|
43
43
|
end
|
44
44
|
|
45
45
|
inject_into_file 'app/javascript/controllers/application.js', before: "export { application }" do
|
@@ -9,6 +9,7 @@
|
|
9
9
|
'filters' => find_existing_translation('filters', locale),
|
10
10
|
'show' => find_existing_translation('show', locale),
|
11
11
|
'to' => find_existing_translation('to', locale),
|
12
|
+
'export_btn' => find_existing_translation('export_btn', locale),
|
12
13
|
'confirm_delete' => find_existing_translation('confirm_delete', locale),
|
13
14
|
'record' => {
|
14
15
|
'created' => find_existing_translation('created', locale),
|
data/lib/tybo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tybo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Delpierre
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-10-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -17,20 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '7.
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 7.0.4.3
|
20
|
+
version: '7.1'
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
25
|
- - "~>"
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: '7.
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 7.0.4.3
|
27
|
+
version: '7.1'
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: puma
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -302,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
302
296
|
- !ruby/object:Gem::Version
|
303
297
|
version: '0'
|
304
298
|
requirements: []
|
305
|
-
rubygems_version: 3.
|
299
|
+
rubygems_version: 3.0.3.1
|
306
300
|
signing_key:
|
307
301
|
specification_version: 4
|
308
302
|
summary: A tailwind custom admin engine for Ruby on Rails
|