headmin 0.3.4 → 0.4.0

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 (157) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +27 -0
  3. data/.gitignore +14 -0
  4. data/.nvmrc +1 -0
  5. data/CHANGELOG.md +24 -0
  6. data/Gemfile +7 -4
  7. data/Gemfile.lock +171 -3
  8. data/README.md +7 -0
  9. data/Rakefile +1 -7
  10. data/app/assets/javascripts/headmin/config/i18n.js +9 -9
  11. data/app/assets/javascripts/headmin/controllers/autocomplete_controller.js +255 -0
  12. data/app/assets/javascripts/headmin/controllers/blocks_controller.js +74 -79
  13. data/app/assets/javascripts/headmin/controllers/date_range_controller.js +24 -24
  14. data/app/assets/javascripts/headmin/controllers/dropzone_controller.js +23 -25
  15. data/app/assets/javascripts/headmin/controllers/file_preview_controller.js +237 -237
  16. data/app/assets/javascripts/headmin/controllers/filter_controller.js +44 -44
  17. data/app/assets/javascripts/headmin/controllers/filters_controller.js +57 -61
  18. data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +29 -29
  19. data/app/assets/javascripts/headmin/controllers/hello_controller.js +3 -3
  20. data/app/assets/javascripts/headmin/controllers/notification_controller.js +7 -6
  21. data/app/assets/javascripts/headmin/controllers/popup_controller.js +51 -52
  22. data/app/assets/javascripts/headmin/controllers/redactorx_controller.js +36 -9
  23. data/app/assets/javascripts/headmin/controllers/repeater_controller.js +122 -125
  24. data/app/assets/javascripts/headmin/controllers/select_controller.js +40 -39
  25. data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +100 -101
  26. data/app/assets/javascripts/headmin/controllers/table_controller.js +115 -115
  27. data/app/assets/javascripts/headmin/index.js +38 -35
  28. data/app/assets/javascripts/headmin.js +243 -34
  29. data/app/assets/stylesheets/headmin/forms/autocomplete.scss +21 -0
  30. data/app/assets/stylesheets/headmin/forms/file.scss +46 -0
  31. data/app/assets/stylesheets/headmin/forms/repeater.scss +62 -0
  32. data/app/assets/stylesheets/headmin/forms/search.scss +12 -0
  33. data/app/assets/stylesheets/headmin/forms.scss +11 -0
  34. data/app/assets/stylesheets/headmin/general.scss +5 -0
  35. data/app/assets/stylesheets/headmin/overrides/bootstrap.scss +5 -3
  36. data/app/assets/stylesheets/headmin/overrides/redactorx.scss +74 -0
  37. data/app/assets/stylesheets/headmin/popup.scss +1 -0
  38. data/app/assets/stylesheets/headmin/syntax.scss +36 -349
  39. data/app/assets/stylesheets/headmin/table.scss +1 -1
  40. data/app/assets/stylesheets/headmin/utilities/buttons.scss +19 -0
  41. data/app/assets/stylesheets/headmin/utilities/dropzone.scss +72 -0
  42. data/app/assets/stylesheets/headmin/utilities.scss +2 -68
  43. data/app/assets/stylesheets/headmin.css +205 -205
  44. data/app/assets/stylesheets/headmin.scss +1 -1
  45. data/app/helpers/headmin/admin_helper.rb +0 -1
  46. data/app/helpers/headmin/form_helper.rb +2 -8
  47. data/app/models/concerns/headmin/blockable.rb +1 -1
  48. data/app/models/concerns/headmin/field.rb +1 -0
  49. data/app/models/concerns/headmin/form/autocompletable.rb +38 -0
  50. data/app/models/concerns/headmin/form/hintable.rb +19 -0
  51. data/app/models/concerns/headmin/form/input_groupable.rb +23 -0
  52. data/app/models/concerns/headmin/form/labelable.rb +33 -0
  53. data/app/models/concerns/headmin/form/listable.rb +28 -0
  54. data/app/models/concerns/headmin/form/placeholderable.rb +13 -0
  55. data/app/models/concerns/headmin/form/validatable.rb +40 -0
  56. data/app/models/concerns/headmin/form/wrappable.rb +21 -0
  57. data/app/models/headmin/.DS_Store +0 -0
  58. data/app/models/headmin/blocks_view.rb +15 -0
  59. data/app/models/headmin/form/blocks_view.rb +29 -0
  60. data/app/models/headmin/form/checkbox_view.rb +52 -0
  61. data/app/models/headmin/form/date_range_view.rb +25 -0
  62. data/app/models/headmin/form/date_view.rb +45 -0
  63. data/app/models/headmin/form/email_view.rb +48 -0
  64. data/app/models/headmin/form/file_view.rb +116 -0
  65. data/app/models/headmin/form/flatpickr_range_view.rb +102 -0
  66. data/app/models/headmin/form/flatpickr_view.rb +37 -0
  67. data/app/models/headmin/form/hidden_view.rb +10 -0
  68. data/app/models/headmin/form/hint_view.rb +6 -0
  69. data/app/models/headmin/form/input_group_view.rb +19 -0
  70. data/app/models/headmin/form/label_view.rb +24 -0
  71. data/app/models/headmin/form/number_view.rb +49 -0
  72. data/app/models/headmin/form/password_view.rb +44 -0
  73. data/app/models/headmin/form/redactorx_view.rb +59 -0
  74. data/app/models/headmin/form/search_view.rb +48 -0
  75. data/app/models/headmin/form/select_view.rb +62 -0
  76. data/app/models/headmin/form/switch_view.rb +23 -0
  77. data/app/models/headmin/form/text_view.rb +48 -0
  78. data/app/models/headmin/form/textarea_view.rb +44 -0
  79. data/app/models/headmin/form/url_view.rb +48 -0
  80. data/app/models/headmin/form/wrapper_view.rb +19 -0
  81. data/app/models/headmin/form/wysiwyg_view.rb +17 -0
  82. data/app/models/headmin/{thumbnail.rb → thumbnail_view.rb} +6 -1
  83. data/app/models/view_model.rb +58 -0
  84. data/app/views/headmin/_blocks.html.erb +13 -9
  85. data/app/views/headmin/_heading.html.erb +7 -1
  86. data/app/views/headmin/_thumbnail.html.erb +1 -37
  87. data/app/views/headmin/forms/_autocomplete.html.erb +11 -0
  88. data/app/views/headmin/forms/_blocks.html.erb +16 -17
  89. data/app/views/headmin/forms/_checkbox.html.erb +24 -29
  90. data/app/views/headmin/forms/_datalist.html.erb +3 -0
  91. data/app/views/headmin/forms/_date.html.erb +24 -24
  92. data/app/views/headmin/forms/_date_range.html.erb +19 -21
  93. data/app/views/headmin/forms/_email.html.erb +27 -32
  94. data/app/views/headmin/forms/_errors.html.erb +2 -3
  95. data/app/views/headmin/forms/_file.html.erb +84 -181
  96. data/app/views/headmin/forms/_flatpickr.html.erb +19 -20
  97. data/app/views/headmin/forms/_flatpickr_range.html.erb +28 -37
  98. data/app/views/headmin/forms/_hidden.html.erb +9 -10
  99. data/app/views/headmin/forms/_hint.html.erb +16 -0
  100. data/app/views/headmin/forms/_input_group.html.erb +21 -0
  101. data/app/views/headmin/forms/_label.html.erb +5 -13
  102. data/app/views/headmin/forms/_number.html.erb +23 -35
  103. data/app/views/headmin/forms/_password.html.erb +21 -30
  104. data/app/views/headmin/forms/_redactorx.html.erb +21 -40
  105. data/app/views/headmin/forms/_repeater.html.erb +55 -60
  106. data/app/views/headmin/forms/_search.html.erb +43 -0
  107. data/app/views/headmin/forms/_select.html.erb +24 -49
  108. data/app/views/headmin/forms/_switch.html.erb +29 -0
  109. data/app/views/headmin/forms/_text.html.erb +42 -96
  110. data/app/views/headmin/forms/_textarea.html.erb +21 -32
  111. data/app/views/headmin/forms/_url.html.erb +26 -31
  112. data/app/views/headmin/forms/_validation.html.erb +10 -13
  113. data/app/views/headmin/forms/_wrapper.html.erb +9 -0
  114. data/app/views/headmin/forms/_wysiwyg.html.erb +28 -0
  115. data/app/views/headmin/forms/autocomplete/_item.html.erb +3 -0
  116. data/app/views/headmin/forms/autocomplete/_list.html.erb +3 -0
  117. data/app/views/headmin/forms/fields/_group.html.erb +5 -3
  118. data/app/views/headmin/forms/repeater/_row.html.erb +4 -4
  119. data/bin/console +0 -1
  120. data/config/locales/headmin/forms/en.yml +0 -11
  121. data/config/locales/headmin/forms/nl.yml +0 -11
  122. data/esbuild-css.js +18 -18
  123. data/esbuild-js.js +8 -8
  124. data/headmin.gemspec +1 -3
  125. data/lib/generators/templates/controllers/auth/confirmations_controller.rb +0 -2
  126. data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +0 -2
  127. data/lib/generators/templates/controllers/auth/passwords_controller.rb +0 -2
  128. data/lib/generators/templates/controllers/auth/registrations_controller.rb +0 -2
  129. data/lib/generators/templates/controllers/auth/sessions_controller.rb +0 -2
  130. data/lib/generators/templates/controllers/auth/unlocks_controller.rb +0 -2
  131. data/lib/headmin/version.rb +1 -3
  132. data/lib/headmin.rb +0 -2
  133. data/package-lock.json +5359 -0
  134. data/package.json +12 -4
  135. data/view_model_benchmark.rb +74 -0
  136. data/yarn-error.log +17 -12
  137. data/yarn.lock +1575 -31
  138. metadata +62 -24
  139. data/app/assets/stylesheets/headmin/form.scss +0 -132
  140. data/app/assets/stylesheets/headmin/overrides/redactorx.css +0 -3
  141. data/app/helpers/headmin/documentation_helper.rb +0 -35
  142. data/app/models/headmin/documentation_renderer.rb +0 -32
  143. data/app/models/headmin/form/base.rb +0 -78
  144. data/app/models/headmin/form/text.rb +0 -51
  145. data/app/services/block_service.rb +0 -72
  146. data/app/views/headmin/_card.html.erb +0 -52
  147. data/app/views/headmin/forms/_actions.html.erb +0 -28
  148. data/app/views/headmin/forms/_base.html.erb +0 -114
  149. data/app/views/headmin/forms/_image.html.erb +0 -21
  150. data/app/views/headmin/forms/_video.html.erb +0 -21
  151. data/app/views/headmin/forms/actions/_destroy.html.erb +0 -13
  152. data/app/views/headmin/forms/actions/_save.html.erb +0 -12
  153. data/app/views/headmin/forms/actions/_view.html.erb +0 -15
  154. data/docs/blocks-and-fields.md +0 -54
  155. data/docs/blocks.md +0 -48
  156. data/docs/devise.md +0 -41
  157. data/docs/fields.md +0 -79
@@ -1,7 +1,7 @@
1
1
  @charset "UTF-8";
2
2
  @import "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css";
3
3
 
4
- /* sass-plugin-0:/usr/local/var/www/headmin/src/scss/headmin.scss */
4
+ /* sass-plugin-0:/opt/homebrew/var/www/headmin/src/scss/headmin.scss */
5
5
  :root {
6
6
  --bs-blue: #0d6efd;
7
7
  --bs-indigo: #6610f2;
@@ -260,7 +260,7 @@ small,
260
260
  mark,
261
261
  .mark {
262
262
  padding: 0.2em;
263
- background-color: #fcf8e3;
263
+ background-color: #ffec89;
264
264
  }
265
265
  sub,
266
266
  sup {
@@ -12913,23 +12913,134 @@ span.flatpickr-weekday {
12913
12913
  top: 3px;
12914
12914
  }
12915
12915
  .rx-container {
12916
+ padding: 0 !important;
12917
+ border: 1px solid #ced4da;
12918
+ border-radius: 0.25rem;
12919
+ }
12920
+ .rx-container.rx-in-focus {
12921
+ color: #212529;
12922
+ background-color: #fff;
12923
+ border-color: #86b7fe;
12924
+ outline: 0;
12925
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075), 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
12926
+ }
12927
+ .rx-container.rx-in-focus.is-valid {
12928
+ border-color: #198754;
12929
+ box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
12930
+ }
12931
+ .rx-container.rx-in-focus.is-invalid {
12932
+ border-color: #dc3545;
12933
+ box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
12934
+ }
12935
+ .rx-container.is-valid,
12936
+ .rx-container.is-invalid {
12937
+ background-position: top calc(0.375em + 0.1875rem) right calc(0.375em + 0.1875rem);
12938
+ }
12939
+ .rx-toolbar-container.is-rx-toolbar {
12940
+ background: transparent;
12941
+ border-bottom: 1px solid #ced4da;
12942
+ }
12943
+ .rx-content {
12944
+ padding: 0.375rem 0.75rem !important;
12945
+ position: relative;
12946
+ }
12947
+ .rx-content p {
12948
+ font-size: 0.9rem;
12949
+ line-height: 1.5;
12950
+ color: #212529;
12951
+ }
12952
+ .rx-placeholder:before {
12953
+ font-size: 0.9rem;
12954
+ color: #6c757d;
12955
+ opacity: 1;
12956
+ }
12957
+ .rx-control {
12958
+ margin-left: -0.75rem;
12959
+ }
12960
+ .rx-toolbar .rx-button-icon {
12961
+ background: #fff;
12962
+ }
12963
+ .rx-toolbar .rx-button-icon span {
12964
+ color: #6c757d;
12965
+ }
12966
+ .rx-toolbar .rx-button-icon:hover span {
12967
+ color: #212529;
12968
+ }
12969
+ .form-label[required=required]:after,
12970
+ .form-check-label[required=required]:after {
12971
+ content: " *";
12972
+ color: #dc3545;
12973
+ }
12974
+ .h-autocomplete {
12975
+ position: absolute;
12976
+ top: calc(100% + 2px);
12977
+ left: 0;
12978
+ z-index: 1000;
12916
12979
  width: 100%;
12980
+ font-family: var(--bs-font-sans-serif);
12981
+ font-style: normal;
12982
+ font-weight: 400;
12983
+ line-height: 1.5;
12984
+ text-align: left;
12985
+ text-align: start;
12986
+ text-decoration: none;
12987
+ text-shadow: none;
12988
+ text-transform: none;
12989
+ letter-spacing: normal;
12990
+ word-break: normal;
12991
+ word-spacing: normal;
12992
+ white-space: normal;
12993
+ line-break: auto;
12994
+ font-size: 1rem;
12995
+ word-wrap: break-word;
12996
+ background-color: #fff;
12997
+ background-clip: padding-box;
12998
+ border-radius: 0.25rem !important;
12999
+ box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
13000
+ border: 1px solid rgba(0, 0, 0, 0.15);
13001
+ overflow: hidden;
12917
13002
  }
12918
- input[type=search] {
12919
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E%0A");
12920
- background-repeat: no-repeat;
12921
- background-position: 10px center;
12922
- padding-left: 35px;
13003
+ .h-autocomplete .list-group-flush {
13004
+ margin: 0;
13005
+ padding: 0;
12923
13006
  }
12924
- .form-control[readonly] {
12925
- background-color: transparent;
13007
+ .h-form-file .h-form-file-thumbnails {
13008
+ margin-bottom: 0.5rem;
12926
13009
  }
12927
- .form-label[required=required]:after {
12928
- content: "*";
12929
- margin-left: 1px;
13010
+ .h-form-file.h-dropzone {
13011
+ padding: 0.5rem;
12930
13012
  }
12931
- .forms-group .card-footer {
12932
- border-top: none;
13013
+ .h-form-file.h-dropzone .h-form-file-thumbnails {
13014
+ margin-bottom: 0;
13015
+ }
13016
+ .h-form-file-thumbnails {
13017
+ position: relative;
13018
+ display: flex;
13019
+ flex-wrap: wrap;
13020
+ gap: 0.5rem;
13021
+ }
13022
+ .h-form-file-thumbnail {
13023
+ position: relative;
13024
+ pointer-events: initial !important;
13025
+ display: flex;
13026
+ }
13027
+ .h-form-file-thumbnail-remove {
13028
+ position: absolute;
13029
+ top: 0;
13030
+ right: 0;
13031
+ background: #dc3545;
13032
+ width: 20px;
13033
+ height: 20px;
13034
+ display: flex;
13035
+ align-items: center;
13036
+ justify-content: center;
13037
+ color: white;
13038
+ border-radius: 0.25rem;
13039
+ z-index: 3;
13040
+ cursor: pointer;
13041
+ }
13042
+ .h-form-file-thumbnail-remove:hover {
13043
+ background: #e15361;
12933
13044
  }
12934
13045
  .repeater {
12935
13046
  position: relative;
@@ -12981,50 +13092,23 @@ input[type=search] {
12981
13092
  visibility: hidden;
12982
13093
  cursor: move;
12983
13094
  }
12984
- .h-form-file {
12985
- position: relative;
12986
- }
12987
- .h-form-file .h-form-file-thumbnails {
12988
- margin-bottom: 0.5rem;
12989
- }
12990
- .h-form-file.h-dropzone {
12991
- padding: 0.5rem;
12992
- }
12993
- .h-form-file.h-dropzone .h-form-file-thumbnails {
12994
- margin-bottom: 0;
12995
- }
12996
- .h-form-file-thumbnails {
12997
- position: relative;
12998
- display: flex;
12999
- flex-wrap: wrap;
13000
- gap: 0.5rem;
13001
- }
13002
- .h-form-file-thumbnail {
13003
- position: relative;
13004
- pointer-events: initial !important;
13005
- display: flex;
13006
- }
13007
- .h-form-file-thumbnail-remove {
13008
- position: absolute;
13009
- top: 0;
13010
- right: 0;
13011
- background: #dc3545;
13012
- width: 20px;
13013
- height: 20px;
13014
- display: flex;
13015
- align-items: center;
13016
- justify-content: center;
13017
- color: white;
13018
- border-radius: 0.25rem;
13019
- z-index: 3;
13020
- cursor: pointer;
13095
+ input[type=search] {
13096
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E%0A");
13097
+ background-repeat: no-repeat;
13098
+ background-position: 10px center;
13099
+ padding-left: 35px !important;
13021
13100
  }
13022
- .h-form-file-thumbnail-remove:hover {
13023
- background: #e15361;
13101
+ .form-floating input[type=search] ~ label {
13102
+ padding-left: 35px;
13024
13103
  }
13025
13104
  html {
13026
13105
  height: 100%;
13027
13106
  }
13107
+ mark,
13108
+ .mark {
13109
+ padding: 0;
13110
+ box-shadow: 0 0.2em 0 #ffec89, 0 -0.2em 0 #ffec89;
13111
+ }
13028
13112
  .body {
13029
13113
  background: rgba(0, 0, 0, 0.03);
13030
13114
  height: 100vh;
@@ -13129,10 +13213,12 @@ body.empty {
13129
13213
  border: 1px solid #ced4da;
13130
13214
  }
13131
13215
  .h-dropzone {
13216
+ position: relative;
13132
13217
  border: 2px dashed #ced4da;
13133
13218
  border-radius: 0.25rem;
13134
13219
  }
13135
- .h-dropzone > *:not(input[type=file]) {
13220
+ .h-dropzone > *:not(.form-control) {
13221
+ margin: 0.5rem;
13136
13222
  pointer-events: none;
13137
13223
  z-index: 2;
13138
13224
  }
@@ -13143,19 +13229,40 @@ body.empty {
13143
13229
  .h-dropzone.dragover input[type=file] {
13144
13230
  z-index: 3;
13145
13231
  }
13146
- .h-dropzone.active {
13232
+ .h-dropzone.focus,
13233
+ .h-dropzone.dragover {
13147
13234
  border-color: #86b7fe;
13148
13235
  outline: 0;
13149
13236
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075), 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
13150
13237
  }
13151
- .h-dropzone input[type=file] {
13238
+ .h-dropzone.focus.is-valid,
13239
+ .h-dropzone.dragover.is-valid {
13240
+ border-color: #198754;
13241
+ box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
13242
+ }
13243
+ .h-dropzone.focus.is-invalid,
13244
+ .h-dropzone.dragover.is-invalid {
13245
+ border-color: #dc3545;
13246
+ box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
13247
+ }
13248
+ .h-dropzone .form-control {
13152
13249
  position: absolute;
13153
13250
  top: 0;
13154
13251
  left: 0;
13155
13252
  width: 100%;
13156
13253
  height: 100%;
13157
- opacity: 0;
13158
13254
  z-index: 1;
13255
+ border: none;
13256
+ box-shadow: none;
13257
+ text-indent: -100vw;
13258
+ color: transparent;
13259
+ background: none;
13260
+ }
13261
+ .h-dropzone.is-invalid {
13262
+ border-color: #dc3545;
13263
+ }
13264
+ .h-dropzone.is-valid {
13265
+ border-color: #198754;
13159
13266
  }
13160
13267
  .h-dropzone-placeholder {
13161
13268
  color: #6c757d;
@@ -13232,6 +13339,7 @@ body.empty {
13232
13339
  background-clip: padding-box;
13233
13340
  border-radius: 0.3rem;
13234
13341
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
13342
+ border: 1px solid rgba(0, 0, 0, 0.2);
13235
13343
  }
13236
13344
  .h-popup.closed {
13237
13345
  display: none;
@@ -13254,201 +13362,93 @@ body.empty {
13254
13362
  left: calc(50% - 14px);
13255
13363
  font-size: 28px;
13256
13364
  }
13365
+ .h-syntax {
13366
+ background-color: #ffffcc;
13367
+ }
13368
+ .h-syntax .hll {
13369
+ background-color: #ffffcc;
13370
+ }
13371
+ .h-syntax {
13372
+ background: #f8f8f8;
13373
+ }
13257
13374
  .h-syntax .c {
13258
- color: #727272;
13375
+ color: #6a737d;
13376
+ }
13377
+ .h-syntax .k {
13378
+ color: #d73a49;
13259
13379
  }
13260
13380
  .h-syntax .ch {
13261
- font-style: italic;
13262
- color: #60a0b0;
13381
+ color: #6a737d;
13263
13382
  }
13264
13383
  .h-syntax .cm {
13265
- color: #727272;
13384
+ color: #6a737d;
13266
13385
  }
13267
13386
  .h-syntax .cp {
13268
- color: #008085;
13387
+ color: #d73a49;
13269
13388
  }
13270
13389
  .h-syntax .cpf {
13271
- color: #007020;
13390
+ color: #032f62;
13272
13391
  }
13273
13392
  .h-syntax .c1 {
13274
- color: #727272;
13393
+ color: #6a737d;
13275
13394
  }
13276
13395
  .h-syntax .cs {
13277
- color: #727272;
13396
+ color: #6a737d;
13278
13397
  }
13279
13398
  .h-syntax .gd {
13280
- background-color: #fcc;
13281
- border: 1px solid #c00;
13282
- }
13283
- .h-syntax .ge {
13284
- font-style: italic;
13285
- }
13286
- .h-syntax .gr {
13287
- color: #f00;
13399
+ color: #b31d28;
13400
+ background-color: #ffeef0;
13288
13401
  }
13289
13402
  .h-syntax .gh {
13290
- color: #030;
13403
+ color: #005cc5;
13291
13404
  }
13292
13405
  .h-syntax .gi {
13293
- background-color: #cfc;
13294
- border: 1px solid #0c0;
13295
- }
13296
- .h-syntax .go {
13297
- color: #aaa;
13298
- }
13299
- .h-syntax .gp {
13300
- color: #009;
13406
+ color: #22863a;
13407
+ background-color: #f0fff4;
13301
13408
  }
13302
13409
  .h-syntax .gs {
13303
- font-weight: 700;
13410
+ font-weight: bold;
13304
13411
  }
13305
13412
  .h-syntax .gu {
13306
- color: #030;
13413
+ color: #6f42c1;
13414
+ font-weight: bold;
13307
13415
  }
13308
13416
  .h-syntax .gt {
13309
- color: #9c6;
13310
- }
13311
- .h-syntax .gl {
13312
- text-decoration: underline;
13313
- }
13314
- .h-syntax .k {
13315
- color: #069;
13417
+ color: #0044DD;
13316
13418
  }
13317
13419
  .h-syntax .kc {
13318
- color: #069;
13420
+ color: #005cc5;
13319
13421
  }
13320
13422
  .h-syntax .kd {
13321
- color: #069;
13423
+ color: #d73a49;
13322
13424
  }
13323
13425
  .h-syntax .kn {
13324
- color: #069;
13426
+ color: #d73a49;
13325
13427
  }
13326
13428
  .h-syntax .kp {
13327
- color: #069;
13429
+ color: #d73a49;
13328
13430
  }
13329
13431
  .h-syntax .kr {
13330
- color: #069;
13432
+ color: #d73a49;
13331
13433
  }
13332
13434
  .h-syntax .kt {
13333
- color: #078;
13435
+ color: #d73a49;
13334
13436
  }
13335
13437
  .h-syntax .m {
13336
- color: #c24f19;
13337
- }
13338
- .h-syntax .mb {
13339
- color: #40a070;
13340
- }
13341
- .h-syntax .mf {
13342
- color: #c24f19;
13343
- }
13344
- .h-syntax .mh {
13345
- color: #c24f19;
13346
- }
13347
- .h-syntax .mi {
13348
- color: #c24f19;
13349
- }
13350
- .h-syntax .il {
13351
- color: #c24f19;
13352
- }
13353
- .h-syntax .mo {
13354
- color: #c24f19;
13438
+ color: #666666;
13355
13439
  }
13356
13440
  .h-syntax .s {
13357
- color: #d73038;
13358
- }
13359
- .h-syntax .sa {
13360
- color: #4070a0;
13361
- }
13362
- .h-syntax .sb {
13363
- color: #c30;
13364
- }
13365
- .h-syntax .sc {
13366
- color: #c30;
13367
- }
13368
- .h-syntax .dl {
13369
- color: #4070a0;
13370
- }
13371
- .h-syntax .sd {
13372
- font-style: italic;
13373
- color: #c30;
13374
- }
13375
- .h-syntax .s2 {
13376
- color: #c30;
13377
- }
13378
- .h-syntax .se {
13379
- color: #c30;
13380
- }
13381
- .h-syntax .sh {
13382
- color: #c30;
13383
- }
13384
- .h-syntax .si {
13385
- color: #a00;
13386
- }
13387
- .h-syntax .sx {
13388
- color: #c30;
13389
- }
13390
- .h-syntax .sr {
13391
- color: #337e7e;
13392
- }
13393
- .h-syntax .s1 {
13394
- color: #c30;
13395
- }
13396
- .h-syntax .ss {
13397
- color: #fc3;
13398
- }
13399
- .h-syntax .na {
13400
- color: #006ee0;
13441
+ color: #032f62;
13401
13442
  }
13402
13443
  .h-syntax .nb {
13403
- color: #366;
13444
+ color: #005cc5;
13404
13445
  }
13405
13446
  .h-syntax .nc {
13406
- color: #168174;
13447
+ color: #6f42c1;
13407
13448
  }
13408
13449
  .h-syntax .no {
13409
- color: #360;
13450
+ color: #005cc5;
13410
13451
  }
13411
13452
  .h-syntax .nd {
13412
- color: #6b62de;
13413
- }
13414
- .h-syntax .ni {
13415
- color: #727272;
13416
- }
13417
- .h-syntax .ne {
13418
- color: #c00;
13419
- }
13420
- .h-syntax .nf {
13421
- color: #b715f4;
13422
- }
13423
- .h-syntax .nl {
13424
- color: #6b62de;
13425
- }
13426
- .h-syntax .nn {
13427
- color: #007ca5;
13428
- }
13429
- .h-syntax .nt {
13430
- color: #2f6f9f;
13431
- }
13432
- .h-syntax .nv {
13433
- color: #033;
13434
- }
13435
- .h-syntax .o {
13436
- color: #555;
13437
- }
13438
- .h-syntax .ow {
13439
- color: #000;
13440
- }
13441
- .h-syntax .w {
13442
- color: #bbb;
13443
- }
13444
- .h-syntax .language-bash::before,
13445
- .h-syntax .language-sh::before {
13446
- color: #009;
13447
- content: "$ ";
13448
- user-select: none;
13449
- }
13450
- .h-syntax .language-powershell::before {
13451
- color: #009;
13452
- content: "PM> ";
13453
- user-select: none;
13453
+ color: #6f42c1;
13454
13454
  }
@@ -53,7 +53,7 @@
53
53
 
54
54
  // Headmin
55
55
  @import "headmin/filters";
56
- @import "headmin/form";
56
+ @import "headmin/forms";
57
57
  @import "headmin/general";
58
58
  @import "headmin/layout";
59
59
  @import "headmin/login";
@@ -5,6 +5,5 @@ module Headmin
5
5
  include Headmin::FormHelper
6
6
  include Headmin::NotificationHelper
7
7
  include Headmin::RequestHelper
8
- include Headmin::DocumentationHelper
9
8
  end
10
9
  end
@@ -1,22 +1,16 @@
1
1
  module Headmin
2
2
  module FormHelper
3
- def form_field_valid?(form, name)
4
- !form.object.errors.has_key?(name)
5
- end
6
-
3
+ # TODO: cleanup after input field refactoring
7
4
  def form_field_validation_id(form, name)
8
5
  [form.object_name, name.to_s, "validation"].join("_").parameterize.underscore
9
6
  end
10
7
 
8
+ # TODO: cleanup after input field refactoring
11
9
  def form_field_validation_class(form, name)
12
10
  return nil if request.get?
13
11
  form.object.errors.has_key?(name) ? "is-invalid" : "is-valid"
14
12
  end
15
13
 
16
- def human_attribute_name(attribute)
17
- attribute.to_s.humanize
18
- end
19
-
20
14
  # Outputs currently present query parameters as hidden fields for a given form
21
15
  #
22
16
  # https://example.com/products?amount=1&type[]=food&type[]=beverage
@@ -3,7 +3,7 @@ module Headmin
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- has_many :blocks, as: :blockable
6
+ has_many :blocks, as: :blockable, dependent: :destroy
7
7
  accepts_nested_attributes_for :blocks, allow_destroy: true
8
8
  end
9
9
  end
@@ -12,6 +12,7 @@ module Headmin
12
12
  has_many :fields, foreign_key: "parent_id"
13
13
  accepts_nested_attributes_for :fields, allow_destroy: true
14
14
  has_one_attached :file
15
+ accepts_nested_attributes_for :file_attachment
15
16
  end
16
17
  end
17
18
  end
@@ -0,0 +1,38 @@
1
+ module Headmin
2
+ module Form
3
+ module Autocompletable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def autocomplete?
8
+ collection.is_a?(String) || collection.is_a?(Array)
9
+ end
10
+
11
+ def autocomplete_options
12
+ {
13
+ collection: collection.is_a?(Array) ? collection : []
14
+ }
15
+ end
16
+
17
+ def autocomplete_input_options
18
+ {
19
+ data: {
20
+ autocomplete_target: autocomplete? ? "input" : nil
21
+ }
22
+ }
23
+ end
24
+
25
+ def autocomplete_input_group_options
26
+ options = {
27
+ data: {
28
+ controller: autocomplete? ? "autocomplete" : nil,
29
+ autocomplete_url_value: collection.is_a?(String) ? collection : nil
30
+ }
31
+ }
32
+ options = options.merge(bypass: false) if autocomplete?
33
+ options
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,19 @@
1
+ module Headmin
2
+ module Form
3
+ module Hintable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def hint?
8
+ hint.present?
9
+ end
10
+
11
+ def hint_options
12
+ {
13
+ content: hint
14
+ }
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ module Headmin
2
+ module Form
3
+ module InputGroupable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def input_group_options
8
+ default_input_group_options.merge(@input_group || {})
9
+ end
10
+
11
+ private
12
+
13
+ def default_input_group_options
14
+ {
15
+ bypass: !(prepend || append || @input_group),
16
+ prepend: prepend,
17
+ append: append
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ module Headmin
2
+ module Form
3
+ module Labelable
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ def label?
7
+ label != false
8
+ end
9
+
10
+ def prepend_label?
11
+ label != false && !float
12
+ end
13
+
14
+ def append_label?
15
+ label != false && float
16
+ end
17
+
18
+ def label_input_group_options
19
+ float ? {bypass: true} : {}
20
+ end
21
+
22
+ def label_options
23
+ {
24
+ attribute: attribute,
25
+ form: form,
26
+ required: required,
27
+ text: label
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end