Is it possible yet to display the custom message bar when viewing a record, or only during edit (pageInit)?
Client script is OK for EDIT, but CSS don't fire in view mode, and UES before load doesnt work either.
/**
* #NApiVersion 2.x
* #NScriptType ClientScript
* #NModuleScope SameAccount
*/
define(['N/ui/message'],
/**
* #param {message} message
*/
function(message) {
function showMessage() {
console.log('exec pageInit');
message.create({
title: "Message Title",
message: "Message Text",
type: message.Type.INFORMATION
}).show();
}
return {
pageInit: showMessage
};
});
Is it possible yet to display the custom message bar when viewing a record
Yes it is possible.
In view mode, pageInit of client script is not triggered, so you can either use worflows, or modify your logic to be trigerred from userevent to show message using N/ui/message module.
Related
I am using gin-swagger for generating API document.
It shows Models at the bottom of the page list by default.
How to hide it?
I met the same issue before, I removed one annotation in comment and Models gone. But I could not remember the name of annotation, however, you can compare your annotaions with below and remove the additional one.
// #Summary Get all users
// #Description Get all users
// #Tags UserMgt
// #Accept json
// #Produce json
// #Param filter body object{UserFilter} true "filter"
// #Success 200 {array} object{models.User} "users"
// #Failure 400 {object} object{models.User} "users not found"
// #Router /user/all [post]
// #Security ApiKeyAuth
func GetAllUsers(ctx *gin.Context) {
....omitted....
}
You juste have to add this line
ginSwagger.DefaultModelsExpandDepth(-1))
like that
ginSwagger.WrapHandler(swaggerFiles.Handler,
ginSwagger.DefaultModelsExpandDepth(-1))
Using nightwatch.js how can I wait for an element to load without the result printing to the console?
I do not want waits to appear in my reports, only normal assertions.
The following code will output 'Waiting for settings menu to load' to the console. If no custom message is used, the default message is 'Element #editMenuContentsButton was visible after xxxx milliseconds':
/**Clicks the settings menu and logs the action.
* #method clickSettings
*/
clickSettings: function () {
this.waitForElementVisible('#settingsSettings', 5000, 'Waiting for settings menu to load');
this.click('#settingsSettings', function () {
testUtil.logAction('Click Gallery settings menu');
});
this.api.pause(1000);
return this;
}
I found a solution to this by simply commenting out the following code in the waitForElement.js file (found in: lib/api/element-commands)
WaitForElement.prototype.pass = function(result, defaultMsg, timeMs) {
this.message = this.formatMessage(defaultMsg, timeMs);
//this.client.assertion(true, null, null, this.message, this.abortOnFailure);
return this.complete(result);
};
During version update, user will receive an update notification once he active the app, an update alert box will pop up, and he/she is able to choose "Update" or "Cancel" the update request.
How do I detect the action(Update/Cancel) user choose ?
If using the feature as provided by default in the product, you cannot.
In order to do such "detection", you will need to implement Custom Direct Update, but it doesn't sound like a full customization is needed in your case, so you can take a look at the following example under "customizing the UI": https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/advanced-client-side-development/using-direct-update-to-quickly-update-your-application/#userExprience
In the example code, there is additional code that either starts or cancels the update process, so it is this spot that you could add additional code to "know" that it was either started or canceled.
wl_directUpdateChallengeHandler.handleDirectUpdate = function(directUpdateData,
directUpdateContext) {
// custom WL.SimpleDialog for Direct Update
var customDialogTitle = 'Custom Title Text';
var customDialogMessage = 'Custom Message Text';
var customButtonText1 = 'Update Application';
var customButtonText2 = 'Not Now';
WL.SimpleDialog.show(customDialogTitle, customDialogMessage,
[{
text : customButtonText1,
handler : function() {
directUpdateContext.start();
// Additional code here.
}
},
{
text : customButtonText2,
handler : function() {
wl_directUpdateChallengeHandler.submitFailure();
// Additional code here.
}
}]
);
};
I want to execute some javascript on page in #BeforeStep hook that depends on jQuery. However jQuery is not defined at that time, in fact page is blank.
Here's what I am trying to achive:
/**
* #BeforeStep #javascript
*/
public function registerAjaxEventHandlers()
{
$javascript = <<<JS
window.jQuery(document).ready(function () {
if (window.__ajaxStatus !== undefined) {
return;
}
window.__ajaxStatus = 'none';
$('body').ajaxStop(function() {
window.__ajaxStatus = 'idle';
});
$('body').ajaxStart(function() {
window.__ajaxStatus = 'in-flight';
});
});
JS;
//$this->getSession()->wait(5000, 'window.jQuery !== undefined');
$this->getSession()->executeScript($javascript);
}
I figured maybe I could wait for the page to load jQuery first (commented line), but it is not true. Seems like execution is halted until that hook is processed.
What is the right place in behat/mink ecosystem to execute javascript on page?
How about this?
$this->getSession()->wait(5000, 'typeof window.jQuery == "function"');
Your javascript is execute before the step, i.e. before the page is loaded. But if you load a page, all kinds of ondomload/pageload JavaScript will be firing already as well.
If you are happy to run it after the initial page, you can use #AfterStep like this:
/**
* #AfterStep
*/
public function set_selenium_css_selector (Behat\Behat\Event\StepEvent $event) {
$this->getSession()->wait(10, 'jQuery ("body").addClass ("selenium")');
}
I want to use different navigator buttons in jqGrid depending on login status.
for example: if the user is logged in then add/delete/edit button appeared.
Any ideas?
Thanks in advance.
It is possible to add buttons programmatically using the navButtonAdd method (for the navigation bar) and the toolbarButtonAdd method for the toolbar. For example:
jQuery("#grid").toolbarButtonAdd('#t_meters',{caption:"MyButton",
id: "t_my_button",
title: "Do my button action",
buttonicon: 'ui-icon-edit',
onClickButton:function(){
// Button handle code goes here...
}
});
And:
jQuery("#grid")..navButtonAdd('#pager',{
id: "t_my_button",
title: "Do my button action",
buttonicon: 'ui-icon-edit',
onClickButton:function(){
// Button handle code goes here...
}
});
For more information see the Custom Buttons on the Wiki.
Anyway, once this code is in place, you can detect login status server-side. Then use this knowledge to generate client code that only adds the buttons to your grid if the user is supposed to have access to them.
You can also use for example userdata (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#user_data) to send information about buttons which you need to have in the navigator. userdata should be set by server. Then with respect of:
var navGridParams = jQuery("grid_id").getGridParam('userData');
// var navGridParams = { edit: false, add: false, search: true }
you can get the data set by the server.
Now the typical call like:
jQuery("grid_id").navGrid('#pager', { edit: false, add: false, search: true });
You should place not after creating of jqGrid, but inside of than inside of loadComplete. So the code could looks like following:
var isNavCreated = false;
jQuery('#list').jqGrid({
// ...
loadComplete: function () {
var grid = jQuery("grid_id");
if (isNavCreated === false) {
isNavCreated = true;
var navGridParams = grid.getGridParam('userData');
grid.navGrid('#pager', navGridParams);
}
},
// ...
});
Another option that I see, is to use cookie instead of userdata to send information about navGridParams back to the client.