drg_cms 0.6.0.8 → 0.6.1.0
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 +4 -4
- data/app/assets/javascripts/drg_cms/drg_cms.js +100 -58
- data/app/assets/stylesheets/drg_cms/drg_cms.css +177 -43
- data/app/controllers/cmsedit_controller.rb +149 -145
- data/app/controllers/dc_application_controller.rb +235 -113
- data/app/controllers/dc_common_controller.rb +32 -3
- data/app/controls/dc_help_control.rb +126 -0
- data/app/controls/dc_report.rb +5 -7
- data/app/forms/all_options.yml +10 -4
- data/app/forms/cms_menu.yml +7 -1
- data/app/forms/dc_category.yml +2 -1
- data/app/forms/dc_design.yml +1 -0
- data/app/forms/dc_help_1.yml +109 -0
- data/app/forms/dc_journal.yml +3 -1
- data/app/forms/dc_link.yml +1 -1
- data/app/forms/dc_menu.yml +2 -0
- data/app/forms/dc_menu_item.yml +1 -0
- data/app/forms/dc_page.yml +2 -0
- data/app/forms/dc_part.yml +1 -0
- data/app/forms/dc_piece.yml +1 -0
- data/app/forms/dc_poll.yml +3 -0
- data/app/forms/dc_simple_menu.yml +2 -0
- data/app/forms/dc_site.yml +2 -6
- data/app/forms/dc_user.yml +27 -11
- data/app/forms/dc_user_role.yml +3 -0
- data/app/helpers/cms_common_helper.rb +69 -4
- data/app/helpers/cms_edit_helper.rb +32 -24
- data/app/helpers/cms_helper.rb +64 -26
- data/app/helpers/cms_index_helper.rb +84 -72
- data/app/helpers/dc_application_helper.rb +33 -24
- data/app/models/concerns/dc_page_concern.rb +11 -2
- data/app/models/concerns/dc_policy_rule_concern.rb +20 -8
- data/app/models/concerns/dc_site_concern.rb +56 -44
- data/app/models/concerns/dc_user_concern.rb +57 -18
- data/app/models/dc_design.rb +29 -19
- data/app/models/dc_key_value_store.rb +1 -0
- data/app/models/dc_permission.rb +19 -9
- data/app/models/dc_policy.rb +25 -14
- data/app/models/dc_policy_role.rb +22 -11
- data/app/models/dc_temp.rb +1 -1
- data/app/models/dc_user_role.rb +2 -2
- data/app/models/drgcms_form_fields/embedded.rb +5 -8
- data/app/models/drgcms_form_fields/file_field.rb +1 -1
- data/app/models/drgcms_form_fields/file_select.rb +2 -2
- data/app/models/drgcms_form_fields/hash_field.rb +11 -7
- data/app/models/drgcms_form_fields/link_to.rb +2 -2
- data/app/models/drgcms_form_fields/method.rb +5 -4
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +1 -1
- data/app/models/drgcms_form_fields/select.rb +10 -9
- data/app/models/drgcms_form_fields/text_autocomplete.rb +2 -2
- data/app/views/cmsedit/edit.html.erb +2 -0
- data/app/views/cmsedit/index.html.erb +2 -1
- data/app/views/cmsedit/new.html.erb +2 -0
- data/app/views/dc_common/_help.html.erb +8 -0
- data/app/views/layouts/models.html.erb +2 -1
- data/config/locales/drgcms_en.yml +12 -0
- data/config/locales/drgcms_sl.yml +15 -0
- data/config/locales/models_en.yml +5 -5
- data/config/locales/models_sl.yml +7 -6
- data/lib/drg_cms.rb +58 -0
- data/lib/drg_cms/version.rb +1 -1
- metadata +5 -3
- data/app/models/__dc_dummy.rb +0 -102
data/app/models/dc_permission.rb
CHANGED
@@ -44,23 +44,23 @@ class DcPermission
|
|
44
44
|
#- Available permissions settings
|
45
45
|
|
46
46
|
# User has no access
|
47
|
-
NO_ACCESS
|
47
|
+
NO_ACCESS = 0
|
48
48
|
# User can view documents
|
49
|
-
CAN_VIEW
|
49
|
+
CAN_VIEW = 1
|
50
50
|
# User can create new documents
|
51
|
-
CAN_CREATE
|
51
|
+
CAN_CREATE = 2
|
52
52
|
# User can edit his own documents
|
53
|
-
CAN_EDIT
|
53
|
+
CAN_EDIT = 4
|
54
54
|
# User can edit all documents in collection
|
55
|
-
CAN_EDIT_ALL
|
55
|
+
CAN_EDIT_ALL = 8
|
56
56
|
# User can delete his own documents
|
57
|
-
CAN_DELETE
|
57
|
+
CAN_DELETE = 16
|
58
58
|
# User can delete all documents in collection
|
59
59
|
CAN_DELETE_ALL = 32
|
60
60
|
# User can admin collection (same as can_delete_all, but can see documents which do not belong to current site)
|
61
|
-
CAN_ADMIN
|
61
|
+
CAN_ADMIN = 64
|
62
62
|
# User is superadmin. Basicly same as admin.
|
63
|
-
SUPERADMIN
|
63
|
+
SUPERADMIN = 128
|
64
64
|
|
65
65
|
include Mongoid::Document
|
66
66
|
include Mongoid::Timestamps
|
@@ -75,7 +75,17 @@ embeds_many :dc_policy_rules, as: :policy_rules
|
|
75
75
|
index( { table_name: 1 }, { unique: true } )
|
76
76
|
|
77
77
|
validates :table_name, presence: true
|
78
|
-
validates :table_name, uniqueness: true
|
78
|
+
validates :table_name, uniqueness: true
|
79
|
+
|
80
|
+
after_save :cache_clear
|
81
|
+
after_destroy :cache_clear
|
82
|
+
|
83
|
+
####################################################################
|
84
|
+
# Clear cache if cache is configured
|
85
|
+
####################################################################
|
86
|
+
def cache_clear
|
87
|
+
DrgCms.cache_clear(:dc_permission)
|
88
|
+
end
|
79
89
|
|
80
90
|
########################################################################
|
81
91
|
# Will return choices for permissions prepared for usega in select input field.
|
data/app/models/dc_policy.rb
CHANGED
@@ -45,22 +45,33 @@
|
|
45
45
|
# other policies. Default policy is also used when document has no access policy assigned.
|
46
46
|
#########################################################################
|
47
47
|
class DcPolicy
|
48
|
-
|
49
|
-
|
48
|
+
include Mongoid::Document
|
49
|
+
include Mongoid::Timestamps
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
field :name, type: String
|
52
|
+
field :description, type: String, default: ''
|
53
|
+
field :is_default, type: Boolean, default: false
|
54
|
+
field :active, type: Boolean, default: true
|
55
|
+
field :updated_by, type: BSON::ObjectId
|
56
|
+
field :message, type: String, default: ''
|
57
|
+
|
58
|
+
embeds_many :dc_policy_rules, as: :policy_rules
|
59
|
+
embedded_in :dc_site
|
60
|
+
|
61
|
+
validates :name, length: { minimum: 4 }
|
62
|
+
validates :message, length: { minimum: 5 }
|
63
|
+
|
64
|
+
after_save :cache_clear
|
65
|
+
after_destroy :cache_clear
|
66
|
+
|
67
|
+
####################################################################
|
68
|
+
# Clear cache if cache is configured
|
69
|
+
####################################################################
|
70
|
+
def cache_clear
|
71
|
+
DrgCms.cache_clear(:dc_permission)
|
72
|
+
DrgCms.cache_clear(:dc_site)
|
73
|
+
end
|
60
74
|
|
61
|
-
validates :name, :length => { :minimum => 4 }
|
62
|
-
validates :message, :length => { :minimum => 5 }
|
63
|
-
|
64
75
|
=begin
|
65
76
|
#########################################################################
|
66
77
|
# Returns values for permissions ready to be used in select field.
|
@@ -38,18 +38,29 @@
|
|
38
38
|
# which can be persistent, when application is used as Rails plugin.
|
39
39
|
#########################################################################
|
40
40
|
class DcPolicyRole
|
41
|
-
|
42
|
-
|
41
|
+
include Mongoid::Document
|
42
|
+
include Mongoid::Timestamps
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
44
|
+
field :name, type: String
|
45
|
+
field :system_name, type: String
|
46
|
+
field :active, type: Boolean, default: true
|
47
|
+
|
48
|
+
index( { name: 1 }, { unique: true } )
|
49
|
+
index( system_name: 1 )
|
50
|
+
|
51
|
+
validates :name, :length => { :minimum => 4 }
|
52
|
+
validates :name, uniqueness: true
|
53
|
+
|
54
|
+
after_save :cache_clear
|
55
|
+
after_destroy :cache_clear
|
56
|
+
|
57
|
+
####################################################################
|
58
|
+
# Clear cache if cache is configured
|
59
|
+
####################################################################
|
60
|
+
def cache_clear
|
61
|
+
DrgCms.cache_clear(:dc_permission)
|
62
|
+
DrgCms.cache_clear(:dc_site)
|
63
|
+
end
|
53
64
|
|
54
65
|
########################################################################
|
55
66
|
# Return all defined roles as choices for use in select field.
|
data/app/models/dc_temp.rb
CHANGED
@@ -46,7 +46,7 @@ class DcTemp
|
|
46
46
|
########################################################################
|
47
47
|
def initialize(parms = {})
|
48
48
|
super()
|
49
|
-
parms.stringify_keys
|
49
|
+
parms = parms.nil? ? {} : parms.stringify_keys
|
50
50
|
self.key = parms.delete('key') if parms['key']
|
51
51
|
self.active = parms.delete('active') if parms['active']
|
52
52
|
self.order = parms.delete('order') if parms['order']
|
data/app/models/dc_user_role.rb
CHANGED
@@ -57,8 +57,8 @@ class DcUserRole
|
|
57
57
|
# Determine of role is still active
|
58
58
|
###############################################################################
|
59
59
|
def active?
|
60
|
-
now = Time.
|
61
|
-
|
60
|
+
now = Time.current
|
61
|
+
active && (valid_from.nil? || now > valid_from) && (valid_to.nil? || now < valid_to)
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
@@ -49,20 +49,17 @@ class Embedded < DrgcmsField
|
|
49
49
|
###########################################################################
|
50
50
|
# Render embedded field html code
|
51
51
|
###########################################################################
|
52
|
-
def render
|
53
|
-
#return self if @record.new_record? # would be in error otherwise
|
52
|
+
def render
|
54
53
|
# HTML defaults. Some must be set
|
55
54
|
@yaml['html'] ||= {}
|
56
|
-
@yaml['html']['
|
57
|
-
@yaml['html']
|
55
|
+
@yaml['html']['width'] ||= '99%'
|
56
|
+
html = @yaml['html'].inject('') { |r, val| r << "#{val.first}=\"#{val.last}\" " }
|
57
|
+
|
58
58
|
@yaml['action'] ||= 'index'
|
59
59
|
# defaults both way
|
60
60
|
@yaml['table'] ||= @yaml['form_name'] if @yaml['form_name']
|
61
61
|
@yaml['form_name'] ||= @yaml['table'] if @yaml['table']
|
62
|
-
|
63
|
-
html = ''
|
64
|
-
@yaml['html'].each {|k,v| html << "#{k}=\"#{v}\" "}
|
65
|
-
#
|
62
|
+
|
66
63
|
if @yaml['name'] == @yaml['table'] or @yaml['table'] == 'dc_memory'
|
67
64
|
tables = @yaml['table']
|
68
65
|
ids = @record.id
|
@@ -43,7 +43,7 @@ class FileField < DrgcmsField
|
|
43
43
|
###########################################################################
|
44
44
|
def render
|
45
45
|
return self if @readonly
|
46
|
-
|
46
|
+
|
47
47
|
@html << @parent.file_field(nil,@yaml['name'], @yaml['html'])
|
48
48
|
self
|
49
49
|
end
|
@@ -50,10 +50,10 @@ class FileSelect < DrgcmsField
|
|
50
50
|
###########################################################################
|
51
51
|
def render
|
52
52
|
return ro_standard if @readonly
|
53
|
-
# retrieve
|
53
|
+
# retrieve file_select component from site settings
|
54
54
|
selector_string = @parent.dc_get_site.params['file_select'] if @parent.dc_get_site
|
55
55
|
selector_string ||= 'elfinder'
|
56
|
-
|
56
|
+
|
57
57
|
klas_string = selector_string.camelize
|
58
58
|
if DrgcmsFormFields.const_defined?(klas_string)
|
59
59
|
klas = DrgcmsFormFields::const_get(klas_string)
|
@@ -45,6 +45,7 @@ class HashField < DrgcmsField
|
|
45
45
|
###########################################################################
|
46
46
|
def ro_standard()
|
47
47
|
return self if @record[@yaml['name']].nil?
|
48
|
+
|
48
49
|
html = ''
|
49
50
|
@record[@yaml['name']].each do |key, value|
|
50
51
|
html << "#{key}:#{value}<br>"
|
@@ -57,10 +58,10 @@ end
|
|
57
58
|
###########################################################################
|
58
59
|
def render
|
59
60
|
return ro_standard if @readonly
|
61
|
+
|
60
62
|
set_initial_value
|
61
|
-
#
|
62
63
|
record = record_text_for(@yaml['name'])
|
63
|
-
# Convert Hash to values separated by colon
|
64
|
+
# Convert Hash to values separated by colon
|
64
65
|
if @record[@yaml['name']]
|
65
66
|
@yaml['html']['value'] = @record[@yaml['name']].to_a.inject('') {|r, e| r << "#{e.first}:#{e.last}\n"}
|
66
67
|
end
|
@@ -73,12 +74,15 @@ end
|
|
73
74
|
###########################################################################
|
74
75
|
def self.get_data(params, name)
|
75
76
|
return nil if params['record'][name].blank?
|
76
|
-
|
77
|
-
result = params['record'][name].split("\n").select {|e| !e.blank? }
|
78
|
-
return
|
79
|
-
# convert to Hash
|
77
|
+
|
78
|
+
result = params['record'][name].split("\n").select { |e| !e.blank? }
|
79
|
+
return if result.size == 0
|
80
|
+
# convert to Hash
|
80
81
|
ret = {}
|
81
|
-
result.map
|
82
|
+
result.map do |e|
|
83
|
+
key, value = e.chomp.split(':')
|
84
|
+
ret[key.strip] = value.strip if value.present?
|
85
|
+
end
|
82
86
|
ret
|
83
87
|
end
|
84
88
|
|
@@ -53,13 +53,13 @@ def render
|
|
53
53
|
@yaml['html'] ||= {}
|
54
54
|
@yaml['html']['class'] ||= 'dc-link dc-animate'
|
55
55
|
@yaml['html'].symbolize_keys!
|
56
|
-
|
56
|
+
|
57
57
|
@yaml[:id] = record._id if @yaml[:id] == 'id'
|
58
58
|
url = @yaml['url'] || "#{@yaml[:controller]}/#{@yaml[:action]}/#{@yaml[:id]}"
|
59
59
|
url.gsub!('//','/') # no action and id
|
60
60
|
url = '/' + @yaml['url'] unless url[0,1] == '/' # no leading /
|
61
61
|
url.chop if url[0,-1] == '/' # remove trailing /
|
62
|
-
|
62
|
+
|
63
63
|
caption = @yaml['caption'] || @yaml['text']
|
64
64
|
@html << @parent.dc_link_to(caption, @yaml['icon'], url, @yaml['html'])
|
65
65
|
self
|
@@ -24,9 +24,10 @@ module DrgcmsFormFields
|
|
24
24
|
|
25
25
|
###########################################################################
|
26
26
|
# Implementation of custom DRG CMS form field. Method field will call method or class method
|
27
|
-
# defined in eval option and add returned code to HTML output code.
|
28
|
-
#
|
29
|
-
# be
|
27
|
+
# defined in eval option and add returned code to HTML output code.
|
28
|
+
#
|
29
|
+
# It can be used in case when form contains complex data structure. For example set of pictures which can not
|
30
|
+
# be simply displayed by any other DRG Forms field.
|
30
31
|
#
|
31
32
|
# Form example:
|
32
33
|
# 50:
|
@@ -44,7 +45,7 @@ class Method < DrgcmsField
|
|
44
45
|
###########################################################################
|
45
46
|
def render
|
46
47
|
# might be defined as my_method or MyClass.my_method
|
47
|
-
clas, method = @yaml['eval'].split(
|
48
|
+
clas, method = @yaml['eval'].split(/\.|\,/).map(&:strip)
|
48
49
|
if method.nil?
|
49
50
|
if @parent.respond_to?(clas)
|
50
51
|
@html << @parent.send(clas, @record, @yaml, @readonly)
|
@@ -77,7 +77,7 @@ def render
|
|
77
77
|
method = @yaml['search']['method']
|
78
78
|
search = method.nil? ? field_name : "#{field_name}.#{method}"
|
79
79
|
elsif @yaml['search'].to_s.match(/\./)
|
80
|
-
table, field_name, method = @yaml['search'].split(/\.|\,/)
|
80
|
+
table, field_name, method = @yaml['search'].split(/\.|\,/).map(&:strip)
|
81
81
|
search = method.nil? ? field_name : "#{field_name}.#{method}"
|
82
82
|
else # search and table name are separated
|
83
83
|
search = field_name = @yaml['search']
|
@@ -133,7 +133,8 @@ def get_choices
|
|
133
133
|
choices.chomp.split(',').inject([]) { |r,v| r << (v.match(':') ? v.split(':') : v ) } :
|
134
134
|
choices
|
135
135
|
rescue Exception => e
|
136
|
-
Rails.logger.debug "
|
136
|
+
Rails.logger.debug "\nError in select eval. #{e.message}\n"
|
137
|
+
Rails.logger.debug(e.backtrace.join($/)) if Rails.env.development?
|
137
138
|
['error'] # return empty array when error occures
|
138
139
|
end
|
139
140
|
end
|
@@ -143,6 +144,7 @@ end
|
|
143
144
|
###########################################################################
|
144
145
|
def add_view_code
|
145
146
|
return '' if (data = @record.send(@yaml['name'])).blank?
|
147
|
+
|
146
148
|
ar = @yaml['view'].split(/\ |\,/).delete_if {|e| e.blank?}
|
147
149
|
table, form_name = *ar
|
148
150
|
url = @parent.url_for(controller: :cmsedit, id: data, action: :edit, table: table, form_name: form_name, readonly: true, window_close: 1 )
|
@@ -186,16 +188,16 @@ end
|
|
186
188
|
###########################################################################
|
187
189
|
def render
|
188
190
|
return ro_standard if @readonly
|
191
|
+
|
189
192
|
set_initial_value('html','selected')
|
190
193
|
# separate options and html part
|
191
|
-
@yaml['html'].symbolize_keys!
|
192
194
|
html_part = {}
|
193
|
-
|
194
|
-
html_part[
|
195
|
-
html_part[:
|
195
|
+
@yaml['html'].symbolize_keys!
|
196
|
+
%i(class id style required).each { |sym| html_part[sym] = @yaml['html'].delete(sym) if html_part[sym]}
|
197
|
+
html_part[:multiple] = true if @yaml['multiple']
|
198
|
+
|
196
199
|
record = record_text_for(@yaml['name'])
|
197
|
-
if
|
198
|
-
html_part[:multiple] = true
|
200
|
+
if html_part[:multiple]
|
199
201
|
@html << @parent.select(record, @yaml['name'], get_choices, @yaml['html'], html_part)
|
200
202
|
@js << "$('##{record}_#{@yaml['name']}').selectMultiple();"
|
201
203
|
else
|
@@ -212,12 +214,11 @@ end
|
|
212
214
|
def self.get_data(params, name)
|
213
215
|
if params['record'][name].class == Array
|
214
216
|
params['record'][name].delete_if {|e| e.blank? }
|
215
|
-
return
|
217
|
+
return if params['record'][name].size == 0
|
216
218
|
|
217
219
|
# convert to BSON objects
|
218
220
|
is_id = BSON::ObjectId.legal?(params['record'][name].first)
|
219
221
|
return params['record'][name].map{ |e| BSON::ObjectId.from_string(e) } if is_id
|
220
|
-
return params['record'][name]
|
221
222
|
end
|
222
223
|
params['record'][name]
|
223
224
|
end
|
@@ -59,7 +59,7 @@ def render
|
|
59
59
|
ret_name = @yaml['search']['field']
|
60
60
|
method = @yaml['search']['method']
|
61
61
|
elsif @yaml['search'].match(/\./)
|
62
|
-
table, ret_name, method = @yaml['search'].split(
|
62
|
+
table, ret_name, method = @yaml['search'].split(/\.|\,/).map(&:strip)
|
63
63
|
else
|
64
64
|
ret_name = @yaml['search']
|
65
65
|
end
|
@@ -74,7 +74,7 @@ def render
|
|
74
74
|
nil
|
75
75
|
end
|
76
76
|
end
|
77
|
-
return 'Table or field keyword not defined!' unless (table
|
77
|
+
return ro_standard 'Table or field keyword not defined!' unless (table && ret_name)
|
78
78
|
# TODO check if table exists
|
79
79
|
t = table.classify.constantize
|
80
80
|
# find record and return value of field
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="dc-form-frame">
|
2
|
-
<%=
|
2
|
+
<%= dc_title_for_index @records %>
|
3
3
|
|
4
4
|
<%= dc_actions_for_index %>
|
5
5
|
<%= dc_div_filter %>
|
@@ -9,3 +9,4 @@
|
|
9
9
|
|
10
10
|
<%= javascript_tag(@js) unless @js.blank? %>
|
11
11
|
<% unless @css.blank? %><style type="text/css"><%= @css %></style><% end %>
|
12
|
+
<div id="popup" style="display: none;"></div>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= javascript_include_tag "cms" %>
|
2
|
+
|
3
|
+
<div class="dc-help">
|
4
|
+
<h1><%= t('drgcms.dc_help.help') %>: <%= dc_form_title %></h1>
|
5
|
+
|
6
|
+
<div class="help-fields"><%= dc_help_fields if params[:type] == 'form' %></div>
|
7
|
+
<div class="help-body"><%= dc_help_body if @help %></div>
|
8
|
+
</div>
|
@@ -118,3 +118,15 @@ en:
|
|
118
118
|
filters:
|
119
119
|
this_site_only: Documents for currently selected site only
|
120
120
|
|
121
|
+
dc_help:
|
122
|
+
help: HELP
|
123
|
+
title: Manage help documents
|
124
|
+
project: Project
|
125
|
+
lang: Locale
|
126
|
+
project_refresh: Refresh
|
127
|
+
project_refresh_title: Refresh list of available documents
|
128
|
+
form_name: Form
|
129
|
+
updated_at: Updated
|
130
|
+
1basic: Basic
|
131
|
+
2index: Index
|
132
|
+
3form: Form
|