diff --git a/services/web/app/views/project/editor/pdf.jade b/services/web/app/views/project/editor/pdf.jade index 492f75f582..2dfcb0a0eb 100644 --- a/services/web/app/views/project/editor/pdf.jade +++ b/services/web/app/views/project/editor/pdf.jade @@ -36,6 +36,15 @@ div.full-size.pdf(ng-controller="PdfController") i.fa.fa-fw(ng-class="{'fa-check': draft}") |  #{translate("fast")}  span.subdued [draft] + li.dropdown-header #{translate("compile_time_checks")} + li + a(href, ng-click="stop_on_validation_error = true") + i.fa.fa-fw(ng-class="{'fa-check': stop_on_validation_error}") + |  #{translate("stop_on_validation_error")} + li + a(href, ng-click="stop_on_validation_error = false") + i.fa.fa-fw(ng-class="{'fa-check': !stop_on_validation_error}") + |  #{translate("ignore_validation_errors")} li.dropdown-header #{translate("file_checks")} li a(href, ng-click="recompile({check:true})") @@ -204,6 +213,13 @@ div.full-size.pdf(ng-controller="PdfController") p.entry-content(ng-show="entry.content") {{ entry.content.trim() }} + p.force-recompile(ng-if="$first && !check && stop_on_validation_error") + a.btn.btn-info( + href, + ng-disabled="pdf.compiling", + ng-click="recompile({force:true})" + ) + span() #{translate("force_recompile")} p .files-dropdown-container a.btn.btn-default.btn-sm( diff --git a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee index a31a336885..d6c19cd0ea 100644 --- a/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee +++ b/services/web/public/coffee/ide/pdf/controllers/PdfController.coffee @@ -73,6 +73,12 @@ define [ $scope.pdf.view = 'errors' $scope.pdf.renderingError = true + # abort compile if syntax checks fail + $scope.stop_on_validation_error = localStorage("stop_on_validation_error:#{$scope.project_id}") or ide.$scope?.user?.betaProgram + $scope.$watch "stop_on_validation_error", (new_value, old_value) -> + if new_value? and old_value != new_value + localStorage("stop_on_validation_error:#{$scope.project_id}", new_value) + $scope.draft = localStorage("draft:#{$scope.project_id}") or false $scope.$watch "draft", (new_value, old_value) -> if new_value? and old_value != new_value @@ -83,10 +89,17 @@ define [ params = {} if options.isAutoCompile params["auto_compile"]=true + # keep track of whether this is a compile or check + $scope.check = if options.check then true else false + # send appropriate check type to clsi + checkType = switch + when $scope.check then "validate" # validate only + when $scope.stop_on_validation_error then "error" # try to compile + else "silent" # ignore errors return $http.post url, { rootDoc_id: options.rootDocOverride_id or null draft: $scope.draft - check: if options.check then "validate" else "silent" + check: checkType _csrf: window.csrfToken }, {params: params} @@ -347,6 +360,11 @@ define [ $scope.pdf.compiling = true + if options?.force + # for forced compile, turn off validation check + $scope.stop_on_validation_error = false + $scope.shouldShowLogs = false # hide the logs while compiling + ide.$scope.$broadcast("flush-changes") options.rootDocOverride_id = getRootDocOverride_id() diff --git a/services/web/public/stylesheets/app/editor/pdf.less b/services/web/public/stylesheets/app/editor/pdf.less index 2183798650..12c86a6190 100644 --- a/services/web/public/stylesheets/app/editor/pdf.less +++ b/services/web/public/stylesheets/app/editor/pdf.less @@ -161,6 +161,10 @@ .dropdown { position: relative; } + .force-recompile { + margin-top: 10px; + text-align: right; + } } .synctex-controls {