kirgudu_base 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/kirgudu_base/dynamicEvents.js +2 -1
  3. data/app/assets/javascripts/kirgudu_base/jquery.container-management.js +241 -0
  4. data/app/assets/javascripts/kirgudu_base/jquery.fancybox copia.js +2020 -0
  5. data/app/assets/javascripts/kirgudu_base/scripts_nrg.js +300 -383
  6. data/app/controllers/kirgudu_base/admin_controller.rb +1 -44
  7. data/app/controllers/kirgudu_base/application_controller.rb +135 -92
  8. data/app/controllers/kirgudu_base/cabinet_controller.rb +35 -35
  9. data/app/controllers/kirgudu_base/security/authentications_controller.rb +452 -0
  10. data/app/controllers/kirgudu_base/security/email_confirmations_controller.rb +46 -0
  11. data/app/helpers/kirgudu_base/application_helper.rb +25 -0
  12. data/app/helpers/kirgudu_base/authentication_form_builder.rb +76 -0
  13. data/app/helpers/kirgudu_base/controllers/{basic_actions_with_parent.rb → OLD_basic_actions.rb} +39 -54
  14. data/app/helpers/kirgudu_base/controllers/basic_actions.rb +967 -161
  15. data/app/helpers/kirgudu_base/controllers/container_items_management_actions.rb +118 -40
  16. data/app/helpers/kirgudu_base/controllers/container_items_sorting_actions.rb +2 -2
  17. data/app/helpers/kirgudu_base/controllers/dynamic_pages.rb +147 -11
  18. data/app/helpers/kirgudu_base/form_builder.rb +3 -1
  19. data/app/helpers/kirgudu_base/gui_helper.rb +10 -5
  20. data/app/helpers/kirgudu_base/models/exports.rb +122 -122
  21. data/app/helpers/kirgudu_base/models/scopes.rb +5 -0
  22. data/app/mailers/authentications_mailer.rb +53 -0
  23. data/app/models/kirgudu_base/base_model.rb +47 -14
  24. data/app/models/kirgudu_base/dynamic_pages/builder.rb +0 -8
  25. data/app/models/kirgudu_base/dynamic_pages/controller_link.rb +4 -1
  26. data/app/models/kirgudu_base/dynamic_pages/controller_link_builder.rb +2 -1
  27. data/app/models/kirgudu_base/dynamic_pages/controller_link_id.rb +6 -6
  28. data/app/models/kirgudu_base/dynamic_pages/controller_link_id_builder.rb +6 -6
  29. data/app/models/kirgudu_base/dynamic_pages/element.rb +4 -5
  30. data/app/models/kirgudu_base/dynamic_pages/entry_builder.rb +2 -2
  31. data/app/models/kirgudu_base/dynamic_pages/event_if_block_builder.rb +1 -1
  32. data/app/models/kirgudu_base/dynamic_pages/form_builder.rb +2 -2
  33. data/app/models/kirgudu_base/dynamic_pages/list.rb +2 -0
  34. data/app/models/kirgudu_base/dynamic_pages/list_builder.rb +7 -3
  35. data/app/models/kirgudu_base/dynamic_pages/management_settings.rb +30 -0
  36. data/app/models/kirgudu_base/dynamic_pages/management_settings_builder.rb +47 -0
  37. data/app/models/kirgudu_base/dynamic_pages/menu.rb +9 -5
  38. data/app/models/kirgudu_base/dynamic_pages/menu_builder.rb +8 -5
  39. data/app/models/kirgudu_base/dynamic_pages/menu_item.rb +22 -6
  40. data/app/models/kirgudu_base/dynamic_pages/menu_items_block_builder.rb +9 -4
  41. data/app/models/kirgudu_base/dynamic_pages/menu_section.rb +38 -0
  42. data/app/models/kirgudu_base/dynamic_pages/menu_section_builder.rb +36 -0
  43. data/app/models/kirgudu_base/dynamic_pages/page.rb +6 -2
  44. data/app/models/kirgudu_base/dynamic_pages/page_builder.rb +18 -0
  45. data/app/models/kirgudu_base/dynamic_pages/relation.rb +23 -0
  46. data/app/models/kirgudu_base/dynamic_pages/relation_builder.rb +35 -0
  47. data/app/models/kirgudu_base/dynamic_pages/sorting_settings.rb +31 -0
  48. data/app/models/kirgudu_base/dynamic_pages/sorting_settings_builder.rb +48 -0
  49. data/app/models/kirgudu_base/security/autheintication.rb +4 -0
  50. data/app/models/kirgudu_base/security/authentication.rb +6 -7
  51. data/app/models/kirgudu_base/security/email_confirmation.rb +7 -0
  52. data/app/models/kirgudu_base/security/restore_password_code.rb +5 -0
  53. data/app/models/kirgudu_base/security/user.rb +2 -0
  54. data/app/models/kirgudu_base/security.rb +6 -7
  55. data/app/models/kirgudu_base/settings/group.rb +22 -0
  56. data/app/models/kirgudu_base/settings/option.rb +44 -0
  57. data/app/models/kirgudu_base/settings/settings_manager.rb +69 -0
  58. data/app/models/kirgudu_base/settings/value.rb +36 -0
  59. data/app/views/admin_templates/default/admin/layouts/application.html.erb +6 -4
  60. data/app/views/admin_templates/default/admin/system/settings/groups/edit.html.erb +9 -9
  61. data/app/views/admin_templates/default/admin/system/settings/groups/new.html.erb +1 -1
  62. data/app/views/admin_templates/default/admin/system/settings/options/edit.html.erb +1 -1
  63. data/app/views/admin_templates/default/admin/system/settings/options/new.html.erb +1 -1
  64. data/app/views/admin_templates/default/admin/system/settings/values/edit.html.erb +1 -1
  65. data/app/views/admin_templates/default/admin/system/settings/values/new.html.erb +1 -1
  66. data/app/views/admin_templates/erp/admin/shared/_top_nav_bar.html.erb +1 -3
  67. data/app/views/admin_templates/erp/admin/shared/entry_edit_form_renderer.html.erb +1 -1
  68. data/app/views/admin_templates/erp/admin/shared/entry_new_form_renderer.html.erb +1 -1
  69. data/app/views/admin_templates/good/admin/layouts/OLD_application.html.erb +14 -14
  70. data/app/views/admin_templates/good/admin/layouts/application.html.erb +11 -113
  71. data/app/views/admin_templates/good/admin/shared/_left_menu.html.erb +74 -63
  72. data/app/views/admin_templates/good/{zapanel/files/New Adobe Photoshop Image 12.psd → admin/shared/_left_menu_item.html.erb} +0 -0
  73. data/app/views/admin_templates/good/admin/shared/_left_menu_section.html.erb +21 -0
  74. data/app/views/admin_templates/good/admin/shared/render_new_OLD.html.erb +90 -0
  75. data/app/views/admin_templates/good/admin/shared/renderer_edit.html.erb +44 -13
  76. data/app/views/admin_templates/good/admin/shared/renderer_edit_OLD.html.erb +106 -0
  77. data/app/views/admin_templates/good/admin/shared/renderer_entries_list.html.erb +39 -18
  78. data/app/views/admin_templates/good/admin/shared/renderer_entries_list_with_parent.html.erb +4 -4
  79. data/app/views/admin_templates/good/admin/shared/renderer_management.html.erb +164 -0
  80. data/app/views/admin_templates/good/admin/shared/renderer_new.html.erb +40 -10
  81. data/app/views/admin_templates/good/admin/shared/renderer_show.html.erb +170 -58
  82. data/app/views/admin_templates/good/admin/shared/renderer_show_OLD.html.erb +159 -0
  83. data/app/views/admin_templates/good/admin/shared/renderer_sorting.html.erb +30 -0
  84. data/app/views/admin_templates/good/kirgudu_base/authentications/login.html.erb +13 -13
  85. data/app/views/admin_templates/good/kirgudu_base/authentications/register.html.erb +1 -1
  86. data/app/views/admin_templates/good/kirgudu_base/old/login_page.html.erb +7 -7
  87. data/app/views/admin_templates/good_flexy/admin/layouts/application.html.erb +17 -16
  88. data/app/views/admin_templates/good_flexy/admin/shared/_left_menu.html.erb +7 -0
  89. data/app/views/admin_templates/good_flexy/admin/shared/renderer_entries_list.html.erb +25 -17
  90. data/app/views/admin_templates/good_flexy/admin/shared/renderer_form_edit.html.erb +34 -13
  91. data/app/views/admin_templates/good_flexy/admin/shared/renderer_form_new.html.erb +31 -10
  92. data/app/views/admin_templates/good_flexy/admin/shared/renderer_show.html.erb +67 -52
  93. data/config/locales/kirgudu_base.ru.yml +92 -0
  94. data/config/routes.rb +16 -16
  95. data/db/migrate/20140413134252_create_kirgudu_base_security_authentications.rb +15 -0
  96. data/db/migrate/20140413152144_create_kirgudu_base_security_email_confirmations.rb +17 -0
  97. data/db/migrate/20140413201121_add_confirmations_kirgudu_base_security_users.rb +14 -0
  98. data/db/migrate/20140415093106_create_kirgudu_base_security_restore_password_codes.rb +20 -0
  99. data/lib/kirgudu_base.rb +2 -2
  100. data/test/fixtures/kirgudu_base/kirgudu_base/security/autheintications.yml +11 -0
  101. data/test/fixtures/kirgudu_base/security/applications.yml +21 -0
  102. data/test/fixtures/kirgudu_base/security/autheintications.yml +11 -0
  103. data/test/fixtures/kirgudu_base/security/authentications.yml +11 -0
  104. data/test/fixtures/kirgudu_base/security/email_confirmations.yml +13 -0
  105. data/test/fixtures/kirgudu_base/security/restore_password_codes.yml +13 -0
  106. data/test/models/kirgudu_base/kirgudu_base/security/autheintication_test.rb +9 -0
  107. data/test/models/kirgudu_base/security/application_test.rb +9 -0
  108. data/test/models/kirgudu_base/security/autheintication_test.rb +9 -0
  109. data/test/models/kirgudu_base/security/authentication_test.rb +9 -0
  110. data/test/models/kirgudu_base/security/email_confirmation_test.rb +9 -0
  111. data/test/models/kirgudu_base/security/restore_password_code_test.rb +9 -0
  112. metadata +102 -79
  113. data/app/assets/javascripts/kirgudu_base/jquery.fancybox.pack.js +0 -45
  114. data/app/controllers/kirgudu_base/authentications_controller.rb +0 -157
  115. data/app/views/admin_templates/good/zapanel/404.html +0 -386
  116. data/app/views/admin_templates/good/zapanel/billing.html +0 -550
  117. data/app/views/admin_templates/good/zapanel/blank-page.html +0 -343
  118. data/app/views/admin_templates/good/zapanel/buttons.html +0 -1018
  119. data/app/views/admin_templates/good/zapanel/calendars.html +0 -451
  120. data/app/views/admin_templates/good/zapanel/cart.html +0 -522
  121. data/app/views/admin_templates/good/zapanel/charts.html +0 -611
  122. data/app/views/admin_templates/good/zapanel/collapse.html +0 -555
  123. data/app/views/admin_templates/good/zapanel/contact.php +0 -102
  124. data/app/views/admin_templates/good/zapanel/dashboard.html +0 -985
  125. data/app/views/admin_templates/good/zapanel/dashboard2.html +0 -1091
  126. data/app/views/admin_templates/good/zapanel/dashboard3.html +0 -1079
  127. data/app/views/admin_templates/good/zapanel/data/movies.json +0 -1
  128. data/app/views/admin_templates/good/zapanel/faq.html +0 -435
  129. data/app/views/admin_templates/good/zapanel/file-manager.html +0 -358
  130. data/app/views/admin_templates/good/zapanel/files/index.php +0 -0
  131. data/app/views/admin_templates/good/zapanel/font-awesome/less/bootstrap.less +0 -84
  132. data/app/views/admin_templates/good/zapanel/font-awesome/less/core.less +0 -129
  133. data/app/views/admin_templates/good/zapanel/font-awesome/less/extras.less +0 -93
  134. data/app/views/admin_templates/good/zapanel/font-awesome/less/font-awesome-ie7.less +0 -1953
  135. data/app/views/admin_templates/good/zapanel/font-awesome/less/font-awesome.less +0 -33
  136. data/app/views/admin_templates/good/zapanel/font-awesome/less/icons.less +0 -381
  137. data/app/views/admin_templates/good/zapanel/font-awesome/less/mixins.less +0 -48
  138. data/app/views/admin_templates/good/zapanel/font-awesome/less/path.less +0 -14
  139. data/app/views/admin_templates/good/zapanel/font-awesome/less/variables.less +0 -735
  140. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_bootstrap.scss +0 -84
  141. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_core.scss +0 -129
  142. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_extras.scss +0 -93
  143. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_icons.scss +0 -381
  144. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_mixins.scss +0 -48
  145. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_path.scss +0 -14
  146. data/app/views/admin_templates/good/zapanel/font-awesome/scss/_variables.scss +0 -734
  147. data/app/views/admin_templates/good/zapanel/font-awesome/scss/font-awesome-ie7.scss +0 -1953
  148. data/app/views/admin_templates/good/zapanel/font-awesome/scss/font-awesome.scss +0 -33
  149. data/app/views/admin_templates/good/zapanel/form.html +0 -790
  150. data/app/views/admin_templates/good/zapanel/gallery.html +0 -392
  151. data/app/views/admin_templates/good/zapanel/grids.html +0 -574
  152. data/app/views/admin_templates/good/zapanel/hosting-dashboard.html +0 -448
  153. data/app/views/admin_templates/good/zapanel/icon.html +0 -722
  154. data/app/views/admin_templates/good/zapanel/inbox.html +0 -375
  155. data/app/views/admin_templates/good/zapanel/index.html +0 -48
  156. data/app/views/admin_templates/good/zapanel/invoice.html +0 -423
  157. data/app/views/admin_templates/good/zapanel/js/proxy/elFinderSupportVer1.js +0 -338
  158. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-close.png +0 -0
  159. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-next.png +0 -0
  160. data/app/views/admin_templates/good/zapanel/js/skins/default/lightbox-prev.png +0 -0
  161. data/app/views/admin_templates/good/zapanel/notification.html +0 -400
  162. data/app/views/admin_templates/good/zapanel/order-recieved.html +0 -348
  163. data/app/views/admin_templates/good/zapanel/php/MySQLStorage.sql +0 -23
  164. data/app/views/admin_templates/good/zapanel/php/connector.php +0 -44
  165. data/app/views/admin_templates/good/zapanel/php/elFinder.class.php +0 -1103
  166. data/app/views/admin_templates/good/zapanel/php/elFinderConnector.class.php +0 -133
  167. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeDriver.class.php +0 -3370
  168. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeLocalFileSystem.class.php +0 -835
  169. data/app/views/admin_templates/good/zapanel/php/elFinderVolumeMySQL.class.php +0 -896
  170. data/app/views/admin_templates/good/zapanel/php/mime.types +0 -512
  171. data/app/views/admin_templates/good/zapanel/price-table.html +0 -400
  172. data/app/views/admin_templates/good/zapanel/profile.html +0 -387
  173. data/app/views/admin_templates/good/zapanel/progressbar.html +0 -555
  174. data/app/views/admin_templates/good/zapanel/range-slider.html +0 -440
  175. data/app/views/admin_templates/good/zapanel/ribbon-grids.html +0 -491
  176. data/app/views/admin_templates/good/zapanel/sale-purchase-dashboard.html +0 -803
  177. data/app/views/admin_templates/good/zapanel/search.html +0 -370
  178. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-close.png +0 -0
  179. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-loading.gif +0 -0
  180. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-next.png +0 -0
  181. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-pause.png +0 -0
  182. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-play.png +0 -0
  183. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-playvideo.png +0 -0
  184. data/app/views/admin_templates/good/zapanel/skins/default/lightbox-prev.png +0 -0
  185. data/app/views/admin_templates/good/zapanel/slider.html +0 -453
  186. data/app/views/admin_templates/good/zapanel/tables.html +0 -470
  187. data/app/views/admin_templates/good/zapanel/typography.html +0 -746
@@ -13,74 +13,136 @@ module KirguduBase
13
13
 
14
14
 
15
15
  module InstanceMethods
16
- def managing_items_index
17
- @container = get_managing_container_class.find(params[get_managing_parent_id_key])
18
- @items = get_managing_item_class.where(container_id: @container).order(:sort_position).page(params[:page_id])
16
+ def management_items_index
19
17
 
20
- @managing_item_class = get_managing_item_class.to_s
21
- @managing_container_class = get_managing_container_class.to_s
18
+ management_settings = self.class.get_kb_option(:management_settings)
19
+
20
+ filters_4_container = {}
21
+ self.fill_obligatory_filters(filters_4_container)
22
+
23
+ local_data = {}
24
+
25
+ local_data[:management_settings] = management_settings
26
+
27
+ local_container = management_settings.container_class.get_entry_by_id(params[management_settings.container_id_property], filters_4_container, {logger: string_logger})
28
+ local_data[:container] = local_container
29
+
30
+ filters_4_items = {}
31
+ self.fill_obligatory_filters(filters_4_items)
32
+ filters_4_items[management_settings.container_id_property] = params[management_settings.container_id_property]
33
+
34
+ local_items = management_settings.item_class.get_entries(nil, filters_4_items, {logger: string_logger})
35
+ local_data[:items] = local_items
22
36
 
23
- views_path = get_managing_views_path if self.respond_to?(:get_managing_views_path)
24
- views_path = "/shared/manage_items/" unless views_path
25
37
 
26
38
  respond_to do |format|
27
- format.html { render_html1("#{views_path}managing_items_index") }
28
- format.json { render json: @container }
39
+ format.html { render_html1(self.class.get_method_latest_result(:get_kb_view_path, :index), locals: { data: local_data}) }
40
+ format.json { render json: local_data }
29
41
  end
30
42
  end
31
43
 
32
- def managing_items_manage
33
- @container = get_managing_container_class.find(params[get_managing_parent_id_key])
34
- @items = get_managing_item_class.where(container_id: @container).order(:sort_position).page(params[:cpage])
44
+ def management_items_manage
35
45
 
36
- @managing_item_class = get_managing_item_class.to_s
37
- @managing_container_class = get_managing_container_class.to_s
46
+ local_data = {}
38
47
 
48
+ # gettting management settings
49
+ management_settings = self.class.get_kb_option(:management_settings)
50
+ local_data[:management_settings] = management_settings
39
51
 
40
- container_all_items_ids = Array.new
52
+ #loading container data
53
+ filters_4_container = {}
54
+ self.fill_obligatory_filters(filters_4_container)
41
55
 
42
- get_managing_item_class.where(container_id: @container.id).map { |u| container_all_items_ids.push(u.entry_id) }
56
+ local_container = management_settings.container_class.get_entry_by_id(params[management_settings.container_id_property], filters_4_container, {logger: string_logger})
57
+ local_data[:container] = local_container
43
58
 
59
+ #loading items data
60
+ filters_4_items = {}
61
+ self.fill_obligatory_filters(filters_4_items)
62
+ filters_4_items[management_settings.container_id_property] = params[management_settings.container_id_property]
63
+ filters_4_items[:per_page] = 999999
64
+ filters_4_items[:page] = 1
44
65
 
45
- entries_order_by = get_managing_entries_order_by if self.respond_to?(:get_managing_entries_order_by)
46
- entries_order_by = "name asc" unless entries_order_by
66
+ local_items = management_settings.item_class.get_entries(nil, filters_4_items, {logger: string_logger})
67
+ local_data[:items] = local_items
47
68
 
48
- @entries = get_managing_entry_class.where { -(id.in container_all_items_ids) }.page(params[:ppage]).order(entries_order_by)
69
+ #entries_order_by = get_managing_entries_order_by if self.respond_to?(:get_managing_entries_order_by)
70
+ #entries_order_by = "name asc" unless entries_order_by
71
+ filters_4_entries = {}
72
+ self.fill_obligatory_filters(filters_4_entries)
73
+ filters_4_entries[management_settings.entry_id_property] = params[management_settings.entry_id_property]
74
+ filters_4_entries[:per_page] = 999999
75
+ filters_4_entries[:page] = 1
76
+
77
+ # query to exclude already added entries
78
+ local_entries_initial_query = management_settings.entry_class.where { -(id.in management_settings.item_class.get_entries(nil, filters_4_items, {logger: string_logger}).select(management_settings.entry_id_property)) }
79
+
80
+ local_entries = management_settings.entry_class.get_entries(local_entries_initial_query, filters_4_entries, {logger: string_logger})
81
+ local_data[:entries] = local_entries
82
+
83
+ # fill parent for data
84
+ filters_for_parents = {}
85
+ self.fill_obligatory_filters(filters_for_parents)
86
+ self.fill_parents_for_local_data(local_data, filters_for_parents)
49
87
 
50
88
 
51
- views_path = get_managing_views_path if self.respond_to?(:get_managing_views_path)
52
- views_path = "/shared/manage_items/" unless views_path
53
89
 
54
90
  respond_to do |format|
55
- format.html { render_html1("#{views_path}managing_items_manage") }
91
+ format.html { render_html1 self.class.get_method_latest_result(:get_kb_view_path, :management), locals: { data: local_data} }
56
92
  format.json { render json: @entries }
57
93
  end
58
94
  end
59
95
 
60
- def managing_items_add
61
- container = get_managing_container_class.where(id: params[get_managing_parent_id_key]).first
62
- entry = get_managing_entry_class.where(id: params[:entry_id]).first
96
+ def management_items_add
97
+
98
+ local_data = {}
99
+
100
+ # getting management settings
101
+ management_settings = self.class.get_kb_option(:management_settings)
102
+ local_data[:management_settings] = management_settings
63
103
 
104
+ #loading container data
105
+ filters_4_container = {}
106
+ self.fill_obligatory_filters(filters_4_container)
107
+ local_container = management_settings.container_class.get_entry_by_id(params[management_settings.container_id_property], filters_4_container, {logger: string_logger})
64
108
 
65
- unless container
109
+ #loading entry data
110
+ filters_4_entries = {}
111
+ self.fill_obligatory_filters(filters_4_entries)
112
+ local_entry = management_settings.entry_class.get_entry_by_id(params[management_settings.entry_id_property], filters_4_entries, {logger: string_logger})
113
+
114
+ #checking if data found and valid
115
+ unless local_container
66
116
  render json: {status: ::ChupakabraTools::SetManagementResult.id_by_tag('set_not_found'), message: I18n.t("#{self.to_i18n}.management.messages.set_not_found", id: params[:id])}
67
117
  return
68
118
  end
69
- unless entry
119
+ unless local_entry
70
120
  render json: {status: ::ChupakabraTools::SetManagementResult.id_by_tag('entry_not_found'), message: I18n.t("#{self.to_i18n}.management.messages.entry_not_found", entry_id: params[:entry_id])}
71
121
  return
72
122
  end
73
123
 
74
- item = get_managing_item_class.where(container_id: container.id, entry_id: entry).first
124
+ filters_4_item = {}
125
+ self.fill_obligatory_filters(filters_4_item)
126
+ filters_4_item[management_settings.entry_id_property] = params[management_settings.entry_id_property]
127
+ filters_4_item[management_settings.container_id_property] = params[management_settings.container_id_property]
128
+
129
+ local_item = management_settings.item_class.get_entries(nil, filters_4_item, {logger: string_logger}).first
130
+
131
+ unless local_item
132
+ local_item = get_managing_item_class.new
133
+ local_item[management_settings.container_id_property] = container.id
134
+ local_item[management_settings.entry_id_property] = entry.id
75
135
 
76
- unless item
77
- item = get_managing_item_class.new
78
- item.container_id = container.id
79
- item.entry_id = entry.id
80
- max_sort_position = get_managing_item_class.where(container_id: container.id).maximum(:sort_position)
81
- item.sort_position = max_sort_position ? max_sort_position + 1 : 1
136
+ if local_item.respond_to?(:sort_position)
137
+ filters_4_items_max = {}
138
+ self.fill_obligatory_filters(filters_4_items_max)
139
+ filters_4_items_max[management_settings.container_id_property] = params[management_settings.container_id_property]
140
+
141
+ max_sort_position = management_settings.item_class.get_entries(nil, filters_4_items_max, {logger: string_logger}).maximum(:sort_position)
142
+ local_item.sort_position = max_sort_position ? max_sort_position + 1 : 1
143
+ end
82
144
 
83
- if item.save
145
+ if local_item.save
84
146
  render json: {status: ::ChupakabraTools::SetManagementResult.id_by_tag('management_ok'), message: I18n.t("#{self.to_i18n}.management.messages.add_management_ok")}
85
147
  else
86
148
  render json: {status: ::ChupakabraTools::SetManagementResult.id_by_tag('management_error'), message: I18n.t("#{self.to_i18n}.management.messages.add_management_error")}
@@ -90,17 +152,33 @@ module KirguduBase
90
152
  end
91
153
  end
92
154
 
93
- def managing_items_remove
94
- container = get_managing_container_class.where(id: params[:id]).first
155
+ def management_items_remove
95
156
 
157
+ local_data = {}
96
158
 
97
- unless container
159
+ # getting management settings
160
+ management_settings = self.class.get_kb_option(:management_settings)
161
+ local_data[:management_settings] = management_settings
162
+
163
+ #loading container data
164
+ filters_4_container = {}
165
+ self.fill_obligatory_filters(filters_4_container)
166
+ local_container = management_settings.container_class.get_entry_by_id(params[management_settings.container_id_property], filters_4_container, {logger: string_logger})
167
+
168
+ unless local_container
98
169
  render json: {status: ::ChupakabraTools::SetManagementResult.id_by_tag('set_not_found'), message: I18n.t("#{self.to_i18n}.management.messages.set_not_found", id: params[:id])}
99
170
  return
100
171
  end
101
172
 
102
- item = get_managing_item_class.where(container_id: container.id, entry_id: params[:entry_id]).first
103
- unless item
173
+ filters_4_item = {}
174
+ self.fill_obligatory_filters(filters_4_item)
175
+ filters_4_item[management_settings.entry_id_property] = params[management_settings.entry_id_property]
176
+ filters_4_item[management_settings.container_id_property] = params[management_settings.container_id_property]
177
+
178
+ local_item = management_settings.item_class.get_entries(nil, filters_4_item, {logger: string_logger}).first
179
+
180
+
181
+ unless local_item
104
182
  render json: {status: ::ChupakabraTools::SetManagementResult.id_by_tag('item_not_found'), message: I18n.t("#{self.to_i18n}.management.messages.item_not_found", entry_id: params[:entry_id])}
105
183
  return
106
184
  end
@@ -11,7 +11,7 @@ module KirguduBase
11
11
  end
12
12
 
13
13
  module InstanceMethods
14
- def managing_items_sort_index
14
+ def sorting_items_index
15
15
  @container= get_managing_container_class.find(params[get_managing_parent_id_key])
16
16
  @items = get_managing_item_class.where(container_id: @container.id).order(:sort_position)
17
17
 
@@ -27,7 +27,7 @@ module KirguduBase
27
27
  end
28
28
  end
29
29
 
30
- def managing_items_sort_process
30
+ def sorting_items_process
31
31
  container = get_managing_container_class.find(params[get_managing_parent_id_key])
32
32
  unless container
33
33
  render json: {status: ::ChupakabraTools::SetManagementResult.id_by_tag('set_not_found'), message: I18n.t("#{self.to_i18n}.sorting.messages.set_not_found", id: params[:id])}
@@ -2,6 +2,10 @@ module KirguduBase
2
2
  module Controllers
3
3
  module DynamicPages
4
4
 
5
+
6
+ attr_accessor :kirgudu_controller_options
7
+
8
+
5
9
  def kb_page(name, &block)
6
10
 
7
11
  #raise "Page Name: #{name}"
@@ -10,28 +14,111 @@ module KirguduBase
10
14
 
11
15
  element = ::KirguduBase::DynamicPages::PageBuilder.new(name, &block).to_element
12
16
 
13
- exist_elements = @kirgudu_base_pages[element.name]
17
+ existent_page = @kirgudu_base_pages[element.name]
14
18
 
15
- if exist_elements
16
- exist_elements.merge(element)
19
+ if existent_page
20
+ existent_page.merge(element)
17
21
  else
18
22
  @kirgudu_base_pages[element.name] = element
19
23
  end
24
+ end
25
+
26
+ def kb_menu(name, &block)
27
+
28
+ #raise "Page Name: #{name}"
29
+
30
+ @kirgudu_base_menus ||= {}
31
+
32
+ element = ::KirguduBase::DynamicPages::MenuBuilder.new(name, &block).to_element
33
+
34
+ existent_element = @kirgudu_base_menus[element.name]
35
+
36
+ if existent_element
37
+ existent_element.merge(element)
38
+ else
39
+ @kirgudu_base_menus[element.name] = element
40
+ end
41
+ end
42
+
43
+
44
+ def kb_parent_controller(controller, id)
45
+ options_array = kb_get_parents_options_container
46
+ options_array << {controller: controller, id: id}
47
+ end
48
+
49
+
50
+ def kb_entry_class(entry_class)
51
+ options = kb_get_options_container
52
+ options[:entry_class] = entry_class
53
+ end
54
+
55
+ def kb_home_controller(name)
56
+ options = kb_get_options_container
57
+ options[:home_controller] = name
58
+ end
59
+
60
+
61
+ def kb_management_settings(&block)
62
+ options = kb_get_options_container
63
+ options[:management_settings] = ::KirguduBase::DynamicPages::ManagementSettingsBuilder.new(&block).to_element
64
+ end
65
+
66
+ def kb_views_paths_404_page(value)
67
+ options = kb_get_view_paths_options_container
68
+ options[:page_404] = value
69
+ end
70
+
71
+ def kb_views_paths_entry_not_found(value)
72
+ options = kb_get_view_paths_options_container
73
+ options[:entry_not_found] = value
74
+ end
75
+
20
76
 
77
+ def kb_views_paths_index(value)
78
+ options = kb_get_view_paths_options_container
79
+ options[:index] = value
80
+ end
21
81
 
82
+ def kb_views_paths_new(value)
83
+ options = kb_get_view_paths_options_container
84
+ options[:new] = value
22
85
  end
23
86
 
24
- def kb_parent_controller(value)
25
- @kirgudu_controller_options ||= {}
26
- @kirgudu_controller_options[:parent_controller] = value
87
+ def kb_views_paths_edit(value)
88
+ options = kb_get_view_paths_options_container
89
+ options[:edit] = value
27
90
  end
28
91
 
29
- def kb_parent_id(value)
30
- @kirgudu_controller_options ||= {}
31
- @kirgudu_controller_options[:parent_id] = value
92
+ def kb_views_paths_delete(value)
93
+ options = kb_get_view_paths_options_container
94
+ options[:delete] = value
32
95
  end
33
96
 
34
- def get_kb_options(name)
97
+ def kb_views_paths_show(value)
98
+ options = kb_get_view_paths_options_container
99
+ options[:show] = value
100
+ end
101
+
102
+ def kb_views_paths_management(value)
103
+ options = kb_get_view_paths_options_container
104
+ options[:management] = value
105
+ end
106
+
107
+ def kb_views_paths_sorting(value)
108
+ options = kb_get_view_paths_options_container
109
+ options[:sorting] = value
110
+ end
111
+
112
+
113
+
114
+ def kb_template(name)
115
+ options = kb_get_options_container
116
+ options[:template] = name
117
+ end
118
+
119
+
120
+
121
+ def get_kb_option(name)
35
122
  @kirgudu_controller_options[name] if @kirgudu_controller_options
36
123
  end
37
124
 
@@ -39,6 +126,36 @@ module KirguduBase
39
126
  @kirgudu_base_pages[name] if @kirgudu_base_pages
40
127
  end
41
128
 
129
+ def get_kb_menu(name)
130
+ @kirgudu_base_menus[name] if @kirgudu_base_menus
131
+ end
132
+
133
+ def get_kb_view_path(view_name)
134
+ if view_name
135
+ options = kb_get_view_paths_options_container
136
+ options[view_name.to_sym]
137
+ end
138
+ end
139
+
140
+ def get_kb_parents
141
+ kb_get_parents_options_container
142
+ end
143
+
144
+ def get_kb_entry_class
145
+ options = kb_get_options_container
146
+ options[:entry_class]
147
+ end
148
+
149
+ def get_kb_home_controller
150
+ options = kb_get_options_container
151
+ options[:home_controller]
152
+ end
153
+
154
+ def get_kb_template
155
+ options = kb_get_options_container
156
+ options[:template]
157
+ end
158
+
42
159
 
43
160
  def kb_form_properties_template_set(name, &block)
44
161
 
@@ -46,7 +163,7 @@ module KirguduBase
46
163
 
47
164
  #@form_properties_template_set = {} unless @form_properties_template_set
48
165
  #
49
- #template_set = ::KirguduBase::DynamicPages::FormPropertiesNamedSetBuilder.new(self, name, &block).to_set
166
+ #template_set = ::KirguduBase::DynamicPages::FormPropertiesNamedSetBuilder.new(name, &block).to_set
50
167
  #@@form_properties_template_set[template_set.name] = template_set
51
168
 
52
169
 
@@ -55,6 +172,25 @@ module KirguduBase
55
172
  def get_form_properties_template_set(name)
56
173
  @kirgudu_base_pages[name] if @kirgudu_base_pages
57
174
  end
175
+
176
+ protected
177
+ def kb_get_view_paths_options_container
178
+ options = self.kb_get_options_container
179
+ options[:views_paths] ||= {}
180
+ options[:views_paths]
181
+ end
182
+
183
+ def kb_get_options_container
184
+ self.kirgudu_controller_options ||= {}
185
+ self.kirgudu_controller_options
186
+ end
187
+
188
+ def kb_get_parents_options_container
189
+ options = kb_get_options_container
190
+ options[:parents] ||= []
191
+ options[:parents]
192
+ end
193
+
58
194
  end
59
195
  end
60
196
  end
@@ -104,6 +104,7 @@ module KirguduBase
104
104
  def text_field(property, html_options = {})
105
105
  html_options ||= {}
106
106
 
107
+
107
108
  html_options.merge!(property.html_options) if property.html_options
108
109
  html_options.merge!(
109
110
  {
@@ -116,7 +117,8 @@ module KirguduBase
116
117
 
117
118
  html_options_add_class(html_options, "error") if @object.errors[property.name].present?
118
119
 
119
- super(property.name, html_options)
120
+
121
+ text_field_tag(property, @object, html_options)
120
122
  end
121
123
 
122
124
  def text_area(property, html_options = {})
@@ -65,9 +65,10 @@ module KirguduBase
65
65
  ::KirguduBase::GuiHelper.html_options_prepare_commons(html_options, property, data_source)
66
66
 
67
67
  html_options[:id] = SecureRandom.uuid.underscore unless html_options[:id]
68
- html_options[:type] = "text"
69
- html_options[:"control-type"] = "text-field"
70
-
68
+ html_options.merge!({
69
+ type: "text",
70
+ :"control-type" => "text-field"
71
+ })
71
72
  content_tag("input", '', html_options)
72
73
  end
73
74
 
@@ -90,12 +91,13 @@ module KirguduBase
90
91
  def password_field_tag(property, data_source, html_options = {})
91
92
  html_options ||= {}
92
93
 
94
+ ::KirguduBase::GuiHelper.html_options_prepare_commons(html_options, property, data_source)
95
+
93
96
  html_options.merge!({
94
97
  type: "password",
95
98
  :"control-type" => "password-field"
96
99
  })
97
100
 
98
- ::KirguduBase::GuiHelper.html_options_prepare_commons(html_options, property, data_source)
99
101
 
100
102
  html_options[:id] = SecureRandom.uuid.underscore unless html_options[:id]
101
103
 
@@ -299,6 +301,7 @@ module KirguduBase
299
301
 
300
302
  html_options ||= {}
301
303
  ::KirguduBase::GuiHelper.html_options_add_class(html_options, ["chzn-select"])
304
+ html_options[:'control-type'] = 'chosen-select'
302
305
 
303
306
  select_tag(property, data_source, choices_data, html_options)
304
307
  end
@@ -310,6 +313,8 @@ module KirguduBase
310
313
 
311
314
  control_value = ::KirguduBase::GuiHelper.get_value_for_control(property, data_source)
312
315
 
316
+ html_options[:'control-type'] ||= 'select'
317
+
313
318
  if property.data_source.type == :jquery || property.data_source.type == :jquery_db
314
319
  html_options.merge!({
315
320
  :"ds-method" => property.data_source.http_method,
@@ -628,7 +633,7 @@ module KirguduBase
628
633
  :"property-name" => property.name,
629
634
  :"property-value" => control_value,
630
635
  :"parent-property" => (property.parent if property.parent),
631
- :"placeholder" => property.i18n_data_as_string(:placeholder)
636
+ :"placeholder" => (property.i18n_data_as_string(:placeholder) if property.placeholder)
632
637
  )
633
638
 
634
639
  # Adding to control attribute value: class = 'error' if error