Ignore:
Timestamp:
Jun 13, 2013, 3:39:50 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

References #1729 and #1730. Fixed for the file types, extra value types and hardware edit dialogs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/admin/hardware/edit_hardware.jsp

    r6217 r6296  
    9797  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
    9898  subtypesQuery.include(Include.ALL);
    99  
    100  
    101  
     99   
    102100  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), hardware);
    103101  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
    104102  %>
    105   <base:page type="popup" title="<%=title%>">
    106   <base:head scripts="tabcontrol.js,subtypes.js" styles="tabcontrol.css">
     103  <base:page type="popup" title="<%=title%>" id="edit-page">
     104  <base:head scripts="tabcontrol-2.js,subtypes.js,~hardware.js" styles="tabcontrol.css">
    107105    <ext:scripts context="<%=jspContext%>" />
    108106    <ext:stylesheets context="<%=jspContext%>" />
    109     <script>
    110     // Validate the "Hardware" tab
    111     function validateHardware()
    112     {
    113       var frm = document.forms['hardware'];
    114       if (Main.trimString(frm.name.value) == '')
    115       {
    116         Forms.showNotification(frm.name, 'You must enter a name');
    117         return false;
    118       }
    119       return true;
    120     }
    121 
    122     // Submit the form
    123     function saveSettings()
    124     {
    125       var frm = document.forms['hardware'];
    126       if (TabControl.validateActiveTab('settings'))
    127       {
    128         frm.submit();
    129       }
    130     }
    131    
    132     function init()
    133     {
    134       <%
    135       if (hardware == null)
    136       {
    137         %>
    138         var frm = document.forms['hardware'];
    139         frm.name.focus();
    140         frm.name.select();
    141         subtypeOnChange();
    142         <%
    143       }
    144       %>
    145     }
    146     function subtypeOnChange()
    147     {
    148       var frm = document.forms['hardware'];
    149       if (frm.replaceExistingDefault)
    150       {
    151         var subtypeId = ItemSubtype.getSubtypeId('hardware');
    152         var defaultInfo = ItemSubtype.getRecentAndDefaultInfo(subtypeId, 'HARDWARE');
    153         var currentDefaultDiv = document.getElementById('currentDefault');
    154        
    155         var tooltip = '';
    156         var html = '';
    157         var checked = true;
    158         var disabled = false;
    159        
    160         var numDefaults = defaultInfo['default'] ? defaultInfo['default'].length : 0;
    161         if (numDefaults == 1)
    162         {
    163           html = '('+Main.encodeTags(Main.cutString(defaultInfo['default'][0].name, 40)) + ')';
    164         }
    165         else if (numDefaults == 0)
    166         {
    167           html = '(-none-)';
    168           checked = false;
    169           disabled = true;
    170         }
    171         else
    172         {
    173           html = '(' + numDefaults + ' different)';
    174           for (var i = 0; i < numDefaults; i++)
    175           {
    176             tooltip += Main.encodeTags(defaultInfo['default'][i].name) + '\n';
    177           }
    178           checked = false;
    179         }
    180        
    181         currentDefaultDiv.title = tooltip;
    182         currentDefaultDiv.innerHTML = html;
    183         frm.replaceExistingDefault.checked = checked;
    184         frm.replaceExistingDefault.disabled = disabled;
    185       }
    186     }
    187     </script>
    188107  </base:head>
    189   <base:body onload="init()">
     108  <base:body>
    190109    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
    191110    <form action="index.jsp?ID=<%=ID%>" method="post" name="hardware">
     
    196115      position="bottom"  remember="<%=hardware != null%>"
    197116      extensions="<%=invoker%>">
    198     <t:tab id="info" title="Hardware" validate="validateHardware()" helpid="hardware.edit">
     117    <t:tab id="info" title="Hardware" helpid="hardware.edit">
    199118      <table class="fullform input100 smaller">
    200119      <tr>
    201120        <th>Name</th>
    202         <td><input class="text required" type="text" name="name"
     121        <td><input class="text required auto-init" type="text" name="name" data-auto-init="<%=hardware == null ? "focus-select" : "focus" %>"
    203122          value="<%=HTML.encodeTags(hardware == null ? Values.getString(cc.getPropertyValue("name"), "New hardware") : hardware.getName())%>"
    204123          maxlength="<%=Hardware.MAX_NAME_LENGTH%>"></td>
     
    208127        <th>Type</th>
    209128        <td>
    210           <select name="subtype_id"
     129          <select name="subtype_id" id="subtype_id"
    211130            <%=!readCurrentSubtype ? "disabled readonly class=\"disabled selectionlist\"" : "class=\"selectionlist\""%>
    212             onchange="subtypeOnChange()"
    213131            >
    214132          <%
     
    286204
    287205    <base:buttongroup subclass="dialogbuttons">
    288       <base:button onclick="saveSettings()" title="Save" />
    289       <base:button onclick="window.close()" title="Cancel" />
     206      <base:button id="btnSave" title="Save" />
     207      <base:button id="close" title="Cancel" />
    290208    </base:buttongroup>
    291209  </base:body>
Note: See TracChangeset for help on using the changeset viewer.