updates for label management
This commit is contained in:
parent
7ff02342e4
commit
3314e5a4b0
12 changed files with 1226 additions and 75 deletions
|
@ -1,62 +1,93 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Custom form for managing labels for individuals -->
|
||||
<#import "manageLabelsForIndividualMacros.ftl" as m >
|
||||
<#assign requiredHint = "<span class='requiredHint'> *</span>" />
|
||||
<#assign subjectUri = editConfiguration.subjectUri/>
|
||||
<#assign labelStr = "" >
|
||||
<#assign languageTag = "" >
|
||||
<#assign labelSeq = [] >
|
||||
<#if subjectName?? >
|
||||
<h2>${i18n().manage_labels_for} ${subjectName}</h2>
|
||||
<#assign submissionErrorsExist = "false"/>
|
||||
<#assign selectLocalesFullList = {} />
|
||||
<#assign editable = false/>
|
||||
<#if editConfiguration.pageData.editable?has_content>
|
||||
<#assign editable = editConfiguration.pageData.editable />
|
||||
</#if>
|
||||
<#if editSubmission?has_content && editSubmission.submissionExists = true && editSubmission.validationErrors?has_content>
|
||||
<#assign submissionErrors = editSubmission.validationErrors/>
|
||||
<#assign submissionErrorsExist = "true" />
|
||||
</#if>
|
||||
|
||||
<#if editConfiguration.pageData.subjectName?? >
|
||||
<h2>${i18n().manage_labels_for} ${editConfiguration.pageData.subjectName}</h2>
|
||||
<#else>
|
||||
<h2>${i18n().manage_labels_capitalized}</h2>
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
<p id="mngLabelsText">${i18n().manage_labels_intro}</p>
|
||||
|
||||
|
||||
<section id="rdfsLabels" role="container">
|
||||
<ul>
|
||||
<#list labels as label>
|
||||
<#-- the query will return labels with their language tag or datatype, if any. So strip those out -->
|
||||
<#if label?? && ( label?index_of("@") > -1 ) >
|
||||
<#assign labelStr = label?substring(0, label?index_of("@")) >
|
||||
<#assign tagOrTypeStr = label?substring(label?index_of("@")) >
|
||||
<#elseif label?? && ( label?index_of("^^") > -1 ) >
|
||||
<#assign labelStr = label?substring(0, label?index_of("^^")) >
|
||||
<#assign tagOrTypeStr = label?substring(label?index_of("^^")) >
|
||||
<#assign tagOrTypeStr = tagOrTypeStr?replace("^^http","^^<http") >
|
||||
<#assign tagOrTypeStr = tagOrTypeStr?replace("#string","#string>") >
|
||||
<#else>
|
||||
<#assign labelStr = label >
|
||||
<#assign tagOrTypeStr = "" >
|
||||
</#if>
|
||||
<li>
|
||||
<input type="radio" class="labelCheckbox" name="labelCheckbox" id="${labelStr}" tagOrType="${tagOrTypeStr!}" role="radio" />
|
||||
<label class="inline">${labelStr}
|
||||
<#if labelSeq?seq_contains(labelStr)>
|
||||
(duplicate value)
|
||||
</#if>
|
||||
</label>
|
||||
</li>
|
||||
<#assign labelSeq = labelSeq + [labelStr]>
|
||||
</#list>
|
||||
|
||||
<script type="text/javascript">
|
||||
var existingLabelsData = [];
|
||||
</script>
|
||||
|
||||
<ul id="existingLabelsList" name="existingLabelsList">
|
||||
<#if editConfiguration.pageData.labelsSortedByLanguageName?has_content>
|
||||
<#--List of labelInformation objects as value where key = language name -->
|
||||
<#assign labelsSorted = editConfiguration.pageData.labelsSortedByLanguageName />
|
||||
<#--Keys would be the actual names of languages-->
|
||||
<#assign labelLanguages = labelsSorted?keys?sort />
|
||||
<#assign editGenerator = "editForm=edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.RDFSLabelGenerator" />
|
||||
|
||||
<#--What we need here is printing out the labels by the language Name and not language code, starting with untyped first-->
|
||||
<@m.displayExistingLabelsForLanguage "untyped" labelsSorted editable editGenerator/>
|
||||
<@m.displayExistingTypedLabels labelLanguages labelsSorted editable editGenerator/>
|
||||
|
||||
</#if>
|
||||
</ul>
|
||||
|
||||
<br />
|
||||
<p>
|
||||
<input type="button" class="submit" id="submit" value="${i18n().save_button}" role="button" role="input" />
|
||||
<span class="or"> or </span>
|
||||
<a href="${urls.referringPage}" class="cancel" title="${i18n().cancel_title}" >${i18n().cancel_link}</a>
|
||||
<span id="indicator" class="indicator hidden">
|
||||
<img class="indicator" src="${urls.base}/images/indicatorWhite.gif" alt="${i18n().processing_icon}"/> ${i18n().selection_in_process}
|
||||
</span>
|
||||
</p>
|
||||
</section>
|
||||
<p>
|
||||
|
||||
<#if editable>
|
||||
<#include "manageLabelsForIndividualSubmissionErrors.ftl">
|
||||
<div id="showAddForm">
|
||||
<input type="submit" value="${i18n().add_label}" id="showAddFormButton" name="showAddFormButton"> ${i18n().or}
|
||||
<a class="cancel" href="${cancelUrl}&url=/individual" title="${i18n().return_to_profile}">${i18n().return_to_profile}</a>
|
||||
</div>
|
||||
|
||||
<#include "manageLabelsForIndividualAddForm.ftl" >
|
||||
</#if>
|
||||
|
||||
</p>
|
||||
</section>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var selectLocalesFullList = [];
|
||||
<#if editConfiguration.pageData.selectLocaleFullList?has_content>
|
||||
<#assign selectLocalesFullList = editConfiguration.pageData.selectLocaleFullList />
|
||||
<#list selectLocalesFullList as localeInfo>
|
||||
<#assign code = localeInfo["code"] />
|
||||
<#assign label= localeInfo["label"] />
|
||||
selectLocalesFullList.push({'code':'${code}', 'label':'${label}'});
|
||||
</#list>
|
||||
|
||||
</#if>
|
||||
|
||||
var customFormData = {
|
||||
processingUrl: '${urls.base}/edit/primitiveRdfEdit',
|
||||
individualUri: '${subjectUri!}'
|
||||
individualUri: '${subjectUri!}',
|
||||
submissionErrorsExist: '${submissionErrorsExist}',
|
||||
selectLocalesFullList: selectLocalesFullList
|
||||
};
|
||||
var i18nStrings = {
|
||||
errorProcessingLabels: '${i18n().error_processing_labels}'
|
||||
errorProcessingLabels: '${i18n().error_processing_labels}',
|
||||
selectLocaleOptionString : '${i18n().select_locale}'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
<#--The form for adding a new label-->
|
||||
<form id="addLabelForm" name="addLabelForm" class="customForm" action="${submitUrl}">
|
||||
<h2>${i18n().add_label}</h2>
|
||||
<p>
|
||||
<label for="name">${i18n().name} ${requiredHint}</label>
|
||||
<input size="30" type="text" id="label" name="label" value="" />
|
||||
</p>
|
||||
<label for="newLabelLanguage">${i18n().add_label_for_language}</label>
|
||||
<select name="newLabelLanguage" id="newLabelLanguage" >
|
||||
<option value=""<#if !newLabelLanguageValue?has_content> selected="selected"</#if>>${i18n().select_locale}</option>
|
||||
<#if editConfiguration.pageData.selectLocale?has_content>
|
||||
<#assign selectLocale = editConfiguration.pageData.selectLocale />
|
||||
<#--Use the list of names because that is the order we want displayed-->
|
||||
|
||||
<#list selectLocale as locale>
|
||||
|
||||
<option value="${locale.code}"<#if newLabelLanguageValue?has_content && locale.code == newLabelLanguageValue> selected="selected"</#if>>${locale.label}</option>
|
||||
</#list>
|
||||
</#if>
|
||||
</select>
|
||||
|
||||
<input type="hidden" name="editKey" id="editKey" value="${editKey}"/>
|
||||
|
||||
<input type="submit" class="submit" id="submit" value="${i18n().save_button}" role="button" role="input" />
|
||||
${i18n().or}
|
||||
<a href="${urls.referringPage}" class="cancel" title="${i18n().cancel_title}" >${i18n().cancel_link}</a>
|
||||
|
||||
</form>
|
|
@ -0,0 +1,79 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
<#--LabelsSorted is a hash keyed by language name where the value is a list of LabelInformation class objects-->
|
||||
<#macro displayExistingLabelsForLanguage lang labelsSorted editable editGenerator>
|
||||
<#--get label information for this language-->
|
||||
<#assign labelList = labelsSorted[lang] />
|
||||
<#--Reset for every language-->
|
||||
<#assign labelSeq = []/>
|
||||
<#list labelList as labelObject>
|
||||
<#assign labelLiteral = labelObject.labelLiteral />
|
||||
<#assign labelStringValue = labelObject.labelStringValue />
|
||||
<#--Try label as label literal-->
|
||||
<#assign label = labelLiteral />
|
||||
<#assign labelLang = labelObject.languageName />
|
||||
<#assign languageCode = labelObject.languageCode />
|
||||
<#assign labelEditLink = labelObject.editLinkURL />
|
||||
<#if label?? && ( label?index_of("@") > -1 ) >
|
||||
<#assign labelStr = label?substring(0, label?index_of("@")) >
|
||||
<#assign tagOrTypeStr = label?substring(label?index_of("@")) >
|
||||
<#elseif label?? && ( label?index_of("^^") > -1 ) >
|
||||
<#assign labelStr = label?substring(0, label?index_of("^^")) >
|
||||
<#assign tagOrTypeStr = label?substring(label?index_of("^^")) >
|
||||
<#assign tagOrTypeStr = tagOrTypeStr?replace("^^http","^^<http") >
|
||||
<#assign tagOrTypeStr = tagOrTypeStr?replace("#string","#string>") >
|
||||
<#else>
|
||||
<#assign labelStr = label >
|
||||
<#assign tagOrTypeStr = "" >
|
||||
</#if>
|
||||
<li>${labelStr} <#if labelSeq?seq_contains(labelStr)> (duplicate value) </#if>
|
||||
<#if editable && labelEditLink?has_content> <a href="${labelEditLink}&${editGenerator}">Edit</a>
|
||||
<a href="${urls.base}/edit/primitiveRdfEdit" languageName="${labelLang}" languageCode="${languageCode}"
|
||||
labelValue="${labelStr}" tagOrType="${tagOrTypeStr!}" class="remove" title="${i18n().remove_capitalized}">${i18n().remove_capitalized}</a>
|
||||
</#if>
|
||||
|
||||
</li>
|
||||
<#assign labelSeq = labelSeq + [labelStr]>
|
||||
</#list>
|
||||
</#macro>
|
||||
|
||||
<#--ignore 'untyped' and display everything-->
|
||||
<#macro displayExistingTypedLabels langList labelsSorted editable editGenerator>
|
||||
<#list langList as lang>
|
||||
<#if lang != "untyped">
|
||||
<h3 languageName="${lang}">${lang}</h3>
|
||||
<#--get label information for this language-->
|
||||
<#assign labelList = labelsSorted[lang] />
|
||||
<#--Reset for every language-->
|
||||
<#assign labelSeq = []/>
|
||||
<#list labelList as labelObject>
|
||||
<#assign labelLiteral = labelObject.labelLiteral />
|
||||
<#assign labelStringValue = labelObject.labelStringValue />
|
||||
<#--Try label as label literal-->
|
||||
<#assign label = labelLiteral />
|
||||
<#assign labelLang = labelObject.languageName />
|
||||
<#assign languageCode = labelObject.languageCode />
|
||||
<#assign labelEditLink = labelObject.editLinkURL />
|
||||
<#if label?? && ( label?index_of("@") > -1 ) >
|
||||
<#assign labelStr = label?substring(0, label?index_of("@")) >
|
||||
<#assign tagOrTypeStr = label?substring(label?index_of("@")) >
|
||||
<#elseif label?? && ( label?index_of("^^") > -1 ) >
|
||||
<#assign labelStr = label?substring(0, label?index_of("^^")) >
|
||||
<#assign tagOrTypeStr = label?substring(label?index_of("^^")) >
|
||||
<#assign tagOrTypeStr = tagOrTypeStr?replace("^^http","^^<http") >
|
||||
<#assign tagOrTypeStr = tagOrTypeStr?replace("#string","#string>") >
|
||||
<#else>
|
||||
<#assign labelStr = label >
|
||||
<#assign tagOrTypeStr = "" >
|
||||
</#if>
|
||||
<li>${labelStr} <#if labelSeq?seq_contains(labelStr)> (duplicate value) </#if>
|
||||
<#if editable && labelEditLink?has_content> <a href="${labelEditLink}&${editGenerator}">Edit</a>
|
||||
<a href="${urls.base}/edit/primitiveRdfEdit" languageName="${labelLang}" languageCode="${languageCode}"
|
||||
labelValue="${labelStr}" tagOrType="${tagOrTypeStr!}" class="remove" title="${i18n().remove_capitalized}">${i18n().remove_capitalized}</a>
|
||||
</#if>
|
||||
|
||||
</li>
|
||||
<#assign labelSeq = labelSeq + [labelStr]>
|
||||
</#list>
|
||||
</#if>
|
||||
</#list>
|
||||
</#macro>
|
|
@ -0,0 +1,14 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
<#if submissionErrors?has_content >
|
||||
<section id="error-alert" role="alert">
|
||||
<img src="${urls.images}/iconAlert.png" width="24" height="24" alt="${i18n().error_alert_icon}" />
|
||||
<p>
|
||||
<#list submissionErrors?keys as errorFieldName>
|
||||
<#if errorFieldName == "label">
|
||||
${i18n().enter_value_name_field}
|
||||
</#if>
|
||||
<br />
|
||||
</#list>
|
||||
</p>
|
||||
</section>
|
||||
</#if>
|
|
@ -209,13 +209,18 @@ name will be used as the label. -->
|
|||
|
||||
<#-- Label -->
|
||||
<#macro label individual editable labelCount>
|
||||
<#assign labelPropertyUri = ("http://www.w3.org/2000/01/rdf-schema#label"?url) />
|
||||
<#-- Will need to deal with multiple languages as well-->
|
||||
<#local label = individual.nameStatement>
|
||||
${label.value}
|
||||
<#if (labelCount > 1) && editable >
|
||||
<#-- Changing this so that manage labels now goes to generator -->
|
||||
<span class="inline">
|
||||
<a id="manageLabels" href="${urls.base}/manageLabels?subjectUri=${individual.uri!}">
|
||||
${i18n().manage_labels}
|
||||
</a>
|
||||
<#--Previous link which went to manage labels controller-->
|
||||
<#--a id="manageLabels" href="${urls.base}/manageLabels?subjectUri=${individual.uri!}"-->
|
||||
<a class="add-label" href="${urls.base}/editRequestDispatch?subjectUri=${individual.uri!}&editForm=edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.ManageLabelsForIndividualGenerator&predicateUri=${labelPropertyUri}"
|
||||
title="${i18n().manage_list_of} labels">
|
||||
<img class="add-individual" src="${urls.images}/individual/manage-icon.png" alt="${i18n().manage}" /></a>
|
||||
</span>
|
||||
<#else>
|
||||
<@editingLinks "label" label editable />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue