Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Inline markdown method #13288

Merged
merged 6 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ public static function parseEscapedMarkedown($str = null)
}
}

public static function parseEscapedMarkedownInline($str = null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we misspelled the original method as well but this should be Markdown and not Markedown 😅

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think that was a misspelling - Marked as in “this is marked down text”

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 huh...my mind went to the text having been "markdowned" but that doesn't really make sense

{
$Parsedown = new \Parsedown();
$Parsedown->setSafeMode(true);

if ($str) {
return $Parsedown->line($str);
}
}

/**
* The importer has formatted number strings since v3,
* so the value might be a string, or an integer.
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/AccessoriesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function transformAccessory(Accessory $accessory)
'model_number' => ($accessory->model_number) ? e($accessory->model_number) : null,
'category' => ($accessory->category) ? ['id' => $accessory->category->id, 'name'=> e($accessory->category->name)] : null,
'location' => ($accessory->location) ? ['id' => $accessory->location->id, 'name'=> e($accessory->location->name)] : null,
'notes' => ($accessory->notes) ? Helper::parseEscapedMarkedown($accessory->notes) : null,
'notes' => ($accessory->notes) ? Helper::parseEscapedMarkedownInline($accessory->notes) : null,
'qty' => ($accessory->qty) ? (int) $accessory->qty : null,
'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null,
'purchase_cost' => Helper::formatCurrencyOutput($accessory->purchase_cost),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/ActionlogsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function transformActionlog (Actionlog $actionlog, $settings = null)
'type' => e($actionlog->targetType()),
] : null,

'note' => ($actionlog->note) ? Helper::parseEscapedMarkedown($actionlog->note): null,
'note' => ($actionlog->note) ? Helper::parseEscapedMarkedownInline($actionlog->note): null,
'signature_file' => ($actionlog->accept_signature) ? route('log.signature.view', ['filename' => $actionlog->accept_signature ]) : null,
'log_meta' => ((isset($clean_meta)) && (is_array($clean_meta))) ? $clean_meta: null,
'action_date' => ($actionlog->action_date) ? Helper::getFormattedDateObject($actionlog->action_date, 'datetime'): Helper::getFormattedDateObject($actionlog->created_at, 'datetime'),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/AssetMaintenancesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function transformAssetMaintenance(AssetMaintenance $assetmaintenance)
'id' => (int) $assetmaintenance->asset->defaultLoc->id,
'name'=> e($assetmaintenance->asset->defaultLoc->name),
] : null,
'notes' => ($assetmaintenance->notes) ? Helper::parseEscapedMarkedown($assetmaintenance->notes) : null,
'notes' => ($assetmaintenance->notes) ? Helper::parseEscapedMarkedownInline($assetmaintenance->notes) : null,
'supplier' => ($assetmaintenance->supplier) ? ['id' => $assetmaintenance->supplier->id, 'name'=> e($assetmaintenance->supplier->name)] : null,
'cost' => Helper::formatCurrencyOutput($assetmaintenance->cost),
'asset_maintenance_type' => e($assetmaintenance->asset_maintenance_type),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/AssetModelsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function transformAssetModel(AssetModel $assetmodel)
'default_fieldset_values' => $default_field_values,
'eol' => ($assetmodel->eol > 0) ? $assetmodel->eol.' months' : 'None',
'requestable' => ($assetmodel->requestable == '1') ? true : false,
'notes' => Helper::parseEscapedMarkedown($assetmodel->notes),
'notes' => Helper::parseEscapedMarkedownInline($assetmodel->notes),
'created_at' => Helper::getFormattedDateObject($assetmodel->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($assetmodel->updated_at, 'datetime'),
'deleted_at' => Helper::getFormattedDateObject($assetmodel->deleted_at, 'datetime'),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/AssetsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function transformAsset(Asset $asset)
'id' => (int) $asset->supplier->id,
'name'=> e($asset->supplier->name),
] : null,
'notes' => ($asset->notes) ? Helper::parseEscapedMarkedown($asset->notes) : null,
'notes' => ($asset->notes) ? Helper::parseEscapedMarkedownInline($asset->notes) : null,
'order_number' => ($asset->order_number) ? e($asset->order_number) : null,
'company' => ($asset->company) ? [
'id' => (int) $asset->company->id,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/ComponentsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function transformComponent(Component $component)
'id' => (int) $component->company->id,
'name' => e($component->company->name),
] : null,
'notes' => ($component->notes) ? Helper::parseEscapedMarkedown($component->notes) : null,
'notes' => ($component->notes) ? Helper::parseEscapedMarkedownInline($component->notes) : null,
'created_at' => Helper::getFormattedDateObject($component->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($component->updated_at, 'datetime'),
'user_can_checkout' => ($component->numRemaining() > 0) ? 1 : 0,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/ConsumablesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function transformConsumable(Consumable $consumable)
'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost),
'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'),
'qty' => (int) $consumable->qty,
'notes' => ($consumable->notes) ? Helper::parseEscapedMarkedown($consumable->notes) : null,
'notes' => ($consumable->notes) ? Helper::parseEscapedMarkedownInline($consumable->notes) : null,
'created_at' => Helper::getFormattedDateObject($consumable->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'),
];
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/LicensesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function transformLicense(License $license)
'depreciation' => ($license->depreciation) ? ['id' => (int) $license->depreciation->id,'name'=> e($license->depreciation->name)] : null,
'purchase_cost' => Helper::formatCurrencyOutput($license->purchase_cost),
'purchase_cost_numeric' => $license->purchase_cost,
'notes' => Helper::parseEscapedMarkedown($license->notes),
'notes' => Helper::parseEscapedMarkedownInline($license->notes),
'expiration_date' => Helper::getFormattedDateObject($license->expiration_date, 'date'),
'seats' => (int) $license->seats,
'free_seats_count' => (int) $license->free_seats_count,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/SuppliersTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function transformSupplier(Supplier $supplier = null)
'licenses_count' => (int) $supplier->licenses_count,
'consumables_count' => (int) $supplier->consumables_count,
'components_count' => (int) $supplier->components_count,
'notes' => ($supplier->notes) ? Helper::parseEscapedMarkedown($supplier->notes) : null,
'notes' => ($supplier->notes) ? Helper::parseEscapedMarkedownInline($supplier->notes) : null,
'created_at' => Helper::getFormattedDateObject($supplier->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($supplier->updated_at, 'datetime'),

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Transformers/UsersTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function transformUser(User $user)
'id' => (int) $user->userloc->id,
'name'=> e($user->userloc->name),
] : null,
'notes'=> Helper::parseEscapedMarkedown($user->notes),
'notes'=> Helper::parseEscapedMarkedownInline($user->notes),
'permissions' => $user->decodePermissions(),
'activated' => ($user->activated == '1') ? true : false,
'autoassign_licenses' => ($user->autoassign_licenses == '1') ? true : false,
Expand Down
1 change: 1 addition & 0 deletions app/Presenters/AssetModelPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public static function dataTableLayout()
'switchable' => true,
'title' => trans('general.notes'),
'visible' => false,
'formatter' => 'notesFormatter',
],
[
'field' => 'created_at',
Expand Down
2 changes: 1 addition & 1 deletion resources/views/accessories/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class="table table-striped snipe-table"
</strong>
</div>
<div class="col-md-9">
{!! nl2br(e($accessory->notes)) !!}
{!! nl2br(Helper::parseEscapedMarkedownInline($accessory->notes)) !!}
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/asset_maintenances/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<div class="row">
<div class="col-md-12 col-sm-12" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
<strong>{{ trans('admin/asset_maintenances/form.notes') }}: </strong>
{{ $assetMaintenance->notes }}
{!! nl2br(Helper::parseEscapedMarkedownInline($assetMaintenance->notes)) !!}
</div>
</div>
<!-- 5th Row End -->
Expand Down
4 changes: 2 additions & 2 deletions resources/views/consumables/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class="table table-striped snipe-table"

<td>
@if ($file->note)
{{ $file->note }}
{!! nl2br(Helper::parseEscapedMarkedownInline($file->note)) !!}
@endif
</td>
<td>
Expand Down Expand Up @@ -275,7 +275,7 @@ class="table table-striped snipe-table"
</strong>
</div>
<div class="col-md-12">
{!! nl2br(e($consumable->notes)) !!}
{!! nl2br(Helper::parseEscapedMarkedownInline($consumable->notes)) !!}
</div>
</div>
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/hardware/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@
</strong>
</div>
<div class="col-md-6">
{!! nl2br(e($asset->notes)) !!}
{!! nl2br(Helper::parseEscapedMarkedownInline($asset->notes)) !!}
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/licenses/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
</strong>
</div>
<div class="col-md-9">
{!! nl2br(e($license->notes)) !!}
{!! nl2br(Helper::parseEscapedMarkedownInline($license->notes)) !!}
</div>
</div>
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/suppliers/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class="table table-striped snipe-table"
@endif

@if ($supplier->notes!='')
<li><i class="fa fa-comment"></i> {{ $supplier->notes }}</li>
<li><i class="fa fa-comment"></i> {!! nl2br(Helper::parseEscapedMarkedownInline($supplier->notes)) !!}</li>
@endif

</ul>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/users/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@
{{ trans('admin/users/table.notes') }}
</div>
<div class="col-md-9">
{{ $user->notes }}
{!! nl2br(Helper::parseEscapedMarkedownInline($user->notes)) !!}
</div>

</div>
Expand Down