udongo 1.0.3 → 1.0.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/app/assets/javascripts/backend/flexible_content.js +33 -0
- data/app/assets/javascripts/backend/sortable.js +1 -1
- data/app/assets/stylesheets/backend/pages/_flexible_content.scss +61 -0
- data/app/controllers/backend/admins_controller.rb +7 -7
- data/app/controllers/backend/content/rows/columns_controller.rb +7 -15
- data/app/controllers/backend/content/rows/images_controller.rb +1 -1
- data/app/controllers/backend/content/rows/texts_controller.rb +1 -1
- data/app/controllers/backend/content/rows_controller.rb +4 -13
- data/app/controllers/backend/email_templates_controller.rb +4 -4
- data/app/controllers/backend/emails_controller.rb +3 -3
- data/app/controllers/backend/forms/base_controller.rb +14 -0
- data/app/controllers/backend/forms/submissions_controller.rb +8 -0
- data/app/controllers/backend/forms_controller.rb +7 -0
- data/app/controllers/backend/navigation/items_controller.rb +8 -5
- data/app/controllers/backend/navigations_controller.rb +1 -1
- data/app/controllers/backend/pages_controller.rb +5 -5
- data/app/controllers/backend/redirects_controller.rb +4 -4
- data/app/controllers/backend/sessions_controller.rb +1 -1
- data/app/controllers/backend/snippets_controller.rb +6 -5
- data/app/controllers/backend/tagbox_controller.rb +4 -4
- data/app/controllers/backend_controller.rb +3 -3
- data/app/controllers/catch_all_controller.rb +1 -1
- data/app/controllers/redirects_controller.rb +1 -1
- data/app/decorators/application_decorator.rb +5 -0
- data/app/decorators/content_image_decorator.rb +1 -1
- data/app/decorators/content_row_decorator.rb +9 -0
- data/app/decorators/content_text_decorator.rb +1 -1
- data/app/decorators/form_decorator.rb +16 -0
- data/app/decorators/form_submission_decorator.rb +3 -0
- data/app/decorators/navigation_item_decorator.rb +2 -2
- data/app/decorators/page_decorator.rb +2 -2
- data/app/decorators/pagination_decorator.rb +4 -0
- data/app/decorators/redirect_decorator.rb +1 -1
- data/app/decorators/snippet_decorator.rb +1 -1
- data/app/forms/backend/snippet_form.rb +4 -18
- data/app/helpers/backend/pagination_helper.rb +1 -11
- data/app/helpers/icon_helper.rb +1 -1
- data/app/helpers/snippet_helper.rb +1 -1
- data/app/models/concerns/storable/collection.rb +48 -26
- data/app/models/concerns/translatable.rb +1 -1
- data/app/models/content_row.rb +4 -0
- data/app/models/form.rb +1 -0
- data/app/models/store_with_file.rb +2 -0
- data/app/views/backend/content/_image.html.erb +1 -8
- data/app/views/backend/content/_rows.html.erb +52 -49
- data/app/views/backend/emails/index.html.erb +2 -10
- data/app/views/backend/forms/index.html.erb +27 -0
- data/app/views/backend/forms/submissions/_filter.html.erb +16 -0
- data/app/views/backend/forms/submissions/index.html.erb +34 -0
- data/app/views/backend/redirects/index.html.erb +2 -10
- data/app/views/layouts/backend/_top_navigation.html.erb +1 -0
- data/changelog.md +14 -1
- data/config/locales/en_backend.yml +5 -5
- data/config/locales/nl_backend.yml +10 -10
- data/config/routes.rb +6 -6
- data/db/migrate/20160711114156_add_description_to_forms.rb +5 -0
- data/lib/generators/udongo/form/form_generator.rb +1 -1
- data/lib/tasks/udongo_tasks.rake +1 -1
- data/lib/udongo/config.rb +2 -1
- data/lib/udongo/configs/forms.rb +14 -0
- data/lib/udongo/flexible_content/column_width_calculator.rb +32 -0
- data/lib/udongo/form.rb +36 -0
- data/lib/udongo/forms/config.rb +11 -0
- data/lib/udongo/forms/submission_datagrid.rb +29 -0
- data/lib/udongo/forms/submission_filter.rb +33 -0
- data/lib/udongo/notification.rb +19 -0
- data/lib/udongo/object_path.rb +0 -2
- data/lib/udongo/version.rb +1 -1
- data/lib/udongo/will_paginate/options.rb +40 -0
- data/lib/udongo/will_paginate/renderer.rb +8 -4
- data/lib/udongo.rb +4 -11
- data/readme.md +145 -49
- metadata +24 -2
data/readme.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://codeclimate.com/github/udongo/udongo)
|
2
2
|
|
3
3
|
# Concerns
|
4
4
|
## Storable concern
|
@@ -12,38 +12,46 @@
|
|
12
12
|
* Float
|
13
13
|
|
14
14
|
### Setup
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
```ruby
|
16
|
+
class User < ActiveRecord::Base
|
17
|
+
include Concerns::Storable
|
18
|
+
|
19
|
+
storable_field :gender, String, 'male'
|
20
|
+
storable_field :age, Integer
|
21
|
+
storable_field :last_login_at, DateTime
|
22
|
+
storable_field :cool_dude, Boolean, true
|
23
|
+
storable_field :locales, Array, %w(nl)
|
24
|
+
storable_field :birthday, Date
|
25
|
+
end
|
26
|
+
```
|
25
27
|
|
26
28
|
### Reading values
|
27
|
-
|
28
|
-
|
29
|
+
```ruby
|
30
|
+
u = User.first
|
31
|
+
u.gender
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
# Which is equal to
|
34
|
+
u.store(:default).gender
|
35
|
+
```
|
32
36
|
|
33
37
|
### Writing values
|
34
|
-
|
35
|
-
|
38
|
+
```ruby
|
39
|
+
u = User.first
|
40
|
+
u.gender = 'female'
|
36
41
|
|
37
|
-
|
38
|
-
|
42
|
+
# Which is equal to
|
43
|
+
u.store(:default).gender = 'female'
|
44
|
+
```
|
39
45
|
|
40
46
|
### Saving values
|
41
|
-
|
42
|
-
|
43
|
-
|
47
|
+
```ruby
|
48
|
+
u = User.first
|
49
|
+
u.gender = 'female'
|
50
|
+
u.save
|
44
51
|
|
45
|
-
|
46
|
-
|
52
|
+
u.store(:custom).gender = 'unknown'
|
53
|
+
u.store(:custom).save
|
54
|
+
```
|
47
55
|
|
48
56
|
When you save the parent object (user), all the store collections will
|
49
57
|
automatically be saved.
|
@@ -53,32 +61,42 @@ automatically be saved.
|
|
53
61
|
## Add tasks to the queue
|
54
62
|
You can add tasks to the queue by executing:
|
55
63
|
|
56
|
-
|
64
|
+
```ruby
|
65
|
+
QueuedTask.queue('SomeClass', id: 37, foo: bar)
|
66
|
+
```
|
57
67
|
|
58
68
|
The first paramter specifiecs the string of the class you want to execute the run method from. The second parameter is a hash that contains most scalar values.
|
59
69
|
|
60
70
|
## Example of a task
|
61
71
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
```ruby
|
73
|
+
class SomeClass
|
74
|
+
def initialize(data)
|
75
|
+
@id = data[:id]
|
76
|
+
@foo = data[:foo]
|
77
|
+
end
|
67
78
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
79
|
+
def run!
|
80
|
+
# add code to run
|
81
|
+
end
|
82
|
+
end
|
83
|
+
```
|
72
84
|
|
73
85
|
## Rake task to run as a cronjob
|
74
|
-
|
86
|
+
```ruby
|
87
|
+
rake udongo:queue:process
|
88
|
+
```
|
75
89
|
|
76
90
|
# Validators
|
77
91
|
## E-mail validator
|
78
|
-
|
92
|
+
```ruby
|
93
|
+
validates :email, email: true
|
94
|
+
```
|
79
95
|
|
80
96
|
## URL validator
|
81
|
-
|
97
|
+
```ruby
|
98
|
+
validates :url, url: true
|
99
|
+
```
|
82
100
|
|
83
101
|
|
84
102
|
# Cryptography
|
@@ -96,16 +114,20 @@ end
|
|
96
114
|
|
97
115
|
## Syntax
|
98
116
|
### encrypt
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
117
|
+
```ruby
|
118
|
+
crypt.encrypt('foo')
|
119
|
+
=> "azZiS1lPVU8zV1ljOTdjM2tIM2hTdz09LS1PODc5OEprRmxlMFVMU1lqaDdXK25RPT0=--77983f6f21e31117ac15011fed52dac3fdf776a8"
|
120
|
+
crypt.encrypt('foo')
|
121
|
+
=> "bEFwVHVDV1hVc29UUmhJK1RQcllYUT09LS03WkZVYTdkOVhIQnloa1czUkE3L1V3PT0=--3fcc73bd6c11874966bb23811ad48980a44e40e7"
|
122
|
+
```
|
103
123
|
|
104
124
|
### decrypt
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
125
|
+
```ruby
|
126
|
+
crypt.decrypt('azZiS1lPVU8zV1ljOTdjM2tIM2hTdz09LS1PODc5OEprRmxlMFVMU1lqaDdXK25RPT0=--77983f6f21e31117ac15011fed52dac3fdf776a8')
|
127
|
+
=> "foo"
|
128
|
+
crypt.decrypt('bEFwVHVDV1hVc29UUmhJK1RQcllYUT09LS03WkZVYTdkOVhIQnloa1czUkE3L1V3PT0=--3fcc73bd6c11874966bb23811ad48980a44e40e7')
|
129
|
+
=> "foo"
|
130
|
+
```
|
109
131
|
|
110
132
|
As the examples above illustrate, each subsequent encrypt always returns a different, decryptable hash.
|
111
133
|
|
@@ -129,10 +151,12 @@ def Udongo::Cryptography
|
|
129
151
|
end
|
130
152
|
```
|
131
153
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
154
|
+
```ruby
|
155
|
+
crypt = Udongo::Crypt.new(secret: '1234567890123456789012345678901234567890')
|
156
|
+
=> #<Udongo::Crypt:0x007fcb1a0f3b50 @options={:secret=>"1234567890123456789012345678901234567890"}>
|
157
|
+
crypt.encrypt('foo')
|
158
|
+
=> "YXhsZDV4RlZLTnljclhvM3pKbmV3Zz09LS1ycVR4bEtZemh2UUVKVlBQRnhlcjZRPT0=--f23e37ef7fb94e94cfa8a509f93bdb94e4bc5552"
|
159
|
+
```
|
136
160
|
|
137
161
|
# Datepickers
|
138
162
|
There are two custom inputs in Udongo to help handles dates. ```DatePickerInput``` and ```DateRangePickerInput```. Both make use of the [bootstrap-datepicker](http://bootstrap-datepicker.readthedocs.io/en/stable/) JS plugin. You can set/override its defaults through data-attributes, as explained in the docs.
|
@@ -143,6 +167,7 @@ Applying ```as: :date_picker``` to a simple_form input will bind a datepicker wi
|
|
143
167
|
```erb
|
144
168
|
<%= f.input :date, as: :date_picker %>
|
145
169
|
```
|
170
|
+
|
146
171
|
### DateRangePickerInput
|
147
172
|
You can combine two datepicker input fields into a range picker by applying ```as: :date_range_picker``` to 2 different simple_form input fields.
|
148
173
|
|
@@ -152,3 +177,74 @@ This will link a datepicker to each input with its relevant change listeners bou
|
|
152
177
|
<%= f.input :stop_date, as: :date_range_picker, stop: 'foo' %>
|
153
178
|
```
|
154
179
|
The value used in the ```start``` and ```stop``` attributes needs to be the same for two datepicker fields to be combined into a range picker. **If these values don't match, your pickers won't display the intended behaviour.**
|
180
|
+
|
181
|
+
# Notifications
|
182
|
+
The ```Udongo::Notification``` class provides a generic way to parse action notices without directly interacting with ```I18n```. Its ```translate``` method can be used in a number of ways:
|
183
|
+
|
184
|
+
## Without parameters
|
185
|
+
```yaml
|
186
|
+
nl:
|
187
|
+
b:
|
188
|
+
msg:
|
189
|
+
refreshed: De pagina werd opnieuw ingeladen.
|
190
|
+
```
|
191
|
+
|
192
|
+
```
|
193
|
+
irb(main):001:0> Udongo::Notification.new(:refreshed).translate
|
194
|
+
=> "De pagina werd opnieuw ingeladen."
|
195
|
+
```
|
196
|
+
|
197
|
+
## A string as parameter
|
198
|
+
```yaml
|
199
|
+
nl:
|
200
|
+
b:
|
201
|
+
admin: Beheerder
|
202
|
+
msg:
|
203
|
+
added: '%{actor} werd toegevoegd.'
|
204
|
+
```
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
irb(main):001:0> Udongo::Notification.new(:added).translate(:admin)
|
208
|
+
=> "Beheerder werd toegevoegd."
|
209
|
+
```
|
210
|
+
|
211
|
+
## Parameter hash
|
212
|
+
```yaml
|
213
|
+
nl:
|
214
|
+
b:
|
215
|
+
msg:
|
216
|
+
added: '%{name} werd toegevoegd met %{pies} taarten.'
|
217
|
+
```
|
218
|
+
```ruby
|
219
|
+
irb(main):001:0> Udongo::Notification.new(:added).translate(name: 'Dave', pies: 10)
|
220
|
+
=> "Dave werd toegevoegd met 10 taarten."
|
221
|
+
```
|
222
|
+
|
223
|
+
## Notifications in controllers
|
224
|
+
```BackendController#translate_notice``` uses ```Udongo::Notification``` to output translated notices. Typically this is used in tandem with redirects. For example in the admins module:
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
class Backend::AdminsController < BackendController
|
228
|
+
def create
|
229
|
+
redirect_to backend_admins_path, notice: translate_notice(:added, :admin)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
```
|
233
|
+
|
234
|
+
## Configurable form submissions datagrids
|
235
|
+
There are two things you can configure in ```config/initializers/udongo.rb``` to affect the form submission datagrids in the CMS:
|
236
|
+
* The visible columns in the datagrid
|
237
|
+
* Which fields the filter should have
|
238
|
+
|
239
|
+
```ruby
|
240
|
+
Udongo.configure do |config|
|
241
|
+
config.form_submissions = {
|
242
|
+
contest: {
|
243
|
+
filter: %w(email last_name),
|
244
|
+
datagrid_fields: %w(last_name first_name telephone)
|
245
|
+
}
|
246
|
+
}
|
247
|
+
end
|
248
|
+
```
|
249
|
+
|
250
|
+
Note that the ```contest``` in the config above maps to a ```Form#identifier```. This way you can have different configurations per submissions page.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: udongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davy Hellemans
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -458,6 +458,7 @@ files:
|
|
458
458
|
- app/assets/javascripts/backend/application.js
|
459
459
|
- app/assets/javascripts/backend/bootstrap.js
|
460
460
|
- app/assets/javascripts/backend/datepickers.js
|
461
|
+
- app/assets/javascripts/backend/flexible_content.js
|
461
462
|
- app/assets/javascripts/backend/general.js
|
462
463
|
- app/assets/javascripts/backend/pages.js
|
463
464
|
- app/assets/javascripts/backend/plugins/autocomplete.js
|
@@ -485,6 +486,9 @@ files:
|
|
485
486
|
- app/controllers/backend/dashboard_controller.rb
|
486
487
|
- app/controllers/backend/email_templates_controller.rb
|
487
488
|
- app/controllers/backend/emails_controller.rb
|
489
|
+
- app/controllers/backend/forms/base_controller.rb
|
490
|
+
- app/controllers/backend/forms/submissions_controller.rb
|
491
|
+
- app/controllers/backend/forms_controller.rb
|
488
492
|
- app/controllers/backend/navigation/items_controller.rb
|
489
493
|
- app/controllers/backend/navigations_controller.rb
|
490
494
|
- app/controllers/backend/pages_controller.rb
|
@@ -501,10 +505,15 @@ files:
|
|
501
505
|
- app/controllers/concerns/backend/translatable_controller.rb
|
502
506
|
- app/controllers/concerns/pagination_controller.rb
|
503
507
|
- app/controllers/redirects_controller.rb
|
508
|
+
- app/decorators/application_decorator.rb
|
504
509
|
- app/decorators/content_image_decorator.rb
|
510
|
+
- app/decorators/content_row_decorator.rb
|
505
511
|
- app/decorators/content_text_decorator.rb
|
512
|
+
- app/decorators/form_decorator.rb
|
513
|
+
- app/decorators/form_submission_decorator.rb
|
506
514
|
- app/decorators/navigation_item_decorator.rb
|
507
515
|
- app/decorators/page_decorator.rb
|
516
|
+
- app/decorators/pagination_decorator.rb
|
508
517
|
- app/decorators/redirect_decorator.rb
|
509
518
|
- app/decorators/snippet_decorator.rb
|
510
519
|
- app/forms/backend/email_template_translation_form.rb
|
@@ -571,6 +580,7 @@ files:
|
|
571
580
|
- app/models/setting.rb
|
572
581
|
- app/models/snippet.rb
|
573
582
|
- app/models/store.rb
|
583
|
+
- app/models/store_with_file.rb
|
574
584
|
- app/models/tag.rb
|
575
585
|
- app/models/tagged_item.rb
|
576
586
|
- app/uploaders/ckeditor_attachment_file_uploader.rb
|
@@ -605,6 +615,9 @@ files:
|
|
605
615
|
- app/views/backend/email_templates/new.html.erb
|
606
616
|
- app/views/backend/emails/index.html.erb
|
607
617
|
- app/views/backend/emails/show.html.erb
|
618
|
+
- app/views/backend/forms/index.html.erb
|
619
|
+
- app/views/backend/forms/submissions/_filter.html.erb
|
620
|
+
- app/views/backend/forms/submissions/index.html.erb
|
608
621
|
- app/views/backend/navigation/items/_form.html.erb
|
609
622
|
- app/views/backend/navigation/items/_tabs.html.erb
|
610
623
|
- app/views/backend/navigation/items/edit.html.erb
|
@@ -709,6 +722,7 @@ files:
|
|
709
722
|
- db/migrate/20160601111729_add_collection_to_store.rb
|
710
723
|
- db/migrate/20160601115312_remove_klass_from_stores.rb
|
711
724
|
- db/migrate/20160601200049_remove_translation_model.rb
|
725
|
+
- db/migrate/20160711114156_add_description_to_forms.rb
|
712
726
|
- lib/generators/udongo/form/form_generator.rb
|
713
727
|
- lib/generators/udongo/form/templates/form.rb
|
714
728
|
- lib/tasks/task_extras.rb
|
@@ -719,15 +733,23 @@ files:
|
|
719
733
|
- lib/udongo/assets/precompiler.rb
|
720
734
|
- lib/udongo/breadcrumb.rb
|
721
735
|
- lib/udongo/config.rb
|
736
|
+
- lib/udongo/configs/forms.rb
|
722
737
|
- lib/udongo/crypt.rb
|
723
738
|
- lib/udongo/cryptography.rb
|
724
739
|
- lib/udongo/email_vars/address.rb
|
725
740
|
- lib/udongo/email_vars/form_submission.rb
|
726
741
|
- lib/udongo/email_vars_parser.rb
|
727
742
|
- lib/udongo/engine.rb
|
743
|
+
- lib/udongo/flexible_content/column_width_calculator.rb
|
744
|
+
- lib/udongo/form.rb
|
745
|
+
- lib/udongo/forms/config.rb
|
746
|
+
- lib/udongo/forms/submission_datagrid.rb
|
747
|
+
- lib/udongo/forms/submission_filter.rb
|
728
748
|
- lib/udongo/meta_info.rb
|
749
|
+
- lib/udongo/notification.rb
|
729
750
|
- lib/udongo/object_path.rb
|
730
751
|
- lib/udongo/version.rb
|
752
|
+
- lib/udongo/will_paginate/options.rb
|
731
753
|
- lib/udongo/will_paginate/renderer.rb
|
732
754
|
- readme.md
|
733
755
|
- vendor/assets/images/jstree/default/32px.png
|