diff --git a/gulp/build.js b/gulp/build.js index 6ce7324c..eea22513 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -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 }); @@ -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']); diff --git a/src/app/component/angularjs-dropdown-multiselect.controller.js b/src/app/component/angularjs-dropdown-multiselect.controller.js index f6324298..e837cc99 100644 --- a/src/app/component/angularjs-dropdown-multiselect.controller.js +++ b/src/app/component/angularjs-dropdown-multiselect.controller.js @@ -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; diff --git a/src/app/main/main.controller.js b/src/app/main/main.controller.js index c9edb050..581d4a8e 100644 --- a/src/app/main/main.controller.js +++ b/src/app/main/main.controller.js @@ -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; + }, + }; } } diff --git a/src/app/main/main.template.html b/src/app/main/main.template.html index 48886878..2e939cd0 100644 --- a/src/app/main/main.template.html +++ b/src/app/main/main.template.html @@ -1058,6 +1058,48 @@
{{smartButtonTextProviderModel|json}}+