From b97cbb60e3e3adb0544835060909472457261dfe Mon Sep 17 00:00:00 2001 From: cappadona Date: Tue, 26 Jul 2011 21:08:34 +0000 Subject: [PATCH] NIHVIVO-3062 Merged r8856 from maint-rel-vivo-1.3 branch. --- webapp/web/js/menupage/menumanagement_edit.js | 62 +++++++------------ .../freemarker/edit/forms/menuManagement.ftl | 31 +++++----- 2 files changed, 39 insertions(+), 54 deletions(-) diff --git a/webapp/web/js/menupage/menumanagement_edit.js b/webapp/web/js/menupage/menumanagement_edit.js index 29db9419b..fc7ca7d53 100644 --- a/webapp/web/js/menupage/menumanagement_edit.js +++ b/webapp/web/js/menupage/menumanagement_edit.js @@ -5,7 +5,6 @@ var menuManagementEdit = { this.initObjects(); this.bindEventListeners(); this.toggleClassSelection(); - //this.validateMenuItemForm(); }, initObjects: function() { this.defaultTemplateRadio = $('input.default-template'); @@ -17,7 +16,6 @@ var menuManagementEdit = { this.selectClassGroupDropdown = $('#selectClassGroup'); this.classesForClassGroup = $('#classesInSelectedGroup'); this.selectedGroupForPage = $('#selectedContentTypeValue'); - // this.selectClassesMessage = $('#selectClassesMessage'); this.allClassesSelectedCheckbox = $('#allSelected'); this.displayInternalMessage = $('#internal-class label em'); }, @@ -31,9 +29,6 @@ var menuManagementEdit = { this.selectClassGroupDropdown.change(function() { menuManagementEdit.chooseClassGroup(); }); - // this.allClassesSelectedCheckbox.change(function() { - // menuManagementEdit.toggleClassSelection(); - // }); // Listeners for template field this.defaultTemplateRadio.click(function(){ @@ -56,39 +51,29 @@ var menuManagementEdit = { }); }, updateInternalClassMessage:function(classGroupName) { //User has changed content type - //Set content type within internal class message - this.displayInternalMessage.filter(":first").html(classGroupName); + //Set content type within internal class message + this.displayInternalMessage.filter(":first").html(classGroupName); }, showClassGroups: function() { //User has clicked change content type - //Show the section with the class group dropdown - this.selectContentType.removeClass("hidden"); - //Hide the "change content type" section which shows the selected class group - this.existingContentType.addClass("hidden"); - //Hide the checkboxes for classes within the class group + //Show the section with the class group dropdown + this.selectContentType.removeClass("hidden"); + //Hide the "change content type" section which shows the selected class group + this.existingContentType.addClass("hidden"); + //Hide the checkboxes for classes within the class group this.classesForClassGroup.addClass("hidden"); }, hideClassGroups: function() { //User has selected class group/content type, page should show classes for class group and 'existing' type with change link - //Hide the class group dropdown - this.selectContentType.addClass("hidden"); - //Show the "change content type" section which shows the selected class group - this.existingContentType.removeClass("hidden"); - //Show the classes in the class group - this.classesForClassGroup.removeClass("hidden"); - + //Hide the class group dropdown + this.selectContentType.addClass("hidden"); + //Show the "change content type" section which shows the selected class group + this.existingContentType.removeClass("hidden"); + //Show the classes in the class group + this.classesForClassGroup.removeClass("hidden"); + }, toggleClassSelection: function() { - /*To do: please fix so selecting all selects all classes and deselecting - * any class will deselect all - */ - /* - if(this.allClassesSelectedCheckbox.is(':checked')) { - $('#classInClassGroup').attr('checked', 'checked'); - } else { - $('#classInClassGroup').removeAttr('checked'); - }*/ // Check/unckeck all classes for selection $('input:checkbox[name=allSelected]').click(function(){ - // alert($('input:checkbox[name=classInClassGroup]')); if ( this.checked ) { // if checked, select all the checkboxes $('input:checkbox[name=classInClassGroup]').attr('checked','checked'); @@ -116,21 +101,22 @@ var menuManagementEdit = { } if ($("input:radio[name=selectedTemplate]:checked").val() == "custom") { - if($("input[name=customTemplate]").val() == "") { - validationError += "You must supply a template
"; - } + if ($("input[name=customTemplate]").val() == "") { + validationError += "You must supply a template
"; + } } //if no class group selected, this is an error if ($("#selectClassGroup").val() =='-1'){ validationError += "You must supply a content type
"; } else { - //class group has been selected, make sure there is at least one class selected - var noClassesSelected = $("input[name='classInClassGroup']:checked").length; - if(noClassesSelected == 0) { - //at least one class should be selected - validationError += "You must supply some content to display
"; - } + //class group has been selected, make sure there is at least one class selected + var allSelected = $('input[name="allSelected"]:checked').length; + var noClassesSelected = $("input[name='classInClassGroup']:checked").length; + if (allSelected == 0 && noClassesSelected == 0) { + //at least one class should be selected + validationError += "You must select the type of content to display
"; + } } diff --git a/webapp/web/templates/freemarker/edit/forms/menuManagement.ftl b/webapp/web/templates/freemarker/edit/forms/menuManagement.ftl index 02ebaba8c..38ea38f69 100644 --- a/webapp/web/templates/freemarker/edit/forms/menuManagement.ftl +++ b/webapp/web/templates/freemarker/edit/forms/menuManagement.ftl @@ -5,7 +5,8 @@ <#-- some additional processing here which shows or hides the class group selection and classes based on initial action--> <#assign existingClassGroupStyle = " " /> <#assign selectClassGroupStyle = 'class="hidden"' /> -<#if menuAction = "Add"> +<#-- Reveal the class group and hide the class selects if adding a new menu item or editing an existing menu item with an empty class group (no classes)--> +<#if menuAction == "Add" || !classGroup?has_content> <#assign existingClassGroupStyle = 'class="hidden"' /> <#assign selectClassGroupStyle = " " /> @@ -28,7 +29,7 @@

(Format: / - e.g., /people)

- +

Template *

checked role="radio" /> @@ -38,17 +39,17 @@
class="hidden" role="region"> - * + * +
+ +
+

Selected content type for the associated page

+

+ ${associatedPage} + Change content type +

-
-

Selected content type for the associated page

-

- ${associatedPage} - Change content type -

-
- <#-- Select class group -->
@@ -59,19 +60,17 @@ -
- - +
<#-- Select classes in a class group -->

Select content to display *

- <#include "menuManagement--classIntersections.ftl"> + <#include "menuManagement--classIntersections.ftl">