Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"angular-breadcrumb": "^0.4.1",
"jquery-timepicker-addon": "^1.3.1",
"jquery-ui": "^1.11.4",
"messageformat": "^0.3.1"
"messageformat": "^0.3.1",
"jasny-bootstrap": "git://github.com/jasny/bootstrap"
},
"overrides": {
"angular-bootstrap": {
Expand Down Expand Up @@ -84,6 +85,12 @@
"main": [
"./messageformat.js"
]
},
"jasny-bootstrap": {
"main": [
"./dist/css/jasny-bootstrap.css",
"./js/fileinput.js"
]
}
},
"resolutions": {
Expand Down
34 changes: 34 additions & 0 deletions src/common/motech-file-upload/motech-file-upload.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function () {
'use strict';

angular.module('motech-common')
.directive('motechFileUpload', ['$compile', '$timeout', '$http', '$templateCache', motechFileUploadDirective]);

function motechFileUploadDirective($compile, $timeout, $http, $templateCache) {
var templateLoader;

return {
restrict: 'E',
replace : true,
transclude: false,
compile: function (tElement, tAttrs, scope) {
var url = '../server/resources/partials/motech-file-upload.html',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jredlarski Can you change this to '/common/motech-file-upload/motech-file-upload.html'? Thanks for adding this directive.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shanmukhm Of course, sorry for this. I'll add it right away...


templateLoader = $http.get(url, {cache: $templateCache})
.success(function (html) {
tElement.html(html);
});

return function (scope, element, attrs) {
templateLoader.then(function () {
var $input = element.find("#fileInput");
if (attrs.accept) {
$input.attr('accept', attrs.accept);
}
element.html($compile(tElement.html())(scope));
});
};
}
};
}
})();
10 changes: 10 additions & 0 deletions src/common/motech-file-upload/motech-file-upload.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="form-control input-auto input-large fileinput-exists" data-trigger="fileinput">
<span class="glyphicon glyphicon-file"></span>&nbsp;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also since we are not using glyphicons, I think we have to use font awesome file icon.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, there would be a quick fix in a few minutes...

<span class="fileinput-preview"></span>
</div>
<span class="btn btn-default btn-file">
<span class="fileinput-new">{{'server.button.selectFile' | translate}}</span>
<span class="fileinput-exists">{{'server.button.changeFile' | translate}}</span>
<input type="file" id="fileInput" name="file" class="input-file"/>
</span>
<button class="button-delete fileinput-exists" data-dismiss="fileinput">{{'server.button.remove' | translate}}</button>