@@ -187,7 +187,8 @@ var ui_builder = function () {
187187 var patternType = _ . find ( patternlab . patternTypes , [ 'patternType' , pattern . patternType ] ) ;
188188
189189 if ( ! patternType ) {
190- plutils . logRed ( "Could not find patternType" , pattern . patternType , "This is a critical error." ) ;
190+ plutils . logRed ( 'Could not find patternType' + pattern . patternType + '. This is a critical error.' ) ;
191+ console . trace ( ) ;
191192 process . exit ( 1 ) ;
192193 }
193194
@@ -205,7 +206,8 @@ var ui_builder = function () {
205206 var patternSubType = _ . find ( patternType . patternTypeItems , [ 'patternSubtype' , pattern . patternSubType ] ) ;
206207
207208 if ( ! patternSubType ) {
208- plutils . logRed ( "Could not find patternType" , pattern . patternType + '-' + pattern . patternType , "This is a critical error." ) ;
209+ plutils . logRed ( 'Could not find patternType ' + pattern . patternType + '-' + pattern . patternType + '. This is a critical error.' ) ;
210+ console . trace ( ) ;
209211 process . exit ( 1 ) ;
210212 }
211213
@@ -220,7 +222,6 @@ var ui_builder = function () {
220222 */
221223 function addPatternSubType ( patternlab , pattern ) {
222224 var patternType = getPatternType ( patternlab , pattern ) ;
223-
224225 patternType . patternTypeItems . push (
225226 {
226227 patternSubtypeLC : pattern . patternSubGroup . toLowerCase ( ) ,
@@ -255,9 +256,9 @@ var ui_builder = function () {
255256 * @param pattern - the pattern to derive the subtypeitem from
256257 * @param createViewAllVariant - whether or not to create the special view all item
257258 */
258- function addPatternSubTypeItem ( patternlab , pattern , createViewAllVariant ) {
259+ function addPatternSubTypeItem ( patternlab , pattern , createSubtypeViewAllVarient ) {
259260 var patternSubType = getPatternSubType ( patternlab , pattern ) ;
260- if ( createViewAllVariant ) {
261+ if ( createSubtypeViewAllVarient ) {
261262 patternSubType . patternSubtypeItems . push (
262263 {
263264 patternPartial : 'viewall-' + pattern . patternGroup + '-' + pattern . patternSubGroup ,
@@ -267,7 +268,8 @@ var ui_builder = function () {
267268 patternSubtype : pattern . patternSubtype
268269 }
269270 ) ;
270- } else {
271+ }
272+ else {
271273 patternSubType . patternSubtypeItems . push (
272274 createPatternSubTypeItem ( pattern )
273275 ) ;
@@ -279,19 +281,32 @@ var ui_builder = function () {
279281 * @param patternlab - global data store
280282 * @param pattern - the pattern to add
281283 */
282- function addPatternItem ( patternlab , pattern ) {
284+ function addPatternItem ( patternlab , pattern , isViewAllVariant ) {
283285 var patternType = getPatternType ( patternlab , pattern ) ;
284286 if ( ! patternType ) {
285- plutils . logRed ( "Could not find patternType" , pattern . patternType , "This is a critical error." ) ;
287+ plutils . logRed ( 'Could not find patternType' + pattern . patternType + '. This is a critical error.' ) ;
288+ console . trace ( ) ;
286289 process . exit ( 1 ) ;
287290 }
288291
289292 if ( ! patternType . patternItems ) {
290293 patternType . patternItems = [ ] ;
291294 }
292295
293- patternType . patternItems . push ( createPatternSubTypeItem ( pattern ) ) ;
296+ if ( isViewAllVariant ) {
297+ if ( ! pattern . isFlatPattern ) {
298+ //todo: it'd be nice if we could get this into createPatternSubTypeItem someday
299+ patternType . patternItems . push ( {
300+ patternPartial : 'viewall-' + pattern . patternGroup + '-all' ,
301+ patternName : 'View All' ,
302+ patternSrcPath : encodeURI ( pattern . patternType + '/index.html' ) ,
303+ patternPath : encodeURI ( pattern . patternType + '/index.html' )
304+ } ) ;
305+ }
294306
307+ } else {
308+ patternType . patternItems . push ( createPatternSubTypeItem ( pattern ) ) ;
309+ }
295310 }
296311
297312 // function getPatternItems(patternlab, patternType) {
@@ -349,6 +364,7 @@ var ui_builder = function () {
349364
350365 //todo: Pattern Type View All and Documentation
351366 //groupedPatterns.patternGroups[pattern.patternGroup]['viewall-' + pattern.patternGroup] = injectDocumentationBlock(pattern, patternlab, false);
367+ addPatternItem ( patternlab , pattern , true ) ;
352368 }
353369
354370 //continue building navigation for nested patterns
@@ -384,7 +400,7 @@ var ui_builder = function () {
384400 /**
385401 * Builds footer HTML from the general footer and user-defined footer
386402 * @param patternlab - global data store
387- * @param patternPartial - the partial key to build this for //todo test for relevancy
403+ * @param patternPartial - the partial key to build this for, either viewall-patternPartial or a viewall-patternType-all
388404 * @returns HTML
389405 */
390406 function buildFooterHTML ( patternlab , patternPartial ) {
@@ -408,7 +424,7 @@ var ui_builder = function () {
408424 * Used by the type and subtype viewall sets
409425 * @param patternlab - global data store
410426 * @param patterns - the set of patterns to build the viewall page for
411- * @param patternPartial - a key used to identify the viewall pager
427+ * @param patternPartial - a key used to identify the viewall page
412428 * @returns HTML
413429 */
414430 function buildViewAllHTML ( patternlab , patterns , patternPartial ) {
@@ -477,7 +493,7 @@ var ui_builder = function () {
477493 }
478494
479495 //render the footer needed for the viewall template
480- var footerHTML = buildFooterHTML ( patternlab , patternType ) ;
496+ var footerHTML = buildFooterHTML ( patternlab , 'viewall-' + patternType + '-all' ) ;
481497
482498 //add any flat patterns
483499 //todo this isn't quite working yet
0 commit comments