-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(osSelect): Don't show clear button if no function is provided
- Loading branch information
csnyders
committed
Mar 15, 2016
1 parent
5e3792c
commit ebfa83d
Showing
4 changed files
with
101 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
var _ = require("lodash"); | ||
var webpack = require('webpack'); | ||
var webpackConfig = require("./webpack.config.js"); | ||
|
||
webpackConfig.devtool = 'inline-source-map'; | ||
|
||
console.log('webpackConfig', webpackConfig); | ||
|
||
|
||
module.exports = function(config) { | ||
config.set({ | ||
basePath: '.', | ||
frameworks: ['jasmine'], | ||
files: [ | ||
'./node_modules/angular/angular.js', | ||
'./node_modules/angular-mocks/angular-mocks.js', | ||
// tests | ||
'test/*_test.js', | ||
'test/**/*_test.js' | ||
], | ||
|
||
preprocessors: { | ||
// add webpack as preprocessor | ||
'test/*_test.js': ['webpack'], | ||
'test/**/*_test.js': ['webpack'] | ||
}, | ||
|
||
logLevel: config.LOG_DEBUG, | ||
|
||
webpack: webpackConfig, | ||
|
||
webpackMiddleware: { | ||
// webpack-dev-middleware configuration | ||
// i. e. | ||
stats: { | ||
colors: true | ||
}, | ||
noInfo: false | ||
}, | ||
//browsers: ['PhantomJS'], | ||
browsers: ['Chrome'], | ||
plugins: [ | ||
"karma-webpack", | ||
"karma-jasmine", | ||
"karma-chrome-launcher", | ||
"karma-phantomjs-launcher" | ||
] | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
/// <reference path="../../../typings/main.d.ts" /> | ||
|
||
export class OsSelect { | ||
static $inject = ['$element']; | ||
static $inject = ['$attrs']; | ||
|
||
constructor($element: ng.IRootElementService) { | ||
constructor(private $attrs:ng.IAttributes) { | ||
|
||
} | ||
|
||
hasCloseExpression() { | ||
return this.$attrs['osClear']; | ||
} | ||
|
||
} | ||
} | ||
|
||
angular | ||
.module('osElements') | ||
.component('osSelect', { | ||
bindings: { | ||
disabled: '=ngDisabled', | ||
ngModel: '=', | ||
osItems: '=', | ||
placeholder: '@', | ||
displayField: '@osDisplayField', | ||
clear: '&osClear' | ||
}, | ||
controller: OsSelect, | ||
controllerAs: 'osSelect', | ||
transclude: false, | ||
template: ` | ||
.module('osElements') | ||
.component('osSelect', { | ||
bindings: { | ||
disabled: '=ngDisabled', | ||
ngModel: '=', | ||
osItems: '=', | ||
placeholder: '@', | ||
displayField: '@osDisplayField', | ||
clear: '&osClear' | ||
}, | ||
controller: OsSelect, | ||
controllerAs: 'osSelect', | ||
transclude: false, | ||
template: ` | ||
<md-select ng-disabled="osSelect.disabled" ng-model="osSelect.ngModel" aria-label="{{osSelect.ngModel[osSelect.displayField]}}" placeholder="{{ osSelect.placeholder }}"> | ||
<md-option ng-value="option" ng-disabled="option.disabled" ng-repeat="option in osSelect.osItems">{{ option[osSelect.displayField] }}</md-option> | ||
</md-select> | ||
<os-button ng-if="osSelect.ngModel" class="osSelect__cancel" ng-click="osSelect.clear({object: osSelect.ngModel})" variation="icon"><i class="material-icons">close</i></os-button> | ||
<os-button ng-if="osSelect.ngModel && osSelect.hasCloseExpression()" class="osSelect__cancel" ng-click="osSelect.clear({object: osSelect.ngModel})" variation="icon"><i class="material-icons">close</i></os-button> | ||
` | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
describe("sample test", function() { | ||
|
||
//beforeEach(angular.mock.module('osElements')); | ||
// | ||
//var $controller; | ||
// | ||
//beforeEach(inject(function(_$controller_){ | ||
// $controller = _$controller_; | ||
// console.log('$controller', $controller); | ||
//})); | ||
|
||
it("should run another test", function() { | ||
expect(true).toBe(true); | ||
}); | ||
|
||
}); |