Skip to content

Instantly share code, notes, and snippets.

@jorge-perez-anfix
Last active June 10, 2019 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorge-perez-anfix/e758d8c9f94350f3a4020f8e8a861d03 to your computer and use it in GitHub Desktop.
Save jorge-perez-anfix/e758d8c9f94350f3a4020f8e8a861d03 to your computer and use it in GitHub Desktop.
Actions deprecados
searchPayChargeMethods: function(onSuccess, onFailure, applicationInstanceId) {
var PayChargeMethodModel = Ext.ModelManager.getModel('Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod'),
payChargeMethodModel = new PayChargeMethodModel({applicationInstanceId: applicationInstanceId || this.controller.appContaPro[ConstantsGui.WINDOW_ID]});
payChargeMethodModel.search({
search : {
jsonRequest: {
Order : ['PayChargeMethodCode'],
OrderTypes : ['ASC'],
Fields : ['PayChargeMethodId','PayChargeMethodCode','PayChargeMethodName'],
Group : [],
CompanySelected: ContaProUtis.getCompanySelected()
},
ApplicationId: CosntantsGUI.APP_OS
},
success : onSuccess,
failure : onFailure || Ext.emptyFn,
scope : this
});
},
/**
* Copyright (c) 2011 Anfix Software, S.L. Todos los derechos reservados.
* Documento Confidencial.
*
* @file NewPayChargeMethod.js
* @Author Patricia Gañan (patricia.ganan@anfix.com)
* @date August, 2012
* @brief Controller for the new pay charge method form.
*/
Ext.define("Anfix.contapro.controller.expirations.paychargemethods.NewPayChargeMethod", {
requires : [
"Anfix.contapro.view.expirations.paychargemethods.NewPayChargeMethod",
"Anfix.utils.Utils" ],
alternateClassName : 'NewPayChargeMethodContaProController',
extend : "Anfix.controller.AbstractController",
models : [ "Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod" ],
statics : {},
load : function() {
var newPayChargeMethodWindow = Ext.create('Anfix.contapro.view.expirations.paychargemethods.NewPayChargeMethod',{
controller : this,
title : toLocale(ContaProMetaController.NAME,"contapro.paychargemethods.newPayChargeMethod"),
modal : false,
appContaPro : this.appContaPro,
parentController : this.parentController
});
this.view = newPayChargeMethodWindow;
this.callParent();
if (this.mode === ConstantsContaPro.UPDATE) {
if (this.record.PayChargeMethodIsInstallments) {
this.record.PayChargeMethodNumberExpirationsInstallments = this.record.PayChargeMethodNumberExpirations;
this.record.PayChargeMethodExpiration1Installments = this.record.PayChargeMethodExpiration1;
this.record.PayChargeMethodDaysOrMonthsInstallments = this.record.PayChargeMethodDaysOrMonths;
} else {
this.record.PayChargeMethodNumberExpirationsNoInstallments = this.record.PayChargeMethodNumberExpirations;
this.record.PayChargeMethodExpiration1NoInstallments = this.record.PayChargeMethodExpiration1;
this.record.PayChargeMethodDaysOrMonthsNoInstallments = this.record.PayChargeMethodDaysOrMonths;
}
this.view.setTitle(toLocale(ContaProMetaController.NAME,"contapro.paychargemethods.updatePayChargeMethod"));
var PayChargeMethodModel = this.getModel("Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod");
var payChargeMethodModel = new PayChargeMethodModel(this.record, this.record.PayChargeMethodId);
this.view.loadData(payChargeMethodModel);
}
this.appContaPro.view.add(this.view);
newPayChargeMethodWindow.show();
newPayChargeMethodWindow.center();
//Ext.Function.defer(function(){this.view.query('#payChargeMethodCode')[0].focus();}, 100, this);
},
handleSave : function(button, event) {
this.disableSaveButton(true);
var payChargeMethodForm = this.view.formPanel.getForm();
if (payChargeMethodForm.isValid()) {
var PayChargeMethodModel = this.getModel("Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod");
var values = this.view.formPanel.getForm().getValues(), isInstallments = values.PayChargeMethodIsInstallments;
values.CompanySelected = ContaProUtils.getCompanySelected();
values.applicationId = ConstantsGui.APP_OS;
if (isInstallments === 'true') {
values.PayChargeMethodNumberExpirations = values.PayChargeMethodNumberExpirationsInstallments;
values.PayChargeMethodExpiration1 = values.PayChargeMethodExpiration1Installments;
values.PayChargeMethodDaysOrMonths = values.isInstallmentsRadioGroup;
} else {
values.PayChargeMethodNumberExpirations = values.PayChargeMethodNumberExpirationsNoInstallments;
values.PayChargeMethodExpiration1 = values.PayChargeMethodExpiration1NoInstallments;
values.PayChargeMethodDaysOrMonths = values.isNoInstallmentsRadioGroup;
}
if (!values.PayChargeMethodProportionalExpirations) {
values.PayChargeMethodProportionalExpirations = false;
}
if (!values.PayChargeMethodFitExpirationsEndMonth) {
values.PayChargeMethodFitExpirationsEndMonth = false;
}
if (!values.PayChargeMethodIsCash) {
values.PayChargeMethodIsCash = false;
}
var action = null;
if (this.mode === ConstantsContaPro.NEW) {
action = ConstantsGui.ADD;
} else if (this.mode === ConstantsContaPro.UPDATE) {
action = ConstantsGui.UPDATE;
}
var payChargeMethodModel = new PayChargeMethodModel();
payChargeMethodModel.set(values);
payChargeMethodModel.save({
Action : action,
success : this.onSuccessSave,
failure : this.onFailureSave,
scope : this
});
} else {
this.addDockedStatusBar.call(this);
this.addErrors(payChargeMethodForm, this.view.query('#form-statusbar')[0]);
this.view.query('#form-statusbar')[0].getPlugin().showErrors();
this.disableSaveButton(false);
}
},
onSuccessSave : function(model, operation) {
var controller = this.parentController || this.parentController.params.controller,
view = this.parentController.view || this.parentController.params.controller.view,
jsonResponse = Ext.decode(operation.response.responseText),
payChargeMethodId = jsonResponse.outputData.PayChargeMethod || {'PayChargeMethodId' : this.query('#newPayChargeMethodForm')[0].getForm().findField('PayChargeMethodId').getValue()},
msg = this.mode === ConstantsContaPro.UPDATE ? toLocale(ContaProMetaController.NAME,'contapro.paychargemethod.msg.ok.update') : toLocale(ContaProMetaController.NAME,'contapro.paychargemethod.msg.ok.new');
msg = msg + '<a href="javascript:(function(){var closedWindow = Ext.getCmp(\''+ this.id + '\');closedWindow.show();})();">';
config = {};
config.element = this.parentController.view.grid.getEl();
config.cls = 'msgOK';
Anfix.Popup.msg(null, msg, config);
controller.lastUpdated = operation.action.toUpperCase() === ConstantsGui.UPDATE ? operation.request.jsonData.inputBusinessData.PayChargeMethod : payChargeMethodId;
controller.lastScrollTop = (operation.action.toUpperCase() === ConstantsGui.UPDATE && !Ext.isEmpty(this.parentController.view.grid.getVerticalScroller())) ? this.parentController.view.grid.getVerticalScroller().scrollEl.dom.scrollTop : null;
controller.load({
scopeParentView: view
});
if(this.view){
this.view.destroy();
}
},
onFailureSave : function(model, operation) {
this.addDockedStatusBar.call(this);
Utils.showErrors.call(this.view, model, operation,'#newPayChargeMethodForm');
this.view.query('#form-statusbar')[0].getPlugin().showErrors();
this.disableSaveButton(false);
},
disableSaveButton: function(disabledStatus){
Utils.setButtonDisabled(this.view.query('#savePayChargeMethod')[0], disabledStatus);
},
addDockedStatusBar : function() {
var statusBar = this.view.query('#form-statusbar')[0];
if (statusBar) {
if (!Ext.isEmpty(statusBar.getPlugin())) {
statusBar.getPlugin().hideErrors();
}
statusBar.destroy();
}
statusBar = Utils.createStatusBar(this.view.query('#newPayChargeMethodForm')[0]);
var container = this.view.query('#containerStatus')[0];
container.add(statusBar);
},
addErrors : function(form, statusBar) {
var errors, validationStatus = statusBar.getPlugin();
form.getFields().each(function(field) {
errors = field.getErrors();
for ( var i = 0, leni = errors.length; i < leni; i++) {
validationStatus.errors.add(field.id, {field : field,msg : errors[i]});
statusBar.setStatus({text : validationStatus.showText,iconCls : validationStatus.errorIconCls});
}
});
}
});
/**
* Copyright (c) 2011 Anfix Software, S.L. Todos los derechos reservados.
* Documento Confidencial.
*
* @file PayChargeMethod.js
* @Author Patricia Gañán (patricia.ganan@anfix.com)
* @date August, 2012
* @brief Model for PayChargeMethods
*/
Ext.define('Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod',{
extend: 'Ext.data.Model',
idProperty : 'PayChargeMethodId',
fields: [
{name: 'Action', useNull: true},
{name: 'PayChargeMethodId'},
{name: 'PayChargeMethodCode', type: 'string', useNull: true},
{name: 'PayChargeMethodName', type: 'string', useNull: true},
{name: 'PayChargeMethodNumberExpirations', type: 'int', useNull: true},
{name: 'PayChargeMethodDaysOrMonths', type: 'int', useNull: true},
{name: 'PayChargeMethodProportionalExpirations', type: 'bool', useNull: true},
{name: 'PayChargeMethodFitExpirationsEndMonth', type: 'bool', useNull: true},
{name: 'PayChargeMethodIsCash', type: 'bool', useNull: true},
{name: 'PayChargeMethodIsInstallments', type: 'bool', useNull: true},
{name: 'PayChargeMethodExpiration1', type: 'int', useNull: true},
{name: 'PayChargeMethodExpiration2', type: 'int', useNull: true},
{name: 'PayChargeMethodExpiration3', type: 'int', useNull: true},
{name: 'PayChargeMethodExpiration4', type: 'int', useNull: true},
{name: 'PayChargeMethodExpiration5', type: 'int', useNull: true},
{name: 'PayChargeMethodExpiration6', type: 'int', useNull: true},
{name: 'PayChargeMethodExpiratedPercentage1', type: 'float', useNull: true},
{name: 'PayChargeMethodExpiratedPercentage2', type: 'float', useNull: true},
{name: 'PayChargeMethodExpiratedPercentage3', type: 'float', useNull: true},
{name: 'PayChargeMethodExpiratedPercentage4', type: 'float', useNull: true},
{name: 'PayChargeMethodExpiratedPercentage5', type: 'float', useNull: true},
{name: 'PayChargeMethodExpiratedPercentage6', type: 'float', useNull: true},
{name: 'PayChargeMethodEInvoiceCodeId'}
],
proxy: {
type: 'ajax',
api: {
read : '/os/os/paychargemethod/search',
create : '/os/os/paychargemethod/create',
update : '/os/os/paychargemethod/update',
destroy : '/os/os/paychargemethod/delete'
},
url : '/os/os/paychargemethod/search',
reader: {
type: 'json',
root: 'outputData.PayChargeMethod'
},
writer : {
root:'PayChargeMethod'
}
}
});
/**
* Copyright (c) 2011 Anfix Software, S.L. Todos los derechos reservados.
* Documento Confidencial.
*
* @file PayChargeMethods.js
* @Author Patricia Gañan (patricia.ganan@anfix.com)
* @date August, 2012
* @brief Controller for the PayChargeMethods. Controls and manages all events and some views of paychargemethods
*/
Ext.define("Anfix.contapro.controller.expirations.paychargemethods.PayChargeMethods", {
requires : [
"Anfix.contapro.view.expirations.paychargemethods.PayChargeMethods",
"Anfix.utils.Utils",
"Anfix.contapro.controller.expirations.paychargemethods.NewPayChargeMethod",
"Anfix.utils.DeleteRecordsManager"
],
alternateClassName : 'ContaProPayChargeMethodController',
extend : "Anfix.controller.AbstractController",
models : ["Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod"],
load: function() {
if(!this.view || this.view.isDestroyed) {
if(this.view) {
delete this.view;
}
var payChargeMethodsWindow = Ext.create('Anfix.contapro.view.expirations.paychargemethods.PayChargeMethods',{
controller : this,
appContaPro : this.appContaPro,
parent : this.parent,
application : this.application,
title : toLocale(ContaProMetaController.NAME, "contapro.paychargemethods.toolbar")
});
this.view = payChargeMethodsWindow;
this.lastUpdated = null;
this.lastScrollTop = null;
if(this.fromWindow){
this.parent.view.add(this.view);
}else{
this.parent.view.up("#bodyTabs").add(this.view);
}
this.callParent();
this.view.show();
this.view.center();
if(this.callbackFn && this.callerScope) {
this.view.on('destroy', this.callbackFn, this.callerScope);
}
} else {
this.view.query('#ContaPaychargemethodSearch')[0].fireEvent('timeout', this.view.query('#ContaPaychargemethodSearch')[0]);
this.view.show();
this.view.center();
}
this.view.toFront();
Utils.focusFirstToolbarItem(this.view);
},
refreshView: function() {
this.view.query('#ContaPaychargemethodSearch')[0].fireEvent('timeout', this.view.query('#ContaPaychargemethodSearch')[0]);
},
onSuccessSearch : function(model, operation){
var store = this.up('window').grid.store,
me = this.up('window').controller,
data = model['PayChargeMethod'] || {};
store.loadData(data);
if(!Ext.isEmpty(me.lastUpdated)){
Ext.Function.defer(Utils.setScrollPositionToSeeRecord, 150, this, [me.lastUpdated.PayChargeMethodId, 'PayChargeMethodId', me.lastScrollTop, me.view.grid]);
Ext.Function.defer(Utils.paintRecord, 400, this, [me.view.grid, me.lastUpdated.PayChargeMethodId]);
me.lastUpdated = undefined;
}
},
onFailureSearch : function(model, operation){
Utils.onFailure.call(this,operation,'#listPayChargeMethods');
},
handleNewPayChargeMethod: function() {
var controller = new NewPayChargeMethodContaProController ({
parentController: this,
appController : this.appContaPro,
appContaPro : this.appContaPro,
application : this.application,
mode : ConstantsContaPro.NEW
});
controller.load();
},
handleModifyPayChargeMethod: function() {
var grid = this.view.grid,
selectedRecord = grid.getSelectionModel().getLastSelected();
selectedId = selectedRecord.getId();
var jsonRequest = {
Order : ['PayChargeMethodCode'],
OrderTypes : ['ASC'],
Filters : [{'PayChargeMethodId':selectedId}],
Group : [],
CompanySelected: ContaProUtils.getCompanySelected()
};
var options = {
search : jsonRequest,
success : this.onSuccessQueryOnePayChargeMethod,
failure : this.onFailureQueryOnePayChargeMethod,
timeoutFn : Ext.emptyFn,
timeout : ConstantsGui.TIMEOUT_LARGE_OPERATIONS,
scope : this,
applicationId: ConstantsGui.APP_OS
};
var PayChargeMethodModel = this.getModel("Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod"),
payChargeMethodModel = new PayChargeMethodModel({applicationInstanceId:this.appContaPro[ConstantsGui.WINDOW_ID]});
payChargeMethodModel.search(options);
},
onSuccessQueryOnePayChargeMethod: function(model, operation) {
var recordData = model['PayChargeMethod'][0] || {};
var controller = new NewPayChargeMethodContaProController ({
parentController: this,
appController : this.appContaPro,
appContaPro : this.appContaPro,
application : this.application,
mode : ConstantsContaPro.UPDATE,
record : recordData
});
controller.load();
},
onFailureQueryOnePayChargeMethod: function(model, operation) {
Utils.onFailure.call(this,operation,'#listPayChargeMethods');
},
askDeleteConfirmation: function() {
var grid = this.view.grid;
Ext.create('Anfix.gui.AnfixMessageBox', {
title : toLocale(ContaProMetaController.NAME, "contapro.util.confirmdeletetitle"),
text : ContaProUtils.createDeleteMessage(grid,"contapro.paychargemethod",true),
buttonCfg : [{
text : toLocale(ConstantsCore.NAME, "anfix.util.delete"),
ui : 'default-submit-warning',
handler : this.handleDeletePayChargeMethod,
scope : this
}],
iconBody : Ext.MessageBox.QUESTION,
appWindow : this
});
},
handleDeletePayChargeMethod: function() {
var grid = this.view.grid,
records = grid.getSelectionModel().getSelection();
var PayChargeMethodModel = this.getModel("Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod"),
payChargeMethodModel,
options = {
success : this.onSuccessDelete,
failure : this.onFailureDelete,
scope : this
};
this.deleteRecordsManager = new DeleteRecordsManager({
numberOfRecordsToDelete : records.length,
defaultMsgError : toLocale(ContaProMetaController.NAME,'contapro.paychargemethod.msg.error.deletePayChargeMethod')
});
Ext.Array.each(records, function(store, i) {
payChargeMethodModel = new PayChargeMethodModel({
Action: ConstantsGui.DELETE,
PayChargeMethodId: store.get('PayChargeMethodId'),
applicationId: ConstantsGui.APP_OS,
CompanySelected: ContaProUtils.getCompanySelected()});
payChargeMethodModel.destroy(options);
},this);
},
onSuccessDelete : function(model, operation){
Log.action('Delete PayChargeMethod');
var deletedRecord = null,
grid = this.view.grid;
if(!Ext.isEmpty(operation)){
deletedRecord = grid.store.getById(operation.records[0].get('PayChargeMethodId'));
}
if (!Ext.isEmpty(deletedRecord)) {
grid.store.remove(deletedRecord);
}
this.deleteRecordsManager.onSuccess();
if(this.deleteRecordsManager.hasFinished()){
this.showMsg();
}
},
onFailureDelete : function(model, operation){
this.deleteRecordsManager.onFailure(operation);
if(this.deleteRecordsManager.hasFinished()){
this.showMsg();
}
},
showMsg : function (){
var config = {};
config.element = this.view.grid.getEl();
if(!this.deleteRecordsManager.hasErrors()){
config.cls = 'msgOK';
Anfix.Popup.msg(null, toLocale(ContaProMetaController.NAME,'contapro.paychargemethod.msg.deletePayChargeMethod'), config);
}else{
config.cls = 'msgKO';
var msgError = this.deleteRecordsManager.getMsgError();
Anfix.Popup.msg(null, msgError, config);
}
delete this.deleteRecordsManager;
},
selectRow :function(sm, record, index){
Log.action('select & deselect Payment method');
var modifyPayChargeMethodButton = this.query('#ContaPaychargemethodUpdate')[0],
deletePayChargeMethodButton = this.query('#ContaPaychargemethodDelete')[0];
if (sm.getSelection().length>1){
Utils.setButtonDisabled(modifyPayChargeMethodButton, true);
Utils.setButtonDisabled(deletePayChargeMethodButton, false);
}else if (sm.getSelection().length===1){
Utils.setButtonDisabled(modifyPayChargeMethodButton, false);
Utils.setButtonDisabled(deletePayChargeMethodButton, false);
}else{
Utils.setButtonDisabled(modifyPayChargeMethodButton, true);
Utils.setButtonDisabled(deletePayChargeMethodButton, true);
}
}
});
/**
* Copyright (c) 2011 Anfix Software, S.L. Todos los derechos reservados.
* Documento Confidencial.
*
* @file PayChargeMethods.js
* @Author Patricia Gañan (patricia.ganan@anfix.com)
* @date August, 2012
* @brief View for PayChargeMethods
*/
Ext.require([
'Ext.window.Window',
'Anfix.gui.SearchButtonGroup',
'Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod'
]);
Ext.define('Anfix.contapro.view.expirations.paychargemethods.PayChargeMethods',{
extend : "Ext.window.Window",
layout : 'fit',
resize : false,
height : 400,
width : 800,
alternateClassName : 'ContaProPayChargeMethodsView',
initComponent: function() {
this.callParent(arguments);
var dockedItems = [
this.createToolbar(),
{
xtype : 'toolbar',
itemId : 'footPayChargeMethod',
dock : 'bottom',
ui : 'footer',
items : [
'->',
{
text : toLocale(ConstantsCore.NAME, "anfix.button.close"),
width : 100,
handler : this.close,
scope : this,ui: 'close-footer',
scale : 'medium'
}
]
}
];
this.addDocked(dockedItems);
this.add(this.createGrid());
this.addListener('beforedestroy', this.onBeforeDestroy, this);
},
createToolbar: function() {
var optionsToolbar = {
items: [
{text: toLocale(ContaProMetaController.NAME, 'contapro.util.new'), itemId: 'ContaPaychargemethodCreate', iconCls:'new16', handler:this.controller.handleNewPayChargeMethod, scope: this.controller, application: this.appContaPro},
{text: toLocale(ContaProMetaController.NAME, 'contapro.util.edit'), itemId: 'ContaPaychargemethodUpdate', disabled:true,iconCls: 'edit16', iconAlign: 'left', handler:this.controller.handleModifyPayChargeMethod, scope: this.controller, application: this.appContaPro},
{text: toLocale(ContaProMetaController.NAME, 'contapro.util.delete'), itemId: 'ContaPaychargemethodDelete',disabled:true, iconCls: 'delete16',iconAlign: 'left', handler: this.controller.askDeleteConfirmation, scope: this.controller, application: this.appContaPro},
"-",
"->",
this.createSearchButtongroup()
]
};
var windowToolbar = Ext.create('Ext.toolbar.Toolbar', optionsToolbar);
return windowToolbar;
},
createSearchButtongroup : function(){
var me = this, optionsSearch = {};
optionsSearch.modelName = me.controller.getModel("Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod").modelName;
optionsSearch.jsonRequest = {
Order:['PayChargeMethodCode'],
OrderTypes:['ASC'],
Fields: ['PayChargeMethodId','PayChargeMethodCode','PayChargeMethodName','PayChargeMethodNumberExpirations','PayChargeMethodDaysOrMonths','PayChargeMethodProportionalExpirations','PayChargeMethodFitExpirationsEndMonth','PayChargeMethodIsCash'],
Group : [],
CompanySelected: ContaProUtils.getCompanySelected()
};
optionsSearch.nameButtonGroup = toLocale(ContaProMetaController.NAME, 'contapro.util.queries');
optionsSearch.itemIdLiveSearch = 'ContaPaychargemethodSearch';
optionsSearch.isFilterButton = false;
optionsSearch.isFilterPanel = false;
optionsSearch.success = me.controller.onSuccessSearch;
optionsSearch.failure = me.controller.onFailureSearch;
optionsSearch.applicationId = ConstantsGui.APP_OS;
// optionsSearch.applicationInstanceId = me.appContaPro[ConstantsGui.WINDOW_ID];
return Ext.create('Anfix.gui.SearchButtonGroup',{options:optionsSearch,margin:'2 0'});
},
createGrid: function(){
var payChargeMethodSelectionModel = new Ext.selection.CheckboxModel({
mode : 'MULTI',
listeners : {
selectionchange : this.controller.selectRow,
scope : this
}
});
this.grid = new Ext.grid.GridPanel({
store :Ext.create('Ext.data.Store', {
model: 'Anfix.contapro.model.expirations.paychargemethods.PayChargeMethod'
}),
defaultSortField : 'PayChargeMethodCode',
defaultSortDir : 'ASC',
listeners : {
afterrender : Utils.markDefaultSort,
scope : this.controller
},
itemId : 'listPayChargeMethods',
selModel : payChargeMethodSelectionModel,
stripRows : false,
columns : [
{text: toLocale(ContaProMetaController.NAME, "contapro.util.code"), width: 100, dataIndex: 'PayChargeMethodCode', sortable: true},
{text: toLocale(ContaProMetaController.NAME, "contapro.util.name"), flex: 2, dataIndex: 'PayChargeMethodName', sortable: true},
{text: toLocale(ContaProMetaController.NAME, "contapro.paychargemethods.expirations"),flex: 1.3, dataIndex: 'PayChargeMethodNumberExpirations', sortable: true, align: 'right'},
{text: toLocale(ContaProMetaController.NAME, "contapro.paychargemethods.daysormonths"), flex: 1.2, dataIndex: 'PayChargeMethodDaysOrMonths', renderer: this.renderDaysOrMonths, sortable: true},
{text: toLocale(ContaProMetaController.NAME, "contapro.paychargemethods.proportionalexpirationsUpper"),flex: 1.6, dataIndex: 'PayChargeMethodProportionalExpirations', align: 'center', renderer: this.renderBoolean, sortable: true},
{text: toLocale(ContaProMetaController.NAME, "contapro.paychargemethods.fitExpirations"), flex: 2, dataIndex: 'PayChargeMethodFitExpirationsEndMonth', align: 'center', renderer: this.renderBoolean, sortable: true},
{text: toLocale(ContaProMetaController.NAME, "contapro.paychargemethods.iscash"), flex: 1, dataIndex: 'PayChargeMethodIsCash', align: 'center', renderer: this.renderBoolean, sortable: true},
{xtype:'optioncolumn', width:ConstantsContaPro.WIDTH_OPTION_COLUMN,sm: payChargeMethodSelectionModel, items: [{itemId: 'payChargeMethod'}], callbacks:[this.controller.handleModifyPayChargeMethod, this.controller.askDeleteConfirmation], scope: this.controller,menuItemId:['ContaPaychargemethodUpdate', 'ContaPaychargemethodDelete'], optionItemsDisabledMultiSelecction: [0], application:this.appContaPro}
]
});
this.grid.getView().addListener('itemdblclick',this.controller.handleModifyPayChargeMethod, this.controller);
return this.grid;
},
renderBoolean: function(value, metaData, record, rowIndex, colIndex, store) {
value = value || false;
if(value){
return toLocale(ContaProMetaController.NAME, "contapro.util.yes");
}else {
return toLocale(ContaProMetaController.NAME, "contapro.util.no");
}
},
renderDaysOrMonths: function(value, metaData, record, rowIndex, colIndex, store) {
if(value == ConstantsContaPro.DAYS) {
return toLocale(ContaProMetaController.NAME, 'contapro.paychargemethods.days');
} else if(value == ConstantsContaPro.MONTHS) {
return toLocale(ContaProMetaController.NAME, 'contapro.paychargemethods.months');
} else {
return "";
}
},
getAppWidth: function() {
return this.appContaPro.view.getWidth();
},
getAppHeight: function() {
return this.appContaPro.view.getHeight();
},
fitWindow: function() {
this.width = this.width*0.95;
this.height = this.height*0.80;
this.x = this.appContaPro.view.x + parseInt(((this.getAppWidth()-this.width)/2));
this.y = this.appContaPro.view.y + parseInt(((this.getAppHeight()-this.height)/2));
},
onBeforeDestroy : function() {
var me = this,
main = me.parent.up? me.parent.up('window'): me.parent.view.up('window');
if(main){
main.remove(me);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment