@@ -24,13 +24,40 @@ module.exports = yeoman.Base.extend({
2424 message : 'What is the name of your add-in?' ,
2525 default : this . appname
2626 } , {
27+ type : 'list' ,
28+ name : 'type' ,
29+ message : 'What type of add-in do you want to create?' ,
30+ default : 'MyGeotabPage' ,
31+ choices : [ {
32+ name : 'MyGeotab Add-In Page' ,
33+ value : 'MyGeotabPage'
34+ } , {
35+ name : 'MyGeotab Add-In Button' ,
36+ value : 'MyGeotabButton'
37+ } , {
38+ name : 'Geotab Drive Add-In Page' ,
39+ value : 'DrivePage'
40+ } ]
41+ } , {
42+ type : 'input' ,
43+ name : 'supportEmail' ,
44+ message : 'What is the support contact email address for the add-in?' ,
45+ default : ''
46+ } , {
47+ type : 'input' ,
48+ name : 'host' ,
49+ message : 'What is the deployment host URL?' ,
50+ default : 'https://www.example.com/myaddin/'
51+ } ] ;
52+
53+ var MyGeotabPagePrompts = [ {
2754 type : 'list' ,
2855 name : 'path' ,
2956 message : 'Select where your add-in will be located in MyGeotab side nav tree: (Geotab Drive specific add-in must choose "Geotab Drive")' ,
3057 default : false ,
3158 choices : [ {
3259 name : 'Root' ,
33- value : '/ '
60+ value : ''
3461 } , {
3562 name : 'Getting Started' ,
3663 value : 'GettingStartedLink/'
@@ -49,36 +76,120 @@ module.exports = yeoman.Base.extend({
4976 } , {
5077 name : 'Administration' ,
5178 value : 'AdministrationLink/'
52- } , {
53- name : 'Geotab Drive' ,
54- value : 'DriveAppLink/'
5579 } ]
5680 } , {
5781 type : 'input' ,
5882 name : 'menuName' ,
5983 message : 'What is the add-in menu item name?' ,
6084 default : this . appname
85+ } ] ;
86+
87+ var MyGeotabButtonPrompts = [ {
88+ type : 'list' ,
89+ name : 'page' ,
90+ message : 'Select which page your add-in button will be located in MyGeotab' ,
91+ default : 'Map' ,
92+ choices : [ {
93+ name : 'Map' ,
94+ value : 'map'
95+ } , {
96+ name : 'Trips History' ,
97+ value : 'tripsHistory'
98+ } , {
99+ name : 'Vehicles' ,
100+ value : 'devices'
101+ } , {
102+ name : 'Vehicle Add/Edit' ,
103+ value : 'device'
104+ } , {
105+ name : 'Zones' ,
106+ value : 'zones'
107+ } , {
108+ name : 'Zone Add/Edit' ,
109+ value : 'zones'
110+ } , {
111+ name : 'Users' ,
112+ value : 'users'
113+ } , {
114+ name : 'User Add/Edit' ,
115+ value : 'user'
116+ } , {
117+ name : 'Rules' ,
118+ value : 'rules'
119+ } , {
120+ name : 'Rule Add/Edit' ,
121+ value : 'rule'
122+ } , {
123+ name : 'Exceptions' ,
124+ value : 'exceptions'
125+ } , {
126+ name : 'Custom Reports' ,
127+ value : 'customReports'
128+ } , {
129+ name : 'Custom Report Edit' ,
130+ value : 'customReport'
131+ } , {
132+ name : 'Engine Faults' ,
133+ value : 'engineFaults'
134+ } , {
135+ name : 'Speed Profile' ,
136+ value : 'speedProfile'
137+ } , {
138+ name : 'Duty Status Logs' ,
139+ value : 'hosLogs'
140+ } , {
141+ name : 'HOS Log Add/Edit' ,
142+ value : 'hosLog'
143+ } , {
144+ name : 'Groups' ,
145+ value : 'groupsTree'
146+ } , {
147+ name : 'Routes' ,
148+ value : 'routes'
149+ } , {
150+ name : 'Fuel Usage' ,
151+ value : 'fuelUsage'
152+ } , {
153+ name : 'Engine Measurements' ,
154+ value : 'engineMeasurements'
155+ } ]
61156 } , {
62157 type : 'input' ,
63- name : 'supportEmail' ,
64- message : 'What is the support contact email address for the add-in?' ,
65- default : ''
66- } , {
67- type : 'input' ,
68- name : 'host' ,
69- message : 'What is the deployment host URL?' ,
70- default : 'https://www.example.com/myaddin/'
158+ name : 'menuName' ,
159+ message : 'What is the add-in button text?' ,
160+ default : this . appname
71161 } ] ;
72162
73163 this . prompt ( prompts , function ( props ) {
164+ var nextPrompts ;
165+
74166 props . camelName = camelCase ( props . name ) ;
75- props . fileName = props . camelName + '.html' ;
76- props . isDriveAddin = props . path === 'DriveAppLink/' ;
77- if ( props . host && props . host . indexOf ( '/' , props . host . length - 1 ) === - 1 ) {
167+ if ( props . host && props . host . indexOf ( '/' , props . host . length - 1 ) === - 1 ) {
78168 props . host += '/' ;
79169 }
80- this . props = props ;
81- done ( ) ;
170+
171+ switch ( props . type ) {
172+ case 'MyGeotabPage' :
173+ nextPrompts = MyGeotabPagePrompts ;
174+ break ;
175+ case 'MyGeotabButton' :
176+ nextPrompts = MyGeotabButtonPrompts ;
177+ props . isButton = true ;
178+ break ;
179+ case 'DrivePage' :
180+ nextPrompts = [ MyGeotabPagePrompts [ 1 ] ] ;
181+ props . isDriveAddin = true ;
182+ props . path === 'DriveAppLink/'
183+ break ;
184+ }
185+
186+ this . prompt ( nextPrompts , function ( props2 ) {
187+ Object . assign ( props , props2 ) ;
188+ this . props = props ;
189+
190+ done ( ) ;
191+ } . bind ( this ) ) ;
192+
82193 } . bind ( this ) ) ;
83194 } ,
84195
@@ -89,7 +200,8 @@ module.exports = yeoman.Base.extend({
89200 this . destinationPath ( 'gulpfile.babel.js' ) , {
90201 date : new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ,
91202 name : this . pkg . name ,
92- version : this . pkg . version
203+ version : this . pkg . version ,
204+ isButton : this . props . isButton ,
93205 }
94206 ) ;
95207 } ,
@@ -135,11 +247,15 @@ module.exports = yeoman.Base.extend({
135247 } ,
136248
137249 index : function ( ) {
250+ var indexLocation = this . props . isButton ? '.dev/button.html' : `app/${ this . props . camelName } .html` ;
138251 this . fs . copyTpl (
139252 this . templatePath ( 'app/addin.html' ) ,
140- this . destinationPath ( 'app/' + this . props . fileName ) , {
253+ this . destinationPath ( indexLocation ) , {
141254 title : this . props . name ,
142- root : this . props . camelName
255+ root : this . props . camelName ,
256+ isDriveAddin : this . props . isDriveAddin ,
257+ isButton : this . props . isButton ,
258+ click : this . props . camelName + ( this . props . isButton ? '.js' : '.html' )
143259 }
144260 ) ;
145261 } ,
@@ -150,29 +266,43 @@ module.exports = yeoman.Base.extend({
150266 this . destinationPath ( 'app/config.json' ) , {
151267 title : this . props . name ,
152268 supportEmail : this . props . supportEmail ,
153- url : this . props . fileName ,
269+ url : this . props . camelName + ( this . props . isButton ? '.js' : '.html' ) ,
154270 path : this . props . path ,
271+ page : this . props . page ,
155272 menuName : this . props . menuName ,
156273 root : this . props . camelName ,
157- host : this . props . host
274+ host : this . props . host ,
275+ isButton : this . props . isButton
158276 }
159277 ) ;
160278 } ,
161279
162280 scripts : function ( ) {
163- this . fs . copyTpl (
164- this . templatePath ( 'app/scripts/main.js' ) ,
165- this . destinationPath ( 'app/scripts/main.js' ) , {
166- root : this . props . camelName
167- }
168- ) ;
281+ if ( this . props . isButton ) {
282+ this . fs . copyTpl (
283+ this . templatePath ( 'app/scripts/button.js' ) ,
284+ this . destinationPath ( 'app/scripts/' + this . props . camelName + '.js' ) , {
285+ root : this . props . camelName
286+ }
287+ ) ;
288+ } else {
289+ this . fs . copyTpl (
290+ this . templatePath ( 'app/scripts/main.js' ) ,
291+ this . destinationPath ( 'app/scripts/main.js' ) , {
292+ root : this . props . camelName ,
293+ isDriveAddin : this . props . isDriveAddin
294+ }
295+ ) ;
296+ }
169297 } ,
170298
171299 css : function ( ) {
172- this . fs . copy (
173- this . templatePath ( 'app/styles/main.css' ) ,
174- this . destinationPath ( 'app/styles/main.css' )
175- ) ;
300+ if ( ! this . props . isButton ) {
301+ this . fs . copy (
302+ this . templatePath ( 'app/styles/main.css' ) ,
303+ this . destinationPath ( 'app/styles/main.css' )
304+ ) ;
305+ }
176306 } ,
177307
178308 icon : function ( ) {
@@ -203,9 +333,11 @@ module.exports = yeoman.Base.extend({
203333 this . destinationPath ( '.dev/api.js' )
204334 ) ;
205335
206- this . fs . copy (
336+ this . fs . copyTpl (
207337 this . templatePath ( '_dev/login.html' ) ,
208- this . destinationPath ( '.dev/login.html' )
338+ this . destinationPath ( '.dev/login.html' ) , {
339+ isDriveAddin : this . props . isDriveAddin
340+ }
209341 ) ;
210342
211343 this . fs . copy (
@@ -217,6 +349,16 @@ module.exports = yeoman.Base.extend({
217349 this . templatePath ( '_dev/rison.js' ) ,
218350 this . destinationPath ( '.dev/rison.js' )
219351 ) ;
352+
353+ this . fs . copy (
354+ this . templatePath ( '_dev/style/styleGuide.css' ) ,
355+ this . destinationPath ( '.dev/style/styleGuide.css' )
356+ ) ;
357+
358+ this . fs . copy (
359+ this . templatePath ( '_dev/style/styleGuideMyGeotab.html' ) ,
360+ this . destinationPath ( '.dev/style/styleGuideMyGeotab.html' )
361+ ) ;
220362 }
221363 } ,
222364
0 commit comments