Changeset 2594


Ignore:
Timestamp:
01/27/10 01:54:14 (2 years ago)
Author:
mswertz
Message:

enhancement: in the ui model one can now say <form compact_view="field1,field2" to initially only show these fields when the form is in edit view. A button is provided to 'show additional fields'. When pushed all the other (hidden=false) fields are shown.

Location:
molgenis/3.3/src/org/molgenis
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • molgenis/3.3/src/org/molgenis/framework/ui/FormModel.java

    r2442 r2594  
    141141         */ 
    142142        public abstract void resetSystemHiddenColumns(); 
     143         
     144        /** 
     145         * Default settings for compact columns 
     146         */ 
     147        public abstract void resetCompactView(); 
    143148 
    144149        /** 
     
    233238        // TODO make this infer automatically 
    234239        private List<ParentFilter> parentFilters = new ArrayList<ParentFilter>(); 
     240         
     241        /* which fields are shown in compact view */ 
     242        protected List<String> compactView = new ArrayList<String>(); 
    235243 
    236244        /** */ 
  • molgenis/3.3/src/org/molgenis/framework/ui/FormView.ftl

    r2442 r2594  
    233233                        <input type="hidden" name="massUpdate" value="${id}"> 
    234234        </#list> 
    235         <#list screen.getNewRecordForm() as input> 
     235        <#list screen.getRecordForm() as input> 
    236236                <#if !input.isHidden()> 
    237237                        <tr> 
     
    270270                                <#assign readonly = "false" /> 
    271271                        </#if> 
     272                         
    272273                        <#if !input.isHidden()> 
    273         <tr title="${input.getDescription()}"> 
     274        <tr title="${input.getDescription()}" <#if input.collapse>class="${screen.name}_collapse" </#if>> 
    274275                <td><label>${input.label}</label></td> 
    275276                                <#if screen.readonly > 
     
    286287                        ${input.toHtml()} 
    287288                        </#if> 
     289                         
    288290                        <#if !input.isNillable() && !input.isHidden() && !input.isReadonly()> 
    289291                                <#if requiredcount &gt; 0><#assign required = required + "," /></#if> 
     
    292294                        </#if> 
    293295                </#list> 
     296<#--show collapse button if collapsed items--> 
     297<#list record.inputs as input> 
     298        <#if input.collapse><tr><td colspan="2"><script>toggleCssClass("${screen.name}_collapse");</script> 
     299        <input type="button" onClick="toggleCssClass('${screen.name}_collapse'); if(this.value == 'Hide additional fields') this.value='Show additional fields'; else this.value='Hide additional fields'" value="Show additional fields"/></td></tr><#break/></#if> 
     300</#list>                 
    294301</table></td><td  class="edit_button_area"> 
    295302<#if readonly != "true"> 
  • molgenis/3.3/src/org/molgenis/framework/ui/html/HtmlInput.java

    r2308 r2594  
    4040        /** required form field */ 
    4141        private boolean nillable = true; 
     42         
     43        /** indicate if this input should be hidden in 'compact' view */ 
     44        private boolean collapse = false; 
    4245 
    4346        /** 
     
    202205        } 
    203206         
     207        public boolean isCollapse() 
     208        { 
     209                return collapse; 
     210        } 
     211 
     212        public void setCollapse(boolean collapse) 
     213        { 
     214                this.collapse = collapse; 
     215        } 
     216 
    204217        public String toString() 
    205218        { 
  • molgenis/3.3/src/org/molgenis/generators/ui/FormScreenGen.java.ftl

    r2592 r2594  
    163163                        input.setHidden(<#if (field.auto && field.readOnly) || (field.defaultValue?exists)>true<#else>!isNewRecord()</#if>); 
    164164                        </#if>                   
     165                        <#if form.getCompactView()?size &gt; 0 && !form.getCompactView()?seq_contains(field.name)> 
     166                        input.setCollapse(true); 
     167                        </#if> 
    165168                        inputs.add(input); 
    166169                } 
     
    189192                return fieldName; 
    190193        }        
     194         
     195        @Override 
     196        public void resetCompactView() 
     197        { 
     198                this.compactView = new ArrayList<String>(); 
     199<#list form.getCompactView() as field_name> 
     200                this.compactView.add("${field_name}"); 
     201</#list>         
     202        } 
    191203} 
    192204 
  • molgenis/3.3/src/org/molgenis/model/MolgenisModelParser.java

    r2562 r2594  
    8686 
    8787                // construct 
    88                 Entity entity = new Entity(element.getAttribute("name").trim(), element.getAttribute("label"), model.getDatabase()); 
     88                Entity entity = new Entity(element.getAttribute("name").trim(), element.getAttribute("label"), model 
     89                                .getDatabase()); 
    8990                entity.setNamespace(model.getName()); 
    9091 
     
    752753                // check for illegal words 
    753754                String[] keywords = new String[] 
    754                 { "name", "label"}; 
     755                { "name", "label" }; 
    755756                List<String> key_words = new ArrayList<String>(Arrays.asList(keywords)); 
    756757                for (int i = 0; i < element.getAttributes().getLength(); i++) 
     
    773774 
    774775                // construct 
    775                 Module module = new Module(model.getName()+"."+element.getAttribute("name").trim(), model); 
    776                  
    777                 if(element.getAttribute("label") != "") module.setLabel(element.getAttribute("label")); 
     776                Module module = new Module(model.getName() + "." + element.getAttribute("name").trim(), model); 
     777 
     778                if (element.getAttribute("label") != "") module.setLabel(element.getAttribute("label")); 
    778779 
    779780                // DESCRIPTION 
     
    904905                        // ENTITY 
    905906                        // TODO: whould have expected this in the constructor! 
    906                         DBSchema entity = model.getDatabase().getChild(element.getAttribute("entity")); 
     907                        Entity entity = (Entity) model.getDatabase().getChild(element.getAttribute("entity")); 
    907908                        if (entity == null) 
    908909                        { 
     
    911912                        } 
    912913                        form.setRecord((Record) entity);// form.setEntity(entity); 
     914 
     915                        // COMPACT_FIELDS 
     916                        if (element.getAttribute("compact_view") != "") 
     917                        { 
     918                                String[] fields = element.getAttribute("compact_view").split(","); 
     919                                // check if the fields are there 
     920                                List<String> compact_fields = new ArrayList<String>(); 
     921                                for (String field : fields) 
     922                                { 
     923                                        Field f = entity.getField(field); 
     924                                        if (f == null) 
     925                                        { 
     926                                                throw new MolgenisModelException("Could not find field '" 
     927                                                                + field + "' defined in compact_view='"+element.getAttribute("compact_view")+"' in form '" + form.getName() + "'"); 
     928                                        } 
     929                                        compact_fields.add(field); 
     930                                } 
     931                                form.setCompactView(compact_fields); 
     932                        } 
    913933                } 
    914934                else if (element.getTagName().equals("tree")) 
     
    9951015                        // retrieve the document-root 
    9961016                        Element document_root = document.getDocumentElement(); 
    997 //                      if (document_root.getAttribute("name") == "" && model.getName().equals("")) 
    998 //                      { 
    999 //                              document_root.setAttribute("name", "molgenis"); 
    1000 //                      } 
    1001 //                      String modelName = document_root.getAttribute("name"); 
     1017                        // if (document_root.getAttribute("name") == "" && 
     1018                        // model.getName().equals("")) 
     1019                        // { 
     1020                        // document_root.setAttribute("name", "molgenis"); 
     1021                        // } 
     1022                        // String modelName = document_root.getAttribute("name"); 
    10021023                        // FIXME should be solved by using modules 
    10031024                        // alternatively ui should be in predefined dir anyway... 
    10041025 
    10051026                        // set the package name for the UI 
    1006                         //model.setName("ui"); 
     1027                        // model.setName("ui"); 
    10071028 
    10081029                        // retrieve the children 
  • molgenis/3.3/src/org/molgenis/model/elements/Form.java

    r2592 r2594  
    195195         * The other fields will be 'collapsed' with a '+' to uncollapse them. 
    196196         */ 
    197         private List<String> compact_fields = new ArrayList<String>(); 
     197        private List<String> compactView = new ArrayList<String>(); 
    198198         
    199199        /** */ 
     
    329329                this.actionPlugins = actionPlugins; 
    330330        } 
     331 
     332        public List<String> getCompactView() 
     333        { 
     334                return compactView; 
     335        } 
     336 
     337        public void setCompactView(List<String> compactFields) 
     338        { 
     339                this.compactView = compactFields; 
     340        } 
     341         
    331342} 
Note: See TracChangeset for help on using the changeset viewer.