IT Monkey will place code here as examples of what Cireson's consulting team has to offer as well as examples for public consumption to benefit the Microsoft System Center community as a whole.
DISCLAIMER
All files and projects located here come as is and without any warranty or support. We will attempt to improve the projects as time goes on based on customer and community demand. Comments and improvements are welcome as well as customization requests. Your use of these Cireson Uploads is subject to our Terms of Use.
Cireson's support team has no information on these projects outside of what you have available and will not provide support for these enhancements, extensions, and scripts.
Dont forget to checkout solutions uploaded by our customers, partners and community members here.
Comments
Did you switch to use ajaxComplete() instead of ajaxStop()? And made sure, that the .unbind below is also changed to ajaxComplete()?
What browser are you using?
It could of course have both functionalities by defining that if the tag includes a string, the title should remain, i.e. @placeholder("this should be the placeholder") or simply @placeholder to use the title as placeholder.
If of course needs to be called in the ajaxComplete event as so:
$("p:contains('@placeholder')").parent().parent().each(makePlaceholder);
As with the other controls. it looks for a prompt containing "@placeholder", and then takes the next prompts Title and inserts it as placeholder in the text prompt.
Example with and without placeholder:
I would like to implement the functionality as I described in my last post, allowing one to input @placeholder(something), such that that text would become the placeholder, but I'm not sure, how I would distinguish between a tag with and without text (do you have an idea @john_doyle?).
Ideally, this tag could even be in the title for the specific prompt itself (so not another prompt), but I'm still considering how that could/should be done.
I have been working a little more on the code myself and adding a mechanism for adding properties to the tags, so for example, I want to be able to let the admin define the minLength on the autocomplete control. I do this by adding a JSON object to the tag, like this:
@AutoComplete {"minLength": "3"}
(Note that I decided to change the tag names going forward. Hopefully this will not cause too much distress, but it is easy to change them back in the js file anyway)
Anyway, the code still searches for the tag like this:
if ( !($( "div.custom-item-picker" ).length) ) {
$("p:contains('@AutoComplete')").parent().parent().each(function() {createAutoComplete("@AutoComplete",$(this))});
the createAutoComplete function now takes two arguments:
function createAutoComplete(tag,tagElement)
{
var userDefined = parseOptions(tag,tagElement);
// Hide the out of the box controls
tagElement.hide();
the parseOptions function is like this:
function parseOptions(controlName,control) {
var properties = "{}";
var regExp = /({[^}]+})/;
var matches = regExp.exec(control.text());
if (matches[1]) properties = matches[1];
return JSON.parse(properties);
}
I can then reference the properties set in the JSON string as userDefined.minLength (for example). I do need to do some more work on the tools before posting a new version.
I changed the names of the original tags, so if you have implemented the previous version, you will need to either change the tags on your forms or edit the function which searches for the tags.
Very nice, the toolbox is starting to take form! Thank you for crediting me, although if you continue to do it, could you please use my full name: Konstantin Slavin-Borovskij? The Cireson username is capped at 20 chars. Thanks!
I've edited the
makePlaceholder
function a bit, as you added the replace linebreak with nothing (line 105); I inserted a space in the replace string, and removed the line replacing "(" with " (", i.e.Also, I've implemented the @ConfirmField I mentioned with a small function:
It reuses the regex field on the second prompt, to make sure that the two fields match. So the 2nd prompt / "confirm prompt" needs to be to configured to use .Net Regular Expressions with any Regular Expression (e.g.
.*
) and a Custom ToolTip, which will be shown on mismatch.I don't use the
tag
argument, but I kepttagElement
to try and maintain some consistency, so the function call looks like:The @ConfirmFIelds tag should be placed right above the first prompt.
btw, I get the same issue whether I'm using IE or Chrome
$(document).ajaxStop(function() {
$(this).unbind('ajaxStop');
This may lead to a long delay before the toolbox kicks in.
Can you try replacing those two lines with this:
$(window).load( function() {
I ended up using (window).load() instead; it can result in a short glimpse of the original fields, but now they are consistently changing to the new one, which is fine for us. It's still a lot better than the crappy OotB fields!
Can you test this? Replace the window.load()...etc. with this:
app.events.subscribe('drawerCreated',transformRO);
function transformRO() {
app.events.unsubscribe('drawerCreated',transformRO);
app.lib.mask.apply();
$("p:contains('@Placeholder')").parent().parent().each(function() {
makePlaceholder("@Placeholder", $(this))
});
if (!($("div.custom-item-picker").length)) {
$("p:contains('@AutoComplete')").parent().parent().each(function() {
createAutoComplete("@AutoComplete", $(this))
});
}
if (!($("div.custom-item-multipicker").length)) {
$("p:contains('@MultiSelect')").parent().parent().each(function() {
createMultiSelect("@MultiSelect", $(this))
});
}
if (!($("div.custom-item-daterange").length)) {
$("p:contains('@DateRange')").parent().parent().each(function() {
createDateRange("@DateRange", $(this))
});
}
$("p:contains('@AddClass')").parent().parent().each(function() {
addCssClass("@AddClass", $(this))
});
app.lib.mask.remove();
}
when setting up conditions to only show the grid views on certain conditions, eg a checkbox ticked, this doesn't translate over to the replacement field.
i have got around this by adding the following at the bottom of the variables at line 207
then down around line 251 i have replaced
with these changed the custom field gets the same show/hide conditions as the grid, allowing the fields to be hidden or shown as the ones they replace are set to
and around line 308 replacing
with
will have it keep the show/hide criteria for it's actual grid view as well
I found that when loading the page initially on IE the page loaded with the transformations, but if F5 was pressed to reload it they would not happen and the grid pickers would show.
i put in the change you had above @john_doyle for the "app.events.subscribe('drawerCreated',transformRO);"
and after replacing the ajax.complete, i found the page did load a LOT faster in IE, and also the grids have not shown up since on over 20 page refresh's, it has only shown the transformed fields as it should.
Ah, that is excellent! And that event is always fires after the RO is loaded? Either way it passes my stress tests, and it seems to work really well. I encountered a strange thing though: The function call in the event subscriptions needs to include the parentheses and in the unsubscription they needs to be excluded, i.e.:
If the parentheses are omitted in the subscribe function, the function is never called. If the parentheses are included in the unsubscribe function, the code just silently fails at that line and never continues. Weird, but it works like that for me.
@Jeff_Lang
That's a real good catch, it hadn't crossed my mind at all! Your code works great, you just need to compare values with undefined by comparing to
typeof
the val, i.e:Thanks for sharing!
Hi All,
Any chance that a final version of the code can be uploaded with all of these posted amendments?
Cheers,
Adrian
instead of the
as stated above for both, i now have
for both the @AutoComplete Section and @MultiSelect section
and the @autocomplete section i have changed
and in the @MultiSelect section i have changed
with these changes, all 3 items, as in the @AutoComplete/@MultiSelect Display Only Prompts, AND the Optional Text field, AND the Query results prompts, can all have different Show/Hide Criteria.
This allows up to 3 show/hide criteria to be used to show/hide the transformed control.
so I've coded for an extra option that should be placed after the @AutoComplete or @MultiSelect in the ARO, which will allow using the same 3 criteria as above, but either as a "AND" between them or an "OR" between them. By default it will use "AND" for the Criteria, but this can be changed to an "OR" by adding a display only field called "@ShowHideOR" just after the @AutoComplete or @MultiSelect.
for this to work the following needs to be added/changed.
Add 2 extra Procedures.
in the transformRO procedure add the following ABOVE the @autocomplete check
Replace the ngshow1,2,3 variables in both the @AutoComplete and @MultiSelect with
In the @AutoComplete procedure, replace everything between
// Add the HTML template for the AutoComplete control.
and
// Process the data returned from the server and may the display columns into one string.
with
In the @MultiSelect procedure, replace everything between
// Add the HTML template for the AutoComplete control.
and
// Process the data returned from the server and may the display columns into one string.
with
Now we have the option for up to 3 sets of criteria, using a "AND" as default, and if setting the @ShowHideOR then it will use "OR" instead.