tramway-core 1.16.1 → 1.16.1.5
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/README.md +26 -0
- data/app/assets/javascripts/tramway/core/application.js.coffee +2 -0
- data/app/decorators/tramway/core/concerns/attributes_decorator_helper.rb +6 -6
- data/app/models/tramway/core/application_record.rb +4 -0
- data/app/uploaders/file_uploader.rb +1 -1
- data/lib/tramway/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e95b821e3743c540a04d8972861cec96926adb1fb210c9a51a39c5caa711cd
|
4
|
+
data.tar.gz: 456b6f0345b026debd72949521ab48b0bbc8b855d38045ca2bd70c7f6868b7de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e9d365a1af79128772bec57746ad6fc1bfc61e840179ac98eed919b620b6656ff7d1448a6f6cf12a6ec69c73e8a72f2a9c4666a0ccbd70c34e08e878812d794
|
7
|
+
data.tar.gz: 796ce3b5eab185625a02945ff9e90ab78cb2e74bae61de21bb4aa68180c199dae52fd63cd1ef46864edf42cb788d07aa5f4956b1573e3942b9375f73ce512d35
|
data/README.md
CHANGED
@@ -12,6 +12,7 @@ tramway-core - это ядро проекта [tramway](https://github.com/ulmic
|
|
12
12
|
```ruby
|
13
13
|
gem 'tramway-core'
|
14
14
|
gem 'audited'
|
15
|
+
gem 'clipboard-rails'
|
15
16
|
```
|
16
17
|
|
17
18
|
```shell
|
@@ -81,6 +82,31 @@ def field_type
|
|
81
82
|
end
|
82
83
|
```
|
83
84
|
|
85
|
+
## Other helpers
|
86
|
+
|
87
|
+
### CopyToClipboardHelper
|
88
|
+
|
89
|
+
[app/helpers/tramway/core/copy_to_clipboard_helper.rb](https://github.com/ulmic/tramway-dev/blob/develop/tramway-core/app/helpers/tramway/core/copy_to_clipboard_helper.rb)
|
90
|
+
|
91
|
+
#### Install
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
include ::Tramway::Core::CopyToClipboardHelper
|
95
|
+
```
|
96
|
+
|
97
|
+
#### How to use it
|
98
|
+
|
99
|
+
It will show you in the view in bootstrap styles with font-awesome `copy` icon.
|
100
|
+
|
101
|
+
Something like this:
|
102
|
+
|
103
|
+

|
104
|
+
|
105
|
+
```ruby
|
106
|
+
copy_to_clipboard "some_id" # some_id is HTML id of element. Content of this element will be copied to the clipboard after pressing the button
|
107
|
+
```
|
108
|
+
|
109
|
+
|
84
110
|
# Базовые классы
|
85
111
|
|
86
112
|
* ApplicationDecorator - Базовый класс декоратора. В него по умолчанию включены `ActionView::Helpers` и `ActionView::Context` и `FontAwesome5` (версия гема FontAwesome, которая поддерживает 5 версию шрифта). `FontAwesome` считается в `Tramway` основным шрифтом для иконок.
|
@@ -15,11 +15,11 @@ module Tramway::Core::Concerns::AttributesDecoratorHelper
|
|
15
15
|
|
16
16
|
def image_view(original, thumb: nil, filename: nil)
|
17
17
|
if original.present?
|
18
|
-
thumb ||= original.small
|
19
|
-
filename ||= original.path
|
20
|
-
src_thumb = if thumb
|
18
|
+
thumb ||= original.is_a?(CarrierWave::Uploader::Base) ? original.small : nil
|
19
|
+
filename ||= original.is_a?(CarrierWave::Uploader::Base) ? original.path&.split('/')&.last : nil
|
20
|
+
src_thumb = if thumb&.is_a?(CarrierWave::Uploader::Base)
|
21
21
|
thumb.url
|
22
|
-
elsif thumb
|
22
|
+
elsif thumb&.match(%r{^(?:[a-zA-Z0-9+/]{4})*(?:|(?:[a-zA-Z0-9+/]{3}=)|(?:[a-zA-Z0-9+/]{2}==)|(?:[a-zA-Z0-9+/]{1}===))$})
|
23
23
|
"data:image/jpeg;base64,#{thumb}"
|
24
24
|
else
|
25
25
|
thumb
|
@@ -33,12 +33,12 @@ module Tramway::Core::Concerns::AttributesDecoratorHelper
|
|
33
33
|
end
|
34
34
|
content_tag(:div) do
|
35
35
|
begin
|
36
|
-
concat image_tag src_thumb
|
36
|
+
concat image_tag src_thumb || src_original
|
37
37
|
rescue NoMethodError => e
|
38
38
|
error = Tramway::Error.new plugin: :core, method: :image_view, message: "You should mount PhotoUploader to your model. Just add `mount_uploader \#{attribute_name}, PhotoUploader` to your model. #{e.message}"
|
39
39
|
raise error.message
|
40
40
|
end
|
41
|
-
concat link_to(fa_icon(:download), src_original, class: 'btn btn-success', download: filename)
|
41
|
+
concat link_to(fa_icon(:download), src_original, class: 'btn btn-success', download: filename) if filename
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
data/lib/tramway/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.1
|
4
|
+
version: 1.16.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: audited
|