Commit f7d07bea authored by Fabien Morin's avatar Fabien Morin

In Proxy Field, Widget properties show parent values. Here, even if delegated

was checked on, the UI looked modifiable, and there was no difference in whether
it was possible or not. And, when you changed a value which was delegated, the UI
reports that the change was successful, but in reality the change was discarded.
This interface was horribly confusing. In this commit, I use javascript to add
the attribute readonly in case the checkbox is checked. This makes not possible to
modify a field if the checkbox is checked, in this way, we should be able to
avoid mistakes like before.

I try it on browser with javascript disable and the behaviour is exacly like
before, so this improvement benefit only to those who have javascript enable on
their web browsers.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35493 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 89fce777
...@@ -78,9 +78,11 @@ Surcharge <dtml-var meta_type> properties here. ...@@ -78,9 +78,11 @@ Surcharge <dtml-var meta_type> properties here.
<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 >
...@@ -96,9 +98,15 @@ Surcharge <dtml-var meta_type> properties here. ...@@ -96,9 +98,15 @@ Surcharge <dtml-var meta_type> properties here.
</dtml-if> </dtml-if>
</div> </div>
</td> </td>
<td align="left" valign="top"> <dtml-if "proxy_field.is_delegated(field_id)">
<dtml-var "field.render(value)"> <td align="left" valign="top" class="to_disable delegated">
</td> <dtml-var "field.render(value)">
</td>
<dtml-else >
<td align="left" valign="top" class="to_disable">
<dtml-var "field.render(value)">
</td>
</dtml-if>
<td><div class="form-element"> <td><div class="form-element">
<dtml-var "field.meta_type"> <dtml-var "field.meta_type">
</div></td> </div></td>
...@@ -130,6 +138,52 @@ Surcharge <dtml-var meta_type> properties here. ...@@ -130,6 +138,52 @@ Surcharge <dtml-var meta_type> properties here.
</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;
console.log(allElements);
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