<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('模型对象版本脚本')" />
    <th:block th:include="include :: jsonview-css" />
</head>
<body class="gray-bg">
      <div class="wrapper wrapper-content animated fadeInRight">
          <form class="form-horizontal m" id="form-modelVersion-add">
              <input type="hidden" id="projectId" name="projectId" th:value="${modelVersion.projectId}">
          </form>
          <div class="text-right p-xxs">
              <a href="#" class="btn btn-sm btn-success m-t-n-xs" id="btnSaveVersion" onclick="buildNewVersion()"><i class="fa fa-floppy-o"></i> 保存新版本 </a>
              <a href="#" class="btn btn-sm btn-warning m-t-n-xs" id="btnSyncFlagn" onclick="syncFlag()"><i class="fa fa-exchange"></i> 标记为同步 </a>
          </div>
        <div class="row">
            <div class="col-sm-4">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>变化信息</h5>
                    </div>  
                    <div class="ibox-content">
                        <div class="form-group">
                            <div class="form-control-static"><pre id="changeContent">无</pre></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-8">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>变化脚本</h5>
                    </div>
                     <div class="ibox-content">
                        <div class="form-group">
                            <div class="form-control-static"><pre id="scriptContent">无</pre></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
      <th:block th:include="include :: jsonview-js" />
    <script th:inline="javascript">
        var prefix = ctx + "model/modelVersion";

        $(function() {
            var changeContent = [[${modelVersion.changeContent}]];
            var parentVersionId = [[${modelVersion.parentVersionId}]];
            var versionId = [[${modelVersion.id}]];
            var syncFlag = [[${modelVersion.syncFlag}]];

            if(versionId <= 0 || syncFlag == "1") {
                $('#btnSyncFlagn').hide();
            }

            if ($.common.isEmpty(changeContent) || changeContent.length <= 0) {
                $("#changeContent").text("无");
            } else {
                if(parentVersionId == 0) {
                    $("#changeContent").text("全量脚本");
                } else {
                    $("#changeContent").text(changeContent);
                }
            }
            var scriptContent = [[${modelVersion.scriptContent}]];
            var id = [[${modelVersion.id}]];
            if ($.common.isEmpty(scriptContent) || scriptContent.length <= 0) {
                $("#scriptContent").text("无");
                $('#btnSaveVersion').hide();
            } else {
                $("#scriptContent").text(scriptContent);
                if(id > 0) {
                    $('#btnSaveVersion').hide();
                }
            }
        });

        function buildNewVersion(){
            var projectId = $("#projectId").val();
            var url = prefix + '/add/' + projectId;
            $.modal.open("保存新版本", url);
        }
    </script>
</body>
</html>
