ServiceDialog.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * ServiceDialog.js
  3. *
  4. * @author realor
  5. */
  6. import { Dialog } from './Dialog.js'
  7. class ServiceDialog extends Dialog {
  8. constructor(title, serviceTypeOptions, serviceType, name, description, url, username, password) {
  9. super(title)
  10. this.setSize(260, 330)
  11. this.serviceTypeSelect = this.addSelectField('svcType', 'label.service_type', serviceTypeOptions, serviceType)
  12. this.nameElem = this.addTextField('svcName', 'label.service_name', name)
  13. this.nameElem.spellcheck = false
  14. this.descriptionElem = this.addTextField('svcDesc', 'label.service_desc', description)
  15. this.urlElem = this.addTextField('svcUrl', 'label.service_url', url)
  16. this.urlElem.spellcheck = false
  17. this.usernameElem = this.addTextField('svcUsername', 'label.service_user', username)
  18. this.passwordElem = this.addPasswordField('svcPassword', 'label.service_pass', password)
  19. this.addButton('save', 'button.save', () => {
  20. this.hide()
  21. this.onSave(this.serviceTypeSelect.value, this.nameElem.value, this.descriptionElem.value, this.urlElem.value, this.usernameElem.value, this.passwordElem.value)
  22. })
  23. this.cancelButton = this.addButton('cancel', 'button.cancel', () => this.onCancel())
  24. }
  25. onShow() {
  26. this.serviceTypeSelect.focus()
  27. }
  28. onSave(serviceType, name, description, url, username, password) {}
  29. onCancel() {
  30. this.hide()
  31. }
  32. }
  33. export { ServiceDialog }