Skip to content

Commit

Permalink
Fix ScrollableMessage, SetGlobalProperties, AlertManeuver (#451)
Browse files Browse the repository at this point in the history
The was noticed a wrong image validation logic in mentioned
rpcs. In all cases HMI responds twice - first time with
regular result code and the second time with the result of
images validation.
To fix that, image validation has been placed into the proper
place in the code and appropriate breaks were added.
Also, was added timer stop for AlertManeuver popup.
  • Loading branch information
AKalinich-Luxoft authored Nov 4, 2020
1 parent 32356f6 commit 7e6fd1c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 31 deletions.
10 changes: 5 additions & 5 deletions app/controller/sdl/Abstract/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,15 +883,15 @@ SDL.SDLController = Em.Object.extend(
messageRequestId,
'UI.ScrollableMessage'
);
}else if(result == SDL.SDLModel.data.resultCode.WARNINGS) {
} else if(result == SDL.SDLModel.data.resultCode.WARNINGS) {
FFW.UI.sendUIResult(
result,
messageRequestId,
'UI.ScrollableMessage'
'UI.ScrollableMessage',
'Requested image(s) not found'
);
}
else {
FFW.UI.sendError(
} else {
FFW.UI.sendUIResult(
result,
messageRequestId,
'UI.ScrollableMessage',
Expand Down
17 changes: 0 additions & 17 deletions app/model/sdl/Abstract/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -936,23 +936,6 @@ SDL.SDLModel = Em.Object.extend({
request.params, messageRequestId
);
}
if(request.params.softButtons) {
var imageList = [];
for(var i = 0; i < request.params.softButtons.length; i++) {
if(request.params.softButtons[i].image) {
imageList.push(request.params.softButtons[i].image.value);
}
}
var callback = function(failed) {
if(failed) {
FFW.UI.sendUIResult(
SDL.SDLModel.data.resultCode.WARNINGS,
request.id,
request.method, "Requested image(s) not found");
}
};
SDL.SDLModel.validateImages(request.id, callback, imageList);
}
return true;
} else {
FFW.UI.sendError(SDL.SDLModel.data.resultCode.REJECTED, request.id,
Expand Down
2 changes: 2 additions & 0 deletions app/view/sdl/AlertManeuverPopUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ SDL.AlertManeuverPopUp = Em.ContainerView.create(
SDL.TTSPopUp.DeactivateTTS();
}

clearTimeout(this.timer);

const resultCode = this.iconsAreValid ?
SDL.SDLModel.data.resultCode.SUCCESS : SDL.SDLModel.data.resultCode.WARNINGS;
const info = this.iconsAreValid ?
Expand Down
35 changes: 33 additions & 2 deletions app/view/sdl/shared/scrollableMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ SDL.ScrollableMessage = SDL.SDLAbstractView.create(
timer: null,
timeout: null,
endTime: null,
areAllImagesValid: true,
childViews: [
'backButton', 'captionText', 'softButtons', 'listOfCommands'
],
Expand All @@ -65,9 +66,21 @@ SDL.ScrollableMessage = SDL.SDLAbstractView.create(
this.set('active', false);
this.softButtons.set('page', 0);
this.timeout = null;

let calculate_result_code = function(areAllImagesValid) {
if (ABORTED) {
return SDL.SDLModel.data.resultCode.ABORTED;
}

if (!areAllImagesValid) {
return SDL.SDLModel.data.resultCode.WARNINGS;
}

return SDL.SDLModel.data.resultCode.SUCCESS;
};

SDL.SDLController.scrollableMessageResponse(
ABORTED ? SDL.SDLModel.data.resultCode['ABORTED'] :
SDL.SDLModel.data.resultCode.SUCCESS, this.messageRequestId
calculate_result_code(this.areAllImagesValid), this.messageRequestId
);
SDL.SDLController.onSystemContextChange();
SDL.SDLModel.data.registeredApps.forEach(app => {
Expand All @@ -76,13 +89,16 @@ SDL.ScrollableMessage = SDL.SDLAbstractView.create(
})
})
},

activate: function(appName, params, messageRequestId) {
if (appName) {
var self = this;
if (params.messageText.fieldName == 'scrollableMessageBody') {
this.set('listOfCommands.items', params.messageText.fieldText);
}

this.set('messageRequestId', messageRequestId);
this.set('areAllImagesValid', true);
this.set('captionText.content', appName);
this.softButtons.addItems(params.softButtons, params.appID);
this.set('active', true);
Expand All @@ -95,6 +111,21 @@ SDL.ScrollableMessage = SDL.SDLAbstractView.create(
self.deactivate();
}, params.timeout
);

if(params.softButtons) {
var imageList = [];
for(var i = 0; i < params.softButtons.length; i++) {
if(params.softButtons[i].image) {
imageList.push(params.softButtons[i].image.value);
}
}
var that = this;
var callback = function(failed) {
that.set('areAllImagesValid', !failed);
};

SDL.SDLModel.validateImages(messageRequestId, callback, imageList);
}
}
},
softButtons: SDL.MenuList.extend(
Expand Down
16 changes: 9 additions & 7 deletions ffw/UIRPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,23 +343,25 @@ FFW.UI = FFW.RPCObserver.create(
}
}

var that = this;
var callback = function(failed) {
var WARNINGS = SDL.SDLModel.data.resultCode.WARNINGS;
var SUCCESS = SDL.SDLModel.data.resultCode.SUCCESS;
var SUCCESS = resultCode;

FFW.Navigation.sendNavigationResult(
failed ? WARNINGS : SUCCESS,
request.id,
request.method,
that.sendUIResult(
failed ? WARNINGS : SUCCESS,
request.id,
request.method,
failed ? "Requested image(s) not found" : null);
}
SDL.SDLModel.validateImages(request.id, callback, imageList);
break;
} else {
info = 'Erroneous response is assigned by settings';
}

this.sendUIResult(
resultCode, request.id, request.method, info
this.sendUIResult(
resultCode, request.id, request.method, info
);
break;
}
Expand Down

0 comments on commit 7e6fd1c

Please sign in to comment.