lato_core 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/lato_core/application.js +18 -9
  3. data/app/assets/javascripts/lato_core/modules/CoreButton.js +38 -0
  4. data/app/assets/javascripts/lato_core/{initializers/Charts.js → modules/CoreChart.js} +12 -12
  5. data/app/assets/javascripts/lato_core/modules/CoreDatepicker.js +42 -0
  6. data/app/assets/javascripts/lato_core/modules/CoreEditor.js +27 -0
  7. data/app/assets/javascripts/lato_core/modules/CoreFlash.js +27 -0
  8. data/app/assets/javascripts/lato_core/modules/CoreFormValidator.js +110 -0
  9. data/app/assets/javascripts/lato_core/{initializers/Layout.js → modules/CoreLayout.js} +6 -5
  10. data/app/assets/javascripts/lato_core/modules/CoreMediapicker.js +140 -0
  11. data/app/assets/javascripts/lato_core/{interfaces/Modal.js → modules/CoreModal.js} +27 -2
  12. data/app/assets/javascripts/lato_core/modules/CoreSelect.js +110 -0
  13. data/app/assets/javascripts/lato_core/{initializers/inputs/SortableManager.js → modules/CoreSortableManager.js} +7 -6
  14. data/app/assets/javascripts/lato_core/modules/CoreTable.js +28 -0
  15. data/app/assets/stylesheets/lato_core/cells/inputs/_inputs.scss +1 -0
  16. data/app/assets/stylesheets/lato_core/cells/inputs/_multipleselect.scss +6 -0
  17. data/app/assets/stylesheets/lato_core/cells/widgets/_index.scss +9 -0
  18. data/app/cells/lato_core/inputs/dropzone/views/show.html.erb +24 -20
  19. data/app/cells/lato_core/inputs/multipleselect/cell.rb +52 -0
  20. data/app/cells/lato_core/inputs/multipleselect/views/show.html.erb +16 -0
  21. data/app/cells/lato_core/inputs/select/cell.rb +19 -1
  22. data/app/cells/lato_core/inputs/select/views/show.html.erb +10 -2
  23. data/app/cells/lato_core/widgets/index/cell.rb +1 -0
  24. data/app/cells/lato_core/widgets/index/views/partials/counter.html.erb +3 -0
  25. data/app/cells/lato_core/widgets/index/views/show.html.erb +2 -0
  26. data/app/controllers/lato_core/back/superusers_controller.rb +9 -9
  27. data/app/controllers/lato_core/doc/cells_inputs_controller.rb +28 -0
  28. data/app/views/lato_core/doc/cells_elements/button.html.erb +0 -4
  29. data/app/views/lato_core/doc/cells_elements/modal.html.erb +4 -4
  30. data/app/views/lato_core/doc/cells_inputs/multipleselect.html.erb +110 -0
  31. data/app/views/lato_core/doc/cells_inputs/select.html.erb +48 -2
  32. data/app/views/lato_core/doc/doc/index.html.erb +1 -0
  33. data/app/views/lato_core/doc/general/generators.html.erb +40 -0
  34. data/app/views/layouts/lato_core/partials/_logo.html.erb +7 -5
  35. data/config/languages/default.yml +2 -1
  36. data/config/languages/it.yml +2 -1
  37. data/config/routes/doc.rb +5 -0
  38. data/lib/generators/lato_core/crud_controller_generator.rb +35 -0
  39. data/lib/generators/lato_core/crud_generator.rb +31 -12
  40. data/lib/generators/lato_core/crud_views_generator.rb +52 -0
  41. data/lib/generators/lato_core/initializer_generator.rb +38 -28
  42. data/lib/generators/lato_core/scaffold_generator.rb +30 -0
  43. data/lib/generators/lato_core/templates/crud_controller/app/controllers/lato/crud_controller.rb +94 -0
  44. data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/edit.html.erb +24 -0
  45. data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/index.html.erb +35 -0
  46. data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/new.html.erb +24 -0
  47. data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/shared/_form.html.erb +42 -0
  48. data/lib/generators/lato_core/templates/crud_views/app/views/lato/crud/show.html.erb +22 -0
  49. data/lib/generators/lato_core/templates/{assets → initializer/assets}/images/logo.svg +0 -0
  50. data/lib/generators/lato_core/templates/{assets → initializer/assets}/javascripts/application.js +0 -0
  51. data/lib/generators/lato_core/templates/{assets → initializer/assets}/stylesheets/application.scss +0 -0
  52. data/lib/generators/lato_core/templates/{assets → initializer/assets}/stylesheets/theme.scss.erb +0 -0
  53. data/lib/generators/lato_core/templates/initializer/controllers/application_controller.rb +25 -0
  54. data/lib/generators/lato_core/templates/initializer/views/application/index.html.erb +20 -0
  55. data/lib/lato_core/interfaces/token.rb +4 -3
  56. data/lib/lato_core/version.rb +1 -1
  57. metadata +33 -16
  58. data/app/assets/javascripts/lato_core/initializers/Elements.js +0 -67
  59. data/app/assets/javascripts/lato_core/initializers/Inputs.js +0 -249
  60. data/app/assets/javascripts/lato_core/initializers/inputs/MultipleSelect.js +0 -0
  61. data/lib/generators/lato_core/templates/controllers/application_controller.rb +0 -13
  62. data/lib/generators/lato_core/templates/views/application/index.html.erb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f4211f6915556b1d0fde041227bea548304fce4
4
- data.tar.gz: 8f63acc58fe73ee0818e0f518d8a52c97855d324
3
+ metadata.gz: d03404575f2dc3428326581b02cddb3a8d247aa1
4
+ data.tar.gz: b12942916abaec0b8d60bedaf36a1867e1a0c05e
5
5
  SHA512:
6
- metadata.gz: bb052e5c212bd1d62beecf76842fd462716bf018fca36fb3f617d24960e947d836cb47ee1f9e4566cf935d3b81a51a90f4a7af35a2e54166efcb281ad48b012f
7
- data.tar.gz: abb566a77dc9c1e53287a6920be505c69a2b9bf5488b50857e23a7ac1c504c37e96ad1358e7f4f2562e358b36d23ba493171b4a78b2f26b53ca8a5a338fdc32f
6
+ metadata.gz: ad94e466f6c6dc74c390ab21ae482b9f032dcb4091be16a56ef8e2ae8199e14fe369f28c91a8c04a991b4de2c9e796f48e94e3c7befc0da76f01157bd20236c3
7
+ data.tar.gz: dffaebee14da1902f0447ff94a65d6d3e7fd8b1b5fdabd10e0e9b6aa26989b7cc72f7387c06dcb9dd8a48cb52fe932f9d4271d404909787908ea9dba2b3aede0
@@ -13,16 +13,25 @@
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
15
  //= require_tree ./vendors
16
- //= require_tree ./initializers
17
- //= require_tree ./initializers/inputs
18
- //= require_tree ./interfaces
16
+ //= require_tree ./modules
19
17
 
20
- $(window).load(function () {
21
- InputsInitializer.init()
18
+ $(document).ready(function () {
19
+ CoreButton.init()
20
+ CoreChart.init()
21
+ CoreDatepicker.init()
22
+ CoreFlash.init()
23
+ CoreFormValidator.init()
24
+ CoreLayout.init()
25
+ CoreModal.init()
26
+ CoreSelect.init()
27
+ CoreSortableManager.init()
28
+ CoreTable.init()
29
+ CoreEditor.init()
22
30
  })
23
31
 
24
- $(document).ready(function() {
25
- ChartsInitializer.init()
26
- ElementsInitializer.init()
27
- LayoutInitializer.init()
32
+ $(window).load(function () {
33
+ // DISCUSSION: Messo al load per attendere caricamento dipendenze Google mappe.
34
+ // Valutare se fare un modulo solo per le mappe e spostare solo
35
+ // quelllo al load.
36
+ CoreMediapicker.init()
28
37
  })
@@ -0,0 +1,38 @@
1
+ var CoreButton = (function () {
2
+
3
+ function initializeButtonConfirmation (button) {
4
+ var buttonElement = $(button).find('.elements-button__element')
5
+ $(buttonElement).click(function (e) {
6
+ var dataConfirmation = $(this).attr('data-confirmation')
7
+ if (dataConfirmation && dataConfirmation === 'true') {
8
+ e.preventDefault()
9
+ // find confirmation popup
10
+ var confirmation = $(this).parent().find('.elements-button__confirmation')
11
+ // open confirmation popup
12
+ $(confirmation).addClass('elements-button__confirmation--active')
13
+ // manage delete click
14
+ $(confirmation).find('.button.popup.false').click(function (e) {
15
+ $(confirmation).removeClass('elements-button__confirmation--active')
16
+ e.preventDefault()
17
+ })
18
+ }
19
+ })
20
+ }
21
+
22
+ function _initButtonConfirmation () {
23
+ $('.elements-button').each(function () {
24
+ initializeButtonConfirmation(this)
25
+ })
26
+ }
27
+
28
+ // Init:
29
+ function init () {
30
+ _initButtonConfirmation()
31
+ }
32
+
33
+ return {
34
+ init: init,
35
+ initializeButtonConfirmation: initializeButtonConfirmation
36
+ }
37
+
38
+ })()
@@ -1,11 +1,4 @@
1
- var ChartsInitializer = (function () {
2
-
3
- function initializeBarCharts () {
4
- var charts = $('.charts-bar')
5
- charts.each(function () {
6
- initializeBarChart(this)
7
- })
8
- }
1
+ var CoreChart = (function () {
9
2
 
10
3
  function initializeBarChart (chart) {
11
4
  var chartData = JSON.parse($(chart).find('.charts__metadata').html())
@@ -22,15 +15,22 @@ var ChartsInitializer = (function () {
22
15
  })
23
16
  }
24
17
 
25
- // Init:
18
+ function _initBarCharts () {
19
+ var charts = $('.charts-bar')
20
+ charts.each(function () {
21
+ initializeBarChart(this)
22
+ })
23
+ }
26
24
 
25
+ // Init:
27
26
  function init () {
28
- initializeBarCharts()
27
+ _initBarCharts()
29
28
  }
30
29
 
31
30
  return {
32
- init: init
31
+ init: init,
32
+ initializeBarChart: initializeBarChart
33
33
  }
34
34
 
35
35
  })()
36
-
36
+
@@ -0,0 +1,42 @@
1
+ var CoreDatepicker = (function () {
2
+
3
+ function initializeDatetime (datetime) {
4
+ var datetimeInput = $(datetime).find('.inputs__input--datetime')
5
+ $(datetimeInput).datetimepicker({
6
+ format: 'd/m/Y H:i'
7
+ })
8
+ }
9
+
10
+ function initializeDate (date) {
11
+ var dateInput = $(date).find('.inputs__input--date')
12
+ $(dateInput).datetimepicker({
13
+ timepicker: false,
14
+ format: 'd/m/Y'
15
+ })
16
+ }
17
+
18
+ function _initDatetime () {
19
+ $('.inputs-datetime').each(function () {
20
+ initializeDatetime(this)
21
+ })
22
+ }
23
+
24
+ function _initDate () {
25
+ $('.inputs-date').each(function () {
26
+ initializeDate(this)
27
+ })
28
+ }
29
+
30
+ // Init:
31
+ function init () {
32
+ _initDatetime()
33
+ _initDate()
34
+ }
35
+
36
+ return {
37
+ init: init,
38
+ initializeDate: initializeDate,
39
+ initializeDatetime: initializeDatetime
40
+ }
41
+
42
+ })()
@@ -0,0 +1,27 @@
1
+ var CoreEditor = (function () {
2
+
3
+ function initializeEditor (editor) {
4
+ var editorInput = $(editor).find('.inputs__editor')
5
+ $(editorInput).trumbowyg({
6
+ svgPath: $('#ddtj__editor-icons-path').html()
7
+ })
8
+ }
9
+
10
+ function _initEditor () {
11
+ $('.inputs-editor').each(function () {
12
+ initializeEditor(this)
13
+ })
14
+ }
15
+
16
+ // Init:
17
+ function init () {
18
+ _initEditor()
19
+ }
20
+
21
+ return {
22
+ init: init,
23
+ initializeEditor: initializeEditor
24
+ }
25
+
26
+ })()
27
+
@@ -0,0 +1,27 @@
1
+ var CoreFlash = (function () {
2
+
3
+ function initializeFlashCloseButton (flash) {
4
+ var closeButton = $(flash).find('.elements-flash__close-button')
5
+ $(closeButton).click(function (e) {
6
+ e.preventDefault()
7
+ flash.addClass('elements-flash--hidden')
8
+ })
9
+ }
10
+
11
+ function _initFlashCloseButton () {
12
+ $('.elements-flash').each(function () {
13
+ initializeFlashCloseButton(this)
14
+ })
15
+ }
16
+
17
+ // Init:
18
+ function init () {
19
+ _initFlashCloseButton()
20
+ }
21
+
22
+ return {
23
+ init: init,
24
+ initializeFlashCloseButton: initializeFlashCloseButton
25
+ }
26
+
27
+ })()
@@ -0,0 +1,110 @@
1
+ var CoreFormValidator = (function () {
2
+
3
+ function initializeFormValidation (form) {
4
+ $(form).submit(function (e) {
5
+ $(e.target).find('input').each(function () {
6
+ if (!validateInput(this)) { e.preventDefault() }
7
+ })
8
+ $(e.target).find('select').each(function () {
9
+ if (!validateInput(this)) { e.preventDefault() }
10
+ })
11
+ $(e.target).find('textarea').each(function () {
12
+ if (!validateInput(this)) { e.preventDefault() }
13
+ })
14
+ })
15
+ }
16
+
17
+ function validateInput (input) {
18
+ if ($(input).attr('data-required') && $(input).attr('data-required') === 'true') {
19
+ if (!validateInputRequired(input)) { return false }
20
+ }
21
+
22
+ if ($(input).attr('data-max-length')) {
23
+ if (!validateInputMaxLength(input)) { return false }
24
+ }
25
+
26
+ if ($(input).attr('data-min-length')) {
27
+ if (!validateInputMinLength(input)) { return false }
28
+ }
29
+
30
+ return true
31
+ }
32
+
33
+ function validateInputRequired (input) {
34
+ if ($(input).is(':checkbox')) {
35
+ var inputChecked = $(input).is(':checked')
36
+ if (!inputChecked || inputChecked === null || inputChecked === false) {
37
+ _addInputErrorStyle(input)
38
+ return false
39
+ }
40
+ } else {
41
+ var inputValue = $(input).val()
42
+ if (inputValue === null || inputValue === '' || inputValue === ' ') {
43
+ _addInputErrorStyle(input)
44
+ return false
45
+ }
46
+ }
47
+
48
+ return true
49
+ }
50
+
51
+ function validateInputMaxLength (input) {
52
+ var inputValue = $(input).val()
53
+ if (inputValue !== null && inputValue !== '' && inputValue.length > $(input).attr('data-max-length')) {
54
+ _addInputErrorStyle(input)
55
+ return false
56
+ }
57
+
58
+ return true
59
+ }
60
+
61
+ function validateInputMinLength (input) {
62
+ var inputValue = $(input).val()
63
+ if (inputValue !== null && inputValue !== '' && inputValue.length < $(input).attr('data-min-length')) {
64
+ _addInputErrorStyle(input)
65
+ return false
66
+ }
67
+
68
+ return true
69
+ }
70
+
71
+ function _addInputErrorStyle (input) {
72
+ if ($(input).is('select')) {
73
+ $(input).next().addClass('inputs__select--error')
74
+ $(input).next().click(function () {
75
+ $(this).removeClass('inputs__select--error')
76
+ })
77
+ } else if ($(input).is('textarea')) {
78
+ $(input).addClass('inputs__textarea--error')
79
+ $(input).click(function () {
80
+ $(this).removeClass('inputs__textarea--error')
81
+ })
82
+ } else {
83
+ $(input).addClass('inputs__input--error')
84
+ $(input).focus(function () {
85
+ $(this).removeClass('inputs__input--error')
86
+ })
87
+ }
88
+ }
89
+
90
+ function _initFormValidation () {
91
+ $('.inputs__form').each(function () {
92
+ initializeFormValidation(this)
93
+ })
94
+ }
95
+
96
+ // Init:
97
+ function init () {
98
+ _initFormValidation()
99
+ }
100
+
101
+ return {
102
+ init: init,
103
+ initializeFormValidation: initializeFormValidation,
104
+ validateInput: validateInput,
105
+ validateInputRequired: validateInputRequired,
106
+ validateInputMaxLength: validateInputMaxLength,
107
+ validateInputMinLength: validateInputMinLength
108
+ }
109
+
110
+ })()
@@ -1,5 +1,6 @@
1
- var LayoutInitializer = (function () {
2
- function toggleProfileMenu () {
1
+ var CoreLayout = (function () {
2
+
3
+ function _initToggleProfileMenu () {
3
4
  $('.layout-admin__profile-container').click(function () {
4
5
  // close header widgets
5
6
  $('.layout-admin__widget-container').removeClass('layout-admin__widget-container--active')
@@ -8,7 +9,7 @@ var LayoutInitializer = (function () {
8
9
  })
9
10
  }
10
11
 
11
- function toggleWidget () {
12
+ function _initToggleWidget () {
12
13
  $('.layout-admin__widget-button').click(function (e) {
13
14
  var widgetContainer = $(this).parent()
14
15
  // close profile menu
@@ -26,8 +27,8 @@ var LayoutInitializer = (function () {
26
27
 
27
28
  // Init:
28
29
  function init () {
29
- toggleProfileMenu()
30
- toggleWidget()
30
+ _initToggleProfileMenu()
31
+ _initToggleWidget()
31
32
  }
32
33
 
33
34
  return {
@@ -0,0 +1,140 @@
1
+ var CoreMediapicker = (function () {
2
+
3
+ function initializeDropzone (dropzone) {
4
+ var dropzoneForm = $(dropzone).find('.inputs__dropzone')
5
+ var paramName = $(dropzoneForm).attr('data-param-name')
6
+ var maxFilesize = $(dropzoneForm).attr('data-max-size')
7
+ var maxFiles = $(dropzoneForm).attr('data.max-files')
8
+ $(dropzoneForm).dropzone({
9
+ paramName: paramName,
10
+ maxFilesize: maxFilesize,
11
+ maxFiles: maxFiles
12
+ })
13
+ }
14
+
15
+ function initializeGelocalizationMap (geolocalizationMap) {
16
+ var mapContainer = $(geolocalizationMap).find('.inputs-geolocalization__map')[0]
17
+ var searchBoxInput = $(geolocalizationMap).find('.inputs-geolocalization__search')[0]
18
+ var latInput = $(geolocalizationMap).find('.inputs-geolocalization__input-lat')[0]
19
+ var lngInput = $(geolocalizationMap).find('.inputs-geolocalization__input-lng')[0]
20
+ var addressInput = $(geolocalizationMap).find('.inputs-geolocalization__input-address')[0]
21
+ // initialize map
22
+ var map = new google.maps.Map(mapContainer, {
23
+ zoom: parseInt($(mapContainer).attr('data-default-zoom')),
24
+ center: {
25
+ lat: parseFloat($(mapContainer).attr('data-default-lat')),
26
+ lng: parseFloat($(mapContainer).attr('data-default-lng'))
27
+ },
28
+ mapTypeId: $(mapContainer).attr('data-default-type'),
29
+ streetViewControl: false
30
+ })
31
+ // initialize markers
32
+ var markers = []
33
+ if ($(latInput).val() && $(lngInput).val()) {
34
+ markers.push(new google.maps.Marker({
35
+ map: map,
36
+ position: {lat: parseFloat($(latInput).val()), lng: parseFloat($(lngInput).val())},
37
+ title: $(addressInput).val()
38
+ }))
39
+ }
40
+ // initialize searchbox
41
+ var searchBox = new google.maps.places.SearchBox(searchBoxInput)
42
+ // sync map bounds with search
43
+ map.addListener('bounds_changed', function () {
44
+ searchBox.setBounds(map.getBounds())
45
+ })
46
+ // sync searchbox search with map and hidden inputs
47
+ searchBox.addListener('places_changed', function () {
48
+ // get search palces
49
+ var places = searchBox.getPlaces()
50
+ if (places.length === 0) { return }
51
+ // clean old markers
52
+ markers.forEach(function (marker) { marker.setMap(null) })
53
+ markers = []
54
+ // show first place on map
55
+ var bounds = new google.maps.LatLngBounds()
56
+ var place = places[0]
57
+ if (!place.geometry) { return }
58
+ markers.push(new google.maps.Marker({
59
+ map: map,
60
+ position: place.geometry.location,
61
+ title: place.formatted_address
62
+ }))
63
+ if (place.geometry.viewport) {
64
+ bounds.union(place.geometry.viewport)
65
+ } else {
66
+ bounds.extend(place.geometry.location)
67
+ }
68
+ map.fitBounds(bounds)
69
+ // save place info on hidden inputs
70
+ $(latInput).val(place.geometry.location.lat())
71
+ $(lngInput).val(place.geometry.location.lng())
72
+ $(addressInput).val(place.formatted_address)
73
+ })
74
+ }
75
+
76
+ function initializeYoutube (youtube) {
77
+ var youtubeInput = $(youtube).find('.inputs__input')
78
+ $(youtubeInput).change(function () {
79
+ var inputVal = $(this).val()
80
+ var videoId = _getYoutubeVideoId(inputVal)
81
+ var iframeMarkup = '<iframe src="//www.youtube.com/embed/' + videoId + '" frameborder="0" allowfullscreen></iframe>'
82
+ var videoContainer = $(this).parent().find('.inputs-youtube__video')
83
+ if (inputVal && inputVal !== '') {
84
+ $(videoContainer).html(iframeMarkup)
85
+ $(videoContainer).addClass('inputs-youtube__video--active')
86
+ } else {
87
+ $(videoContainer).html('')
88
+ $(videoContainer).removeClass('inputs-youtube__video--active')
89
+ }
90
+ })
91
+ // trigger initial change
92
+ $(youtubeInput).trigger('change')
93
+ }
94
+
95
+ // function to get youtube video
96
+ function _getYoutubeVideoId (url) {
97
+ var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
98
+ var match = url.match(regExp)
99
+
100
+ if (match && match[2].length === 11) {
101
+ return match[2]
102
+ } else {
103
+ return 'error'
104
+ }
105
+ }
106
+
107
+ function _initDropzone () {
108
+ $('.inputs-dropzone').each(function () {
109
+ initializeDropzone(this)
110
+ })
111
+ }
112
+
113
+ function _initGeolocalizationMap () {
114
+ $('.inputs-geolocalization').each(function () {
115
+ initializeGelocalizationMap(this)
116
+ })
117
+ }
118
+
119
+ function _initYoutube () {
120
+ $('.inputs-youtube').each(function () {
121
+ initializeYoutube(this)
122
+ })
123
+ }
124
+
125
+ // Init:
126
+ function init () {
127
+ _initDropzone()
128
+ _initGeolocalizationMap()
129
+ _initYoutube()
130
+ }
131
+
132
+ return {
133
+ init: init,
134
+ initializeDropzone: initializeDropzone,
135
+ initializeGelocalizationMap: initializeGelocalizationMap,
136
+ initializeYoutube: initializeYoutube
137
+ }
138
+
139
+ })()
140
+