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

feature: add button delete page view asset #13065

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 32 additions & 0 deletions resources/assets/js/snipeit.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,46 @@ var baseUrl = $('meta[name="baseUrl"]').attr('content');
};
};

// confirm delete modal single
Components.modals.confirmDeleteSingle = function () {
var $el = $(document);

var events = {
'click': function (evnt) {
var $context = $(this);
var $dataConfirmModal = $('#dataConfirmModal');
var href = $context.attr('href');
var message = $context.attr('data-content');
var title = $context.attr('data-title');

$('#myModalLabel').text(title);
$dataConfirmModal.find('.modal-body').text(message);
$('#deleteForm').attr('action', href);
$dataConfirmModal.modal({
show: true
});
return false;
}
};

var render = function () {
$el.on('click', '.delete-asset-single', events['click']);
};

return {
render: render
};
};


/**
* Application start point
* Component definition stays out of load event, execution only happens.
*/
$(function() {
new Components.modals.confirmRestore().render();
new Components.modals.confirmDelete().render();
new Components.modals.confirmDeleteSingle().render();
});
}(jQuery, window.snipeit.settings));

Expand Down
13 changes: 13 additions & 0 deletions resources/views/hardware/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@
</a>
</li>
@endcan

@can('delete', \App\Models\Asset::class)
@if ($asset->deleted_at == '' && $asset->assigned_to == '')
<li role="menuitem">
<a href="{{ route('hardware.destroy', $asset->id) }}" class="delete-asset-single"
data-content="{{ trans('general.sure_to_delete') }}@if ($asset->name) {{ $asset->name }} @else {{ $asset->asset_tag }} @endif?"
data-title="{{ trans('general.delete') }}" onClick="return false;">
{{ trans('general.delete') }}
</a>
</li>
@endif
@endcan

</ul>
</div>
@endif
Expand Down