How do I add a DatePicker to a custom field - trac

I have TRAC 1.0.1 running.
For my tickets I would like to have a DueDate. Entering the DueDate should be done by using a DatePicker. Because it is convenient, and you can not enter wrong values.
I added following plugin to TRAC: http://trac-hacks.org/wiki/DateFieldPlugin
The description says, that it provides validation for custom fields and a DatePicker for Milestone and Ticket fields.
My trac.ini configuration file looks like this:
[ticket-custom]
duedate1 = text
duedate1.date = true
duedate1.date_empty = true
duedate1.label = Due Date
duedate1.order = 4
duedate1.value = DD-MM-YYYY
[datefield]
first_day = 1
format = dmy
separator = -
TRAC is now checking the input against the format. But what I really want is a DatePicker that pops up and lets me choose the date.
Any help is appreciated.

If the input is being validated but there is no datepicker it sounds like a client side JS / browser problem.
I just created a new Trac env, added the DateFieldPlugin, copied your [ticket-custom]
and [datefield] ini configuration and it seemed to work out of the box just fine. For example on /newticket I can see a datepicker for the Due Date field (using Firefox at least). Given that, all I can really do is give some more details which might help us debug your problem.
The datepicker is added via JavaScript. If you are running Trac 1.0 then you don't need to worry about jQuery or jQuery UI as Trac core now ships with these dependencies. You can see that by looking at the scripts tab in Firebug etc. when you are running tracd. Are you serving your own jQuery or jQuery UI scripts which might be conflicting? Are there any errors shown on the Firebug console tab?
The plugin serves extra JS files when you request certain pages in Trac, including /newticket and /ticket. You should also be able to see these scripts being served in Firebug etc. Is that true for you?
If you inspect the HTML in the ticket.html template displayed on /newticket you should also see something like this for the Due Date input
<input type="text" class="datepick hasDatepicker" value="MM-DD-YYYY" name="field_due_date1" id="field-due_date1">
Note the two datepick and hasDatePicker classes are what tell JS to to render a jQuery Datepicker dialog. Does your custom field have these classes? The plugin should be adding them for you (inside the post_process_request())
If all that is the same for you then maybe it is a browser problem?

While the plugin way was ok, when there was no other way, now it is only second best, because of all the limitations of storing date/time as formatted string instead of POSIX (micro)seconds, just like for other native Trac time fields.
There is a better way: Custom date/time field support has entered Trac core since 1.1.1 ("unstable" development branch moving towards next stable 1.2).
At least if you foresee heavy use and/or long term Trac deployment, you'll appreciate adding true timestamps to your db right from the start. It provides you with the best possible experience like date picker UI, full time zone and TracQuery support, even future time constraints ('nextday', 'nextweek', etc.) are possible right now.
A last note regarding Trac code stability: For what its worth I'm using true custom time fields support via patches in production since 2009 (Trac 0.13dev), runs smoothly in applications with 30.000+ tickets by now.

Related

Automate a button click on chrome://extensions page using selenium webdriver

I'm trying to write an automated test that will automate the process of updating a google chrome extension. I'm not aware of another method of doing this automatically so here is what I'm currently trying to do:
Open the chrome extensions page (as far as I'm aware this is just an html page unless I'm missing something).
Click on the "Update extensions" button
Here is what I have tried having opened the chrome extensions page:
IwebElement UpdateButton = driver.findelement(By.Id("update-extensions-now"));
UpdateButton.Click();
For some reason the button click is not registering. I have tried some other locators such as CSS path and Xpath but they don't work either. Also, when I debug this test, it passes fine so I know it's not an issue with any of my locators. I have (as a test) tried to automate clicks on the other elements on this page and it's the same issue. I can't get a handle on any elements on the chrome://extensions page at all.
Has anyone encountered this or have any ideas as to what's going on?
You can use the Chrome extensions API to auto-update required extension.
Find the file "manifest.json" in the default Google Chrome
C:\Users\*UserName*\AppData\Local\Google\Chrome\User Data\Default\Extensions
There find the update URL of your extension:
{
"name": "My extension",
...
"update_url": "http://myhost.com/mytestextension/updates.xml",
...
}
The returned XML by the Google server looks like:
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='yourAppID'>
<updatecheck codebase='http://myhost.com/mytestextension/mte_v2.crx' version='2.0' />
</app>
</gupdate>
appid
The extension or app ID, generated based on a hash of the public key, as described in Packaging. You can find the ID of an extension or Chrome App by going to the Extensions page (chrome://extensions).
codebase
A URL to the .crx file.
version
Used by the client to determine whether it should download the .crx file specified by codebase. It should match the value of "version" in the .crx file's manifest.json file.
The update manifest XML file may contain information about multiple extensions by including multiple elements.
Another option is to use the --extensions-update-frequency command-line flag to set a more frequent interval in seconds. For example, to make checks run every 45 seconds, run Google Chrome like this:
chrome.exe --extensions-update-frequency=45
Note that this affects checks for all installed extensions and apps, so consider the bandwidth and server load implications of this. You may want to temporarily uninstall all but the one you are testing with, and should not run with this option turned on during normal browser usage.
The request to update each individual extension would be:
http://test.com/extension_updates.php?x=id%3DyourAppID%26v%3D1.1
You can find even more detailed information on exntesions developers site: https://developer.chrome.com/extensions
If you look at the HTML of the "chrome://extensions" page you will notice that the "Update extensions now" button is contained within an iframe. You need to switch to the iframe before trying to register a button click. i.e:
(This is in c#. Note that this code is written from memory so it may not be 100% accurate. Also, you will want to write more robust method. This code just quickly demonstrates that by switching to the iframe, it will work ok)
String ChromeExtensionsPage = "chrome://extensions";
driver.Navigate().GoToUrl(ChromeExtensionsPage);
driver.Switchto().Frame("DesiredFrame");
IwebElement UpdateButton = driver.findelement(By.Id("DesiredButtonID"));
UpdateButton.Click();

how to open jsfiddle with a previous saved version by default

I created a version of my typical daily environment I'm working on (jquery + angular + some personal .js) and I would like to find myself on that base version each time I open jsfiddle.com, instead of finding myself on a blank draft that forces me to go to the dashboard, open the version I would like to work with and fork it.
Is that possible?
not possible, I'd just add your base to bookmarks and use it instead

X Displayed in dijit.form.Select

I am working on an application build on Dojo 1.4 and currently used on IE8.
When tried to run IE10 Compatibility view, I observer some X (to clear the data) are being show in the fields like dijit.form.Select. While in IE8 it doesn't display them
Please guide to remove them or what basically is happening
Thanks in Advance
If this is the same problem I just fixed then the question isn't referring to the IE10 "clear field" X. It's referring to a very large text "X" character that is displayed in the Select widget in addition to the options that are supposed to be there, making the widget twice as tall as it should be.
In my case it was because I was mixing the CSS stylesheet from one Dojo version with the API's from another. Check to make sure that your stylesheet and dojo.js versions match. For example, in my case the stylesheet was:
...href="//ajax.googleapis.com/ajax/libs/dojo/1.7.5/dijit/themes/claro/claro.css" media="screen">
while the script being included was
... src="//ajax.googleapis.com/ajax/libs/dojo/1.10.1/dojo/dojo.js"></script>
I blame the fact that I was modifying Dijit sample code without knowing what the heck I was doing...

Format month/year in Ektron calendar header

Version 8.0.1 SP1
Our client would like us to reformat the month/year in the calendar header. See attached image. They want "April, 2012" instead of the abbreviated "Apr, 2012". Where is this specified? I have looked at the webcalendar objects, css files, xslt files.
Any suggestions?
I haven't made that particular change, but have faced similar requests. Your options are-
Use Javascript (jQuery) to reformat on client side
Dig around in the workarea looking for formatting code, though usually the formatting code is locked up in a DLL.
DisplayXslt or EkMarkup - some controls allow you to apply XSLT or EkMarkup (Ektron markup template) for custom display. You create an XSLT, and apply it via the DisplayXslt property on the control.
Discard the control, and use the APIs to drive your own custom control.
Also, this Ektron forum post suggests having a look at this file- workarea/webcalendar/xsl/default.xsl
If this file exists (I don't have an Ektron installation currently handy), then it is likely you can use the DisplayXslt method described above.

How to stop firefox from downloading and applying CSS via a firefox extension?

Thanks to everyone in advance -
So I have been banging on this issue for quite a while now and have burned through all my options. My current approach to canceling css requests is with nsIRequest.cancel inside of nsIWebProgressListener.onStateChange. This works most of the time, except when things are a little laggy a few will slip through and jump out of the loadgroup before I can get to them. This is obviously a dirty solution.
I have read through the following links to try and get a better idea of how to disable css before a nsIRequest is created...no dice.
https://developer.mozilla.org/en/Document_Loading_-_From_Load_Start_to_Finding_a_Handler
https://developer.mozilla.org/en/The_life_of_an_HTML_HTTP_request
https://developer.mozilla.org/en/Bird's_Eye_View_of_the_Mozilla_Framework
How do I disable css via presentation objects/interfaces? Is this possible? Inside of nsIDocShell there are a few attributes that kind of imply you can disable css via the browsers docshell - allowPlugins, allowJavascript, allowMetaRedirects, allowSubframes, allowImages.
Any suggestions?
Thanks,
Sam
The menu option that disables style sheets uses a function
setStyleDisabled(true)
so you probably can just call this function whenever new browser tab is created. Style sheets are still requested from server, but not applied. This function is not very sophisticated and doesn't mess with nsIRequest, source:
function setStyleDisabled(disabled) {
getMarkupDocumentViewer().authorStyleDisabled = disabled;
}
Digging in Web Developer Toolbar source code I have noticed that their "disable stylesheets" function loops trough all document.styleSheets and sets the disabled property to true, like:
/* if DOM content is loaded */
var sheets = document.styleSheets;
for(var i in sheets){ sheets[i].disabled = true; }
So if the key is to not apply CSS to pages, one of the above solutions should work. But if you really need to stop style sheets from being downloaded from servers, I'm affraid nsIRequest interception is your only option.
Set permissions.default.stylesheet to 2 and voilĂ !
You can actually use the permissions manager to block or allow stylesheets on a host-by-host basis.
Unfortunately there doesn't seem to be a simple flag like allowImages. The bugzilla adding for that is https://bugzilla.mozilla.org/show_bug.cgi?id=340746. You can now vote for it using the new bugzilla voting functionality. You can also add yourself to the CC list to be notified if anyone ever works on it.
A related request is to just give us basic HTML parsing support, which may be what you are trying to do. Unfortunately that isn't supported yet either, but you can vote/track the bugzilla for that at https://bugzilla.mozilla.org/show_bug.cgi?id=102699.
So the only workable solution seems to be some sort of interception as #pawal suggests. Here is a link that talks about the basics of interception to at least get you/us started https://developer.mozilla.org/en/XUL_School/Intercepting_Page_Loads. It lists several options that I list below.
These first few seem to just be at the page/document level so I don't think they help:
Load Events (addEventListener load)
Web Progress Listeners (nsIWebProgressListener) - I tried this approach, it only seems to be called for the page itself, not for content within the page.
Document Loader Service - A global version of nsIWebProgressListener so I think it has the same problem (page level only)
That leaves two others I have not tried yet. They work globally so you would need to filter them to just the browser/pages you care about.
HTTP Observers - Seems like it might work, need to verify it calls back for CSS
Content Policy - Seems like the best option to me since it explicitly is called for CSS, someday I hope to try it :)