Merge branch 'develop' into bug/sc-15034

This commit is contained in:
Marcus Moore
2023-03-27 11:46:30 -07:00
10 changed files with 55 additions and 28 deletions
+14 -7
View File
@@ -334,7 +334,11 @@ class Helper
'#92896B',
];
$total_colors = count($colors);
if ($index >= $total_colors) {
$index = $index - $total_colors;
}
return $colors[$index];
}
@@ -528,20 +532,23 @@ class Helper
* @since [v2.5]
* @return array
*/
public static function categoryTypeList()
public static function categoryTypeList($selection=null)
{
$category_types = [
'' => '',
'accessory' => 'Accessory',
'asset' => 'Asset',
'consumable' => 'Consumable',
'component' => 'Component',
'license' => 'License',
'accessory' => trans('general.accessory'),
'asset' => trans('general.asset'),
'consumable' => trans('general.consumable'),
'component' => trans('general.component'),
'license' => trans('general.license'),
];
if($selection != null){
return $category_types[$selection];
}
else
return $category_types;
}
/**
* Get the list of custom fields in an array to make a dropdown menu
*
@@ -82,8 +82,8 @@ class AssetModelsController extends Controller
$model->user_id = Auth::id();
$model->requestable = Request::has('requestable');
if ($request->input('custom_fieldset') != '') {
$model->fieldset_id = e($request->input('custom_fieldset'));
if ($request->input('fieldset_id') != '') {
$model->fieldset_id = e($request->input('fieldset_id'));
}
$model = $request->handleImages($model);
@@ -160,10 +160,10 @@ class AssetModelsController extends Controller
$this->removeCustomFieldsDefaultValues($model);
if ($request->input('custom_fieldset') == '') {
if ($request->input('fieldset_id') == '') {
$model->fieldset_id = null;
} else {
$model->fieldset_id = $request->input('custom_fieldset');
$model->fieldset_id = $request->input('fieldset_id');
if ($this->shouldAddDefaultValues($request->input())) {
if (!$this->assignCustomFieldsDefaultValues($model, $request->input('default_values'))){
@@ -444,7 +444,7 @@ class AssetModelsController extends Controller
{
return ! empty($input['add_default_values'])
&& ! empty($input['default_values'])
&& ! empty($input['custom_fieldset']);
&& ! empty($input['fieldset_id']);
}
/**
+1 -1
View File
@@ -24,7 +24,7 @@ class AssetFileRequest extends Request
$max_file_size = \App\Helpers\Helper::file_upload_max_size();
return [
'file.*' => 'required|mimes:png,gif,jpg,svg,jpeg,doc,docx,pdf,txt,zip,rar,xls,xlsx,lic,xml,rtf,webp|max:'.$max_file_size,
'file.*' => 'required|mimes:png,gif,jpg,svg,jpeg,doc,docx,pdf,txt,zip,rar,xls,xlsx,lic,xml,rtf,json,webp|max:'.$max_file_size,
];
}
}
@@ -47,7 +47,7 @@ class CategoriesTransformer
'id' => (int) $category->id,
'name' => e($category->name),
'image' => ($category->image) ? Storage::disk('public')->url('categories/'.e($category->image)) : null,
'category_type' => ucwords(e($category->category_type)),
'category_type' => Helper::categoryTypeList($category->category_type),
'has_eula' => ($category->getEula() ? true : false),
'use_default_eula' => ($category->use_default_eula=='1' ? true : false),
'eula' => ($category->getEula()),
@@ -22,7 +22,7 @@ class AddIdsToTables extends Migration
Schema::table('password_resets', function (Blueprint $table) {
// Add the id column to the password_resets table if it doesn't yet have one
if (! Schema::hasColumn('password_resets', 'id')) {
if (! Schema::hasColumn('password_resets', 'id') && $this->notUsingSqlite()) {
$table->increments('id');
}
});
@@ -47,4 +47,9 @@ class AddIdsToTables extends Migration
}
});
}
private function notUsingSqlite()
{
return Schema::connection($this->getConnection())->getConnection()->getDriverName() !== 'sqlite';
}
}
@@ -13,12 +13,27 @@ class AddsWebhookOptionToSettingsTable extends Migration
*/
public function up()
{
/**
* So...you're probably wondering why this isn't all in one Schema::table()...
* Turns out we'll get the following error:
* "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification."
* if we're running sqlite so a solution is to make multiple calls.
* ¯\_(ツ)_/¯
*/
Schema::table('settings', function (Blueprint $table) {
$table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable();
$table->renameColumn('slack_botname', 'webhook_botname');
$table->renameColumn('slack_endpoint', 'webhook_endpoint');
$table->renameColumn('slack_channel', 'webhook_channel');
$table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable();
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_botname', 'webhook_botname');
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_endpoint', 'webhook_endpoint');
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_channel', 'webhook_channel');
});
}
+1 -1
View File
@@ -353,7 +353,7 @@
}).done( function (body) {
// Success
@this.statusType="success";
@this.statusText = {{ trans('general.success_redirecting') }};
@this.statusText = "{{ trans('general.success_redirecting') }}";
// console.dir(body)
window.location.href = body.messages.redirect_url;
}).fail( function (jqXHR, textStatus, error) {
+1 -1
View File
@@ -19,7 +19,7 @@
<label class="btn btn-default">
{{ trans('button.select_file') }}
<input type="file" name="file[]" multiple="true" class="js-uploadFile" id="uploadFile" data-maxsize="{{ Helper::file_upload_max_size() }}" accept="image/*,.csv,.zip,.rar,.doc,.docx,.xls,.xlsx,.xml,.lic,.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/plain,.pdf,application/rtf" style="display:none" required>
<input type="file" name="file[]" multiple="true" class="js-uploadFile" id="uploadFile" data-maxsize="{{ Helper::file_upload_max_size() }}" accept="image/*,.csv,.zip,.rar,.doc,.docx,.xls,.xlsx,.xml,.lic,.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/plain,.pdf,application/rtf,application/json" style="display:none" required>
</label>
</div>
@@ -10,7 +10,7 @@ $expires = Helper::getFormattedDateObject($asset->present()->warranty_expires, '
$diff = round(abs(strtotime($asset->present()->warranty_expires) - strtotime(date('Y-m-d')))/86400);
$icon = ($diff <= ($threshold / 2)) ? '🚨' : (($diff <= $threshold) ? '⚠️' : ' ');
@endphp
<tr><td>{{ $icon }} </td><td> <a href="{{ route('hardware.show', $asset->id) }}">{{ $asset->present()->name }}</a> </td><td> {{ $diff }} {{ trans('mail.Days') }} </td><td> {{ $expires['formatted'] }} </td><td> {{ ($asset->supplier ? e($asset->supplier->name) : '') }} </td><td> {{ ($asset->assignedTo ? e($asset->assignedTo->present()->name()) : '') }} </td></tr>
<tr><td>{{ $icon }} </td><td> <a href="{{ route('hardware.show', $asset->id) }}">{{ $asset->present()->name }}</a> </td><td> {{ $diff }} {{ trans('mail.Days') }} </td><td> {{ !is_null($expires) ? $expires['formatted'] : '' }} </td><td> {{ ($asset->supplier ? e($asset->supplier->name) : '') }} </td><td> {{ ($asset->assignedTo ? e($asset->assignedTo->present()->name()) : '') }} </td></tr>
@endforeach
</table>
@endcomponent
+6 -6
View File
@@ -1,14 +1,14 @@
@extends('layouts/setup')
{{ trans('admin/user/table.createuser') }}
{{ trans('admin/users/table.createuser') }}
@section('title')
{{ trans('admin/user/general.create_user') }} ::
{{ trans('admin/users/general.create_user') }} ::
@parent
@stop
{{-- Page content --}}
@section('content')
<p>{{ trans('admin/user/general.create_user_page_explanation') }}</p>
<p>{{ trans('admin/users/general.create_user_page_explanation') }}</p>
<form action="{{ route('setup.user.save') }}" method="POST">
{{ csrf_field() }}
@@ -156,10 +156,10 @@
<!-- Email credentials -->
<div class="form-group col-lg-12">
<label>{{ trans('admin/user/general.email_credentials') }}</label>
<label>{{ trans('admin/users/general.email_credentials') }}</label>
<div class="checkbox">
<label>
<input type="checkbox" value="1" name="email_creds">{{ trans('admin/user/general.email_credentials_text') }}
<input type="checkbox" value="1" name="email_creds">{{ trans('admin/users/general.email_credentials_text') }}
</label>
</div>
</div>
@@ -167,7 +167,7 @@
@stop
@section('button')
<button class="btn btn-primary">{{ trans('admin/user/general.next_save_user') }}</button>
<button class="btn btn-primary">{{ trans('admin/users/general.next_save_user') }}</button>
</form>
@parent
@stop