Class: DrgcmsFormFields::JournalDiff
- Inherits:
-
DrgcmsField
- Object
- DrgcmsField
- DrgcmsFormFields::JournalDiff
- Defined in:
- app/models/drgcms_form_fields.rb
Overview
Implementation of journal_diff DRG CMS form field. journal_diff field is used to show differences between two fields in DcJournal collection.
Form options:
-
name:field name (required) -
type:journal_diff (required)
Form example:
10:
name: diff
type: journal_diff
html:
size: 100x25
Instance Attribute Summary
Attributes inherited from DrgcmsField
Instance Method Summary collapse
-
#render ⇒ Object
Render journal_diff field html code.
Methods inherited from DrgcmsField
get_data, #hash_to_options, #initialize, #record_text_for, #ro_standard, #set_initial_value, #set_style, #t
Constructor Details
This class inherits a constructor from DrgcmsFormFields::DrgcmsField
Instance Method Details
#render ⇒ Object
Render journal_diff field html code
385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'app/models/drgcms_form_fields.rb', line 385 def render @yaml['name'] = 'old' if @record[@yaml['name']].nil? @html << '<table width="99%">' JSON.parse(@record[@yaml['name']]).each do |k,v| old_value = v.class == Array ? v[0] : v new_value = v.class == Array ? v[1] : v @html << "<tr><td style='background-color: #654ddd;'>#{@parent.check_box('select', k)} #{k}:</td></tr> <tr><td style='background-color: #ffe;'>- #{old_value}</td></tr> <tr><td style='background-color: #eff;'>+ #{new_value}</td></tr>" end @html << '</table>' self end |