Ignore:
Timestamp:
Jun 8, 2010, 11:18:27 AM (13 years ago)
Author:
duh
Message:
  • dev commit
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r527 r539  
    991991        }
    992992
    993         def PublicationSelectElement = { attrs, body ->
    994 
    995             attrs.description = 'Publications';
    996             // render list with publications currently available
    997             baseElement.call(
    998                     '_publicationList',
    999                     attrs,
    1000                     body
    1001             )
    1002 
    1003             attrs.description = '';
    1004 
    1005             // render 'Add publication button'
    1006             baseElement.call(
    1007                     '_publicationAddButton',
    1008                     attrs,
    1009                     body
    1010             )
    1011         }
    1012 
    1013         /**
    1014         * Renders a input box for publications
    1015         */
    1016         def publicationSelect = { attrs, body ->
    1017                 if( attrs.get( 'value' ) == null ) {
    1018                     attrs.value = [];
    1019                 }
    1020                 if( attrs.get( 'description' ) == null ) {
    1021                     attrs.description = '';
    1022                 }
    1023                 out << '<form id="' + attrs.name + '_form">';
    1024                 out << textField(
    1025                             name: attrs.get( "name" ),
    1026                             value: '',
    1027                             rel: 'publication-pubmed',
    1028                             style: 'width: 400px;'
     993        def PublicationSelectElement = { attrs, body ->
     994
     995                attrs.description = 'Publications';
     996                // render list with publications currently available
     997                baseElement.call(
     998                        '_publicationList',
     999                        attrs,
     1000                        body
     1001                )
     1002
     1003                attrs.description = '';
     1004
     1005                // render 'Add publication button'
     1006                baseElement.call(
     1007                        '_publicationAddButton',
     1008                        attrs,
     1009                        body
     1010                )
     1011        }
     1012
     1013        /**
     1014        * Renders a input box for publications
     1015        */
     1016        def publicationSelect = { attrs, body ->
     1017                if (attrs.get('value') == null) {
     1018                        attrs.value = [];
     1019                }
     1020                if (attrs.get('description') == null) {
     1021                        attrs.description = '';
     1022                }
     1023                out << '<form id="' + attrs.name + '_form">';
     1024                out << textField(
     1025                        name: attrs.get("name"),
     1026                        value: '',
     1027                        rel: 'publication-pubmed',
     1028                        style: 'width: 400px;'
    10291029                );
    1030                 out << '</form>';
    1031                 out << '<script type="text/javascript">';
    1032                 out << '  var onSelect = function( chooserObject, inputElement, event, ui ) { selectPubMedAdd( chooserObject, inputElement, event, ui ); enableButton( ".'+ attrs.name + '_publication_dialog", "Add", true ); };'
    1033                 out << '  iField = $( "#' + attrs.get( 'name' ) + '" );';
    1034                 out << '  new PublicationChooser().initAutocomplete( iField, { "select" : onSelect } );';
    1035                 out << '</script>';
    1036         }
    1037 
    1038         def _publicationList = { attrs, body ->
    1039            def display_none = 'none';
    1040            if( !attrs.get( 'value' ) || attrs.get( 'value' ).size() == 0 ) {
    1041                 display_none = 'inline';
    1042            }
    1043            
    1044             // Add a unordered list
    1045             out << '<ul class="publication_list" id="' + attrs.name + '_list">';
    1046 
    1047             out << '<li>';
    1048             out << '<span class="publication_none" id="' + attrs.name + '_none" style="display: ' + display_none + ';">';
    1049             out << 'No publications selected';
    1050             out << '</span>';
    1051             out << '</li>';
    1052 
    1053             out << '</ul>';
    1054 
    1055            // Add the publications using javascript
    1056            out << '<script type="text/javascript">'
    1057            if( attrs.get( 'value' ) && attrs.get( 'value' ).size() > 0 ) {
    1058                def i = 0;
    1059                attrs.get( 'value' ).each {
    1060                     out << 'showPublication( ';
    1061                     out << '  "' + attrs.name + '",';
    1062                     out << '  ' + it.id + ',';
    1063                     out << '  "' + it.title + '",';
    1064                     out << '  "' + it.authorsList + '",';
    1065                     out << '  ' + i++;
    1066                     out << ');';
    1067                 }
    1068             }
    1069             out << '</script>';
    1070 
    1071             def ids;
    1072             if( attrs.get( 'value' ) && attrs.get( 'value' ).size() > 0 ) {
    1073                 ids = attrs.get( 'value' ).id.join( ',' )
    1074             } else {
    1075                 ids = '';
    1076             }
    1077             out << '<input type="hidden" name="' + attrs.name + '_ids" value="' + ids + '" id="' + attrs.name + '_ids">';
    1078         }
    1079 
    1080         def _publicationAddButton = { attrs, body ->
    1081 
    1082             // Output the dialog for the publications
    1083             out << '<div id="' + attrs.name + '_dialog">';
    1084             out << '<p>Search for a publication on pubmed. You can search on a part of the title or authors. </p>';
    1085             out << publicationSelect( attrs, body );
    1086             out << '</div>';
    1087             out << '<script type="text/javascript">';
    1088             out << '  createPublicationDialog( "' + attrs.name + '" );'
    1089             out << '</script>';
    1090 
    1091             out << '<input type="button" onClick="openPublicationDialog(\'' + attrs.name + '\' );" value="Add Publication">';
    1092         }
    1093 
    1094         def ContactSelectElement = { attrs, body ->
    1095 
    1096             attrs.description = 'Contacts';
    1097             // render list with publications currently available
    1098             baseElement.call(
    1099                     '_contactList',
    1100                     attrs,
    1101                     body
    1102             )
    1103 
    1104             attrs.description = '';
    1105 
    1106             // render 'publications list'
    1107             out << '<div id="' + attrs.name + '_dialog" class="contacts_dialog" style="display: none;">'
    1108             baseElement.call(
    1109                     '_personSelect',
    1110                     attrs,
    1111                     body
    1112             )
    1113             baseElement.call(
    1114                     '_roleSelect',
    1115                     attrs,
    1116                     body
    1117             )
    1118             baseElement.call(
    1119                     '_contactAddButtonAddition',
    1120                     attrs,
    1121                     body
    1122             )
    1123             out << '</div>';
    1124 
    1125             // render 'Add contact button'
    1126             baseElement.call(
    1127                     '_contactAddDialogButton',
    1128                     attrs,
    1129                     body
    1130             )
    1131         }
    1132 
    1133         def _contactList = { attrs, body ->
    1134            def display_none = 'none';
    1135            if( !attrs.get( 'value' ) || attrs.get( 'value' ).size() == 0 ) {
    1136                 display_none = 'inline';
    1137            }
    1138 
    1139             // Add a unordered list
    1140             out << '<ul class="contact_list" id="' + attrs.name + '_list">';
    1141 
    1142             out << '<li>';
    1143             out << '<span class="contacts_none" id="' + attrs.name + '_none" style="display: ' + display_none + ';">';
    1144             out << 'No contacts selected';
    1145             out << '</span>';
    1146             out << '</li>';
    1147 
    1148             out << '</ul>';
    1149 
    1150            // Add the contacts using javascript
    1151            out << '<script type="text/javascript">'
    1152            if( attrs.get( 'value' ) && attrs.get( 'value' ).size() > 0 ) {
    1153                def i = 0;
    1154                attrs.get( 'value' ).each {
    1155                     out << 'showContact( ';
    1156                     out << '  "' + attrs.name + '",';
    1157                     out << '  "' + it.person.id + '-' + it.role.id + '",';
    1158                     out << '  "' + it.person.lastName + ', ' + it.person.firstName + ( it.person.prefix  ? ' ' + it.person.prefix : '' ) + '",';
    1159                     out << '  "' + it.role.name + '",';
    1160                     out << '  ' + i++;
    1161                     out << ');';
    1162                 }
    1163             }
    1164             out << '</script>';
    1165 
    1166             def ids = '';
    1167             if( attrs.get( 'value' ) && attrs.get( 'value' ).size() > 0 ) {
    1168                 ids = attrs.get( 'value' ).collect { it.person.id + '-' + it.role.id }
    1169                 ids = ids.join( ',' );
    1170             }
    1171             out << '<input type="hidden" name="' + attrs.name + '_ids" value="' + ids + '" id="' + attrs.name + '_ids">';
    1172         }
    1173 
    1174         def _contactAddSelect = { attrs, body ->
    1175             out << _personSelect( attrs ) + _roleSelect( attrs );
    1176         }
    1177 
    1178         def _contactAddButtonAddition = { attrs, body ->
    1179             out << '<input type="button" onClick="addContact ( \'' + attrs.name + '\' ); $(\'#' + attrs.name + '_dialog\').hide(); $( \'#' + attrs.name + '_dialogButton\' ).show();" value="Add">';
    1180             out << '<input type="button" onClick="$(\'#' + attrs.name + '_dialog\').hide(); $( \'#' + attrs.name + '_dialogButton\' ).show();" value="Close">';
    1181         }
    1182        
    1183         def _contactAddDialogButton = { attrs, body ->
    1184             out << '<input type="button" onClick="$( \'#' + attrs.name + '_dialog\' ).show(); $(this).hide();" id="' + attrs.name + '_dialogButton" value="Add Contact">';
    1185         }
     1030                out << '</form>';
     1031                out << '<script type="text/javascript">';
     1032                out << '  var onSelect = function( chooserObject, inputElement, event, ui ) { selectPubMedAdd( chooserObject, inputElement, event, ui ); enableButton( ".' + attrs.name + '_publication_dialog", "Add", true ); };'
     1033                out << '  iField = $( "#' + attrs.get('name') + '" );';
     1034                out << '  new PublicationChooser().initAutocomplete( iField, { "select" : onSelect } );';
     1035                out << '</script>';
     1036        }
     1037
     1038        def _publicationList = { attrs, body ->
     1039                def display_none = 'none';
     1040                if (!attrs.get('value') || attrs.get('value').size() == 0) {
     1041                        display_none = 'inline';
     1042                }
     1043
     1044                // Add a unordered list
     1045                out << '<ul class="publication_list" id="' + attrs.name + '_list">';
     1046
     1047                out << '<li>';
     1048                out << '<span class="publication_none" id="' + attrs.name + '_none" style="display: ' + display_none + ';">';
     1049                out << 'No publications selected';
     1050                out << '</span>';
     1051                out << '</li>';
     1052
     1053                out << '</ul>';
     1054
     1055                // Add the publications using javascript
     1056                out << '<script type="text/javascript">'
     1057                if (attrs.get('value') && attrs.get('value').size() > 0) {
     1058                        def i = 0;
     1059                        attrs.get('value').each {
     1060                                out << 'showPublication( ';
     1061                                out << '  "' + attrs.name + '",';
     1062                                out << '  ' + it.id + ',';
     1063                                out << '  "' + it.title + '",';
     1064                                out << '  "' + it.authorsList + '",';
     1065                                out << '  ' + i++;
     1066                                out << ');';
     1067                        }
     1068                }
     1069                out << '</script>';
     1070
     1071                def ids;
     1072                if (attrs.get('value') && attrs.get('value').size() > 0) {
     1073                        ids = attrs.get('value').id.join(',')
     1074                } else {
     1075                        ids = '';
     1076                }
     1077                out << '<input type="hidden" name="' + attrs.name + '_ids" value="' + ids + '" id="' + attrs.name + '_ids">';
     1078        }
     1079
     1080        def _publicationAddButton = { attrs, body ->
     1081
     1082                // Output the dialog for the publications
     1083                out << '<div id="' + attrs.name + '_dialog">';
     1084                out << '<p>Search for a publication on pubmed. You can search on a part of the title or authors. </p>';
     1085                out << publicationSelect(attrs, body);
     1086                out << '</div>';
     1087                out << '<script type="text/javascript">';
     1088                out << '  createPublicationDialog( "' + attrs.name + '" );'
     1089                out << '</script>';
     1090
     1091                out << '<input type="button" onClick="openPublicationDialog(\'' + attrs.name + '\' );" value="Add Publication">';
     1092        }
     1093
     1094        def ContactSelectElement = { attrs, body ->
     1095
     1096                attrs.description = 'Contacts';
     1097                // render list with publications currently available
     1098                baseElement.call(
     1099                        '_contactList',
     1100                        attrs,
     1101                        body
     1102                )
     1103
     1104                attrs.description = '';
     1105
     1106                // render 'publications list'
     1107                out << '<div id="' + attrs.name + '_dialog" class="contacts_dialog" style="display: none;">'
     1108                baseElement.call(
     1109                        '_personSelect',
     1110                        attrs,
     1111                        body
     1112                )
     1113                baseElement.call(
     1114                        '_roleSelect',
     1115                        attrs,
     1116                        body
     1117                )
     1118                baseElement.call(
     1119                        '_contactAddButtonAddition',
     1120                        attrs,
     1121                        body
     1122                )
     1123                out << '</div>';
     1124
     1125                // render 'Add contact button'
     1126                baseElement.call(
     1127                        '_contactAddDialogButton',
     1128                        attrs,
     1129                        body
     1130                )
     1131        }
     1132
     1133        def _contactList = { attrs, body ->
     1134                def display_none = 'none';
     1135                if (!attrs.get('value') || attrs.get('value').size() == 0) {
     1136                        display_none = 'inline';
     1137                }
     1138
     1139                // Add a unordered list
     1140                out << '<ul class="contact_list" id="' + attrs.name + '_list">';
     1141
     1142                out << '<li>';
     1143                out << '<span class="contacts_none" id="' + attrs.name + '_none" style="display: ' + display_none + ';">';
     1144                out << 'No contacts selected';
     1145                out << '</span>';
     1146                out << '</li>';
     1147
     1148                out << '</ul>';
     1149
     1150                // Add the contacts using javascript
     1151                out << '<script type="text/javascript">'
     1152                if (attrs.get('value') && attrs.get('value').size() > 0) {
     1153                        def i = 0;
     1154                        attrs.get('value').each {
     1155                                out << 'showContact( ';
     1156                                out << '  "' + attrs.name + '",';
     1157                                out << '  "' + it.person.id + '-' + it.role.id + '",';
     1158                                out << '  "' + it.person.lastName + ', ' + it.person.firstName + (it.person.prefix ? ' ' + it.person.prefix : '') + '",';
     1159                                out << '  "' + it.role.name + '",';
     1160                                out << '  ' + i++;
     1161                                out << ');';
     1162                        }
     1163                }
     1164                out << '</script>';
     1165
     1166                def ids = '';
     1167                if (attrs.get('value') && attrs.get('value').size() > 0) {
     1168                        ids = attrs.get('value').collect { it.person.id + '-' + it.role.id }
     1169                        ids = ids.join(',');
     1170                }
     1171                out << '<input type="hidden" name="' + attrs.name + '_ids" value="' + ids + '" id="' + attrs.name + '_ids">';
     1172        }
     1173
     1174        def _contactAddSelect = { attrs, body ->
     1175                out << _personSelect(attrs) + _roleSelect(attrs);
     1176        }
     1177
     1178        def _contactAddButtonAddition = { attrs, body ->
     1179                out << '<input type="button" onClick="addContact ( \'' + attrs.name + '\' ); $(\'#' + attrs.name + '_dialog\').hide(); $( \'#' + attrs.name + '_dialogButton\' ).show();" value="Add">';
     1180                out << '<input type="button" onClick="$(\'#' + attrs.name + '_dialog\').hide(); $( \'#' + attrs.name + '_dialogButton\' ).show();" value="Close">';
     1181        }
     1182
     1183        def _contactAddDialogButton = { attrs, body ->
     1184                out << '<input type="button" onClick="$( \'#' + attrs.name + '_dialog\' ).show(); $(this).hide();" id="' + attrs.name + '_dialogButton" value="Add Contact">';
     1185        }
    11861186        /**
    11871187         * Person select element
     
    11891189         */
    11901190        def _personSelect = { attrs ->
    1191             def selectAttrs = new LinkedHashMap();
    1192 
    1193             // define 'from'
    1194             def persons = Person.findAll().sort( { a, b -> a.lastName == b.lastName ? ( a.firstName <=> b.firstName ) : ( a.lastName <=> b.lastName ) } as Comparator );
    1195             selectAttrs.from = persons.collect { it.lastName + ', ' + it.firstName + ( it.prefix ? ' ' + it.prefix : '' ) }
    1196             selectAttrs.keys = persons.id;
    1197 
    1198             // add 'rel' attribute
    1199             selectAttrs.rel = 'person'
    1200             selectAttrs.name = attrs.name + '_person';
    1201 
    1202             out << "Person: " + select(selectAttrs)
    1203         }
     1191                def selectAttrs = new LinkedHashMap();
     1192
     1193                // define 'from'
     1194                def persons = Person.findAll().sort({ a, b -> a.lastName == b.lastName ? (a.firstName <=> b.firstName) : (a.lastName <=> b.lastName) } as Comparator);
     1195                selectAttrs.from = persons.collect { it.lastName + ', ' + it.firstName + (it.prefix ? ' ' + it.prefix : '') }
     1196                selectAttrs.keys = persons.id;
     1197
     1198                // add 'rel' attribute
     1199                selectAttrs.rel = 'person'
     1200                selectAttrs.name = attrs.name + '_person';
     1201
     1202                out << "Person: " + select(selectAttrs)
     1203        }
    12041204
    12051205        /**
     
    12081208         */
    12091209        def _roleSelect = { attrs ->
    1210             println( attrs );
    1211             def selectAttrs = new LinkedHashMap();
    1212 
    1213             // define 'from'
    1214             def roles = PersonRole.findAll();
    1215             selectAttrs.from = roles.collect { it.name };
    1216             selectAttrs.keys = roles.id;
    1217            
    1218             // add 'rel' attribute
    1219             selectAttrs.rel = 'role'
    1220             selectAttrs.name = attrs.name + '_role';
    1221 
    1222             out << "Role: " + select(selectAttrs)
    1223         }
     1210                println(attrs);
     1211                def selectAttrs = new LinkedHashMap();
     1212
     1213                // define 'from'
     1214                def roles = PersonRole.findAll();
     1215                selectAttrs.from = roles.collect { it.name };
     1216                selectAttrs.keys = roles.id;
     1217
     1218                // add 'rel' attribute
     1219                selectAttrs.rel = 'role'
     1220                selectAttrs.name = attrs.name + '_role';
     1221
     1222                out << "Role: " + select(selectAttrs)
     1223        }
    12241224}
Note: See TracChangeset for help on using the changeset viewer.