rao-component 0.0.12.pre → 0.0.13.pre

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
- SHA1:
3
- metadata.gz: 94764255737ffc07408b7ad6a0d46c2c155b650d
4
- data.tar.gz: 4d9da7a0ae336f2dd30f6430ff07ecafb15a80e8
2
+ SHA256:
3
+ metadata.gz: c0613885c558246bc228999d7f7d3a91444b77a76731257393fd8c8991b3b318
4
+ data.tar.gz: 0014e3e575b034b41cd3b4a5d34734ab666017c797c236532369fec1b76126a8
5
5
  SHA512:
6
- metadata.gz: 1496be3ef1bacfe0ddbb1d298c4c4b18f014857f7492bdee81b4946d42d899d3b1cbc89372c83dd8e55347accb0cf6352f575e26f30cf0e84c798f2047519296
7
- data.tar.gz: 97cb8d49ee46329a3659c1baa4f0014a8c3ddcc499b3173d4e75270c230d0f6ba466c7fc8f93e05a4d55cb57b5304c4bda8eb27efd050cb379a0778cf701aef8
6
+ metadata.gz: d606c60b4a3ddeb307279fbab0bf9d0f2fe9f9ea3b942a8443704b82b307ce9538a0713d082938e6a0224cf44b4c691cd06bc68f552a3effc91b668d090257bb
7
+ data.tar.gz: e70869a49f4b2548acd9e8ded0385b63ec2a9eefaf4ce3605f0f165078ecb61bae5ead63eef11819b9161e3609a892ba08e30740904a71c440ed65ca548e5de7
@@ -15,6 +15,11 @@ module Rao
15
15
  include ActsAsListConcern
16
16
  include BatchActionsConcern
17
17
  include BooleanConcern
18
+ include EmailConcern
19
+ include DateConcern
20
+ include ThumbnailConcern
21
+
22
+ attr_reader :collection
18
23
 
19
24
  SIZE_MAP = {
20
25
  default: nil,
@@ -11,6 +11,9 @@ module Rao
11
11
  #
12
12
  class ResourceTable < Base
13
13
  include BooleanConcern
14
+ include DateConcern
15
+ include EmailConcern
16
+ include ThumbnailConcern
14
17
 
15
18
  SIZE_MAP = {
16
19
  default: nil,
@@ -0,0 +1,12 @@
1
+ module Rao
2
+ module Component
3
+ module CollectionTable::DateConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ def date(name, options = {}, &block)
7
+ options.reverse_merge!(render_as: :date, format: Rao::Component::Configuration.table_default_date_format)
8
+ column(name, options, &block)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Rao
2
+ module Component
3
+ module CollectionTable::EmailConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ def email(name, options = {}, &block)
7
+ options.reverse_merge!(render_as: :email)
8
+ column(name, options, &block)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Rao
2
+ module Component
3
+ module CollectionTable::ThumbnailConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ def thumbnail(name, options = {}, &block)
7
+ options.reverse_merge!(render_as: :thumbnail, variant_options: Rao::Component::Configuration.image_variant_options[:collection])
8
+ column(name, options, &block)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Rao
2
+ module Component
3
+ module ResourceTable::DateConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ def date(name, options = {}, &block)
7
+ options.reverse_merge!(render_as: :date, format: Rao::Component::Configuration.table_default_date_format)
8
+ row(name, options, &block)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Rao
2
+ module Component
3
+ module ResourceTable::EmailConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ def email(name, options = {}, &block)
7
+ options.reverse_merge!(render_as: :email)
8
+ row(name, options, &block)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Rao
2
+ module Component
3
+ module ResourceTable::ThumbnailConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ def thumbnail(name, options = {}, &block)
7
+ options.reverse_merge!(render_as: :thumbnail, variant_options: Rao::Component::Configuration.image_variant_options[:resource])
8
+ row(name, options, &block)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,11 +1,10 @@
1
- - link_path = controller.url_for(action: :toggle_published, id: resource.to_param)
2
1
  - if resource.published?
3
- = button_to(link_path, class: 'btn btn-sm btn-xs btn-danger btn-responsive', method: :post) do
2
+ = button_to([:toggle_published, resource], class: 'btn btn-sm btn-xs btn-danger btn-responsive', method: :post) do
4
3
  %i.fas.fa-eye-slash
5
4
  %span.glyphicon.glyphicon-eye-close
6
5
  %span.btn-text= t('.unpublish', default: t('acts_as_published.actions.unpublish'))
7
6
  - else
8
- = button_to(link_path, class: 'btn btn-sm btn-xs btn-success btn-responsive', method: :post) do
7
+ = button_to([:toggle_published, resource], class: 'btn btn-sm btn-xs btn-success btn-responsive', method: :post) do
9
8
  %i.fas.fa-eye
10
9
  %span.glyphicon.glyphicon-eye-open
11
10
  %span.btn-text= t('.publish', default: t('acts_as_published.actions.publish'))
@@ -1,18 +1,19 @@
1
- - label = if options[:label_method].present?
2
- - case options[:label_method]
1
+ - if resource.send(name).present?
2
+ - label = if options[:label_method].present?
3
+ - case options[:label_method]
4
+ - when Proc
5
+ - options[:label_method].call(resource.send(name))
6
+ - else
7
+ - resource.send(name).try(options[:label_method])
8
+ - else
9
+ - resource.send(name)
10
+ - link_to = options[:link_to]
11
+ - case link_to
3
12
  - when Proc
4
- - options[:label_method].call(resource.send(name))
5
- - else
6
- - resource.send(name).try(options[:label_method])
7
- - else
8
- - resource.send(name)
9
- - link_to = options[:link_to]
10
- - case link_to
11
- - when Proc
12
- = link_to(label, link_to.call(resource))
13
- - when String
14
- = link_to(label, link_to)
15
- - when Symbol
16
- = link_to(label, send(link_to))
17
- - when nil
18
- = label
13
+ = link_to(label, link_to.call(resource))
14
+ - when String
15
+ = link_to(label, link_to)
16
+ - when Symbol
17
+ = link_to(label, send(link_to))
18
+ - when nil
19
+ = label
@@ -0,0 +1,7 @@
1
+ - if options[:label_method].present?
2
+ = resource.send(name).send(options[:label_method])
3
+ - else
4
+ - if (value = resource.send(name)).present? && options[:format].present?
5
+ = I18n.l(value, format: options[:format])
6
+ - else
7
+ = value
@@ -0,0 +1 @@
1
+ = mail_to(resource.send(name))
@@ -0,0 +1,2 @@
1
+ - image_html = options[:image_html] || { src: main_app.url_for(resource.send(name).variant(options[:variant_options])) }
2
+ %img{ image_html }
@@ -10,6 +10,7 @@ de:
10
10
  edit: Bearbeiten
11
11
  show: Anzeigen
12
12
  download: Download
13
+ visit: Öffnen
13
14
  table:
14
15
  body_cells:
15
16
  boolean:
@@ -18,4 +19,12 @@ de:
18
19
  header_cells:
19
20
  batch_actions:
20
21
  title: Stapelverarbeitung
21
- destroy: Löschen
22
+ destroy: Löschen
23
+ publish: Veröffentlichen
24
+ unpublish: Zurückziehen
25
+ date:
26
+ formats:
27
+ short_with_year: "%d.%m.%Y"
28
+ time:
29
+ formats:
30
+ short_with_year: "%d.%m.%Y %H:%M:%S"
@@ -10,6 +10,7 @@ en:
10
10
  edit: Edit
11
11
  show: Show
12
12
  download: Download
13
+ visit: Open
13
14
  table:
14
15
  body_cells:
15
16
  boolean:
@@ -18,4 +19,12 @@ en:
18
19
  header_cells:
19
20
  batch_actions:
20
21
  title: Batch actions
21
- destroy: Delete
22
+ destroy: Delete
23
+ publish: Publish
24
+ unpublish: Unpublish
25
+ date:
26
+ formats:
27
+ short_with_year: "%Y-%m-%d"
28
+ time:
29
+ formats:
30
+ short_with_year: "%Y-%m-%d %I:%M:%S %p"
@@ -4,4 +4,25 @@ Rao::Component.configure do |config|
4
4
  # Default: config.table_default_timestamp_format = nil
5
5
  #
6
6
  config.table_default_timestamp_format = nil
7
+
8
+ # Set the default format for dates in tables.
9
+ #
10
+ # Default: config.table_default_date_format = nil
11
+ #
12
+ config.table_default_date_format = nil
13
+
14
+
15
+ # Image variant options for images in tables
16
+ #
17
+ # default:
18
+ #
19
+ # config.image_variant_options = {
20
+ # collection: { resize: "160x120" },
21
+ # resource: { resize: "320x240" }
22
+ # }
23
+ #
24
+ config.image_variant_options = {
25
+ collection: { resize: "160x120" },
26
+ resource: { resize: "320x240" }
27
+ }
7
28
  end
@@ -6,6 +6,13 @@ module Rao
6
6
  end
7
7
 
8
8
  mattr_accessor(:table_default_timestamp_format) { nil }
9
+ mattr_accessor(:table_default_date_format) { nil }
10
+ mattr_accessor(:image_variant_options) {
11
+ {
12
+ collection: { resize: "160x120" },
13
+ resource: { resize: "320x240" }
14
+ }
15
+ }
9
16
  end
10
17
  end
11
18
  end
data/lib/rao/component.rb CHANGED
@@ -6,4 +6,6 @@ module Rao
6
6
  module Component
7
7
  extend Configuration
8
8
  end
9
- end
9
+ end
10
+
11
+ Rao.configure { |c| c.register_configuration(:component, Rao::Component) }
data/lib/rao-component.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require "haml-rails"
2
-
3
2
  require "rao"
3
+
4
4
  require "rao/component"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rao-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12.pre
4
+ version: 0.0.13.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-14 00:00:00.000000000 Z
11
+ date: 2019-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -183,7 +183,13 @@ files:
183
183
  - app/concerns/rao/component/collection_table/awesome_nested_set_concern.rb
184
184
  - app/concerns/rao/component/collection_table/batch_actions_concern.rb
185
185
  - app/concerns/rao/component/collection_table/boolean_concern.rb
186
+ - app/concerns/rao/component/collection_table/date_concern.rb
187
+ - app/concerns/rao/component/collection_table/email_concern.rb
188
+ - app/concerns/rao/component/collection_table/thumbnail_concern.rb
186
189
  - app/concerns/rao/component/resource_table/boolean_concern.rb
190
+ - app/concerns/rao/component/resource_table/date_concern.rb
191
+ - app/concerns/rao/component/resource_table/email_concern.rb
192
+ - app/concerns/rao/component/resource_table/thumbnail_concern.rb
187
193
  - app/helpers/rao/component/application_helper.rb
188
194
  - app/views/rao/component/_collection_table.html.haml
189
195
  - app/views/rao/component/_resource_table.html.haml
@@ -193,7 +199,10 @@ files:
193
199
  - app/views/rao/component/table/body_cells/_awesome_nested_set.html.haml
194
200
  - app/views/rao/component/table/body_cells/_batch_actions.html.haml
195
201
  - app/views/rao/component/table/body_cells/_boolean.html.haml
202
+ - app/views/rao/component/table/body_cells/_date.html.haml
196
203
  - app/views/rao/component/table/body_cells/_default.html.haml
204
+ - app/views/rao/component/table/body_cells/_email.html.haml
205
+ - app/views/rao/component/table/body_cells/_thumbnail.html.haml
197
206
  - app/views/rao/component/table/body_cells/_timestamp.html.haml
198
207
  - app/views/rao/component/table/header_cells/_batch_actions.html.haml
199
208
  - config/locales/de.yml
@@ -224,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
233
  - !ruby/object:Gem::Version
225
234
  version: 1.3.1
226
235
  requirements: []
227
- rubyforge_project:
228
- rubygems_version: 2.6.14
236
+ rubygems_version: 3.0.2
229
237
  signing_key:
230
238
  specification_version: 4
231
239
  summary: View Components for Ruby on Rails.