From 6c9c5c9ebaa2d8f3301f9d891ac67f6035e7ab0b Mon Sep 17 00:00:00 2001 From: Andrew Melnik Date: Mon, 31 Mar 2014 17:16:35 +0300 Subject: [PATCH] APPLINK-6450: Added Exit button in App menu --- src/components/HMI/app/controller/sdl/AppController.js | 15 +++++++++++++-- src/components/HMI/app/controller/sdl/Controller.js | 14 ++++++++++++++ src/components/HMI/app/model/sdl/AppModel.js | 4 +++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/components/HMI/app/controller/sdl/AppController.js b/src/components/HMI/app/controller/sdl/AppController.js index 7c5d6af..bc88bdf 100644 --- a/src/components/HMI/app/controller/sdl/AppController.js +++ b/src/components/HMI/app/controller/sdl/AppController.js @@ -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(); diff --git a/src/components/HMI/app/controller/sdl/Controller.js b/src/components/HMI/app/controller/sdl/Controller.js index bb91c4a..6fc1ebd 100644 --- a/src/components/HMI/app/controller/sdl/Controller.js +++ b/src/components/HMI/app/controller/sdl/Controller.js @@ -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 diff --git a/src/components/HMI/app/model/sdl/AppModel.js b/src/components/HMI/app/model/sdl/AppModel.js index a0d21b9..d05604f 100644 --- a/src/components/HMI/app/model/sdl/AppModel.js +++ b/src/components/HMI/app/model/sdl/AppModel.js @@ -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.'); } -- 2.7.4