/**
 * Created by Zhong on 2017/11/24.
 */
let projDisplayView = {
    datas: null,//just for view
    init: function () {
        this.datas = projectObj.project.projectInfo.property.displaySetting;
        this.datas = this.datas === undefined ? {autoHeight: true, disPlayMainMaterial: true} : this.datas;
        //$("#autoHeight").prop("checked", this.datas.autoHeight);
        $("#billsAutoHeight").prop("checked", this.datas.billsAutoHeight);
        $("#rationAutoHeight").prop("checked", this.datas.rationAutoHeight);
        $("#disPlayMainMaterial").prop("checked", this.datas.disPlayMainMaterial);
        //$('#disPlayMainMateria').prop('checked')
    },

    needUpdate: function (autoHeight, disPlayMainMaterial) {
        if (this.datas == null) {
            return;
        }
        return autoHeight !== this.datas.autoHeight || disPlayMainMaterial !== this.datas.disPlayMainMaterial;
    },

    updateChecking: function (properties) {
        if (this.datas == null) {
            return;
        }
        let billsAutoHeight = $("#billsAutoHeight").prop("checked");
        let rationAutoHeight = $("#rationAutoHeight").prop("checked");
        if (this.datas.rationAutoHeight !== rationAutoHeight || this.datas.billsAutoHeight !== billsAutoHeight) {
            this.datas.billsAutoHeight = billsAutoHeight;
            this.datas.rationAutoHeight = rationAutoHeight;
            properties['property.displaySetting'] = this.datas;
        }
    }
};

let calcOptions = {
    datas: null,//just for view
    init: function () {
        this.datas = projectObj.project.projectInfo.property.calcOptions;
        $("#calc_main").prop("checked", this.datas.calc_main);
        $("#calc_add").prop("checked", this.datas.calc_add);
        $("#calc_est").prop("checked", this.datas.calc_est);
    },
    updateChecking: function (properties) {
        if (this.datas == null) {
            return false;
        }
        let calc_main = $('#calc_main').prop('checked');
        let calc_add = $('#calc_add').prop('checked');
        let calc_est = $('#calc_est').prop('checked');
        if (this.datas.calc_main !== calc_main || this.datas.calc_add !== calc_add||this.datas.calc_est !== calc_est) {
            this.datas.calc_main = calc_main;
            this.datas.calc_add = calc_add;
            this.datas.calc_est = calc_est;
            properties['property.calcOptions'] = this.datas;
            return true
        }
        return false
    }
}


/*
$(document).ready(function () {
    $('#tab_display_setting').on('shown.bs.tab', function () {
        projDisplayView.init();
    });
    $('#about-calc').on('shown.bs.tab', function () {
        calcOptions.init();
    });
});*/
