create popup for events overlap vtiger calendar - calendar

How can I add the control to the configuration screen of a calendar event?
overlapping of events or if the same user "assigned to" already has an event in calendar (even partial) between "Start date and time" and "End date and time" of the new one event by clicking the "Save" button a warning popup must appear with the message "It is already present a calendar event at this juncture, we want to proceed?"
The selection YES will create the calendar event, the NO choice will return to edit mode on the event.

One strategy would be to create an ajax action in the events module that receives start and end date & time and checks whether the current user has an overlapping event.
Then you create a JS script that listens to the onclick event of the Save. When clicking on the button you then call the ajax action and process the response.
That's the general idea. Take a look at other ajax actions in Vtiger to have an example.

Related

Detect press of "cancel" on a Codename One lightweight date picker

On a Codename One lightweight date pickers, the user has four buttons in the top, like in the following screenshot.
I suppose the tapping of the second, third and fourth buttons are detected by the .addActionListener() (please correct me if I'm wrong)... but I need to detected also the tapping of the "Cancel" button. How can I run some code when the user taps "Cancel"?
We don't provide a way to detect cancel since we can't consistently detect it on native. As a workaround you can listen to the click on the picker button and unless you get a selection it would mean that the action was canceled.
Alternatively we can add a feature like this for the lightweight picker only. If you need that you can file an RFE on that.
I overcame this by comparing the newly selected picker value to the previously stored value. If it’s the same, I consider it a cancel.

How to allow/stop an event based on a condition like YES or NO?

I need to allow or stop an event from happening, based on a given condition such as a pop up box with options YES, NO and CANCEL.
I need to notify the user saying that there are unsaved data and if the user wishes to SAVE it, IGNORE it or CANCEL his current action(event such as Selection-change or Click).
I tried to use createInterceptor() function. But could not achieve the functionality.
Can anybody give me some suggestions with example? Basically I want to know how to stop an event.
Thanks..
Edited
I like the idea of using beforeXXX events. But I am still facing problems. As I mentioned, I need to ask the user if he wishes to save the unsaved data, which is a popup message box (With options YES, NO and CANCEL) that runs asynchronously. So by the time I get a reply, the event will have happened.
For ex. lets imagine a situation where, there is a page that displays a list of records in a grid with a pagination toolbar attached to it on the bottom(with a page size of 10 and total number pages is 10. So totally 100 records) on the left hand side. If you select a record in the list, the details are shown in a detail view on the right hand side.
Now,
I select third record in the list and make some changes to it in the detail view(form).
Without saving the record, I click on next page button on the Pagination toolbar.
It will show a confirm box from the beforeXXX event of Pagination toolbar, but the event will have happened anyway.
Here if the user clicks on CANCEL, I will have to restore the previous state which is already gone. Somehow I will have to go back and select the third record in the list of previous page.
So in order to resolve this problem, if I return false from my beforeXXX event, the next XXX event will be not be triggered.
But if the user clicks on YES or NO options I will have to trigger the event XXX manually which I am unable to do it for a selection-change event as of now.
Like this there can be many operations like list-filtering, searching, Ordering(A-Z/ Z-A), logout etc. For each of this operation I will have to write customised code which totally spoils the readability of the code.
So I was thinking if there is way to, somehow manually trigger the event XXX by holding the event object in beforeXXX...or is there any other way to restore the previous state.
Please give me suggestions....Thanks...
Many events have their "before-" counterpart, for example "beforeactivate". If you return false from this kind of the processing stops.
If not, or if your event does not have it's before- part, then you can use event object passed to all event handlers and call:
ev.stopEvent();
ev.stopPropagation();
return false;
at the end of your handler.

need way to close datebook when shown inline

I am using the stable version jQM DateBox with JQM 1.4.5 and jQuery 2.
I have a popup form that has a datebook widget on it. I use inline blind because the initial value is set for the date. But the user can click into the field, the datebook opens up the calendar and the user can pick a new date.
However, if the user opens up the datebook calendar, there's no way to close it without them picking a date. It would be nice if either clicking on the date field again closes the calendar (like a toggle) or there's an explicit close button that is shown when the calendar is shown.
Thanks.

DateTimePicker ValueChanged event fires the first time when there is no change

Winforms 2.0. Stick a DateTimePicker on a form. It defaults to TODAY. Click on the dropdown arrow to show the Calendar, and click on TODAY. The ValueChanged event DOES FIRE, even though it is already set to today.
What i would like to do is replicate this same functionality - I would like to reset it (in code) to today, and next time i click on today via the Calendar i want that ValueChanged event to fire (just like it did the first time).
If the above is not possible, i want some event that always fires whenever i pick a date on the Calendar (regardless if there is a change or no change).
Sounds really simple, surely someone has the answer?
What you're seeing there is a side-effect of the fact that DateTimePicker stores the time component of its value as well as the date.
So when your form first initializes, the DateTimePicker is being initialized with DateTime.Now. When you then select "Today" from its drop-down calendar, you're changing the value to DateTime.Today.
If you don't care about the time component and/or you're always reading the value as dateTimePicker1.Value.Date, then you could initialize the control in code with DateTime.Now and the ValueChanged event will fire when the user selects Today from the calendar. Otherwise you might consider catching the CloseUp event, which is fired whenever the calendar control is closed (regardless of whether the value changed).
Im not a win form programmer, but see if there is a Day_Render event.
That should fire for each day...at least there is one for web based development, but I would think it is the same. So look for Render() event.

Silverlight click event registered a second time before first event completed

I have a button which launches a "modal dialog" - it just creates a transparent grid covering everything, with the "dialog" created on top of that.
However I have a strange issue - if I double/triple click the button really fast (or add some delay in the event code), the button click event is executed multiple times, creating multiple overlapping modal dialogs. If the first action in my event is to disable the button (IsEnabled=false) it seems to prevent this.
My guess is that Silverlight is being multithreaded with input - it is not only recording the second click in another thread (while the button's click event is running), but it is jumping the gun by evaluating which control should be the target before the previous event has finished executing. Even though that event alters what control is at those mouse coordinates, it doesn't matter.
Does anyone know anything about this behavoir, or a way around it? If I have something like a save window, where the user clicks a save button, a blocking grid ("Saving...") is placed up while it saves, and then the whole "window" is closed, I'd like to avoid the user being able to queue up multiple save event clicks (this could lead to unpredictable program behavoir).
If you've ever worked with WinForms or WPF, this is expected behavior. Your button is broadcasting its Click event until your modal dialog covers it up. Unfortunately, there is some amount of time between your first click and when the modal dialog covers the button which allows multiple clicks to the original button.
You have two solution choices:
Disable the button after the first click and then re-enable after the modal dialog returns. You've already mentioned that this works.
Write code in the Event Handler of the button to determine if a modal dialog is already being displayed. This way, you're putting the responsibility in one location rather than splitting it up (disabling and re-enabling the button). This would be my preferred solution.
I think what you're seeing is the behaviour of Silverlight's routed events.
You can set the Handled property of the event arguments to true to prevent the event from bubbling.

Resources