diff --git a/flat/style/flat.editor.js b/flat/style/flat.editor.js index 83c16a3..9917634 100644 --- a/flat/style/flat.editor.js +++ b/flat/style/flat.editor.js @@ -386,6 +386,16 @@ function addhigherorderfield(set, index, type) { } else if (folia_isspanrole(type)) { newchildannotation = {'type':type,'targets': []}; } + if (folia_occurrences(type) == 1) { + //ensure we don't add a duplicate + var exists = false; + for (var i = 0; i < editdata[index].children.length; i++) { + if (editdata[index].children[i].type == type) { + alert("An annotation of this type already exists, there can be only one"); + return false; + } + } + } if (newchildannotation !== null) { $('#higherorderfields' + index + "placeholder")[0].outerHTML = "" + diff --git a/flat/style/folia.js b/flat/style/folia.js index ddf02bf..c0bd430 100644 --- a/flat/style/folia.js +++ b/flat/style/folia.js @@ -194,11 +194,10 @@ function folia_required_spanroles(tag) { return spanroles; } -} function folia_occurrences_class(elementclass) { /* Get the maximum amount of occurrences for this element class (0=unlimited) */ - if ((foliaelements[elementclass]) && (foliaelements[elementclass].properties) && (foliaelements[elementclass].properties.occurrences)) { + if ((foliaelements[elementclass]) && (foliaelements[elementclass].properties) && (foliaelements[elementclass].properties.occurrences !== undefined)) { return foliaelements[elementclass].properties.occurrences; } else if (foliaelements[elementclass].ancestors.length >= 1) { return folia_occurrences_class(foliaelements[elementclass].ancestors[0]);