Rails 3 Full Calendar- unable to update events - ruby-on-rails-3

Relatively new to Jquery and Rails 3. I have implemented full calendar into my site and all works ok apart from actually updating my Events model via the full calendar interface. From what iunderstand I should be able to drag and drop a calendar entry to another day and it will update the Events model and leave the appointment in its new day upon a refresh. This however does not happen. has anyone had similar issues with this? the code for this action looks like this
function updateEvent(the_event) {
$.update(
"/events/" + the_event.id,
{ event: { title: the_event.title,
starts_at: "" + the_event.start,
ends_at: "" + the_event.end,
description: the_event.description
}
},
function (reponse) { alert('successfully updated task.'); }
);
};
Am I missing something obvious?

I had a problem with editing events in the fullCalendar plugin. In my case it had to do with the parameters editable and disableResizing. You have to implement the eventDrop handler for the drag and drop functionality. The parameters dayDelta, minuteDelta, allDay contain the time difference between old and new date:
$('#calendar').fullCalendar({
...
editable: true,
eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {
$.ajax({
type:"PUT",
url: "/events/"+event.id,
data: "minute_delta="+minuteDelta+"&day_delta="+dayDelta,
..
});
}
});

Related

How to catch opened event on a ComboBox with Dojo?

I want to know whether a combo box has been opened and call a function that displays an progress bar while it loads the data from a store. I've check the API but no I didn't find any suitable event for what I'm doing.
EDIT
What I want to do is start a progress bar while the combobox is populated from the store. I've created a widget with the combobox and the progress bar (a custom class) and "decorate" openDropDown function with aspect.before. This is the code I've written:
postCreate: function() {
this.inherited(arguments);
aspect.before(
this.comboBox, 'openDropDown',
lang.hitch(this, function(){
this.progressBar.increase();
})
);
on(
this.comboBox,
'search',
lang.hitch(this.progressBar, 'decrease')
);
}
But it seems is not using the right progressBar object.
It sounds like you are looking for something like an "onOpen" event. as of Dojo 1.10 The Dijit/Combobox widget does not support an event like the one you are describing, however it does support a number of other events that might meet your requirements.
I recommend looking into the api for a list of possible events: http://dojotoolkit.org/api/
However the following code will create a custom "onOpen" event like what you are describing. I've provided a jsfiddle which demos this new event
http://jsfiddle.net/kagant15/z4nvzy44/
var comboBox = new ComboBox({
id: "stateSelect",
name: "state",
value: "California",
store: stateStore,
searchAttr: "name"
}, "stateSelect")
// grab the existing openDropDown method
var openDropDownFunction = comboBox.openDropDown;
newFunction = function(){
topic.publish("openDropDown") // add the custom "openDropDown" event trigger
return openDropDownFunction.apply(this);
}
// replace the old comBox method will our new function
comboBox.openDropDown = newFunction;
// Subscribe to the custom openDropDown event and do something when it fires
topic.subscribe("openDropDown", function(){
console.log("Open Drop Down even trigger");
});

Sencha touch 2.0 Calendar Plugin Run Issues in production, package and device

I have implemented this calendar in my app developed in sencha touch 2.0 and I face a problem.When I run my application source code in a web browser, Calendar works fine. But when I generate the production & package of the app the calendar not work and following issues occur.Moreover these issues also occur when app run in a device:
1): Cell not select in the month view of calendar.
2): Next and Previous not work in the month, week and day view of calendar.
3): This seems to me that on tap events cannot get bind
Example :
this.element.on({
tap: this.onTableHeaderTap,
scope: this,
delegate: 'td'
});
this.element.on({
tap: this.onTimeSlotTap,
scope: this,
delegate: this.getItemSelector()
});
Please help me to get rid of this hurdle.
I shall be very thank full to you.
Create your class obj like this and add this in your child class constructor:
companyCalender = Ext.create('myapp.view.TouchCalendarView',{
viewConfig : {
mode : 'month',
weekStart : 0,
value : new Date()
}
});
Ext.apply(this.initialConfig, config);
Ext.apply(this, config);
myapp.view.CompanyCalender.superclass.constructor.apply(this, arguments);
this.add(companyCalender);

client web - how to get current record id at any time

I'm trying to work on the "different permissions based on workflow state" issue but I'm struggling with the fact that it seems impossible to get the id of the current object 'at any time' that is necessary in order to get the permission of that object. What I mean is that I manage to get it from the client state following jquery bbq docs like:
$.bbq.getState().id
BUT it looks like this is doable only AFTER a complete page load. I investigated this by placing some alert in the main view events, like:
openerp.web.PageView = openerp.web.PageView.extend({
on_loaded: function(data) {
this._super(data);
alert('page load ' + $.bbq.getState().id);
},
do_show: function() {
this._super();
alert('page show ' + $.bbq.getState().id);
},
reload: function() {
this._super();
alert('page reload ' + $.bbq.getState().id);
},
on_record_loaded: function(record) {
this._super(record);
alert('record loaded ' + $.bbq.getState().id);
}
});
and I found that when you open the page view (by clicking on an item in a search view, for instance) you get always "undefined".
Then, you get it into "reload" and "on_record_loaded" when passing from an object to another using paged navigation. And then, you miss it again when you click on the "edit" button.
In the form view I successfully got it only on the 1st load because it seems that some caching is in-place. So that, if I place a pdb into web client's fields_view_get and I do this into the form "init_view":
var ids = [];
if ($.bbq.getState().id){
ids = [parseInt($.bbq.getState().id)];
}
console.log(ids);
return this.rpc("/web/view/load", {
"model": this.model,
"view_id": this.view_id,
"view_type": "form",
toolbar: this.options.sidebar,
context: context,
ids: ids,
}, this.on_loaded);
I get it only the 1st time that the page gets loaded. The same happen if I take ids from
this.dataset.ids
I looked anywhere at the core web module and I can't find a proper API for this and it looks weird (above all on dataset) that we don't have a proper way for getting/working on the current record/s. Even the context and the session do not have any information about that.
Probably I should store this into the view itself on 1st load...
Thanks in advance for any pointers.
try:
this.view.datarecord.id
OpenERP 7 in form view:
debugged using google chrome
Try the combination of the
this.dataset.ids and this.dataset.index
like
curr_id = this.dataset.ids[this.dataset.index]
this might solve your problem.

Open graph stories of action I do show up on my ticker but not on my friends' ticker

I created a canvas app and defined action, object and aggregation. When I publish an action using javascript sdk by doing -
FB.api('/me/namespace:action?object=object_url', 'post',
function (response) {
if (!response || response.error) {
//failure
} else {
//success
}
});
I get success and it shows up on my ticker and timeline but my friend is not able to see anything related to this activity neither on his ticker nor in the news feed. The visibility of activity in this app is set to friends but still nothing shows up in firends' accounts.
It was because I had delete 4 aggregations created automatically and created a single aggregation that I thought would only be required. I deleted this action and aggregation, created a new one from scratch and updated aggregations with action/object and it worked.

view is undefine, loading combo box issue in 4.07

I am occassionally ( usually 1 in 3 page loads) receive the following error message
view is undefined
view.onItemSelect(record);
In my view
{
xtype:'combobox',
name:'PurchaseOrderStatusId',
id:'PurchaseOrderStatusCombo',
displayField:'Name',
store:'PurchaseOrderStatuses',
mode:'local',
valueField:'Id',
fieldLabel:'Status',
width: 350
},
{
xtype:'combobox',
name:'SupplierId',
id:'SupplierCombo',
displayField:'Name',
store:'Suppliers',
mode:'local',
valueField:'Id',
fieldLabel:'Suppliers',
width: 350
},
// in my controller
onLaunch: function () {
var suppliers = this.getSuppliersStore();
suppliers.load();
var purchaseOrderStatuses = this.getPurchaseOrderStatusesStore();
purchaseOrderStatuses.load();
var purchaseOrdersStore = this.getPurchaseOrdersStore();
purchaseOrdersStore.load({
callback: this.onPurchaseOrderLoad,
scope: this
});
},
onPurchaseOrderLoad: function (selection) {
var form = Ext.getCmp('purchaseOrderForm');
form.loadRecord(selection[0]);
},
in my model
{
mapping:'PurchaseOrderStatusId',
name:'PurchaseOrderStatusId'
},
{
mapping:'SupplierId',
name:'SupplierId'
}
It's not clear how the error message you are reporting is linked to any of the code you have revealed so far. So it's difficult to connect the dots here.
However here are a couple of observations:
1. If you need your stores to always load ASAP when your app launches set the autoLoad:true config on those stores. This way you don't have to explicitly load them and they have more time to finish loading before your view is ready to go.
2. If you need to load an instance of your model into the form you can use Model.load method instead of having a store do that for you. You will need to provide API on the model on how to read the records from the server.
3. Model mapping is not necessary if your Model fields match to what the server returns.
If you need further help, please update your question with some more debug info.