adds Field offset option to labels

This commit is contained in:
Godfrey M
2025-04-22 10:50:20 -07:00
committed by snipe
parent 511be74e74
commit 93489529a3
5 changed files with 67 additions and 2 deletions

View File

@@ -771,6 +771,7 @@ class SettingsController extends Controller
$setting->label2_2d_type = $request->input('label2_2d_type');
$setting->label2_2d_target = $request->input('label2_2d_target');
$setting->label2_fields = $request->input('label2_fields');
$setting->label2_empty_row_count = $request->input('label2_empty_row_count');
$setting->labels_per_page = $request->input('labels_per_page');
$setting->labels_width = $request->input('labels_width');
$setting->labels_height = $request->input('labels_height');

View File

@@ -190,9 +190,28 @@ class Label implements View
return $toAdd ? $myFields->push($toAdd) : $myFields;
}, new Collection());
$assetData->put('fields', $fields->take($template->getSupportFields()));
$emptyRowsCount = $settings->label2_empty_row_count;
if($emptyRowsCount) {
// Create empty rows
$emptyRows = collect(range(1, $emptyRowsCount))->map(function () {
return [
'label' => '',
'value' => '',
'dataSource' => null,
];
});
// Prepend empty rows to the existing fields
$fieldsWithEmpty = $emptyRows->merge($fields);
$assetData->put('fields', $fieldsWithEmpty->take($template->getSupportFields()));
return $assetData;
}
else{
$assetData->put('fields', $fields->take($template->getSupportFields()));
return $assetData;
}
return $assetData;
});
if ($template instanceof Sheet) {

View File

@@ -0,0 +1,21 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('settings', function (Blueprint $table) {
$table->unsignedInteger('label2_empty_row_count')->default(0)->after('label2_fields');
});
}
public function down(): void
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('label2_empty_row_count');
});
}
};

View File

@@ -64,6 +64,8 @@ return [
'enabled' => 'Enabled',
'eula_settings' => 'EULA Settings',
'eula_markdown' => 'This EULA allows <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>.',
'empty_row_count' => 'Field Start Offset (Empty Rows)',
'empty_row_count_help' => 'Fields will begin populating after this many empty rows are skipped at the top of the label.',
'favicon' => 'Favicon',
'favicon_format' => 'Accepted filetypes are ico, png, and gif. Other image formats may not work in all browsers.',
'favicon_size' => 'Favicons should be square images, 16x16 pixels.',

View File

@@ -313,6 +313,28 @@
<p class="help-block">{{ trans('admin/settings/general.label2_2d_target_help') }}</p>
</div>
</div>
<!-- Title -->
<div class="form-group{{ $errors->has('label2_empty_row_count') ? ' has-error' : '' }}">
<div class="col-md-3 text-right">
<label for="label2_empty_row_count" class="control-label">{{trans('admin/settings/general.empty_row_count')}}</label>
</div>
<div class="form-group row">
<div class="col-md-2">
<input
class="form-control"
aria-label="Empty Row Count"
name="label2_empty_row_count"
type="number"
id="label2_empty_row_count"
min="0"
value="{{ old('label2_empty_row_count', $setting->label2_empty_row_count) }}">
</div>
<div class="col-md-7">
{!! $errors->first('empty_row_count', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
<p class="help-block">{!! trans('admin/settings/general.empty_row_count_help') !!}</p>
</div>
</div>
</div>
<div class="col-md-9 col-md-offset-3" style="margin-bottom: 10px;">
@include('partials.label2-preview')
</div>