alchemy-custom-model 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +147 -0
  4. data/Rakefile +32 -0
  5. data/app/assets/config/alchemy_custom_model_manifest.js +3 -0
  6. data/app/assets/images/alchemy-custom-model/no_image.png +0 -0
  7. data/app/assets/javascripts/alchemy-custom-model/change_language.js +11 -0
  8. data/app/assets/javascripts/alchemy-custom-model/common_init.js +16 -0
  9. data/app/assets/javascripts/alchemy-custom-model/custom_admin_element_editor.js.coffee +25 -0
  10. data/app/assets/javascripts/alchemy-custom-model/custom_tiny_mce.js.coffee.erb +95 -0
  11. data/app/assets/javascripts/alchemy-custom-model/el_finder.js.coffee.erb +241 -0
  12. data/app/assets/javascripts/alchemy-custom-model/elfinder_ui_manifest.js +4 -0
  13. data/app/assets/javascripts/alchemy-custom-model/manifest.js +23 -0
  14. data/app/assets/javascripts/alchemy-custom-model/nested_attributes_sortable.js.coffee +25 -0
  15. data/app/assets/javascripts/alchemy-custom-model/select2filter.js +51 -0
  16. data/app/assets/javascripts/alchemy-custom-model/subobjects.js +98 -0
  17. data/app/assets/javascripts/alchemy-custom-model/total_page_elfinder.js.coffee +15 -0
  18. data/app/assets/stylesheets/alchemy-custom-model/custom_elfinder.css.scss +130 -0
  19. data/app/assets/stylesheets/alchemy-custom-model/custom_style.css.scss +228 -0
  20. data/app/assets/stylesheets/alchemy-custom-model/custom_tiny_mce.scss +6 -0
  21. data/app/assets/stylesheets/alchemy-custom-model/manifest.css +16 -0
  22. data/app/controllers/alchemy/custom/model/admin/base_controller.rb +189 -0
  23. data/app/controllers/alchemy/custom/model/admin/files_controller.rb +106 -0
  24. data/app/controllers/alchemy/pages_controller_decorator.rb +1 -0
  25. data/app/helpers/alchemy/custom/model/admin/base_helper.rb +379 -0
  26. data/app/helpers/alchemy/custom/model/base_helper.rb +18 -0
  27. data/app/helpers/alchemy/custom/model/custom_model_helper.rb +112 -0
  28. data/app/helpers/alchemy/pages_helper_decorator.rb +95 -0
  29. data/app/models/admin_override_to_param.rb +9 -0
  30. data/app/models/application_record.rb +9 -0
  31. data/app/views/alchemy/custom/model/admin/base/_buttons_tool.html.erb +16 -0
  32. data/app/views/alchemy/custom/model/admin/base/_gallery_item.html.erb +4 -0
  33. data/app/views/alchemy/custom/model/admin/base/_language_tree_select.html.erb +9 -0
  34. data/app/views/alchemy/custom/model/admin/base/_search_box.html.erb +19 -0
  35. data/app/views/alchemy/custom/model/admin/base/_seo.html.erb +8 -0
  36. data/app/views/alchemy/custom/model/admin/base/_table.html.erb +33 -0
  37. data/app/views/alchemy/custom/model/admin/base/_title.html.erb +3 -0
  38. data/app/views/alchemy/custom/model/admin/base/edit.html.erb +18 -0
  39. data/app/views/alchemy/custom/model/admin/base/index.html.erb +39 -0
  40. data/app/views/alchemy/custom/model/admin/base/new.html.erb +19 -0
  41. data/app/views/alchemy/custom/model/admin/files/error_notice.json.jbuilder +1 -0
  42. data/app/views/alchemy/custom/model/admin/files/ui.html.erb +13 -0
  43. data/config/initializers/elfinder_abilities.rb +1 -0
  44. data/config/locales/en.yml +11 -0
  45. data/config/locales/it.yml +21 -0
  46. data/config/routes.rb +8 -0
  47. data/lib/alchemy-custom-model.rb +29 -0
  48. data/lib/alchemy/custom/model/el_finder.rb +17 -0
  49. data/lib/alchemy/custom/model/el_finder/ability.rb +16 -0
  50. data/lib/alchemy/custom/model/el_finder/connector.rb +435 -0
  51. data/lib/alchemy/custom/model/el_finder/image.rb +35 -0
  52. data/lib/alchemy/custom/model/el_finder/path_name.rb +220 -0
  53. data/lib/alchemy/custom/model/el_finder/paths.rb +21 -0
  54. data/lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb +50 -0
  55. data/lib/alchemy/custom/model/el_finder/paths/base.rb +298 -0
  56. data/lib/alchemy/custom/model/el_finder/paths/component_file.rb +59 -0
  57. data/lib/alchemy/custom/model/el_finder/paths/component_files.rb +34 -0
  58. data/lib/alchemy/custom/model/el_finder/paths/file.rb +23 -0
  59. data/lib/alchemy/custom/model/el_finder/paths/files.rb +25 -0
  60. data/lib/alchemy/custom/model/el_finder/paths/image.rb +42 -0
  61. data/lib/alchemy/custom/model/el_finder/paths/images.rb +31 -0
  62. data/lib/alchemy/custom/model/el_finder/paths/root.rb +24 -0
  63. data/lib/alchemy/custom/model/el_finder/volumes.rb +18 -0
  64. data/lib/alchemy/custom/model/el_finder/volumes/alchemy_file.rb +197 -0
  65. data/lib/alchemy/custom/model/el_finder/volumes/alchemy_files.rb +51 -0
  66. data/lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb +69 -0
  67. data/lib/alchemy/custom/model/el_finder/volumes/base.rb +149 -0
  68. data/lib/alchemy/custom/model/el_finder/volumes/component_attribute.rb +130 -0
  69. data/lib/alchemy/custom/model/engine.rb +40 -0
  70. data/lib/alchemy/custom/model/global_id_setter.rb +35 -0
  71. data/lib/alchemy/custom/model/model_decoration.rb +82 -0
  72. data/lib/alchemy/custom/model/pages_controller_dec.rb +132 -0
  73. data/lib/alchemy/custom/model/translation_scope.rb +18 -0
  74. data/lib/alchemy/custom/model/version.rb +7 -0
  75. data/lib/alchemy/touching_decorator.rb +12 -0
  76. data/lib/tasks/alchemy_custom_model_tasks.rake +41 -0
  77. data/vendor/elfinder/css/elfinder.full.css +5117 -0
  78. data/vendor/elfinder/css/elfinder.min.css +9 -0
  79. data/vendor/elfinder/css/theme.css +349 -0
  80. data/vendor/elfinder/js/elfinder.full.js +34270 -0
  81. data/vendor/elfinder/js/elfinder.min.js +25 -0
  82. metadata +194 -0
@@ -0,0 +1,4 @@
1
+ //= require jquery
2
+ //= require jquery-ui
3
+ //= require "./el_finder"
4
+ //= require "./total_page_elfinder"
@@ -0,0 +1,23 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery-ui
14
+ //= require "./custom_tiny_mce"
15
+ //= require "./custom_admin_element_editor"
16
+ //= require "./nested_attributes_sortable"
17
+ //= require "./change_language"
18
+ //= require "./subobjects"
19
+ //= require select2_locale_it
20
+ //= require "./select2filter"
21
+ //= require "./el_finder"
22
+ //= require "./total_page_elfinder"
23
+ //= require "./common_init"
@@ -0,0 +1,25 @@
1
+ $ = jQuery
2
+
3
+ # Adds plugin object to jQuery
4
+ $.fn.extend
5
+ nested_attributes_sortable: (options) ->
6
+ # Default settings
7
+ settings =
8
+ field: null #campo obbligatorio
9
+
10
+ # Merge default settings with options.
11
+ settings = $.extend settings, options
12
+
13
+ console.error('field required for nested_attributes_sortable') if settings.field == ''
14
+
15
+ return @each ()->
16
+ $(@).sortable(
17
+ update: (event, ui)->
18
+ console.log(arguments);
19
+ $(event.target).find(settings.field).each (i)->
20
+ $(@).val(i)
21
+ $(event.target).find('*').trigger('parent_sorted', event.target);
22
+ stop:(event)->
23
+ $(event.target).find('*').trigger('parent_stop_sorted', event.target);
24
+ );
25
+ $(@).disableSelection();
@@ -0,0 +1,51 @@
1
+ (function ($) {
2
+
3
+ $.fn.select2filter = function (options) {
4
+
5
+ var options = $.extend({
6
+ elementToFilter: "",
7
+ hideparam: "to-hide-id"
8
+ }, options);
9
+
10
+ if (options.elementToFilter === "") {
11
+ throw "select2filter: You have to specify elementToFilter option";
12
+ }
13
+
14
+
15
+ return this.each(function (index, element) {
16
+ var allOptions = $(options.elementToFilter).find("option");
17
+ if ($(options.elementToFilter).val() == "") {
18
+ $(options.elementToFilter).prop("disabled", true);
19
+ }
20
+ var select = this
21
+
22
+ $(this).change(function (event) {
23
+
24
+ if ($(element).val() != "") {
25
+ $(options.elementToFilter).select2("destroy");
26
+ $(options.elementToFilter).html(allOptions);
27
+ $(options.elementToFilter).val(null);
28
+
29
+ $(options.elementToFilter).find("option").each(function (index, element) {
30
+ var selectedValue = $(select).val();
31
+ if ($(this).val() != "" && $(this).attr("data-" + options.hideparam) != selectedValue) {
32
+ $(this).remove();
33
+ }
34
+ });
35
+
36
+ $(options.elementToFilter).prop("disabled", false);
37
+ $(options.elementToFilter).select2({
38
+ //allowClear: true,
39
+ minimumResultsForSearch: 7,
40
+ dropdownAutoWidth: true
41
+
42
+ });
43
+
44
+
45
+ }
46
+ });
47
+ })
48
+
49
+ }
50
+
51
+ })(jQuery);
@@ -0,0 +1,98 @@
1
+ (function ($) {
2
+
3
+ $.fn.subobjects = function (options) {
4
+
5
+ var options = $.extend(options, {});
6
+
7
+
8
+ function maximizza(row) {
9
+ var last_element = $(row).find(".fields").find(".input").not(".hidden").last()[0];
10
+ var height = $(last_element).offset().top - row.offset().top;
11
+ row.height(height + $(last_element).height());
12
+ }
13
+
14
+
15
+ function minimizza(row) {
16
+
17
+ var first_element = $(row).find(".fields").find(".input").not(".hidden").first()[0];
18
+ var height = $(first_element).offset().top - row.offset().top;
19
+ row.height(height + $(first_element).height());
20
+ }
21
+
22
+
23
+ return this.each(function (index, element) {
24
+ var subObjContainer = $(this).find(".sub_objects_container")[0];
25
+
26
+ $(subObjContainer).nested_attributes_sortable({field: '.sortable_field'});
27
+
28
+ var buttonAdd = $(this).find(".add").get(0);
29
+ $(buttonAdd).on("click", function (event) {
30
+ event.preventDefault();
31
+ var url_partial = $(buttonAdd).data("url");
32
+ var element_to_load = $(buttonAdd).data("to-load");
33
+
34
+ $.ajax({
35
+ url: url_partial,
36
+ dataType: "html",
37
+ method: "GET",
38
+ success: function (data, textStatus, jqXHR) {
39
+ var to_load = $(data).find(element_to_load);
40
+ var to_load_id = $(to_load).last().next("input");
41
+ $(to_load).removeClass("sample");
42
+ $(subObjContainer).append($(to_load).last());
43
+ $(subObjContainer).append(to_load_id);
44
+
45
+ },
46
+ error: function (jqXHR, textStatus, errorThrown) {
47
+ console.error(errorThrown)
48
+ }
49
+ });
50
+ });
51
+
52
+
53
+ var buttonMaximizeAll = $(this).find(".maximize_all").get(0);
54
+ $(buttonMaximizeAll).on("click", function (event) {
55
+ event.preventDefault();
56
+ $(subObjContainer).find(".subobject_row:not('.sample')").each(function (index, element) {
57
+ maximizza($(element));
58
+ });
59
+ });
60
+
61
+
62
+ var buttonMinimizeAll = $(this).find(".minimize_all").get(0);
63
+ $(buttonMinimizeAll).on("click", function (event) {
64
+ event.preventDefault();
65
+ $(subObjContainer).find(".subobject_row:not('.sample')").each(function (index, element) {
66
+ minimizza($(element));
67
+ });
68
+ });
69
+
70
+
71
+ $(this).on('click', ".subobject_row .remove", function (event) {
72
+ event.preventDefault();
73
+ var buttonRemove = event.target
74
+
75
+ var toHide = $(this).closest(".subobject_row");
76
+ var destroyField = $(this).find("input")[0];
77
+ $(destroyField).val(true);
78
+ $(toHide).hide(500);
79
+
80
+
81
+ });
82
+
83
+ $(this).on('click', ".subobject_row .minimize", function (event) {
84
+ event.preventDefault();
85
+ minimizza($(this).closest(".subobject_row"));
86
+ })
87
+
88
+ $(this).on('click', ".subobject_row .maximize", function (event) {
89
+ event.preventDefault();
90
+ maximizza($(this).closest(".subobject_row"));
91
+ });
92
+
93
+
94
+ });
95
+ }
96
+
97
+ })(jQuery);
98
+
@@ -0,0 +1,15 @@
1
+ $ ->
2
+ if($('#elfinder').size()>0)
3
+ datas = $('#elfinder').data()
4
+
5
+ elf = new ElFinderConfigurator(
6
+ mode: 'single_selection',
7
+ volumes: datas['elfinderVolumes']
8
+ )
9
+
10
+ elf.once 'file_select', (file,fm)->
11
+ parent.tinymce.activeEditor.windowManager.getParams().oninsert(file, fm);
12
+ parent.tinymce.activeEditor.windowManager.close();
13
+
14
+ elf.start($('#elfinder'))
15
+
@@ -0,0 +1,130 @@
1
+ //= require jquery-ui
2
+ //= require elfinder/css/elfinder.min
3
+ //= require elfinder/css/theme
4
+
5
+ .elfinder_picture_gallery {
6
+ .blk_container_immagini {
7
+ background-color: #d8d8d8;
8
+ width: 85%;
9
+ display: block;
10
+ float: left;
11
+
12
+ .gallery_item_blk {
13
+ display: block;
14
+ float: left;
15
+ margin: 6px;
16
+ width: 100px;
17
+ height: 100px;
18
+ overflow: hidden;
19
+
20
+ .open_el_finder {
21
+ width: 98%;
22
+ height: 98%;
23
+ margin: auto;
24
+ display: block;
25
+ background-color: rgba(236, 169, 110, 0.75);
26
+ text-align: center;
27
+
28
+ i.fa-images {
29
+ font-size: 50px;
30
+ margin-top: 20px;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ .elfinder_picture_thumbnail {
38
+
39
+ margin: 8px;
40
+ background-color: #fff;
41
+ display: inline-block;
42
+ position: relative;
43
+ box-shadow: 0 0 0 1px rgba(175, 175, 175, 0.5);
44
+ width: 160px;
45
+ height: 140px;
46
+
47
+ .picture_image {
48
+ height: 100px;
49
+ width: 100px;
50
+ display: block;
51
+ margin: 5px auto 5px auto;
52
+
53
+ }
54
+
55
+ .edit_images_bottom {
56
+ position: absolute;
57
+ display: flex;
58
+ justify-content: space-between;
59
+ left: 0;
60
+ bottom: 0;
61
+ z-index: 0;
62
+ width: 100%;
63
+ padding: 4px 2px;
64
+ background-color: #f0f0f0;
65
+
66
+ a {
67
+ margin: 0 2px;
68
+ padding: 2px;
69
+ cursor: pointer;
70
+ }
71
+ }
72
+
73
+ }
74
+
75
+ /* Nascondo il pulsante save_as nell'editing di un'immagine */
76
+ .elfinder-dialog {
77
+ .ui-dialog-buttonset {
78
+ .elfinder-btncnt-1 {
79
+ display: none;
80
+ }
81
+ }
82
+ }
83
+
84
+ .elfinder_attachment {
85
+ margin: 8px;
86
+ background-color: #fff;
87
+ display: inline-block;
88
+ position: relative;
89
+ box-shadow: 0 0 0 1px rgba(175, 175, 175, 0.5);
90
+ width: 80px;
91
+ height: 80px;
92
+
93
+ .attachment_file {
94
+ height: 50px;
95
+ width: 50px;
96
+ display: block;
97
+ margin: 5px auto 5px auto;
98
+
99
+ }
100
+
101
+ .container_icon_container {
102
+ padding: 3px;
103
+ }
104
+
105
+ .edit_file_bottom {
106
+ position: absolute;
107
+ display: flex;
108
+ justify-content: space-between;
109
+ left: 0;
110
+ bottom: 0;
111
+ z-index: 0;
112
+ width: 100%;
113
+ padding: 4px 2px;
114
+ background-color: #f0f0f0;
115
+
116
+ a {
117
+ margin: 0 2px;
118
+ padding: 2px;
119
+ cursor: pointer;
120
+ }
121
+ }
122
+
123
+ }
124
+
125
+ /* Modifiche stile elfinder*/
126
+ .elfinder {
127
+ .elfinder-preference-tabs {
128
+ clear: both;
129
+ }
130
+ }
@@ -0,0 +1,228 @@
1
+ .base_form_container {
2
+
3
+ .category_tree {
4
+
5
+ &.sortable, &.margined {
6
+ padding-top: 100px;
7
+ }
8
+
9
+ &.sortable_products.margined {
10
+ padding-top: 5px;
11
+ }
12
+
13
+ .category_block, .product_block {
14
+
15
+ height: 32px;
16
+ margin: 12px 0;
17
+ position: relative;
18
+ transition: background-color 250ms;
19
+
20
+ &:hover {
21
+ background-color: rgba(251, 251, 216, 0.5);
22
+ border-radius: 3px;
23
+ }
24
+
25
+ .icon {
26
+ position: relative;
27
+ width: 32px;
28
+ line-height: 32px;
29
+ float: left;
30
+ padding: 0 8px;
31
+ text-align: center;
32
+ }
33
+
34
+ .category, .product {
35
+ border-bottom-left-radius: 3px;
36
+ border-top-left-radius: 3px;
37
+ line-height: 28px;
38
+ overflow: hidden;
39
+ background-color: rgba(255, 255, 255, 0.75);
40
+
41
+ .name {
42
+ display: block;
43
+ padding: 0 10px;
44
+ margin: 2px;
45
+ text-decoration: none;
46
+ }
47
+
48
+ &.disabled {
49
+ background-color: #efefef;
50
+ }
51
+ }
52
+
53
+ .right_tools {
54
+ height: 32px;
55
+ padding: 0 8px;
56
+ float: right;
57
+
58
+ .tool {
59
+ float: left;
60
+ width: 32px;
61
+ height: 32px;
62
+ line-height: 32px;
63
+ text-align: center;
64
+ margin: 0;
65
+ position: relative;
66
+ display: inline-block;
67
+ }
68
+ }
69
+ }
70
+ }
71
+
72
+ .form_in_page {
73
+ width: 80% !important;
74
+
75
+ form .control-label {
76
+ width: 15%;
77
+ }
78
+
79
+ form {
80
+ input[type="url"],
81
+ input[type="text"],
82
+ input[type="email"],
83
+ input[type="password"],
84
+ textarea,
85
+ .select2-container,
86
+ .mce-tinymce,
87
+ .with-hint{
88
+ width: 85%;
89
+ }
90
+ .tinymce_container {
91
+ width: 85%;
92
+ float: left;
93
+ }
94
+ .input.boolean {
95
+ margin-left: 15%;
96
+ }
97
+ }
98
+
99
+ /*form {
100
+
101
+ .input {
102
+ margin: 5px 0px 5px 0px;
103
+ padding: 0px 5px;
104
+
105
+ label {
106
+ display: block;
107
+ float: none;
108
+ text-align: left;
109
+ width: 100%;
110
+ }
111
+
112
+ input,textarea, select, .select2-container{
113
+ float: none;
114
+ }
115
+
116
+ select {
117
+ width: 65%;
118
+ margin: 4px 0;
119
+ }
120
+
121
+ input[type='checkbox'] {
122
+ float: left;
123
+ }
124
+
125
+ .tinymce_container {
126
+ float: none;
127
+ }
128
+ }
129
+ } */
130
+
131
+ .subobjects {
132
+
133
+ .sub_objects_container {
134
+ margin-top: 10px;
135
+ }
136
+
137
+ .subobject_row.sample {
138
+ display: none;
139
+ }
140
+
141
+ legend {
142
+ float: left;
143
+ line-height: 35px;
144
+ margin-right: 10px;
145
+ width: 100%;
146
+ }
147
+ .buttons {
148
+ text-align: right;
149
+ }
150
+ .subobject_row {
151
+ background-color: #d8d8d8;
152
+ margin-bottom: 10px;
153
+ padding-right: 10px;
154
+ padding-top: 3px;
155
+ overflow: hidden;
156
+ border-radius: 3px;
157
+ border: 1px solid #c0c0c0;
158
+ }
159
+
160
+ .remove {
161
+ .icon_button {
162
+ i {
163
+ color: red;
164
+ }
165
+ }
166
+ }
167
+ }
168
+ }
169
+
170
+ .field_with_errors {
171
+ .error {
172
+ display: block;
173
+ color: #a23434;
174
+ padding-left: 15%;
175
+ }
176
+ }
177
+
178
+ .after_save_messages{
179
+ margin-left: 15%;
180
+ }
181
+
182
+ }
183
+
184
+ .main_navi_entry {
185
+ line-height: 25px;
186
+ }
187
+
188
+ .form_cloner{
189
+ .error{
190
+ padding-left: 35%;
191
+ color: #a23434;
192
+ }
193
+ }
194
+
195
+ .alchemy-dialog-container{
196
+ .base-errors{
197
+ color: #a23434;
198
+ }
199
+ }
200
+
201
+ #toolbar{
202
+ .current_site_language{
203
+ position: absolute;
204
+ right: 255px;
205
+ top: 13px;
206
+ color: rgba(51, 59, 81, 0.8);
207
+
208
+ strong{
209
+ font-size: 15px;
210
+ }
211
+ }
212
+ }
213
+
214
+
215
+ .edit_ingredients{
216
+
217
+ .preparation{
218
+ padding: 15px;
219
+
220
+ fieldset{
221
+
222
+ .text{
223
+ padding-left: 15px
224
+ }
225
+ }
226
+ }
227
+ }
228
+