Skip to content

A free open source IT asset/license management system

remove unnecessary code, update label edit to pull from config

Godfrey Mf89a9e921c42
diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.php
index 76b85eef3f..486c64e16c 100755
--- a/app/Http/Controllers/LabelsController.php
+++ b/app/Http/Controllers/LabelsController.php
@@ -19,6 +19,7 @@ use Illuminate\Validation\Rule;
use App\Models\Labels\RectangleSheet;
use App\Models\Labels\LabelPreviewAsset;
use App\Models\Labels\LabelGeometryRules;
+use App\Models\Labels\CustomLabelFonts;
class LabelsController extends Controller
{
@@ -430,38 +431,28 @@ class LabelsController extends Controller
public function customLabelPreview(Request $request, string $labelName)
{
+ $request->validate([
+ 'content.tag_font' => ['nullable', 'string', Rule::in(CustomLabelFonts::ALLOWED),],
+ 'content.title_font' => ['nullable', 'string', Rule::in(CustomLabelFonts::ALLOWED),],
+ 'content.field_label_font' => ['nullable', 'string', Rule::in(CustomLabelFonts::ALLOWED),],
+ 'content.field_value_font' => ['nullable', 'string', Rule::in(CustomLabelFonts::ALLOWED),],
+ ]);
$labelName = str_replace('/', '\\', $labelName);
- $customLabel = null;
-
- if (str_starts_with($labelName, 'custom:')) {
- $customLabelId = (int)str_replace('custom:', '', $labelName);
-
- $customLabel = CustomUserLabel::find($customLabelId);
- }
$baseTemplate = match (true) {
- $customLabel !== null => null,
$labelName === 'DefaultLabel' => new DefaultLabel,
$labelName === 'StandardTape' => null,
default => Label::find($labelName),
};
- $isTape = $customLabel
- ? $customLabel->type === 'tape'
- : (
+ $isTape =
$request->input('type') === 'tape'
|| str_starts_with($labelName, 'Tapes\\')
- || $labelName === 'StandardTape'
- );
-
- if ($customLabel) {
- $editorConfig = $customLabel->config_snapshot;
- } else {
- $editorConfig = [
- 'content' => $request->input('content', []),
- 'supports' => $request->input('supports', []),
- ];
- }
+ || $labelName === 'StandardTape';
+ $editorConfig = [
+ 'content' => $request->input('content', []),
+ 'supports' => $request->input('supports', []),
+ ];
if ($isTape) {
$editorConfig['dimensions'] = $request->input('dimensions', []);
$template = new PreviewTapeLabel;
diff --git a/app/Models/Labels/Sheets/Avery/_5267.php b/app/Models/Labels/Sheets/Avery/_5267.php
index 20b33578d6..51a59ee4f4 100644
--- a/app/Models/Labels/Sheets/Avery/_5267.php
+++ b/app/Models/Labels/Sheets/Avery/_5267.php
@@ -51,8 +51,8 @@ abstract class _5267 extends RectangleSheet
$columnSpacingPt = self::COLUMN2_X - self::COLUMN1_X - self::LABEL_W;
$this->columnSpacing = Helper::convertUnit($columnSpacingPt, 'pt', $this->getUnit());
- $rowSpacingPt = self::ROW2_Y - self::ROW1_Y - self::LABEL_H;
- $this->rowSpacing = Helper::convertUnit($rowSpacingPt, 'pt', $this->getUnit());
+// $rowSpacingPt = self::ROW2_Y - self::ROW1_Y - self::LABEL_H;
+ $this->rowSpacing = 0;
$this->labelWidth = Helper::convertUnit(self::LABEL_W, 'pt', $this->getUnit());
$this->labelHeight = Helper::convertUnit(self::LABEL_H, 'pt', $this->getUnit());
diff --git a/resources/views/settings/label-edit.blade.php b/resources/views/settings/label-edit.blade.php
index 8c66ca4dec..c09d2910aa 100644
--- a/resources/views/settings/label-edit.blade.php
+++ b/resources/views/settings/label-edit.blade.php
@@ -153,7 +153,7 @@
type="text"
name="name"
class="form-control"
- value="{{ old('name', data_get($importedConfig ?? [], 'name', $defaultName)) }}"
+ value="{{ old('name', data_get($config ?? [], 'name', $defaultName)) }}"
placeholder="Enter label name"
style="max-width: 320px;"
>