--- a/web/data/cubicweb.preferences.js Mon Jun 22 11:53:59 2009 +0200
+++ b/web/data/cubicweb.preferences.js Tue Jun 23 08:44:42 2009 +0200
@@ -4,6 +4,8 @@
* move me in a more appropriate place
*/
+var prefsValues = {};
+
function togglePrefVisibility(elemId) {
clearPreviousMessages();
jQuery('#' + elemId).toggleClass('hidden');
@@ -21,7 +23,6 @@
_toggleFieldset(fieldsetid, 0, linklabel, linkhref);
}
-
function _toggleFieldset(fieldsetid, closeaction, linklabel, linkhref){
jQuery('#'+fieldsetid).find('div.openlink').each(function(){
var link = A({'href' : "javascript:noop();",
@@ -75,7 +76,6 @@
jQuery('#err-value:' + formid).remove();
}
-
function checkValues(form, success){
var unfreezeButtons = false;
jQuery(form).find('select').each(function () {
@@ -100,8 +100,8 @@
}
function _checkValue(input, unfreezeButtons){
- var currentValueInput = jQuery("input[name=current-" + input.attr('name') + "]");
- if (currentValueInput.val() != input.val()){
+ var currentValue = prefsValues[input.attr('name')];
+ if (currentValue != input.val()){
input.addClass('changed');
unfreezeButtons = true;
}else{
@@ -112,27 +112,22 @@
return unfreezeButtons;
}
-
function setCurrentValues(form){
- jQuery(form).find('input[name^=current-value]').each(function () {
- var currentValueInput = jQuery(this);
- var name = currentValueInput.attr('name').split('-')[1];
- jQuery(form).find("[name=" + name + "]").each(function (){
- var input = jQuery(this);
- if(input.attr('type') == 'radio'){
- // NOTE: there seems to be a bug with jQuery(input).attr('checked')
- // in our case, we can't rely on its value, we use
- // the DOM API instead.
- if(input[0].checked){
- currentValueInput.val(input.val());
- }
- }else{
- currentValueInput.val(input.val());
- }
- });
- });
+ jQuery(form).find('input[name^=value]').each(function () {
+ var input = jQuery(this);
+ if(input.attr('type') == 'radio'){
+ // NOTE: there seems to be a bug with jQuery(input).attr('checked')
+ // in our case, we can't rely on its value, we use
+ // the DOM API instead.
+ if(input[0].checked){
+ prefsValues[input.attr('name')] = input.val();
+ }
+ }else{
+ prefsValues[input.attr('name')] = input.val();
+ }
+ });
}
-
+
function initEvents(){
jQuery('form').each(function() {
var form = jQuery(this);
@@ -153,4 +148,3 @@
$(document).ready(function() {
initEvents();
});
-
--- a/web/views/cwproperties.py Mon Jun 22 11:53:59 2009 +0200
+++ b/web/views/cwproperties.py Tue Jun 23 08:44:42 2009 +0200
@@ -139,7 +139,6 @@
w(u'<h2 class="propertiesform">%s</h2>\n' %
(make_togglable_link('fieldset_' + group, label.capitalize())))
w(u'<div id="fieldset_%s" %s>' % (group, status))
-
# create selection
sorted_objects = sorted((self.req.__('%s_%s' % (group, o)), o, f)
for o, f in objects.iteritems())
@@ -217,10 +216,9 @@
eidparam=True))
subform.vreg = self.vreg
subform.form_add_hidden('pkey', key, eidparam=True)
- subform.form_add_hidden("current-value:%s" % entity.eid,)
form.form_add_subform(subform)
return subform
-
+
def is_user_prefs(cls, req, rset, row=None, col=0, **kwargs):
return req.user.eid == rset[row or 0][col]
@@ -303,7 +301,7 @@
choices = entity.vreg.user_property_keys()
return [(u'', u'')] + sorted(zip((_(v) for v in choices), choices))
-
+
class PropertyValueField(StringField):
"""specific field for CWProperty.value which will be different according to
the selected key type and vocabulary information
@@ -355,7 +353,6 @@
self.choices = field.vocabulary(form)
self.widget = wdg
-
uicfg.autoform_field.tag_attribute(('CWProperty', 'pkey'), PropertyKeyField)
uicfg.autoform_field.tag_attribute(('CWProperty', 'value'), PropertyValueField)
--- a/web/views/primary.py Mon Jun 22 11:53:59 2009 +0200
+++ b/web/views/primary.py Tue Jun 23 08:44:42 2009 +0200
@@ -54,6 +54,7 @@
self.w(u'<table width="100%"><tr><td style="width: 75%">')
self.w(u'<div>')
self.w(u'<div class="mainInfo">')
+ self.content_navigation_components('navcontenttop')
try:
self.render_entity_attributes(entity)
except TypeError: # XXX bw compat
@@ -61,7 +62,6 @@
'deprecated (%s)' % self.__class__)
self.render_entity_attributes(entity, [])
self.w(u'</div>')
- self.content_navigation_components('navcontenttop')
if self.main_related_section:
try:
self.render_entity_relations(entity)