binda 0.1.1 → 0.1.2

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/app/assets/javascripts/binda/components/{form_item_choice.js → field_setting_choices.js} +13 -12
  4. data/app/assets/javascripts/binda/components/form_item_repeater.js +34 -30
  5. data/app/assets/javascripts/binda/components/login_form.js +15 -15
  6. data/app/assets/javascripts/binda/components/sortable.js +22 -20
  7. data/app/assets/javascripts/binda/dist/binda.bundle.js +154 -140
  8. data/app/assets/javascripts/binda/index.js +20 -20
  9. data/app/assets/stylesheets/binda/components/field_setting_choices.scss +90 -0
  10. data/app/assets/stylesheets/binda/components/form_item.scss +0 -50
  11. data/app/assets/stylesheets/binda/components/{form_item_choice.scss → form_item_choices.scss} +1 -7
  12. data/app/assets/stylesheets/binda/components/main_sortable_table.scss +68 -0
  13. data/app/assets/stylesheets/binda/components/main_table.scss +2 -5
  14. data/app/assets/stylesheets/binda/components/sortable.scss +1 -2
  15. data/app/assets/stylesheets/binda/components/standard-form.scss +5 -6
  16. data/app/assets/stylesheets/binda/index.scss +3 -1
  17. data/app/controllers/binda/field_groups_controller.rb +22 -75
  18. data/app/controllers/binda/manage/users_controller.rb +18 -13
  19. data/app/controllers/binda/structures_controller.rb +12 -11
  20. data/app/models/binda/choice.rb +10 -5
  21. data/app/models/binda/field_setting.rb +16 -6
  22. data/app/models/concerns/binda/fieldable_associations.rb +24 -12
  23. data/app/views/binda/components/sort_index.html.erb +21 -25
  24. data/app/views/binda/field_groups/_form_body.html.erb +5 -5
  25. data/app/views/binda/field_groups/_form_item_choice.erb +49 -66
  26. data/app/views/binda/structures/_form_section.html.erb +1 -1
  27. data/app/views/binda/structures/index.html.erb +2 -2
  28. data/app/views/binda/structures/sort_index.html.erb +28 -21
  29. data/config/locales/en.yml +7 -5
  30. data/lib/binda/version.rb +1 -1
  31. metadata +6 -4
@@ -1,26 +1,46 @@
1
1
  <%# - - - - - - - - - - - - %>
2
2
  <%# CHOICES %>
3
3
  <%# - - - - - - - - - - - - %>
4
- <div class="standard-form--header field-settings-header">
5
- <p><%= t(:choices).capitalize %></p>
4
+ <div class="field-setting-choices--header field-settings-header">
5
+ <a href="#" class="field-setting-choices--toggle-choice field-setting-choices--add-choice" data-choices-id="field-setting-choices-<%= ff.object.id %>">
6
+ <i class="fa fa-plus" aria-hidden="true"></i> <%= t(:add_choice).capitalize %>
7
+ </a>
8
+ <p class="control-label"><%= t(:choices).capitalize %></p>
6
9
  </div>
7
10
 
8
- <div class="form-item--choices">
11
+ <div id="field-setting-choices-<%= ff.object.id %>" class="field-setting-choices">
12
+
13
+ <%# - - - - - - - - - - - - %>
14
+ <%# NEW CHOICE %>
15
+ <%# - - - - - - - - - - - - %>
16
+ <%= f.simple_fields_for "new_choices[]", ff.object.choices.build(), defaults: {label: false} do |fff| %>
17
+ <div class="field-setting-choices--choice field-setting-choices--new-choice">
18
+ <%= fff.association :field_setting, as: :hidden %>
19
+ <div class="field-setting-choices--choice-label">
20
+ <%= fff.input :label, placeholder: t('binda.choice_label') %>
21
+ </div>
22
+ <div class="field-setting-choices--choice-value">
23
+ <%= fff.input :value, placeholder: t('binda.choice_value') %>
24
+ </div>
25
+ <a href="#" class="field-setting-choices--toggle-choice field-setting-choices--js-delete-choice">
26
+ <i class="far fa-trash-alt"></i>
27
+ </a>
28
+ <div class="clearfix"></div>
29
+ </div>
30
+ <% end %>
9
31
 
10
- <%= ff.simple_fields_for :choices, ff.object.choices.order( :label ) do |fff| %>
11
- <div id="form-item--choice-<%= fff.object.id %>" class="form-item--choice">
32
+ <%= ff.simple_fields_for :choices, ff.object.choices.order( :label ), defaults: {label: false} do |fff| %>
33
+ <div id="field-setting-choices--choice-<%= fff.object.id %>" class="field-setting-choices--choice">
12
34
  <%= fff.input :id, as: :hidden %>
13
35
  <%= fff.association :field_setting, as: :hidden %>
14
- <div class="form-item--choice-label">
15
-
16
- <%= fff.input :label %>
36
+ <div class="field-setting-choices--choice-label">
37
+ <%= fff.input :label, placeholder: t('binda.choice_label') %>
17
38
  </div>
18
- <div class="form-item--choice-value">
19
-
20
- <%= fff.input :value %>
39
+ <div class="field-setting-choices--choice-value">
40
+ <%= fff.input :value, placeholder: t('binda.choice_value') %>
21
41
  </div>
22
- <a href="<%= choice_path( fff.object ) %>" class="form-item--delete-choice">
23
- <span><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></span>
42
+ <a href="<%= choice_path( fff.object ) %>" class="field-setting-choices--delete-choice">
43
+ <i class="far fa-trash-alt"></i>
24
44
  </a>
25
45
  <div class="clearfix"></div>
26
46
  </div>
@@ -30,50 +50,23 @@
30
50
  <%# DEFAULT INITIAL CHOICE %>
31
51
  <%# - - - - - - - - - - - - %>
32
52
  <% unless ff.object.choices.find_all{|c| c.persisted? }.any? %>
33
- <%= f.simple_fields_for "new_choices[]", ff.object.choices.build() do |fff| %>
34
- <div class="form-item--choice">
53
+ <%= f.simple_fields_for "new_choices[]", ff.object.choices.build(), defaults: {label: false} do |fff| %>
54
+ <div class="field-setting-choices--choice">
35
55
  <%= fff.association :field_setting, as: :hidden %>
36
- <div class="form-item--choice-label">
37
-
38
- <%= fff.input :label %>
56
+ <div class="field-setting-choices--choice-label">
57
+ <%= fff.input :label, placeholder: t('binda.choice_label') %>
39
58
  </div>
40
- <div class="form-item--choice-value">
41
-
42
- <%= fff.input :value %>
59
+ <div class="field-setting-choices--choice-value">
60
+ <%= fff.input :value, placeholder: t('binda.choice_value') %>
43
61
  </div>
44
- <a href="#" class="form-item--toggle-choice form-item--js-delete-choice">
45
- <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
62
+ <a href="#" class="field-setting-choices--toggle-choice field-setting-choices--js-delete-choice">
63
+ <i class="far fa-trash-alt"></i>
46
64
  </a>
47
65
  <div class="clearfix"></div>
48
66
  </div>
49
67
  <% end %>
50
68
  <% end %>
51
69
 
52
- <%# - - - - - - - - - - - - %>
53
- <%# NEW CHOICE %>
54
- <%# - - - - - - - - - - - - %>
55
- <%= f.simple_fields_for "new_choices[]", ff.object.choices.build() do |fff| %>
56
- <div class="form-item--choice form-item--new-choice">
57
- <%= fff.association :field_setting, as: :hidden %>
58
- <div class="form-item--choice-label">
59
-
60
- <%= fff.input :label %>
61
- </div>
62
- <div class="form-item--choice-value">
63
-
64
- <%= fff.input :value %>
65
- </div>
66
- <a href="#" class="form-item--toggle-choice form-item--js-delete-choice">
67
- <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
68
- </a>
69
- <div class="clearfix"></div>
70
- </div>
71
- <% end %>
72
-
73
- <a href="#" class="form-item--toggle-choice form-item--add-choice">
74
- <%= t(:add_choice).capitalize %>&nbsp;&nbsp;<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
75
- </a>
76
-
77
70
  </div>
78
71
 
79
72
  <div class="clearfix"></div>
@@ -84,18 +77,13 @@
84
77
  <%# - - - - - - - - - - - - %>
85
78
  <% if ff.object.choices.find_all{|c| c.persisted? }.any? %>
86
79
  <div class="form-item--full-size">
87
-
88
- <div class="standard-form--header field-settings-header">
89
- <p><%= t(:default_choice).capitalize %></p>
90
- </div>
91
-
92
80
  <%= ff.input :default_choice_id,
93
81
  as: :select, collection: ff.object.choices.find_all{|c| c.persisted? },
94
82
  label_method: :label,
95
83
  include_blank: false,
96
84
  selected: ff.object.default_choice_id,
97
- hint: t(:default_choice_description).capitalize,
98
- class: 'select2-item' %>
85
+ hint: t(:default_choice_description),
86
+ input_html: {class: 'select2-item'} %>
99
87
  </div>
100
88
  <% end %>
101
89
 
@@ -104,18 +92,13 @@
104
92
  <%# - - - - - - - - - - - - %>
105
93
  <%# ALLOW NULL %>
106
94
  <%# - - - - - - - - - - - - %>
107
- <div class="form-item--full-size form-group allow-null">
108
- <div class="control-label">
109
- <p><%= t(:allow_null).capitalize %></p>
110
- </div>
111
-
95
+ <div class="form-item--full-size standard-form--checkbox field-setting-choices--allow-null">
112
96
  <%= ff.input :allow_null,
113
- as: :boolean,
114
- boolean_style: :inline,
115
- input_html: { class: "form-item--input" },
116
- checked_value: true,
117
- unchecked_value: false,
118
- selected: ff.object.allow_null,
97
+ as: :radio_buttons,
98
+ label: t('binda.allow_null'),
99
+ collection: [[t('binda.allow_null_true'), true], [t('binda.allow_null_false'), false]],
100
+ label_method: -> (x){ "<span class=\"standard-form--input-box\"></span>#{x[0]}".html_safe },
101
+ checked: ff.object.allow_null,
119
102
  default: false %>
120
103
  </div>
121
104
  <% end %>
@@ -37,7 +37,7 @@
37
37
  data: { confirm: t('binda.confirm_delete') },
38
38
  class: 'form-item--delete-repeater-item' %>
39
39
 
40
- <p><%= ff.object.name %> (<%= ff.object.name.humanize.capitalize %>)</p>
40
+ <p><%= ff.object.name %></p>
41
41
  <% end %>
42
42
  </div>
43
43
 
@@ -3,7 +3,7 @@
3
3
  <%= link_to "<i class=\"fa fa-plus\" aria-hidden=\"true\"></i> New Structure".html_safe, new_structure_path, class: 'main-header--link b-btn b-btn-primary' %>
4
4
  <%= get_structures_sort_index_link %>
5
5
  </div>
6
- <p>Structures</p>
6
+ <p class="main-header--title">Structures</p>
7
7
  <% end %>
8
8
 
9
9
  <% content_for :content do %>
@@ -12,7 +12,7 @@
12
12
  <table class="standard-form--container">
13
13
  <thead class="standard-form--header">
14
14
  <tr>
15
- <th style="width: 70%">Structures</th>
15
+ <th>Structures</th>
16
16
  <th style="width: 30%"></th>
17
17
  </tr>
18
18
  </thead>
@@ -2,35 +2,42 @@
2
2
  <div class="main-header--buttons">
3
3
  <%= link_to "<i class=\"fa fa-plus\" aria-hidden=\"true\"></i> New Structure".html_safe, new_structure_path, class: 'main-header--link b-btn b-btn-primary' %>
4
4
  </div>
5
- <p><%= t 'binda.structures' %></p>
5
+ <p class="main-header--title"><%= t 'binda.structures' %></p>
6
6
  <% end %>
7
7
 
8
8
  <% content_for :content do %>
9
- <div class="main-table--container">
9
+ <div class="popup-warning popup-warning--hidden">
10
+ <div class="popup-warning--loader">
11
+ <span></span>
12
+ <span></span>
13
+ <span></span>
14
+ <span></span>
15
+ </div>
16
+ <p><%= t 'binda.sort_items_loader', { arg1: t('binda.structures').downcase } %></p>
17
+ </div>
10
18
 
19
+ <div class="main-table--container">
11
20
  <h5 class="text-muted"><%= t('binda.sort_index_hint', { arg1: t('binda.structures').downcase }).html_safe %></h5>
12
21
 
13
- <table class="standard-form--container table-sort">
14
- <thead class="standard-form--header">
15
- <tr>
16
- <th style="width: 70%">Structures</th>
17
- <th style="width: 30%"></th>
18
- </tr>
19
- </thead>
20
-
21
- <tbody class="sortable" data-update-url="<%= structures_sort_path() %>">
22
+ <div class="main-sortable-table">
23
+ <div class="main-sortable-table--header-row">
24
+ <div class="main-sortable-table--header-title">
25
+ <p>Structures</p>
26
+ </div>
27
+ </div>
28
+ <div id="structures--sort-index" class="sortable" data-update-url="<%= structures_sort_path() %>">
22
29
  <% @structures.order( :name ).each do |structure| %>
23
- <tr id="structure_<%= structure.id %>">
24
- <td><%= structure.name %></td>
25
- <td></td>
26
- </tr>
30
+ <div id="structure_<%= structure.id %>" class="main-sortable-table--row ui-sortable-handle">
31
+ <div class="main-sortable-table--row-cell">
32
+ <p><%= structure.name %></p>
33
+ </div>
34
+ </div>
27
35
  <% end %>
28
- <tbody>
29
- </table>
30
-
31
- <%= paginate @structures %>
32
- <%= link_to "<i class=\"fa fa-plus\" aria-hidden=\"true\"></i> New Structure".html_safe, new_structure_path, class: 'main-header--link b-btn b-btn-primary' %>
33
-
36
+ </div>
37
+ </div>
34
38
  </div>
35
39
 
40
+ <%= paginate @structures %>
41
+ <%= link_to "<i class=\"fa fa-plus\" aria-hidden=\"true\"></i> New Structure".html_safe, new_structure_path, class: 'main-header--link b-btn b-btn-primary' %>
42
+
36
43
  <% end %>
@@ -37,12 +37,9 @@ en:
37
37
  structure_has_categories: Enable categories
38
38
  asset: asset
39
39
  choices: choices
40
- choice_label: label
41
- choice_value: value
42
40
  add_choice: Add choice
43
41
  default_choice: default choice
44
- default_choice_description: if you have added/removed any choice you need to click save to update the list of choices
45
- allow_null: allow null?
42
+ default_choice_description: If you have added/removed any choice, this list might not be correct. Please save to update it.
46
43
  instance: instance
47
44
  structure_instance_type: 'This structure is for:'
48
45
 
@@ -103,4 +100,9 @@ en:
103
100
  login_email: Enter your email
104
101
  login_password: Enter your password
105
102
  login_welcome: Welcome to %{arg1} admin panel
106
- login_credit: Built with Binda %{arg1}
103
+ login_credit: Built with Binda %{arg1}
104
+ choice_label: label
105
+ choice_value: value
106
+ allow_null: Choice method
107
+ allow_null_true: Allow to not choose any of the choices
108
+ allow_null_false: Force to make a choice among the available choices
data/lib/binda/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Binda
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Barbieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-03 00:00:00.000000000 Z
11
+ date: 2018-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -575,9 +575,9 @@ files:
575
575
  - app/assets/javascripts/binda/application.js
576
576
  - app/assets/javascripts/binda/components/bootstrap.js
577
577
  - app/assets/javascripts/binda/components/field_group_editor.js
578
+ - app/assets/javascripts/binda/components/field_setting_choices.js
578
579
  - app/assets/javascripts/binda/components/fileupload.js
579
580
  - app/assets/javascripts/binda/components/form_item.js
580
- - app/assets/javascripts/binda/components/form_item_choice.js
581
581
  - app/assets/javascripts/binda/components/form_item_editor.js
582
582
  - app/assets/javascripts/binda/components/form_item_image.js
583
583
  - app/assets/javascripts/binda/components/form_item_repeater.js
@@ -593,9 +593,10 @@ files:
593
593
  - app/assets/stylesheets/binda/components/b-alert.scss
594
594
  - app/assets/stylesheets/binda/components/b-btn.scss
595
595
  - app/assets/stylesheets/binda/components/button.scss
596
+ - app/assets/stylesheets/binda/components/field_setting_choices.scss
596
597
  - app/assets/stylesheets/binda/components/fileupload.scss
597
598
  - app/assets/stylesheets/binda/components/form_item.scss
598
- - app/assets/stylesheets/binda/components/form_item_choice.scss
599
+ - app/assets/stylesheets/binda/components/form_item_choices.scss
599
600
  - app/assets/stylesheets/binda/components/form_item_image.scss
600
601
  - app/assets/stylesheets/binda/components/form_item_video.scss
601
602
  - app/assets/stylesheets/binda/components/login.scss
@@ -603,6 +604,7 @@ files:
603
604
  - app/assets/stylesheets/binda/components/main_content.scss
604
605
  - app/assets/stylesheets/binda/components/main_header.scss
605
606
  - app/assets/stylesheets/binda/components/main_sidebar.scss
607
+ - app/assets/stylesheets/binda/components/main_sortable_table.scss
606
608
  - app/assets/stylesheets/binda/components/main_table.scss
607
609
  - app/assets/stylesheets/binda/components/popup_warning.scss
608
610
  - app/assets/stylesheets/binda/components/select2.scss