@@ -55,6 +55,16 @@ module.exports = function (oAppData) {
5555 }
5656 ;
5757
58+ let contactsViewInstance = null ;
59+
60+ const getContactsViewInstance = ( ) => {
61+ if ( ! contactsViewInstance ) {
62+ const CContactsView = require ( 'modules/%ModuleName%/js/views/CContactsView.js' ) ;
63+ contactsViewInstance = new CContactsView ( ) ;
64+ }
65+ return contactsViewInstance ;
66+ } ;
67+
5868 EnumsDeclarator . init ( oAppData , Settings . ServerModuleName ) ;
5969 Settings . init ( oAppData ) ;
6070
@@ -102,14 +112,30 @@ module.exports = function (oAppData) {
102112 ] ) ;
103113 }
104114 fRegisterMessagePaneControllerOnStart ( ) ;
115+
116+ App . broadcastEvent ( 'RegisterNewItemElement' , {
117+ 'title' : TextUtils . i18n ( '%MODULENAME%/ACTION_NEW_CONTACT' ) ,
118+ 'handler' : ( ) => {
119+ window . location . hash = Settings . HashModuleName ;
120+ const contactsViewInstance = getContactsViewInstance ( ) ;
121+
122+ const loadingListSubscription = contactsViewInstance . loadingList . subscribe ( ( isListLoading ) => {
123+ if ( ! isListLoading ) {
124+ const command = contactsViewInstance . newContactCommand ;
125+ if ( command . enabled ( ) ) {
126+ command ( )
127+ } ;
128+ loadingListSubscription . dispose ( ) ;
129+ }
130+ } )
131+ } ,
132+ 'className' : 'item_contacts' ,
133+ 'order' : 3 ,
134+ 'column' : 1
135+ } ) ;
105136 } ,
106137 getScreens : function ( ) {
107- var oScreens = { } ;
108- oScreens [ Settings . HashModuleName ] = function ( ) {
109- var CContactsView = require ( 'modules/%ModuleName%/js/views/CContactsView.js' ) ;
110- return new CContactsView ( ) ;
111- } ;
112- return oScreens ;
138+ return { [ Settings . HashModuleName ] : getContactsViewInstance } ;
113139 } ,
114140 getHeaderItem : function ( ) {
115141 return {
0 commit comments