Brian Gough 10 лет назад
Родитель
Сommit
74bc157e7c

+ 16 - 0
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(

+ 19 - 1
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()

+ 4 - 0
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 {