agile_rails 0.0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/MIT-LICENSE +20 -0
- data/README.md +285 -0
- data/Rakefile +39 -0
- data/agile_rails.gemspec +36 -0
- data/app/assets/fonts/ibm-plex-sans-300.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-400.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-500.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-600.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-700.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-italic.woff2 +0 -0
- data/app/assets/images/32px.png +0 -0
- data/app/assets/images/throbber.gif +0 -0
- data/app/assets/javascripts/agile/agile.js +1489 -0
- data/app/assets/javascripts/agile/jquery-migrate.js +702 -0
- data/app/assets/javascripts/agile/jquery.bpopup.js +372 -0
- data/app/assets/javascripts/agile/jquery.datetimepicker.js +1353 -0
- data/app/assets/javascripts/agile/jstree.min.js +6 -0
- data/app/assets/javascripts/agile/select-multiple.js +459 -0
- data/app/assets/javascripts/agile/some_scripts.js +33 -0
- data/app/assets/javascripts/agile.js +22 -0
- data/app/assets/javascripts/agile_application.js +22 -0
- data/app/assets/javascripts/agile_editor.js +22 -0
- data/app/assets/stylesheets/agile/agile.css +1882 -0
- data/app/assets/stylesheets/agile/agile_apps.css +149 -0
- data/app/assets/stylesheets/agile/jquery.datetimepicker.css +304 -0
- data/app/assets/stylesheets/agile/jstree.css +1107 -0
- data/app/assets/stylesheets/agile/select-multiple.css +110 -0
- data/app/assets/stylesheets/agile/th-bg.png +0 -0
- data/app/assets/stylesheets/agile/theme.css +49 -0
- data/app/assets/stylesheets/agile.css +21 -0
- data/app/assets/stylesheets/agile_application.css +20 -0
- data/app/assets/stylesheets/agile_editor.css +19 -0
- data/app/controllers/agile_application_controller.rb +735 -0
- data/app/controllers/agile_common_controller.rb +345 -0
- data/app/controllers/agile_controller.rb +977 -0
- data/app/controllers/agile_main_controller.rb +36 -0
- data/app/controls/agile_control.rb +120 -0
- data/app/controls/agile_report.rb +364 -0
- data/app/controls/ar_category_control.rb +39 -0
- data/app/controls/ar_help_control.rb +139 -0
- data/app/controls/ar_image_control.rb +180 -0
- data/app/controls/ar_journal_control.rb +47 -0
- data/app/controls/ar_menu_item_control.rb +55 -0
- data/app/controls/ar_page_control.rb +64 -0
- data/app/controls/ar_poll_result_control.rb +84 -0
- data/app/controls/ar_setup_control.rb +62 -0
- data/app/controls/belongs_to_control.rb +61 -0
- data/app/controls/browse_models_control.rb +98 -0
- data/app/controls/settings_form_control.rb +137 -0
- data/app/forms/agile_help.yml +112 -0
- data/app/forms/agile_menu.yml +140 -0
- data/app/forms/agile_report_defaults.yml +39 -0
- data/app/forms/all_options.yml +810 -0
- data/app/forms/ar_ad.yml +121 -0
- data/app/forms/ar_big_table.yml +60 -0
- data/app/forms/ar_big_table_value.yml +52 -0
- data/app/forms/ar_browse_fields.yml +35 -0
- data/app/forms/ar_browse_models.yml +48 -0
- data/app/forms/ar_category.yml +73 -0
- data/app/forms/ar_category_as_tree.yml +31 -0
- data/app/forms/ar_design.yml +75 -0
- data/app/forms/ar_filter.yml +52 -0
- data/app/forms/ar_folder_permission.yml +56 -0
- data/app/forms/ar_folder_rule.yml +48 -0
- data/app/forms/ar_gallery.yml +55 -0
- data/app/forms/ar_image.yml +126 -0
- data/app/forms/ar_image_search.yml +83 -0
- data/app/forms/ar_journal.yml +76 -0
- data/app/forms/ar_json_ld.yml +56 -0
- data/app/forms/ar_key_value.yml +33 -0
- data/app/forms/ar_key_value_store.yml +33 -0
- data/app/forms/ar_link.yml +60 -0
- data/app/forms/ar_menu.yml +67 -0
- data/app/forms/ar_menu_item.yml +141 -0
- data/app/forms/ar_page.yml +187 -0
- data/app/forms/ar_part.yml +91 -0
- data/app/forms/ar_permission.yml +52 -0
- data/app/forms/ar_permission_rule.yml +40 -0
- data/app/forms/ar_piece.yml +106 -0
- data/app/forms/ar_policy.yml +64 -0
- data/app/forms/ar_policy_rule.yml +42 -0
- data/app/forms/ar_policy_rule_nocms.yml +40 -0
- data/app/forms/ar_poll.yml +118 -0
- data/app/forms/ar_poll_item.yml +78 -0
- data/app/forms/ar_poll_result.yml +88 -0
- data/app/forms/ar_poll_result_export.yml +35 -0
- data/app/forms/ar_removed_url.yml +41 -0
- data/app/forms/ar_role.yml +43 -0
- data/app/forms/ar_seo.yml +32 -0
- data/app/forms/ar_setup.yml +45 -0
- data/app/forms/ar_site.yml +149 -0
- data/app/forms/ar_steps_template.yml +51 -0
- data/app/forms/ar_user.yml +140 -0
- data/app/forms/ar_user_role.yml +57 -0
- data/app/forms/help/dc_category_as_tree.en +4 -0
- data/app/forms/help/dc_category_as_tree.sl +5 -0
- data/app/forms/json_ld_schema.yml +168 -0
- data/app/helpers/agile_application_helper.rb +1162 -0
- data/app/helpers/agile_category_helper.rb +128 -0
- data/app/helpers/agile_common_helper.rb +308 -0
- data/app/helpers/agile_edit_helper.rb +645 -0
- data/app/helpers/agile_helper.rb +509 -0
- data/app/helpers/agile_index_helper.rb +677 -0
- data/app/helpers/ar_image_helper.rb +128 -0
- data/app/models/agile_form_fields/action.rb +61 -0
- data/app/models/agile_form_fields/agile_form_field.rb +322 -0
- data/app/models/agile_form_fields/belongs_to.rb +112 -0
- data/app/models/agile_form_fields/check_box.rb +73 -0
- data/app/models/agile_form_fields/comment.rb +62 -0
- data/app/models/agile_form_fields/date_picker.rb +104 -0
- data/app/models/agile_form_fields/date_select.rb +68 -0
- data/app/models/agile_form_fields/datetime_picker.rb +88 -0
- data/app/models/agile_form_fields/datetime_select.rb +73 -0
- data/app/models/agile_form_fields/file_field.rb +52 -0
- data/app/models/agile_form_fields/file_select.rb +69 -0
- data/app/models/agile_form_fields/hidden_field.rb +51 -0
- data/app/models/agile_form_fields/html_field.rb +69 -0
- data/app/models/agile_form_fields/journal_diff.rb +62 -0
- data/app/models/agile_form_fields/link_to.rb +69 -0
- data/app/models/agile_form_fields/method.rb +66 -0
- data/app/models/agile_form_fields/multitext_autocomplete.rb +215 -0
- data/app/models/agile_form_fields/number_field.rb +92 -0
- data/app/models/agile_form_fields/password_field.rb +63 -0
- data/app/models/agile_form_fields/radio_button.rb +95 -0
- data/app/models/agile_form_fields/readonly.rb +77 -0
- data/app/models/agile_form_fields/select.rb +281 -0
- data/app/models/agile_form_fields/submit_tag.rb +58 -0
- data/app/models/agile_form_fields/text_area.rb +61 -0
- data/app/models/agile_form_fields/text_autocomplete.rb +171 -0
- data/app/models/agile_form_fields/text_field.rb +55 -0
- data/app/models/agile_form_fields/text_with_select.rb +94 -0
- data/app/models/agile_form_fields/tree_select.rb +170 -0
- data/app/models/ar_big_table.rb +82 -0
- data/app/models/ar_big_table_value.rb +53 -0
- data/app/models/ar_category.rb +109 -0
- data/app/models/ar_design.rb +116 -0
- data/app/models/ar_filter.rb +200 -0
- data/app/models/ar_folder_permission.rb +50 -0
- data/app/models/ar_folder_rule.rb +47 -0
- data/app/models/ar_gallery.rb +53 -0
- data/app/models/ar_image.rb +198 -0
- data/app/models/ar_internals.rb +60 -0
- data/app/models/ar_journal.rb +46 -0
- data/app/models/ar_json_ld.rb +131 -0
- data/app/models/ar_key_value_store.rb +128 -0
- data/app/models/ar_link.rb +48 -0
- data/app/models/ar_memory.rb +172 -0
- data/app/models/ar_menu.rb +144 -0
- data/app/models/ar_menu_item.rb +106 -0
- data/app/models/ar_page.rb +74 -0
- data/app/models/ar_part.rb +66 -0
- data/app/models/ar_permission.rb +180 -0
- data/app/models/ar_permission_rule.rb +65 -0
- data/app/models/ar_policy.rb +78 -0
- data/app/models/ar_policy_rule.rb +65 -0
- data/app/models/ar_poll.rb +74 -0
- data/app/models/ar_poll_item.rb +47 -0
- data/app/models/ar_poll_result.rb +38 -0
- data/app/models/ar_removed_url.rb +42 -0
- data/app/models/ar_role.rb +84 -0
- data/app/models/ar_setup.rb +115 -0
- data/app/models/ar_site.rb +68 -0
- data/app/models/ar_temp.rb +150 -0
- data/app/models/ar_user.rb +72 -0
- data/app/models/ar_user_group.rb +38 -0
- data/app/models/ar_user_role.rb +54 -0
- data/app/models/ar_visit.rb +41 -0
- data/app/models/concerns/ar_page_concern.rb +128 -0
- data/app/models/concerns/ar_part_concern.rb +48 -0
- data/app/models/concerns/ar_piece_concern.rb +48 -0
- data/app/models/concerns/ar_policy_rule_concern.rb +87 -0
- data/app/models/concerns/ar_seo_concern.rb +66 -0
- data/app/models/concerns/ar_site_concern.rb +103 -0
- data/app/models/concerns/ar_user_concern.rb +195 -0
- data/app/renderers/agile_common_renderer.rb +93 -0
- data/app/renderers/agile_renderer.rb +59 -0
- data/app/renderers/ar_ad_renderer.rb +219 -0
- data/app/renderers/ar_captcha_renderer.rb +113 -0
- data/app/renderers/ar_common_renderer.rb +90 -0
- data/app/renderers/ar_gallery_renderer.rb +107 -0
- data/app/renderers/ar_menu_renderer.rb +195 -0
- data/app/renderers/ar_page_renderer.rb +147 -0
- data/app/renderers/ar_part_renderer.rb +235 -0
- data/app/renderers/ar_piece_renderer.rb +119 -0
- data/app/renderers/ar_poll_renderer.rb +272 -0
- data/app/views/agile/_edit_stuff.html.erb +57 -0
- data/app/views/agile/_form.html.erb +24 -0
- data/app/views/agile/_result.html.erb +28 -0
- data/app/views/agile/edit.html.erb +13 -0
- data/app/views/agile/error.html.erb +2 -0
- data/app/views/agile/index.html.erb +14 -0
- data/app/views/agile/login.html.erb +19 -0
- data/app/views/agile/new.html.erb +12 -0
- data/app/views/agile_common/_help.html.erb +18 -0
- data/app/views/agile_common/_iframe_edit.html.erb +2 -0
- data/app/views/agile_common/paste_clipboard.html.erb +17 -0
- data/app/views/layouts/agile.html.erb +17 -0
- data/app/views/layouts/content.html.erb +20 -0
- data/app/views/models/dump_models.html.erb +47 -0
- data/config/initializers/kaminari_patch.rb +56 -0
- data/config/locales/agile_de.yml +138 -0
- data/config/locales/agile_en.yml +162 -0
- data/config/locales/agile_sl.yml +163 -0
- data/config/locales/datetimepicker.yml +19 -0
- data/config/locales/de.yml +231 -0
- data/config/locales/en.yml +13 -0
- data/config/locales/kaminari.yml +26 -0
- data/config/locales/models_en.yml +1032 -0
- data/config/locales/models_sl.yml +1065 -0
- data/config/locales/sl.yml +211 -0
- data/db/migrate/20240120160001_add_sessions_table.rb +12 -0
- data/db/migrate/20240120160002_ar_big_table.rb +17 -0
- data/db/migrate/20240120160003_ar_big_table_value.rb +18 -0
- data/db/migrate/20240120160004_ar_category.rb +22 -0
- data/db/migrate/20240120160005_ar_design.rb +20 -0
- data/db/migrate/20240120160006_ar_filter.rb +17 -0
- data/db/migrate/20240120160007_ar_gallery.rb +21 -0
- data/db/migrate/20240120160008_ar_journal.rb +19 -0
- data/db/migrate/20240120160009_ar_key_value_store.rb +11 -0
- data/db/migrate/20240120160010_ar_link.rb +19 -0
- data/db/migrate/20240120160011_ar_memory.rb +8 -0
- data/db/migrate/20240120160012_ar_menu.rb +21 -0
- data/db/migrate/20240120160013_ar_menu_item.rb +28 -0
- data/db/migrate/20240120160014_ar_page.rb +50 -0
- data/db/migrate/20240120160015_ar_part.rb +33 -0
- data/db/migrate/20240120160016_ar_permission.rb +16 -0
- data/db/migrate/20240120160017_ar_permission_rule.rb +17 -0
- data/db/migrate/20240120160018_ar_piece.rb +28 -0
- data/db/migrate/20240120160019_ar_policy.rb +21 -0
- data/db/migrate/20240120160020_ar_policy_rule.rb +18 -0
- data/db/migrate/20240120160021_ar_poll.rb +27 -0
- data/db/migrate/20240120160022_ar_poll_item.rb +23 -0
- data/db/migrate/20240120160023_ar_poll_result.rb +14 -0
- data/db/migrate/20240120160024_ar_removed_url.rb +16 -0
- data/db/migrate/20240120160025_ar_role.rb +17 -0
- data/db/migrate/20240120160026_ar_site.rb +37 -0
- data/db/migrate/20240120160027_ar_temp.rb +11 -0
- data/db/migrate/20240120160028_ar_user.rb +42 -0
- data/db/migrate/20240120160029_ar_user_group.rb +12 -0
- data/db/migrate/20240120160030_ar_user_role.rb +18 -0
- data/db/migrate/20240120160031_ar_visit.rb +15 -0
- data/db/migrate/20240703016001_ar_setup.rb +16 -0
- data/db/migrate/20240703016002_ar_folder_permission.rb +15 -0
- data/db/migrate/20240703016003_ar_folder_rule.rb +14 -0
- data/db/migrate/20250115000001_ar_image.rb +25 -0
- data/lib/agile/configuration.rb +43 -0
- data/lib/agile/engine.rb +29 -0
- data/lib/agile/version.rb +27 -0
- data/lib/agile.rb +282 -0
- data/lib/agile_rails.rb +1 -0
- data/lib/generators/agile/USAGE +11 -0
- data/lib/generators/agile/new_form_generator.rb +369 -0
- data/lib/generators/convert_to_ar/convert_to_ar_generator.rb +158 -0
- data/lib/tasks/agile_db_clone.rake +132 -0
- data/lib/tasks/agile_db_export_to_yaml.rake +37 -0
- data/lib/tasks/agile_db_migrate.rake +35 -0
- metadata +414 -0
@@ -0,0 +1,172 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#+
|
23
|
+
|
24
|
+
########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Table name: ar_memory : Collection name used when form does not belong to database model.
|
28
|
+
#
|
29
|
+
# Which is not collection at all. ArMemory model is used for entering data on forms
|
30
|
+
# where data will not be saved to database but will instead be saved only to memory as
|
31
|
+
# temporary variable and processed by custom made methods.
|
32
|
+
# For example, define start and end date when making a timeline report.
|
33
|
+
#
|
34
|
+
# Example (as used in forms):
|
35
|
+
#
|
36
|
+
# table: ar_memory
|
37
|
+
# title: Enter time period
|
38
|
+
#
|
39
|
+
# form:
|
40
|
+
# actions:
|
41
|
+
# 1:
|
42
|
+
# type: ajax
|
43
|
+
# method: post
|
44
|
+
# controller: reports
|
45
|
+
# action: do_some_report
|
46
|
+
# caption: Run report
|
47
|
+
#
|
48
|
+
# fields:
|
49
|
+
# 10:
|
50
|
+
# name: date_start
|
51
|
+
# type: date_picker
|
52
|
+
# caption: Start date
|
53
|
+
# 20:
|
54
|
+
# name: date_end
|
55
|
+
# type: date_picker
|
56
|
+
# caption: End date
|
57
|
+
#
|
58
|
+
# And suppose your report saved data to file named public/report.pdf.
|
59
|
+
# Put this line at the end of do_some_report method:
|
60
|
+
#
|
61
|
+
# render inline: { :window_report => '/report.pdf' }.to_json, formats: 'js'
|
62
|
+
#
|
63
|
+
# As result report.pdf file will be opened in new browser window.
|
64
|
+
########################################################################
|
65
|
+
class ArMemory < ApplicationRecord
|
66
|
+
|
67
|
+
########################################################################
|
68
|
+
# Initilize object
|
69
|
+
########################################################################
|
70
|
+
def initialize(parms = {})
|
71
|
+
@internals = {}
|
72
|
+
parms.each { |key, value| @internals[key.to_s] = value } if parms
|
73
|
+
super
|
74
|
+
end
|
75
|
+
=begin
|
76
|
+
########################################################################
|
77
|
+
# Return id field
|
78
|
+
########################################################################
|
79
|
+
def id
|
80
|
+
@internals['id']
|
81
|
+
end
|
82
|
+
|
83
|
+
########################################################################
|
84
|
+
# Respond_to should always return true.
|
85
|
+
########################################################################
|
86
|
+
def id=(value)
|
87
|
+
@internals['id'] = value
|
88
|
+
end
|
89
|
+
=end
|
90
|
+
|
91
|
+
|
92
|
+
########################################################################
|
93
|
+
# Converts data field to @internals hash
|
94
|
+
########################################################################
|
95
|
+
def read_yaml
|
96
|
+
@internals = YAML.load(data) || {}
|
97
|
+
end
|
98
|
+
|
99
|
+
########################################################################
|
100
|
+
# Convert @internals hash to data field
|
101
|
+
########################################################################
|
102
|
+
def save_yaml
|
103
|
+
self.data = @internals.to_yaml
|
104
|
+
end
|
105
|
+
|
106
|
+
########################################################################
|
107
|
+
# Respond_to should always return true.
|
108
|
+
########################################################################
|
109
|
+
def respond_to?(m)
|
110
|
+
true
|
111
|
+
end
|
112
|
+
|
113
|
+
########################################################################
|
114
|
+
# Redefine send method. Send is used to assign or access value by agile controller.
|
115
|
+
########################################################################
|
116
|
+
def send(field, value = nil)
|
117
|
+
field = field.to_s
|
118
|
+
if field.match('=')
|
119
|
+
field.chomp!('=')
|
120
|
+
@internals ||= {}
|
121
|
+
@internals[field] = value
|
122
|
+
else
|
123
|
+
@internals[field]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
########################################################################
|
128
|
+
# Redefine [] method to act similar as send method
|
129
|
+
########################################################################
|
130
|
+
def [](field)
|
131
|
+
return nil unless @internals
|
132
|
+
@internals[field.to_s]
|
133
|
+
end
|
134
|
+
|
135
|
+
########################################################################
|
136
|
+
# Redefine [] method to act similar as send method
|
137
|
+
########################################################################
|
138
|
+
def []=(field, value)
|
139
|
+
@internals ||= {}
|
140
|
+
@internals[field.to_s] = value
|
141
|
+
end
|
142
|
+
|
143
|
+
########################################################################
|
144
|
+
# For debugging purposes
|
145
|
+
########################################################################
|
146
|
+
def to_s
|
147
|
+
" ArMemory: @internals=#{@internals.size} #{@internals}"
|
148
|
+
end
|
149
|
+
|
150
|
+
########################################################################
|
151
|
+
# Dummy errors so far.
|
152
|
+
########################################################################
|
153
|
+
#def errors
|
154
|
+
## []
|
155
|
+
#end
|
156
|
+
|
157
|
+
########################################################################
|
158
|
+
# Method missing will return value if value defined by m parameter is saved to
|
159
|
+
# @internals array or will save field value to @internals hash if m matches '='.
|
160
|
+
########################################################################
|
161
|
+
def method_missing(m, *args, &block) #:nodoc:
|
162
|
+
@internals ||= {}
|
163
|
+
m = m.to_s
|
164
|
+
if m.match('=')
|
165
|
+
m = m.chomp('=')
|
166
|
+
@internals[m] = args.first
|
167
|
+
else
|
168
|
+
@internals[m]
|
169
|
+
end
|
170
|
+
end
|
171
|
+
#=end
|
172
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
#########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Table name: ArMenu : AgileRail menu system
|
28
|
+
#
|
29
|
+
# Default menu system for AgileRails. Model recursively embeds ArMenuItem documents
|
30
|
+
# which (theoretically) results in infinite level of sub menus. In practice
|
31
|
+
# reasonable maximum level of 4 is advised.
|
32
|
+
#########################################################################
|
33
|
+
class ArMenu < ApplicationRecord
|
34
|
+
|
35
|
+
belongs_to :ar_site
|
36
|
+
has_many :ar_menu_items
|
37
|
+
|
38
|
+
validates :name, :length => { :minimum => 4 }
|
39
|
+
validates :name, uniqueness: true
|
40
|
+
validates_length_of :description, minimum: 10
|
41
|
+
|
42
|
+
after_save :cache_delete
|
43
|
+
after_destroy :cache_delete
|
44
|
+
|
45
|
+
######################################################################
|
46
|
+
# Clear menu cache
|
47
|
+
######################################################################
|
48
|
+
def cache_delete
|
49
|
+
Agile.cache_clear(name)
|
50
|
+
end
|
51
|
+
|
52
|
+
#######################################################################
|
53
|
+
# Will return list of menu items of specified menu. Used in ArPage document for
|
54
|
+
# selecting top level selected menu.
|
55
|
+
#
|
56
|
+
# Called from AgileApplicationHelper :agile_choices_for_menu: method.
|
57
|
+
#
|
58
|
+
# Parameters:
|
59
|
+
# [Site] ArSite document. Site for which menu belongs to. If site is not specified
|
60
|
+
# all current menus in ar_menus collection will be returned.
|
61
|
+
#
|
62
|
+
# Returns:
|
63
|
+
# Array. Of choices prepared for select input field.
|
64
|
+
#######################################################################
|
65
|
+
def self.choices_for_menu(site)
|
66
|
+
rez = []
|
67
|
+
menus = (site.menu_name.blank? ? all : where(name: site.menu_name)).to_a
|
68
|
+
menus.each do |menu|
|
69
|
+
rez << [menu.name, nil]
|
70
|
+
menu.ozs_menu_items.where(active: true).order(:order).each do |menu_item|
|
71
|
+
rez << ['-- ' + menu_item.caption, menu_item._id]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
rez
|
75
|
+
end
|
76
|
+
|
77
|
+
#######################################################################
|
78
|
+
# Subroutine of choices_for_menu_as_tree
|
79
|
+
#######################################################################
|
80
|
+
def self.do_sub_menu(menus, parent, ids) #:nodoc:
|
81
|
+
result = []
|
82
|
+
menus.each do |item|
|
83
|
+
long_id = "#{ids};#{item.id}"
|
84
|
+
result << [item.caption, long_id, parent, item.order]
|
85
|
+
sub_menus = ArMenuItem.where(parent_id: item.id).order(:order).to_a
|
86
|
+
result += do_sub_menu(sub_menus, long_id, long_id) if sub_menus.size > 0
|
87
|
+
end
|
88
|
+
result
|
89
|
+
end
|
90
|
+
|
91
|
+
#######################################################################
|
92
|
+
# Will return menu structure for menus belonging to the site.
|
93
|
+
#
|
94
|
+
# Parameters:
|
95
|
+
# [Site] ArSite document. Site for which menu belongs to. If site is not specified
|
96
|
+
# all current menus in collection will be returned.
|
97
|
+
#
|
98
|
+
# Returns:
|
99
|
+
# Array. Of choices prepared for tree:select input field.
|
100
|
+
#######################################################################
|
101
|
+
def self.choices_for_menu_as_tree(site_id = nil)
|
102
|
+
return [] if site_id == nil
|
103
|
+
|
104
|
+
id = site_id.class == Integer ? site_id : site_id.id
|
105
|
+
where(ar_site_id: [nil, id], active: true).order(:name).inject([]) do |r, menu|
|
106
|
+
r << [menu.name, menu.id, nil, 0]
|
107
|
+
sub_menus = ArMenuItem.where(ar_menu_id: menu.id, parent_id: 0).order(:order).to_a
|
108
|
+
r += do_sub_menu(sub_menus, menu.id, menu.id.to_s) if sub_menus.size > 0
|
109
|
+
r
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
#######################################################################
|
114
|
+
# Will update link value of selected menu_item
|
115
|
+
#
|
116
|
+
# Parameters:
|
117
|
+
# [record] Array. Data of saved document.
|
118
|
+
#######################################################################
|
119
|
+
def self.menu_item_link_update(record)
|
120
|
+
return if record.try(:menu_id).blank? # not set
|
121
|
+
|
122
|
+
ar = record.menu_id.split(';')
|
123
|
+
menu = ArMenuItem.find(ar.last.to_i)
|
124
|
+
menu.page_id = record.id
|
125
|
+
menu.save
|
126
|
+
end
|
127
|
+
|
128
|
+
######################################################################
|
129
|
+
# Return all pages belonging to site ready for select input field. Used
|
130
|
+
# by ar_menu* forms, for selecting page which will be linked by menu option.
|
131
|
+
#
|
132
|
+
# Parameters:
|
133
|
+
# [site] Site document.
|
134
|
+
######################################################################
|
135
|
+
def self.all_pages_for_site(parms)
|
136
|
+
menu_id = parms[:ids].split(';').first # get menu id from params[:ids]
|
137
|
+
site_id = ArMenu.only(:site_id).find(menu_id).ar_site_id
|
138
|
+
site = ArSite.only(:page_class, :id).find(site_id) # find site
|
139
|
+
pages = site.page_class.constantize # pages collection name
|
140
|
+
pages.only(:subject, :id).where(ar_site_id: site.id, active: true).order(:subject)
|
141
|
+
.map { |page| [ page.subject, page.id] }
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
#########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Table name: ar_menu_item : Menu items
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# created_at Time created_at
|
31
|
+
# updated_at Time updated_at
|
32
|
+
# caption String Caption of menu item
|
33
|
+
# picture String Picture for the menu
|
34
|
+
# link String Link called when menu is chosen
|
35
|
+
# link_prepend String Link field usually holds direct link to document. Prepand field holds data, that has to be prepanded to the link.
|
36
|
+
# target String Target window for the link. Leave empty when same window.
|
37
|
+
# page_id Integer Page link
|
38
|
+
# order Integer Order on which menu item is shown. Lower number means prior position.
|
39
|
+
# hidden Boolean Is hidden
|
40
|
+
# active Boolean Is active
|
41
|
+
# policy_id Integer Menu item will be diplayed according to this policy
|
42
|
+
# parent_id Integer Parent menu item. 0 if top level
|
43
|
+
# created_by Integer created_by
|
44
|
+
# updated_by Integer updated_by
|
45
|
+
#
|
46
|
+
# ArMenuItems model is used to save items of a menu.
|
47
|
+
#########################################################################
|
48
|
+
class ArMenuItem < ApplicationRecord
|
49
|
+
|
50
|
+
belongs_to :ar_menu
|
51
|
+
|
52
|
+
validates :order, presence: true
|
53
|
+
|
54
|
+
before_save :do_before_save
|
55
|
+
after_save :cache_delete
|
56
|
+
after_destroy :cache_delete
|
57
|
+
|
58
|
+
#######################################################################
|
59
|
+
# Will return menu path for the item as array of id-s. Method can be used
|
60
|
+
# to determine all parents of current item.
|
61
|
+
#
|
62
|
+
# Returns:
|
63
|
+
# Array. Of parent items ids.
|
64
|
+
#######################################################################
|
65
|
+
def menu_path
|
66
|
+
path, parent = [], self
|
67
|
+
while parent
|
68
|
+
path << parent.id
|
69
|
+
parent = parent._parent
|
70
|
+
end
|
71
|
+
path.reverse
|
72
|
+
end
|
73
|
+
|
74
|
+
#######################################################################
|
75
|
+
# Will return top menu item id. Used for detecting which top-level menu
|
76
|
+
# was last selected.
|
77
|
+
#
|
78
|
+
# Returns:
|
79
|
+
# Integer: Top menu level id
|
80
|
+
#######################################################################
|
81
|
+
def top_menu_id
|
82
|
+
menu_path[1]
|
83
|
+
end
|
84
|
+
|
85
|
+
######################################################################
|
86
|
+
# Implementation of before_save callback.
|
87
|
+
######################################################################
|
88
|
+
def do_before_save
|
89
|
+
self.link = ArPage.clear_link(caption.downcase.strip) if link.blank?
|
90
|
+
end
|
91
|
+
|
92
|
+
######################################################################
|
93
|
+
# Clear parent record from cache
|
94
|
+
######################################################################
|
95
|
+
def cache_delete
|
96
|
+
ArMenu.find(ar_menu_id).cache_delete
|
97
|
+
end
|
98
|
+
|
99
|
+
######################################################################
|
100
|
+
# Dummy method
|
101
|
+
######################################################################
|
102
|
+
def top_menu_id
|
103
|
+
menu_path[1]
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#+
|
23
|
+
|
24
|
+
#########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Table name: ar_page : Pages
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# created_at Time created_at
|
31
|
+
# updated_at Time Updated
|
32
|
+
# subject String Articles subject
|
33
|
+
# link String Friendly link defined
|
34
|
+
# alt_link String Alternative link, by which page could be found
|
35
|
+
# sub_subject String Sub subject, short description of text
|
36
|
+
# picture String Picture used in conjunction with page
|
37
|
+
# gallery Boolean Picture gallery defined on page. Picture data is saved to document parts with id gallery.
|
38
|
+
# body String Content of this page
|
39
|
+
# css String CSS only for this menu page
|
40
|
+
# script String Javascript only for this page
|
41
|
+
# params String Special parameters which may come handy when displaying page
|
42
|
+
# menu_id Integer Top menu under where this page is displayed
|
43
|
+
# author_id Integer Author of the article
|
44
|
+
# ar_poll_id Integer Select poll, if poll is to be used with page
|
45
|
+
# author_name String Author of the article
|
46
|
+
# publish_date DateTime Publish date
|
47
|
+
# user_name String user_name
|
48
|
+
# valid_from DateTime Article is valid from date
|
49
|
+
# valid_to DateTime Article is valid to date
|
50
|
+
# comments Integer Comments on this article are allowed
|
51
|
+
# active Boolean Page is active
|
52
|
+
# created_by Integer created_by
|
53
|
+
# updated_by Integer updated_by
|
54
|
+
# kats Array Categories for this article
|
55
|
+
# policy_id Integer Access policy for the page
|
56
|
+
# ar_site_id Object ar_site_id
|
57
|
+
# ar_design_id Object Design used for rendering page
|
58
|
+
#
|
59
|
+
# ArPage documents are anchors for urls. Default ArApplicationController.ar_process_default_request()
|
60
|
+
# method searches for ArPage document by link, id or alt_link. When found it loads
|
61
|
+
# design document defined by design_id and renders view code defined by design.
|
62
|
+
#
|
63
|
+
# Site owner has all control of how ArPage data is rendered by providing its own page renderer methods.
|
64
|
+
#
|
65
|
+
# Every ArPage document may embed many ArPart documents. ArPart documents mostly contain fields
|
66
|
+
# with same names and functionality as ArPage fields. And may therefore represent whole subpage data
|
67
|
+
# system within single document. Clever programmer may provide data for whole web site in just
|
68
|
+
# one ArSite, one ArMenu, one ArDesign and one ArPage document (with some embedded documents). And since
|
69
|
+
# AgileRails runs multiple sites on single Rails instance by default it may run hundreds of small sites
|
70
|
+
# on single Ruby on Rails instance.
|
71
|
+
#########################################################################
|
72
|
+
class ArPage < ApplicationRecord
|
73
|
+
include ArPageConcern
|
74
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#+
|
23
|
+
|
24
|
+
########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Table name: ar_part : Parts of page
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# created_at Time created_at
|
31
|
+
# updated_at Time Last updated at
|
32
|
+
# name String Parts can be searched by name or by id
|
33
|
+
# description String Short description of part
|
34
|
+
# picture String Picture contents of part
|
35
|
+
# thumbnail String Small version of picture if available
|
36
|
+
# body String Content of this part
|
37
|
+
# css String CSS
|
38
|
+
# script String Script, if script is included in part
|
39
|
+
# script_type String Script type
|
40
|
+
# params String params
|
41
|
+
# piece_id Integer Piece name if part is connected to piece
|
42
|
+
# div_id String Div id (position name) where this part is displayed as defined on design
|
43
|
+
# site_id Integer site_id
|
44
|
+
# order Integer Order between parts
|
45
|
+
# active Boolean Part is active
|
46
|
+
# valid_from DateTime Part is valid from
|
47
|
+
# valid_to DateTime Part is valid to
|
48
|
+
# created_by Integer created_by
|
49
|
+
# updated_by Integer Last updated by
|
50
|
+
# _type String _type
|
51
|
+
# policy_id Integer Access policy for the part
|
52
|
+
# link String Link when part can be accessed with pretty link
|
53
|
+
#
|
54
|
+
# ArPart model is used for embedding parts of final document into other models. It declares fields
|
55
|
+
# which may be used in various scenarios. For example:
|
56
|
+
# - part of page which is visible to all users and part only to registered users
|
57
|
+
# - list of pictures or attachments which belong to document
|
58
|
+
# -
|
59
|
+
#
|
60
|
+
# ArPart model inherits its definition from ArPiece model, but adds policy_id
|
61
|
+
# field to definition. Policy_id field may be used where site policy must be
|
62
|
+
# taken into account when rendering part.
|
63
|
+
########################################################################
|
64
|
+
class ArPart < ApplicationRecord
|
65
|
+
include ArPartConcern
|
66
|
+
end
|