APPLINK-6450: Added Exit button in App menu
authorAndrew Melnik <AMelnik@luxoft.com>
Mon, 31 Mar 2014 14:16:35 +0000 (17:16 +0300)
committerJustin Dickow <jjdickow@gmail.com>
Tue, 8 Jul 2014 22:29:49 +0000 (18:29 -0400)
src/components/HMI/app/controller/sdl/AppController.js
src/components/HMI/app/controller/sdl/Controller.js
src/components/HMI/app/model/sdl/AppModel.js

index 7c5d6af..bc88bdf 100644 (file)
@@ -54,9 +54,20 @@ SDL.SDLAppController = Em.Object.create({
      */
     onCommand: function (element) {
 
-        // if submenu
-        if (element.menuID >= 0) {
+        if (element.commandID < 0) {
+
+            switch (element.commandID) {
+                case -1: {
+                    FFW.BasicCommunication.ExitApplication(SDL.SDLAppController.model.appID);
+                    break;
+                }
+                default: {
+                    console.log("Unknown command with ID: " + element.commandID);
+                }
+            }
+        } else if (element.menuID >= 0) {
 
+            // if subMenu
             // activate driver destruction if necessary
             if (SDL.SDLModel.driverDistractionState) {
                 SDL.DriverDistraction.activate();
index bb91c4a..6fc1ebd 100644 (file)
@@ -526,6 +526,20 @@ SDL.SDLController = Em.Object
                     deviceName: params.deviceName,
                     appType: params.appType
                 }));
+
+            var exitCommand = {
+                "id": -10,
+                "params": {
+                    "menuParams":{
+                        "parentID": 0,
+                        "menuName": "Exit",
+                        "position": 0
+                    },
+                    cmdID: -1
+                }
+            };
+
+            SDL.SDLController.getApplicationModel(params.appID).addCommand(exitCommand);
         },
         /**
          * Unregister application
index a0d21b9..d05604f 100644 (file)
@@ -287,7 +287,9 @@ SDL.SDLAppModel = Em.Object.extend({
                 }
 
                 console.log(commands.length);
-                FFW.UI.sendUIResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method);
+                if (request.id >= 0) {
+                    FFW.UI.sendUIResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method);
+                }
             } else {
                 FFW.UI.sendError(SDL.SDLModel.resultCode["REJECTED"], request.id, request.method, 'Adding more than 1000 item to the top menu or to submenu is not allowed.');
             }