app/helpers/cmsedit_helper.rb in drg_cms-0.4.61 vs app/helpers/cmsedit_helper.rb in drg_cms-0.5.0
- old
+ new
@@ -46,15 +46,13 @@
actions['standard'] = nil
end
# start div with hidden spinner image
html = <<EOT
<div id="dc-action-menu">
- <span id="dc-spinner" class="div-hidden">#{fa_icon('spinner lg spin')}"</span>
+ <span id="dc-spinner" class="div-hidden">#{fa_icon('spinner lg spin')}</span>
<ul class="dc-action-menu">
EOT
-# #{fa_icon('spinner lg spin', id: 'dc-spinner', class: 'div-hidden')}
-
#
actions.each do |k,v|
session[:form_processing] = "index:actions: #{k}=#{v}"
next if v.nil? # must be
url = @parms.clone
@@ -97,11 +95,12 @@
# caption << ' '+image_tag('drg_cms/checkbox-checked.png') if s and s[:filter]
yhtml['onclick'] = "$('#drgcms_filter').toggle(300);"
# link_to(caption.html_safe, '#', yhtml )
dc_link_to('drgcms.filter','filter', '#', yhtml )
when action == 'new' then # new
- dc_link_to(t('drgcms.new'),'plus', url, yhtml )
+ caption = yaml['caption'] || 'drgcms.new'
+ dc_link_to(caption,'plus', url, yhtml )
when action == 'menu' then # menu
caption = t(v['caption'], v['caption'])
caption + eval(v['eval'])
else
caption = yaml['caption'] || yaml['text']
@@ -217,45 +216,10 @@
end
dc_table_title(title, result)
end
############################################################################
-# Similar to rails submit_tag, but also takes care of link icon, translation, ...
-############################################################################
-def dc_submit_tag(caption, icon, parms, rest={})
- parms['class'] ||= 'dc-submit'
- if icon
- icon_image = if icon.match(/\./)
- image_tag(icon, class: 'dc-animate')
- else
- fa_icon(icon)
- end
- end
- html = icon_image || ''
- html << submit_tag(t(caption, caption), parms)
-end
-############################################################################
-# Similar to rails link_to, but also takes care of link icon, translation, ...
-############################################################################
-def dc_link_to(caption, icon, parms, rest={})
- rest['class'] = rest['class'].to_s + ' dc-animate'
- if icon
- icon_image = if icon.match(/\./)
- image_tag(icon, class: 'dc-link-img dc-animate')
- else
- fa_icon(icon)
- end
- end
-#
- if caption
- caption = t(caption, caption)
- icon_image << ' ' if icon_image
- end
- link_to("#{icon_image}#{caption}".html_safe, parms, rest)
-end
-
-############################################################################
# Creates code for link or ajax action type. Subroutine of dc_actions_for_result.
############################################################################
def dc_link_or_ajax(yaml, parms) #:nodoc:
rest = {}
rest['method'] = yaml['method'] || yaml['request'] || 'get'
@@ -334,10 +298,11 @@
dc_link_to( nil, 'pencil lg', parms )
when yaml['type'] == 'duplicate' then
parms['id'] = record.id
# duplicate string will be added to these fields.
parms['dup_fields'] = yaml['dup_fields']
+ parms['action'] = 'create'
dc_link_to( nil, 'copy lg', parms, data: { confirm: t('drgcms.confirm_dup') }, method: :post )
when yaml['type'] == 'delete' then
parms['action'] = 'destroy'
parms['id'] = record.id
dc_link_to( nil, 'remove lg', parms, data: { confirm: t('drgcms.confirm_delete') }, method: :delete )
@@ -483,12 +448,14 @@
actions = nil if actions.class == String && actions == 'standard'
# standard actions
actions = std_actions if actions.nil?
# readonly
actions = {' 1' => 'back'} if @form['readonly']
-
- if actions['standard']
+# Actions are strictly forbidden
+ if @form['form']['actions'] and dc_dont?(@form['form']['actions'])
+ actions = []
+ elsif actions['standard']
actions.merge!(std_actions)
actions['standard'] = nil
end
# Update save and save&back
actions.each do |k,v|
@@ -761,11 +728,12 @@
############################################################################
def dc_document_statistics
return '' if @record.new_record? or dc_dont?(@form['form']['info'])
html = "<div id='dc-document-info'>#{t('drgcms.doc_info')}</div>"
# html = "<div id='dc-document-info'>#{fa_icon 'info-circle 2x'}</div>"
- html << "<div id='dc-document-info-popup' class='div-hidden'><table>"
+ html = '<div id="dc-document-info">' + fa_icon('info-circle lg') + '</div>'
#
+ html << "<div id='dc-document-info-popup' class='div-hidden'><table>"
u = _get_user_for('created_by')
html << "<tr><td>#{t('drgcms.created_by', 'Created by')}: </td><td><b>#{u}</td></tr>" if u
u = _get_user_for('updated_by')
html << "<tr><td>#{t('drgcms.updated_by', 'Updated by')}: </td><td><b>#{u}</td></tr>" if u
html << "<tr><td>#{t('drgcms.created_at', 'Created at')}: </td><td><b>#{dc_format_value(@record.created_at)}</td></tr>" if @record['created_at']