dialog sapui5 oError.body display Rendering - dialog

Hi I have a dialog witch should display the content of an error in the console from a button.
Inside a UPDATE CRUD I have a dialog witch should return me an error from the console if the operation is in a certain situation.
This is my code from the error function.
function(oError){
var StringoError = JSON.parse(oError.response.body);
/*alert("Error!\n"+oError.message);*/
alert(StringoError.error.message.value);
if I use the 2 alerts it works .. but now I have to style the user experience and put the content of Error.message and StringoError.error.message.value in a dialog/popover/popup.. so I implemented like this:
var dialog = new Dialog({
title: (oError.message),
type: 'Message',
state: 'Error',
content: new Text({
text: JSON.parse(oError.response.body).error.message.value,
}),
beginButton: new sap.m.Button({
text: 'Close',
press: function () {
dialog.close();
}
}),
afterClose: function() {
dialog.destroy();
}
});
dialog.open();
});
The problem is that I get to see the title but I can't see error.message.value and the console gives me back as error:
The renderer for class sap.ui.core.Control is not defined or does not
define a render function! Rendering of __control0 will be skipped!

Should it not be sap.m.Text? Or are you using the AMD Module format? But you are using sap.m.Button in the same code...
content: new sap.m.Text({
text: JSON.parse(oError.response.body).error.message.value,
}),

Related

dialog.showMessageBoxSync(null, options) getting hidden

I have an Electron app. If I use dialog.showmessageBoxSync normally it has to wait for user input. The options are: close, cancel or ok.
It is working fine but if I click outside of the dialog box (anywhere inside my app) then this message box hidden. I'm unable to click on any option.
How can I make the message box stay focused until the user chooses a button to click or closes the dialog box? The user should be forced to respond to the message box before continuing to work in the rest of the app.
dialog.showMessageBoxSync({
type: "info",
buttons: ["Ok,", "Cancel"],
defaultId: 0,
title: "",
message:""
cancelId: 1,
})
I'd suggest passing in a parent window
From the docs
The browserWindow argument allows the dialog to attach itself to a
parent window, making it modal.
const iconPath = upath.toUnix(upath.join(__dirname, "app", "assets", "icon.png"));
const dialogIcon = nativeImage.createFromPath(iconPath);
var options = {
type: 'question',
buttons: ['&Yes', '&No'],
title: 'Confirm Quit',
icon: dialogIcon,
normalizeAccessKeys: true,
message: 'Do you really want to close the application?'
};
const win = BrowserWindow.getFocusedWindow();
dialog.showMessageBox(win, options)
.then((choice) => {
if (choice.response === 0) {
quitApplication();
}
}).catch(err => {
console.log('ERROR', err);
});

How to react on link remove event in JointJS

I use the following code to control the remove functionality on links. How can I intercept the remove event and prevent it if the link match a specific condition?
// add a remove button on hovered link
this.paper.on("link:mouseenter", function(linkView) {
let tools = [new joint.linkTools.Remove({ distance: 20 })];
linkView.addTools(
new joint.dia.ToolsView({
name: "onhover",
tools: tools
})
);
});
// remove button on hovered link
this.paper.on("link:mouseleave", function(linkView) {
if (!linkView.hasTools("onhover")) return;
linkView.removeTools();
});
found the answer by using the action argument passed to the linkTools.Remove constructor.
// add a remove button on hovered link
this.paper.on("link:mouseenter", function(linkView) {
let tools = [
new joint.linkTools.Remove({
distance: 20,
action: function(evt) {
// do stuff and remove link using
this.model.remove({ ui: true, tool: this.cid });
}
})
];
linkView.addTools(
new joint.dia.ToolsView({
name: "onhover",
tools: tools
})
);
});

Including dialogs or reusing dialogs from different file

I am trying to do begindialog from another another dialog js file. I am getting error.
<b>[onTurnError]: Error: DialogContext.beginDialog(): A dialog with an id of 'FollowUpDialog' wasn't found. </b>
this is dialog structure-
dialogs
orderstatus
orderstatus.js
index.js
FollowUp
followUp.js
index.js
i am trying to include FollowUp dialog in OrderStatus Dialog, similary i have other dialogs where i want to begin followup or orderstatus dialog. trying to reuse the dialogs.
One way to do use how we include the file in botjs amd to do adddialog same way i can include in otherfile. But it is redundant work. I am trying to avoid that. Can some one tell me better approach to include the dialog in different dialogs.
code:
Below code is from greeting.js
If you see line where i am doing begindialog.
return await step.beginDialog(ORDER_STATUS_DIALOG);
return await step.beginDialog(ENTITLEMENT_CHECK_DIALOG);
It is error. I am trying to include the dialog which is part of different JS files.
async step => {
if (step.context.activity.channelId == 'directline') {
const buttons = [{
type: ActionTypes.ImBack,
title: 'Repair Order Status',
value: symbolicString.ZEB_GR_STR_013
}, {
type: ActionTypes.ImBack,
title: 'Entitlement Check',
value: symbolicString.ZEB_GR_STR_014
}];
const card = CardFactory.heroCard('', undefined, buttons, {
text: symbolicString.ZEB_GR_STR_015
});
const reply = {type: ActivityTypes.Message};
reply.attachments = [card];
return await step.context.sendActivity(reply);
} else {
return await step.prompt(MENU_PROMPT, symbolicString.ZEB_GR_STR_028);
}
},
async step => {
if (step.context.activity.channelId != 'directline'){
console.log("step greeting dialog next step");
console.log(step);
console.log(step.context.activity);
if (step.context.activity.text == '1'){
return await step.beginDialog(ORDER_STATUS_DIALOG);
}else if (step.context.activity.text == '2'){
return await step.beginDialog(ENTITLEMENT_CHECK_DIALOG);
}
}
return await step.endDialog();
}
]));

SuiteScript 2.0 addButton should call a function?

Say I have the following snippet, which is basically a form with a button attached to it. On click, I want to execute a function:
define(['N/ui/serverWidget', 'N/search', 'N/https'],
function(serverWidget, search, https) {
function onRequest(context) {
if (context.request.method === 'GET')
{
var form = serverWidget.createForm({
title: 'Some Form'
});
// some code
form.addButton({
id : '_buttonId',
label : 'Button Label',
functionName: "someFunctinonIWantToCallOnClick(myParam)"
});
context.response.writePage(form)
} else {
// some other code
}
}
function someFunctinonIWantToCallOnClick(myParam)
{
// some code
}
return {
onRequest: onRequest
};
});
According to the NetSuite's documentation:
options.functionName
string
optional
The function name to be triggered on a click event.
Version 2016 Release 1
What am I doing wrong?
There are a number of things wrong with your example.
you are not actually writing the form. Eventually you need:
context.response.writePage(form);
Your function you want to call is only on the server. It is not defined on the client. You need to include a client script that has that function:
form.clientScriptModulePath = './myFormClient.js';

ember.js update view after PUT using node.js/express

I'm pretty new to ember. I have a basic ember app in place with a CRUD page. I'm having trouble refreshing the view/template of the CRUD page after making a PUT request to a node API using mongoDB.
When I delete a model, the page refreshes fine, but not when I PUT. If I refresh the page, everything is fine and working, but I want the view to refresh as soon as I click the "approve" button I have.
Can someone point me in the right direction of how I should be dealing with this in Ember? Or am I not returning something properly from my API and Ember is doing what it should?
Thanks
Node API PUT:
router.put( '/:id', function( req, res ) {
return Picture.findById( req.params.id, function( err, picture ) {
picture.status = req.body.picture.status;
picture.url = req.body.picture.url;
//...and so on
return picture.save( function( err ) {
if( !err ) { return res.send( picture ); }
return res.send('ERROR');
});
});
});
Model:
App.Picture = DS.Model.extend
authorName: DS.attr('string')
pictureName: DS.attr('string')
url: DS.attr('string')
tags: DS.attr('string')
status: DS.attr('string')
Route:
App.AdminRoute = Ember.Route.extend
model: ->
return #store.find 'picture'
actions:
delete: (picture) ->
picture.destroyRecord() # view updates fine
approve: (picture) ->
picture.set('status', 'verified')
picture.save()
Note - I'm also getting this error in my console that I have no understanding of - I don't remember always getting it though, so I'm not sure how much it's related.
Error: No model was found for 'v'
at new Error (native)
at Error.r (http://localhost:3000/javascripts/libs/ember-1.7.0.js:4:992)
at Ember.Object.extend.modelFor (http://localhost:3000/javascripts/libs/ember-data.js:3:4754)
at t.default.i.extend.extractSingle (http://localhost:3000/javascripts/libs/ember-data.js:1:23642)
at y (http://localhost:3000/javascripts/libs/ember-1.7.0.js:4:30411)
at r [as extractSingle] (http://localhost:3000/javascripts/libs/ember-1.7.0.js:4:28863)
at e.default.Ember.Object.extend.extractSave (http://localhost:3000/javascripts/libs/ember-data.js:1:22390)
at e.default.Ember.Object.extend.extractUpdateRecord (http://localhost:3000/javascripts/libs/ember-data.js:1:22097)
at e.default.Ember.Object.extend.extract (http://localhost:3000/javascripts/libs/ember-data.js:1:21661)
at http://localhost:3000/javascripts/libs/ember-data.js:3:9807
The JSON payload being returned from the server is not in a format suitable for Ember to determine the model type. Ember is expecting something like this:
{
picture: {
"_id":"5428abf33e733af2fc0007ff","authorName":"Ben","pictureName":"Proud Chicken",
"status":"verified","tags":null,"url":"benrlodge.github.io/isotopeSearchFilter/img/four.jpg"
}
}
Since you say it works when you refresh, try comparing this payload with what is returned from the GET. The PUT response should be similar.
Refer to this Ember guide: http://emberjs.com/guides/models/connecting-to-an-http-server/#toc_json-conventions
To tweak the payload and (for example) remove the offending property, you can do this:
App.PictureSerializer = DS.RESTSerializer.extend({
normalizePayload: function(payload) {
if (payload['__v']) {
delete payload['__v'];
}
return this._super(payload);
}
});
This example is for PictureSerializer, but if you made it ApplicationSerializer it would work for any type. See the API here: http://emberjs.com/api/data/classes/DS.RESTSerializer.html#method_normalize

Resources