IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

60 linhas
1.8KB

  1. //
  2. // Copyright (C) Stanislaw Adaszewski, 2020
  3. // Contact: s.adaszewski@gmail.com
  4. // Website: https://adared.ch/wba
  5. // License: GNU Affero General Public License, Version 3
  6. //
  7. import { h, Component, createRef } from 'preact';
  8. import WBDialog from 'wb-dialog';
  9. import linkState from 'linkstate';
  10. import makeArvadosRequest from 'make-arvados-request';
  11. import arvadosTypeName from 'arvados-type-name';
  12. class WBEditDescriptionDialog extends Component {
  13. constructor(...args) {
  14. super(...args);
  15. this.dialogRef = createRef();
  16. this.state.inputId = uuid.v4();
  17. }
  18. show(item, callback) {
  19. const { inputId } = this.state;
  20. this.setState({
  21. 'item': item,
  22. 'newDescription': null,
  23. 'callback': callback || (() => {})
  24. });
  25. this.dialogRef.current.show();
  26. $('#' + inputId).focus();
  27. }
  28. hide() {
  29. this.dialogRef.current.hide();
  30. }
  31. render({ app }, { item, newDescription, callback, inputId }) {
  32. const { arvHost, arvToken } = app.state;
  33. return (
  34. <WBDialog title="Edit Description" ref={ this.dialogRef } accept={ () =>
  35. makeArvadosRequest(arvHost, arvToken,
  36. '/arvados/v1/' + arvadosTypeName(item.uuid) +
  37. 's/' + item.uuid, {
  38. method: 'PUT',
  39. data: JSON.stringify({
  40. description: newDescription || null
  41. })
  42. }).then(callback)
  43. }>
  44. <div>
  45. <input type="text" class="form-control" id={ inputId }
  46. placeholder={ (item && item.description) ? item.description : 'Type new description here' }
  47. value={ newDescription } onChange={ linkState(this, 'newDescription') } />
  48. </div>
  49. </WBDialog>
  50. );
  51. }
  52. }
  53. export default WBEditDescriptionDialog;