model.js 2.35 KB
Ext.define('MyMA.model.Users', {
    extend: 'Ext.data.Model',
    fields: [{
			name: 'id',
			type: 'int'
		}, {
			name: 'name',
			type: 'string'
		}, {
			name: 'login',
			type: 'string'
		}, {
			name: 'passwd',
			type: 'string'
		}, {
			name: 'uid',
			type: 'int',
			defaultValue: 8
		}, {
			name: 'gid',
			type: 'int',
			defaultValue: 12
		}, {
			name: 'maildir',
			type: 'string'
		}, {
			name: 'smtp',
			type: 'int'
		}, {
			name: 'imap',
            type: 'int'
		}, {
			name: 'quota',
			type: 'int',
			defaultValue: 10000000
		}, {
			name: 'manager',
			type: 'int'
		}],
	validations: [{
		type: 'format',
		field: 'maildir',
		matcher: /^\/[a-z]\.ru\/[a-z_0-9]\/Maildir\/$/
	}],
    proxy: {
        type: 'rest',
        url: Ext.Ajax.getRestUrl('api/user'),
        reader: {
            type: 'json',
            root: 'results'
        },
        writer: {
            type: 'json',
            allowSingle: true
        }
    }
});
Ext.define('MyMA.model.Brief', {
    extend: 'Ext.data.Model',
    fields: ['id', 'name'],
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'results'
        }
    }
});
Ext.define('MyMA.model.Aliases', {
    extend: 'Ext.data.Model',
    fields: [{
            name: 'id',
            type: 'int'
        }, {
            name: 'alias',
            type: 'string'
        }, {
            name: 'recipient',
            type: 'string'
        }, {
            name: 'comment',
            type: 'string'
        }],
    proxy: {
        type: 'rest',
        url: Ext.Ajax.getRestUrl('api', 'alias'),
        reader: {
            type: 'json',
            root: 'results',
            totalProperty: 'total'
        },
        writer: {
        	type: 'json',
        	allowSingle: true
        }
    }
});
Ext.define('MyMA.model.Transports', {
    extend: 'Ext.data.Model',
    fields: [{
            name: 'id',
            type: 'int'
        }, {
            name: 'domain',
            type: 'string'
        }, {
            name: 'transport',
            type: 'string'
        }],
    proxy: {
        type: 'rest',
        url: Ext.Ajax.getRestUrl('api', 'transport'),
        reader: {
            type: 'json',
            root: 'results',
            totalProperty: 'total'
        },
        writer: {
            type: 'json',
            allowSingle: true
        }
    }
});