Search in others sample DB like R2U or OPM
SELECT * FROM public."_ContextMenu"
where "Status"='A'
ORDER BY "Id" ASC;
There are 4 or 5 samples. “Generate calendar entries”:
var total = records.length;
var counter = 0, created = 0;
function OnCalenderaCreated(success) {
counter++;
if (success) {
created++;
}
if (counter === total) {
records.length === 1 ? CMDBuildUI.util.Notifier.showSuccessMessage("Operation performed on " + created + " element") :
CMDBuildUI.util.Notifier.showSuccessMessage("Operazione performed on " + created + " elements");
api.refreshGrid();
popup.close();
}
}
var popup = CMDBuildUI.util.Utilities.openPopup(
null,
"Generate calendar entries",
{
xtype: 'form',
bodyPadding: CMDBuildUI.util.helper.FormHelper.properties.padding,
fieldDefaults: CMDBuildUI.util.helper.FormHelper.fieldDefaults,
viewModel: {
data: {
fromDate: new Date(),
toDate: null
}
},
items: [{
xtype: 'datefield',
fieldLabel: 'From:',
allowBlank: false,
format: 'd/m/Y',
bind: {
value: '{fromDate}'
}
}, {
xtype: 'datefield',
fieldLabel: 'To:',
allowBlank: false,
format: 'd/m/Y',
bind: {
value: '{toDate}'
}
}],
buttons: [{
text: 'Ok',
ui: 'management-action',
formBind: true,
handler: function (btn, eOpts) {
records.forEach(function (elem) {
Ext.Ajax.request({
url: CMDBuildUI.util.Config.baseUrl + CMDBuildUI.util.api.Functions.getFunctionOutputsByNameUrl('ctx_maintcal_gen'),
method: "GET",
params: {
parameters: Ext.JSON.encode({
prevmaintconfig_id: elem.data._id,
start_period: btn.up("form").getViewModel().get("fromDate"),
stop_period: btn.up("form").getViewModel().get("toDate"),
update_policy: null
})
},
callback: function (fopitons, fsuccess, fresponse) {
if (fresponse.status < 400) { // has no errors
var fresponseJson = Ext.JSON.decode(fresponse.responseText, true);
if (fresponseJson['data'][0]['success']) {
OnCalenderaCreated(true);
} else {
OnCalenderaCreated(false);
}
} else {
OnCalenderaCreated(false);
}
}
});
})
}
}, {
text: 'Annulla',
ui: 'secondary-action',
handler: function () {
popup.close();
}
}]
}, null, {
width: 300,
height: 210
}
);