para 0.6.9 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/para/admin/tangram-mosaic.png +0 -0
  3. data/app/assets/images/para/admin/template-section.svg +23 -0
  4. data/app/assets/javascripts/para/admin.coffee +20 -0
  5. data/app/assets/javascripts/para/admin/tabs.coffee +22 -5
  6. data/app/assets/javascripts/para/admin/theme_actions.coffee +3 -3
  7. data/app/assets/javascripts/para/inputs/material-input.coffee +4 -0
  8. data/app/assets/javascripts/para/inputs/multi-select-input.coffee +173 -0
  9. data/app/assets/javascripts/para/inputs/nested_many.coffee +9 -9
  10. data/app/assets/stylesheets/para/admin.sass +5 -5
  11. data/app/assets/stylesheets/para/admin/main.sass +32 -0
  12. data/app/assets/stylesheets/para/admin/src/_alert.sass +17 -0
  13. data/app/assets/stylesheets/para/admin/src/_base.sass +51 -0
  14. data/app/assets/stylesheets/para/admin/src/_bootstrap-variables.scss +874 -0
  15. data/app/assets/stylesheets/para/admin/src/_breadcrumb.sass +22 -0
  16. data/app/assets/stylesheets/para/admin/src/_buttons.sass +107 -0
  17. data/app/assets/stylesheets/para/admin/src/_checkable.sass +94 -0
  18. data/app/assets/stylesheets/para/admin/src/_common.sass +203 -0
  19. data/app/assets/stylesheets/para/admin/src/_dropdown.sass +40 -0
  20. data/app/assets/stylesheets/para/admin/src/_form.sass +271 -0
  21. data/app/assets/stylesheets/para/admin/src/_list.sass +61 -0
  22. data/app/assets/stylesheets/para/admin/src/_mixins.sass +113 -0
  23. data/app/assets/stylesheets/para/admin/src/_multi-select.sass +91 -0
  24. data/app/assets/stylesheets/para/admin/src/_navigation.sass +150 -0
  25. data/app/assets/stylesheets/para/admin/src/_navtabs.sass +41 -0
  26. data/app/assets/stylesheets/para/admin/src/_nested-many.sass +69 -0
  27. data/app/assets/stylesheets/para/admin/src/_nested_one.sass +13 -0
  28. data/app/assets/stylesheets/para/admin/src/_orderable.sass +44 -0
  29. data/app/assets/stylesheets/para/admin/src/_page-loading.sass +39 -0
  30. data/app/assets/stylesheets/para/admin/src/_pagination.sass +34 -0
  31. data/app/assets/stylesheets/para/admin/src/_panel.sass +55 -0
  32. data/app/assets/stylesheets/para/admin/src/_responsive.sass +100 -0
  33. data/app/assets/stylesheets/para/admin/{theme → src}/_sorting.sass +11 -3
  34. data/app/assets/stylesheets/para/admin/src/_statcard.sass +41 -0
  35. data/app/assets/stylesheets/para/admin/src/_table.sass +33 -0
  36. data/app/assets/stylesheets/para/admin/src/_tree.sass +52 -0
  37. data/app/assets/stylesheets/para/admin/src/_variables.sass +37 -0
  38. data/app/assets/stylesheets/para/admin/src/_well.sass +12 -0
  39. data/app/assets/stylesheets/para/{admin/src → lib}/datetimepicker.sass +1 -3
  40. data/app/assets/stylesheets/para/{admin/src → lib}/fuelux.sass +3 -5
  41. data/app/assets/stylesheets/para/lib/jasny-bootstrap.sass +97 -0
  42. data/app/assets/stylesheets/para/{admin/src → lib}/redactor.sass +2 -5
  43. data/app/assets/stylesheets/para/lib/selectize.sass +112 -0
  44. data/app/assets/stylesheets/para/lib/slider.sass +12 -0
  45. data/app/controllers/concerns/para/admin/resource_controller_concerns.rb +14 -2
  46. data/app/controllers/para/admin/base_controller.rb +7 -0
  47. data/app/controllers/para/admin/crud_resources_controller.rb +13 -6
  48. data/app/controllers/para/admin/form_resources_controller.rb +5 -3
  49. data/app/controllers/para/admin/resources_controller.rb +9 -3
  50. data/app/controllers/para/admin/search_controller.rb +15 -0
  51. data/app/controllers/para/application_controller.rb +10 -2
  52. data/app/helpers/para/admin/page_helper.rb +9 -9
  53. data/app/helpers/para/application_helper.rb +1 -10
  54. data/app/helpers/para/form_helper.rb +5 -6
  55. data/app/helpers/para/model_helper.rb +13 -3
  56. data/app/helpers/para/ordering_helper.rb +1 -1
  57. data/app/helpers/para/search_results_helper.rb +16 -0
  58. data/app/helpers/para/tree_helper.rb +10 -6
  59. data/app/models/para/page.rb +5 -0
  60. data/app/models/para/page/section.rb +42 -0
  61. data/app/models/para/page/section_resource.rb +12 -0
  62. data/app/views/layouts/para/admin.html.haml +5 -8
  63. data/app/views/para/admin/dashboard.html.haml +21 -8
  64. data/app/views/para/admin/form_resources/show.html.haml +1 -1
  65. data/app/views/para/admin/imports/new.html.haml +2 -2
  66. data/app/views/para/admin/resources/_actions.html.haml +3 -3
  67. data/app/views/para/admin/resources/_add_button.html.haml +1 -1
  68. data/app/views/para/admin/resources/_exports_menu.html.haml +6 -6
  69. data/app/views/para/admin/resources/_filters.html.haml +7 -8
  70. data/app/views/para/admin/resources/_imports_menu.html.haml +6 -6
  71. data/app/views/para/admin/resources/_list.html.haml +14 -15
  72. data/app/views/para/admin/resources/_per_page_select.html.haml +4 -3
  73. data/app/views/para/admin/resources/_subclassable_add_button.html.haml +3 -3
  74. data/app/views/para/admin/resources/_tree.html.haml +7 -9
  75. data/app/views/para/admin/resources/_tree_item.html.haml +5 -6
  76. data/app/views/para/admin/resources/edit.html.haml +1 -1
  77. data/app/views/para/admin/resources/new.html.haml +1 -1
  78. data/app/views/para/admin/search/_result.html.haml +7 -0
  79. data/app/views/para/admin/search/index.html.haml +1 -0
  80. data/app/views/para/admin/settings_component/show.html.haml +1 -1
  81. data/app/views/para/admin/shared/_breadcrumbs.html.haml +2 -3
  82. data/app/views/para/admin/shared/_header.html.haml +16 -27
  83. data/app/views/para/admin/shared/_navigation.html.haml +20 -19
  84. data/app/views/para/form/_tabs.html.haml +6 -7
  85. data/app/views/para/inputs/_multi_select.html.haml +40 -0
  86. data/app/views/para/inputs/_nested_many.html.haml +4 -4
  87. data/app/views/para/inputs/multi_select/_no_items.html.haml +6 -0
  88. data/app/views/para/inputs/nested_many/_add.html.haml +1 -2
  89. data/app/views/para/inputs/nested_many/_add_with_subclasses.html.haml +4 -5
  90. data/app/views/para/inputs/nested_many/_container.html.haml +7 -8
  91. data/app/views/shared/_breadcrumbs.html.haml +4 -0
  92. data/config/locales/fr.yml +29 -4
  93. data/db/migrate/20170324125547_create_para_page_section_resources.rb +15 -0
  94. data/lib/generators/para/filters/templates/_filters.html.haml +3 -5
  95. data/lib/generators/para/install/templates/initializer.rb +12 -0
  96. data/lib/generators/para/page/section/section_generator.rb +13 -2
  97. data/lib/generators/para/page/section/templates/section.html.haml.erb +3 -0
  98. data/lib/generators/para/resource/resource_generator.rb +1 -1
  99. data/lib/para.rb +25 -21
  100. data/lib/para/attribute_field.rb +2 -0
  101. data/lib/para/attribute_field/base.rb +1 -1
  102. data/lib/para/attribute_field/belongs_to.rb +1 -1
  103. data/lib/para/attribute_field/boolean.rb +1 -1
  104. data/lib/para/attribute_field/friendly_id.rb +19 -0
  105. data/lib/para/attribute_field/has_many.rb +43 -4
  106. data/lib/para/attribute_field/nested_field.rb +46 -0
  107. data/lib/para/attribute_field/nested_many.rb +30 -9
  108. data/lib/para/attribute_field/nested_one.rb +28 -9
  109. data/lib/para/attribute_field/password.rb +1 -1
  110. data/lib/para/attribute_field/relation.rb +19 -1
  111. data/lib/para/attribute_field_mappings.rb +9 -3
  112. data/lib/para/breadcrumbs/breadcrumb.rb +57 -10
  113. data/lib/para/breadcrumbs/controller.rb +19 -6
  114. data/lib/para/breadcrumbs/manager.rb +9 -1
  115. data/lib/para/config.rb +3 -0
  116. data/lib/para/controller_resource.rb +34 -0
  117. data/lib/para/engine.rb +33 -14
  118. data/lib/para/exporter/base.rb +1 -1
  119. data/lib/para/ext.rb +1 -1
  120. data/lib/para/ext/active_record_nested_attributes.rb +51 -0
  121. data/lib/para/ext/paperclip.rb +2 -6
  122. data/lib/para/form_builder.rb +3 -0
  123. data/lib/para/form_builder/attributes_mappings_tracker.rb +45 -0
  124. data/lib/para/form_builder/containers.rb +13 -17
  125. data/lib/para/form_builder/nested_form.rb +2 -3
  126. data/lib/para/helpers.rb +8 -0
  127. data/lib/para/helpers/attributes_mappings.rb +13 -0
  128. data/lib/para/helpers/resource_name.rb +14 -0
  129. data/lib/para/inputs.rb +1 -0
  130. data/lib/para/inputs/multi_select_input.rb +90 -0
  131. data/lib/para/inputs/nested_many_input.rb +6 -1
  132. data/lib/para/markup/resources_table.rb +15 -11
  133. data/lib/para/model_field_parsers.rb +3 -2
  134. data/lib/para/model_field_parsers/base.rb +7 -2
  135. data/lib/para/model_field_parsers/friendly_id.rb +19 -0
  136. data/lib/para/model_field_parsers/relations.rb +20 -1
  137. data/lib/para/page/model.rb +3 -1
  138. data/lib/para/routes.rb +1 -0
  139. data/lib/para/simple_form_config.rb +85 -0
  140. data/lib/para/version.rb +1 -1
  141. data/lib/rails/routing_mapper.rb +5 -8
  142. data/vendor/assets/javascripts/jasny-bootstrap.js +577 -0
  143. data/vendor/assets/stylesheets/animate.css +3340 -0
  144. data/vendor/assets/stylesheets/hint.css +649 -0
  145. data/vendor/assets/stylesheets/jasny-bootstrap.css +287 -0
  146. metadata +114 -67
  147. data/app/assets/images/para/admin/bg.png +0 -0
  148. data/app/assets/javascripts/para/admin.js +0 -20
  149. data/app/assets/stylesheets/admin/theme.sass +0 -0
  150. data/app/assets/stylesheets/para/admin/src/jasny.bootstrap.sass +0 -40
  151. data/app/assets/stylesheets/para/admin/src/nested_many.sass +0 -5
  152. data/app/assets/stylesheets/para/admin/src/page-loading.sass +0 -24
  153. data/app/assets/stylesheets/para/admin/src/page-top-bar.sass +0 -9
  154. data/app/assets/stylesheets/para/admin/src/selectize.sass +0 -46
  155. data/app/assets/stylesheets/para/admin/src/slider.sass +0 -12
  156. data/app/assets/stylesheets/para/admin/theme.sass +0 -22
  157. data/app/assets/stylesheets/para/admin/theme/_base.sass +0 -176
  158. data/app/assets/stylesheets/para/admin/theme/_breadcrumb.sass +0 -75
  159. data/app/assets/stylesheets/para/admin/theme/_buttons.sass +0 -27
  160. data/app/assets/stylesheets/para/admin/theme/_checkable.sass +0 -108
  161. data/app/assets/stylesheets/para/admin/theme/_commonds.sass +0 -210
  162. data/app/assets/stylesheets/para/admin/theme/_dropdown.sass +0 -52
  163. data/app/assets/stylesheets/para/admin/theme/_form.sass +0 -150
  164. data/app/assets/stylesheets/para/admin/theme/_list.sass +0 -139
  165. data/app/assets/stylesheets/para/admin/theme/_navigation.sass +0 -229
  166. data/app/assets/stylesheets/para/admin/theme/_navtabs.sass +0 -151
  167. data/app/assets/stylesheets/para/admin/theme/_orderable.sass +0 -45
  168. data/app/assets/stylesheets/para/admin/theme/_panel.sass +0 -264
  169. data/app/assets/stylesheets/para/admin/theme/_responsive.sass +0 -123
  170. data/app/assets/stylesheets/para/admin/theme/_table.sass +0 -28
  171. data/app/assets/stylesheets/para/admin/theme/_tree.sass +0 -74
  172. data/app/assets/stylesheets/para/admin/theme/_variables.sass +0 -31
  173. data/app/assets/stylesheets/para/application.css +0 -15
  174. data/app/assets/stylesheets/para/lib/_variables.scss +0 -646
  175. data/app/assets/stylesheets/para/overrides/responsive.sass +0 -62
  176. data/app/assets/stylesheets/para/overrides/theme.sass +0 -172
  177. data/lib/para/ext/cancan.rb +0 -26
  178. data/vendor/assets/javascripts/jasny.bootstrap.min.js +0 -7
  179. data/vendor/assets/stylesheets/animate.min.css +0 -6
  180. data/vendor/assets/stylesheets/jasny.bootstrap.min.css +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4915e7e03e392a3307e8b5176de12be7fdb73d6e
4
- data.tar.gz: 45bf225b7000ad5f140bedfb91ab7ac77f8aa624
3
+ metadata.gz: f89735619264be8599e3ccccfccdb64d07aa219c
4
+ data.tar.gz: 7aea1f82a1e545b142dc4abcca505de107a3d94d
5
5
  SHA512:
6
- metadata.gz: d874e015838070cc4a3d1dde20c78d22cc5faddf9ca53ebc70feb6962fc0cab806cb23960047224e8fe2fdabb944645f3bdec79e62b1d6318c9b12774bcbc644
7
- data.tar.gz: 40ba2a96ee48edeeccd59ff47a39275df5fc10f86ddbcd194471291516684f6fca51b16077f53c4a61370cd74d309a1a6ed6fbe981dae53c3c8f3f4a962822e0
6
+ metadata.gz: cc137eb9e0185c8a7fac27b9ddb830981bcfa0e7b1951153beed16f4cc289efd3c5b6f467ee793cf9920aa02e9ed407f677b494fffa04fb60cff7ea85d69cfe6
7
+ data.tar.gz: 7d2b0d6a005b9a2770bf28a459fe34c8ca4cddd8276cb58f3df99923131a96f24e99903850d8867de76778b3a771ced22ed49b6bc95f4c4062768d360880a55b
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg width="248px" height="152px" viewBox="0 0 248 152" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 43 (38999) - http://www.bohemiancoding.com/sketch -->
4
+ <title>Circle with Text Centered</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs></defs>
7
+ <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.0799999982">
8
+ <g id="Section" transform="translate(-23.000000, -8.000000)">
9
+ <g id="Circle-with-Text-Centered">
10
+ <g transform="translate(23.000000, 8.000000)">
11
+ <g id="Circle-Image" transform="translate(97.000000, 0.000000)">
12
+ <path d="M54.1791045,27.0906486 C54.1791045,42.0513524 42.0513524,54.1791045 27.0906486,54.1791045 C12.1277521,54.1791045 0,42.0513524 0,27.0906486 C0,12.1299448 12.1277521,0 27.0906486,0 C42.0513524,0 54.1791045,12.1299448 54.1791045,27.0906486" id="Fill-1195" fill="#6C7A8C"></path>
13
+ <path d="M43.9738349,32.7029625 L33.369052,19.4754572 C32.730731,18.6805036 31.5254945,18.6826756 30.8915012,19.4798012 L25.5772088,26.1456819 C25.034095,26.8276912 24.0452385,26.9449795 23.359314,26.4063224 L21.208497,24.7208472 C20.5853226,24.2321463 19.6960009,24.2777584 19.1269215,24.8316194 L11.1598105,32.5574382 C10.1320056,33.5522161 10.8352406,35.2985075 12.2633485,35.2985075 L42.7361414,35.2985075 C44.0712059,35.2985075 44.8112255,33.7476965 43.9738349,32.7029625" id="Fill-1196" fill="#B3C0C5"></path>
14
+ <path d="M12.3134328,18.8794297 C12.3134328,20.6933958 13.6003682,22.1641791 15.1875885,22.1641791 C16.7727661,22.1641791 18.0597015,20.6933958 18.0597015,18.8794297 C18.0597015,17.0654637 16.7727661,15.5970149 15.1875885,15.5970149 C13.6003682,15.5970149 12.3134328,17.0654637 12.3134328,18.8794297" id="Fill-1197" fill="#B3C0C5"></path>
15
+ </g>
16
+ <path d="M245.247179,136 L2.75282063,136 C1.54052422,136 0.828262225,135.402475 0.828262225,135 L0.828262225,126 C0.828262225,125.595003 1.5375189,125 2.75282063,125 L245.247179,125 C246.459476,125 247.171738,125.597525 247.171738,126 L247.171738,135 C247.171738,135.402475 246.459476,136 245.247179,136" id="Fill-1198" fill="#B3C0C5"></path>
17
+ <path d="M226.963875,152 L18.1492878,152 C16.9361399,152 16.2247294,151.402612 16.2247294,151 L16.2247294,142 C16.2247294,141.594867 16.9331382,141 18.1492878,141 L226.963875,141 C228.177022,141 228.888433,141.597388 228.888433,142 L228.888433,151 C228.888433,151.402612 228.177022,152 226.963875,152" id="Fill-1199" fill="#B3C0C5"></path>
18
+ <path d="M223.114758,120 L21.9984047,120 C20.8850909,120 20.0738463,119.308911 20.0738463,118 L20.0738463,106 C20.0738463,104.68853 20.8820863,104 21.9984047,104 L223.114758,104 C224.228071,104 225.039316,104.691089 225.039316,106 L225.039316,118 C225.039316,119.308911 224.228071,120 223.114758,120" id="Fill-1200" fill="#6C7A8C"></path>
19
+ </g>
20
+ </g>
21
+ </g>
22
+ </g>
23
+ </svg>
@@ -0,0 +1,20 @@
1
+ #= require jquery
2
+ #= require jquery_ujs
3
+ #= require turbolinks
4
+ #= require bootstrap
5
+ #= require vertebra
6
+ #= require jasny-bootstrap
7
+ #= require simple_form_extension
8
+ #= require jquery.scrollto
9
+ #= require html5-sortable
10
+ #= require cocoon
11
+ #= require jquery.remote-modal-form
12
+ #= require_self
13
+ #= require_tree ./lib
14
+ #= require_tree ./inputs
15
+ #= require_tree ./admin
16
+ #= require ./plugins-includes
17
+ #= require admin/app
18
+
19
+ # Initialize scope
20
+ window.Para = {}
@@ -4,23 +4,40 @@
4
4
  class Para.Tabs extends Vertebra.View
5
5
  events:
6
6
  'shown.bs.tab a[data-toggle="tab"]': 'onTabShown'
7
+ 'change .tab-pane': 'onFormInputUpdate'
7
8
 
8
9
  initialize: (options = {}) ->
9
10
  @$anchorInput = options.$anchorInput
10
11
  @showActiveTab()
12
+ @refreshTabsErrors()
11
13
 
12
14
  showActiveTab: ->
13
- if (hash = location.hash or @$anchorInput?.val())
14
- @$('a[href="' + hash + '"]').tab('show')
15
+ if (hash = (location.hash or @$anchorInput?.val()))
16
+ @findTab(hash).tab('show')
15
17
 
16
18
  onTabShown: (e) =>
17
- tabHash = $(e.target).attr('href').substr(1)
18
- history.pushState(null, null, "##{ tabHash }")
19
- @updateAnchorInput(tabHash)
19
+ tabHash = $(e.target).attr('href')
20
+ history.pushState(null, null, tabHash)
21
+ @updateAnchorInput()
20
22
 
21
23
  updateAnchorInput: ->
22
24
  @$anchorInput.val(location.hash) if @$anchorInput.length
23
25
 
26
+ refreshTabsErrors: ->
27
+ @$('[data-toggle="tab"]').each (i, tab) =>
28
+ @refreshTabErrors($(tab))
29
+
30
+ refreshTabErrors: ($tab) ->
31
+ $panel = @$($tab.attr('href'))
32
+ $tab.addClass('has-error') if $panel.find('.has-error').length
33
+
34
+ onFormInputUpdate: (e) ->
35
+ $tab = @findTab($(e.currentTarget).attr('id'))
36
+ @refreshTabErrors($tab)
37
+
38
+ findTab: (id) ->
39
+ id = id.replace(/^\#/, '')
40
+ @$('a[href="' + id + '"]')
24
41
 
25
42
  $(document).on 'page:change turbolinks:load', ->
26
43
  $('[data-form-tabs]').each (i, el) ->
@@ -1,7 +1,7 @@
1
1
  scrollToComponentSection = ($component, duration = 0) ->
2
- sectionOffset = $component.closest('.component-section-item').offset().top + $('.page-sidebar').scrollTop()
3
- headerHeight = $('.page-sidebar .brand-logo').outerHeight()
4
- $('.page-sidebar').scrollTo(sectionOffset - headerHeight, duration: duration)
2
+ sectionOffset = $component.closest('.component-section-item').offset().top + $('.navmenu').scrollTop()
3
+ headerHeight = $('.navmenu .navmenu-brand').outerHeight()
4
+ $('.navmenu-nav').scrollTo(sectionOffset - headerHeight, duration: duration)
5
5
 
6
6
  responsive_sidebar_navigation = ->
7
7
  # Scroll to active element's section on page change
@@ -0,0 +1,4 @@
1
+ $(document).on 'page:change turbolinks:load', ->
2
+ $('body').on 'focusin focusout', 'input, .redactor-editor, select, textarea', (e) ->
3
+ focused = e.type is 'focusin'
4
+ $(e.target).closest('.form-group').toggleClass('focused', focused)
@@ -0,0 +1,173 @@
1
+ class Para.MultiSelectInput extends Vertebra.View
2
+ events:
3
+ 'keyup [data-search-field]': 'onSearchKeyUp'
4
+ 'click [data-add-all]': 'onAllItemsAdded'
5
+ 'click [data-remove-all]': 'onAllItemsRemoved'
6
+
7
+ initialize: ->
8
+ @$searchField = @$('[data-search-field]')
9
+ @$selectedItems = @$('[data-selected-items] tbody')
10
+ @$availableItems = @$('[data-available-items]')
11
+ @$input = @$('[data-multi-select-input-field]')
12
+
13
+ @searchURL = @$el.data('search-url')
14
+ @orderable = @$el.is('[data-orderable]')
15
+
16
+ @noSelectedItemsTemplate = @$('[data-no-selected-items]').data('no-selected-items')
17
+ @noAvailableItemsTemplate = @$('[data-no-available-items]').data('no-available-items')
18
+
19
+ @throttledTriggerSearch = throttle(@triggerSearch, 300, trailing: true)
20
+
21
+ @availableItems = []
22
+ @selectedItems = (@buildSelectedItem(el) for el in @$selectedItems.find('[data-selected-item-id]'))
23
+ @refreshSelectedItems()
24
+ @refreshAvailableItems()
25
+
26
+ onSearchKeyUp: ->
27
+ @throttledTriggerSearch()
28
+
29
+ triggerSearch: =>
30
+ @searchFor(@$searchField.val())
31
+
32
+ searchFor: (terms) ->
33
+ terms = trim(terms)
34
+ return if terms is @terms
35
+ @terms = terms
36
+ @setLoading(true)
37
+ @_currentSearchXHR?.abort()
38
+ @_currentSearchXHR = $.get(@searchURL, search: terms).done(@onSearchReturn)
39
+
40
+ onSearchReturn: (results, b, c) =>
41
+ @_currentSearchXHR = null
42
+ @setLoading(false)
43
+ @$('[data-available-items] tbody').html(results)
44
+ @refreshAvailableItems()
45
+
46
+ refreshAvailableItems: ->
47
+ item.destroy() for item in @availableItems
48
+ @availableItems = (@buildAvailableItem(el) for el in @$('[data-available-items] tr'))
49
+ @showEmptyListHint(@noAvailableItemsTemplate, @$availableItems) unless @availableItems.length
50
+
51
+ buildAvailableItem: (el) ->
52
+ availableItem = new Para.MultiSelectAvailableItem(el: el)
53
+ availableItem.setSelected(true) for selectedItem in @selectedItems when selectedItem.id is availableItem.id
54
+ @listenTo(availableItem, 'add', @onItemAdded)
55
+ availableItem
56
+
57
+ onItemAdded: (item) =>
58
+ @selectItem(item)
59
+
60
+ buildSelectedItem: (el) ->
61
+ selectedItem = new Para.MultiSelectSelectedItem(el: el)
62
+ @listenTo(selectedItem, 'remove', @onItemRemoved)
63
+ selectedItem
64
+
65
+ selectItem: (item) ->
66
+ return if @alreadySelected(item)
67
+
68
+ item.setSelected(true)
69
+ selectedItem = @buildSelectedItem(item.$el.attr('data-selected-item-template'))
70
+ @selectedItems.push(selectedItem)
71
+ @refreshSelectedItems()
72
+
73
+ alreadySelected: (item) ->
74
+ return true for selectedItem in @selectedItems when selectedItem.id is item.id
75
+ false
76
+
77
+ refreshSelectedItems: ->
78
+ @$selectedItems.empty()
79
+ selectedItem.renderTo(@$selectedItems) for selectedItem in @selectedItems
80
+
81
+ selectedItemIds = (selectedItem.id for selectedItem in @selectedItems).join(', ')
82
+ @$input.val(selectedItemIds)
83
+
84
+ if @selectedItems.length
85
+ @initializeOrderable()
86
+ else
87
+ @showEmptyListHint(@noSelectedItemsTemplate, @$selectedItems)
88
+
89
+ showEmptyListHint: (template, $container) ->
90
+ $(template).appendTo($container)
91
+
92
+ onItemRemoved: (selectedItem) =>
93
+ itemIndex = index for item, index in @selectedItems when item.id is selectedItem.id
94
+ @selectedItems.splice(itemIndex, 1)
95
+ selectedItem.destroy()
96
+ @refreshSelectedItems()
97
+
98
+ availableItem = item for item in @availableItems when item.id is selectedItem.id
99
+ availableItem.setSelected(false) if availableItem
100
+
101
+ onAllItemsAdded: ->
102
+ return unless @availableItems.length
103
+
104
+ @selectItem(availableItem) for availableItem in @availableItems
105
+
106
+ onAllItemsRemoved: ->
107
+ return unless @selectedItems.length
108
+
109
+ @selectedItems = []
110
+ @refreshSelectedItems()
111
+
112
+ item.setSelected(false) for item in @availableItems
113
+
114
+ initializeOrderable: ->
115
+ return unless @orderable
116
+
117
+ columnsCount = @$selectedItems.find('> tr > td').length
118
+
119
+ @$selectedItems.sortable('destroy')
120
+
121
+ @$selectedItems.sortable
122
+ handle: '.order-anchor'
123
+ forcePlaceholderSize: true
124
+ placeholder: "<tr><td colspan='#{ columnsCount }'></td></tr>"
125
+
126
+ @$selectedItems.on('sortupdate', @selectedItemsSorted)
127
+
128
+ selectedItemsSorted: =>
129
+ indices = {}
130
+ indices[$(el).data('selected-item-id')] = index for el, index in @$selectedItems.find('[data-selected-item-id]')
131
+
132
+ @selectedItems.sort (a, b) =>
133
+ aIndex = indices[a.id]
134
+ bIndex = indices[b.id]
135
+ if aIndex > bIndex then 1 else -1
136
+
137
+ @refreshSelectedItems()
138
+
139
+ setLoading: (state) ->
140
+ @$el.toggleClass('loading', state)
141
+ @$('.fa-search').toggleClass('fa-spin', state)
142
+
143
+ class Para.MultiSelectAvailableItem extends Vertebra.View
144
+ events:
145
+ 'click [data-add-item]': 'addItem'
146
+
147
+ initialize: ->
148
+ @id = @$el.data('available-item-id')
149
+
150
+ addItem: ->
151
+ @trigger('add', this)
152
+
153
+ setSelected: (@selected) ->
154
+ @$el.toggleClass('selected', @selected)
155
+
156
+
157
+ class Para.MultiSelectSelectedItem extends Vertebra.View
158
+ initialize: ->
159
+ @id = @$el.data('selected-item-id')
160
+
161
+ bindEvents: ->
162
+ @$('[data-remove-item]').on 'click', @removeItem
163
+
164
+ renderTo: ($container) ->
165
+ @$el.appendTo($container)
166
+ @bindEvents()
167
+
168
+ removeItem: (e) =>
169
+ @trigger('remove', this)
170
+
171
+
172
+ $.simpleForm.onDomReady ($document) ->
173
+ $document.find('[data-multi-select-input]').each (i, el) -> new Para.MultiSelectInput(el: el)
@@ -23,6 +23,7 @@ class Para.NestedManyField
23
23
 
24
24
  initializeCocoon: ->
25
25
  @$fieldsList.on 'cocoon:after-insert', $.proxy(@afterInsertField, this)
26
+ @$fieldsList.on 'cocoon:before-remove', $.proxy(@beforeRemoveField, this)
26
27
 
27
28
  afterInsertField: (e, $element) ->
28
29
  if ($collapsible = $element.find('[data-open-on-insert="true"]')).length
@@ -33,14 +34,13 @@ class Para.NestedManyField
33
34
  @initializeOrderable()
34
35
  @sortUpdate()
35
36
 
36
- if ($redactor = $element.find('[data-redactor]')).length
37
- $redactor.simpleFormRedactor()
37
+ $element.simpleForm()
38
38
 
39
- if ($selectize = $element.find('[data-selectize]'))
40
- $selectize.simpleFormSelectize()
41
-
42
- if ($slider = $element.find('[data-slider]'))
43
- $slider.simpleFormSlider()
39
+ beforeRemoveField: (e, $element) ->
40
+ $nextEl = $element.next()
41
+ # Remove attributes mappings field for new records since it will try to
42
+ # create an empty nested resource otherwise
43
+ $nextEl.remove() if $nextEl.is('[data-attributes-mappings]') and not $element.is('[data-persisted]')
44
44
 
45
45
  openInsertedField: ($field) ->
46
46
  $target = $($field.attr('href'))
@@ -54,5 +54,5 @@ class Para.NestedManyField
54
54
  $target.find('input, textarea, select').eq('0').focus()
55
55
 
56
56
 
57
- $(document).on 'page:change turbolinks:load', ->
58
- $('.nested-many-field').each (i, el) -> new Para.NestedManyField($(el))
57
+ $.simpleForm.onDomReady ($document) ->
58
+ $document.find('.nested-many-field').each (i, el) -> new Para.NestedManyField($(el))
@@ -1,12 +1,12 @@
1
1
  //= require_self
2
- //= require animate.min
2
+ //= require animate
3
+ //= require hint
3
4
  //= require font-awesome
4
- //= require jasny.bootstrap.min
5
+ //= require jasny-bootstrap
5
6
  //= require simple_form_extension
6
7
  //= require selectize
7
8
  //= require selectize.bootstrap3
8
- //= require ./admin/theme
9
- //= require_tree ./overrides
10
- //= require_tree ./admin/src
9
+ //= require_tree ./lib
10
+ //= require ./admin/main
11
11
  //= require ./plugins-includes
12
12
  //= require admin/app
@@ -0,0 +1,32 @@
1
+ @charset "UTF-8"
2
+ //** Import google font
3
+ @import url('//fonts.googleapis.com/css?family=Roboto:300,400,500,700,900')
4
+
5
+ @import "src/variables"
6
+ @import "bootstrap"
7
+
8
+ @import "src/mixins"
9
+ @import "src/common"
10
+ @import "src/base"
11
+ @import "src/buttons"
12
+ @import "src/form"
13
+ @import "src/nested_one"
14
+ @import "src/table"
15
+ @import "src/list"
16
+ @import "src/panel"
17
+ @import "src/alert"
18
+ @import "src/dropdown"
19
+ @import "src/multi-select"
20
+ @import "src/nested-many"
21
+ @import "src/checkable"
22
+ @import "src/sorting"
23
+ @import "src/orderable"
24
+ @import "src/pagination"
25
+ @import "src/tree"
26
+ @import "src/navigation"
27
+ @import "src/breadcrumb"
28
+ @import "src/navtabs"
29
+ @import "src/statcard"
30
+ @import "src/page-loading"
31
+ @import "src/responsive"
32
+ @import "src/well"
@@ -0,0 +1,17 @@
1
+ //
2
+ // Alert
3
+ // --------------------------------------------------
4
+
5
+ //== Main style
6
+ //
7
+ //##
8
+
9
+ .page-content
10
+ .alert
11
+ +first-child()
12
+ margin-right: -15px
13
+ margin-left: -15px
14
+ margin-bottom: 0
15
+ +border-radius(0)
16
+ &.no-results
17
+ margin: 15px 0 0 0
@@ -0,0 +1,51 @@
1
+ //
2
+ // Base
3
+ // --------------------------------------------------
4
+
5
+ //== Layout
6
+ //
7
+ //##
8
+
9
+ html *
10
+ outline: 0!important
11
+
12
+ body, html
13
+ min-height: 100%
14
+ position: relative
15
+ -webkit-font-smoothing: antialiased
16
+ -moz-osx-font-smoothing: grayscale
17
+
18
+ .body-full-height
19
+ height: 100%
20
+ body
21
+ height: 100%
22
+
23
+ body
24
+ padding: $navbar-height 0 0 0
25
+ background: image_url('para/admin/tangram-mosaic.png') repeat top left $gray-light
26
+ background-size: 128px 128px
27
+
28
+ //== Page content
29
+ //
30
+ //##
31
+
32
+ .page-title
33
+ background-color: #fff
34
+ padding: 15px 25px 15px 25px
35
+ z-index: $zindex-navbar-fixed + 1
36
+ +material-box-shadow-soft(2)
37
+ h1
38
+ margin: 0
39
+ font-weight: 300
40
+ float: left
41
+ line-height: 34px
42
+
43
+ .page-content-wrap
44
+ background-color: #fff
45
+ margin: 25px 10px 25px 10px
46
+ +border-radius($border-radius-small)
47
+ +material-box-shadow-soft
48
+ padding: 25px
49
+
50
+ b, strong
51
+ font-weight: 500