Ignore:
Timestamp:
03/11/14 22:45:58 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • Added subcodes to schema and config widgets.
  • Disallow empty strings in schema and strip objects before sending them to the server.
  • Finally managed proper change events in lists and complexvalues.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/model/classes/_Class.js

    r493 r506  
    11define([
    22    "./_View",
     3    "dojo/_base/array",
    34    "dojo/_base/declare",
    45    "dojo/_base/lang",
    56    "dojo/date/stamp"
    6 ], function(_View, declare, lang, stamp) {
     7], function(_View, array, declare, lang, stamp) {
    78
    89    var _Class = declare([_View],{
     
    2223        _doSerialize: function(obj) {
    2324            obj = lang.clone(obj);
    24             return this._serialize(obj) || obj;
     25            obj = this._serialize(obj) || obj;
     26            this._strip(obj);
     27            return obj;
    2528        },
    2629        _serialize: function(obj) {
     
    6164        _formatDate: function(date) {
    6265            return stamp.toISOString(date,{zulu:true,milliseconds:false});
     66        },
     67        _strip: function(obj) {
     68            if ( lang.isArray(obj) ) {
     69                array.forEach(obj,this._strip,this);
     70            } else if ( lang.isObject(obj) ) {
     71                for ( var prop in obj ) {
     72                    if ( obj.hasOwnProperty(prop) ) {
     73                        var v = obj[prop];
     74                        if ( v === null || v === "" || (typeof v === "number" && isNaN(v)) ) {
     75                            delete obj[prop];
     76                        } else {
     77                            this._strip(v);
     78                        }
     79                    }
     80                }
     81            }
     82
    6383        }
    6484    });
Note: See TracChangeset for help on using the changeset viewer.