Ignore:
Timestamp:
Jun 11, 2010, 4:00:10 PM (9 years ago)
Author:
roberth
Message:

Improved template editor , stringlists and ontologyfields can be edited and extra checks are built in.

Location:
trunk/grails-app/views/templateEditor
Files:
4 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/views/templateEditor/elements/_available.gsp

    r556 r558  
    1 <li class="ui-state-default" id="templateField_${it.id}">
    2     <g:render template="elements/liField" model="['templateField': it, 'fieldTypes': fieldTypes]"/>
     1<li class="ui-state-default <g:if test="${templateField.required}">required</g:if>" id="templateField_${templateField.id}">
     2    <g:render template="elements/liField" model="['templateField': templateField, 'ontologies': ontologies, 'fieldTypes': fieldTypes]"/>
    33</li>
  • trunk/grails-app/views/templateEditor/elements/_disabledFieldForm.gsp

    r555 r558  
    1         <label for="name">Name:</label> <g:textField name="name" value="${templateField?.name}" /><br />
    2         <label for="type">Type:</label> <g:select from="${fieldTypes}" name="type" value="${templateField?.type}" /><br />
    3         <label for="unit">Unit:</label> <g:textField name="unit" value="${templateField?.unit}" /><br />
    4         <label for="comment">Comment:</label> <g:textArea name="comment" value="${templateField?.comment}" /><br />
    5         <label for="required">Required:</label> <g:checkBox name="required" value="${templateField?.required}" /><br />
     1        <label for="name">Name:</label> <g:textField disabled="disabled" name="name" value="${templateField?.name}" /><br />
     2        <label for="type">Type:</label> <g:textField disabled="disabled" name="type" value="${templateField?.type}" /><br />
     3
     4        <div class="extra stringlist_options" <g:if test="${templateField?.type.toString() == 'STRINGLIST'}">style='display: block;'</g:if>>
     5          <label for="type">Items:</label>
     6                <g:textArea name="listEntries" disabled="disabled" value="${templateField?.listEntries?.name?.join( '\n' )}" />
     7        </div>
     8        <div class="extra ontologyterm_options" <g:if test="${templateField?.type.toString() == 'ONTOLOGYTERM'}">style='display: block;'</g:if>>
     9          <label for="type">Ontology:</label> <g:textArea name="ontology" disabled="disabled" value="${templateField?.ontologies?.name?.join( '\n' )}" /><br />
     10        </div>
     11       
     12        <label for="unit">Unit:</label> <g:textField disabled="disabled" name="unit" value="${templateField?.unit}" /><br />
     13        <label for="comment">Comment:</label> <g:textArea disabled="disabled" name="comment" value="${templateField?.comment}" /><br />
     14        <label for="required">Required:</label> <input type="checkbox" disabled <g:if test="${templateField?.required}">checked</g:if><br />
  • trunk/grails-app/views/templateEditor/elements/_fieldForm.gsp

    r544 r558  
    11        <label for="name">Name:</label> <g:textField name="name" value="${templateField?.name}" /><br />
    2         <label for="type">Type:</label> <g:select from="${fieldTypes}" name="type" value="${templateField?.type}" /><br />
     2        <label for="type">Type:</label> <g:select from="${fieldTypes}" name="type" value="${templateField?.type}" onChange="showExtraFields( ${templateField ? templateField.id : '\'new\''} );" /><br />
     3
     4        <div class="extra stringlist_options" <g:if test="${templateField?.type.toString() == 'STRINGLIST'}">style='display: block;'</g:if>>
     5          <label for="type">Items (every item on a new line):</label>
     6                <g:textArea name="listEntries" value="${templateField?.listEntries?.name?.join( '\n' )}" />
     7        </div>
     8        <div class="extra ontologyterm_options" <g:if test="${templateField?.type.toString() == 'ONTOLOGYTERM'}">style='display: block;'</g:if>>
     9          <label for="type">Ontology:<br /><br /><a href="#" style="text-decoration: underline;" onClick="openOntologyDialog();">Add new</a></label>
     10                <g:select multiple="yes" size="5" from="${ontologies}" class="ontologySelect" optionValue="name" optionKey="id" name="ontologies" id="ontologies_${templateField?.id}" value="${templateField?.ontologies}" /><br />
     11        </div>
     12
    313        <label for="unit">Unit:</label> <g:textField name="unit" value="${templateField?.unit}" /><br />
    414        <label for="comment">Comment:</label> <g:textArea name="comment" value="${templateField?.comment}" /><br />
  • trunk/grails-app/views/templateEditor/elements/_liField.gsp

    r556 r558  
    11<g:if test="${templateField.inUse()}">
    2         <g:render template="elements/liFieldInUse" model="['templateField': templateField, 'fieldTypes': fieldTypes]"/>
     2        <g:render template="elements/liFieldInUse" model="['templateField': templateField, 'ontologies': ontologies, 'fieldTypes': fieldTypes]"/>
    33</g:if>
    44<g:else>
    5         <g:render template="elements/liFieldNotInUse" model="['templateField': templateField, 'fieldTypes': fieldTypes]"/>
     5        <g:render template="elements/liFieldNotInUse" model="['templateField': templateField, 'ontologies': ontologies, 'fieldTypes': fieldTypes]"/>
    66</g:else>
  • trunk/grails-app/views/templateEditor/elements/_liFieldInUse.gsp

    r556 r558  
    11<g:set var="numUses" value="${templateField.numUses()}" />
    22<span class="listButtons">
    3   <img class="disabled" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/application_edit.png')}" alt="Editing not possible. Field is used in ${numUses} templates." title="Editing not possible. Field is used in ${numUses} templates.">
     3  <img onClick="showTemplateFieldForm( 'templateField_' + ${templateField.id}); this.blur(); return false;" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/application_edit.png')}" alt="Edit template field properties" title="Edit template field properties">
    44  <img class="disabled" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/delete.png')}" alt="Deleting this field is not possible. Field is used in ${numUses} templates." title="Deleting this field is not possible. Field is used in ${numUses} templates.">
    5   <img onClick="addTemplateField( ${templateField.id} ); moveFieldListItem( ${templateField.id}, '#selectedTemplateFields' );" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/add.png')}" alt="Add field to template" title="Add field to template">
     5  <img onClick="addTemplateField( ${templateField.id}, null, true );" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/add.png')}" alt="Add field to template" title="Add field to template">
    66</span>
    77
     
    99    (<g:if test="${templateField.unit}">${templateField.unit}, </g:if><g:render template="elements/${templateField.type.toString().toLowerCase().replaceAll(/ /,'_')}" model="[templateField: templateField]"/>)
    1010   
     11<form class="templateField_form" id="templateField_${templateField.id}_form" action="updateField">
     12        <g:hiddenField name="id" value="${templateField.id}" />
     13        <g:hiddenField name="version" value="${templateField.version}" />
     14        <p class="noEditsPossible">Editing not possible. Field is used in ${numUses} template(s).</p>
     15        <g:render template="elements/disabledFieldForm" model="['templateField': templateField, 'ontologies': ontologies, 'fieldTypes': fieldTypes]"/>
     16        <div class="templateFieldButtons">
     17                <input type="button" value="Close" onClick="hideTemplateFieldForm( ${templateField.id} );">
     18        </div>
     19</form>
    1120
  • trunk/grails-app/views/templateEditor/elements/_liFieldNotInUse.gsp

    r556 r558  
    22  <img onClick="showTemplateFieldForm( 'templateField_' + ${templateField.id}); this.blur(); return false;" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/application_edit.png')}" alt="Edit template field properties" title="Edit template field properties">
    33  <img onClick="if( confirm( 'Are you sure?' ) ) { deleteTemplateField( ${templateField.id} ); }" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/delete.png')}" alt="Delete this template field" title="Delete this template field">
    4   <img onClick="addTemplateField( ${templateField.id} ); moveFieldListItem( ${templateField.id}, '#selectedTemplateFields' );" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/add.png')}" alt="Add field to template" title="Add field to template">
     4  <img onClick="addTemplateField( ${templateField.id}, null, true );" src="${createLinkTo( dir: 'images', file: 'icons/famfamfam/add.png')}" alt="Add field to template" title="Add field to template">
    55</span>
    66
     
    1111        <g:hiddenField name="id" value="${templateField.id}" />
    1212        <g:hiddenField name="version" value="${templateField.version}" />
    13         <g:render template="elements/fieldForm" model="['templateField': templateField, 'fieldTypes': fieldTypes]"/>
     13        <g:render template="elements/fieldForm" model="['templateField': templateField, 'ontologies': ontologies, 'fieldTypes': fieldTypes]"/>
    1414        <div class="templateFieldButtons">
    1515                <input type="button" value="Save" onClick="updateTemplateField( ${templateField.id} );">
  • trunk/grails-app/views/templateEditor/elements/_selected.gsp

    r556 r558  
    1 <li class="ui-state-default <g:if test="${template.inUse()}">inUse</g:if>" id="templateField_${it.id}">
    2     <g:render template="elements/liFieldSelected" model="['templateField': it, 'template': template, 'fieldTypes': fieldTypes]"/>
     1<li class="ui-state-default  <g:if test="${templateField.required}">required</g:if>" id="templateField_${templateField.id}">
     2    <g:render template="elements/liFieldSelected" model="['templateField': templateField, 'template': template, 'fieldTypes': fieldTypes]"/>
    33</li>
  • trunk/grails-app/views/templateEditor/index.gsp

    r556 r558  
    3232                                <li class="empty ui-state-default" <g:if test="${templates.size() > 0 }">style='display: none;'</g:if>>There are no templates for ${humanReadableEntity}. Use the 'Add template' button to add fields.</li>
    3333                                <g:each in="${templates}" var="currentTemplate">
    34                                         <li id="template_${currentTemplate.id}"class="ui-state-default">
    35                                           <g:if test="${currentTemplate.inUse()}">
    36                                                 <g:render template="elements/liTemplateNonEditable" model="['template': currentTemplate]"/>
    37                                           </g:if>
    38                                           <g:else>
    39                                                 <g:render template="elements/liTemplateEditable" model="['template': currentTemplate]"/>
    40                                           </g:else>
    41                                         </li>
     34                                  <g:render template="elements/liTemplate" model="['template': currentTemplate]"/>
    4235                                </g:each>
    4336                        </ul>
  • trunk/grails-app/views/templateEditor/template.gsp

    r556 r558  
    2121                <script src="${createLinkTo(dir: 'js', file: 'templateEditor.js')}" type="text/javascript"></script>
    2222                <link rel="stylesheet" href="${createLinkTo(dir: 'css', file: 'templateEditor.css')}" />
     23                <g:if env="production">
     24                  <script type="text/javascript" src="${resource(dir: 'js', file: 'ontology-chooser.min.js')}"></script>
     25                </g:if><g:else>
     26                  <script type="text/javascript" src="${resource(dir: 'js', file: 'ontology-chooser.js')}"></script>
     27                </g:else>
    2328        </head>
    2429        <body>
     
    2934                                $("#selectedTemplateFields").sortable({
    3035                                        placeholder: 'ui-state-highlight',
     36                                        items: 'li:not(.domain)',
    3137                                        cancel: '.empty, input, select, button, textarea, form, label',
    3238                                        connectWith: '.templateFields',
    3339                                        update: updateTemplateFieldPosition,
     40                                        receive: addTemplateFieldEvent,
    3441                                        remove: removeTemplateFieldEvent,
    35                                         receive: addTemplateFieldEvent
     42                                        start: savePosition
    3643                                }).disableSelection();
    3744
     
    4047                                        placeholder: 'ui-state-highlight',
    4148                                        cancel: '.empty, input, select, button, textarea, form, label',
    42                                         connectWith: '.templateFields'
     49                                        connectWith: '.templateFields',
     50                                        start: savePosition
    4351                                }).disableSelection();
    44                                
     52
     53
     54                                $("#ontologyDialog").dialog({
     55                                  autoOpen: false,
     56                                  title: 'Search for ontology',
     57                                  height: 290,
     58                                  width: 350,
     59                                  modal: true,
     60                                  buttons: {
     61                                          'Add': addOntology,
     62                                          Cancel: function() {
     63                                                  $(this).dialog('close');
     64                                          }
     65                                  },
     66                                  close: function() {
     67                                  }
     68
     69                                });
     70
    4571                        });
    4672                </script>
     
    5682
    5783                                <p>Currently, this template contains the following fields. Drag fields to reorder. Drag fields to the list of available fields to remove the field from the template.</p>
    58                                 <ol id="selectedTemplateFields" class="templateFields">
     84                                <ol id="domainFields" class="templateFields <g:if test="${template.inUse()}">inUse</g:if>">
     85                                        <g:render template="elements/domainField" var="domainField" collection="${domainFields}" model="['template':template]"/>
     86                                </ol>
     87                                <ol id="selectedTemplateFields" class="templateFields <g:if test="${template.inUse()}">inUse</g:if>">
     88                                        <g:render template="elements/selected" var="templateField" collection="${template.fields}" model="['template':template]"/>
    5989                                        <li class="empty ui-state-default" <g:if test="${template.fields?.size() > 0 }">style='display: none;'</g:if>>This template does not yet contain any fields. Drag a field to this list or use the 'Add field button'.</li>
    60                                         <g:render template="elements/selected" collection="${template.fields}" model="['template':template]"/>
    6190                                </ol>
    6291                        </div>
     
    6796                                <ol id="availableTemplateFields" class="templateFields">
    6897                                        <li class="empty ui-state-default" <g:if test="${allFields.size() > template.fields.size()}">style='display: none;'</g:if>>There are no additional fields that can be added. Use the 'Create new field' button to create new fields.</li>
    69                                         <g:render template="elements/available" collection="${allFields - template.fields}" />
     98                                        <g:render template="elements/available" var="templateField" collection="${allFields - template.fields}" />
    7099                                </ol>
    71100
     
    87116                </g:if>
    88117
     118                <div id="ontologyDialog">
     119                  <g:render template="ontologyDialog" />
     120                </div>
    89121
    90122        </body>
Note: See TracChangeset for help on using the changeset viewer.