Module: NotesHelper

Defined in:
frontend/app/helpers/notes_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) bioghist_subnotes



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'frontend/app/helpers/notes_helper.rb', line 98

def bioghist_subnotes
  note_types = {}

  JSONModel(:note_bioghist).schema['properties']['subnotes']['items']['type'].each do |item_def|
    type = JSONModel.parse_jsonmodel_ref(item_def['type'])[0].to_s
    note_types[type] = {
      :value => type,
      :i18n => I18n.t("#{type}.option", :default => type)
    }
  end

  note_types
end

- (Object) clean_note(note)



113
114
115
# File 'frontend/app/helpers/notes_helper.rb', line 113

def clean_note(note)
  MixedContentParser::parse(note, url_for(:root), :wrap_blocks => true)
end

- (Object) multipart_notes



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'frontend/app/helpers/notes_helper.rb', line 67

def multipart_notes
  note_types = {}

  JSONModel.enum_values(JSONModel(:note_multipart).schema['properties']['type']['dynamic_enum']).each do |type|
    note_types[type] = {
      :target => :note_multipart,
      :enum => JSONModel(:note_multipart).schema['properties']['type']['dynamic_enum'],
      :value => type,
      :i18n => I18n.t("enumerations.#{JSONModel(:note_multipart).schema['properties']['type']['dynamic_enum']}.#{type}", :default => type)
    }
  end

  note_types
end

- (Object) multipart_subnotes



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'frontend/app/helpers/notes_helper.rb', line 83

def multipart_subnotes
  note_types = {}

  JSONModel(:note_multipart).schema['properties']['subnotes']['items']['type'].each do |item_def|
    type = JSONModel.parse_jsonmodel_ref(item_def['type'])[0].to_s
    note_types[type] = {
      :value => type,
      :i18n => I18n.t("#{type}.option", :default => type)
    }
  end

  note_types
end

- (Object) note_types_for(jsonmodel_type)



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'frontend/app/helpers/notes_helper.rb', line 5

def note_types_for(jsonmodel_type)
  note_types = {
    "bibliography" => {
      :target => :note_bibliography,
      :value => "bibliography",
      :i18n => I18n.t("enumerations._note_types.bibliography", :default => "bibliography")
    }
  }

  if jsonmodel_type =~ /digital_object/

    # Digital object/digital object component
    JSONModel.enum_values(JSONModel(:note_digital_object).schema['properties']['type']['dynamic_enum']).each do |type|
      note_types[type] = {
        :target => :note_digital_object,
        :enum => JSONModel(:note_digital_object).schema['properties']['type']['dynamic_enum'],
        :value => type,
        :i18n => I18n.t("enumerations.#{JSONModel(:note_digital_object).schema['properties']['type']['dynamic_enum']}.#{type}", :default => type)
      }
    end

  elsif jsonmodel_type =~ /agent/

    note_types = {"bioghist" => {
        :target => :note_bioghist,
        :value => "bioghist",
        :i18n => I18n.t("enumerations._note_types.bioghist", :default => "bioghist")
      }
    }

  else

    note_types.merge!(singlepart_notes)
    note_types.merge!(multipart_notes)

    note_types["index"] = {
      :target => :note_index,
      :value => "index",
      :i18n => I18n.t("enumerations._note_types.index", :default => "index")
    }
  end

  note_types
end

- (Object) singlepart_notes



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'frontend/app/helpers/notes_helper.rb', line 51

def singlepart_notes
  note_types = {}

  JSONModel.enum_values(JSONModel(:note_singlepart).schema['properties']['type']['dynamic_enum']).each do |type|
    note_types[type] = {
      :target => :note_singlepart,
      :enum => JSONModel(:note_singlepart).schema['properties']['type']['dynamic_enum'],
      :value => type,
      :i18n => I18n.t("enumerations.#{JSONModel(:note_singlepart).schema['properties']['type']['dynamic_enum']}.#{type}", :default => type)
    }
  end

  note_types
end