1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Added attachment creation from link/name

This commit is contained in:
Dan Brown
2016-10-10 21:13:18 +01:00
parent ac0b29fb6d
commit 89509b487a
7 changed files with 96 additions and 8 deletions

View File

@@ -606,6 +606,18 @@ module.exports = function (ngApp, events) {
});
};
$scope.attachLinkSubmit = function(fileName, fileLink) {
$http.post('/files/link', {
uploaded_to: pageId,
name: fileName,
link: fileLink
}).then(resp => {
$scope.files.unshift(resp.data);
events.emit('success', 'Link attached');
});
$scope.fileName = $scope.fileLink = '';
};
}]);
};

View File

@@ -41,6 +41,19 @@
<p class="muted small">Upload some files to display on your page. This are visible in the page sidebar.</p>
<drop-zone upload-url="@{{getUploadUrl()}}" uploaded-to="@{{uploadedTo}}" event-success="uploadSuccess"></drop-zone>
<hr class="even">
<div class="form-group">
<label for="attachment-via-link">File Name</label>
<input type="text" placeholder="File name" ng-model="fileName">
</div>
<div class="form-group">
<label for="attachment-via-link">Link to file</label>
<input type="text" placeholder="File url" ng-model="fileLink">
</div>
<button type="button" ng-click="attachLinkSubmit(fileName, fileLink)" class="button pos">Attach</button>
<table class="no-style" tag-autosuggestions style="width: 100%;">
<tbody ui-sortable="sortOptions" ng-model="files" >
<tr ng-repeat="file in files track by $index">

View File

@@ -5,7 +5,7 @@
<h6 class="text-muted">Attachments</h6>
@foreach($page->files as $file)
<div class="attachment">
<a href="{{ $file->getUrl() }}"><i class="zmdi zmdi-file"></i> {{ $file->name }}</a>
<a href="{{ $file->getUrl() }}" @if($file->external) target="_blank" @endif><i class="zmdi zmdi-file"></i> {{ $file->name }}</a>
</div>
@endforeach
@endif