Skip to content

Commit

Permalink
Merge pull request #10 from jhoopes/form-admin
Browse files Browse the repository at this point in the history
Form administration, updates, and json api implementation
  • Loading branch information
jhoopes committed Dec 29, 2020
2 parents 8500dc3 + ca119c7 commit 3ff1378
Show file tree
Hide file tree
Showing 41 changed files with 1,970 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ composer.lock
/node_modules
/vendor
/.idea

*.iml
8 changes: 6 additions & 2 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
],
"require": {
"php": ">=7.2",
"mews/purifier": "3.3.*",
"mews/purifier": "3.3.*",
"neomerx/json-api": "^4.0",
"laravel/framework": "5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ~6 || ~7 || ~8"
},
"autoload": {
Expand All @@ -29,7 +30,10 @@
"laravel": {
"providers": [
"jhoopes\\LaravelVueForms\\Providers\\LaravelVueFormsServiceProvider"
]
],
"aliases": {
"LaravelForms": "jhoopes\\LaravelVueForms\\Facades\\LaravelVueForms"
}
}
}
}
127 changes: 127 additions & 0 deletions config/laravel-vue-forms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?php


return [

'api_middleware' => '',
'check_permissions' => env('LVF_CHECK_PERMISSIONS', false),
'values_soft_delete' => env('LVF_VALUES_SOFT_DELETE', false),

/**
* Registers open access to the form configuration and form field policies.
* If set to false, you must specify your own policies for these when using the administration area
*/
'openAccess' => true,

/**
* Allow editing of system level forms
*/
'edit_system_forms' => true,


/**
* Admin Configuration
*/
'use_web_routes' => env('LVF_USE_WEB_ROUTES', true),
'use_base_api' => env('LVF_USE_BASE_API', true),
'use_admin_api' => env('LVF_USE_ADMIN_API', true),
'admin_middleware' => '',



'entity_types' => [
'form_configuration' => \jhoopes\LaravelVueForms\Models\FormConfiguration::class,
'form_field' => \jhoopes\LaravelVueForms\Models\FormField::class,
],

/**
* Possible field types to allow for selection when adding a new field
*/
'widget_types' => [
'column' => [
'name' => 'Column',
'structural' => true,
],
'tab' => [
'name' => 'Tab',
'structural' => true,
],
'static' => [
'name' => 'Static',
],
'text' => [
'name' => 'Text',
],
'autocomplete' => [
'name' => 'autocomplete'
],
'textarea' => [
'name' => 'Generic Textarea',
],
'dropdown' => [
'name' => 'Select / Dropdown',
],
'checkbox' => [
'name' => 'Checkbox',
],
'radio' => [
'name' => 'Radio',
],
'datepicker' => [
'name' => 'Date Picker',
],
'timepicker' => [
'name' => 'Time Picker'
],
'datetimepicker' => [
'name' => 'Date/Time Picker'
],
'files' => [
'name' => 'File Uploader',
],
'wysiwyg' => [
'name' => 'Rich text editor',
],
'code' => [
'name' => 'Code Editor'
]
],

/**
* Possible casting types for casting attributes to
*/
'cast_types' => [
'integer' => 'Integer',
'boolean' => 'Boolean',
'string' => 'String',
'array' => 'Array',
'double' => 'Double / Float'
],

/**
* Standard validation rules
* These are rules most found in Laravel's validation rule set
* The "hasOptions" key allows you to specify additional options for that validation rule. This is dependent on the rule itself
*/
'standard_validation_rules' => [
['value'=>'accepted', 'name' => 'Accepted'],
['value'=>'alpha', 'name' => 'Alphabetic Characters'],
['value'=>'alpha_dash', 'name' => 'Alphabetic Characters w/dashes'],
['value'=>'alpha_num', 'name' => 'Alpha-numeric Characters'],
['value'=>'array', 'name' => 'Array'],
['value'=>'between', 'name' => 'Between', 'hasOptions'=>'true', 'options' => ['Min', 'Max']],
['value'=>'boolean', 'name' => 'Boolean'],
['value'=>'date', 'name' => 'Date'],
['value'=>'digits', 'name' => 'Required Number of Digits', 'hasOptions'=>'true', 'options' => ['#']],
['value'=>'digits_between', 'name' => 'Between', 'hasOptions'=>'true', 'options' => ['Min', 'Max']],
['value'=>'email', 'name' => 'Email'],
['value'=>'file', 'name' => 'File'],
['value'=>'integer', 'name' => 'Integer'],
['value'=>'min', 'name' => 'Min', 'hasOptions'=>'true', 'options' => ['Min']],
['value'=>'max', 'name' => 'Max', 'hasOptions'=>'true', 'options' => ['Max']],
['value'=>'nullable', 'name' => 'Allowed Empty'],
['value'=>'required_if', 'name' => 'Required If', 'hasOptions'=>'true', 'options' => ['Field', 'Value']],
['value'=>'required_unless', 'name' => 'Required Unless', 'hasOptions'=>'true', 'options' => ['Field', 'Value']],
['value'=>'string', 'name' => 'String'],
]
];
13 changes: 13 additions & 0 deletions database/factories/FormConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Faker\Generator as Faker;

$factory->define(\jhoopes\LaravelVueForms\Models\FormConfiguration::class, function(Faker $faker) {
return [
'name' => $faker->word,
'type' => $faker->word,
'active' => $faker->randomElement([1, 0]),
'entity_name' => $faker->word,
'entity_type' => $faker->className,
];
});
1 change: 0 additions & 1 deletion database/factories/ModelFactory.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateFormConfigurationsForAdmin extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('form_configurations', function (Blueprint $table) {
$table->string('type')->nullable()->after('name');
$table->boolean('active')->default(1)->after('type');
$table->json('options')->nullable()->after('entity_model');

$table->string('entity_name')->nullable()->change();
$table->string('entity_model')->nullable()->change();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('form_configurations', function (Blueprint $table) {
$table->dropColumn([
'type',
'active',
'options'
]);

$table->string('entity_name')->nullable(false)->change();
$table->string('entity_model')->nullable(false)->change();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateFormFieldsForCasts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('form_fields', function (Blueprint $table) {
$table->string('cast_to')->nullable()->after('parent_id');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('form_fields', function (Blueprint $table) {
$table->dropColumn([
'cast_to'
]);
});
}
}
Loading

0 comments on commit 3ff1378

Please sign in to comment.