QuickEdit.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Dcat\Admin\Grid\Actions;
  3. use Dcat\Admin\Form;
  4. use Dcat\Admin\Grid\RowAction;
  5. class QuickEdit extends RowAction
  6. {
  7. protected static $resolvedWindow;
  8. /**
  9. * @return array|null|string
  10. */
  11. public function title()
  12. {
  13. if ($this->title) {
  14. return $this->title;
  15. }
  16. return '<i class="feather icon-edit"></i> '.__('admin.quick_edit');
  17. }
  18. public function render()
  19. {
  20. if (! static::$resolvedWindow) {
  21. static::$resolvedWindow = true;
  22. [$width, $height] = $this->parent->option('dialog_form_area');
  23. $title = trans('admin.edit');
  24. Form::dialog($title)
  25. ->click(".{$this->getElementClass()}")
  26. ->dimensions($width, $height)
  27. ->forceRefresh()
  28. ->success('Dcat.reload()');
  29. }
  30. $this->setHtmlAttribute([
  31. 'data-url' => "{$this->resource()}/{$this->getKey()}/edit",
  32. ]);
  33. return parent::render();
  34. }
  35. public function makeSelector()
  36. {
  37. return 'quick-edit';
  38. }
  39. }