Hi,
does someone already have a javascript solution how to remove and add again components to be selectable?
My problem (tested with Jira 4.4):
I want to provide only part of the components in the projects to be available for selection depending on a custom field "client" (single select field).
I.e I have component1 .. component6, client A has only licensed component1 and component4, client B has licensed component1 .. component4. When I select the client, only the licensed components of the client shall be available for selection.
The selection of components seems to be a bit tricky - there is an id "components" (hidden) containing all options availabe including an attribute "selected". And there is a class "representation" which is showing the selected components only as buttons, with clicking the buttons will remove the according component from selection.
I am quite new to jacascript and jquery. What I managed to do:
I could remove the options from "components" and depending on the selected client I could add the according components in the html. I can see them in Firebug.
I am struggling with:
Removing the selected components from representation, i.e. the formerly selected components are still shown in "representation" when I changed the clients - that also happens, if I only remove the "selected" attribute of the components in id "components" (without removing components).
Second problem:
Even if no component is selected, if I remove the components and add only those for the new selected client the dropbox to select the components can not be used to show the available options. Firebug is showing an error "invalid descriptor" in "batch.js" which is probably a script from Jira.
My next step: try to find out more about the "invalid descriptor" error. However, if someone already has a solution to manipulate properly the selection of components - thanks for sharing.
Clemens