ZenTrack

Project management and bug tracking software

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Please Login or Register.    Lost Password?

Making fields visible/invisible using behaviours
(1 viewing) (1) Guest
Help
Go to bottomPage: 1
TOPIC: Making fields visible/invisible using behaviours
#6532
Making fields visible/invisible using behaviours 7 Months ago Karma: 0  
Hi,

Here's my system information: Ubuntu 8.04, MySQL 5.0.22, PHP 5.1.2, ZT 2.6.4

I am wondering if it's possible to make a custom field visible/invisible in zentrack based on a behaviour rule. I currently make some fields active/inactive based on behaviour rules, but would rather they didn't show at all unless needed.

This is in the ticket create screen I'm thinking of.

Thanks,
DJ.
Djb (User)
Pebble in Pond
Posts: 20
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#6534
Re:Making fields visible/invisible using behaviours 6 Months, 4 Weeks ago Karma: 0  
Hi DJ,

I thought it might be possible if you could edit the DOM form properties (not just values) using javascript in the Data Group and Behavior configuration, but I've run a few tests and it doesn't look like you can. Today I spent a few hours playing around to see if it could be done, but didn't get anywhere unfortunately. It seems all you can do in the data groups is set the 'x' array, which is probably by design to prevent any malicious code from being run.

Obviously the concept of hiding fields is within the realms of javascript and style sheets, but apparently not from the configuration screens. You would probably need to make some changes in the server code.

Maybe cflonso or kato will be able to shed some light?

Meanwhile, it's a good requirement to add to ZT3, but that could be a while off yet.

Regards,

Donkeybandit
donkeybandit (Admin)
Developer
Posts: 47
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#6539
Re:Making fields visible/invisible using behaviours 6 Months, 1 Week ago Karma: 1  
Hey DB and DJB,
I'm not sure if this is currently possible. Give me some time to check it out and I'll be back.
Regards,

--Claudio
cfalonso (User)
Pebble in Pond
Posts: 5
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#6541
Re:Making fields visible/invisible using behaviours 6 Months ago Karma: 1  
Well, I was able to do it. I'll try to explain how, I suppose you have some general knowledge about data groups and behaviors. If you don't, please let me know.

First of all, we will be using 2 Javascript data groups (one to hide the field, and the other to show it again).
The behavior's "Field to change" is not necesarilly the field we are about to hide or show. In order to be more clear I will state that the field to hide or show is custom_text1 and the field which values we will change is custom_menu1 (A, B and C when custom_text1 hides, and W, X, Y and Z when custom_text1 shows). The triggering will be related to the selection in the system field.

So, we will now create the TextHide Data Group (Javascript):
-Table Name: Custom
-Group Name: TextHide
-Eval Type: Javascript
-Eval Script:
Code:


var x=new Array();
x[0]='A';
x[1]='B';
x[2]='C';
var myDiv=document.getElementsByName("custom_text1")[0].parentNode.parentNode;
if (myDiv!=null) {
      myDiv.style.display='none';
}




And the TextShow Data Group (Javascript too):
-Table Name: Custom
-Group Name: TextShow
-Eval Type: Javascript
-Eval Script:
Code:


var x=new Array();
x[0]='W';
x[1]='X';
x[2]='Y';
x[3]='Z';
var myDiv=document.getElementsByName("custom_text1")[0].parentNode.parentNode;
if (myDiv!=null) {
      myDiv.style.display='table-row';
}



Note that the code specifies the field to hide or to show (custom_text1, hardcoded), and the values to put in the "Field to change" (the name of the field is not hardcoded, and has to be configured in the behavior).

After that, just create the 2 behaviors:
The first one:
PROPERTIES:
-Behavior Name: TextHide (can be any one you like)
-Active: True
-Data Group: TextHide (this is the name of the first data group)
-Field to change: custom_menu1 (as stated in the example)
-Field is enabled: True
RULES: Anyone you like, for example System = 5

The second:
PROPERTIES:
-Behavior Name: TextShow (can be any one you like)
-Active: True
-Data Group: TextShow (this is the name of the second data group)
-Field to change: custom_menu1 (as stated in the example)
-Field is enabled: True
RULES: Anyone you like, for example System = 6

Before going on, be sure to check that these 2 fields (custom_text1 and custom_menu1) are visible in the ticket_create fieldmap configuration. Also check the descriptions associated to the system ids 5 and 6.

After that, go to the New ticket page and toggle the System values through 5 (PC if you are in the default installation) and 6 (Printer if you are in the default installation). You will see the custom_text1 field appear and disappear, and the values of custom_menu1 change from "A, B, C" to "W, X, Y, Z".

I hope the explanation is clear enough and wish you could recreate the example and adapt it to your needs.

Please let me know if there is anything you don't understand and/or if you have any problem.

Regards,

--Claudio
cfalonso (User)
Pebble in Pond
Posts: 5
User Offline Click here to see the profile of this user
Last Edit: 2010/03/09 19:35 By cfalonso.
The administrator has disabled public write access.
 
#6544
Re:Making fields visible/invisible using behaviours 6 Months ago Karma: 0  
Hi Claudio,

That's great! Thanks for taking the effort to respond. I'll try that out at the weekend

All the best,

Donkeybandit
donkeybandit (Admin)
Developer
Posts: 47
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#6545
Re:Making fields visible/invisible using behaviours 6 Months ago Karma: 0  
Excellent! Thanks very much. I'll let you know how it goes.

Dj
Djb (User)
Pebble in Pond
Posts: 20
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#6551
Re:Making fields visible/invisible using behaviours 5 Months, 1 Week ago Karma: 0  
That is great, and works well in my tests. I have a bit of work to do to replace my existing active/inactive rules, get the sort order right, etc, but I'll get there.

Is it possible to hide/unhide more than one field at the same time based on chosen system (or whatever)?

Thanks very much for this,
Dermot.
Djb (User)
Pebble in Pond
Posts: 20
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#6552
Re:Making fields visible/invisible using behaviours 5 Months, 1 Week ago Karma: 0  
I think i need some advice on how this would work as follows:

1. User chooses Item 1 in System menu: this is to unhide custom_menu1 with entries a,b,c and unhide custom_string1, custom_string2 and custom_string3

2. User may choose Item 2 in System Menu: this is hide custom_menu1, custom_string1, custom_string2 and custom_string3. It will unhide nothing.

3. User may choose Item 3 in System Menu: this will unhide custom_menu1 with entries x,y,z

4. User may choose Item 4 in System Menu: this will hide custom_menu1 and unhide custom_string5 and custom_string6.

I think my problem with getting the above to work has something to do with the sort order. When i click New Ticket, and then Item 1 from the System Menu, the custom_menu1 appears with the correct items. If i click Item 3 at this point, custom_menu1 does not change to items x,y,z. I can't make it hide/unhide for more than one Rule. Seems the first rule to run causes no further rules to run after it?

Also, not sure if i can hide/unhide more than one field at once.

Not sure if this makes sense!

Dj
Djb (User)
Pebble in Pond
Posts: 20
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#6614
Re:Making fields visible/invisible using behaviours 4 Months ago Karma: 0  
Bump!
Djb (User)
Pebble in Pond
Posts: 20
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1

Contributors


Support Us

Support This Project