I am banging my head looking at the code for ... quite some time.
I have a lightning event, created from ics (including an alarm).
I want to delete the alarm after something has occurred. I found calItemBase has mAlarms. But how to delete a single alarm? (there should be only one). What is the proper value of mAlarms if there is no alarm?
What to do with mAlarmLastAck and other properties?
My workaround is to recreate from ical without the alarm, but then the user looses categories and other things he set for the event in the UI.
Many thanks,
Klaus
A summary of the methods intended to be public for an item can be seen here: http://mxr.mozilla.org/comm-central/source/calendar/base/public/calIItemBase.idl
Specifically, there is a deleteAlarm method. Example:
var alarms = item.getAlarms({});
item.deleteAlarm(alarms[0]);
If you are sure you want to delete all alarms, you can also use the clearAlarms method.
item.clearAlarms();
Related
So I know I can put search_auto_update = False on the Model in question, however I dont want to turn off indexing entirely.
https://docs.wagtail.org/en/v2.13.5/topics/search/indexing.html#disabling-auto-update-signal-handlers-for-a-model
I have a command which bulk syncs data from an API. Currently, on every Save, it's also triggering and index; this is inefficient and slow. It would make a lot more sense to disable indexing during the sync and then bulk-index the items at the end.
Is this possible? I tried setting search_auto_update as an key/value on the model before save, but it didn't seem to do anything (it looks like it needs to be an attribute on the class, rather than a model instance value).
The search indexing on save is done via signals, so I think this SO answer for how to temporarily disable signals should work. In short, use FactoryBoy's mute_signals decorator
So, we all know that you can add events post-render by calling Template.templateName.events() and passing in new events. My question is: How do I remove them? I've found that I'm adding them how I like, but I end up with several of the same event, that all fire, and it's causing all sorts of problems. Is there a specific place that meteor stores the actual events? Where I could clear them out?
Template events should not be called several times but used once for static event definitions for this template that every instance of the template will listen to.
The documentation is not very helpful here. However, if you need dynamic template events you are still in good hands using the classic addEventListener or jQuery on and use bind to bind them to the template instance.
Don't forget to remove them when required but at least in Template#onDestroyed
I found that Template.templateName.__eventMaps = [] did the trick. I run this before creating a new instance of my template, and therefore only get one set of event handlers. woo!
I have faced an issue while using .set(#{value}) to fill the text field in registering form, e.g: the phone number i wanna put in is 506307 then it ended up with 063075.
The work-around i have been made is executing Javascript block like
execute_script("document.querySelector('#{selector}').value = '#{value}'")
However, using the same scripts applying for Webmobile based on React.JS, the scripts above just send the text but didn't send the onChange event, which cause another element cannot be selected/clicked -> made the test failed.
I came up with another approach is to use the send_keys #{value} to trigger the key-pressed event that would make browser think there was a key-pressed event happen for that form, but it ended up with race-condition like set(#{value}) as i mentioned.
The another work-around is using What is the best way to trigger onchange event in react js , but i tend to use the native Capybara actions before making that tricky Javascript.
So, is there any other way to interact / fill the form field which won't cause that Race condition issue ?
Thanks everybody in advance.
Note: Any "solution" suggested that is purely the use of execute_script to run some JS is a terrible idea since it completely bypasses the concept of testing what a user can do and can basically make your test worthless.
The root cause of the issue here is the JS behavior attached to the input not being able to handle the key events fast enough. The proper fix would be to fix the JS, however if that's not possible there's a few things you can try
First you can try changing the clear method being used by set
element.set('506307', clear: :backspace)
or
element.set('506307', clear: :none)
If that doesn't change anything then try clicking on the input, followed by a short sleep before setting the content
element.click
sleep 0.25
element.set('506307')
If none of those work around the issue we need to know exactly what JS behavior you have attached to the input and/or what events that JS behavior is listening to.
I am using paper_trail for audit trail. Along with create, update and delete events I want to track few custom events like view(record), sent(email) etc. How can we introduce such custom events while auditing a model?
I have found a tweak to add custom events in paper_trail managed Versions:
Version.create(item_type: "Campaign", item_id: campaign.id, event: "Sent")
Maybe this is not right solution, but it helped me to achieve the goal. I would like to explore paper_trail more to find a better solution.
Following the paper trail flow, and having paper trail hooked to your touch events:
record.paper_trail_event = 'notified'
record.touch
If you don't want to have that hook in place you can:
record.versions.create!(event: 'notified')
The main problem with the second approach is that it won't apply any of the PaperTrail scoped params, nor any other dynamic field you may have defined for that model PaperTrail config.
You will need to set those manually. For the request.whodunnit it would be like:
record.versions.create!(event: 'notified', whodunnit: current_user.id)
See simple hit counter for page views in rails as an answer to the first part of your question. As for tracking sent mails, you may want to use Observer pattern.
In any case all these events are outside of paper_trail domain. While paper_trail simply creates versions of your model during data changing, what you need is to observe custom event and write to DB all necessary information about that event.
I know this question may seem weird but I'd like to get a list of currently dispatched events.
The thing is that I am a lazy man and I would like to check if the 'checkout_cart_add_product_complete' has been fired without creating an observer for it.
So the idea is to get an array of all dispatched events and do an in_array on it :)
I thought that Mage::getEvents()->getAllEvents() would throw some info but it just returns an empty array.
I also digged a bit in lib/Varien/Event files and folders but didn't manage to be successful at creating an observer programmatically. Yep, I know, why being simple while one can be complicated ? :)
So this main question (getting a list of dispatched events) hides another (for the pure knowledge) wich would be "how to create an observer programmatically".
What do you think?
Thanks a lot!
Take a look at dispatchEvent and you'll see that events are only loaded from the assorted config.xml files, via SimpleXML. I cannot see any way to intercept this except to override Mage_Core_Model_App.
Of course there cannot be an event-dispatched-event, that would create an infinite loop, so there is no way to observe all events.
If you need to see events for development my advice would be to set a breakpoint in dispatchEvent with your debugger, that way you get to see not only the event names but also the objects passed as parameters too. I've tried other ways before but this was most convenient for me.
I need to do the same and I think it's possible to trick magento by the function getEventConfig in Mage_Core_Model_Config. You could force him to add automatically a default observer.