1 Attachment(s)
Error when attempting to write/sync a record with a null date value
REQUIRED INFORMATION
Ext version tested:
Browser versions tested against:
OS X Chrome (latest)
Safari IOS
DOCTYPE tested against:
HTML 5
Description:
This is a bit involved, but it seems that Writer.js doesn't know how to deal with null values for dates when dealing with my proxy.
If I try to sync a record that has a particular value for a date (which is optional on my back-end), the code works fine. However, when trying to sync a record that does not have a date in this field, the error occurs.
Steps to reproduce the problem:
* Read some records from JSON with dates...some dates should be filled, some null
* Write a record with a null date
Test Case:
Here's my model definition...if I get back a 'null' value for 'due_date', then try to write that record again is where the bug happens.
Code:
Ext.define('CbMobile.model.LineItem', {
extend: 'Ext.data.Model',
labelCodes: [
'neutral',
'blue',
'green',
'yellow',
'orange',
'red'
],
config: {
fields: [
{name:'id', type:'int'},
{name:'comments_count', type:'int'},
{name:'created_on', type:'date', dateFormat:'c'},
{name:'description', type:'string'},
{name:'due_date', type:'date', dateFormat:'c'},
{name:'estimate_id', type:'int'},
{name:'flat_fee', type:'float'},
{name:'invoice_line_items_count', type:'int'},
{name:'is_complete', type:'boolean'},
{name:'is_taxable', type:'boolean'},
{name:'label_code', type:'int'},
{name:'markup_percentage', type:'float'},
{name:'person_id', type:'int'},
{name:'price_actual', type:'float'},
{name:'price_per', type:'float'},
{name:'project_id', type:'int'},
{name:'project_list_id', type:'int'},
{name:'quantity_low', type:'float'},
{name:'quantity_high', type:'float'},
{name:'rank', type:'int'},
{name:'time_entry_minutes', type:'int'},
{name:'title', type:'string'},
{name:'type_code', type:'int'},
{name:'unit_label', type:'string'},
{name:'updated_at', type:'date', dateFormat:'c'}
],
validations: []
}
labelColor: function() {
return this.labelCodes[this.get('label_code')];
},
isComplete: function() {
return (this.get('is_complete') == true);
},
toggleCompletion: function() {
this.set('is_complete', !this.isComplete());
}
});
HELPFUL INFORMATION
I've attached a screenshot of the error trace from the Chrome javascript console.
Attachment 38368