<commit_before>var EasyAssess = require('../../easyassess.application');

EasyAssess.directives["esFormSubmit"]
    = EasyAssess.app.directive("esFormSubmit", function (esRequestService,ngDialog,Upload) {
    return {
        restrict: 'E',
        replace: true,
        transclude: false,
        template:'<div>'
                     +'<es-form-page>'
                         +'<div>'
                            +'<button type="button" class="btn btn-primary" ng-click="submit()">提交</button>'
                            +'<button type="button" class="btn btn-primary" ng-click="manageAttachment()">上传附件</button>'
                            //+'<button ng-if="esType!=\'plan\'" type="button" class="btn btn-primary" ng-click="save()">保存</button>'
                         +'</div>'
                         +'<es-app-tab-pane>'
                         + '<es-app-tab es-active="true" es-ref="formView" es-title="表单">'
                            +'<div class="es-page-section">'
                            +'<es-form-header es-header="formHeader" es-editable="false"></es-form-header>'
                            +'</div>'
                            +'<div style="position: relative">'
                            +'<div style="width: 100%; overflow-x:auto; overflow-y: visible;">'
                            +'<div ng-repeat="group in template.groups" class="es-page-section">'
                            +'<es-form-group-edit es-type="{{esType}}" es-group="group" es-data="helpData"></es-form-group-edit>'
                            + '</div>'
                            +'</div>'
                            +   '<div style="padding: 10px 0px 10px 0px;">'
                            +      '<span class="es-form-group-title">填报说明:</span>'
                            +      '<es-form-footer ng-if="template" es-editable="false" es-footer="template.footer"></es-form-footer>'
                            +   '</div>'
                            +'</div>'
                         + '</es-app-tab>'
                         + '<es-app-tab es-ref="preView" es-title="预览">'
                         +    '<es-form-result ng-if="template && previewModel" es-form="previewModel" es-template="template"></es-form-result>'
                         + '</es-app-tab>'
                        +'</es-app-tab-pane>'
                     +'</es-form-page>'
                 +'</div>',
        scope: {
            esForm: "=",
            esType: "@"
        },

        controller: ["$scope","ngDialog", function($scope,ngDialog){
            if ($scope.esType == 'assess'){
                var url = EasyAssess.activeEnv['assess']() + 'template/' + $scope.esForm.securedAssessment.templateGuid;
                esRequestService.esGet(url).then(function(data){
                    $scope.template = data.data;
                });
            }else if($scope.esType == 'plan'){
                $scope.template = $scope.esForm.template;
            }

            $scope.formHeader = {
                name:$scope.esForm.formName
            };
            
            if ($scope.esType =='assess'){
                $scope.helpData =  $scope.esForm.securedAssessment.id;
            }else{
                $scope.helpData = null;
            }

            $scope.manageAttachment = function () {
                ngDialog.open({
                    template: '<div style="padding: 10px 10px 10px 10px;">'
                            +	'<div class="es-dialog-form-line">'
                            +  '<span style="color: #9d261d;">注意: 每个表单只能上传一个附件，重复上传会相互覆盖</span>'
                            +  '</div>'
                             +	'<div class="es-dialog-form-line">'
                             +      '<a href="javascript:void(0)" class="button" ngf-select ng-model="file" name="file" ngf-max-size="20MB" ngf-min-height="100">选择文件</a>'
                             +      '<a ng-if="attachment" href="attachment" style="padding-left: 20px;">查看附件</a>'
                             +  '</div>'

                             +	'<div class="es-dialog-form-line">'
                             +      '<button type="submit" class="btn btn-primary" ng-click="submit()">上传</button>'
                             +  '</div>'
                             + '</div>',
                    plain: true,
                    controller: ['$scope', function ($dialogScope) {
                        $dialogScope.attachment = $scope.esForm.attachment;
                        $dialogScope.submit = function () {
                            if (!$dialogScope.file) {
                                EasyAssess.QuickMessage.error("请选择文件");
                            } else {
                                $dialogScope.upload($dialogScope.file);
                            }
                        };

                        $dialogScope.upload = function (file) {
                            $dialogScope.fileInfo = file;
                            Upload.upload({
                                url: EasyAssess.activeEnv['assess']() + 'form/' + $scope.esForm.id + "/attachment",
                                data: {
                                    'attachment': file
                                },
                                withCredentials: true
                            }).success(function (data, status, headers, config) {
                                EasyAssess.QuickMessage.message("上传成功");<commit_msg>Allow form editor download attachment<commit_after>var EasyAssess = require('../../easyassess.application');

EasyAssess.directives["esFormSubmit"]
    = EasyAssess.app.directive("esFormSubmit", function (esRequestService,ngDialog,Upload) {
    return {
        restrict: 'E',
        replace: true,
        transclude: false,
        template:'<div>'
                     +'<es-form-page>'
                         +'<div>'
                            +'<button type="button" class="btn btn-primary" ng-click="submit()">提交</button>'
                            +'<button type="button" class="btn btn-primary" ng-click="manageAttachment()">上传附件</button>'
                            //+'<button ng-if="esType!=\'plan\'" type="button" class="btn btn-primary" ng-click="save()">保存</button>'
                         +'</div>'
                         +'<es-app-tab-pane>'
                         + '<es-app-tab es-active="true" es-ref="formView" es-title="表单">'
                            +'<div class="es-page-section">'
                            +'<es-form-header es-header="formHeader" es-editable="false"></es-form-header>'
                            +'</div>'
                            +'<div style="position: relative">'
                            +'<div style="width: 100%; overflow-x:auto; overflow-y: visible;">'
                            +'<div ng-repeat="group in template.groups" class="es-page-section">'
                            +'<es-form-group-edit es-type="{{esType}}" es-group="group" es-data="helpData"></es-form-group-edit>'
                            + '</div>'
                            +'</div>'
                            +   '<div style="padding: 10px 0px 10px 0px;">'
                            +      '<span class="es-form-group-title">填报说明:</span>'
                            +      '<es-form-footer ng-if="template" es-editable="false" es-footer="template.footer"></es-form-footer>'
                            +   '</div>'
                            +'</div>'
                         + '</es-app-tab>'
                         + '<es-app-tab es-ref="preView" es-title="预览">'
                         +    '<es-form-result ng-if="template && previewModel" es-form="previewModel" es-template="template"></es-form-result>'
                         + '</es-app-tab>'
                        +'</es-app-tab-pane>'
                     +'</es-form-page>'
                 +'</div>',
        scope: {
            esForm: "=",
            esType: "@"
        },

        controller: ["$scope","ngDialog", function($scope,ngDialog){
            if ($scope.esType == 'assess'){
                var url = EasyAssess.activeEnv['assess']() + 'template/' + $scope.esForm.securedAssessment.templateGuid;
                esRequestService.esGet(url).then(function(data){
                    $scope.template = data.data;
                });
            }else if($scope.esType == 'plan'){
                $scope.template = $scope.esForm.template;
            }

            $scope.formHeader = {
                name:$scope.esForm.formName
            };
            
            if ($scope.esType =='assess'){
                $scope.helpData =  $scope.esForm.securedAssessment.id;
            }else{
                $scope.helpData = null;
            }

            $scope.manageAttachment = function () {
                ngDialog.open({
                    template: '<div style="padding: 10px 10px 10px 10px;">'
                            +	'<div class="es-dialog-form-line">'
                            +  '<span style="color: #9d261d;">注意: 每个表单只能上传一个附件，重复上传会相互覆盖</span>'
                            +  '</div>'
                             +	'<div class="es-dialog-form-line">'
                             +      '<a href="javascript:void(0)" class="button" ngf-select ng-model="file" name="file" ngf-max-size="20MB" ngf-min-height="100">选择文件</a>'
                             +      '<a ng-if="attachment" href="attachment" style="padding-left: 20px;">查看附件</a>'
                             +  '</div>'

                             +	'<div class="es-dialog-form-line">'
                             +      '<button type="submit" class="btn btn-primary" ng-click="submit()">上传</button>'
                             +  '</div>'
                             + '</div>',
                    plain: true,
                    controller: ['$scope', function ($dialogScope) {
                        if (!$dialogScope.attachment) {
                            $dialogScope.attachment = $scope.esForm.attachment;
                        }
                        $dialogScope.submit = function () {
                            if (!$dialogScope.file) {
                                EasyAssess.QuickMessage.error("请选择文件");
                            } else {
                                $dialogScope.upload($dialogScope.file);
                            }
                        };

                        $dialogScope.upload = function (file) {
                            $dialogScope.fileInfo = file;
                            Upload.upload({
                                url: EasyAssess.activeEnv['assess']() + 'form/' + $scope.esForm.id + "/attachment",
                                data: {
                                    'attachment': file
                                },
                                withCredentials: true
                            }).success(function (data, status, headers, config) {
                                EasyAssess.QuickMessage.message("上传成功");
{'fraction_non_alphanumeric': 0.15179384447277364, 'fraction_numerical': 0.005281369513749772, 'mean_word_length': 1.1662721893491124, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 111, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3216939', 'n_tokens_mistral': 2990, 'n_tokens_neox': 2909, 'n_words': 411}