Module: NotesHelper

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

Instance Method Summary collapse

Instance Method Details

#bioghist_subnotesObject



236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'frontend/app/helpers/notes_helper.rb', line 236

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

#clean_note(note) ⇒ Object



306
307
308
# File 'frontend/app/helpers/notes_helper.rb', line 306

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

#general_context_subnotesObject



250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'frontend/app/helpers/notes_helper.rb', line 250

def general_context_subnotes
  note_types = {}

  JSONModel(:note_general_context).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


278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'frontend/app/helpers/notes_helper.rb', line 278

def legal_status_subnotes
  note_types = {}

  JSONModel(:note_legal_status).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

#mandate_subnotesObject



264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'frontend/app/helpers/notes_helper.rb', line 264

def mandate_subnotes
  note_types = {}

  JSONModel(:note_mandate).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

#multipart_notesObject



205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'frontend/app/helpers/notes_helper.rb', line 205

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

#multipart_subnotesObject



221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'frontend/app/helpers/notes_helper.rb', line 221

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

#note_types_for(jsonmodel_type) ⇒ Object



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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# 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 =~ /lang_material/

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

  elsif jsonmodel_type =~ /used_language/

    note_types = {
      "text" => {
        :target => :note_text,
        :value => "text",
        :i18n => I18n.t("note.note_text")
      },
      "citation" => {
        :target => :note_citation,
        :value => "citation",
        :i18n => I18n.t("note.note_citation")
      }
    }

  elsif jsonmodel_type == "agent_contact"

    note_types = {
      "contact_note" => {
        :target => :note_contact_note,
        :value => "contact_note",
        :i18n => I18n.t("note.note_contact_note")
      }
    }

  elsif jsonmodel_type == "agent_place" ||
        jsonmodel_type == "agent_occupation" ||
        jsonmodel_type == "agent_function" ||
        jsonmodel_type == "agent_topic" ||
        jsonmodel_type == "agent_gender"

    note_types = {
      "text" => {
        :target => :note_text,
        :value => "text",
        :i18n => I18n.t("note.note_text")
      },
      "citation" => {
        :target => :note_citation,
        :value => "citation",
        :i18n => I18n.t("note.note_citation")
      }
    }

  elsif jsonmodel_type == "agent_person" ||
        jsonmodel_type == "agent_software"

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

  elsif jsonmodel_type == "agent_family"

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

  elsif jsonmodel_type == "agent_corporate_entity"
    note_types = {
      "bioghist" => {
        :target => :note_bioghist,
        :value => "bioghist",
        :i18n => I18n.t("enumerations._note_types.bioghist", :default => "bioghist")
      },
      "general_context" => {
        :target => :note_general_context,
        :value => "general_context",
        :i18n => I18n.t("enumerations._note_types.general_context", :default => "general_context")
      },
      "mandate" => {
        :target => :note_mandate,
        :value => "mandate",
        :i18n => I18n.t("enumerations._note_types.mandate", :default => "mandate")
      },
      "legal_status" => {
        :target => :note_legal_status,
        :value => "legal_status",
        :i18n => I18n.t("enumerations._note_types.legal_status", :default => "legal_status")
      },
      "structure_or_genealogy" => {
        :target => :note_structure_or_genealogy,
        :value => "structure_or_genealogy",
        :i18n => I18n.t("enumerations._note_types.structure_or_genealogy", :default => "structure_or_genealogy")
      }
    }

  elsif jsonmodel_type == 'rights_statement'

    note_types = {}

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

  elsif jsonmodel_type == 'rights_statement_act'

    note_types = {}

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

  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 = Plugins.handle_note_types_for(jsonmodel_type, note_types, self)

  note_types
end

#singlepart_notesObject



189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'frontend/app/helpers/notes_helper.rb', line 189

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

#structure_or_genealogy_subnotesObject



292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'frontend/app/helpers/notes_helper.rb', line 292

def structure_or_genealogy_subnotes
  note_types = {}

  JSONModel(:note_structure_or_genealogy).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