diff --git a/app/Database/migrations/2017_06_07_014930_create_settings_table.php b/app/Database/migrations/2017_06_07_014930_create_settings_table.php index ae410de7..938ac195 100644 --- a/app/Database/migrations/2017_06_07_014930_create_settings_table.php +++ b/app/Database/migrations/2017_06_07_014930_create_settings_table.php @@ -33,7 +33,7 @@ class CreateSettingsTable extends Migration [ 'order' => 1, 'name' => 'Start Date', - 'group' => '', + 'group' => 'general', 'key' => 'general.start_date', 'value' => '', 'type' => 'date', @@ -45,7 +45,7 @@ class CreateSettingsTable extends Migration 'group' => 'general', 'key' => 'general.currency', 'value' => 'dollar', - 'type' => 'text', + 'type' => 'select', 'options' => 'dollar,euro,gbp,yen,jpy,rupee,ruble', 'description' => 'Currency to show in the interface', ], diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index 875f29b1..3e1e5441 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -2,42 +2,43 @@ namespace App\Http\Controllers\Admin; +use Log; use Illuminate\Http\Request; -use Setting; + +use App\Models\Setting; class SettingsController extends BaseController { /** - * Display a listing of setting. - * - * @return Response + * Display the settings. Group them by the setting group */ public function index() { - /*$settings = array_filter(Setting::all(), function ($key) { - if (strpos($key, '_descrip') !== false) { return true; } - return false; - });*/ - $settings = []; + $settings = Setting::orderBy('order', 'asc')->get(); + $settings = $settings->groupBy('group'); return view('admin.settings.index',[ - 'settings' => $settings, + 'grouped_settings' => $settings, ]); } /** * Update the specified setting in storage. - * - * @param Setting $setting - * @param Request $request - * - * @return Response */ - public function update(Setting $setting, Request $request) + public function update(Request $request) { - /*$this->validate($request, Setting::$rules, Setting::$messages); - $this->updateEntry($setting, $request->all());*/ + foreach($request->post() as $id => $value) { + $setting = Setting::find($id); + if(!$setting) { + continue; + } + Log::info('Updating "'.$setting->key.'" from "'.$setting->value.'" to "'.$value.'"'); + $setting->value = $value; + $setting->save(); + } + + flash('Settings saved!'); return redirect('/admin/settings'); } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 6e15c424..2e478bc4 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -22,7 +22,4 @@ class Setting extends BaseModel 'description', ]; - public $casts = [ - 'options' => 'array', - ]; } diff --git a/app/Routes/admin.php b/app/Routes/admin.php index 6ce419ee..921ec289 100644 --- a/app/Routes/admin.php +++ b/app/Routes/admin.php @@ -32,7 +32,7 @@ Route::group([ # view/update settings Route::match(['get'], 'settings', 'SettingsController@index'); - Route::match(['post', 'put'], 'settings', 'SettingsController@update'); + Route::match(['post', 'put'], 'settings', 'SettingsController@update')->name('settings.update'); # pirep related routes Route::resource('pireps', 'PirepController'); diff --git a/package-lock.json b/package-lock.json index 615c608d..702f811c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -243,6 +243,12 @@ "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=" }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, "asn1": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", @@ -1189,11 +1195,6 @@ "hoek": "2.16.3" } }, - "bootstrap-editable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bootstrap-editable/-/bootstrap-editable-1.0.1.tgz", - "integrity": "sha1-RFpnG1q1/td+jH9OX/vHlsYLUCM=" - }, "bootstrap-sass": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/bootstrap-sass/-/bootstrap-sass-3.3.7.tgz", @@ -1860,6 +1861,67 @@ "run-queue": "1.0.3" } }, + "copy-webpack-plugin": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-4.3.1.tgz", + "integrity": "sha512-xlcFiW/U7KrpS6dFuWq3r8Wb7koJx7QVc7LDFCosqkikaVSxkaYOnwDLwilbjrszZ0LYZXThDAJKcQCSrvdShQ==", + "dev": true, + "requires": { + "cacache": "10.0.1", + "find-cache-dir": "1.0.0", + "globby": "7.1.1", + "is-glob": "4.0.0", + "loader-utils": "0.2.17", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "p-limit": "1.1.0", + "pify": "3.0.0", + "serialize-javascript": "1.4.0" + }, + "dependencies": { + "globby": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz", + "integrity": "sha1-+yzP+UAfhgCUXfral0QMypcrhoA=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "dir-glob": "2.0.0", + "glob": "7.1.2", + "ignore": "3.3.7", + "pify": "3.0.0", + "slash": "1.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-glob": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", + "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "dev": true, + "requires": { + "is-extglob": "2.1.1" + } + }, + "loader-utils": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", + "integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=", + "dev": true, + "requires": { + "big.js": "3.2.0", + "emojis-list": "2.1.0", + "json5": "0.5.1", + "object-assign": "4.1.1" + } + } + } + }, "core-js": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz", @@ -2540,6 +2602,27 @@ "randombytes": "2.0.5" } }, + "dir-glob": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-2.0.0.tgz", + "integrity": "sha512-37qirFDz8cA5fimp9feo43fSuRo2gHwaIn6dXL8Ber1dGwUosDrGZeCCXq57WnIqE4aQ+u3eQZzsk1yOzhdwag==", + "dev": true, + "requires": { + "arrify": "1.0.1", + "path-type": "3.0.0" + }, + "dependencies": { + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "3.0.0" + } + } + } + }, "dns-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", @@ -4855,6 +4938,12 @@ "resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz", "integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=" }, + "ignore": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", + "dev": true + }, "imagemin": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/imagemin/-/imagemin-5.3.1.tgz", @@ -9421,6 +9510,12 @@ } } }, + "serialize-javascript": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.4.0.tgz", + "integrity": "sha1-fJWFFNtqwkQ6irwGLcn3iGp/YAU=", + "dev": true + }, "serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", diff --git a/package.json b/package.json index ef37cdf1..4ab14ecf 100755 --- a/package.json +++ b/package.json @@ -27,5 +27,8 @@ "rivets": "0.9.6", "select2": "^4.0.5", "x-editable": "1.5.1" + }, + "devDependencies": { + "copy-webpack-plugin": "^4.3.1" } } diff --git a/public/assets/admin/css/blue.png b/public/assets/admin/css/blue.png new file mode 100644 index 00000000..a3e040fc Binary files /dev/null and b/public/assets/admin/css/blue.png differ diff --git a/public/assets/admin/css/blue@2x.png b/public/assets/admin/css/blue@2x.png new file mode 100644 index 00000000..8fdea12f Binary files /dev/null and b/public/assets/admin/css/blue@2x.png differ diff --git a/public/assets/admin/css/vendor.min.css b/public/assets/admin/css/vendor.min.css index 4c53848e..3a982342 100644 --- a/public/assets/admin/css/vendor.min.css +++ b/public/assets/admin/css/vendor.min.css @@ -16363,57 +16363,63 @@ a.editable-click.editable-disabled:hover { border-right-color: #fff; } -/* iCheck plugin Flat skin, orange +/* iCheck plugin Square skin, blue ----------------------------------- */ -.icheckbox_flat-orange, -.iradio_flat-orange { +.icheckbox_square-blue, +.iradio_square-blue { display: inline-block; *display: inline; vertical-align: middle; margin: 0; padding: 0; - width: 20px; - height: 20px; - background: url(orange.png) no-repeat; + width: 22px; + height: 22px; + background: url(blue.png) no-repeat; border: none; cursor: pointer; } -.icheckbox_flat-orange { +.icheckbox_square-blue { background-position: 0 0; } - .icheckbox_flat-orange.checked { - background-position: -22px 0; + .icheckbox_square-blue.hover { + background-position: -24px 0; } - .icheckbox_flat-orange.disabled { - background-position: -44px 0; + .icheckbox_square-blue.checked { + background-position: -48px 0; + } + .icheckbox_square-blue.disabled { + background-position: -72px 0; cursor: default; } - .icheckbox_flat-orange.checked.disabled { - background-position: -66px 0; + .icheckbox_square-blue.checked.disabled { + background-position: -96px 0; } -.iradio_flat-orange { - background-position: -88px 0; +.iradio_square-blue { + background-position: -120px 0; } - .iradio_flat-orange.checked { - background-position: -110px 0; + .iradio_square-blue.hover { + background-position: -144px 0; } - .iradio_flat-orange.disabled { - background-position: -132px 0; + .iradio_square-blue.checked { + background-position: -168px 0; + } + .iradio_square-blue.disabled { + background-position: -192px 0; cursor: default; } - .iradio_flat-orange.checked.disabled { - background-position: -154px 0; + .iradio_square-blue.checked.disabled { + background-position: -216px 0; } /* HiDPI support */ @media (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) { - .icheckbox_flat-orange, - .iradio_flat-orange { - background-image: url(orange@2x.png); - -webkit-background-size: 176px 22px; - background-size: 176px 22px; + .icheckbox_square-blue, + .iradio_square-blue { + background-image: url(blue@2x.png); + -webkit-background-size: 240px 24px; + background-size: 240px 24px; } } /*! X-editable - v1.5.1 diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 64614644..628edd61 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,8 +1,10 @@ { "/assets/admin/vendor/paper-dashboard.css": "/assets/admin/vendor/paper-dashboard.css?id=729efec551211db36219", "/assets/frontend/css/now-ui-kit.css": "/assets/frontend/css/now-ui-kit.css?id=58ec3dc768f07fee143a", - "/assets/admin/css/vendor.min.css": "/assets/admin/css/vendor.min.css?id=66957049f4a01c51c68d", + "/assets/admin/css/vendor.min.css": "/assets/admin/css/vendor.min.css?id=f583577fe1de7a1da1e6", "/assets/admin/js/vendor.js": "/assets/admin/js/vendor.js?id=eb27f6c829378a084072", + "/assets/admin/css/blue.png": "/assets/admin/css/blue.png?id=753a3c0dec86d3a38d9c", + "/assets/admin/css/blue@2x.png": "/assets/admin/css/blue@2x.png?id=97da23d47b838cbd4bef", "/assets/system/js/vendor.js": "/assets/system/js/vendor.js?id=434db3f2c9beafd58bae", "/assets/system/css/vendor.css": "/assets/system/css/vendor.css?id=7bd98a28084fea99e307", "/assets/system/js/installer-vendor.js": "/assets/system/js/installer-vendor.js?id=b2bca761f222e97bf4ff" diff --git a/resources/views/admin/app.blade.php b/resources/views/admin/app.blade.php index 8120fff2..ad52fa21 100644 --- a/resources/views/admin/app.blade.php +++ b/resources/views/admin/app.blade.php @@ -140,8 +140,8 @@ $(document).ready(function () { $(".select2").select2(); $('input').iCheck({ - checkboxClass: 'icheckbox_flat-orange', - radioClass: 'iradio_flat-orange' + checkboxClass: 'icheckbox_square-blue', + radioClass: 'icheckbox_square-blue' }); var storage = getStorage("phpvms.admin"); diff --git a/resources/views/admin/settings/index.blade.php b/resources/views/admin/settings/index.blade.php index 6f93c1e9..5c61972b 100644 --- a/resources/views/admin/settings/index.blade.php +++ b/resources/views/admin/settings/index.blade.php @@ -2,9 +2,8 @@ @section('title', 'Settings') @section('content') -
- @include('flash::message') - @include('admin.settings.table') -
+ @include('flash::message') + @include('admin.settings.table') @endsection +@include('admin.settings.script') diff --git a/resources/views/admin/settings/script.blade.php b/resources/views/admin/settings/script.blade.php new file mode 100644 index 00000000..4a387288 --- /dev/null +++ b/resources/views/admin/settings/script.blade.php @@ -0,0 +1,30 @@ +@section('scripts') + +@endsection diff --git a/resources/views/admin/settings/table.blade.php b/resources/views/admin/settings/table.blade.php index eaa69fc6..3dcce6fd 100644 --- a/resources/views/admin/settings/table.blade.php +++ b/resources/views/admin/settings/table.blade.php @@ -1,22 +1,44 @@ - - - - - - - -@foreach($settings as $s) - - - - - +{!! Form::model($grouped_settings, ['route' => ['admin.settings.update'], 'method' => 'post']) !!} +@foreach($grouped_settings as $group => $settings) +
+
+
NameValueDescription
{!! $s->key !!}{!! $s->value !!} - @if(Setting::get($s->key.'_descrip')) - {!! Setting::get($s->key.'_descrip') !!} - @else -   - @endif -
+ + + + + @foreach($settings as $setting) + + + + + @endforeach +
+
{!! $group !!}
+
+

{!! $setting->name !!}

+

{{$setting->description}}

+ @if($setting->type === 'text') + {!! Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) !!} + @elseif($setting->type === 'boolean' || $setting->type === 'bool') + {!! Form::hidden($setting->id, 0) !!} + {!! Form::checkbox($setting->id, null, $setting->value, ['']) !!} + @elseif($setting->type === 'int' || $setting->type === 'number') + {!! Form::number($setting->id, $setting->value, ['class'=>'form-control']) !!} + @elseif($setting->type === 'select') + {!! Form::select($setting->id, + explode(',', $setting->options), + $setting->value, ['class' => 'select2', 'style' => 'width: 100%']) !!} + @else + {!! Form::input('text', $setting->id, $setting->value, ['class' => 'form-control']) !!} + @endif + +
+ + @endforeach - - +
+ {!! Form::submit('Save', ['class' => 'btn btn-primary']) !!} + Cancel +
+{!! Form::close() !!} diff --git a/webpack.mix.js b/webpack.mix.js index 9a04c897..f6c9390f 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -33,7 +33,7 @@ mix.styles([ 'public/assets/admin/vendor/font-awesome.css', 'node_modules/select2/dist/css/select2.css', 'node_modules/leaflet/dist/leaflet.css', - 'node_modules/icheck/skins/flat/orange.css', + 'node_modules/icheck/skins/square/blue.css', 'node_modules/x-editable/dist/bootstrap3-editable/css/bootstrap-editable.css', 'public/assets/admin/vendor/paper-dashboard.css', ], 'public/assets/admin/css/vendor.min.css').version() @@ -52,6 +52,8 @@ mix.scripts([ 'node_modules/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.js', ], 'public/assets/admin/js/vendor.js'); +mix.copy('node_modules/icheck/skins/square/blue*.png', 'public/assets/admin/css'); + /** * SYSTEM REQUIRED FILES */