Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
pkempenaers committed Apr 25, 2017
2 parents 5a8379f + d305a52 commit dd618e5
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 6 deletions.
33 changes: 27 additions & 6 deletions gulp/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ gulp.task('compile:component', ['clean:component'], function(cb) {
runSequence(['scripts', 'styles', 'partials'], cb);
});

gulp.task('build:component', ['compile:component'], function() {
gulp.task('build.component.minified', ['compile:component'], function () {
var jsFilter = $.filter('**/*.js', { restore: true });
var cssFilter = $.filter('**/*.css', { restore: true });

Expand All @@ -129,14 +129,35 @@ gulp.task('build:component', ['compile:component'], function() {
path.join(conf.paths.tmp, 'partials/templateCacheHtml.js')
])
.pipe(jsFilter)
.pipe(concat({ path: 'angularjs-dropdown-multiselect.min.js'}))
.pipe($.sourcemaps.init())
.pipe($.uglify({ preserveComments: $.uglifySaveLicense })).on('error', conf.errorHandler('Uglify'))
.pipe($.sourcemaps.write('maps'))
.pipe(concat({ path: 'angularjs-dropdown-multiselect.min.js' }))
.pipe($.sourcemaps.init())
.pipe($.uglify({ preserveComments: $.uglifySaveLicense })).on('error', conf.errorHandler('Uglify'))
.pipe($.sourcemaps.write('maps'))
.pipe(jsFilter.restore)
.pipe(cssFilter)
.pipe($.cssnano())
.pipe(cssFilter.restore)
.pipe(gulp.dest(path.join(conf.paths.dist, '/')))
.pipe($.size({ title: path.join(conf.paths.dist, '/'), showFiles: true }));
.pipe($.size({ title: path.join(conf.paths.dist, '/'), showFiles: true }));
});

gulp.task('build.component', ['compile:component'], function () {
var jsFilter = $.filter('**/*.js', { restore: true });
var cssFilter = $.filter('**/*.css', { restore: true });

return gulp.src([
path.join(conf.paths.tmp, 'serve/app/index.css'),
path.join(conf.paths.tmp, 'serve/app/index.module.js'),
path.join(conf.paths.tmp, 'partials/templateCacheHtml.js')
])
.pipe(jsFilter)
.pipe(concat({ path: 'angularjs-dropdown-multiselect.js' }))
.pipe(jsFilter.restore)
.pipe(cssFilter)
.pipe($.cssnano())
.pipe(cssFilter.restore)
.pipe(gulp.dest(path.join(conf.paths.dist, '/src')))
.pipe($.size({ title: path.join(conf.paths.dist, '/'), showFiles: true }));
});

gulp.task('build:component', ['build.component.minified', 'build.component']);
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export default function dropdownMultiselectController(

function getButtonText() {
if ($scope.settings.dynamicTitle && $scope.selectedModel && $scope.selectedModel.length > 0) {
if (angular.isFunction($scope.settings.smartButtonTextProvider)) {
return $scope.settings.smartButtonTextProvider($scope.selectedModel);
}

if ($scope.settings.smartButtonMaxItems > 0) {
const paddingWidth = 12 * 2;
const borderWidth = 1 * 2;
Expand Down
13 changes: 13 additions & 0 deletions src/app/main/main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,5 +324,18 @@ export default class MainController {
$scope.idPropertySettings = {
idProperty: 'id',
};

$scope.smartButtonTextProviderModel = [
];
$scope.smartButtonTextProviderData = [
{ id: 1, label: 'David' },
{ id: 2, label: 'Jhon' },
{ id: 3, label: 'Danny' },
];
$scope.smartButtonTextProviderSettings = {
smartButtonTextProvider(selectionArray) {
return selectionArray.length + 2;
},
};
}
}
42 changes: 42 additions & 0 deletions src/app/main/main.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,48 @@ <h3>Code</h3>
];
$scope.idPropertySettings = {
idProperty: 'id',
};
</div>
</div>
</div>
</div>
<div uib-accordion-group heading="Button text provider">
<div class="row">
<div class="col-xs-12">
When there is a selection this method will be called with the selection as a parameter. The function is supposed to return the text that you want to display on the button.
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6">
<h3>Demo</h3>
<div class="well">
<div ng-dropdown-multiselect="" options="smartButtonTextProviderData" selected-model="smartButtonTextProviderModel" extra-settings="smartButtonTextProviderSettings">
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6">
<h3>The model:</h3>
<pre>{{smartButtonTextProviderModel|json}}</pre>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Code</h3>
<div hljs language="javascript">
// HTML
<div ng-dropdown-multiselect="" options="idPropertyData" selected-model="idPropertyModel" extra-settings="idPropertySettings">
</div>

$scope.smartButtonTextProviderModel = [];
$scope.smartButtonTextProviderData = [
{ id: 1, label: 'David' },
{ id: 2, label: 'Jhon' },
{ id: 3, label: 'Danny' },
];
$scope.idPropertySettings = {
smartButtonTextProvider(selectionArray) {
return selectionArray.length + 2;
},
};
</div>
</div>
Expand Down

0 comments on commit dd618e5

Please sign in to comment.