From 2fb20f1efedd495a4ca9e81d755810f35c3c5926 Mon Sep 17 00:00:00 2001
From: tworrall
Date: Fri, 2 Dec 2011 20:52:06 +0000
Subject: [PATCH] display a create own option before a search is performed
---
productMods/edit/forms/css/addConcept.css | 5 +++
productMods/edit/forms/js/addConcept.js | 31 +++++++++++--------
.../edit/forms/addAssociatedConcept.ftl | 6 ++--
3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/productMods/edit/forms/css/addConcept.css b/productMods/edit/forms/css/addConcept.css
index 303bb47d..9dce6df8 100644
--- a/productMods/edit/forms/css/addConcept.css
+++ b/productMods/edit/forms/css/addConcept.css
@@ -25,4 +25,9 @@
form#addConceptForm {
display:none;
+}
+
+form#addConceptForm span#createOwnOne{
+ float:left;
+ margin-top:24px
}
\ No newline at end of file
diff --git a/productMods/edit/forms/js/addConcept.js b/productMods/edit/forms/js/addConcept.js
index ce49fe8a..2d0931d9 100644
--- a/productMods/edit/forms/js/addConcept.js
+++ b/productMods/edit/forms/js/addConcept.js
@@ -55,7 +55,8 @@ var addConceptForm = {
//remove links
this.removeConceptLinks = $('a.remove');
this.errors = $('#errors');
- this.createOwn = $('#createOwn');
+ this.createOwn1 = $('#createOwnOne');
+ this.createOwn2 = $('#createOwnTwo');
this.orSpan = $('span.or')
},
@@ -90,7 +91,7 @@ var addConceptForm = {
this.clearSearchResults();
// Hide the create own link, add selected button and "or"" span
this.orSpan.hide();
- this.createOwn.hide();
+ this.createOwn2.hide();
this.submit.hide();
//Also clear the search input
this.searchTerm.val("");
@@ -114,14 +115,17 @@ var addConceptForm = {
clearErrors:function() {
addConceptForm.errors.empty();
},
- showHiddenElements:function() {
- this.orSpan.show();
- this.createOwn.show();
- this.submit.show();
- },
- showSpanAndCreateOption:function() {
- this.orSpan.show();
- this.createOwn.show();
+ showHiddenElements:function(results) {
+ this.createOwn1.hide();
+ if ( results ) {
+ this.orSpan.show();
+ this.createOwn2.show();
+ this.submit.show();
+ }
+ else {
+ this.orSpan.show();
+ this.createOwn2.show();
+ }
},
showConceptListOnlyView: function() {
this.hideForm();
@@ -131,7 +135,7 @@ var addConceptForm = {
//Get value of search term
var searchValue = this.searchTerm.val();
var checkedVocabSource = $('input:radio[name="source"]:checked');
- var createLink = this.createOwn;
+ var hasResults = false;
if(!checkedVocabSource.length) {
addConceptForm.showUncheckedSourceError();
return;
@@ -173,10 +177,11 @@ var addConceptForm = {
if(htmlAdd.length) {
$('#selectedConcept').html(htmlAdd);
if (htmlAdd.indexOf("No search results") >= 0) {
- addConceptForm.showSpanAndCreateOption();
+ addConceptForm.showHiddenElements(hasResults);
}
else {
- addConceptForm.showHiddenElements();
+ hasResults = true;
+ addConceptForm.showHiddenElements(hasResults);
}
}
});
diff --git a/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl b/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl
index 847f021f..24b9e765 100644
--- a/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl
+++ b/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl
@@ -90,8 +90,8 @@
#list>
-
-
+
+
or Create your own concept
@@ -107,7 +107,7 @@
-