66 * @description
77 * The controller for the doc type creation dialog
88 */
9- function DocumentTypesCreateController ( $scope , $location , navigationService , contentTypeResource , formHelper , appState , notificationsService , localizationService , iconHelper ) {
9+ function DocumentTypesCreateController ( $scope , $location , navigationService , contentTypeResource , formHelper , appState ) {
1010
1111 $scope . model = {
12- allowCreateFolder : $scope . currentNode . parentId === null || $scope . currentNode . nodeType === " container" ,
13- folderName : "" ,
12+ allowCreateFolder : $scope . currentNode . parentId === null || $scope . currentNode . nodeType === ' container' ,
13+ folderName : '' ,
1414 creatingFolder : false
1515 } ;
1616
@@ -31,18 +31,18 @@ function DocumentTypesCreateController($scope, $location, navigationService, con
3131
3232 navigationService . hideMenu ( ) ;
3333
34- var currPath = node . path ? node . path : "-1" ;
34+ var currPath = node . path ? node . path : '-1' ;
3535
3636 navigationService . syncTree ( {
37- tree : " documenttypes" ,
38- path : currPath + "," + folderId ,
37+ tree : ' documenttypes' ,
38+ path : currPath + ',' + folderId ,
3939 forceReload : true ,
4040 activate : true
4141 } ) ;
4242
4343 formHelper . resetForm ( { scope : $scope , formCtrl : $scope . createFolderForm } ) ;
4444
45- var section = appState . getSectionState ( " currentSection" ) ;
45+ var section = appState . getSectionState ( ' currentSection' ) ;
4646
4747 } , function ( err ) {
4848
@@ -51,39 +51,54 @@ function DocumentTypesCreateController($scope, $location, navigationService, con
5151
5252 } ) ;
5353 }
54- } ;
54+ } ;
55+
56+ function createDocType ( config ) {
57+
58+ $location . search ( 'create' , null ) ;
59+ $location . search ( 'notemplate' , null ) ;
60+ $location . search ( 'iscomposition' , null ) ;
61+ $location . search ( 'iselement' , null ) ;
62+ $location . search ( 'icon' , null ) ;
63+
64+ var icon = null ;
65+
66+ if ( config . icon != undefined && config . icon != null ) {
67+ icon = config . icon ;
68+ if ( config . color ) {
69+ icon += ' ' + config . color ;
70+ }
71+ }
72+
73+ $location
74+ . path ( '/settings/documenttypes/edit/' + node . id )
75+ . search ( 'create' , 'true' )
76+ . search ( 'notemplate' , config . notemplate ? 'true' : null )
77+ . search ( 'iscomposition' , config . iscomposition ? 'true' : null )
78+ . search ( 'iselement' , config . iselement ? 'true' : null )
79+ . search ( 'icon' , icon ) ;
80+
81+ navigationService . hideMenu ( ) ;
82+ }
83+
5584
5685 // Disabling logic for creating document type with template if disableTemplates is set to true
5786 if ( ! disableTemplates ) {
58- $scope . createDocType = function ( ) {
59- $location . search ( 'create' , null ) ;
60- $location . search ( 'notemplate' , null ) ;
61- $location . path ( "/settings/documenttypes/edit/" + node . id ) . search ( "create" , "true" ) ;
62- navigationService . hideMenu ( ) ;
87+ $scope . createDocType = function ( icon ) {
88+ createDocType ( { icon } ) ;
6389 } ;
6490 }
6591
66- $scope . createComponent = function ( ) {
67- $location . search ( 'create' , null ) ;
68- $location . search ( 'notemplate' , null ) ;
69- $location . path ( "/settings/documenttypes/edit/" + node . id ) . search ( "create" , "true" ) . search ( "notemplate" , "true" ) ;
70- navigationService . hideMenu ( ) ;
92+ $scope . createComponent = function ( icon ) {
93+ createDocType ( { notemplate : true , icon } ) ;
7194 } ;
7295
73- $scope . createComposition = function ( ) {
74- $location . search ( 'create' , null ) ;
75- $location . search ( 'notemplate' , null ) ;
76- $location . search ( 'iscomposition' , null ) ;
77- $location . path ( "/settings/documenttypes/edit/" + node . id ) . search ( "create" , "true" ) . search ( "notemplate" , "true" ) . search ( "iscomposition" , "true" ) ;
78- navigationService . hideMenu ( ) ;
96+ $scope . createComposition = function ( icon ) {
97+ createDocType ( { iscomposition : true , iselement : true , icon } ) ;
7998 } ;
8099
81- $scope . createElement = function ( ) {
82- $location . search ( 'create' , null ) ;
83- $location . search ( 'notemplate' , null ) ;
84- $location . search ( 'iselement' , null ) ;
85- $location . path ( "/settings/documenttypes/edit/" + node . id ) . search ( "create" , "true" ) . search ( "notemplate" , "true" ) . search ( "iselement" , "true" ) ;
86- navigationService . hideMenu ( ) ;
100+ $scope . createElement = function ( icon ) {
101+ createDocType ( { iselement : true , icon } ) ;
87102 } ;
88103
89104 $scope . close = function ( ) {
@@ -92,4 +107,4 @@ function DocumentTypesCreateController($scope, $location, navigationService, con
92107 } ;
93108}
94109
95- angular . module ( 'umbraco' ) . controller ( " Umbraco.Editors.DocumentTypes.CreateController" , DocumentTypesCreateController ) ;
110+ angular . module ( 'umbraco' ) . controller ( ' Umbraco.Editors.DocumentTypes.CreateController' , DocumentTypesCreateController ) ;
0 commit comments