- Timestamp:
- Jun 3, 2010, 12:27:08 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy
r507 r518 983 983 } 984 984 } 985 986 def PublicationSelectElement = { attrs, body -> 987 988 attrs.description = 'Publications'; 989 // render list with publications currently available 990 baseElement.call( 991 '_publicationList', 992 attrs, 993 body 994 ) 995 996 attrs.description = ''; 997 998 // render 'Add publication button' 999 baseElement.call( 1000 '_publicationAddButton', 1001 attrs, 1002 body 1003 ) 1004 } 1005 1006 /** 1007 * Renders a input box for publications 1008 */ 1009 def publicationSelect = { attrs, body -> 1010 if( attrs.get( 'value' ) == null ) { 1011 attrs.value = []; 1012 } 1013 if( attrs.get( 'description' ) == null ) { 1014 attrs.description = ''; 1015 } 1016 out << '<form id="' + attrs.name + '_form">'; 1017 out << textField( 1018 name: attrs.get( "name" ), 1019 value: '', 1020 rel: 'publication-pubmed', 1021 style: 'width: 400px;' 1022 ); 1023 out << '</form>'; 1024 out << '<script type="text/javascript">'; 1025 out << ' iField = $( "#' + attrs.get( 'name' ) + '" );'; 1026 out << ' new PublicationChooser().initAutocomplete( iField );'; 1027 out << '</script>'; 1028 } 1029 1030 def _publicationList = { attrs, body -> 1031 def display_none = 'none'; 1032 if( !attrs.get( 'value' ) || attrs.get( 'value' ).size() == 0 ) { 1033 display_none = 'inline'; 1034 } 1035 1036 // Add a unordered list 1037 out << '<ul class="publication_list" id="' + attrs.name + '_list">'; 1038 1039 out << '<li>'; 1040 out << '<span class="publication_none" id="' + attrs.name + '_none" style="display: ' + display_none + ';">'; 1041 out << 'No publications selected'; 1042 out << '</span>'; 1043 out << '</li>'; 1044 1045 out << '</ul>'; 1046 1047 // Add the publications using javascript 1048 out << '<script type="text/javascript">' 1049 if( attrs.get( 'value' ) && attrs.get( 'value' ).size() > 0 ) { 1050 def i = 0; 1051 attrs.get( 'value' ).each { 1052 out << 'showPublication( '; 1053 out << ' "' + attrs.name + '",'; 1054 out << ' ' + it.id + ','; 1055 out << ' "' + it.title + '",'; 1056 out << ' "' + it.authorsList + '",'; 1057 out << ' ' + i++; 1058 out << ');'; 1059 } 1060 } 1061 out << '</script>'; 1062 1063 def ids; 1064 if( attrs.get( 'value' ) && attrs.get( 'value' ).size() > 0 ) { 1065 ids = attrs.get( 'value' ).id.join( ',' ) 1066 } else { 1067 ids = ''; 1068 } 1069 out << '<input type="hidden" name="' + attrs.name + '_ids" value="' + ids + '" id="' + attrs.name + '_ids" value="' + ids + '">'; 1070 } 1071 1072 def _publicationAddButton = { attrs, body -> 1073 1074 // Output the dialog for the publications 1075 out << '<div id="' + attrs.name + '_dialog">'; 1076 out << publicationSelect( attrs, body ); 1077 out << '</div>'; 1078 out << '<script type="text/javascript">'; 1079 out << ' $("#' + attrs.name + '_dialog").dialog({'; 1080 out << ' title : "Add publication",'; 1081 out << ' autoOpen: false,'; 1082 out << ' width : 800,'; 1083 out << ' height : 400,'; 1084 out << ' modal : true,'; 1085 out << ' position: "center",'; 1086 out << ' buttons : {'; 1087 out << ' Add : function() { addPublication( "' + attrs.name + '" ); $(this).dialog("close"); },'; 1088 out << ' Close : function() { $(this).dialog("close"); }'; 1089 out << ' },'; 1090 out << ' close : function() {'; 1091 out << ' /* closeFunc(this); */'; 1092 out << ' }'; 1093 out << ' }).width(790).height(400);'; 1094 out << '</script>'; 1095 1096 out << '<input type="button" onClick="var field = $( \'#' + attrs.name + '\' ); field.autocomplete( \'close\' ); field.val( \'\' );$( \'#' + attrs.name + '_dialog\' ).dialog( \'open\' ); field.focus();" value="Add Publication">'; 1097 } 1098 985 1099 }
Note: See TracChangeset
for help on using the changeset viewer.