I have response above like
i need to frame that
const masterSettingResponse = {
masterSMS: {
allowOverRide: setting.MasterSMS.AllowUserOverride,
smsEnabled: setting.MasterSMS.SMSEnabled,
smsUrl: setting.MasterSMS.SMSURL,
accessToken: setting.MasterSMS.AccesToken,
smsLogUrl: setting.MasterSMS.SMSLogUrl,
clientId: setting.MasterSMS.ClientId,
},
masterEmail: {
allowOverRide: setting.MasterEmail.AllowOverride,
emailEnabled: setting.MasterEmail.EmailEnabled,
emailLogUrl: setting.MasterEmail.EmailLogUrl,
accessToken: setting.MasterEmail.AccessToken,
emailUrl: setting.MasterEmail.EmailUrl,
clientId: setting.MasterEmail.ClientId,
},
masterGeneralSetting: {
isActive: setting.MasterGeneralSetting.IsActive,
portalSessionTimeout: setting.MasterGeneralSetting.PortalSessionTimeout,
appSessionTimeout: setting.MasterGeneralSetting.AppSessionTimeout,
},
};
return masterSettingResponse;
While coming to MasterEmail I am getting an 'AllowOverride' Null Exception.
But, it is boolean property. If the data is not available I need to show 'masterEmail' as null. How do I overcome the Exception?
You are trying to access a property from a null object. Add a check for this to solve your problem.
const masterSettingResponse = {
masterSMS: {
allowOverRide: (setting.MasterSMS ? setting.MasterSMS.AllowUserOverride : null),
smsEnabled: (setting.MasterSMS ? setting.MasterSMS.SMSEnabled : null),
smsUrl: (setting.MasterSMS ? setting.MasterSMS.SMSURL : null),
accessToken: (setting.MasterSMS ? setting.MasterSMS.AccesToken : null),
smsLogUrl: (setting.MasterSMS ? setting.MasterSMS.SMSLogUrl : null),
clientId: (setting.MasterSMS ? setting.MasterSMS.ClientId : null),
},
masterEmail: {
allowOverRide: (setting.MasterEmail ? setting.MasterEmail.AllowOverride : null),
emailEnabled: (setting.MasterEmail ? setting.MasterEmail.EmailEnabled : null),
emailLogUrl: (setting.MasterEmail ? setting.MasterEmail.EmailLogUrl : null),
accessToken: (setting.MasterEmail ? setting.MasterEmail.AccessToken : null),
emailUrl: (setting.MasterEmail ? setting.MasterEmail.EmailUrl : null),
clientId: (setting.MasterEmail ? setting.MasterEmail.ClientId : null),
},
masterGeneralSetting: {
isActive: (setting.MasterGeneralSetting ? setting.MasterGeneralSetting.IsActive : null),
portalSessionTimeout: (setting.MasterGeneralSetting ? setting.MasterGeneralSetting.PortalSessionTimeout : null),
appSessionTimeout: (setting.MasterGeneralSetting ? setting.MasterGeneralSetting.AppSessionTimeout : null),
},
};
Related
I am building a site with a filter and sort menu. When the user clicks on one of the filters, I want that filter option added to the url and then the page to update using this.$router.push. This works fine when I add all of the filters at the same time, but my url shows all of the filters, even if they haven't been selected yet? I changed my code to only show optional queries, but now it doesn't work:
processCheckedTags() {
let queryParams = "";
Object.assign(queryParams,
this.checkedTags !== [] ? {checkedTags: this.checkedTags} : null,
this.checkedSales !== [] ? {checkedSales: this.checkedSales} : null,
this.checkedRatings !== "" ? {checkedRatings: this.checkedRatings} : null,
this.checkedDateAdded !== "" ? {checkedDateAdded: this.checkedDateAdded} : null,
this.sortBy !== "" ? {sortBy: this.sortBy} : null,
this.minPrice !== "" ? {minPrice: this.minPrice} : null,
this.maxPrice !== "" ? {maxPrice: this.maxPrice} : null,
);
this.$router.push(
{
path: this.$route.params.mainNavigation,
query: queryParams
}
);
}
How do I add optional queries to this.$router.push?
With the help of lodash pickBy, you could rewrite what you need in a very succinct way:
processCheckedTags() {
const params = {
checkedTags: this.checkedTags,
checkedSales: this.checkedSales,
checkedRatings: this.checkedRatings,
checkedDateAdded: this.checkedDateAdded,
sortBy: this.sortBy,
minPrice: this.minPrice,
maxPrice: this.maxPrice,
};
this.$router.push(
{
path: this.$route.params.mainNavigation,
query: _.pickBy(params)
}
);
}
Try to define the an array of filters as strings then iterate over them and assign only the property which has a valid value:
let filters=['checkedTags', 'checkedSales', 'checkedRatings', 'checkedDateAdded', 'sortBy', 'minPrice', 'maxPrice']
let queryParams=filters.reduce((acc,curr)=>{
if (this[curr]!==[] || this[curr]!==''){
acc[curr]=this[curr]
}
return acc
},{})
this.$router.push(
{
path: this.$route.params.mainNavigation,
query: queryParams
}
);
Am using Dojo Gridx in my project. These are my columns names
id, field1, field2, active status
I have a assignment, when click column active status need to change the active status value, column icon and field1, field2 values.
For example : if active status values is 'Y' when I click, then I want to change the value of field1, field2 and change active status icon. I can achieve this functionality with the help of below mentioned code.
But here the problem is, field1 is editable, if I click active status column with out edit the field1 the below mentioned code working fine. After I edited, if I click active status column below mentioned code is not working. But values changes in server side, DB side working fine. I don't know what problem please some one make me to understand. I have attached my code for your reference.
require(["dojo/request","dojo/i18n!RW/nls/appResources"], function(request,bundle){
request.get("/RW/rest/"+that.resourcePath,{handleAs : 'J'}).then(
function(J){
that.JGloData=J;
var dataToPopulate = {
identifier: 'id',
items: that.JGloData
};
review.app.defectClassAE.partStore = new dojo.data.ItemFileWriteStore({
data : dataToPopulate
});
review.app.defectClassAE.partStructure = [
{
field : 'id',
name : that.J.defect_id,
width : '5%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{
field : 'field1',
name : that.J.defect_class,
width : '25%',
dataType : 'string',
alwaysEditing : false,
editable : true,
editor : dijit.form.Textarea,
},
{
field : 'field2',
name : that.J.defect_activate_date,
width : '18%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{
field : 'field3',
name : that.J.defect_deactivate_date,
width : '18%',
dataType : 'string',
alwaysEditing : false,
editable : false,
},
{ field: 'activeStatus', name: bundle.RT_QLIST_ACTIVATE, filterable: false, width: '20%' ,editable : false,
widgetsInCell: true,
decorator: function(){
return "<button data-dojo-type='dijit/form/Button' data-dojo-attach-point='btnactivate' data-dojo-props='showLabel: false' type='button'>Activate</button>";
//return "<div data-dojo-type='dijit.form.Button' data-dojo-attach-point='btnactivate'></div>";
},
setCellValue: function(gridData, storeData, cellWidget){
if(gridData == "Y"){
cellWidget.btnactivate.set('iconClass', "rtIcondeactivateReviewType");
}else{
cellWidget.btnactivate.set('iconClass', "rtIconactivateReviewType");
}
(function(cellWidget){
dojo.connect(cellWidget.btnactivate,"onClick",function(){
//var that = this;
var rawData = cellWidget.cell.row.rawData();
var cell = cellWidget.cell;
var DI="";
var activeStatus="";
DI=rawData.DI;
activeStatus=rawData.activeStatus;
if(DI!=null && DI!=""){
require(["dojo/request","dojo/i18n!RW/nls/appResources"], function(request,bundle){
request.get("/RW/rest/"+that.resourcePath+"/defectActOrDea/"+DI,{handleAs : 'J'}).then(
function(J){
if(activeStatus=='Y' || activeStatus==""){
var deactvalues = {
'activeStatus' : 'N',
'field3':that.getTodayDate(),
'field2':""
};
cell.row.setRawData(deactvalues);
that.set('iconClass', "rtIcondeactivateReviewType");
}
else{
var actvalues = {
'activeStatus' : 'Y',
'field2':that.getTodayDate(),
'field3':""
};
cell.row.setRawData(actvalues);
that.set('iconClass', "rtIconactivateReviewType")
}
},
function(error){
showErrorNotification(that.J.defect_act_deact_error);
}
);
});
}
});
})(cellWidget);
}
},
];
You have to use 'getCellWidgetConnects' for binding events to cell widgets. Also make sure you have your grid model saved after editing.
Good Evening guys,
When I update the method it does not save all model items like "tipoNo" and "pai". Someone know what i can do ?
Request Payload
This is the information sent in the request.
{"parentId":1,"nome":"qwfqwfqw"}
Model:
Fields in the my model.
fields : [ {
name : 'id',
type : 'long'
},{
name : 'pai',
type : 'long'
}, {
name : 'nome',
type : 'string'
}, {
name : 'tipoNo',
type : 'string'
}, {
name : 'leaf',
type : 'boolean',
convert : function(value, record) {
var no = record.get('tipoNo');
return (no == "CLIENTE" ? true : false);
}
} ],
Proxy
Proxy to requisite information on the server.
proxy : {
type : 'rest',
url : Webapp.link('node'),
reader : {
type : 'json',
root : 'nodes',
idProperty : 'id'
},
writer : {
type : 'json',
writeAllFields : false
}
}
Controller Method
/**
* Rename
*
* #param {Ext.grid.plugin.CellEditing} editor
* #param {Object} e
*/
updateList : function (editor, e) {
var node = e.record;
node.save({
success: function(list, operation) {
console.log("updated");
},
failure: function(list, operation) {
var error = operation.getError(),
msg = Ext.isObject(error) ? error.status + ' ' + error.statusText : error;
Ext.MessageBox.show({
title: 'Notificação',
msg: msg,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
});
}
});
},
Take a look at your proxy configuration. Your JSON writer has the writeAllFields property set to false. From the Ext.data.writer.Json documentation:
True to write all fields from the record to the server.
If set to false it will only send the fields that were modified.
So any fields that have not been touched will not be sent back to the server. If you want all properties to be sent to the server, set writeAllFields to true (or just remove it, since true is the default) and try again.
Solution in this case:
/**
* Executa a edição
*
* #param {Ext.grid.plugin.CellEditing} editor
* #param {Object} e
*/
updateList : function (editor, e) {
var node = e.record;
var me = this;
var nodeTree = me.getNodeTree();
var method = (node.data.id !== undefined ? 'PUT' : 'POST');
var post = {
id: (node.data.id !== undefined ? null : node.data.id),
nome: node.data.nome,
pai: (node.data.parentId == -1 ? null : node.data.pai),
tipoNo: node.data.tipoNo
};
Ext.Ajax.request({
url: Webapp.link("node"),
headers: { 'Content-Type': 'application/json' },
jsonData: post,
method: method,
success: function(response){
var text = response.responseText;
console.log(text);
nodeTree.refreshView();
}
});
},
this is the code i use to call the form view:
get_view_form_dimension: function() {
var self = this;
var action_manager = new openerp.web.ActionManager(this);
var dialog = new openerp.web.Dialog(this, {
width: 800,
buttons : [
{text: _t("Cancel"), click: function() { $(this).dialog('destroy'); }},
{text: _t("Save"), click: function() {
var form_view = action_manager.inner_viewmanager.views.form.controller;
form_view.do_save(function() {
$.jstree._reference("#new_tree").destroy();
self.get_tree_structure();
});
$(this).dialog('destroy');
}}
]
}).open();
action_manager.appendTo(dialog.$element);
action_manager.do_action({
res_model : 'df.bi.dimension',
res_id: self.process_id,
views : [[false, 'form']],
type : 'ir.actions.act_window',
flags : {
search_view: false,
sidebar : false,
views_switcher : false,
action_buttons : false,
pager: false
}
});
},
how can i set values into the form that this method will rise ?? or in case that exist other solution please tell me ? sorry for my english!
Add a context field to your do_action call with default values, like this:
context: {'default_account_id': 5, 'default_name': 'hello'},
I'm trying to create a status bar with clock.
I found example in sencha examples, but I'm trying to build it more object oriented way.
Ext.define('Urlopy.Components.Statusbar', {
extend : 'Ext.ux.statusbar.StatusBar',
id : 'basic-statusbar',
defaultText : 'Wczytane...',
defaultIconCls : 'x-status-valid',
iconCls : 'x-status-valid',
autoClear : 3000,
initComponent : function() {
this.currentUserDisplay = Ext.create('Ext.toolbar.TextItem');
this.currentUserDisplay.setText('Not logged in!');
this.timeDisplay = Ext.create('Ext.toolbar.TextItem');
this.timeDisplay.setText(Ext.Date.format(new Date(), 'Y-m-d H:i:s'));
Ext.apply(this, {
items : [this.currentUserDisplay, {
xtype : 'tbseparator'
}, this.timeDisplay],
listeners : {
render : {
fn : function() {
Ext.TaskManager.start({
run : function() {
this.timeDisplay.setText(Ext.Date.format(new Date(),'Y-m-d H:i:s'));
},
interval : 1000
});
},
delay : 100
}
}
});
this.callParent();
},
setCurrentUser : function(username) {
this.currentUserDisplay.setText('Logged as' + ": " + username);
},
startLoad : function(message) {
if (message !== null) {
this.showBusy({
text : message,
iconCls : "x-status-busy"
});
} else {
this.showBusy();
}
},
endLoad : function() {
this.clearStatus({
useDefaults : true
});
}
});
The first time component shows it displays date and time correct, but it doesn't update.
Problem is probably TaskManager or my listeners.
Instead of them I've tried doing this:
initComponent : function() {
this.currentUserDisplay = Ext.create("Ext.toolbar.TextItem");
this.currentUserDisplay.setText('Nie jesteś zalogowany!');
this.timeDisplay = Ext.create("Ext.toolbar.TextItem");
this.timeDisplay.setText(Ext.Date.format(new Date(), "Y-m-d H:i:s"));
Ext.apply(this, {
items : [this.currentUserDisplay, {
xtype : 'tbseparator'
}, this.timeDisplay]
});
this.callParent();
var task = {
run : function() {
this.timeDisplay.setText(Ext.Date.format(new Date(), "Y-m-d H:i:s"));
},
interval : 1000
}
Ext.TaskManager.start(task);
},
but no luck :(
I know that this is probably a tiny mistake, but can't find it.
What you have is a scope issue, this in your run function doesn't point to the status bar. you need to add a scope: this after the interval.
see example http://jsfiddle.net/nscrob/kR9ev/17/