Browse Source

Merge branch 'master' of github.com:jqhph/dcat-admin

jqh 4 years ago
parent
commit
b74b75458a

+ 4 - 1
src/Console/ExportSeedCommand.php

@@ -32,10 +32,13 @@ class ExportSeedCommand extends Command
         $exceptFields = [];
         $exportUsers = $this->option('users');
 
-        $seedFile = $this->laravel->databasePath().'/seeds/'.$name.'.php';
+        $namespace = version_compare(app()->version(), '8.0.0', '<') ? 'seeds' : 'seeders';
+
+        $seedFile = $this->laravel->databasePath().'/'.$namespace.'/'.$name.'.php';
         $contents = $this->getStub('AdminTablesSeeder');
 
         $replaces = [
+            'DummyNamespace' => ucwords($namespace),
             'DummyClass' => $name,
 
             'ClassMenu'       => config('admin.database.menu_model'),

+ 4 - 0
src/Console/stubs/AdminTablesSeeder.stub

@@ -1,6 +1,10 @@
 <?php
 
+namespace Database\DummyNamespace;
+
 use Illuminate\Database\Seeder;
+use Dcat;
+use DB;
 
 class DummyClass extends Seeder
 {

+ 13 - 5
src/Form/Field/ListField.php

@@ -144,13 +144,21 @@ class ListField extends Field
 
         $this->script = <<<JS
 (function () {
-    var index = {$number};
+    $('.{$this->formatColumn()}-add').off()
     $('.{$this->formatColumn()}-add').on('click', function () {
-        var tpl = $('template.{$this->formatColumn()}-tpl').html().replace('{key}', index);
-        $('tbody.list-{$this->formatColumn()}-table').append(tpl);
-        
-        index++;
+        var index = 0;
+         $(this).closest('table').children('tbody.list-value-table').children().each((i,child)=>{
+             let name = $(child).find('input').attr('name')
+             rep = /\[values\]\[\d+\]/;
+             name = rep.exec(name).pop();
+             index = Math.max(index,Number(name.slice(9,-1)));
+             console.log(index);
+         })
+         console.log(index);
+        var tpl = $(this).closest('div.form-group').next('template').html().replace('{key}', index+1);
+        $(this).closest('table').children('tbody.list-{$this->formatColumn()}-table').append(tpl);
     });
+    $('tbody').off('click', '.{$this->formatColumn()}-remove');
     $('tbody').on('click', '.{$this->formatColumn()}-remove', function () {
         $(this).closest('tr').remove();
     });

+ 1 - 3
src/Grid/Filter/Presenter/SelectTable.php

@@ -21,8 +21,6 @@ class SelectTable extends Presenter
 
     protected $style = 'primary';
 
-    protected $title;
-
     protected $id;
 
     protected $options;
@@ -96,7 +94,7 @@ class SelectTable extends Presenter
      */
     public function title($title)
     {
-        $this->title = $title;
+        $this->dialog->title($title);
 
         return $this;
     }