tybo 0.1.2 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19a15b6fd183a3db2358d6da62faaebeb078daf9b6966ba05c8c098e311d35ff
4
- data.tar.gz: 22c8a8d66b275c80c04fe63f016fbcad26fa1fff50fea299ae9c04517e0c1586
3
+ metadata.gz: 99b6c52df41ad55c9a50c8f5e76dbcdf18972f4a417360ac5902f3cb203842ad
4
+ data.tar.gz: f4f9ef0ee8f3029e925b5158714b44776ac4d7ff6234fcf9328652640c137e04
5
5
  SHA512:
6
- metadata.gz: 5d5932d7d1506b24465b9b82768fe1d2d2a91a6c657a6733537bc7cb094afe602f7e74ecd965aaf0c701cf8863aa8eee641e201d1ad99063d6c883e1133ac3e5
7
- data.tar.gz: 8d2b29f180b5c1acb7f54d3edd28c9c2e4f435f22acd13649a4240c7111c58243e21fd46deb7e85cd3e4266d050209ed9af5a0c55501af35a29c251e7e27cc38
6
+ metadata.gz: 42012ad58801a47d31b21905d1036b55dee575ca37f4540cb34dfb8080b004499b5da05d096ab72e5b685c3db847f3dc068991a26a23dd06bd098a045badbdcc
7
+ data.tar.gz: c163a4ddb426ffcc1f886289222a78990f08adb3b2db512b35385a2c58c9b8cb73faf3a69fc478e8e14b730a5b469182c143073f06a4083622626ae81e2b9fe4
@@ -0,0 +1,6 @@
1
+ <div class="my-5">
2
+ <label class="block text-sm font-medium text-gray-700 string required text-sm font-medium text-gray-600">
3
+ <%= @label %>
4
+ </label>
5
+ <%= @form.datetime_field @field, class: "mt-1 block border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-tybo-500 focus:border-tybo-500 sm:text-sm string required" %>
6
+ </div>
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Input
4
+ class DatetimeComponent < ViewComponent::Base
5
+ def initialize(item:, field:, form:)
6
+ @item = item
7
+ @field = field
8
+ @form = form
9
+ @label = label
10
+ end
11
+
12
+ def label
13
+ I18n.t("bo.#{@item.class.name.underscore}.attributes.#{@field}")
14
+ end
15
+ end
16
+ end
@@ -13,7 +13,7 @@ module Input
13
13
  end
14
14
 
15
15
  def label
16
- I18n.t("bo.#{@item.class.name.downcase}.attributes.#{@field}")
16
+ I18n.t("bo.#{@item.class.name.underscore}.attributes.#{@field}")
17
17
  end
18
18
 
19
19
  def picture
@@ -1,34 +1,45 @@
1
- <% link = pagy_link_proc(pagy) -%>
2
- <nav class="mx-auto mt-6 flex max-w-7xl justify-between px-4 text-sm font-medium text-gray-700 sm:px-6 lg:px-8" role="navigation">
3
-
4
- <% if pagy.prev -%>
5
- <div class="min-w-0 flex-1">
6
- <%== link.call(pagy.prev, I18n.t('bo.nav.prev'), 'aria-label="previous" class="inline-flex h-10 items-center rounded-md border border-gray-300 bg-white px-4 hover:bg-gray-100 focus:border-tybo-600 focus:outline-none focus:ring-2 focus:ring-tybo-600 focus:ring-opacity-25 focus:ring-offset-1 focus:ring-offset-tybo-600""') %>
1
+ <% if pagy.next || pagy.prev %>
2
+ <% link = pagy_link_proc(pagy) %>
3
+ <div class="flex items-center justify-between bg-white py-3">
4
+ <div class="hidden sm:flex sm:flex-1 sm:items-center sm:justify-between">
5
+ <div>
6
+ <p class="text-sm text-gray-700">
7
+ <%= I18n.t('bo.pagy.showing').capitalize %>
8
+ <span class="font-bold text-tybo"><%= pagy.from %></span>
9
+ <%= I18n.t('bo.pagy.to') %>
10
+ <span class="font-bold text-tybo"><%= pagy.to %></span>
11
+ <%= I18n.t('bo.pagy.of') %>
12
+ <span class="font-bold text-tybo"><%= pagy.count %></span>
13
+ <%= I18n.t('bo.pagy.results') %>
14
+ </p>
15
+ </div>
16
+ <div>
17
+ <nav class="isolate inline-flex -space-x-px rounded-md shadow-sm" aria-label="Pagination">
18
+ <% if pagy.prev %>
19
+ <a href="<%= pagy_url_for(pagy, pagy.prev) %>" aria-label="precedent" class="relative inline-flex items-center rounded-l-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0">
20
+ <svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
21
+ <path fill-rule="evenodd" d="M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z" clip-rule="evenodd" />
22
+ </svg>
23
+ </a>
24
+ <% end %>
25
+ <% pagy.series.each do |item| %>
26
+ <% if item.is_a?(Integer) %>
27
+ <%== link.call(item, item.to_s, 'class="relative inline-flex items-center px-4 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0"') %>
28
+ <% elsif item.is_a?(String) %>
29
+ <span class="relative z-10 inline-flex items-center bg-tybo-600 px-4 py-2 text-sm font-semibold text-white focus:z-20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-tybo-600"><%= item %></span>
30
+ <% elsif item == :gap %>
31
+ <span class="relative inline-flex items-center px-4 py-2 text-sm font-semibold text-gray-700 ring-1 ring-inset ring-gray-300 focus:outline-offset-0">...</span>
32
+ <% end %>
33
+ <% end %>
34
+ <% if pagy.next %>
35
+ <a href="<%= pagy_url_for(pagy, pagy.next) %>" aria-label="suivant" class="relative inline-flex items-center rounded-r-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0">
36
+ <svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
37
+ <path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
38
+ </svg>
39
+ </a>
40
+ <% end %>
41
+ </nav>
42
+ </div>
7
43
  </div>
8
- <% else -%>
9
- <div class="min-w-0 flex-1">
10
- <%== link.call(pagy.prev, I18n.t('bo.nav.prev'), 'aria-label="previous" class="hidden"') %>
11
- </div>
12
- <% end -%>
13
- <% if pagy.next -%>
14
- <% pagy.series.each do |item|
15
- # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] -%>
16
- <% if item.is_a?(Integer) -%>
17
- <%== link.call(item, item, 'class="inline-flex h-10 items-center rounded-md border border-gray-300 bg-white px-4 hover:bg-gray-100 focus:border-tybo-600 focus:outline-none focus:ring-2 focus:ring-tybo-600 focus:ring-opacity-25 focus:ring-offset-1 focus:ring-offset-tybo-600"') %>
18
- <% elsif item.is_a?(String) -%>
19
- <%== link.call(item, item, 'class="inline-flex h-10 items-center rounded-md border border-tybo-600 bg-white px-4 ring-1 ring-tybo-600 hover:bg-gray-100 focus:border-tybo-600 focus:outline-none focus:ring-2 focus:ring-tybo-600 focus:ring-opacity-25 focus:ring-offset-1 focus:ring-offset-tybo-600"') %>
20
- <% elsif item == :gap -%>
21
- <span class="inline-flex h-10 items-center px-1.5 text-gray-500">
22
- <%== I18n.t('bo.nav.gap') %>
23
- </span>
24
- <% end -%>
25
- <% end -%>
26
- <div class="flex min-w-0 flex-1 justify-end">
27
- <%== link.call(pagy.next, I18n.t('bo.nav.next'), 'aria-label="next" class="inline-flex h-10 items-center rounded-md border border-gray-300 bg-white px-4 hover:bg-gray-100 focus:border-tybo-600 focus:outline-none focus:ring-2 focus:ring-tybo-600 focus:ring-opacity-25 focus:ring-offset-1 focus:ring-offset-tybo-600"') %>
28
- </div>
29
- <% else -%>
30
- <div class="flex min-w-0 flex-1 justify-end">
31
- <%== link.call(pagy.next, I18n.t('bo.nav.next'), 'aria-label="next" class="hidden"') %>
32
- </div>
33
- <% end -%>
34
- </nav>
44
+ </div>
45
+ <% end %>
@@ -1,8 +1,12 @@
1
1
  <%%= simple_form_for [:<%= options[:namespace] %>, <%= class_name.underscore %>], html: { class: "<%= class_name.underscore %> form" } do |f| %>
2
2
  <!-- Model columns -->
3
- <%- bo_model.column_names.each do |column| -%>
4
- <%- next if excluded_columns.include?(column.to_sym) || bo_model.reflect_on_all_associations.map(&:foreign_key).include?(column) -%>
5
- <%%= f.input :<%= column %>,label: I18n.t('bo.<%= class_name.underscore %>.attributes.<%= column %>') %>
3
+ <%- bo_model.columns.each do |column| -%>
4
+ <%- next if excluded_columns.include?(column.name.to_sym) || bo_model.reflect_on_all_associations.map(&:foreign_key).include?(column.name) -%>
5
+ <%- if column.type == :datetime -%>
6
+ <%%= render(Input::DatetimeComponent.new(item: <%= class_name.underscore %>, field: '<%= column.name %>', form: f)) %>
7
+ <%- else -%>
8
+ <%%= f.input :<%= column.name %>,label: I18n.t('bo.<%= class_name.underscore %>.attributes.<%= column.name %>') %>
9
+ <%- end -%>
6
10
  <%- end -%>
7
11
  <!-- belongs_to Associations -->
8
12
  <%- belongs_to_assoc.each do |association| -%>
@@ -1,14 +1,16 @@
1
- <%%= render(FormComponent.new(item: <%= class_name.underscore %>)) do |form| %>
2
- <%% current_page = if <%= class_name.underscore %>.persisted?
3
- { label: I18n.t('bo.show'), path: <%= "#{options[:namespace]}_#{class_name.underscore}_path(#{class_name.underscore})"%> }
4
- else
5
- { label: I18n.t('bo.<%= class_name.underscore %>.new').capitalize, path: <%= "new_#{options[:namespace]}_#{class_name.underscore}_path" %> }
6
- end
7
- form.with_title(<%= class_name.underscore %>.persisted? ? <%= class_name.underscore %>.<%=bo_model_title(bo_model)%> : I18n.t('bo.<%= class_name.underscore %>.new').capitalize)
8
- form.with_breadcrumb([
9
- { label: I18n.t('bo.<%= class_name.underscore %>.others').capitalize, path: <%= "#{options[:namespace]}_#{class_name.pluralize.underscore}_path"%> },
10
- current_page
11
- ]) %>
12
- <br>
13
- <%%= render "form", <%= class_name.underscore %>: @<%= class_name.underscore %> %>
1
+ <%%= turbo_frame_tag "<%= class_name.pluralize.underscore %>", target: '_top' do %>
2
+ <%%= render(FormComponent.new(item: <%= class_name.underscore %>)) do |form| %>
3
+ <%% current_page = if <%= class_name.underscore %>.persisted?
4
+ { label: I18n.t('bo.show'), path: <%= "#{options[:namespace]}_#{class_name.underscore}_path(#{class_name.underscore})"%> }
5
+ else
6
+ { label: I18n.t('bo.<%= class_name.underscore %>.new').capitalize, path: <%= "new_#{options[:namespace]}_#{class_name.underscore}_path" %> }
7
+ end
8
+ form.with_title(<%= class_name.underscore %>.persisted? ? <%= class_name.underscore %>.<%=bo_model_title(bo_model)%> : I18n.t('bo.<%= class_name.underscore %>.new').capitalize)
9
+ form.with_breadcrumb([
10
+ { label: I18n.t('bo.<%= class_name.underscore %>.others').capitalize, path: <%= "#{options[:namespace]}_#{class_name.pluralize.underscore}_path"%> },
11
+ current_page
12
+ ]) %>
13
+ <br>
14
+ <%%= render "form", <%= class_name.underscore %>: @<%= class_name.underscore %> %>
15
+ <%% end %>
14
16
  <%% end %>
@@ -22,5 +22,8 @@
22
22
  "next": "Suivant",
23
23
  "prev": "Précédent",
24
24
  "gap": "...",
25
- "show": "Détails"
25
+ "show": "Détails",
26
+ "showing": "Affichage de",
27
+ "of": "de",
28
+ "results": "resultats"
26
29
  }
@@ -3,35 +3,6 @@
3
3
  def create_translations
4
4
  %w[en fr].each do |locale|
5
5
  locale_file = "config/locales/bo.#{locale}.yml"
6
- unless File.exist?(locale_file)
7
- File.write(locale_file, {
8
- locale => {
9
- 'bo' => {
10
- 'filters' => find_existing_translation('filters', locale),
11
- 'details' => find_existing_translation('details', locale),
12
- 'to' => find_existing_translation('to', locale),
13
- 'confirm_delete' => find_existing_translation('confirm_delete', locale),
14
- 'record' => {
15
- 'created' => find_existing_translation('created', locale),
16
- 'updated' => find_existing_translation('updated', locale),
17
- 'destroyed' => find_existing_translation('destroyed', locale),
18
- 'show' => find_existing_translation('show', locale),
19
- },
20
- 'nav' => {
21
- 'prev' => find_existing_translation('prev', locale),
22
- 'next' => find_existing_translation('next', locale),
23
- 'gap' => find_existing_translation('gap', locale)
24
- },
25
- 'devise' => {
26
- 'password' => find_existing_translation('password', locale),
27
- 'new' => find_existing_translation('new', locale),
28
- 'forgot_password' => find_existing_translation('forgot_password', locale),
29
- }
30
- }
31
- }
32
- }.to_yaml)
33
- end
34
-
35
6
  yaml_string = File.open locale_file
36
7
  data = YAML.load yaml_string
37
8
  data[locale]['bo'][file_name.underscore] = {
@@ -8,7 +8,7 @@ module.exports = {
8
8
  './app/helpers/**/*.rb',
9
9
  './app/javascript/**/*.js',
10
10
  './app/views/**/*.{erb,haml,html,slim}',
11
- './app/components/**/*.html.erb',
11
+ './app/components/**/*.{erb,haml,html,rb}',
12
12
  output.trim() + '/app/**/*.{erb,haml,html,rb}'
13
13
  ],
14
14
  theme: {
@@ -27,5 +27,8 @@
27
27
  "remember_me": "Remember me?",
28
28
  "sign_in": "Sign in",
29
29
  "send_me_reset_password_instructions": "Send me reset password instructions",
30
- "save": "Save"
30
+ "save": "Save",
31
+ "showing": "Showing",
32
+ "of": "of",
33
+ "results": "results"
31
34
  }
@@ -27,5 +27,8 @@
27
27
  "remember_me": "Se souvenir de moi ?",
28
28
  "sign_in": "Connexion",
29
29
  "send_me_reset_password_instructions": "Réinitialiser mon mot de passe",
30
- "save": "Sauvegarder"
30
+ "save": "Sauvegarder",
31
+ "showing": "Affichage de",
32
+ "of": "de",
33
+ "results": "resultats"
31
34
  }
@@ -20,6 +20,13 @@
20
20
  'next' => find_existing_translation('next', locale),
21
21
  'gap' => find_existing_translation('gap', locale)
22
22
  },
23
+ 'pagy' => {
24
+ 'showing' => find_existing_translation('showing', locale),
25
+ 'to' => find_existing_translation('to', locale),
26
+ 'of' => find_existing_translation('of', locale),
27
+ 'show' => find_existing_translation('show', locale),
28
+ 'results' => find_existing_translation('results', locale)
29
+ },
23
30
  'devise' => {
24
31
  'password' => find_existing_translation('password', locale),
25
32
  'forgot_password' => find_existing_translation('forgot_password', locale),
data/lib/tybo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tybo
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.2'
3
3
  end
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.1.2
4
+ version: 0.2.2
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-05-05 00:00:00.000000000 Z
12
+ date: 2023-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -189,6 +189,8 @@ files:
189
189
  - app/components/index_header_component.rb
190
190
  - app/components/index_header_export_component.html.erb
191
191
  - app/components/index_header_export_component.rb
192
+ - app/components/input/datetime_component.html.erb
193
+ - app/components/input/datetime_component.rb
192
194
  - app/components/input/file_component.html.erb
193
195
  - app/components/input/file_component.rb
194
196
  - app/components/sidebar_component.html.erb