Commit 77daadb9 authored by Fabien Morin's avatar Fabien Morin

same as r35493 for tales tab : make fields readonly if the delegated checkbox is checked


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35498 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fbbeb255
...@@ -84,9 +84,11 @@ This tab can therefore not be used. ...@@ -84,9 +84,11 @@ This tab can therefore not be used.
<dtml-if "proxy_field.is_delegated(field_id)"> <dtml-if "proxy_field.is_delegated(field_id)">
<input type="checkbox" <input type="checkbox"
name="<dtml-var checkbox_key>" name="<dtml-var checkbox_key>"
onclick="toggleFieldState(event)"
checked="checked" /> checked="checked" />
<dtml-else > <dtml-else >
<input type="checkbox" <input type="checkbox"
onclick="toggleFieldState(event)"
name="<dtml-var checkbox_key>" /> name="<dtml-var checkbox_key>" />
</dtml-if > </dtml-if >
</dtml-let > </dtml-let >
...@@ -99,9 +101,15 @@ This tab can therefore not be used. ...@@ -99,9 +101,15 @@ This tab can therefore not be used.
<dtml-var "field.title()"> <dtml-var "field.title()">
</div> </div>
</td> </td>
<td align="left" valign="top"> <dtml-if "proxy_field.is_delegated(field_id)">
<td align="left" valign="top" class="to_disable delegated">
<dtml-var "field.render(value)">
</td>
<dtml-else >
<td align="left" valign="top" class="to_disable">
<dtml-var "field.render(value)"> <dtml-var "field.render(value)">
</td> </td>
</dtml-if>
<td><div class="form-element"> <td><div class="form-element">
<dtml-var "current_field.form.get_field(field.id).meta_type"> <dtml-var "current_field.form.get_field(field.id).meta_type">
</div></td> </div></td>
...@@ -130,9 +138,53 @@ This tab can therefore not be used. ...@@ -130,9 +138,53 @@ This tab can therefore not be used.
</table> </table>
</form> </form>
<script type="text/javascript">
function isClass(object, className) {
if (object.className != undefined){
return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
}
return false;
}
function GetElementsWithClassName(elementName,className) {
var allElements = document.getElementsByTagName(elementName);
var elemColl = new Array();
for (i = 0; i< allElements.length; i++) {
if (isClass(allElements[i], className)) {
elemColl[elemColl.length] = allElements[i];
}
}
return elemColl;
}
var class_deletaged_list = GetElementsWithClassName('*','delegated');
for(var i=0; i<class_deletaged_list.length; i++) {
element = class_deletaged_list[i].childNodes[1];
if (element.type == 'hidden'){
element = class_deletaged_list[i].childNodes[2];
}
element.readOnly = true;
}
function toggleFieldState(evt) {
evt=(evt)?evt:event;
var target=(evt.target)?evt.target:evt.srcElement;
tr_parent = target.parentNode.parentNode;
allElements = tr_parent.childNodes;
for (i=0; i<allElements.length; i++) {
if (isClass(allElements[i], 'to_disable')) {
field = allElements[i].childNodes[1];
if (field.type == 'hidden'){
field = allElements[i].childNodes[2];
}
if (field.readOnly){
field.readOnly = false;
}
else{
field.readOnly = true;
}
}
}
}
</script>
<dtml-var manage_page_footer> <dtml-var manage_page_footer>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment