Просмотр исходного кода

Merge pull request #381 from sharelatex/ja-fix-undefined-url

Don't render URL section if not linked file
James Allen 8 лет назад
Родитель
Сommit
3796979e1b

+ 2 - 2
services/web/app/views/project/editor/binary-file.pug

@@ -38,7 +38,7 @@ div.binary-file.full-size(
 	) #{translate("no_preview_available")} {{ failedLoad }} {{ textPreview.error }} {{ isUnpreviewableFile() }}
 
 	div.binary-file-footer
-		div(ng-show="openFile.linkedFileData.provider == 'url'")
+		div(ng-if="openFile.linkedFileData.provider == 'url'")
 			p
 				i.fa.fa-fw.fa-external-link-square.fa-rotate-180.linked-file-icon
 				| Imported from
@@ -47,7 +47,7 @@ div.binary-file.full-size(
 				|
 				| at {{ openFile.created | formatDate:'h:mm a' }} {{ openFile.created | relativeDate }}
 
-		span(ng-show="openFile.linkedFileData.provider == 'url'")
+		span(ng-if="openFile.linkedFileData.provider == 'url'")
 			button.btn.btn-success(
 				href, ng-click="refreshFile(openFile)",
 				ng-disabled="refreshing"

+ 2 - 0
services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee

@@ -37,6 +37,8 @@ define [
 		FILLER = '...'
 		TAIL_OF_URL_LENGTH = MAX_URL_LENGTH - FRONT_OF_URL_LENGTH - FILLER.length
 		$scope.displayUrl = (url) ->
+			if !url?
+				return
 			if url.length > MAX_URL_LENGTH
 				front = url.slice(0, FRONT_OF_URL_LENGTH)
 				tail = url.slice(url.length - TAIL_OF_URL_LENGTH)