Fix #776 : Add check on thumbtitle / business fields

This commit is contained in:
Romain Neutron
2012-07-03 13:35:57 +02:00
parent d0483baab0
commit 40270b9618
2 changed files with 38 additions and 2 deletions

View File

@@ -574,6 +574,10 @@ class databox_field implements cache_cacheableInterface
{ {
$this->Business = ! ! $boolean; $this->Business = ! ! $boolean;
if($this->Business) {
$this->thumbtitle = '0';
}
return $this; return $this;
} }
@@ -666,6 +670,10 @@ class databox_field implements cache_cacheableInterface
{ {
$this->thumbtitle = $value; $this->thumbtitle = $value;
if($this->thumbtitle != '0') {
$this->Business = false;
}
return $this; return $this;
} }

View File

@@ -150,12 +150,12 @@
<input class="metafield_{{ field.get_id() }}" {{ disabled }} name="report_{{ field.get_id() }}" type="checkbox" {% if field.is_report() %}checked="checked"{% endif %}/> <input class="metafield_{{ field.get_id() }}" {{ disabled }} name="report_{{ field.get_id() }}" type="checkbox" {% if field.is_report() %}checked="checked"{% endif %}/>
</td> </td>
<td> <td>
<select class="metafield_{{ field.get_id() }}" {{ disabled }} name="thumbtitle_{{ field.get_id() }}"> <select class="thumbtitle metafield_{{ field.get_id() }}" {{ disabled }} name="thumbtitle_{{ field.get_id() }}">
{{ _self.thumbtitle_selector(field.get_thumbtitle()) }} {{ _self.thumbtitle_selector(field.get_thumbtitle()) }}
</select> </select>
</td> </td>
<td> <td>
<input class="metafield_{{ field.get_id() }}" {{ disabled }} name="business_{{ field.get_id() }}" type="checkbox" {% if field.isBusiness() %}checked="checked"{% endif %}/> <input class="business metafield_{{ field.get_id() }}" {{ disabled }} name="business_{{ field.get_id() }}" type="checkbox" {% if field.isBusiness() %}checked="checked"{% endif %}/>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
@@ -224,6 +224,34 @@
return false; return false;
}); });
$('select.thumbtitle', container).bind('change', function(){
if($(this).val() == '') {
return;
}
var id = $(this).attr('name').split('_').pop();
var business = $('input[name="business_' + id + '"]');
if(business.attr('checked')) {
$(this).val('0');
alert('{% trans 'A field can not be set both as title and business field. Remove business field flag before setting title' %}');
}
});
$('input.business', container).bind('change', function(){
if(!$(this).attr('checked')) {
return;
}
var id = $(this).attr('name').split('_').pop();
var thumbtitle = $('select[name="thumbtitle_' + id + '"]');
if(thumbtitle.val() != '0') {
$(this).removeAttr('checked');
alert('{% trans 'A field can not be set both as title and business field. Remove the title before setting the business flag' %}');
}
});
$("#field_chooser").autocomplete({ $("#field_chooser").autocomplete({
source: "/admin/description/metadatas/search/", source: "/admin/description/metadatas/search/",
minLength: 2, minLength: 2,