package hudson.plugins.git.UserRemoteConfig

f = namespace(lib.FormTagLib)
c = namespace(lib.CredentialsTagLib)

f.entry(title:_("Repository URL"), field:"url") {
    f.textbox(checkMethod: "post")
}

f.entry(title:_("Credentials"), field:"credentialsId") {
    c.select(onchange="""{
            var self = this.targetElement ? this.targetElement : this;
            var r = findPreviousFormItem(self,'url');
            r.onchange(r);
            self = null;
            r = null;
    }""" /* workaround for JENKINS-19124 */)
}

f.advanced {
    f.entry(title:_("Name"), field:"name") {
        f.textbox()
    }
    f.entry(title:_("Refspec"), field:"refspec") {
        f.textbox()
    }
}

f.entry {
    div(class: "show-if-not-only") {
        f.repeatableDeleteButton()
    }
}

package hudson.plugins.git.UserRemoteConfig

f = namespace(lib.FormTagLib)
c = namespace(lib.CredentialsTagLib)

f.entry(title:_("Repository URL"), field:"url") {
    f.textbox(checkMethod: "post")
}

f.entry(title:_("Credentials"), field:"credentialsId") {
    c.select(onchange="""{
            var self = this.targetElement ? this.targetElement : this;
            var r = findPreviousFormItem(self,'url');
            r.onchange(r);
            self = null;
            r = null;
    }""" /* workaround for JENKINS-19124 */)
}

f.advanced {
    f.entry(title:_("Name"), field:"name") {
        f.textbox()
    }
    f.entry(title:_("Refspec"), field:"refspec") {
        f.textbox()
    }
}

f.repeatableDeleteButton()

Remove wasted space on Repository URL field
Remove wasted space on Repository URL field

The repeatable delete button in the groovy form should be consistent
with the repeatable delete button used in jelly files.  No need to add
the extra div and waste vertical space.

The "show-if-not-only" class does not seem to have any affect on the
shipping version of the plugin with Jenkins 2.361.2.  I can delete the
Repository URL region because the delete "x" is displayed even when the
entry is the only entry of that type.  This change does not make the
current condition any worse with regards to the existence of the delete
"x" in the top right corner of the field and makes it more consisistent
with the improvement from @janfaracik.
