Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #80 Hiding Header not working when material isn't used, #79 Materials Attribute Not Responding Correctly #81

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
29 changes: 14 additions & 15 deletions dist/angular-csv-import.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! angular-csv-import - v0.0.37 - 2017-05-19
* Copyright (c) 2017 ; Licensed */
/*! angular-csv-import - v0.0.38 - 2018-02-06
* Copyright (c) 2018 ; Licensed */
'use strict';

var csvImport = angular.module('ngCsvImport', []);
Expand Down Expand Up @@ -33,9 +33,9 @@ csvImport.directive('ngCsvImport', function() {
var material = angular.isDefined(attrs.material);
var multiple = angular.isDefined(attrs.multiple);
return '<div class="ng-csv-import">'+
'<div ng-show="headerVisible"><div class="label">Header</div>' +
(material ? '<input type="checkbox" ng-model="header"></div>' :
'<md-switch class="ng-csv-import-header-switch" ng-model="header"></md-switch>') +
'<div ng-show="headerVisible"><div class="label">Header</div>' +
(material ? '<md-switch class="ng-csv-import-header-switch" ng-model="header"></md-switch>' : '<input type="checkbox" ng-model="header">') +
'</div>' +
'<div ng-show="encodingVisible"><div class="label">Encoding</div><span>{{encoding}}</span></div>'+
'<div ng-show="separatorVisible">'+
'<div class="label">Seperator</div>'+
Expand Down Expand Up @@ -84,9 +84,9 @@ csvImport.directive('ngCsvImport', function() {
scope.result = csvToJSON(content);
scope.$apply();
if ( typeof scope.callback === 'function' ) {
if ( scope.callback != null) {
scope.callback(e);
}
if ( scope.callback != null) {
scope.callback(e);
}
}
}
});
Expand Down Expand Up @@ -117,9 +117,9 @@ csvImport.directive('ngCsvImport', function() {
scope.result.filename = scope.filename;
scope.$$postDigest(function(){
if ( typeof scope.callback === 'function' ) {
if ( scope.callback != null) {
scope.callback(onChangeEvent);
}
if ( scope.callback != null) {
scope.callback(onChangeEvent);
}
}
});
});
Expand All @@ -137,14 +137,13 @@ csvImport.directive('ngCsvImport', function() {
scope.result = csvToJSON(content);
scope.$$postDigest(function(){
if ( typeof scope.callback === 'function' ) {
if ( scope.callback != null) {
scope.callback(onChangeEvent);
}
if ( scope.callback != null) {
scope.callback(onChangeEvent);
}
}
});
}
}

if(!scope.lockImportSameFile){
angular.element(document).find('.ng-csv-import.ng-isolate-scope input[type="file"]')[0].value = null;
}
Expand Down
6 changes: 3 additions & 3 deletions dist/angular-csv-import.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 17 additions & 13 deletions lib/angular-csv-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ csvImport.directive('ngCsvImport', function() {
mdInputClass: '@?',
mdButtonTitle: '@?',
mdSvgIcon: '@?',
uploadButtonLabel: '='
uploadButtonLabel: '=',
lockImportSameFile:'=?'
},
template: function(element, attrs) {
var material = angular.isDefined(attrs.material);
var multiple = angular.isDefined(attrs.multiple);
return '<div class="ng-csv-import">'+
'<div ng-show="headerVisible"><div class="label">Header</div>' +
(material ? '<input type="checkbox" ng-model="header"></div>' :
'<md-switch class="ng-csv-import-header-switch" ng-model="header"></md-switch>') +
'<div ng-show="headerVisible"><div class="label">Header</div>' +
(material ? '<md-switch class="ng-csv-import-header-switch" ng-model="header"></md-switch>' : '<input type="checkbox" ng-model="header">') +
'</div>' +
'<div ng-show="encodingVisible"><div class="label">Encoding</div><span>{{encoding}}</span></div>'+
'<div ng-show="separatorVisible">'+
'<div class="label">Seperator</div>'+
Expand Down Expand Up @@ -81,9 +82,9 @@ csvImport.directive('ngCsvImport', function() {
scope.result = csvToJSON(content);
scope.$apply();
if ( typeof scope.callback === 'function' ) {
if ( scope.callback != null) {
scope.callback(e);
}
if ( scope.callback != null) {
scope.callback(e);
}
}
}
});
Expand Down Expand Up @@ -114,9 +115,9 @@ csvImport.directive('ngCsvImport', function() {
scope.result.filename = scope.filename;
scope.$$postDigest(function(){
if ( typeof scope.callback === 'function' ) {
if ( scope.callback != null) {
scope.callback(onChangeEvent);
}
if ( scope.callback != null) {
scope.callback(onChangeEvent);
}
}
});
});
Expand All @@ -134,13 +135,16 @@ csvImport.directive('ngCsvImport', function() {
scope.result = csvToJSON(content);
scope.$$postDigest(function(){
if ( typeof scope.callback === 'function' ) {
if ( scope.callback != null) {
scope.callback(onChangeEvent);
}
if ( scope.callback != null) {
scope.callback(onChangeEvent);
}
}
});
}
}
if(!scope.lockImportSameFile){
angular.element(document).find('.ng-csv-import.ng-isolate-scope input[type="file"]')[0].value = null;
}
});

var csvToJSON = function(content) {
Expand Down