tramway-core 1.16 → 1.16.1.4
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 +4 -1
- data/app/controllers/tramway/core/application_controller.rb +1 -3
- data/app/decorators/tramway/core/application_decorator.rb +1 -0
- data/app/decorators/tramway/core/concerns/attributes_decorator_helper.rb +6 -6
- data/app/helpers/tramway/core/copy_to_clipboard_helper.rb +13 -0
- data/app/models/tramway/core/application_record.rb +6 -2
- data/app/uploaders/file_uploader.rb +1 -1
- data/lib/tramway/collections/helper.rb +1 -1
- data/lib/tramway/core.rb +2 -2
- data/lib/tramway/core/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43002acf65a91407b1d149325e917c6b6e35296b9a56a6f3f6183f97e25d264a
|
4
|
+
data.tar.gz: 6df6dc5a6d61303f92ab8fcd949a5495c42a762b73ef35e848338600d25f9141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fbedfbc412d573935a63c98ed8dae98d2f1c7b42b6549df1f72d774edce4520bb510dbd6fcf592efb897d5723f1095e4c31c824ee560ec20cf475885f515124
|
7
|
+
data.tar.gz: 3366f0507b64d89f498786f63dbdb4e606125f9b5f2a3d66c893065ee77986c8b0025b22aaf76677aadc75ea2999e8ce6fead5c6275cf7807fab633e6db9c3f4
|
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` основным шрифтом для иконок.
|
@@ -1,9 +1,10 @@
|
|
1
1
|
#= require jquery
|
2
2
|
#= require jquery_ujs
|
3
|
-
#= require
|
3
|
+
#= require bootstrap
|
4
4
|
#= require bootstrap-datepicker-1.8.0
|
5
5
|
#= require bootstrap-datepicker-1.8.0.ru.min
|
6
6
|
#= require font_awesome5
|
7
|
+
#= require clipboard
|
7
8
|
#= require_tree .
|
8
9
|
|
9
10
|
window.i18n_locale = (locale) ->
|
@@ -28,3 +29,5 @@ $(document).ready ->
|
|
28
29
|
anchor = $(this).data('anchor')
|
29
30
|
unless $(anchor).offset() == undefined
|
30
31
|
$(window).scrollTop $(anchor).offset().top
|
32
|
+
|
33
|
+
clipboard = new Clipboard '.clipboard-btn'
|
@@ -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
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Tramway
|
2
|
+
module Core
|
3
|
+
module CopyToClipboardHelper
|
4
|
+
def copy_to_clipboard(id)
|
5
|
+
button_tag class: 'btn btn-info clipboard-btn',
|
6
|
+
data: { clipboard_action: 'copy', clipboard_target: "##{id}" },
|
7
|
+
style: 'margin-left: 15px' do
|
8
|
+
fa_icon 'copy'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -19,11 +19,15 @@ module Tramway
|
|
19
19
|
end
|
20
20
|
|
21
21
|
scope :active, -> { where state: :active }
|
22
|
-
scope :created_by_user, ->
|
23
|
-
scope :admin_scope, ->
|
22
|
+
scope :created_by_user, ->(user_id) { joins(:audits).where('audits.action = \'create\' AND audits.user_id = ?', user_id) }
|
23
|
+
scope :admin_scope, ->(_arg) { all }
|
24
24
|
|
25
25
|
include ::PgSearch::Model
|
26
26
|
|
27
|
+
def creator
|
28
|
+
audits.where(action: :create).first.user
|
29
|
+
end
|
30
|
+
|
27
31
|
# FIXME: detect inhertited locales
|
28
32
|
class << self
|
29
33
|
def human_attribute_name(attribute_name, *_args)
|
@@ -4,7 +4,7 @@ module Tramway
|
|
4
4
|
module Collections
|
5
5
|
module Helper
|
6
6
|
def collection_list_by(name:)
|
7
|
-
begin
|
7
|
+
begin
|
8
8
|
require name # needed to load class name with collection
|
9
9
|
rescue LoadError
|
10
10
|
raise "No such file #{name}. You should create file in the `lib/#{name}.rb` or elsewhere you want"
|
data/lib/tramway/core.rb
CHANGED
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:
|
4
|
+
version: 1.16.1.4
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: audited
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 4.2.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: clipboard-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: enumerize
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -346,6 +360,7 @@ files:
|
|
346
360
|
- app/forms/tramway/core/extendable_form.rb
|
347
361
|
- app/forms/tramway/core/extended_application_form.rb
|
348
362
|
- app/forms/tramway/core/form_creator.rb
|
363
|
+
- app/helpers/tramway/core/copy_to_clipboard_helper.rb
|
349
364
|
- app/helpers/tramway/core/title_helper.rb
|
350
365
|
- app/inputs/date_picker_input.rb
|
351
366
|
- app/models/tramway/core/application_record.rb
|