Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Commit

Permalink
feat(app): use checkboxes for module selection
Browse files Browse the repository at this point in the history
Instead of asking for each module separately, you now get a nice checkbox dialog
where you can tick each of the modules on and off.
  • Loading branch information
passy authored and btford committed Jul 18, 2013
1 parent 8727288 commit 65fe9d2
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 23 deletions.
37 changes: 20 additions & 17 deletions app/index.js
Expand Up @@ -101,26 +101,29 @@ Generator.prototype.askForModules = function askForModules() {
var cb = this.async();

var prompts = [{
type: 'confirm',
name: 'resourceModule',
message: 'Would you like to include angular-resource.js?',
default: true
}, {
type: 'confirm',
name: 'cookiesModule',
message: 'Would you like to include angular-cookies.js?',
default: true
}, {
type: 'confirm',
name: 'sanitizeModule',
message: 'Would you like to include angular-sanitize.js?',
default: true
type: 'checkbox',
name: 'modules',
message: 'Which modules would you like to include?',
choices: [{
value: 'resourceModule',
name: 'angular-resource.js',
checked: true
}, {
value: 'cookiesModule',
name: 'angular-cookies.js',
checked: true
}, {
value: 'sanitizeModule',
name: 'angular-sanitize.js',
checked: true
}]
}];

this.prompt(prompts, function (props) {
this.resourceModule = props.resourceModule;
this.cookiesModule = props.cookiesModule;
this.sanitizeModule = props.sanitizeModule;
var hasMod = function (mod) { return props.modules.indexOf(mod) !== -1; };
this.resourceModule = hasMod('resourceModule');
this.cookiesModule = hasMod('cookiesModule');
this.sanitizeModule = hasMod('sanitizeModule');

cb();
}.bind(this));
Expand Down
10 changes: 10 additions & 0 deletions app/scripts/controllers/weluse.js
@@ -0,0 +1,10 @@
'use strict';

angular.module('generatorAngularApp')
.controller('WeluseCtrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
});
22 changes: 22 additions & 0 deletions test/spec/controllers/weluse.js
@@ -0,0 +1,22 @@
'use strict';

This comment has been minimized.

Copy link
@eddiemonge

eddiemonge Jul 22, 2013

Member

What is this and app/scripts/controllers/weluse.js for?

This comment has been minimized.

Copy link
@passy

passy Jul 23, 2013

Author Member

Woops, this is embarrassing. Thanks, @eddiemonge!


describe('Controller: WeluseCtrl', function () {

// load the controller's module
beforeEach(module('generatorAngularApp'));

var WeluseCtrl,
scope;

// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
WeluseCtrl = $controller('WeluseCtrl', {
$scope: scope
});
}));

it('should attach a list of awesomeThings to the scope', function () {
expect(scope.awesomeThings.length).toBe(3);
});
});
6 changes: 5 additions & 1 deletion test/test-appname-substitution.js
Expand Up @@ -41,7 +41,11 @@ describe('Angular generator template mechanism', function () {
'app/index.html',
'test/spec/controllers/main.js'
];
helpers.mockPrompt(angular, {'bootstrap': 'Y', 'compassBoostrap': 'Y'});
helpers.mockPrompt(angular, {
bootstrap: true,
compassBoostrap: true,
modules: []
});

angular.run({}, function () {
// Check if all files are created for the test
Expand Down
15 changes: 10 additions & 5 deletions test/test-file-creation.js
Expand Up @@ -34,7 +34,8 @@ describe('Angular generator', function () {
it('should generate dotfiles', function (done) {
helpers.mockPrompt(angular, {
bootstrap: true,
compassBoostrap: true
compassBoostrap: true,
modules: []
});

angular.run({}, function () {
Expand All @@ -61,7 +62,8 @@ describe('Angular generator', function () {
];
helpers.mockPrompt(angular, {
bootstrap: true,
compassBoostrap: true
compassBoostrap: true,
modules: []
});

angular.run({}, function() {
Expand All @@ -88,7 +90,8 @@ describe('Angular generator', function () {
];
helpers.mockPrompt(angular, {
bootstrap: true,
compassBoostrap: true
compassBoostrap: true,
modules: []
});

angular.env.options.coffee = true;
Expand All @@ -106,7 +109,8 @@ describe('Angular generator', function () {

helpers.mockPrompt(angular, {
bootstrap: true,
compassBoostrap: true
compassBoostrap: true,
modules: []
});
angular.run([], function () {
angularCtrl.run([], function () {
Expand All @@ -128,7 +132,8 @@ describe('Angular generator', function () {

helpers.mockPrompt(angular, {
bootstrap: true,
compassBoostrap: true
compassBoostrap: true,
modules: []
});
angular.run([], function (){
angularView.run([], function () {
Expand Down

0 comments on commit 65fe9d2

Please sign in to comment.