Skip to content

Commit

Permalink
Add minimal validation on CSV uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmackay committed Feb 18, 2016
1 parent c5a78f1 commit 50fdbc7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/common/directives/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ angular.module('ushahidi.common.file-upload', [])
},

controller: [
'$scope',
'$scope', '$attrs',
function (
$scope
$scope, $attrs
) {
$scope.required = typeof $attrs.required !== 'undefined';
$scope.uploadFile = function ($event) {
$scope.fileContainer.file = $event.target.files[0];
};
Expand Down
2 changes: 1 addition & 1 deletion server/www/templates/file-upload/file-upload.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<input id="appearance-header-image" name="file" type="file" custom-on-change='uploadFile'/>
<input id="appearance-header-image" name="file" type="file" custom-on-change='uploadFile' ng-required="{{ required }}" />

9 changes: 5 additions & 4 deletions server/www/templates/settings/data-import/data-import.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
</ul>
<h1 translate>data_import.import</h1>
</div>

<div class="main-col">
<form class="dk-bg">
<form class="dk-bg" name="upload">
<h2 translate>data_import.csv</h2>
<p><em translate>data_import.import_explanation_csv</em></p>
<p><em translate>data_import.import_explanation_file_size</em></p>
Expand All @@ -18,7 +19,7 @@ <h2 translate>data_import.csv</h2>
<div class="form-field">
<label translate>data_import.post_type</label>
<div class="custom-select init">
<select ng-model="formId">
<select ng-model="formId" required>
<option value="" selected="selected" translate>data_import.select_post_type</option>
<option value="{{form.id}}" ng-repeat="form in forms">
{{form.name}}
Expand All @@ -28,11 +29,11 @@ <h2 translate>data_import.csv</h2>
</div>
<div class="form-field">
<label translate>data_import.file_csv</label>
<file-upload file-container="fileContainer">
<file-upload file-container="fileContainer" required>
</file-upload>
</div>
<div class="form-field">
<button ng-click="importCSV()" type="submit" translate>data_import.import_csv</button>
<button ng-disabled="upload.$invalid" ng-click="importCSV()" type="submit" translate>data_import.import_csv</button>
</div>
</form>
</div>
Expand Down

0 comments on commit 50fdbc7

Please sign in to comment.