Skip to content
Jacky edited this page Feb 1, 2016 · 6 revisions

collection name

EF-Class

admin base - schema

Schema.Class = {
    name : KG.schema.default({
        optional : true
    }),

    programID : KG.schema.default(),
    sessionID : KG.schema.default(),
    status : KG.schema.default({
        allowedValues: Schema.const.status
    }),
    length : KG.schema.default(),
    level : KG.schema.default({
        allowedValues : Schema.const.level,
        defaultValue : 'Beginner'
    }),
    teacher : KG.schema.default({}),
    schedule : {
        type : new SimpleSchema(Schema.ClassSchedule)
    },
    tuition : {
        type : new SimpleSchema(Schema.ClassTuition)
    },
    numberOfClass : KG.schema.default({
        type : Number,
        label : 'Number Of Class',
        custom : function(){
            if(this.value < 1){
                return 'NumberOfClassLess';
            }
        }
    }),
    maxStudent : KG.schema.default({
        type : Number,
        label : 'Maximum Student',
        custom : function(){
            let min = this.field('minStudent');
            //console.log(min, this.value);
            if(this.value < min.value){
                //throw new Error('max student is must more than minimum student');
                return 'MinStudentMoreThanMaxStudent';
            }

        }
    }),
    minStudent : KG.schema.default({
        defaultValue : 0,
        type : Number,
        label : 'Minimum Student'
    }),
    trialStudent : KG.schema.default({
        defaultValue : 0,
        type : Number,
        label : 'Trial Student'
    }),

    minAgeRequire : KG.schema.default({
        type : Number,
        defaultValue : 0,
        optional : true,
        label : 'Minimum Age'
    }),
    maxAgeRequire : KG.schema.default({
        type : Number,
        optional : true,
        label : 'Maximum Age'
    }),
    genderRequire : KG.schema.default({
        allowedValues : Schema.const.genderRequire,
        defaultValue : 'All'
    }),

    createTime : KG.schema.createTime(),
    updateTime : KG.schema.updateTime()
};

Schema.ClassSchedule = {
    day : KG.schema.default({
        allowedValues : Schema.const.day
    }),
    time : KG.schema.default()
};
Schema.ClassTuition = {
    type : KG.schema.default({
        allowedValues : Schema.const.tuitionType
    }),
    money : KG.schema.default({
        label : 'Tuition money'
    })
};

Schema.const = {
    day : ['Sun', 'Mon', 'Tues', 'Wed', 'Thu', 'Fri', 'Sat'],
    tuitionType : ['each', 'total'],
    status : ['Active', 'Inactive'],
    level : ['Beginner', 'Intermediate', 'Advanced'],
    genderRequire : ['All', 'Male', 'Female'],
    //length : ['30 min', '45 min', '1 hr', '1.5 hr', '2 hr']

    registrationStatus : ['trail', 'register', 'wait']
};

mobile base - schema