Re: FormValidation: Check for unique values between fields of repeatableProperty

2018-02-19 Thread Jesse Glick
On Fri, Feb 16, 2018 at 7:04 AM, Joachim Kuhnert
 wrote:
> Is it possible to get the currently not yet stored values for the siblings
> of  form?

Not easily. Unless this is really critical, recommend just printing a
warning at runtime and skipping the duplicate child.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1GRr5c_bL%2BzbfJ%2BRvDww6N8dcdjke-E%3Dn_S10rX5_yAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: FormValidation: Check for unique values between fields of repeatableProperty

2018-02-19 Thread Markus Winter
You could write some javascript to achieve this. I once did this though 
the repeatable property didn't have an own jelly file.
I'm no javascript expert though there might be a better way to get the 
elements. The risk would be if there are other elements that have the 
same name, then you could get false positives.




  
    onkeyup="checkForDuplicates()"/>

  



function StringSet()
{
  var setObj = {}, val = "true"

  this.add = function(str)
  {
    setObj[str] = val
  }

  this.contains = function(str)
  {
    return setObj[str] === val
  }
}

function checkForDuplicates()
{
  var uniqueIds = document.getElementsByName("_.uniqueId")
  var errorElement = document.getElementById("uniqueId-error")
  var uniqueIdSet = new StringSet()
  var hasError = false
  for (i=0; i

Hello,

I would like to check if the content of a text field of a repeatable 
property is unique (in the context of the project) when the user 
enters a text.


Let’s say I have a Plugin with a structure like that:

class Parent extends Builder {

   List objectsWithUniqueName;

}

class Child implements Describable {

   String name;  // has to be unique in project

   public static final class DescriptorImpl extends 
Descriptor {


      FormValidation doCheckName(@QueryParameter String value, 
@AncestorInPath AbstractProject project) {


  // TODO: check uniqueness of name

  }

   }

}








I am able to get the List of  Child-Objects of the Project that were 
saved the last time via the AbstractProject (cast to Project and use 
getBuilkders()-Method). Since the user is currently configuring the 
project he could have made cahnged (changed the name value of 
different Children or added/removed Children) there could be name 
clashes that are not yet saved or already solved.


Is it possible to get the currently not yet stored values for the 
siblings of  form?


Best Regards,

Joachim

---

Joachim Kuhnert

fon:  +49 30 394 09 683 39

mail: joachim.kuhn...@piketec.com

PikeTec GmbH, Waldenserstr. 2-4, 10551 Berlin

Management: Eckard Bringmann, Andreas Krämer, Jens Lüdemann

Location of the company: Berlin (Germany)

Trade register: Amtsgericht Berlin HRB 105491 B

Website: www.piketec.com 

--
You received this message because you are subscribed to the Google 
Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to jenkinsci-dev+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/4e635b05567d409485c8eb4e61e695f7%40piketec.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Jenkins 
Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/5cd58e20-c956-d9df-a0da-a3ef253d0767%40gmx.de.
For more options, visit https://groups.google.com/d/optout.